diff --git a/app/Models/Client.php b/app/Models/Client.php index 5738a35bec04..cbb7500daa29 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -674,6 +674,20 @@ class Client extends BaseModel implements HasLocalePreference } } + + if (in_array($this->currency()->code, ['GBP']) && in_array(GatewayType::BACS, array_column($pms, 'gateway_type_id'))) { + // if ($this->currency()->code == 'CAD' && in_array(GatewayType::ACSS, array_column($pms, 'gateway_type_id'))) { + foreach ($pms as $pm) { + if ($pm['gateway_type_id'] == GatewayType::BACS) { + $cg = CompanyGateway::query()->find($pm['company_gateway_id']); + + if ($cg && $cg->fees_and_limits->{GatewayType::BACS}->is_enabled) { + return $cg; + } + } + } + } + return null; } diff --git a/app/PaymentDrivers/Stripe/Bancontact.php b/app/PaymentDrivers/Stripe/Bancontact.php index 56bace102109..e776377c93a1 100644 --- a/app/PaymentDrivers/Stripe/Bancontact.php +++ b/app/PaymentDrivers/Stripe/Bancontact.php @@ -70,8 +70,8 @@ class Bancontact implements LivewireMethodInterface /* @todo: https://github.com/invoiceninja/invoiceninja/pull/3789/files#r436175798 */ //catch duplicate submissions. - if (Payment::where('transaction_reference', $payment_intent)->exists()) { - return redirect()->route('client.payments.index'); + if ($payment = Payment::query()->where('transaction_reference', $payment_intent)->first()) { + return redirect()->route('client.payments.show', ['payment' => $payment->hashed_id]); } $this->stripe->init(); @@ -84,7 +84,7 @@ class Bancontact implements LivewireMethodInterface 'gateway_type_id' => GatewayType::BANCONTACT, ]; - $this->stripe->createPayment($data, Payment::STATUS_PENDING); + $payment = $this->stripe->createPayment($data, Payment::STATUS_PENDING); SystemLogger::dispatch( ['response' => $this->stripe->payment_hash->data, 'data' => $data], @@ -95,7 +95,8 @@ class Bancontact implements LivewireMethodInterface $this->stripe->client->company, ); - return redirect()->route('client.payments.index'); + +return redirect()->route('client.payments.show', ['payment' => $payment->hashed_id]); } public function processUnsuccessfulPayment() diff --git a/app/PaymentDrivers/Stripe/EPS.php b/app/PaymentDrivers/Stripe/EPS.php index 98b23fdc2b9f..fc70a6079395 100644 --- a/app/PaymentDrivers/Stripe/EPS.php +++ b/app/PaymentDrivers/Stripe/EPS.php @@ -71,8 +71,9 @@ class EPS implements LivewireMethodInterface $this->stripe->init(); //catch duplicate submissions. - if (Payment::where('transaction_reference', $payment_intent)->exists()) { - return redirect()->route('client.payments.index'); + if ($payment = Payment::query()->where('transaction_reference', $payment_intent)->first()) { + + return redirect()->route('client.payments.show', ['payment' => $payment->hashed_id]); } $data = [ @@ -83,7 +84,7 @@ class EPS implements LivewireMethodInterface 'gateway_type_id' => GatewayType::EPS, ]; - $this->stripe->createPayment($data, Payment::STATUS_PENDING); + $payment = $this->stripe->createPayment($data, Payment::STATUS_PENDING); SystemLogger::dispatch( ['response' => $this->stripe->payment_hash->data, 'data' => $data], @@ -94,7 +95,8 @@ class EPS implements LivewireMethodInterface $this->stripe->client->company, ); - return redirect()->route('client.payments.index'); + +return redirect()->route('client.payments.show', ['payment' => $payment->hashed_id]); } public function processUnsuccessfulPayment() diff --git a/app/PaymentDrivers/Stripe/FPX.php b/app/PaymentDrivers/Stripe/FPX.php index a7cfe5d52158..0922b8c77d75 100644 --- a/app/PaymentDrivers/Stripe/FPX.php +++ b/app/PaymentDrivers/Stripe/FPX.php @@ -79,7 +79,7 @@ class FPX implements LivewireMethodInterface 'gateway_type_id' => GatewayType::FPX, ]; - $this->stripe->createPayment($data, Payment::STATUS_PENDING); + $payment = $this->stripe->createPayment($data, Payment::STATUS_PENDING); SystemLogger::dispatch( ['response' => $this->stripe->payment_hash->data, 'data' => $data], @@ -89,8 +89,9 @@ class FPX implements LivewireMethodInterface $this->stripe->client, $this->stripe->client->company, ); + + return redirect()->route('client.payments.show', ['payment' => $payment->hashed_id]); - return redirect()->route('client.payments.index'); } public function processUnsuccessfulPayment() diff --git a/app/PaymentDrivers/Stripe/GIROPAY.php b/app/PaymentDrivers/Stripe/GIROPAY.php index 0a37ecec7300..044c4a4d0705 100644 --- a/app/PaymentDrivers/Stripe/GIROPAY.php +++ b/app/PaymentDrivers/Stripe/GIROPAY.php @@ -71,8 +71,8 @@ class GIROPAY implements LivewireMethodInterface $this->stripe->init(); //catch duplicate submissions. - if (Payment::where('transaction_reference', $payment_intent)->exists()) { - return redirect()->route('client.payments.index'); + if ($payment = Payment::query()->where('transaction_reference', $payment_intent)->first()) { + return redirect()->route('client.payments.show', ['payment' => $payment->hashed_id]); } $data = [ @@ -83,7 +83,7 @@ class GIROPAY implements LivewireMethodInterface 'gateway_type_id' => GatewayType::GIROPAY, ]; - $this->stripe->createPayment($data, Payment::STATUS_PENDING); + $payment = $this->stripe->createPayment($data, Payment::STATUS_PENDING); SystemLogger::dispatch( ['response' => $this->stripe->payment_hash->data, 'data' => $data], @@ -94,7 +94,7 @@ class GIROPAY implements LivewireMethodInterface $this->stripe->client->company, ); - return redirect()->route('client.payments.index'); + return redirect()->route('client.payments.show', ['payment' => $payment->hashed_id]); } public function processUnsuccessfulPayment() @@ -153,6 +153,6 @@ class GIROPAY implements LivewireMethodInterface public function livewirePaymentView(array $data): string { - return 'gateways.giropay.pay_livewire'; + return 'gateways.stripe.giropay.pay_livewire'; } } diff --git a/app/PaymentDrivers/Stripe/Klarna.php b/app/PaymentDrivers/Stripe/Klarna.php index a78dd46073d4..9e85bcc0096b 100644 --- a/app/PaymentDrivers/Stripe/Klarna.php +++ b/app/PaymentDrivers/Stripe/Klarna.php @@ -69,8 +69,10 @@ class Klarna implements LivewireMethodInterface $this->stripe->init(); //catch duplicate submissions. - if (Payment::where('transaction_reference', $payment_intent)->exists()) { - return redirect()->route('client.payments.index'); + if ($pay_exists = Payment::query()->where('transaction_reference', $payment_intent)->first()) { + + return redirect()->route('client.payments.show', ['payment' => $pay_exists->hashed_id]); + } $data = [ @@ -81,7 +83,7 @@ class Klarna implements LivewireMethodInterface 'gateway_type_id' => GatewayType::KLARNA, ]; - $this->stripe->createPayment($data, Payment::STATUS_PENDING); + $payment = $this->stripe->createPayment($data, Payment::STATUS_PENDING); SystemLogger::dispatch( ['response' => $this->stripe->payment_hash->data, 'data' => $data], @@ -92,7 +94,7 @@ class Klarna implements LivewireMethodInterface $this->stripe->client->company, ); - return redirect()->route('client.payments.index'); + return redirect()->route('client.payments.show', ['payment' => $payment->hashed_id]); } public function processUnsuccessfulPayment() diff --git a/app/PaymentDrivers/Stripe/PRZELEWY24.php b/app/PaymentDrivers/Stripe/PRZELEWY24.php index e20103d2fcb6..787ba7a76f6a 100644 --- a/app/PaymentDrivers/Stripe/PRZELEWY24.php +++ b/app/PaymentDrivers/Stripe/PRZELEWY24.php @@ -71,8 +71,8 @@ class PRZELEWY24 implements LivewireMethodInterface $this->stripe->init(); //catch duplicate submissions. - if (Payment::where('transaction_reference', $payment_intent)->exists()) { - return redirect()->route('client.payments.index'); + if ($pay_exists = Payment::query()->where('transaction_reference', $payment_intent)->first()) { + return redirect()->route('client.payments.show', ['payment' => $pay_exists->hashed_id]); } $data = [ @@ -83,7 +83,7 @@ class PRZELEWY24 implements LivewireMethodInterface 'gateway_type_id' => GatewayType::PRZELEWY24, ]; - $this->stripe->createPayment($data, Payment::STATUS_PENDING); + $payment = $this->stripe->createPayment($data, Payment::STATUS_PENDING); SystemLogger::dispatch( ['response' => $this->stripe->payment_hash->data, 'data' => $data], @@ -94,7 +94,8 @@ class PRZELEWY24 implements LivewireMethodInterface $this->stripe->client->company, ); - return redirect()->route('client.payments.index'); + + return redirect()->route('client.payments.show', ['payment' => $payment->hashed_id]); } public function processUnsuccessfulPayment() diff --git a/app/PaymentDrivers/Stripe/SOFORT.php b/app/PaymentDrivers/Stripe/SOFORT.php index f4827e77613f..14603cc9a1f8 100644 --- a/app/PaymentDrivers/Stripe/SOFORT.php +++ b/app/PaymentDrivers/Stripe/SOFORT.php @@ -79,7 +79,7 @@ class SOFORT implements LivewireMethodInterface 'gateway_type_id' => GatewayType::SOFORT, ]; - $this->stripe->createPayment($data, Payment::STATUS_PENDING); + $payment = $this->stripe->createPayment($data, Payment::STATUS_PENDING); SystemLogger::dispatch( ['response' => $this->stripe->payment_hash->data, 'data' => $data], @@ -90,7 +90,7 @@ class SOFORT implements LivewireMethodInterface $this->stripe->client->company, ); - return redirect()->route('client.payments.index'); + return redirect()->route('client.payments.show', ['payment' => $payment->hashed_id]); } public function processUnsuccessfulPayment() diff --git a/app/PaymentDrivers/Stripe/iDeal.php b/app/PaymentDrivers/Stripe/iDeal.php index e08e6a7cb4cd..701b07ce8e43 100644 --- a/app/PaymentDrivers/Stripe/iDeal.php +++ b/app/PaymentDrivers/Stripe/iDeal.php @@ -71,8 +71,8 @@ class iDeal implements LivewireMethodInterface $this->stripe->init(); //catch duplicate submissions. - if (Payment::where('transaction_reference', $payment_intent)->exists()) { - return redirect()->route('client.payments.index'); + if ($pay_exists = Payment::query()->where('transaction_reference', $payment_intent)->first()) { + return redirect()->route('client.payments.show', ['payment' => $pay_exists->hashed_id]); } $data = [ @@ -83,7 +83,7 @@ class iDeal implements LivewireMethodInterface 'gateway_type_id' => GatewayType::IDEAL, ]; - $this->stripe->createPayment($data, Payment::STATUS_COMPLETED); + $payment = $this->stripe->createPayment($data, Payment::STATUS_COMPLETED); SystemLogger::dispatch( ['response' => $this->stripe->payment_hash->data, 'data' => $data], @@ -94,7 +94,7 @@ class iDeal implements LivewireMethodInterface $this->stripe->client->company, ); - return redirect()->route('client.payments.index'); + return redirect()->route('client.payments.show', ['payment' => $payment->hashed_id]); } public function processUnsuccessfulPayment()