From b3aa7877b97be02ba793a3b868b1a89b4576e5c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Sat, 31 Jul 2021 13:26:00 +0200 Subject: [PATCH] Revoking the manadate when deleting --- app/PaymentDrivers/MolliePaymentDriver.php | 26 ++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/app/PaymentDrivers/MolliePaymentDriver.php b/app/PaymentDrivers/MolliePaymentDriver.php index 88d7883ac359..863d9738a8d2 100644 --- a/app/PaymentDrivers/MolliePaymentDriver.php +++ b/app/PaymentDrivers/MolliePaymentDriver.php @@ -14,6 +14,7 @@ namespace App\PaymentDrivers; use App\Http\Requests\Gateways\Mollie\Mollie3dsRequest; use App\Http\Requests\Payments\PaymentWebhookRequest; +use App\Jobs\Util\SystemLogger; use App\Models\ClientGatewayToken; use App\Models\GatewayType; use App\Models\Payment; @@ -123,7 +124,7 @@ class MolliePaymentDriver extends BaseDriver public function processWebhookRequest(PaymentWebhookRequest $request, Payment $payment = null) { } - + public function process3dsConfirmation(Mollie3dsRequest $request) { $this->init(); @@ -134,8 +135,29 @@ class MolliePaymentDriver extends BaseDriver $payment = $this->gateway->payments->get($request->getPaymentId()); return (new CreditCard($this))->processSuccessfulPayment($payment); - } catch(\Mollie\Api\Exceptions\ApiException $e) { + } catch (\Mollie\Api\Exceptions\ApiException $e) { return (new CreditCard($this))->processUnsuccessfulPayment($e); } } + + public function detach(ClientGatewayToken $token) + { + $this->init(); + + try { + $this->gateway->mandates->revokeForId($token->gateway_customer_reference, $token->token); + } catch (\Mollie\Api\Exceptions\ApiException $e) { + SystemLogger::dispatch( + [ + 'server_response' => $e->getMessage(), + 'data' => request()->all(), + ], + SystemLog::CATEGORY_GATEWAY_RESPONSE, + SystemLog::EVENT_GATEWAY_FAILURE, + SystemLog::TYPE_MOLLIE, + $this->client, + $this->client->company + ); + } + } }