【问题标题】:React Stripe multiple transactionReact Stripe 多笔交易
【发布时间】:2021-04-22 09:50:38
【问题描述】:

当用户填写卡信息并单击提交按钮时,我想对所有连接的帐户实施直接收费。 这是 Stripe 提供者。

  <Elements stripe={stripePromise}>
  {
    stripePromise && (
    <CheckoutForm
    />
    )
  }

</Elements>

当提交按钮点击时调用。

  const handleStripeSubmit = async (payment_intents, publishableKey, values) => {

for (const intentItem of payment_intents) {

  const stripeloaded =await loadStripe(publishableKey, {
    stripeAccount: intentItem.stripeAccount
  });

  const loadResult = await stripeloaded.confirmCardPayment(intentItem.clientSecret, {
    payment_method: {
      card: elements.getElement(CardNumberElement),
      billing_details: {
        name: 'Jenny Rosen',
      },
    }
  });

  // setStripe(useStripe);
  if (!stripe || !elements) {
    // Stripe.js has not yet loaded.
    // Make sure to disable form submission until Stripe.js has loaded.
    // return;
  }
  const result = await stripe.confirmCardPayment(intentItem.clientSecret, {
    payment_method: {
      card: elements.getElement(CardNumberElement),
      billing_details: {
        name: 'Jenny Rosen',
      },
    }
  });
  if (result.error) {
    // Show error to your customer (e.g., insufficient funds)
    window.alert(result.error.message);
  } else if (result.paymentIntent.status === 'succeeded') {
    // The payment has been processed!
    window.alert('success');

  }
}

React 钩子值 stripe 仅表示 Stripe 提供者 loadStripe 连接帐户 id。 由于 loadStripe 是一个承诺,我尝试了 loadStripe 返回值,但它也会出错。

const stripeloaded =await loadStripe(publishableKey, {
    stripeAccount: intentItem.stripeAccount
  });

  const loadResult = await stripeloaded.confirmCardPayment(intentItem.clientSecret, {
    payment_method: {
      card: elements.getElement(CardNumberElement),
      billing_details: {
        name: 'Jenny Rosen',
      },
    }
  });

有没有人有一个关于批量付款确认的好主意?

【问题讨论】:

    标签: reactjs stripe-payments


    【解决方案1】:

    有两种方法可以将付款应用到多个关联的帐户。 使用多个直接收费交易并转移到关联的帐户。

    在多笔交易中,我们必须保存卡信息,以便创建新客户并将客户克隆到关联的帐户(它有效。)

    使用转帐连接账户,请参考stripe separate和destination charge。

    【讨论】:

      猜你喜欢
      • 2016-03-17
      • 2012-02-18
      • 1970-01-01
      • 2018-10-03
      • 1970-01-01
      • 2013-10-28
      • 2013-08-15
      • 2022-11-02
      • 2019-07-16
      相关资源
      最近更新 更多