Stripe 获取 Apple Pay 令牌以创建客户 - 网络

Stripe get Apple Pay token to create a customer - web

有没有办法在不向用户收费的情况下获取apple pay支付方式id?现在我一直在尝试对第 5 步进行一些修改:https://stripe.com/docs/stripe-js/elements/payment-request-button,但我似乎只能在确认付款后才能获取付款方式 ID。

您在页面上收听 PaymentRequest 的 paymentmethod 事件,如下所示:https://stripe.com/docs/stripe-js/elements/payment-request-button#html-js-complete-payment

该示例使用 ev.paymentMethod.id 来确认 PaymentIntent,但您可以选择不这样做,而是 post 向您的服务器发送 PaymentMethod 令牌并以其他方式使用它(例如附加到客户并在订阅中使用)。

确保使用 success/fail 适当地调用 ev.complete(),以便付款 sheet 关闭并向客户发送正确的消息。