条码支付
This commit is contained in:
parent
530c29604b
commit
d71aaa72a7
@ -10,6 +10,8 @@ class Demo extends BaseController
|
|||||||
|
|
||||||
$order=['auth_code'=>$name];
|
$order=['auth_code'=>$name];
|
||||||
$a=WechatService::create()->micropay()->scanCode($order);
|
$a=WechatService::create()->micropay()->scanCode($order);
|
||||||
|
// $a = WechatService::create()->jsPay(null, 'wx'.time(), 1, '支付测试', 'APP支付测试', '', 'APP');
|
||||||
|
|
||||||
halt($a);
|
halt($a);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -994,7 +994,7 @@ class WechatService
|
|||||||
return $this->application->combinePay;
|
return $this->application->combinePay;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 条码支付
|
||||||
* @return easywechat\micropay\Client
|
* @return easywechat\micropay\Client
|
||||||
*/
|
*/
|
||||||
public function micropay()
|
public function micropay()
|
||||||
|
@ -12,31 +12,44 @@
|
|||||||
|
|
||||||
namespace crmeb\services\easywechat\micropay;
|
namespace crmeb\services\easywechat\micropay;
|
||||||
|
|
||||||
|
|
||||||
use crmeb\services\easywechat\BaseClient;
|
use crmeb\services\easywechat\BaseClient;
|
||||||
|
|
||||||
class Client extends BaseClient
|
class Client extends BaseClient
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 条码支付
|
||||||
|
*/
|
||||||
public function scanCode($order)
|
public function scanCode($order)
|
||||||
{
|
{
|
||||||
$content=[
|
|
||||||
'appid'=>$this->app['config']['app_id'],
|
$content = [
|
||||||
'mch_id'=>2,
|
'appid' => $this->app['config']['app_id'],
|
||||||
'device_info'=>3,
|
'mch_id' => $this->app['config']['payment']['merchant_id'],
|
||||||
'body'=>'线下支付',
|
'body' => $order['body'],
|
||||||
'attach'=>'测试数据',
|
'nonce_str' => $order['order_sn'],
|
||||||
'out_trade_no'=>time(),
|
'total_fee' => $order['pay_price'],
|
||||||
'total_fee'=>1,
|
'spbill_create_ip' => request()->ip(),
|
||||||
'spbill_create_ip'=>request()->ip(),
|
'auth_code' => (string)$order['auth_code'],
|
||||||
'auth_code'=>$order['auth_code'],
|
|
||||||
];
|
];
|
||||||
$content = json_encode($content);
|
$content['out_trade_no']= $order['order_sn'];
|
||||||
$this->isService=false;
|
ksort($content); // 按照键名排序
|
||||||
$res= $this->request('/pay/micropay', 'POST', ['sign_body' => $content]);
|
$sign_str = urldecode(http_build_query($content)); // 构造签名字符串
|
||||||
|
$sign = strtoupper(md5($sign_str . '&key=' . 'FC685E79840793CE86AE621CE9EDFCDA')); // 生成签名
|
||||||
|
$content['sign']=$sign;
|
||||||
|
$this->isService = false;
|
||||||
|
$res = $this->request('/pay/micropay', 'POST', ['sign_body' => $this->arrayToXml($content)]);
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function arrayToXml($arr)
|
||||||
|
{
|
||||||
|
$xml = "<xml>";
|
||||||
|
foreach ($arr as $key => $val) {
|
||||||
|
$xml .= "<" . $key . ">" . $val . "</" . $key . ">";
|
||||||
|
}
|
||||||
|
$xml .= "</xml>";
|
||||||
|
return $xml;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user