当前位置:   article > 正文

云账户自动提现封装(支付宝加银行卡)_云账户对接/api/payment/v1/order-realtime

云账户对接/api/payment/v1/order-realtime

目录

1、支付宝自动提现代码

2、银行卡自动提现代码


 

1、支付宝自动提现代码

  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: bianenhui
  5. * Date: 2019/10/14
  6. * Time: 16:32
  7. */
  8. class DesUtils
  9. {
  10. private $des3key; // 密钥向量
  11. private $iv; // 混淆向量
  12. private $mode = MCRYPT_MODE_CBC;
  13. /**
  14. * 构造,传递⼆个已经进⾏base64_encode的KEY与IV
  15. *
  16. * @param string $des3key
  17. * @param string $iv
  18. */
  19. function __construct($des3key, $iv = null)
  20. {
  21. $this->des3key = $des3key;
  22. $this->iv = $iv;
  23. }
  24. /**
  25. * 加密
  26. * @param <type> $value
  27. * @return <type>
  28. */
  29. public function encrypt($value)
  30. {
  31. $td = mcrypt_module_open(MCRYPT_3DES, '', $this->mode, '');
  32. $iv = substr($this->des3key, 0, 8);
  33. $value = $this->PaddingPKCS7($value);
  34. @mcrypt_generic_init($td, $this->des3key, $iv);
  35. $dec = mcrypt_generic($td, $value);
  36. $ret = base64_encode($dec);
  37. mcrypt_generic_deinit($td);
  38. mcrypt_module_close($td);
  39. return $ret;
  40. }
  41. /**
  42. * 解密
  43. * @param <type> $value
  44. * @return <type>
  45. */
  46. public function decrypt($value)
  47. {
  48. $td = mcrypt_module_open(MCRYPT_3DES, '', $this->mode, '');
  49. $iv = substr($this->des3key, 0, 8);
  50. @mcrypt_generic_init($td, $this->des3key, $iv);
  51. $ret = trim(mdecrypt_generic($td, base64_decode($value)));
  52. $ret = $this->UnPaddingPKCS7($ret);
  53. mcrypt_generic_deinit($td);
  54. mcrypt_module_close($td);
  55. return $ret;
  56. }
  57. private function PaddingPKCS7($data)
  58. {
  59. $block_size = mcrypt_get_block_size('tripledes', $this->mode);
  60. $padding_char = $block_size - (strlen($data) % $block_size);
  61. $data .= str_repeat(chr($padding_char), $padding_char);
  62. return $data;
  63. }
  64. private function UnPaddingPKCS7($text)
  65. {
  66. $pad = ord($text{strlen($text) - 1});
  67. if ($pad > strlen($text)) {
  68. return false;
  69. }
  70. if (strspn($text, chr($pad), strlen($text) - $pad) != $pad) {
  71. return false;
  72. }
  73. return substr($text, 0, -1 * $pad);
  74. }
  75. }
  76. $info = [
  77. "order_id" => "201910141637".time(),
  78. "dealer_id" => "285114213",
  79. "broker_id" => "27532144",
  80. "real_name" => "张三",
  81. "id_card" => "342522188005052140",
  82. "card_no" => "13000000000",
  83. "pay" => "1.00",
  84. "pay_remark" => "",
  85. "check_name" => "NoCheck",
  86. "notify_url" => "",
  87. ];
  88. $des3key = 'hx4b3sdn32z22T3Q5n862v21';
  89. $appkey = "HFrn2i2W3Eo56m2Fh3I7XX34JAEKvwNk";
  90. $json_data = json_encode($info);
  91. $DesUtilsObj = new DesUtils($des3key);
  92. $data = $DesUtilsObj->encrypt($json_data);
  93. $mess = time();
  94. $timestamp = time();
  95. $key_sign = "data=".$data."&mess=".$mess."&timestamp=".$timestamp."&key=".$appkey;
  96. $key_sign1 = "data=".$data."&amp;mess=".$mess."&amp;timestamp=".$timestamp."&amp;key=".$appkey;
  97. $sign = hash_hmac('sha256', $key_sign, $appkey);
  98. $sign_type = "sha256";
  99. $postUrl = 'https://api-jiesuan.yunzhanghu.com/api/payment/v1/order-alipay';
  100. $postData = array(
  101. 'dealer-id' => '28511713',
  102. 'request-id' => "20191015".time().time(),
  103. 'data' => $data,
  104. 'mess' => $mess,
  105. 'timestamp' => $timestamp,
  106. 'sign' => $sign,
  107. 'sign_type' => $sign_type,
  108. );
  109. $header = [
  110. 'Content-Type:application/x-www-form-urlencoded',
  111. 'dealer-id:28511713',
  112. ];
  113. $postData = http_build_query($postData);
  114. $curl = curl_init();
  115. curl_setopt($curl, CURLOPT_URL, $postUrl);
  116. curl_setopt($curl, CURLOPT_USERAGENT,'Opera/9.80 (Windows NT 6.2; Win64; x64) Presto/2.12.388 Version/12.15');
  117. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // stop verifying certificate
  118. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  119. curl_setopt($curl, CURLOPT_POST, true);
  120. curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
  121. curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
  122. curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
  123. $r = curl_exec($curl);
  124. curl_close($curl);
  125. print_r($r);

