diff --git a/app/PaymentDrivers/GoCardless/DirectDebit.php b/app/PaymentDrivers/GoCardless/DirectDebit.php index fae242949242..2929e081bf7c 100644 --- a/app/PaymentDrivers/GoCardless/DirectDebit.php +++ b/app/PaymentDrivers/GoCardless/DirectDebit.php @@ -152,11 +152,8 @@ class DirectDebit 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([ @@ -167,14 +164,14 @@ class DirectDebit 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); diff --git a/app/PaymentDrivers/GoCardlessPaymentDriver.php b/app/PaymentDrivers/GoCardlessPaymentDriver.php index c7d890e637d0..721125409090 100644 --- a/app/PaymentDrivers/GoCardlessPaymentDriver.php +++ b/app/PaymentDrivers/GoCardlessPaymentDriver.php @@ -265,10 +265,11 @@ class GoCardlessPaymentDriver extends BaseDriver return response()->json([], 200); } - public function ensureMandateIsReady(ClientGatewayToken $cgt) + public function ensureMandateIsReady($token) { try { - $mandate = $this->gateway->mandates()->get($cgt->token); + $this->init(); + $mandate = $this->gateway->mandates()->get($token); if ($mandate->status !== 'active') { throw new \Exception(ctrans('texts.gocardless_mandate_not_ready'));