Fixes for Mollie Direct Debit

This commit is contained in:
David Bomba 2021-11-25 21:45:52 +11:00
parent 6129c44421
commit 534367c80e
2 changed files with 6 additions and 8 deletions

View File

@ -152,11 +152,8 @@ class DirectDebit implements MethodInterface
public function paymentResponse(PaymentResponseRequest $request) 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 { try {
$payment = $this->go_cardless->gateway->payments()->create([ $payment = $this->go_cardless->gateway->payments()->create([
@ -167,14 +164,14 @@ class DirectDebit implements MethodInterface
'payment_hash' => $this->go_cardless->payment_hash->hash, 'payment_hash' => $this->go_cardless->payment_hash->hash,
], ],
'links' => [ 'links' => [
'mandate' => $token->token, 'mandate' => $request->source,
], ],
], ],
]); ]);
if ($payment->status === 'pending_submission') { if ($payment->status === 'pending_submission') {
return $this->processPendingPayment($payment, ['token' => $token->hashed_id]); return $this->processPendingPayment($payment, ['token' => $request->source]);
} }
return $this->processUnsuccessfulPayment($payment); return $this->processUnsuccessfulPayment($payment);

View File

@ -265,10 +265,11 @@ class GoCardlessPaymentDriver extends BaseDriver
return response()->json([], 200); return response()->json([], 200);
} }
public function ensureMandateIsReady(ClientGatewayToken $cgt) public function ensureMandateIsReady($token)
{ {
try { try {
$mandate = $this->gateway->mandates()->get($cgt->token); $this->init();
$mandate = $this->gateway->mandates()->get($token);
if ($mandate->status !== 'active') { if ($mandate->status !== 'active') {
throw new \Exception(ctrans('texts.gocardless_mandate_not_ready')); throw new \Exception(ctrans('texts.gocardless_mandate_not_ready'));