Added fix for currency. Correct redirect

This commit is contained in:
Lars Kusch 2021-10-15 15:37:46 +02:00
parent f6e409cd40
commit 3ae7e6fabc

View File

@ -29,6 +29,7 @@ class BECS
public function __construct(StripePaymentDriver $stripe) public function __construct(StripePaymentDriver $stripe)
{ {
$this->stripe = $stripe; $this->stripe = $stripe;
$this->stripe->init();
} }
public function authorizeView($data) public function authorizeView($data)
@ -47,7 +48,7 @@ class BECS
$intent = \Stripe\PaymentIntent::create([ $intent = \Stripe\PaymentIntent::create([
'amount' => $data['stripe_amount'], 'amount' => $data['stripe_amount'],
'currency' => 'eur', 'currency' => $this->stripe->client->currency()->code,
'payment_method_types' => ['au_becs_debit'], 'payment_method_types' => ['au_becs_debit'],
'setup_future_usage' => 'off_session', 'setup_future_usage' => 'off_session',
'customer' => $this->stripe->findOrCreateCustomer(), 'customer' => $this->stripe->findOrCreateCustomer(),
@ -85,8 +86,6 @@ class BECS
public function processSuccessfulPayment(string $payment_intent) public function processSuccessfulPayment(string $payment_intent)
{ {
$this->stripe->init();
$data = [ $data = [
'payment_method' => $payment_intent, 'payment_method' => $payment_intent,
'payment_type' => PaymentType::BECS, 'payment_type' => PaymentType::BECS,
@ -95,7 +94,7 @@ class BECS
'gateway_type_id' => GatewayType::BECS, 'gateway_type_id' => GatewayType::BECS,
]; ];
$this->stripe->createPayment($data, Payment::STATUS_PENDING); $payment = $this->stripe->createPayment($data, Payment::STATUS_PENDING);
SystemLogger::dispatch( SystemLogger::dispatch(
['response' => $this->stripe->payment_hash->data, 'data' => $data], ['response' => $this->stripe->payment_hash->data, 'data' => $data],
@ -106,7 +105,7 @@ class BECS
$this->stripe->client->company, $this->stripe->client->company,
); );
return redirect()->route('client.payments.index'); return redirect()->route('client.payments.show', $payment->hashed_id);
} }
public function processUnsuccessfulPayment() public function processUnsuccessfulPayment()