From 9981a4c78954f4e705a00a509ea38b6107d6e242 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 7 Dec 2021 23:33:26 +1100 Subject: [PATCH] Fixes for gocardless --- app/PaymentDrivers/GoCardless/ACH.php | 11 +++++------ app/PaymentDrivers/GoCardless/DirectDebit.php | 1 - app/PaymentDrivers/GoCardless/SEPA.php | 11 +++-------- .../ninja2020/gateways/gocardless/ach/pay.blade.php | 4 ++-- .../gateways/gocardless/direct_debit/pay.blade.php | 4 ++-- .../ninja2020/gateways/gocardless/sepa/pay.blade.php | 4 ++-- 6 files changed, 14 insertions(+), 21 deletions(-) diff --git a/app/PaymentDrivers/GoCardless/ACH.php b/app/PaymentDrivers/GoCardless/ACH.php index 055a313563f9..7aafa628d86d 100644 --- a/app/PaymentDrivers/GoCardless/ACH.php +++ b/app/PaymentDrivers/GoCardless/ACH.php @@ -160,11 +160,11 @@ class ACH implements MethodInterface */ public function paymentResponse(PaymentResponseRequest $request) { - $token = ClientGatewayToken::find( - $this->decodePrimaryKey($request->source) - )->firstOrFail(); + // $token = ClientGatewayToken::find( + // $this->decodePrimaryKey($request->source) + // )->firstOrFail(); - $this->go_cardless->ensureMandateIsReady($token); + $this->go_cardless->ensureMandateIsReady($request->source); try { $payment = $this->go_cardless->gateway->payments()->create([ @@ -175,7 +175,7 @@ class ACH implements MethodInterface 'payment_hash' => $this->go_cardless->payment_hash->hash, ], 'links' => [ - 'mandate' => $token->token, + 'mandate' => $request->source, ], ], ]); @@ -201,7 +201,6 @@ class ACH implements MethodInterface public function processPendingPayment(\GoCardlessPro\Resources\Payment $payment, array $data = []) { $data = [ - 'payment_method' => $data['token'], 'payment_type' => PaymentType::ACH, 'amount' => $this->go_cardless->payment_hash->data->amount_with_fee, 'transaction_reference' => $payment->id, diff --git a/app/PaymentDrivers/GoCardless/DirectDebit.php b/app/PaymentDrivers/GoCardless/DirectDebit.php index 2929e081bf7c..7e915f5f8f9d 100644 --- a/app/PaymentDrivers/GoCardless/DirectDebit.php +++ b/app/PaymentDrivers/GoCardless/DirectDebit.php @@ -190,7 +190,6 @@ class DirectDebit implements MethodInterface public function processPendingPayment(\GoCardlessPro\Resources\Payment $payment, array $data = []) { $data = [ - 'payment_method' => $data['token'], 'payment_type' => PaymentType::DIRECT_DEBIT, 'amount' => $this->go_cardless->payment_hash->data->amount_with_fee, 'transaction_reference' => $payment->id, diff --git a/app/PaymentDrivers/GoCardless/SEPA.php b/app/PaymentDrivers/GoCardless/SEPA.php index 35ffef5b91a8..6a9bfb342664 100644 --- a/app/PaymentDrivers/GoCardless/SEPA.php +++ b/app/PaymentDrivers/GoCardless/SEPA.php @@ -160,11 +160,7 @@ class SEPA implements MethodInterface */ public function paymentResponse(PaymentResponseRequest $request) { - $token = ClientGatewayToken::find( - $this->decodePrimaryKey($request->source) - )->firstOrFail(); - - $this->go_cardless->ensureMandateIsReady($token); + $this->go_cardless->ensureMandateIsReady($request->source); try { $payment = $this->go_cardless->gateway->payments()->create([ @@ -175,13 +171,13 @@ class SEPA implements MethodInterface 'payment_hash' => $this->go_cardless->payment_hash->hash, ], 'links' => [ - 'mandate' => $token->token, + 'mandate' => $request->source, ], ], ]); if ($payment->status === 'pending_submission') { - return $this->processPendingPayment($payment, ['token' => $token->hashed_id]); + return $this->processPendingPayment($payment, ['token' => $request->source]); } return $this->processUnsuccessfulPayment($payment); @@ -200,7 +196,6 @@ class SEPA implements MethodInterface public function processPendingPayment(\GoCardlessPro\Resources\Payment $payment, array $data = []) { $data = [ - 'payment_method' => $data['token'], 'payment_type' => PaymentType::SEPA, 'amount' => $this->go_cardless->payment_hash->data->amount_with_fee, 'transaction_reference' => $payment->id, diff --git a/resources/views/portal/ninja2020/gateways/gocardless/ach/pay.blade.php b/resources/views/portal/ninja2020/gateways/gocardless/ach/pay.blade.php index 98dd992b5b5a..eb29b41515f5 100644 --- a/resources/views/portal/ninja2020/gateways/gocardless/ach/pay.blade.php +++ b/resources/views/portal/ninja2020/gateways/gocardless/ach/pay.blade.php @@ -20,10 +20,10 @@ @if (count($tokens) > 0) @foreach ($tokens as $token) @endforeach @endisset diff --git a/resources/views/portal/ninja2020/gateways/gocardless/direct_debit/pay.blade.php b/resources/views/portal/ninja2020/gateways/gocardless/direct_debit/pay.blade.php index cb0620ad1cd3..da00715475fa 100644 --- a/resources/views/portal/ninja2020/gateways/gocardless/direct_debit/pay.blade.php +++ b/resources/views/portal/ninja2020/gateways/gocardless/direct_debit/pay.blade.php @@ -20,10 +20,10 @@ @if (count($tokens) > 0) @foreach ($tokens as $token) @endforeach @endisset diff --git a/resources/views/portal/ninja2020/gateways/gocardless/sepa/pay.blade.php b/resources/views/portal/ninja2020/gateways/gocardless/sepa/pay.blade.php index 7f506a51cc47..25b3c6a870fc 100644 --- a/resources/views/portal/ninja2020/gateways/gocardless/sepa/pay.blade.php +++ b/resources/views/portal/ninja2020/gateways/gocardless/sepa/pay.blade.php @@ -20,10 +20,10 @@ @if (count($tokens) > 0) @foreach ($tokens as $token) @endforeach @endisset