/** * 作用:设置jsapi的参数 */ public function getParameters($prepay_id) { $commonUtil = new Common_util_pub($this); $jsApiObj["appId"] = $this->appId; $timeStamp = time(); $jsApiObj["timeStamp"] = "{$timeStamp}"; $jsApiObj["nonceStr"] = $commonUtil->createNoncestr(); $jsApiObj["package"] = "prepay_id={$prepay_id}"; $jsApiObj["signType"] = "MD5"; $jsApiObj["paySign"] = $commonUtil->getSign($jsApiObj); return json_encode($jsApiObj); }
public function packData($payment) { $return = array(); $price = ceil($payment['M_Amount'] * 100); if (class_exists('BCGcode128')) { $return["BCGcode128"] = "no BCGcode128"; } $common_util_pub = new Common_util_pub(); $return["body"] = $payment['R_Name']; $return["notify_url"] = $this->asyncCallbackUrl; $return["out_trade_no"] = $payment['M_OrderNO']; $return["total_fee"] = $price; $return["trade_type"] = 'NATIVE'; $return["appid"] = WxPayConf_pub::APPID; //公众账号ID $return["mch_id"] = $payment['M_PartnerId']; $return["spbill_create_ip"] = $_SERVER['REMOTE_ADDR']; //终端ip $return["nonce_str"] = $common_util_pub->createNoncestr(); //随机字符串 $return["sign"] = $common_util_pub->getSign($return, $payment['M_PartnerKey']); //签名 return $return; }
function __construct() { parent::__construct(); //设置curl超时时间 $this->curl_timeout = $this->curltimeout; }
function __construct($appid, $mchid, $key, $appsecret) { Common_util_pub::__construct($appid, $mchid, $key, $appsecret); //设置curl超时时间 $this->curl_timeout = 60; }
<?php include_once "WxPayPubHelper.php"; $commonUtil = new Common_util_pub(); $wxPayHelper = new Notify_pub(); $wxPayHelper->setReturnParameter("bank_type", "WX"); $wxPayHelper->setReturnParameter("body", "test"); $wxPayHelper->setReturnParameter("partner", "1900000109"); $wxPayHelper->setReturnParameter("out_trade_no", $commonUtil->create_noncestr()); $wxPayHelper->setReturnParameter("total_fee", "1"); $wxPayHelper->setReturnParameter("fee_type", "1"); $wxPayHelper->setReturnParameter("notify_url", "http://1.yzrc.sinaapp.com/wxpay/test/notify_url.php"); $wxPayHelper->setReturnParameter("spbill_create_ip", "127.0.0.1"); $wxPayHelper->setReturnParameter("input_charset", "GBK"); ?> <html> <script language="javascript"> function callpay() { WeixinJSBridge.invoke('getBrandWCPayRequest',<?php echo $wxPayHelper->create_biz_package(); ?> ,function(res){ WeixinJSBridge.log(res.err_msg); alert(res.err_code+res.err_desc+res.err_msg); }); } </script> <body> <button type="button" onclick="callpay()">wx pay test</button> </body>
function __construct($appid, $mchid, $key, $appsecret) { Common_util_pub::__construct($appid, $mchid, $key, $appsecret); //设置curl超时时间 //$this->curl_timeout = 60; $this->url = "https://api.mch.weixin.qq.com/mmpaymkttransfers/send_coupon"; }
/** * 企业付款测试 */ private function _transfer($openid, $money, $title) { vendor('WxPayPubHelper.WxPayPubHelper'); $mchPay = new \WxMchPay(); // 用户openid $mchPay->setParameter('openid', $openid); // 商户订单号 $mchPay->setParameter('partner_trade_no', 'YB-' . time() . mt_rand(1000, 9999)); // 校验用户姓名选项 $mchPay->setParameter('check_name', 'NO_CHECK'); // 企业付款金额 单位为分 $mchPay->setParameter('amount', $money * 100); // 企业付款描述信息 $mchPay->setParameter('desc', $title); // 调用接口的机器IP地址 自定义 $mchPay->setParameter('spbill_create_ip', '127.0.0.1'); # getClientIp() // 收款用户姓名 // $mchPay->setParameter('re_user_name', 'Max wen'); // 设备信息 // $mchPay->setParameter('device_info', 'dev_server'); $response = $mchPay->postXmlSSL(); if (!empty($response)) { $data = \Common_util_pub::xmlToArray($response); if ($data['return_code'] == 'SUCCESS') { return true; } else { $this->error = $data['return_msg']; return false; } } else { $this->error = 'transfers_接口出错'; return false; } }
public function __construct($appid, $mchid, $key) { Common_util_pub::__construct($appid, $mchid, $key); $this->curl_timeout = 60; }
public function __construct($config) { parent::__construct($config); //设置curl超时时间 $this->curl_timeout = self::CURL_TIMEOUT; }