Skip to content

Commit

Permalink
Fix issue with requires_action (#1226)
Browse files Browse the repository at this point in the history
  • Loading branch information
driesvints authored Aug 3, 2021
1 parent fe71328 commit 6e71f6b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions resources/views/payment.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ class="inline-block w-full px-4 py-3 bg-gray-100 hover:bg-gray-200 text-center t
if (this.paymentMethod.type === 'card') {
if (this.paymentIntent.status === 'requires_payment_method') {
data.payment_method.card = this.paymentElement;
} else if (this.paymentIntent.status === 'requires_action') {
data.payment_method = this.paymentIntent.payment_method.id;
}
paymentPromise = stripe.confirmCardPayment(secret, data);
Expand Down
10 changes: 7 additions & 3 deletions src/Http/Controllers/PaymentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,17 @@ public function show($id)
$id, ['expand' => ['payment_method']])
);

$paymentIntent = Arr::only($payment->asStripePaymentIntent()->toArray(), [
'id', 'status', 'payment_method_types', 'client_secret', 'payment_method',
]);

$paymentIntent['payment_method'] = Arr::only($paymentIntent['payment_method'] ?? [], 'id');

return view('cashier::payment', [
'stripeKey' => config('cashier.key'),
'amount' => $payment->amount(),
'payment' => $payment,
'paymentIntent' => Arr::only($payment->asStripePaymentIntent()->toArray(), [
'id', 'status', 'payment_method_types', 'client_secret',
]),
'paymentIntent' => array_filter($paymentIntent),
'paymentMethod' => (string) request('source_type', optional($payment->payment_method)->type),
'errorMessage' => request('redirect_status') === 'failed'
? 'Something went wrong when trying to confirm the payment. Please try again.'
Expand Down

0 comments on commit 6e71f6b

Please sign in to comment.