Jump to content

[Help] Gateway callback convert Currency


lamjed001

Recommended Posts

I made my own payment gateway and used this for currency conversion but I have a problem, the amount remains the same after the conversion

For example product price is 5$ with usd currency and 4€ for euro currency
and in callback i posted 5$ and currency=USD but my account is using euro currency
and the result is 5 not 4 please give me solution and thanks ♥

<?php
require_once __DIR__ . '/../../../init.php';
require_once __DIR__ . '/../../../includes/gatewayfunctions.php';
require_once __DIR__ . '/../../../includes/invoicefunctions.php';

$gatewayModuleName = basename(__FILE__, '.php');
$gatewayParams = getGatewayVariables($gatewayModuleName);

$paymentAmount=5.00;
$invoiceId=1;
$invoice = WHMCS\Billing\Invoice::find($invoiceId);
$userCurrency = getCurrency($invoice->clientId);
if ($userCurrency["code"] != "EUR") {
    $paymentCurrencyID = WHMCS\Database\Capsule::table("tblcurrencies")->where("code", "EUR")->value("id");
    if (is_null($paymentCurrencyID)) {
        logTransaction($gatewayParams['name'], $_POST, "Unsuccessful - Invalid Currency");
        exit;
    }
    $paymentAmount = convertCurrency($paymentAmount, $paymentCurrencyID, $userCurrency["id"]); //Here the result is the same amount sent
}
?>

 

Edited by lamjed001
Add tags
Link to comment
Share on other sites

  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated