使用JS库Stripe V3,我使用方法stripe.createPaymentMethod()
收集付款信息。我正在尝试通过它传递元数据。
根据文档(https://stripe.com/docs/stripe-js/reference#stripe-create-payment-method),该方法的最后一个参数可以是包含帐单明细和元数据的对象。因此,需要在该对象(https://stripe.com/docs/api/payment_methods/create)中使用键“ billing_details”和“元数据”。
验证付款后,帐单详细信息将显示在Stripe仪表板中,而不是元数据。
元数据必须是“一组可以附加到对象上的键/值对。”,所以我看不出我的代码有什么问题:
stripe.createPaymentMethod('card', cardNumber, {
billing_details: {
"address": {
[...]
},
"email": 'XXX',
"name": 'XXX',
"phone": 'XXX'
},
metadata: {
"numero": 'XXX' ,
"affectation": "XXX"
}
}).then(function(result) {
[...]
})
我设法在后端使用方法\Stripe\PaymentIntent::create()
来做到这一点,所以奇怪的是,它在前端不起作用!参见下面的代码:
$intent = \Stripe\PaymentIntent::create([
'payment_method' => $payment_method_id,
'amount' => $payment_amount * 100,
'currency' => 'eur',
'confirmation_method' => 'manual',
'confirm' => true,
'description' => $payment_desc,
'metadata' => [
'affectation' => $payment_project,
'numero' => $payment_phone
]
]);
谢谢!