Advertisement
Guest User

Untitled

a guest
Jun 27th, 2016
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.57 KB | None | 0 0
  1. <?php
  2.  
  3. ini_set('display_errors', 1);
  4.  
  5. $amount = $_GET['amount'];
  6.  
  7. //$customerIp = $_GET['customer_ip'];
  8.  
  9. $customerIp = $_SERVER['REMOTE_ADDR'];
  10.  
  11. $description = $_GET['description'];
  12.  
  13. //$merchantIp = $_GET['merchant_ip'];
  14.  
  15. $merchantIp = $_SERVER['SERVER_ADDR'];
  16.  
  17. $returnUrl = "https://higoapps.com/api/mandiri-ecash/validate-ipg.php";
  18.  
  19. $mid = 'HIGOAPPS';
  20.  
  21. $trxid = $_GET['idtrans'];
  22.  
  23. $hash = sha1(strtoupper($mid) . $amount . $customerIp);
  24.  
  25. $xml_post_string =
  26. '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.service.gateway.ecomm.ptdam.com/">
  27. <soapenv:Header/>
  28. <soapenv:Body>
  29. <ws:generate>
  30. <params>
  31. <amount>' . $amount . '</amount>
  32. <clientAddress>' . $customerIp . '</clientAddress>
  33. <description>' . $description . '</description>
  34. <memberAddress>' . $merchantIp . '</memberAddress>
  35. <returnUrl>' . $returnUrl . '</returnUrl>
  36. <toUsername>' . $mid . '</toUsername>
  37. <hash>' . $hash . '</hash>
  38. <trxid>' . $trxid . '</trxid>
  39. </params>
  40. </ws:generate>
  41. </soapenv:Body>
  42. </soapenv:Envelope>';
  43.  
  44. $headers = array(            
  45.     "Content-type: text/xml;charset=\"utf-8\"",
  46.     "Accept: text/xml",
  47.     "Cache-Control: no-cache",
  48.     "Pragma: no-cache",
  49.     "Content-length: " . strlen($xml_post_string),
  50.     );
  51.  
  52. $url = 'https://mandiriecash.com/ecommgateway/services/ecommgwws?wsdl';
  53. $username = $mid;
  54. $password = 'A98871A2D438719935D1616125050C47';
  55.  
  56. try {
  57.     $ch = curl_init();
  58.     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  59.     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  60.     curl_setopt($ch, CURLOPT_URL, $url);
  61.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  62.     curl_setopt($ch, CURLOPT_USERPWD, $username.":".$password);
  63.     curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
  64.     curl_setopt($ch, CURLOPT_TIMEOUT, 10);
  65.     curl_setopt($ch, CURLOPT_POST, true);
  66.     curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string);
  67.     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  68.  
  69.             // converting
  70.     $response = curl_exec($ch);
  71.  
  72.     if ($response == false) {
  73.         throw new Exception(curl_error($ch), curl_errno($ch));
  74.     }
  75.  
  76.     curl_close($ch);
  77.  
  78. } catch(Exception $e) {
  79.  
  80.     trigger_error(sprintf(
  81.         'Curl failed with error #%d: %s',
  82.         $e->getCode(), $e->getMessage()),
  83.     E_USER_ERROR);
  84.  
  85. }
  86.  
  87. $parser = simplexml_load_string($response);
  88. $parserEnv = $parser->children('soap', true);
  89. $return = $parserEnv->Body->children('ns2', true)->generateResponse->children();
  90.  
  91. header("Location:https://mandiriecash.com/ecommgateway/payment.html?id=".$return[0]);
  92. exit();
  93.  
  94. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement