mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Ensure mandate is ready before attempting payment
This commit is contained in:
parent
e1f1700226
commit
714b9cb187
@ -164,6 +164,8 @@ class ACH implements MethodInterface
|
||||
$this->decodePrimaryKey($request->source)
|
||||
)->firstOrFail();
|
||||
|
||||
$this->go_cardless->ensureMandateIsReady($token);
|
||||
|
||||
try {
|
||||
$payment = $this->go_cardless->gateway->payments()->create([
|
||||
'params' => [
|
||||
|
@ -156,6 +156,8 @@ class DirectDebit implements MethodInterface
|
||||
$this->decodePrimaryKey($request->source)
|
||||
)->firstOrFail();
|
||||
|
||||
$this->go_cardless->ensureMandateIsReady($token);
|
||||
|
||||
try {
|
||||
$payment = $this->go_cardless->gateway->payments()->create([
|
||||
'params' => [
|
||||
|
@ -164,6 +164,8 @@ class SEPA implements MethodInterface
|
||||
$this->decodePrimaryKey($request->source)
|
||||
)->firstOrFail();
|
||||
|
||||
$this->go_cardless->ensureMandateIsReady($token);
|
||||
|
||||
try {
|
||||
$payment = $this->go_cardless->gateway->payments()->create([
|
||||
'params' => [
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace App\PaymentDrivers;
|
||||
|
||||
use App\Events\Payment\PaymentFailed;
|
||||
use App\Http\Requests\Payments\PaymentWebhookRequest;
|
||||
use App\Jobs\Util\SystemLogger;
|
||||
use App\Models\ClientGatewayToken;
|
||||
@ -258,4 +259,17 @@ class GoCardlessPaymentDriver extends BaseDriver
|
||||
|
||||
return response()->json([], 200);
|
||||
}
|
||||
|
||||
public function ensureMandateIsReady(ClientGatewayToken $cgt)
|
||||
{
|
||||
try {
|
||||
$mandate = $this->gateway->mandates()->get($cgt->token);
|
||||
|
||||
if ($mandate->status !== 'active') {
|
||||
throw new \Exception(ctrans('texts.gocardless_mandate_not_ready'));
|
||||
}
|
||||
} catch (\Exception $exception) {
|
||||
throw new \App\Exceptions\PaymentFailed($exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4337,7 +4337,8 @@ $LANG = array(
|
||||
'invalid_amount' => 'Invalid amount. Number/Decimal values only.',
|
||||
'client_payment_failure_body' => 'Payment for Invoice :invoice for amount :amount failed.',
|
||||
'browser_pay' => 'Google Pay, Apple Pay, Microsoft Pay',
|
||||
'no_available_methods' => 'We can\'t find any credit cards on your device. <a href="https://invoiceninja.github.io/docs/payments#apple-pay-google-pay-microsoft-pay" target="_blank" class="underline">Read more about this.</a>'
|
||||
'no_available_methods' => 'We can\'t find any credit cards on your device. <a href="https://invoiceninja.github.io/docs/payments#apple-pay-google-pay-microsoft-pay" target="_blank" class="underline">Read more about this.</a>',
|
||||
'gocardless_mandate_not_ready' => 'Payment mandate is not ready. Please try again later.',
|
||||
);
|
||||
|
||||
return $LANG;
|
||||
|
Loading…
Reference in New Issue
Block a user