Fixes for gocardless

This commit is contained in:
David Bomba 2021-12-07 23:33:26 +11:00
parent 651346fb89
commit 9981a4c789
6 changed files with 14 additions and 21 deletions

View File

@ -160,11 +160,11 @@ class ACH implements MethodInterface
*/ */
public function paymentResponse(PaymentResponseRequest $request) public function paymentResponse(PaymentResponseRequest $request)
{ {
$token = ClientGatewayToken::find( // $token = ClientGatewayToken::find(
$this->decodePrimaryKey($request->source) // $this->decodePrimaryKey($request->source)
)->firstOrFail(); // )->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([
@ -175,7 +175,7 @@ class ACH 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,
], ],
], ],
]); ]);
@ -201,7 +201,6 @@ class ACH implements MethodInterface
public function processPendingPayment(\GoCardlessPro\Resources\Payment $payment, array $data = []) public function processPendingPayment(\GoCardlessPro\Resources\Payment $payment, array $data = [])
{ {
$data = [ $data = [
'payment_method' => $data['token'],
'payment_type' => PaymentType::ACH, 'payment_type' => PaymentType::ACH,
'amount' => $this->go_cardless->payment_hash->data->amount_with_fee, 'amount' => $this->go_cardless->payment_hash->data->amount_with_fee,
'transaction_reference' => $payment->id, 'transaction_reference' => $payment->id,

View File

@ -190,7 +190,6 @@ class DirectDebit implements MethodInterface
public function processPendingPayment(\GoCardlessPro\Resources\Payment $payment, array $data = []) public function processPendingPayment(\GoCardlessPro\Resources\Payment $payment, array $data = [])
{ {
$data = [ $data = [
'payment_method' => $data['token'],
'payment_type' => PaymentType::DIRECT_DEBIT, 'payment_type' => PaymentType::DIRECT_DEBIT,
'amount' => $this->go_cardless->payment_hash->data->amount_with_fee, 'amount' => $this->go_cardless->payment_hash->data->amount_with_fee,
'transaction_reference' => $payment->id, 'transaction_reference' => $payment->id,

View File

@ -160,11 +160,7 @@ class SEPA implements MethodInterface
*/ */
public function paymentResponse(PaymentResponseRequest $request) public function paymentResponse(PaymentResponseRequest $request)
{ {
$token = ClientGatewayToken::find( $this->go_cardless->ensureMandateIsReady($request->source);
$this->decodePrimaryKey($request->source)
)->firstOrFail();
$this->go_cardless->ensureMandateIsReady($token);
try { try {
$payment = $this->go_cardless->gateway->payments()->create([ $payment = $this->go_cardless->gateway->payments()->create([
@ -175,13 +171,13 @@ class SEPA 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);
@ -200,7 +196,6 @@ class SEPA implements MethodInterface
public function processPendingPayment(\GoCardlessPro\Resources\Payment $payment, array $data = []) public function processPendingPayment(\GoCardlessPro\Resources\Payment $payment, array $data = [])
{ {
$data = [ $data = [
'payment_method' => $data['token'],
'payment_type' => PaymentType::SEPA, 'payment_type' => PaymentType::SEPA,
'amount' => $this->go_cardless->payment_hash->data->amount_with_fee, 'amount' => $this->go_cardless->payment_hash->data->amount_with_fee,
'transaction_reference' => $payment->id, 'transaction_reference' => $payment->id,

View File

@ -20,10 +20,10 @@
@if (count($tokens) > 0) @if (count($tokens) > 0)
@foreach ($tokens as $token) @foreach ($tokens as $token)
<label class="mr-4"> <label class="mr-4">
<input type="radio" data-token="{{ $token->hashed_id }}" name="payment-type" <input type="radio" data-token="{{ $token->token }}" name="payment-type"
class="form-radio cursor-pointer toggle-payment-with-token" /> class="form-radio cursor-pointer toggle-payment-with-token" />
<span class="ml-1 cursor-pointer">{{ ctrans('texts.bank_transfer') }} <span class="ml-1 cursor-pointer">{{ ctrans('texts.bank_transfer') }}
(#{{ $token->hashed_id }})</span> (#{{ $token->token }})</span>
</label> </label>
@endforeach @endforeach
@endisset @endisset

View File

@ -20,10 +20,10 @@
@if (count($tokens) > 0) @if (count($tokens) > 0)
@foreach ($tokens as $token) @foreach ($tokens as $token)
<label class="mr-4"> <label class="mr-4">
<input type="radio" data-token="{{ $token->hashed_id }}" name="payment-type" <input type="radio" data-token="{{ $token->token }}" name="payment-type"
class="form-radio cursor-pointer toggle-payment-with-token" /> class="form-radio cursor-pointer toggle-payment-with-token" />
<span class="ml-1 cursor-pointer">{{ ctrans('texts.payment_type_direct_debit') }} <span class="ml-1 cursor-pointer">{{ ctrans('texts.payment_type_direct_debit') }}
(#{{ $token->hashed_id }})</span> (#{{ $token->token }})</span>
</label> </label>
@endforeach @endforeach
@endisset @endisset

View File

@ -20,10 +20,10 @@
@if (count($tokens) > 0) @if (count($tokens) > 0)
@foreach ($tokens as $token) @foreach ($tokens as $token)
<label class="mr-4"> <label class="mr-4">
<input type="radio" data-token="{{ $token->hashed_id }}" name="payment-type" <input type="radio" data-token="{{ $token->token }}" name="payment-type"
class="form-radio cursor-pointer toggle-payment-with-token" /> class="form-radio cursor-pointer toggle-payment-with-token" />
<span class="ml-1 cursor-pointer">{{ ctrans('texts.payment_type_SEPA') }} <span class="ml-1 cursor-pointer">{{ ctrans('texts.payment_type_SEPA') }}
(#{{ $token->hashed_id }})</span> (#{{ $token->token }})</span>
</label> </label>
@endforeach @endforeach
@endisset @endisset