我正努力用Flutter和Stripe进行3D安全付款。
创建客户后,我要检索其付款方式。
$customer = \Stripe\Customer::retrieve($user->stripe_id);
然后,我使用该付款选项创建“付款意图”:
$intent = \Stripe\PaymentIntent::create([
'payment_method' => $customer->default_source,
'amount' => 1234,
'currency' => 'eur',
'customer' => $user->stripe_id,
'confirmation_method' => 'manual',
'confirm' => true,
]);
现在在Stripe Dashboard中,它表示客户必须确认交易。
然后我这样做:
$intent->confirm();
产生以下响应:
{
"id": "pi_1FxKveJNLhWWsjuJHdXC5tj7",
"object": "payment_intent",
"last_payment_error": "",
"livemode": "",
"next_action": {
"type": "use_stripe_sdk",
"use_stripe_sdk": {
"type": "three_d_secure_redirect",
"stripe_js": "https://hooks.stripe.com/redirect/authenticate/src_1FxKveJNjuJR4F2WkUA?client_secret=src_client_secret_GUJY8uSC9RbPhANkz7",
"source": "src_1FxKveJNLhWWsjuJR4F2WkUA",
"known_frame_issues": "false"
}
},
"status": "requires_action",
接下来我该怎么做才能使付款成功?导航用户到响应对象中给定的URL?如果我访问该网址,我可以接受或拒绝付款,但这不会影响Stripe Dashboard中的任何内容。
PS客户端是移动应用程序(Flutter),后端是Lumen PHP框架。
我希望用户输入一次卡,然后使用该数据进行进一步购买。