我的问题:我正在开发基于订阅或分期付款的应用程序,因此用户可以在 3 或 6 个月内获得所需的任何金额。我使用了条带计划和调度方法来完成这个:
如果手动提供价格,则在创建计划时它可以工作。订阅已创建但对我而言,有时会有计算和金额变化,如动态订阅,我希望价格是动态的。
但是当我进行amount" => $price,
动态时,我收到错误“此付款需要额外的用户操作才能成功完成。可以使用与发票关联的 PaymentIntent 完成付款。有关更多详细信息,请参阅:https ://stripe.com/docs/billing /subscriptions/overview#requires-action"
//Fetching intent
$intent = \Stripe\PaymentIntent::retrieve($paymentMethodParams->paymentIntent['id']);
//Create stripe user
$customer = \Stripe\Customer::create(([
'email' => 'evansd@ed.com',
'description' => 'Valued Customer',
'name' => 'Ed Ward',
'payment_method' => $paymentMethodParams->paymentMethod['id'],
'invoice_settings' =>
[
'default_payment_method' => $paymentMethodParams->paymentMethod['id']
]
]));
//Attaching paymentIntent with Customer
\Stripe\PaymentIntent::update($paymentMethodParams->paymentIntent['id'],
[
'customer' => $customer->id,
]
);
$intent = \Stripe\PaymentIntent::retrieve($paymentMethodParams->paymentIntent['id']);
$product = \Stripe\Product::create([
'name' => 'Payment plan for user',
'type' => 'service'
]);
//Creating plan for the customer
$plan = \Stripe\Plan::create(
array(
"product" => [
"name" => '#1 monthly Subscription'
],
"amount" => 200,
'nickname' => 'Payment Plan for order - ',
"currency" => 'GBP',
"interval" => 'month',
"interval_count" => 1,
'metadata' => [
]
)
);
$schedule = \Stripe\SubscriptionSchedule::create([
'customer' => $customer->id,
'start_date' => 'now',
'end_behavior' => 'cancel',
'metadata' => [
'local_id' => 'ABC 12345',
],
'phases' => [
[
'items' => [
[
'plan' => $plan->id,
],
],
'iterations'=>2
],
],
]);
$subscription_id = $schedule->subscription;
$result = \Stripe\Subscription::update($subscription_id,
[
'expand' => ['latest_invoice.payment_intent'],
]
);
$invoice = \Stripe\Invoice::retrieve($result->latest_invoice->id);
$invoice->pay();
到目前为止我做了什么:
1:我什至尝试设置$price = 1
and 分阶段 'quantity' => $price * $qty
所以它收取我的价格。但后来又一样了。
此问题仅适用于某些测试卡,例如:(4000 0027 6000 3184.
问题在实施 SCA 时开始)。其他没有 sca 规则的卡可以完美运行。(无论卡的设置方式如何,这些卡都需要对所有交易进行身份验证。)
2:首先创建计划,然后使用该计划创建客户,就像在 不同数量的条纹订阅计划中提到的一样
我认为它不是用户行为,而是它的动态计划价格问题。如果价格是静态的,它可以工作并使用 sca 卡。
提前致谢。