From 36adf2925a44937edc66d8888d309c567fefb7cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Mon, 25 Oct 2021 17:44:34 +0200 Subject: [PATCH 1/3] Fixes for refund --- app/PaymentDrivers/BraintreePaymentDriver.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/PaymentDrivers/BraintreePaymentDriver.php b/app/PaymentDrivers/BraintreePaymentDriver.php index d360bdf1f8..55c064581d 100644 --- a/app/PaymentDrivers/BraintreePaymentDriver.php +++ b/app/PaymentDrivers/BraintreePaymentDriver.php @@ -158,10 +158,10 @@ class BraintreePaymentDriver extends BaseDriver { $data = [ - 'transaction_reference' => $response->id, + 'transaction_reference' => $payment->transaction_reference, 'transaction_response' => json_encode($response), - 'success' => (bool)$response->success, - 'description' => $response->status, + 'success' => (bool) $response->success, + 'description' => ctrans('texts.plan_refunded'), 'code' => 0, ]; From 987cb01ca3261aecc6ad4cff94496059dbe0ca6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Mon, 25 Oct 2021 17:44:55 +0200 Subject: [PATCH 2/3] Typehint Braintree\Gateway SDK --- app/PaymentDrivers/BraintreePaymentDriver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/PaymentDrivers/BraintreePaymentDriver.php b/app/PaymentDrivers/BraintreePaymentDriver.php index 55c064581d..aa9e6aac4f 100644 --- a/app/PaymentDrivers/BraintreePaymentDriver.php +++ b/app/PaymentDrivers/BraintreePaymentDriver.php @@ -40,7 +40,7 @@ class BraintreePaymentDriver extends BaseDriver /** * @var Gateway; */ - public $gateway; + public Gateway $gateway; public static $methods = [ GatewayType::CREDIT_CARD => CreditCard::class, From 90ecdc1074f458d7ff49be330346f8ce97ef89fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Mon, 25 Oct 2021 17:45:25 +0200 Subject: [PATCH 3/3] Apply style fixes --- app/PaymentDrivers/BraintreePaymentDriver.php | 21 ++++--------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/app/PaymentDrivers/BraintreePaymentDriver.php b/app/PaymentDrivers/BraintreePaymentDriver.php index aa9e6aac4f..6dfcf1a80d 100644 --- a/app/PaymentDrivers/BraintreePaymentDriver.php +++ b/app/PaymentDrivers/BraintreePaymentDriver.php @@ -12,8 +12,6 @@ namespace App\PaymentDrivers; - -use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest; use App\Jobs\Util\SystemLogger; use App\Models\ClientGatewayToken; use App\Models\GatewayType; @@ -27,7 +25,6 @@ use App\PaymentDrivers\Braintree\CreditCard; use App\PaymentDrivers\Braintree\PayPal; use Braintree\Gateway; use Exception; -use Illuminate\Http\Request; class BraintreePaymentDriver extends BaseDriver { @@ -118,8 +115,7 @@ class BraintreePaymentDriver extends BaseDriver ]); if ($result->success) { - - $address = $this->gateway->address()->create([ + $address = $this->gateway->address()->create([ 'customerId' => $result->customer->id, 'firstName' => $this->client->present()->name, 'streetAddress' => $this->client->address1, @@ -135,12 +131,9 @@ class BraintreePaymentDriver extends BaseDriver { $this->init(); - try{ - + try { $response = $this->gateway->transaction()->refund($payment->transaction_reference, $amount); - } catch (Exception $e) { - $data = [ 'transaction_reference' => null, 'transaction_response' => json_encode($e->getMessage()), @@ -154,9 +147,7 @@ class BraintreePaymentDriver extends BaseDriver return $data; } - if($response->success) - { - + if ($response->success) { $data = [ 'transaction_reference' => $payment->transaction_reference, 'transaction_response' => json_encode($response), @@ -168,10 +159,7 @@ class BraintreePaymentDriver extends BaseDriver SystemLogger::dispatch(['server_response' => $response, 'data' => $data], SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_SUCCESS, SystemLog::TYPE_BRAINTREE, $this->client, $this->client->company); return $data; - - } - else{ - + } else { $error = $response->errors->deepAll()[0]; $data = [ @@ -185,7 +173,6 @@ class BraintreePaymentDriver extends BaseDriver SystemLogger::dispatch(['server_response' => $response, 'data' => $data], SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_BRAINTREE, $this->client, $this->client->company); return $data; - } }