我想要订阅类型 = 试用的 3d 安全模式授权检查。
我正在按照此链接设置条带订阅。当我创建没有“trial_period_days”的订阅时,3d 安全授权模式会弹出,因为订阅状态变为“不完整”。
但是当我通过 >trial_period_days 和 'payment_behavior' => 'allow_incomplete' 时,模式不起作用,因为订阅状态变为“活动”。
订阅试用时如何显示授权模式?我也看过这个链接https://stripe.com/docs/payments/3d-secure#manual-three-ds,但没有进展。
建议我一种方法来实现这一点。
这是我的代码:
public function createCustomer($token) {
\Stripe\Stripe::setApiKey(secretKey);
$customer = \Stripe\Customer::create([
'email' => 'any_email@domain.com',
'source' => $token,
]);
return $this->createSubscription($customer, $token);
}
public function createSubscription($customer, $token) {
$plan_id = $this->getPlanId();
$payment_intent = $this->createSetupIntent($customer->id, $token);
$subscription = \Stripe\Subscription::create([
'customer' => $customer->id,
'items' => [
[
'plan' => $plan->id,
],
],
'trial_period_days' => 14,
'expand' => ['latest_invoice.payment_intent'],
'payment_behavior' => 'allow_incomplete',
]);
return [
'subscription' => $subscription,
'payment_intent' => $payment_intent
];
}
public function createSetupIntent($customer_id, $token) {
$client = new Client();
$url = "https://api.stripe.com/v1/setup_intents";
$response = $client->request('POST', $url, [
'auth' => ['sk_test_key', ''],
'form_params' => [
'customer' => $customer_id,
'payment_method_types' => ["card"],
'payment_method_options' => [
"card" => [
"request_three_d_secure" => "any"
]
]
],
'timeout' => 10.0
]);
$setup_intent = $response->getBody()->getContents();
return json_decode($setup_intent, true);
}
当我将订阅设置为试用时,我也期望 3d 安全授权检查模式。