条码支付
This commit is contained in:
parent
530c29604b
commit
d71aaa72a7
@ -10,6 +10,8 @@ class Demo extends BaseController
|
||||
|
||||
$order=['auth_code'=>$name];
|
||||
$a=WechatService::create()->micropay()->scanCode($order);
|
||||
// $a = WechatService::create()->jsPay(null, 'wx'.time(), 1, '支付测试', 'APP支付测试', '', 'APP');
|
||||
|
||||
halt($a);
|
||||
}
|
||||
}
|
@ -994,7 +994,7 @@ class WechatService
|
||||
return $this->application->combinePay;
|
||||
}
|
||||
|
||||
/**
|
||||
/** 条码支付
|
||||
* @return easywechat\micropay\Client
|
||||
*/
|
||||
public function micropay()
|
||||
|
@ -12,31 +12,44 @@
|
||||
|
||||
namespace crmeb\services\easywechat\micropay;
|
||||
|
||||
|
||||
use crmeb\services\easywechat\BaseClient;
|
||||
|
||||
class Client extends BaseClient
|
||||
{
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 条码支付
|
||||
*/
|
||||
public function scanCode($order)
|
||||
{
|
||||
$content=[
|
||||
'appid'=>$this->app['config']['app_id'],
|
||||
'mch_id'=>2,
|
||||
'device_info'=>3,
|
||||
'body'=>'线下支付',
|
||||
'attach'=>'测试数据',
|
||||
'out_trade_no'=>time(),
|
||||
'total_fee'=>1,
|
||||
'spbill_create_ip'=>request()->ip(),
|
||||
'auth_code'=>$order['auth_code'],
|
||||
|
||||
$content = [
|
||||
'appid' => $this->app['config']['app_id'],
|
||||
'mch_id' => $this->app['config']['payment']['merchant_id'],
|
||||
'body' => $order['body'],
|
||||
'nonce_str' => $order['order_sn'],
|
||||
'total_fee' => $order['pay_price'],
|
||||
'spbill_create_ip' => request()->ip(),
|
||||
'auth_code' => (string)$order['auth_code'],
|
||||
];
|
||||
$content = json_encode($content);
|
||||
$this->isService=false;
|
||||
$res= $this->request('/pay/micropay', 'POST', ['sign_body' => $content]);
|
||||
$content['out_trade_no']= $order['order_sn'];
|
||||
ksort($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;
|
||||
}
|
||||
|
||||
|
||||
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