Fixes for confirming gateway feesg

This commit is contained in:
David Bomba 2024-09-02 09:00:13 +10:00
parent d153ecbe1f
commit e5e7a17d82
3 changed files with 9 additions and 8 deletions

View File

@ -400,8 +400,12 @@ class BaseDriver extends AbstractPaymentDriver
$invoice = $this->payment_hash->fee_invoice; $invoice = $this->payment_hash->fee_invoice;
$fee_count = collect($invoice->line_items) $fee_count = collect($invoice->line_items)
->map(function ($item){
$item->gross_line_total = round($item->gross_line_total, 2);
return $item;
})
->whereIn('type_id', ['3','4']) ->whereIn('type_id', ['3','4'])
->where('gross_line_total', $fee_total) ->where('gross_line_total', round($fee_total,2))
->count(); ->count();
if($invoice && $fee_count == 0){ if($invoice && $fee_count == 0){

View File

@ -92,6 +92,8 @@ class AddGatewayFee extends AbstractService
/**Refresh Invoice values*/ /**Refresh Invoice values*/
$this->invoice = $this->invoice->calc()->getInvoice(); $this->invoice = $this->invoice->calc()->getInvoice();
nlog($this->invoice->line_items);
$new_balance = $this->invoice->balance; $new_balance = $this->invoice->balance;
if (floatval($new_balance) - floatval($balance) != 0) { if (floatval($new_balance) - floatval($balance) != 0) {
@ -141,12 +143,6 @@ class AddGatewayFee extends AbstractService
if (floatval($new_balance) - floatval($balance) != 0) { if (floatval($new_balance) - floatval($balance) != 0) {
$adjustment = $new_balance - $balance; $adjustment = $new_balance - $balance;
// $this->invoice
// ->client
// ->service()
// ->updateBalance($adjustment * -1)
// ->save();
$this->invoice $this->invoice
->ledger() ->ledger()
->updateInvoiceBalance($adjustment * -1, 'Adjustment for adding gateway DISCOUNT'); ->updateInvoiceBalance($adjustment * -1, 'Adjustment for adding gateway DISCOUNT');

View File

@ -148,9 +148,9 @@ class AutoBillInvoice extends AbstractService
]); ]);
nlog("Payment hash created => {$payment_hash->id}"); nlog("Payment hash created => {$payment_hash->id}");
$this->invoice->saveQuietly();
$payment = false; $payment = false;
try { try {
$payment = $gateway_token->gateway $payment = $gateway_token->gateway
->driver($this->client) ->driver($this->client)
@ -163,6 +163,7 @@ class AutoBillInvoice extends AbstractService
} }
$this->invoice = $this->invoice->fresh();
$this->invoice->auto_bill_tries += 1; $this->invoice->auto_bill_tries += 1;
if ($this->invoice->auto_bill_tries == 3) { if ($this->invoice->auto_bill_tries == 3) {