1

我已经将 JMSPaymentBundle 与 paypal 集成在一起,一切正常!当我尝试使用JMS 的此链接更改条带 并使用github 的ruudk/PaymentStripeBundle时,实际上是相同的。

但有一件事。我收到此错误:源参数是必需的

在bundle的issues中,我发现我必须使用条带形式

<form action="" 
method="POST">
 <script
  src="https://checkout.stripe.com/checkout.js" class="stripe-button"
   data-key="MYPUBLISHEDKEY"
   data-amount="999"
   data-name="Demo Site"
   data-description="Widget"
   data-image="https://stripe.com/img/documentation/checkout/marketplace.png"
   data-locale="auto">
 </script>
</form>

此表单生成一个 Token。我需要知道的是:

1- 将 JMSPaymentBundle 使用的已发布令牌放在哪里?

2- 我应该在表格中执行什么操作?paypal也一样吗?

4

1 回答 1

0

很难说这里发生了什么,但似乎https://github.com/ruudk/PaymentStripeBundle/缺少一些必要的文档。

据我所知,它token在您的表单中添加了一个隐藏字段: https ://github.com/ruudk/PaymentStripeBundle/blob/master/src/Form/CheckoutType.php#L12

但是,您使用的 Checkout 嵌入代码不会将令牌保存到该字段。我没有看到这个库中嵌入了任何额外的 Javascript,所以你需要使用自定义的 Stripe Checkout 集成来构建自己的:

https://stripe.com/docs/checkout#integration-custom

像这样的东西应该工作:

var handler = StripeCheckout.configure({
  key: 'pk_test_6pRNASCoBOKtIshFeQd4XMUh',
  image: 'https://stripe.com/img/documentation/checkout/marketplace.png',
  locale: 'auto',
  token: function(token) {
      // NOTE: assuming that the field injected by the library has an ID of "token"--you'll have to check your DOM and possibly adjust this
      var field = document.getElementById('token');
      field.value = token.id;

      // TODO: submit form and send to your backend
  }
});

document.getElementById('customButton').addEventListener('click', function(e) {
  // Open Checkout with further options:
  handler.open({
    name: 'Stripe.com',
    description: '2 widgets',
    zipCode: true,
    amount: 2000
  });
  e.preventDefault();
});

// Close Checkout on page navigation:
window.addEventListener('popstate', function() {
  handler.close();
});
于 2017-09-24T19:45:51.350 回答