Fixes for disabled client portal payments

This commit is contained in:
David Bomba 2024-09-05 13:22:55 +10:00
parent 500f289647
commit c74fac68f4
9 changed files with 50 additions and 29 deletions

View File

@ -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;
}

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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';
}
}

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()