Ios 苹果支付;“未完成付款”使用条纹

Ios 苹果支付;“未完成付款”使用条纹,ios,node.js,express,stripe-payments,payment,Ios,Node.js,Express,Stripe Payments,Payment,我正在使用“付款请求按钮”为我的网站实现Apple Pay。在这方面,一切都很好。当我在条带日志中验证时,令牌被正确地传递。 然而,每次我尝试完成测试付款时,我都会从Apple Pay收到一条错误消息:“付款未完成” 这让我陷入困境,我不知道如何调试或修复。有什么想法吗 我得到一个未定义的令牌 这就是错误: 我的设置: 前端: <script src="https://js.stripe.com/v3/"></script> <div id="payment-r

我正在使用“付款请求按钮”为我的网站实现Apple Pay。在这方面,一切都很好。当我在条带日志中验证时,令牌被正确地传递。

然而,每次我尝试完成测试付款时,我都会从Apple Pay收到一条错误消息:“付款未完成”

这让我陷入困境,我不知道如何调试或修复。有什么想法吗

我得到一个未定义的令牌

这就是错误:

我的设置:

前端:

<script src="https://js.stripe.com/v3/"></script>
<div id="payment-request-button">
  <!-- A Stripe Element will be inserted here. -->
</div>



<script>
var stripe = Stripe('pk_test_xxxxx');

var paymentRequest = stripe.paymentRequest({
  country: 'US',
  currency: 'usd',
  total: {
    label: 'JobQuiz',
    amount: 999,
  },
  requestPayerName: true,
  requestPayerEmail: false,
});


var elements = stripe.elements();
var prButton = elements.create('paymentRequestButton', {
  paymentRequest: paymentRequest,
});

// Check the availability of the Payment Request API first.
paymentRequest.canMakePayment().then(function(result) {
  if (result) {
    prButton.mount('#payment-request-button');
  } else {
    document.getElementById('payment-request-button').style.display = 'none';
  }
});

   paymentRequest.on('token', function(ev) {
  // Send the token to your server to charge it!
    fetch('/apple-pay', {
    method: 'POST',
    body: JSON.stringify({token: ev.token.id}),
    headers: {'content-type': 'application/json'},
  })
  .then(function(response) {
    if (response.ok) {
      // Report to the browser that the payment was successful, prompting
      // it to close the browser payment interface.
      ev.complete('success');
    } else {
      // Report to the browser that the payment failed, prompting it to
      // re-show the payment interface, or show an error message and close
      // the payment interface.
      ev.complete('fail');
    }
  });
});

</script>

终于解决了这个问题。这最终成为我的bodyParser设置的一个问题。这解释了为什么令牌被传递为空。我忽略了包含app.use(bodyParser.json())
;下面

app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());

你能澄清错误吗?它是出现在Apple Pay modal中,还是后来出现在Stripe中?这个流程在我看来是正确的。在手机上,在apple pay,我没有得到指示支付成功的复选标记,而是得到了一个“支付未完成”错误。有没有想法@korben?你需要实际设置一个端点来接受apple pay在
/charges
创建的令牌,该令牌使用该令牌来创建费用()@korben-谢谢!!!你能告诉我如何正确使用node吗?
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());