Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
723
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.61 KB | None | 0 0
  1. <?php
  2. $merchantCode = 'D5085'; // from duitku
  3. $merchantKey = 'e70ce6181f6c0350d24ca2316f6a9bba'; // from duitku
  4. $paymentAmount = '40000';
  5. $paymentMethod = 'M1'; // WW = duitku wallet, VC = Credit Card, MY = Mandiri Clickpay, BK = BCA KlikPay
  6. $merchantOrderId = time(); // from merchant, unique
  7. $productDetails = 'Test Pay with duitku';
  8. $email = 'test@test.com'; // your customer email
  9. $phoneNumber = '08123456789'; // your customer phone number (optional)
  10. $additionalParam = ''; // optional
  11. $merchantUserInfo = ''; // optional
  12. $customerVaName = 'John Doe'; // display name on bank confirmation display
  13. $callbackUrl = 'http://example.com/callback'; // url for callback
  14. $returnUrl = 'http://example.com/return'; // url for redirect
  15. $expiryPeriod = '10'; // set the expired time in minutes
  16.  
  17. $signature = md5($merchantCode . $merchantOrderId . $paymentAmount . $merchantKey);
  18.  
  19. $item1 = array(
  20. 'name' => 'Test Item 1',
  21. 'price' => 10000,
  22. 'quantity' => 1);
  23.  
  24. $item2 = array(
  25. 'name' => 'Test Item 2',
  26. 'price' => 30000,
  27. 'quantity' => 3);
  28.  
  29. $itemDetails = array(
  30. $item1, $item2
  31. );
  32.  
  33. $params = array(
  34. 'merchantCode' => $merchantCode,
  35. 'paymentAmount' => $paymentAmount,
  36. 'paymentMethod' => $paymentMethod,
  37. 'merchantOrderId' => $merchantOrderId,
  38. 'productDetails' => $productDetails,
  39. 'additionalParam' => $additionalParam,
  40. 'merchantUserInfo' => $merchantUserInfo,
  41. 'customerVaName' => $customerVaName,
  42. 'email' => $email,
  43. 'phoneNumber' => $phoneNumber,
  44. 'itemDetails' => $itemDetails,
  45. 'callbackUrl' => $callbackUrl,
  46. 'returnUrl' => $returnUrl,
  47. 'signature' => $signature,
  48. 'expiryPeriod' => $expiryPeriod
  49. );
  50.  
  51. $params_string = json_encode($params);
  52. $url = 'https://sandbox.duitku.com/webapi/api/merchant/v2/inquiry'; // Sandbox
  53. // $url = 'https://passport.duitku.com/webapi/api/merchant/v2/inquiry'; // Production
  54. $ch = curl_init();
  55.  
  56. curl_setopt($ch, CURLOPT_URL, $url);
  57. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  58. curl_setopt($ch, CURLOPT_POSTFIELDS, $params_string);
  59. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  60. curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  61. 'Content-Type: application/json',
  62. 'Content-Length: ' . strlen($params_string))
  63. );
  64. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  65.  
  66. //execute post
  67. $request = curl_exec($ch);
  68. $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  69.  
  70. if($httpCode == 200)
  71. {
  72. $result = json_decode($request, true);
  73. //header('location: '. $result['paymentUrl']);
  74. echo "paymentUrl :". $result['paymentUrl'] . "<br />";
  75. echo "merchantCode :". $result['merchantCode'] . "<br />";
  76. echo "reference :". $result['reference'] . "<br />";
  77. echo "vaNumber :". $result['vaNumber'] . "<br />";
  78. echo "amount :". $result['amount'] . "<br />";
  79. echo "statusCode :". $result['statusCode'] . "<br />";
  80. echo "statusMessage :". $result['statusMessage'] . "<br />";
  81. }
  82. else
  83. echo $httpCode;
  84. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement