mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge pull request #6936 from beganovich/sentry-13483
GoCardless: Ensure mandate is ready before attempting payment
This commit is contained in:
commit
20de95b29d
@ -164,6 +164,8 @@ class ACH implements MethodInterface
|
|||||||
$this->decodePrimaryKey($request->source)
|
$this->decodePrimaryKey($request->source)
|
||||||
)->firstOrFail();
|
)->firstOrFail();
|
||||||
|
|
||||||
|
$this->go_cardless->ensureMandateIsReady($token);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$payment = $this->go_cardless->gateway->payments()->create([
|
$payment = $this->go_cardless->gateway->payments()->create([
|
||||||
'params' => [
|
'params' => [
|
||||||
|
@ -156,6 +156,8 @@ class DirectDebit implements MethodInterface
|
|||||||
$this->decodePrimaryKey($request->source)
|
$this->decodePrimaryKey($request->source)
|
||||||
)->firstOrFail();
|
)->firstOrFail();
|
||||||
|
|
||||||
|
$this->go_cardless->ensureMandateIsReady($token);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$payment = $this->go_cardless->gateway->payments()->create([
|
$payment = $this->go_cardless->gateway->payments()->create([
|
||||||
'params' => [
|
'params' => [
|
||||||
|
@ -164,6 +164,8 @@ class SEPA implements MethodInterface
|
|||||||
$this->decodePrimaryKey($request->source)
|
$this->decodePrimaryKey($request->source)
|
||||||
)->firstOrFail();
|
)->firstOrFail();
|
||||||
|
|
||||||
|
$this->go_cardless->ensureMandateIsReady($token);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$payment = $this->go_cardless->gateway->payments()->create([
|
$payment = $this->go_cardless->gateway->payments()->create([
|
||||||
'params' => [
|
'params' => [
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace App\PaymentDrivers;
|
namespace App\PaymentDrivers;
|
||||||
|
|
||||||
|
use App\Events\Payment\PaymentFailed;
|
||||||
use App\Http\Requests\Payments\PaymentWebhookRequest;
|
use App\Http\Requests\Payments\PaymentWebhookRequest;
|
||||||
use App\Jobs\Util\SystemLogger;
|
use App\Jobs\Util\SystemLogger;
|
||||||
use App\Models\ClientGatewayToken;
|
use App\Models\ClientGatewayToken;
|
||||||
@ -258,4 +259,17 @@ class GoCardlessPaymentDriver extends BaseDriver
|
|||||||
|
|
||||||
return response()->json([], 200);
|
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.',
|
'invalid_amount' => 'Invalid amount. Number/Decimal values only.',
|
||||||
'client_payment_failure_body' => 'Payment for Invoice :invoice for amount :amount failed.',
|
'client_payment_failure_body' => 'Payment for Invoice :invoice for amount :amount failed.',
|
||||||
'browser_pay' => 'Google Pay, Apple Pay, Microsoft Pay',
|
'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;
|
return $LANG;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user