コード例 #1
0
ファイル: UnifiedOrderTest.php プロジェクト: codelint/wechat
 public function testGetPrepareId()
 {
     $unifiedOrder = new UnifiedOrder();
     $unifiedOrder->init($this->config);
     $unifiedOrder->setParameter('out_trade_no', time());
     $unifiedOrder->setParameter('total_fee', 1);
     $unifiedOrder->setParameter('body', 'pay 1 fen');
     $unifiedOrder->setParameter('trade_type', 'JSAPI');
     $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
     $unifiedOrder->setParameter('openid', $this->config['open_id']);
     $unifiedOrder->setParameter('notify_url', 'http://m.qiaocat.com');
     $res = $unifiedOrder->getResult();
     $this->assertEquals('SUCCESS', $res['return_code']);
 }
コード例 #2
0
 * ====================================================
 * 商户生成订单,先调用统一支付接口获取到code_url,
 * 此URL直接生成二维码,用户扫码后调起支付。
 * 
*/
include_once "./WxPayHelper/WxPayHelper.php";
//使用统一支付接口
$unifiedOrder = new UnifiedOrder();
//设置统一支付接口参数
//设置必填参数
//appid已填,商户无需重复填写
//mch_id已填,商户无需重复填写
//noncestr已填,商户无需重复填写
//spbill_create_ip已填,商户无需重复填写
//sign已填,商户无需重复填写
$unifiedOrder->setParameter("body", "贡献一分钱");
//商品描述
//自定义订单号,此处仅作举例
$timeStamp = time();
$out_trade_no = WxPayConf::APPID . "{$timeStamp}";
$unifiedOrder->setParameter("out_trade_no", "{$out_trade_no}");
//商户订单号
$unifiedOrder->setParameter("total_fee", "1");
//总金额
$unifiedOrder->setParameter("notify_url", WxPayConf::NOTIFY_URL);
//通知地址
$unifiedOrder->setParameter("trade_type", "NATIVE");
//交易类型
//非必填参数,商户可根据实际情况选填
//$unifiedOrder->setParameter("sub_mch_id","XXXX");//子商户号
//$unifiedOrder->setParameter("device_info","XXXX");//设备号
コード例 #3
0
    $confirm = explode("_", $_GET['confirm']);
    //error_log("confirm: ".$confirm[1]);
    $jsApi->setCode($code);
    $openid = $jsApi->getOpenId();
}
//=========步骤2:使用统一支付接口,获取prepay_id============
//使用统一支付接口
$unifiedOrder = new UnifiedOrder();
//设置统一支付接口参数
//设置必填参数
//appid已填,商户无需重复填写
//mch_id已填,商户无需重复填写
//noncestr已填,商户无需重复填写
//spbill_create_ip已填,商户无需重复填写
//sign已填,商户无需重复填写
$unifiedOrder->setParameter("openid", $openid);
//openid
$unifiedOrder->setParameter("body", "充值杀价币");
//商品描述
$unifiedOrder->setParameter("out_trade_no", $confirm[0]);
//商户订单号
$unifiedOrder->setParameter("total_fee", $confirm[1] * 100);
//总金额
$unifiedOrder->setParameter("notify_url", WxPayConf::NOTIFY_URL);
//通知地址
$unifiedOrder->setParameter("trade_type", "JSAPI");
//交易类型
//非必填参数,商户可根据实际情况选填
//$unifiedOrder->setParameter("sub_mch_id","XXXX");					//子商户号
//$unifiedOrder->setParameter("device_info","XXXX");				//设备号
//$unifiedOrder->setParameter("attach","XXXX");						//附加数据