Advertisement
Guest User

Untitled

a guest
Aug 14th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 KB | None | 0 0
  1. <?php
  2. if (!defined('WHMCS')) {
  3. exit('This file cannot be accessed directly');
  4. }
  5.  
  6. $GATEWAYMODULE['emsname'] = 'ems';
  7. $GATEWAYMODULE['emsvisiblename'] = 'EMS';
  8. $GATEWAYMODULE['emspaytype'] = 'Invoices';
  9.  
  10. function ems_config() {
  11. $configarray = array(
  12. 'FriendlyName' => array(
  13. 'Type' => 'System',
  14. 'Value' => 'EMS'
  15. ),
  16. 'shopid' => array(
  17. 'FriendlyName' => 'Shop ID',
  18. 'Type' => 'text',
  19. 'Size' => '20',
  20. 'Default' => 'Shop ID'
  21. ),
  22. 'secretkey' => array(
  23. 'FriendlyName' => 'Secret key',
  24. 'Type' => 'text',
  25. 'Size' => '20',
  26. 'Default' => 'Secret key'
  27. ),
  28. 'username' => array(
  29. 'FriendlyName' => 'Username',
  30. 'Type' => 'text',
  31. 'Size' => '20',
  32. 'Default' => 'Username'
  33. ),
  34. 'password' => array(
  35. 'FriendlyName' => 'Password',
  36. 'Type' => 'text',
  37. 'Size' => '20',
  38. 'Default' => 'Password'
  39. ),
  40. 'testmode' => array(
  41. 'FriendlyName' => 'Test mode',
  42. 'Type' => 'yesno',
  43. 'Description' => 'use test mode'
  44. )
  45. );
  46. return $configarray;
  47. }
  48.  
  49. function ems_link($params) {
  50. $hash = hash('SHA512', $params['shopid'].';'.$params['secretkey'].';'.$params['invoiceid'].';'.$params['amount'].';'.$params['currency']);
  51. $ch = curl_init();
  52.  
  53. if ($params['testmode']) {
  54. $url = 'https://test-ms.epayments.com';
  55. } else {
  56. $url = 'https://ms.epayments.com';
  57. }
  58.  
  59. 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');
  60. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  61. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  62. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  63. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  64. curl_setopt($ch, CURLOPT_HEADER, false);
  65. curl_setopt($ch, CURLOPT_NOBODY, false);
  66.  
  67. if ($params['testmode']) {
  68. curl_setopt($ch, CURLOPT_VERBOSE, true);
  69.  
  70. $verbose = fopen(dirname(__FILE__).'/ems_init_log_'.time().'.txt', 'w+');
  71. curl_setopt($ch, CURLOPT_STDERR, $verbose);
  72. }
  73.  
  74. $res = curl_exec($ch);
  75. curl_close($ch);
  76.  
  77. $json = json_decode($res, true);
  78.  
  79. if (empty($json['result']['urlToRedirect'])) {
  80. var_dump($res);
  81. exit;
  82. }
  83.  
  84. $url = parse_url($json['result']['urlToRedirect']);
  85.  
  86. $form = '<form action="'.$url['scheme'].'://'.$url['host'].$url['path'].'" method="GET">';
  87. $params = explode('&', $url['query']);
  88.  
  89. foreach($params as $param) {
  90. list($key, $val) = explode('=', $param);
  91. $form .= '<input name="'.$key.'" type="hidden" value="'.$val.'">';
  92. }
  93.  
  94. $form .= '<input type="submit" value="GO" />';
  95. $form .= '</form>';
  96.  
  97. return $form;
  98. }
  99. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement