【问题标题】:Cloning PaymentMethods from the Platform to Connected Accounts将 PaymentMethods 从平台克隆到关联账户
【发布时间】:2021-08-01 06:35:24
【问题描述】:

我在标准帐户中使用 Stripe。

我在平台上保存客户和支付方法,因此,在客户端,客户选择支付方法并将其发送到服务器。因此,在服务器端,我将 PaymentMethod 克隆到将接收付款的 Connected Account。我的服务器端代码如下所示

RequestOptions requestOptions = RequestOptions.builder()
    .setStripeAccount("{{CONNECTED_STRIPE_ACCOUNT_ID}}")
    .build();

PaymentMethodCreateParams paramsClone = PaymentMethodCreateParams.builder()
    .setCustomer("cus_1")//Id of the customer in the platform
    .setPaymentMethod("payment_method_id")//One of the payment methods of the cus_1
    .build();

PaymentMethod newPaymentMethod = PaymentMethod.create(paramsClone, requestOptions);

此时我假设这个新的 newPaymentMethod 在已连接的帐户中,对吧?

那么,我创建一个 PaymentIntent

PaymentIntentCreateParams params = PaymentIntentCreateParams.builder()
    .setAmount(100)
    .setPaymentMethod(newPaymentMethod.getId())
    .setCurrency("usd")
    .setApplicationFeeAmount(10)
    .build();

PaymentIntent paymentIntent = PaymentIntent.create(params, requestOptions);

此时一切似乎都很好。付款意图返回条纹client secret,如'pi_1Ipfl3Bf0KWukpZWQdbAzoz1_secret_RAKsPMLpyhkDJ7q8N1VvSmaoR'status'requires_confirmation'。所以,当我尝试在客户端确认时,它会抛出一个错误:No such payment_intent: 'pi_1Ipfl3Bf0KWukpZWQdbAzoz1'

我认为这与在我的平台和连接的帐户之间进行切换有关,但我无法弄清楚确切的问题是什么。我正在关注这个https://stripe.com/docs/connect/cloning-customers-across-accounts 和这个https://stripe.com/docs/payments/payment-methods/connect#cloning-payment-methods,但我仍然不知道如何让它工作。

有人能解释一下吗?问候!

【问题讨论】:

    标签: java stripe-payments


    【解决方案1】:

    您的服务器端步骤是正确的,您正在在 Connect 帐户上创建 PaymentIntent。

    您缺少客户端的是,由于 PaymentIntent 存在于 Connect 帐户上,因此您的 Stripe.js/mobile SDK 也需要作为 Connect 帐户进行身份验证。

    你基本上需要在你的客户端指定这个:

    var stripe = Stripe('{{PLATFORM_PUBLISHABLE_KEY}}', {
      stripeAccount: '{{CONNECTED_STRIPE_ACCOUNT_ID}}',
    });
    

    https://stripe.com/docs/connect/authentication#adding-the-connected-account-id-to-a-client-side-application

    由于我假设您已经将 Stripe.js 验证为您的平台可发布密钥(为了在平台上创建第一个 PaymentMethod 以进行克隆),您必须在您的客户端上创建第二个 Stripe.js 实例,一个作为 Connect 帐户进行身份验证。

    【讨论】:

    • 这就是问题所在。我几分钟前才想通!谢谢!!
    【解决方案2】:

    好吧,最后我在客户端解决了它。我只需要让 Stripe 代表关联账户进行确认。在 react native 中使用tipsi-stripe 是这样的:

    stripe.setStripeAccount('acct_XYZ');//Set the connected account
    stripe.confirmPaymentIntent({ clientSecret: stripeClientSecret })
    .then((cofirmResponse) => {
        stripe.setStripeAccount(null);//Reset the connected account
        ...
    }).catch((e) => { 
        stripe.setStripeAccount(null);//Reset the connected account
        ...
    });
    

    【讨论】:

      猜你喜欢
      • 2016-11-30
      • 2022-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-26
      • 2016-12-04
      • 2019-08-05
      • 1970-01-01
      相关资源
      最近更新 更多