【问题标题】:Error handling for custom stripe checkout自定义条带结帐的错误处理
【发布时间】:2017-10-09 06:26:52
【问题描述】:

我正在处理自定义条带集成(网关)。如果我使用信用卡/借记卡付款,我会从这个 url https://api.stripe.com/v1/tokens 获得带有令牌 ID 的成功 json 响应。但是对于无效的 cvc,我没有收到任何错误响应。我从这个 url https://api.stripe.com/v1/tokens 签入网络我收到错误响应。但在程序中我不知道从哪里得到这个响应。请帮助我,我被困在这里。

这是我的代码

var handler = StripeCheckout.configure({
  key: 'pk_test_mXJ6f6GEBqPLjz3GfgDjZ8ig',
  image: 'https://stripe.com/img/documentation/checkout/marketplace.png',
  locale: 'auto',
  token: function(token) {
    // You can access the token ID with `token.id`.
    // Get the token ID to your server-side code for use.
  }
});

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

// Close Checkout on page navigation:
window.addEventListener('popstate', function() {
  handler.close();
});

【问题讨论】:

  • 我认为 Stripe 会自行处理错误。它没有告诉您有关 CVC 错误,因为没有必要:错误会显示给用户,当用户输入正确的 CVC 代码时,您将收到令牌。

标签: javascript stripe-payments


【解决方案1】:

Checkout 向发卡行验证卡信息。如果信息无效,则会在弹出表单中直接向客户显示错误,并且不会创建令牌,即使用自定义集成时,不会调用 token 回调函数。

【讨论】:

  • 为什么 checkout.js 会这样做,但元素却不会:(
猜你喜欢
  • 1970-01-01
  • 2016-08-19
  • 2019-05-31
  • 1970-01-01
  • 2023-03-18
  • 2018-04-27
  • 2018-10-12
  • 2013-02-12
  • 2011-01-29
相关资源
最近更新 更多