Stripe React Native - 如何使用“IntentConfiguration”保存付款方式(在创建意图之前收集付款详细信息)_

问题描述 投票:0回答:1

我正在按照指南在创建意图之前获取付款详细信息。

https://docs.stripe.com/ payments/accept-a- payment-deferred?platform=react-native&type= payment&integration= paymentsheet#react-native-setup

我似乎找不到保存付款方式的方法。我有两种类型的用户。进行订阅的用户和进行一次性付款的用户。两者都使用初始付款意图。

订阅用户付款不会保存,因为意向配置需要

setupFutureUsage='OffSession
。常规付款意图不会使用任何“setupFutureUsage”枚举或缺少枚举来保存卡。


这是我的 initPaymentSheet():

const { error } = await initPaymentSheet({
        customerId: customer,
        customerEphemeralKeySecret: ephemeralKeySecret,
        merchantDisplayName: 'Parket',
        intentConfiguration: {
            mode: {
                amount: checkoutData.totalInCents,
                currencyCode: 'USD',
            },
            captureMethod: 'Manual',
            confirmHandler: (paymentMethod, shouldSavePaymentMethod, intentCreationCallback) => handleCheckout({ checkoutData, paymentMethod, shouldSavePaymentMethod, intentCreationCallback }),
        },
    })

# Create a payment intent based on the configuration of initPaymentSheet() 
# Attach customer_id which provides a payment methods to PaymentIntent Object (PI) | https://docs.stripe.com/payments/paymentintents/lifecycle
# Add metadata, used by our Stripe Listener uses identify linked document
def HandleCreatePaymentIntent(customer_id, total_in_cents, metadata):
    payment_intent = stripe.PaymentIntent.create(
            amount=total_in_cents,
            currency='usd',
            customer=customer_id,
            capture_method='manual',
            metadata=metadata,
            setup_future_usage="on_session",
            automatic_payment_methods={"enabled": True},
        )

    # Return { payment_intent.client_secret } to the client : intentCreationCallback() confirms it on client-side
    # Set { payment_intent.id } in created booking
    return payment_intent.client_secret, payment_intent.id

我验证了我传递到付款表的客户和临时密钥。

react-native stripe-payments
1个回答
0
投票

订阅用户付款不会保存,因为意图配置需要 setupFutureUsage='OffSession。常规付款意图不会使用任何“setupFutureUsage”枚举或缺少枚举来保存卡。

如果您在

付款意图
上设置setup_future_usage,它肯定应该保存付款方式并将其附加到客户。只要成功确认付款意向,您就应该能够列出附加到客户的所有付款方式,并查看该列表中包含的新付款方式。对于订阅,如果您使用
collection_method: charge_automatically
创建订阅,则应自动为您创建已设置
setup_future_usage
的付款意向。您可以通过创建订阅并展开
latest_invoice.payment_intent
以查看所创建的基础付款意图来进行仔细检查。

看起来您在 React Native 代码中确实缺少客户端的一件事。您应该将

setupFutureUsage
(请参阅 docs)添加到您要传递给
IntentConfiguration.Mode
initPaymentSheet()
。这很重要,因为设置
setupFutureUsage
客户端将过滤掉与付款表 UI 中的未来付款不兼容的付款方式类型。

© www.soinside.com 2019 - 2024. All rights reserved.