Jump to content

Third Party Gateway Development


Haithem_Tebib

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • 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