【发布时间】:2023-03-27 11:31:02
【问题描述】:
我已经实施了 Stripe SCA 迁移 我创建付款意图的服务端代码如下
$intent = \Stripe\PaymentIntent::create([
'payment_method' => $requestData['payment_method_id'],
'amount' => $requestData->amount,
'currency' => $requestData->currencyIso,
'payment_method_types' => ['card'],
'confirmation_method' => "manual",
'confirm' => true,
'setup_future_usage'=>"off_session",
]);
return $intent;
我的js代码如下创建卡支付和处理响应
stripe.createPaymentMethod('card', cardElement, {
billing_details: {name: cardholderName.value}
})
并处理响应:
function handleServerResponse(response) {
if (response.error) {
} else if (response.requires_action) {
stripe.handleCardAction(
response.payment_intent_client_secret
).then(function(result) {
if (result.error) {
} else {
// The card action has been handled
// The PaymentIntent can be confirmed again on the server
fetch('https://test.com/server.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
payment_method_id: result.paymentMethod.id,
amount: amount
})
}).then(function(confirmResult) {
console.log(confirmResult);
return confirmResult.json();
}).then(handleServerResponse);
}
});
}
}
}
$plan = Plan::create([
'currency' => $currency,
'interval' => 'month',
'product' => $product->id,
'nickname' => 'Payment Plan for order - ' . $order_id,
'amount' => $price,
'metadata' => [
'order_number' => $order_id,
'bgt_customer_number' => $customer_id,
],
]);
$schedule = SubscriptionSchedule::create([
'customer' => $customer->id,
'start_date' => 'now',
'end_behavior' => 'cancel',
'metadata' => [
'local_id' => $order_id,
'local_account_id' => $account_id,
'local_currency_id' => $currency_id,
'local_user_id'=> $user_id,
'local_installments_total' => $plan_length,
'bgt_customer_number' => $customer_id,
'order_number' => $order_id,
'invoice_description' => 'Payment Plan for order - ' . $order_id
],
'phases' => [
[
'items' => [
[
'plan' => $plan->id,
],
],
'collection_method'=> 'charge_automatically',
'iterations'=>$plan_length
],
],
]);
$metadata = [
'installments_paid' => '0',
'installments_total' => $plan_length,
'local_id' =>$order_id,
'local_account_id' =>$account_id,
'local_currency_id' =>$currency_id,
'subscription_schedule_id' => $schedule->id
];
$subscription_id=$schedule->subscription;
$result=Subscription::update($subscription_id,
[
'metadata' => $metadata,
'default_payment_method' => $paymentMethodParams['payment_method'],
'proration_behavior' =>'always_invoice',
//Create only after adding payment method id in customer
]
);
我正在获取 sca 卡的 SCA 模式,并且工作流程是正确的。 但我担心的是测试使用 sca 创建的订阅
我使用 4000000000003220 和 424242424242424 进行了测试,订阅分为 3 期。
订阅是使用正确的分期付款创建的: 但我担心的是订阅第一期不会立即收费。 发票显示为:
此发票草稿由订阅生成。可以编辑 直到它在 1 小时内自动完成。
.
当我尝试从条带仪表板(作为测试的一部分)完成充电时,它会显示
发票已敲定,但客户需要完成 3D 支付成功的安全认证。这个额外的 他们的银行要求采取措施以防止欺诈。 3D 安全电子邮件是 在您的设置中禁用,因此您需要通知客户 手动
发票未能捕获。 题: 1:我希望第一部分或计划发生。 我如何在登台环境中实现这一点。我在创建订阅或 SCA 方法时是否遗漏了任何要点?
2:真正的“确认方法”=>“手动”。真是一头雾水。
【问题讨论】:
标签: php stripe-payments laravel-cashier