本文整理汇总了PHP中Wechat::createOrder方法的典型用法代码示例。如果您正苦于以下问题:PHP Wechat::createOrder方法的具体用法?PHP Wechat::createOrder怎么用?PHP Wechat::createOrder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Wechat
的用法示例。
在下文中一共展示了Wechat::createOrder方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pay
public function pay()
{
$wechat_config['app_id'] = "wx82a1bf2cd1bfbba2";
// 公众号身份标识
$wechat_config['app_secret'] = "b7b01c0c5e92811d36a716403d3b2515";
// 权限获取所需密钥 Key
$wechat_config['pay_sign_key'] = "VxyJYhODSlANB0ezCH4uHsGcSRQ43awQQdeKn20mDv3RajAuHR63rsnsaHXisX8c1PDuqDGtGYmDFpnOmb1VMlMcd19eOqFPfYkmDcxkv4cFd5mUQAdoVMKWJIS9Zmil";
// 加密密钥 Key,也即appKey
$wechat_config['partner_id'] = '1220793801';
// 财付通商户身份标识
$wechat_config['partner_key'] = '7b7631c5c6db7ccd1f2817d49052501f';
// 财付通商户权限密钥 Key
$wechat_config['notify_url'] = 'http://17huaitao.com/wechat_notify.php';
// 微信支付完成服务器通知页面地址
$wechat_config['cacert_url'] = dirname(__FILE__) . '/1220793801_20140901150545.pfx';
// $total_fee = 0.01; //金额
// $params['total_fee'] = $total_fee*100;
// $params['body']=to_date(get_gmtime(),"Ymdhis").rand(10,99);
// $params['out_trade_no'] = $params['body'];
$total_fee = $_POST['total_fee'];
//金额
$params['total_fee'] = $total_fee * 100;
//echo "totol_fee=".$params['total_fee']."\n";
$params['body'] = $_POST['body'];
//echo "body=".$params['body']."\n";
$params['out_trade_no'] = $_POST['order_sn'];
//echo "out_trade_no=".$params['out_trade_no']."\n";
$params['spbill_create_ip'] = get_client_ip();
// $checker = check_deal_order_is_can_buy($params['out_trade_no'],'order_sn');
// if($checker['status']==0)
// {
// $res = array(
// 'ret'=>'-1',
// 'msg'=>"商品:".$check['info']."不在可购买时间内",
// );
// ajax_return($res);
// }
//
// $checker = check_deal_number($deal_info_arr[$index]['id'],$deal_info_arr[$index]['number'],"app");
// if($checker['status']==0)
// {
// $res = array(
// 'ret'=>'-1',
// 'msg'=>"商品:".$check['info']."库存不足",
// );
// ajax_return($res);
// }
//
//echo "spbill_create_ip=".$params['spbill_create_ip']."\n";
//file_put_contents("/tmp/xiao.log", "\n".date("Y-m-d H:i:s")." params:".json_encode($params)."\n",FILE_APPEND);
$wechat = new Wechat($wechat_config);
$access_token = $wechat->getAccessToken();
//file_put_contents("/tmp/xiao.log", "\n".date("Y-m-d H:i:s")." access_token:".json_encode($access_token)."\n",FILE_APPEND);
//var_dump($access_token);
$tran_result = $wechat->createOrder($access_token, $params);
//file_put_contents("/tmp/xiao.log", "\n".date("Y-m-d H:i:s")." tran_result:".json_encode($tran_result)."\n",FILE_APPEND);
//var_dump($tran_result);
if ($tran_result["errmsg"] == 'Success') {
$info['noncestr'] = $wechat->wechat_noncestr;
$info['package'] = 'Sign=WXPay';
$info['partnerid'] = $wechat_config['partner_id'];
$info['prepayid'] = $tran_result['prepayid'];
$info['timestamp'] = $wechat->wechat_time;
$info['appid'] = $wechat_config['app_id'];
$info['sign'] = $wechat->buildSign($info);
unset($info['appid']);
unset($info['package']);
$info['packageValue'] = 'Sign=WXPay';
$info['ret'] = '0';
$info = json_encode($info);
$info = str_replace('null', '""', $info);
header('Content-Type:application/json;charset=utf-8');
header("Access-Control-Allow-Origin:*");
exit($info);
} else {
$info['ret'] = '-1';
$info = json_encode($info);
header('Content-Type:application/json;charset=utf-8');
header("Access-Control-Allow-Origin:*");
exit($info);
}
}
示例2: date
/**
* 微信支付
* @author funbox www.funboxpower.com
* @copyright 2014
*/
require 'Wechatconfig.php';
require 'WechatAPISDK.php';
$total_fee = 1.0;
//金额
$params['total_fee'] = $total_fee * 100;
$params['body'] = 'www.funboxpower.com专用充值';
$params['out_trade_no'] = 'WX' . date('YmdHis') . $uid . rand(100, 999);
$params['spbill_create_ip'] = get_client_ip();
$wechat = new Wechat($wechat_config);
$access_token = $wechat->getAccessToken();
$tran_result = $wechat->createOrder($access_token, $params);
if ($tran_result["errmsg"] == 'Success') {
$info['noncestr'] = $wechat->wechat_noncestr;
$info['package'] = 'Sign=WXPay';
$info['partnerid'] = $wechat_config['partner_id'];
$info['prepayid'] = $tran_result['prepayid'];
$info['timestamp'] = $wechat->wechat_time;
$info['appid'] = $wechat_config['app_id'];
$info['sign'] = $wechat->buildSign($info);
unset($info['appid']);
unset($info['package']);
$info['packageValue'] = 'Sign=WXPay';
$info = json_encode($info);
$info = str_replace('null', '""', $info);
header('Content-Type:application/json;charset=utf-8');
header("Access-Control-Allow-Origin:*");