Fixes for ledger - not adjusting for gateway fees

This commit is contained in:
David Bomba 2021-01-28 15:21:04 +11:00
parent e0758e587f
commit cc7a1876d0
4 changed files with 6 additions and 13 deletions

View File

@ -140,7 +140,6 @@ class AuthorizeCreditCard
$response = $data['response']; $response = $data['response'];
if ($response != null && $response->getMessages()->getResultCode() == 'Ok') { if ($response != null && $response->getMessages()->getResultCode() == 'Ok') {
$this->authorize->confirmGatewayFee($request);
return $this->processSuccessfulResponse($data, $request); return $this->processSuccessfulResponse($data, $request);
} }

View File

@ -202,14 +202,15 @@ class BaseDriver extends AbstractPaymentDriver
*/ */
public function createPayment($data, $status = Payment::STATUS_COMPLETED): Payment public function createPayment($data, $status = Payment::STATUS_COMPLETED): Payment
{ {
$this->confirmGatewayFee();
$payment = PaymentFactory::create($this->client->company->id, $this->client->user->id); $payment = PaymentFactory::create($this->client->company->id, $this->client->user->id);
$payment->client_id = $this->client->id; $payment->client_id = $this->client->id;
$payment->company_gateway_id = $this->company_gateway->id; $payment->company_gateway_id = $this->company_gateway->id;
$payment->status_id = $status; $payment->status_id = $status;
$payment->currency_id = $this->client->getSetting('currency_id'); $payment->currency_id = $this->client->getSetting('currency_id');
$payment->date = Carbon::now(); $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 = $this->getContact();
$client_contact_id = $client_contact ? $client_contact->id : null; $client_contact_id = $client_contact ? $client_contact->id : null;
@ -245,19 +246,14 @@ class BaseDriver extends AbstractPaymentDriver
* @param PaymentResponseRequest $request The incoming payment request * @param PaymentResponseRequest $request The incoming payment request
* @return void Success/Failure * @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_invoices = $payment_hash->invoices(); $payment_invoices = $this->payment_hash->invoices();
/*Fee charged at gateway*/ /*Fee charged at gateway*/
$fee_total = $payment_hash->fee_total; $fee_total = $this->payment_hash->fee_total;
// Sum of invoice amounts
// $invoice_totals = array_sum(array_column($payment_invoices,'amount'));
/*Hydrate invoices*/ /*Hydrate invoices*/
$invoices = Invoice::whereIn('id', $this->transformKeys(array_column($payment_invoices, 'invoice_id')))->get(); $invoices = Invoice::whereIn('id', $this->transformKeys(array_column($payment_invoices, 'invoice_id')))->get();

View File

@ -142,7 +142,6 @@ class CreditCard
$response = $this->checkout->gateway->payments()->request($payment); $response = $this->checkout->gateway->payments()->request($payment);
if ($response->status == 'Authorized') { if ($response->status == 'Authorized') {
$this->checkout->confirmGatewayFee($request);
return $this->processSuccessfulPayment($response); return $this->processSuccessfulPayment($response);
} }

View File

@ -95,7 +95,6 @@ class CreditCard
$server_response = $this->stripe->payment_hash->data->server_response; $server_response = $this->stripe->payment_hash->data->server_response;
if ($server_response->status == 'succeeded') { 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); $this->stripe->logSuccessfulGatewayResponse(['response' => json_decode($request->gateway_response), 'data' => $this->stripe->payment_hash], SystemLog::TYPE_STRIPE);