diff --git a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php index 10569e081c9f..86c9f5afd45e 100644 --- a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php +++ b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php @@ -140,7 +140,6 @@ class AuthorizeCreditCard $response = $data['response']; if ($response != null && $response->getMessages()->getResultCode() == 'Ok') { - $this->authorize->confirmGatewayFee($request); return $this->processSuccessfulResponse($data, $request); } diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index 16f2c3442cb5..ff1807f71965 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -202,14 +202,15 @@ class BaseDriver extends AbstractPaymentDriver */ public function createPayment($data, $status = Payment::STATUS_COMPLETED): Payment { + $this->confirmGatewayFee(); + $payment = PaymentFactory::create($this->client->company->id, $this->client->user->id); $payment->client_id = $this->client->id; $payment->company_gateway_id = $this->company_gateway->id; $payment->status_id = $status; $payment->currency_id = $this->client->getSetting('currency_id'); $payment->date = Carbon::now(); - - //$payment->gateway_type_id = $data['gateway_type_id']; + $payment->gateway_type_id = $data['gateway_type_id']; $client_contact = $this->getContact(); $client_contact_id = $client_contact ? $client_contact->id : null; @@ -245,19 +246,14 @@ class BaseDriver extends AbstractPaymentDriver * @param PaymentResponseRequest $request The incoming payment request * @return void Success/Failure */ - public function confirmGatewayFee(PaymentResponseRequest $request) :void + public function confirmGatewayFee() :void { - /*Payment meta data*/ - $payment_hash = $request->getPaymentHash(); /*Payment invoices*/ - $payment_invoices = $payment_hash->invoices(); + $payment_invoices = $this->payment_hash->invoices(); /*Fee charged at gateway*/ - $fee_total = $payment_hash->fee_total; - - // Sum of invoice amounts - // $invoice_totals = array_sum(array_column($payment_invoices,'amount')); + $fee_total = $this->payment_hash->fee_total; /*Hydrate invoices*/ $invoices = Invoice::whereIn('id', $this->transformKeys(array_column($payment_invoices, 'invoice_id')))->get(); diff --git a/app/PaymentDrivers/CheckoutCom/CreditCard.php b/app/PaymentDrivers/CheckoutCom/CreditCard.php index d9855594d12b..aa35d5ad3dde 100644 --- a/app/PaymentDrivers/CheckoutCom/CreditCard.php +++ b/app/PaymentDrivers/CheckoutCom/CreditCard.php @@ -142,7 +142,6 @@ class CreditCard $response = $this->checkout->gateway->payments()->request($payment); if ($response->status == 'Authorized') { - $this->checkout->confirmGatewayFee($request); return $this->processSuccessfulPayment($response); } diff --git a/app/PaymentDrivers/Stripe/CreditCard.php b/app/PaymentDrivers/Stripe/CreditCard.php index 48f59eb382cc..d9b007b02a08 100644 --- a/app/PaymentDrivers/Stripe/CreditCard.php +++ b/app/PaymentDrivers/Stripe/CreditCard.php @@ -95,7 +95,6 @@ class CreditCard $server_response = $this->stripe->payment_hash->data->server_response; if ($server_response->status == 'succeeded') { - $this->stripe->confirmGatewayFee($request); $this->stripe->logSuccessfulGatewayResponse(['response' => json_decode($request->gateway_response), 'data' => $this->stripe->payment_hash], SystemLog::TYPE_STRIPE);