我正在与 Stripe Payment Gateway 集成 - 最新版本的 API。
除了“client_reference_id”没有传递给 webhook 或事务(没有出现在日志中)之外,这一切都在工作 - 我需要它来更新数据库中的订单。
我的代码是:
$session = \Stripe\Checkout\Session::create([
'billing_address_collection' => 'required',
'payment_method_types' => ['card'],
'line_items' => [[
'amount' => 1011,
'currency' => 'GBP',
'name' => 'Purchase',
'description' => 'test',
'quantity' => 1,
]],
'client_reference_id' => 'TEST1111223',
'mode' => 'payment',
'success_url' => 'https://example.com/success',
'cancel_url' => 'https://example.com/cancel'
]);
Run Code Online (Sandbox Code Playgroud)
根据文档,应该通过:https://stripe.com/docs/api/checkout/sessions/create
难道我做错了什么?
其他人问了同样的问题但没有得到回答:“client_reference_id”参数未传递
小智 10
customer.created该活动举办是有意义的client_reference_id。然而事实并非如此!它确实出现在checkout.session.completed事件中。
下面是对象详细信息
Stripe\Event Object
(
[id] => evt_1KCO7....dffL4wc0
[object] => event
[api_version] => 2020-08-27
[created] => 1640868753
[data] => Stripe\StripeObject Object
(
[object] => Stripe\Checkout\Session Object
(
[id] => cs_test_a1A....NhSTmvD
[object] => checkout.session
[after_expiration] =>
[allow_promotion_codes] =>
[amount_subtotal] => 15000
[amount_total] => 15000
[automatic_tax] => Stripe\StripeObject Object
(
[enabled] =>
[status] =>
)
[billing_address_collection] =>
[cancel_url] => http://example.org/cancel
[client_reference_id] => 3181234
[consent] =>
[consent_collection] =>
[currency] => usd
[customer] => cus_Ks8...bT
[customer_details] => Stripe\StripeObject Object
(
[email] => user@exmaple.org
[phone] =>
[tax_exempt] => none
[tax_ids] => Array
(
)
)
[customer_email] => user@exmaple.org
[expires_at] => 1640955127
[livemode] =>
[locale] =>
[metadata] => Stripe\StripeObject Object
(
)
[mode] => payment
[payment_intent] => pi_3K...1p2sJ
[payment_method_options] => Array
(
)
[payment_method_types] => Array
(
[0] => card
)
[payment_status] => paid
[phone_number_collection] => Stripe\StripeObject Object
(
[enabled] =>
)
[recovered_from] =>
[setup_intent] =>
[shipping] =>
[shipping_address_collection] =>
[shipping_options] => Array
(
)
[shipping_rate] =>
[status] => complete
[submit_type] =>
[subscription] =>
[success_url] => http://exmaple.org/success
[total_details] => Stripe\StripeObject Object
(
[amount_discount] => 0
[amount_shipping] => 0
[amount_tax] => 0
)
[url] =>
)
)
[livemode] =>
[pending_webhooks] => 2
[request] => Stripe\StripeObject Object
(
[id] =>
[idempotency_key] =>
)
[type] => checkout.session.completed
)
Run Code Online (Sandbox Code Playgroud)
如果您在结帐时通过了它,那么customer.created您确实会得到客户email。您还可以使用它将其连接回您的客户,而无需client_reference_id. 我检查这两个事件,并在第一次成功的机会时使用条带客户 ID 更新数据库。
小智 0
用于引用结帐会话的唯一字符串。这可以是客户 ID、购物车 ID 或类似内容。它包含在 checkout.session.completed webhook 中,可用于完成购买。
来源https://stripe.com/docs/js/checkout/redirect_to_checkout
| 归档时间: |
|
| 查看次数: |
13307 次 |
| 最近记录: |