问题描述
问题是什么?
我正在尝试通过付款方式ID和客户在PHP中创建单一费用:https://stripe.com/docs/api/charges/create
我已成功检索单笔付款方式的付款方式ID
cardButton.addEventListener('click',(e) => {
stripe.createPaymentMethod(
"card",cardElement,{
billing_details: {
name: cardHolderName.value
}
}
).then(function(result) {
//Payment Method id retrieved here...
});
});
我有条带化的客户ID,也有条带化的付款方式ID。
这与订阅无关...
根据文档,没有付款方式属性。我将如何传递此信息?
解决方法
Charges API(https://stripe.com/docs/api/charges/create)不不支持传递PaymentMethod对象-它是一个较旧的API(https://stripe.com/docs/payments/legacy-apis),您通常不会在新的集成中使用它今天。
相反,您将使用在后端使用PaymentIntent获得的PaymentMethod。例如:
https://stripe.com/docs/payments/accept-a-payment-synchronously
if data['payment_method_id']
# Create the PaymentIntent
intent = Stripe::PaymentIntent.create(
payment_method: data['payment_method_id'],# from frontend
amount: 1099,currency: 'usd',confirmation_method: 'manual',confirm: true,)
# check intent.status for next steps...