Skip to content

Commit d17a1e2

Browse files
committed
[fix] Add logic to convert back to client currency after payment
1 parent 9d74cce commit d17a1e2

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

modules/gateways/callback/paystack.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,16 @@
163163
*/
164164
$invoiceId = checkCbInvoiceID($invoiceId, $gatewayModuleName);
165165

166+
$amount = floatval($txStatus->amount)/100;
167+
if ($gatewayParams['convertto']) {
168+
$result = select_query("tblclients", "tblinvoices.invoicenum,tblclients.currency,tblcurrencies.code", array("tblinvoices.id" => $invoiceId), "", "", "", "tblinvoices ON tblinvoices.userid=tblclients.id INNER JOIN tblcurrencies ON tblcurrencies.id=tblclients.currency");
169+
$data = mysql_fetch_array($result);
170+
$invoice_currency_id = $data['currency'];
171+
172+
$converto_amount = convertCurrency($amount, $gatewayParams['convertto'], $invoice_currency_id);
173+
$amount = format_as_currency($converto_amount);
174+
}
175+
166176
/**
167177
* Add Invoice Payment.
168178
*
@@ -174,7 +184,7 @@
174184
* @param float $paymentFee Payment fee (optional)
175185
* @param string $gatewayModule Gateway module name
176186
*/
177-
addInvoicePayment($invoiceId, $trxref, floatval($txStatus->amount)/100, 0, $gatewayModuleName);
187+
addInvoicePayment($invoiceId, $trxref, $amount, 0, $gatewayModuleName);
178188

179189
// load invoice
180190
$isSSL = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443);

0 commit comments

Comments
 (0)