2、银行卡自动提现代码

  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: bianenhui
  5. * Date: 2019/10/14
  6. * Time: 16:32
  7. */
  8. class DesUtils
  9. {
  10. private $des3key; // 密钥向量
  11. private $iv; // 混淆向量
  12. private $mode = MCRYPT_MODE_CBC;
  13. /**
  14. * 构造,传递⼆个已经进⾏base64_encode的KEY与IV
  15. *
  16. * @param string $des3key
  17. * @param string $iv
  18. */
  19. function __construct($des3key, $iv = null)
  20. {
  21. $this->des3key = $des3key;
  22. $this->iv = $iv;
  23. }
  24. /**
  25. * 加密
  26. * @param <type> $value
  27. * @return <type>
  28. */
  29. public function encrypt($value)
  30. {
  31. $td = mcrypt_module_open(MCRYPT_3DES, '', $this->mode, '');
  32. $iv = substr($this->des3key, 0, 8);
  33. $value = $this->PaddingPKCS7($value);
  34. @mcrypt_generic_init($td, $this->des3key, $iv);
  35. $dec = mcrypt_generic($td, $value);
  36. $ret = base64_encode($dec);
  37. mcrypt_generic_deinit($td);
  38. mcrypt_module_close($td);
  39. return $ret;
  40. }
  41. /**
  42. * 解密
  43. * @param <type> $value
  44. * @return <type>
  45. */
  46. public function decrypt($value)
  47. {
  48. $td = mcrypt_module_open(MCRYPT_3DES, '', $this->mode, '');
  49. $iv = substr($this->des3key, 0, 8);
  50. @mcrypt_generic_init($td, $this->des3key, $iv);
  51. $ret = trim(mdecrypt_generic($td, base64_decode($value)));
  52. $ret = $this->UnPaddingPKCS7($ret);
  53. mcrypt_generic_deinit($td);
  54. mcrypt_module_close($td);
  55. return $ret;
  56. }
  57. private function PaddingPKCS7($data)
  58. {
  59. $block_size = mcrypt_get_block_size('tripledes', $this->mode);
  60. $padding_char = $block_size - (strlen($data) % $block_size);
  61. $data .= str_repeat(chr($padding_char), $padding_char);
  62. return $data;
  63. }
  64. private function UnPaddingPKCS7($text)
  65. {
  66. $pad = ord($text{strlen($text) - 1});
  67. if ($pad > strlen($text)) {
  68. return false;
  69. }
  70. if (strspn($text, chr($pad), strlen($text) - $pad) != $pad) {
  71. return false;
  72. }
  73. return substr($text, 0, -1 * $pad);
  74. }
  75. }
  76. $info = [
  77. "order_id" => "201910141637".time(),
  78. "dealer_id" => "28511713",
  79. "broker_id" => "27532644",
  80. "real_name" => "张三",
  81. "card_no" => "6228880199872220",
  82. "phone_no" => "13488795491",
  83. "id_card" => "5326123123123211",
  84. "pay" => "1.00",
  85. "pay_remark" => "",
  86. "notify_url" => "",
  87. ];
  88. $des3key = 'hx4b3sdn62z22TBQ5n862v21';
  89. $appkey = "HFrn2iqW3Eo56m2FhrI7XX34JAEKvwNk";
  90. $json_data = json_encode($info);
  91. $DesUtilsObj = new DesUtils($des3key);
  92. $data = $DesUtilsObj->encrypt($json_data);
  93. $mess = time();
  94. $timestamp = time();
  95. $key_sign = "data=".$data."&mess=".$mess."&timestamp=".$timestamp."&key=".$appkey;
  96. $key_sign1 = "data=".$data."&amp;mess=".$mess."&amp;timestamp=".$timestamp."&amp;key=".$appkey;
  97. $sign = hash_hmac('sha256', $key_sign, $appkey);
  98. $sign_type = "sha256";
  99. $postUrl = 'https://api-jiesuan.yunzhanghu.com/api/payment/v1/order-realtime';
  100. $postData = array(
  101. 'dealer-id' => '28511313',
  102. 'request-id' => "20191015".time().time(),
  103. 'data' => $data,
  104. 'mess' => $mess,
  105. 'timestamp' => $timestamp,
  106. 'sign' => $sign,
  107. 'sign_type' => $sign_type,
  108. );
  109. $header = [
  110. 'Content-Type:application/x-www-form-urlencoded',
  111. 'dealer-id:28511713',
  112. ];
  113. $postData = http_build_query($postData);
  114. $curl = curl_init();
  115. curl_setopt($curl, CURLOPT_URL, $postUrl);
  116. curl_setopt($curl, CURLOPT_USERAGENT,'Opera/9.80 (Windows NT 6.2; Win64; x64) Presto/2.12.388 Version/12.15');
  117. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // stop verifying certificate
  118. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  119. curl_setopt($curl, CURLOPT_POST, true);
  120. curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
  121. curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
  122. curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
  123. $r = curl_exec($curl);
  124. curl_close($curl);
  125. print_r($r);

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/383537
推荐阅读
相关标签
  

闽ICP备14008679号