Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (!defined('WHMCS')) {
- exit('This file cannot be accessed directly');
- }
- $GATEWAYMODULE['emsname'] = 'ems';
- $GATEWAYMODULE['emsvisiblename'] = 'EMS';
- $GATEWAYMODULE['emspaytype'] = 'Invoices';
- function ems_config() {
- $configarray = array(
- 'FriendlyName' => array(
- 'Type' => 'System',
- 'Value' => 'EMS'
- ),
- 'shopid' => array(
- 'FriendlyName' => 'Shop ID',
- 'Type' => 'text',
- 'Size' => '20',
- 'Default' => 'Shop ID'
- ),
- 'secretkey' => array(
- 'FriendlyName' => 'Secret key',
- 'Type' => 'text',
- 'Size' => '20',
- 'Default' => 'Secret key'
- ),
- 'username' => array(
- 'FriendlyName' => 'Username',
- 'Type' => 'text',
- 'Size' => '20',
- 'Default' => 'Username'
- ),
- 'password' => array(
- 'FriendlyName' => 'Password',
- 'Type' => 'text',
- 'Size' => '20',
- 'Default' => 'Password'
- ),
- 'testmode' => array(
- 'FriendlyName' => 'Test mode',
- 'Type' => 'yesno',
- 'Description' => 'use test mode'
- )
- );
- return $configarray;
- }
- function ems_link($params) {
- $hash = hash('SHA512', $params['shopid'].';'.$params['secretkey'].';'.$params['invoiceid'].';'.$params['amount'].';'.$params['currency']);
- $ch = curl_init();
- if ($params['testmode']) {
- $url = 'https://test-ms.epayments.com';
- } else {
- $url = 'https://ms.epayments.com';
- }
- curl_setopt($ch, CURLOPT_URL, $url.'/api/v1/public/paymentpage?ShopId='.$params['shopid'].'&OrderName=EMSPayment&OrderNumber='.$params['invoiceid'].'&OrderSumAmount='.$params['amount'].'&OrderSumCurrency='.$params['currency'].'&Sha512='.$hash.'&GatewayId=1');
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_HEADER, false);
- curl_setopt($ch, CURLOPT_NOBODY, false);
- if ($params['testmode']) {
- curl_setopt($ch, CURLOPT_VERBOSE, true);
- $verbose = fopen(dirname(__FILE__).'/ems_init_log_'.time().'.txt', 'w+');
- curl_setopt($ch, CURLOPT_STDERR, $verbose);
- }
- $res = curl_exec($ch);
- curl_close($ch);
- $json = json_decode($res, true);
- if (empty($json['result']['urlToRedirect'])) {
- var_dump($res);
- exit;
- }
- $url = parse_url($json['result']['urlToRedirect']);
- $form = '<form action="'.$url['scheme'].'://'.$url['host'].$url['path'].'" method="GET">';
- $params = explode('&', $url['query']);
- foreach($params as $param) {
- list($key, $val) = explode('=', $param);
- $form .= '<input name="'.$key.'" type="hidden" value="'.$val.'">';
- }
- $form .= '<input type="submit" value="GO" />';
- $form .= '</form>';
- return $form;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement