From 6bf597b4ee3bb1f4af10a56b244609ffb7c1c1fc Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 17 Jun 2020 11:36:29 +1000 Subject: [PATCH] Authorize - per invoice credit card paymente --- .../Authorize/AuthorizeCreditCard.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php index 32e9a1526f9b..ee6850c52fcf 100644 --- a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php +++ b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php @@ -22,6 +22,7 @@ use App\Models\PaymentType; use App\Models\SystemLog; use App\PaymentDrivers\AuthorizePaymentDriver; use App\PaymentDrivers\Authorize\AuthorizeCreateCustomer; +use App\PaymentDrivers\Authorize\AuthorizePaymentMethod; use App\PaymentDrivers\Authorize\ChargePaymentProfile; use App\Utils\Traits\MakesHash; use Illuminate\Support\Carbon; @@ -65,20 +66,22 @@ class AuthorizeCreditCard $data = $request->all(); - dd($data); + $authorise_create_customer = new AuthorizeCreateCustomer($this->authorize, $this->authorize->client); - $authorise_payment_method = new AuthorizeCreateCustomer($this->authorize, $this->authorize->client); - - $gateway_customer_reference = $authorise_payment_method->create($data); + $gateway_customer_reference = $authorise_create_customer->create($data); info($gateway_customer_reference); + $authorise_payment_method = new AuthorizePaymentMethod($this->authorize); + $payment_profile = $authorise_payment_method->addPaymentMethodToClient($gateway_customer_reference, $data); - if($data['save_payment_method'] == true) + if($request->has('store_card') && $request->input('store_card')) $client_gateway_token = $authorise_payment_method->createClientGatewayToken($payment_profile, $gateway_customer_reference); - return (new ChargePaymentProfile($this->authorize))->chargeCustomerProfile($gateway_customer_reference, $payment_profile, $data['amount_with_fee']); + $data = (new ChargePaymentProfile($this->authorize))->chargeCustomerProfile($gateway_customer_reference, $payment_profile, $data['amount_with_fee']); + + return $this->handleResponse($data, $request); }