fix: Stripe handlePaymentResult for direct payment
This commit is contained in:
parent
1472daa363
commit
cedd5db6b4
|
@ -335,7 +335,7 @@ class StripeController extends Controller
|
|||
], ResponseAlias::HTTP_MOVED_PERMANENTLY);
|
||||
}
|
||||
|
||||
return $this->handlePaymentIntentResult($transaction, $paymentIntent);
|
||||
return $this->handlePaymentIntentResult($transaction, $paymentIntent, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -482,18 +482,24 @@ class StripeController extends Controller
|
|||
return $this->errorResponse(__('errors.unexpected_error'));
|
||||
}
|
||||
|
||||
private function handlePaymentIntentResult(PaymentTransaction $transaction, PaymentIntent $intent){
|
||||
private function handlePaymentIntentResult(PaymentTransaction $transaction, PaymentIntent $intent , bool $returnView = true){
|
||||
|
||||
if($intent->status == 'succeeded'){
|
||||
$transaction->update([
|
||||
'status' => PaymentTransactionStatus::ACCEPTED
|
||||
]);
|
||||
|
||||
return redirect()->route('paymentResult',[
|
||||
$data = [
|
||||
'message' => 'Payment Accepted',
|
||||
'transaction_id' => $transaction->transaction_id,
|
||||
'status' => 1
|
||||
]);
|
||||
];
|
||||
|
||||
if($returnView){
|
||||
return redirect()->route('paymentResult',$data);
|
||||
}else{
|
||||
return $this->successResponse($data);
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
|
@ -501,10 +507,17 @@ class StripeController extends Controller
|
|||
'status' => strtolower($intent->status)
|
||||
]);
|
||||
|
||||
return redirect()->route('paymentResult', [
|
||||
$data = [
|
||||
'message' => "Payment ".$transaction->status,
|
||||
'status' => 0
|
||||
]);
|
||||
];
|
||||
|
||||
if($returnView){
|
||||
return redirect()->route('paymentResult', $data);
|
||||
}else{
|
||||
return $this->errorResponse($data);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue