我在Laravel Cashier Stripe付款中遇到问题。我需要将计费和新订阅合并为一个,以便在发生IncompletePayment例外时,我仍然可以获得带区卷的webhooks。
try{
$user->charge(1000, $creditCard->id, [
'description' => 'Premium Registration',
])
$user->newSubscription('premium_member', $recurring)
->create($creditCard->id);
}
} catch (IncompletePayment $e) {
$intent = \Stripe\PaymentIntent::retrieve($e->payment->id);
$intent->confirm([
'return_url' => url('api/payments-3d-success'),
]);
return response()->json([
'e' => $intent,
]);
}
另一种方法是捕获异常并像laravel一样构建处理不完整异常的方法。
try{
$subscription = \Stripe\Subscription::create([
'customer' => $customer->id,
'items' => [[
'price' => $recurring,
]],
'add_invoice_items' => [[
'price' => $oneTime,
]],
]);
}
//I need to catch the exception here from stripe and build like a laravel way like IncompletePayment exceptions
catch(Exception $e){
$intent = \Stripe\PaymentIntent::retrieve($e->payment->id);
$intent->confirm([
'return_url' => url('api/payments-3d-success'),
]);
return response()->json([
'e' => $intent,
]);
}
请让我知道您如何处理此问题。谢谢
答案 0 :(得分:1)