Advertisement
Guest User

Untitled

a guest
Jan 5th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.02 KB | None | 0 0
  1. <?php
  2.  
  3. define('CORE_API_HTTP_USR', 'merchant_17877');
  4. define('CORE_API_HTTP_PWD', '17877HybqJ3XmpjI7GVKv7e7OLM83xEtfWs');
  5. $bk = 'https://www.baokim.vn/the-cao/restFul/send';
  6. $user = $_POST['txtuser'];
  7. $seri = isset($_POST['txtseri']) ? $_POST['txtseri'] : '';
  8. $sopin = isset($_POST['txtpin']) ? $_POST['txtpin'] : '';
  9. //Loai the cao (VINA, MOBI, VIETEL, VTC, GATE)
  10. switch ($cardtype){
  11. case 'MobiPhone': // Mobifone
  12. $card_type_bk = 'MOBI';
  13. break;
  14.  
  15. case 'VinaPhone': // Vinaphone
  16. $card_type_bk = 'VINA';
  17. break;
  18.  
  19. case 'Viettel': // Viettel
  20. $card_type_bk = 'VIETEL';
  21. break;
  22. default : $card_type_bk = 'Unknow';
  23. }
  24. //Mã MerchantID dang kí trên B?o Kim
  25. $merchant_id = '17877';
  26. //Api username
  27. $api_username = 'muhpcom';
  28. //Api Pwd d
  29. $api_password = 'muhpcom98ugvsHAGs6';
  30. //Mã TransactionId
  31. $transaction_id = time();
  32. //mat khau di kem ma website dang kí trên B?o Kim
  33. $secure_code = 'adffde71d02d99bb';
  34.  
  35. $arrayPost = array(
  36. 'merchant_id'=>$merchant_id,
  37. 'api_username'=>$api_username,
  38. 'api_password'=>$api_password,
  39. 'transaction_id'=>$transaction_id,
  40. 'card_id'=>$card_type_bk,
  41. 'pin_field'=>$card_num_encode,
  42. 'seri_field'=>$card_serial_encode,
  43. 'algo_mode'=>'hmac'
  44. );
  45.  
  46. ksort($arrayPost);
  47.  
  48. $data_sign = hash_hmac('SHA1',implode('',$arrayPost),$secure_code);
  49.  
  50. $arrayPost['data_sign'] = $data_sign;
  51.  
  52. $curl = curl_init($bk);
  53.  
  54. curl_setopt_array($curl, array(
  55. CURLOPT_POST=>true,
  56. CURLOPT_HEADER=>false,
  57. CURLINFO_HEADER_OUT=>true,
  58. CURLOPT_TIMEOUT=>30,
  59. CURLOPT_RETURNTRANSFER=>true,
  60. CURLOPT_SSL_VERIFYPEER => false,
  61. CURLOPT_HTTPAUTH=>CURLAUTH_DIGEST|CURLAUTH_BASIC,
  62. CURLOPT_USERPWD=>CORE_API_HTTP_USR.':'.CORE_API_HTTP_PWD,
  63. CURLOPT_POSTFIELDS=>http_build_query($arrayPost)
  64. ));
  65.  
  66. $data = curl_exec($curl);
  67.  
  68. $status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
  69.  
  70. $result = json_decode($data,true);
  71.  
  72. date_default_timezone_set('Asia/Ho_Chi_Minh');
  73. $time = date("Y-m-d H:i:s",time());
  74. if(isset($result['transaction_id'])){
  75. if($status==200)//n?p th? dúng
  76. {
  77. $edit_menhgia = $result['amount'];
  78. $edit_menhgia = abs(intval($edit_menhgia));
  79. $up_stat = 2;
  80. $logcontent_after = "Thông tin th?: Th? dúng. M?nh giá: $menhgia VNÐ.";
  81. } else { //n?p th? sai
  82. $error_code = $reponse_bk->error_code;
  83. $notice = $result['errorMessage'];
  84. $up_stat = 3;
  85. $logcontent_after = "Th? sai.";
  86. }
  87. // Write Log Nap Bao Kim
  88. $logcontent = "Tài kho?n K?t n?i: $username_bk. M?t kh?u K?t n?i: $password_bk. Mã WebSite: $merchant_id. M?t kh?u: $secure_pass. Mã th?: $card_num_encode, Seri th?: $card_serial_encode. URL n?p: $url. ";
  89. $logcontent .= $logcontent_after;
  90. _writelog("log_autobaokim.txt", $logcontent);
  91. // End Write Log Nap Bao Kim
  92. include('autonap_duyet.php');
  93. }else{
  94. $notice_nap = "Đăng kí mua V.Point bằng thẻ <strong>$cardtype</strong> cho tài khoản <strong>$login</strong> thành công. Hãy theo dõi trong phần danh sách thẻ đã nạp.";
  95. }
  96.  
  97.  
  98.  
  99. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement