Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion modules/gateways/callback/paymes.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,49 @@
// Paymes return post data
$invoiceId = $_POST['id'];
$transactionId = $_POST["payuPaymentReference"];
$paymentAmount = $_POST["amount"];
$paymentAmount1 = $_POST["amount"];
$paymentFee = 0;
$currency = $_POST["currency"];
$message = $_POST["message"];
$success = $_POST['status'] == '3DS_ENROLLED';

/**
* If useInvoiceAmountAsPaid enabled, use the invoice amount,
* as paid amount this to avoid currency conversion issue on non-Default WHMCS Currency transaction
*/

if ($gatewayParams['useInvoiceAmountAsPaid'] == 'on') {
$invoice_result = mysql_fetch_assoc(select_query('tblinvoices', 'total, userid', array("id"=>$order_id)));
$invoice_amount = $invoice_result['total'];
$paymentAmount = $invoice_amount;
}

/**
* If tryToConvertCurrencyBack enabled
* Try to convert amount back to Default WHMCS Currency, if not Default WHMCS Currency
*/
if ($gatewayParams['tryToConvertCurrencyBack'] == 'on') {
try {
$invoice_result = mysql_fetch_assoc(select_query('tblinvoices', 'total, userid', array("id"=>$order_id)));
$invoice_amount = $invoice_result['total'];
$client_result = mysql_fetch_assoc(select_query('tblclients', 'currency', array("id"=>$invoice_result['userid'])));
$currency_id = $client_result['currency'];
$idr_currency_id = $gatewayParams['convertto'];
if($currency_id != $idr_currency_id) {
$converted_amount = convertCurrency(
$paymentAmount1,
$idr_currency_id,
$currency_id
);
} else {
$converted_amount = $paymentAmount1;
}
$paymentAmount = $converted_amount;
} catch (Exception $e) {
echo "fail to tryToConvertCurrencyBack";
}
}

$transactionStatus = $success ? 'Success' : 'Failure';

$invoiceId = checkCbInvoiceID($invoiceId, $gatewayParams['name']);
Expand Down
12 changes: 12 additions & 0 deletions modules/gateways/paymes.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ function paymes_config()
'Default' => '',
'Description' => 'paym.es\'in verdiği size özel kodu (Secret Key) buraya girin',
),
'useInvoiceAmountAsPaid' => array(
'FriendlyName' => 'Fatura tutarını ödenen tutar olarak kullan',
'Type' => 'yesno',
'Description' => 'Bunu yalnızca varsayılan para biriminiz TL değilken ve ödenen faturada tutar uyuşmazlığı sorunuyla karşılaşırsanız kullanın, bu seçenek, ödenen tutar olarak fatura tutarını kullanır (önerilen ayar: kapalı)',
),
'tryToConvertCurrencyBack' => array(
'FriendlyName' => 'Sanal Pos\'tan gelen tutarı dönüştür',
'Type' => 'yesno',
'Description' => 'Bunu yalnızca varsayılan para biriniz TL değilken ve ödenen faturada tutar uyuşmazlığı sorunuyla karşılaşırsanız kullanın, bu seçenek, sanal pos\'tan gelen tutarı orijinal fatura para birimi tutarına geri çevirir. (önerilen ayar: kapalı)',
),
);
}

Expand Down Expand Up @@ -64,6 +74,8 @@ function paymes_3dsecure($params)
$companyName = $params['companyname'];
$moduleName = $params['paymentmethod'];
$langPayNow = $params['langpaynow'];
$useInvoiceAmountAsPaid = $params['useInvoiceAmountAsPaid'];
$tryToConvertCurrencyBack = $params['tryToConvertCurrencyBack'];

if(!empty($address2)) {
$address1 .= " " . $address2;
Expand Down