diff --git a/app/PaymentDrivers/Forte/CreditCard.php b/app/PaymentDrivers/Forte/CreditCard.php index 8e632357e993..b9882b3a4349 100644 --- a/app/PaymentDrivers/Forte/CreditCard.php +++ b/app/PaymentDrivers/Forte/CreditCard.php @@ -88,8 +88,18 @@ class CreditCard { $payment_hash = PaymentHash::whereRaw('BINARY `hash`= ?', [$request->input('payment_hash')])->firstOrFail(); $amount_with_fee = $payment_hash->data->total->amount_with_fee; - $fee_total = ( 3 * $amount_with_fee) / 100; - $amount_with_fee = $amount_with_fee + $fee_total; + $invoice_totals = $payment_hash->data->total->invoice_totals; + $fee_total = 0; + print_r($payment_hash->data->total); + for ($i = ($invoice_totals * 100) ; $i < ($amount_with_fee * 100); $i++) { + $calculated_fee = ( 3 * $i) / 100; + $calculated_amount_with_fee = round(($i + $calculated_fee) / 100,2); + if ($calculated_amount_with_fee == $amount_with_fee) { + $fee_total = round($calculated_fee / 100,2); + $amount_with_fee = $calculated_amount_with_fee; + break; + } + } try { $curl = curl_init();