Haithem_Tebib Posted September 22, 2016 Share Posted September 22, 2016 Hello, Actually, 'm developping a payment gateway using Third Party Gatewy module.The module redirect successfully to the url of the payment gateway.The only problem i have that the payment gateway requires (xx.xxx) as amount's format to work and amount's format in the ivoice parameters of the WHMCS is (xx.xx) so i converted it with a php function number_format but it doesn't work.Could you please help to find a solution for this issue? thanks 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted September 22, 2016 Share Posted September 22, 2016 what code/syntax you are using to convert this amount? or what is the input and output exactly is? 0 Quote Link to comment Share on other sites More sharing options...
Haithem_Tebib Posted September 22, 2016 Author Share Posted September 22, 2016 i applied the function number_format to the amout in the imput in the code like this: // Invoice Parameters $Amount = number_format($params['Amount'], 3, '.', ''); // System Parameters $postfields['Amount'] = number_format($Amount, 3, '.', ''); and this is my imput: unction gatewaymodule_link($params) { // Gateway Configuration Parameters $Numsite = $params['Numsite']; $Password = $params['Password']; $testMode = $params['testMode']; $orderId = time(); $VAD = $Params['VAD']; $Devise = $params['currency']; // $dropdownField = $params['dropdownField']; //$radioField = $params['radioField']; // $textareaField = $params['textareaField']; // Invoice Parameters $invoiceId = $params['invoiceid']; $description = $params["description"]; $Amount = number_format($params['Amount'], 3, '.', ''); $currencyCode = $params['currency']; // Client Parameters $firstname = $params['clientdetails']['firstname']; $lastname = $params['clientdetails']['lastname']; $email = $params['clientdetails']['email']; $address1 = $params['clientdetails']['address1']; $address2 = $params['clientdetails']['address2']; $city = $params['clientdetails']['city']; $state = $params['clientdetails']['state']; $postcode = $params['clientdetails']['postcode']; $country = $params['clientdetails']['country']; $phone = $params['clientdetails']['phonenumber']; // System Parameters $companyName = $params['companyname']; $systemUrl = $params['systemurl']; $returnUrl = $params['returnurl']; $langPayNow = $params['langpaynow']; $moduleDisplayName = $params['name']; $moduleName = $params['paymentmethod']; $whmcsVersion = $params['whmcsVersion']; $signture = sha1($Numsite . $Password . $orderId . number_format($Amount, 3, '.', '') . $Devise); $url = 'https://preprod.gpgcheckout.com/Paiement_test/Validation_paiement.php'; $postfields = array(); $postfields['order_id'] = $orderId; $postfields['invoice_id'] = $invoiceId; $postfields['username'] = $username; $postfields['description'] = $description; $postfields['Amount'] = number_format($Amount, 3, '.', ''); $postfields['currency'] = $currencyCode; $postfields['first_name'] = $firstname; $postfields['last_name'] = $lastname; $postfields['email'] = $email; $postfields['address1'] = $address1; $postfields['address2'] = $address2; $postfields['city'] = $city; $postfields['state'] = $state; $postfields['postcode'] = $postcode; $postfields['country'] = $country; $postfields['phone'] = $phone; $postfields['signture'] = sha1($Numsite . $Password . $orderId . $Amount . $Devise); $postfields['callback_url'] = $systemUrl . '/modules/gateways/callback/' . $moduleName . '.php'; $postfields['return_url'] = $returnUrl; and this is my output: $htmlOutput = '<form method="post" action="' . $url . '">'; foreach ($postfields as $k => $v) { $htmlOutput .= '<input type="hidden" name="' . $k . '" value="' . urlencode($v) . '" />'; } $htmlOutput .= '<input type="hidden" name="NumSite" value="' . $Numsite . '">'; $htmlOutput .= '<input type="hidden" name="Password" value="' . md5($Password) . '">'; $htmlOutput .= '<input type="hidden" name="orderID" value="' . $orderId . '">'; $htmlOutput .= '<input type="hidden" name="Amount" value="' . $Amount . '">'; $htmlOutput .= '<input type="hidden" name="Currency" value="' . $Devise . '">'; $htmlOutput .= '<input type="hidden" name="CustFirstName" value="' . $firstname . '">'; $htmlOutput .= '<input type="hidden" name="CustLastName" value="' . $lastname . '">'; $htmlOutput .= '<input type="hidden" name="EMAIL" value="' . $email . '">'; $htmlOutput .= '<input type="hidden" name="CustAddress" value="' . $address1 . '">'; $htmlOutput .= '<input type="hidden" name="signature" value="' . $signture . '">'; $htmlOutput .= '<input type="submit" value="' . $langPayNow . '" />'; $htmlOutput .= '</form>'; return $htmlOutput; Many thanks. 0 Quote Link to comment Share on other sites More sharing options...
Haithem_Tebib Posted September 22, 2016 Author Share Posted September 22, 2016 the syntaxe is $Amount = number_format($params['Amount'], 3, '.', ''); My input: // Gateway Configuration Parameters $Numsite = $params['Numsite']; $Password = $params['Password']; $testMode = $params['testMode']; $orderId = time(); $VAD = $Params['VAD']; $Devise = $params['currency']; // $dropdownField = $params['dropdownField']; //$radioField = $params['radioField']; // $textareaField = $params['textareaField']; // Invoice Parameters $invoiceId = $params['invoiceid']; $description = $params["description"]; $Amount = number_format($params['Amount'], 3, '.', ''); $currencyCode = $params['currency']; // Client Parameters $firstname = $params['clientdetails']['firstname']; $lastname = $params['clientdetails']['lastname']; $email = $params['clientdetails']['email']; $address1 = $params['clientdetails']['address1']; $address2 = $params['clientdetails']['address2']; $city = $params['clientdetails']['city']; $state = $params['clientdetails']['state']; $postcode = $params['clientdetails']['postcode']; $country = $params['clientdetails']['country']; $phone = $params['clientdetails']['phonenumber']; // System Parameters $companyName = $params['companyname']; $systemUrl = $params['systemurl']; $returnUrl = $params['returnurl']; $langPayNow = $params['langpaynow']; $moduleDisplayName = $params['name']; $moduleName = $params['paymentmethod']; $whmcsVersion = $params['whmcsVersion']; $signture = sha1($Numsite . $Password . $orderId . number_format($Amount, 3, '.', '') . $Devise); $url = 'https://preprod.gpgcheckout.com/Paiement_test/Validation_paiement.php'; $postfields = array(); $postfields['order_id'] = $orderId; $postfields['invoice_id'] = $invoiceId; $postfields['username'] = $username; $postfields['description'] = $description; $postfields['Amount'] = number_format($Amount, 3, '.', ''); $postfields['currency'] = $currencyCode; $postfields['first_name'] = $firstname; $postfields['last_name'] = $lastname; $postfields['email'] = $email; $postfields['address1'] = $address1; $postfields['address2'] = $address2; $postfields['city'] = $city; $postfields['state'] = $state; $postfields['postcode'] = $postcode; $postfields['country'] = $country; $postfields['phone'] = $phone; $postfields['signture'] = sha1($Numsite . $Password . $orderId . $Amount . $Devise); $postfields['callback_url'] = $systemUrl . '/modules/gateways/callback/' . $moduleName . '.php'; $postfields['return_url'] = $returnUrl; my output: $htmlOutput = '<form method="post" action="' . $url . '">'; foreach ($postfields as $k => $v) { $htmlOutput .= '<input type="hidden" name="' . $k . '" value="' . urlencode($v) . '" />'; } $htmlOutput .= '<input type="hidden" name="NumSite" value="' . $Numsite . '">'; $htmlOutput .= '<input type="hidden" name="Password" value="' . md5($Password) . '">'; $htmlOutput .= '<input type="hidden" name="orderID" value="' . $orderId . '">'; $htmlOutput .= '<input type="hidden" name="Amount" value="' . $Amount . '">'; $htmlOutput .= '<input type="hidden" name="Currency" value="' . $Devise . '">'; $htmlOutput .= '<input type="hidden" name="CustFirstName" value="' . $firstname . '">'; $htmlOutput .= '<input type="hidden" name="CustLastName" value="' . $lastname . '">'; $htmlOutput .= '<input type="hidden" name="EMAIL" value="' . $email . '">'; $htmlOutput .= '<input type="hidden" name="CustAddress" value="' . $address1 . '">'; $htmlOutput .= '<input type="hidden" name="signature" value="' . $signture . '">'; $htmlOutput .= '<input type="submit" value="' . $langPayNow . '" />'; $htmlOutput .= '</form>'; return $htmlOutput; Many Thanks 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted September 23, 2016 Share Posted September 23, 2016 try replacing $params['Amount'] with $params['amount'] 0 Quote Link to comment Share on other sites More sharing options...
Haithem_Tebib Posted September 23, 2016 Author Share Posted September 23, 2016 Thank you very much the payment gateway module works! 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.