本文整理匯總了PHP中WxPayApi::getNonceStr方法的典型用法代碼示例。如果您正苦於以下問題:PHP WxPayApi::getNonceStr方法的具體用法?PHP WxPayApi::getNonceStr怎麽用?PHP WxPayApi::getNonceStr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WxPayApi
的用法示例。
在下文中一共展示了WxPayApi::getNonceStr方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getAppPaymentParameters
public function getAppPaymentParameters($order)
{
/*
$order =null;
$order = $this->queryOrder($out_trade_no);
// print json_encode($order) .PHP_EOL;
if ($order) {
$input = new \WxPayReverse();
$input->SetOut_trade_no($out_trade_no);
$result = \WxPayApi::reverse($input);
print('reserve:'.json_encode($result)) .PHP_EOL;
// $input = new \WxPayCloseOrder();
// $input->SetOut_trade_no($out_trade_no);
// $result = \WxPayApi::closeOrder($input);
// print('close:'.json_encode($result)) .PHP_EOL;
}
*/
$wxPayConfig = $this->wxPayApi->getWxPayConfig();
// print( json_encode($order ) ) .PHP_EOL;
$prepay_id = $order['prepay_id'];
$response = array('appid' => $wxPayConfig['APPID'], 'partnerid' => $wxPayConfig['MCHID'], 'prepayid' => $prepay_id, 'package' => 'Sign=WXPay', 'noncestr' => \WxPayApi::getNonceStr(), 'timestamp' => time());
$response['sign'] = $this->calculateSign($response, $wxPayConfig['KEY']);
// send it to APP
return $response;
}
示例2: GetJsApiParameters
/**
*
* 獲取jsapi支付的參數
* @param array $UnifiedOrderResult 統一支付接口返回的數據
* @throws WxPayException
*
* @return json數據,可直接填入js函數作為參數
*/
public function GetJsApiParameters($UnifiedOrderResult)
{
if (!array_key_exists("appid", $UnifiedOrderResult) || !array_key_exists("prepay_id", $UnifiedOrderResult) || $UnifiedOrderResult['prepay_id'] == "") {
throw new WxPayException("參數錯誤");
}
$jsapi = new WxPayJsApiPay();
$jsapi->SetAppid($UnifiedOrderResult["appid"]);
$timeStamp = time();
$jsapi->SetTimeStamp("{$timeStamp}");
$jsapi->SetNonceStr(WxPayApi::getNonceStr());
$jsapi->SetPackage("prepay_id=" . $UnifiedOrderResult['prepay_id']);
$jsapi->SetSignType("MD5");
$jsapi->SetPaySign($jsapi->MakeSign());
$parameters = json_encode($jsapi->GetValues());
return $parameters;
}
示例3: GetJsApiParameters
/**
*
* 獲取jsapi支付的參數
* @param array $UnifiedOrderResult 統一支付接口返回的數據
* @throws WxPayException
*
* @return json數據,可直接填入js函數作為參數
*/
public function GetJsApiParameters($UnifiedOrderResult)
{
if (!array_key_exists("appid", $UnifiedOrderResult) || !array_key_exists("prepay_id", $UnifiedOrderResult) || $UnifiedOrderResult['prepay_id'] == "") {
// throw new WxPayException("參數錯誤");
Yii::log('WxJsPayHelper 71line', CLogger::LEVEL_ERROR, 'WxJsPayHelper');
Yii::app()->request->redirect(Assist::getDefaultURL());
}
$jsapi = new WxPayJsApiPay();
$jsapi->SetAppid($UnifiedOrderResult["appid"]);
$timeStamp = time();
$jsapi->SetTimeStamp($timeStamp);
$jsapi->SetNonceStr(WxPayApi::getNonceStr());
$jsapi->SetPackage("prepay_id=" . $UnifiedOrderResult['prepay_id']);
$jsapi->SetSignType("MD5");
$jsapi->SetPaySign($jsapi->MakeSign());
$parameters = json_encode($jsapi->GetValues());
return $parameters;
}
示例4: NotifyProcess
public function NotifyProcess($data)
{
if (!array_key_exists("openid", $data) || !array_key_exists("product_id", $data)) {
$this->msg = "回調數據異常";
return false;
}
$openid = $data["openid"];
$product_id = $data["product_id"];
//統一下單
$result = $this->unifiedorder($openid, $product_id, $data);
if (!array_key_exists("appid", $result) || !array_key_exists("mch_id", $result) || !array_key_exists("prepay_id", $result)) {
$this->msg = "統一下單失敗";
return false;
}
$this->SetData("appid", $result["appid"]);
$this->SetData("mch_id", $result["mch_id"]);
$this->SetData("nonce_str", WxPayApi::getNonceStr());
$this->SetData("prepay_id", $result["prepay_id"]);
$this->SetData("result_code", "SUCCESS");
$this->SetData("err_code_des", "OK");
return true;
}
示例5: pay_get
public function pay_get()
{
$order = I('get.order', '');
$m = M('orders');
// $map['from_member_id'] = $this->uid;
$map['order_number'] = $order;
// $map['status'] = 0;
$info = $m->where($map)->find();
if (empty($info)) {
//未支付訂單不存在
$this->error(5015);
}
$total = $info['total'] * 100;
$describe = 'testname';
require_once APP_PATH . "SDK/Payment/wechat/lib/WxPay.Api.php";
$input = new \WxPayUnifiedOrder();
//設置公眾賬號ID
$input->SetAppid(\WxPayConfig::APPID);
//設置商戶號
$input->SetMch_id(\WxPayConfig::MCHID);
//設置隨機字符串
$input->SetNonce_str(\WxPayApi::getNonceStr());
//設置商品描述
$input->SetBody($describe);
//設置商戶訂單號
$input->SetOut_trade_no($info['order_number']);
//設置總金額
$input->SetTotal_fee($total);
//設置終端IP
$input->SetSpbill_create_ip(get_client_ip());
//設置通知地址
$input->SetNotify_url(U('Wxpay/callback@api'));
//設置交易類型
$input->SetTrade_type('APP');
$order = \WxPayApi::unifiedOrder($input);
$this->success($order);
}
示例6: wxpay_app
public function wxpay_app()
{
$period_id = Input::get('period_id');
$period = Period::find($period_id);
// 判斷時間段有效性
if (!isset($period)) {
return Response::json(array('error_code' => 2, 'message' => '無該時間段,請重新選擇'));
}
if ($period->current >= $period->total) {
return Response::json(array('error_code' => 3, 'message' => '已滿人,請重新選擇'));
}
$schedule = $period->schedule;
$doctor = $schedule->doctor;
$user_id = Session::get('user.id');
// 選擇指定掛號賬戶
if (Input::has('account_id')) {
$account_id = Input::get('account_id');
$account = RegisterAccount::find($account_id);
if (!isset($account)) {
return Response::json(array('error_code' => 4, 'message' => '不存在該掛號賬戶'));
}
if ($account->user_id != $user_id) {
return Response::json(array('error_code' => 5, 'message' => '無效賬戶'));
}
} else {
$account = RegisterAccount::where('user_id', $user_id)->first();
if (!isset($account)) {
return Response::json(array('error_code' => 6, 'message' => '請先申請掛號賬戶'));
}
$account_id = $account->id;
}
$user_id = Session::get('user.id');
$attach = array('period_id' => (int) Input::get('period_id'), 'account_id' => $account_id);
try {
$period = Period::find(Input::get('period_id'));
$schedule = $period->schedule;
$doctor = $schedule->doctor;
$order = $this->create_order($user_id, 'APP', json_encode($attach), (int) ($doctor->register_fee * 100));
$para = array('appid' => $order['appid'], 'partnerid' => WxPayConfig::MCHID, 'prepayid' => $order['prepay_id'], 'package' => 'Sign=WXPay', 'noncestr' => WxPayApi::getNonceStr(), 'timestamp' => time());
$wxpay_result = new WxPayResults();
$wxpay_result->FromArray($para);
$wxpay_result->SetSign();
$package = $wxpay_result->GetValues();
} catch (Exception $e) {
return Response::json(array('error_code' => 1, 'message' => $e->getMessage()));
}
return Response::json(array('error_code' => 0, 'package' => $package));
}
示例7: joinwxinfo
function joinwxinfo($body_arr)
{
$resp = array();
$order_no = $body_arr['order_no'];
$randnum = rand(1000, 9999);
//產生一個4位隨機數
$out_trade_no = $order_no;
//. '-' . $randnum; //記錄訂單號+_+隨機數
// $arr['device_info'] = isset($body_arr['client_ip'])?$body_arr['client_ip']:''; //客戶端地址
$input = new WxPayUnifiedOrder();
$input->SetBody($out_trade_no);
$input->SetOut_trade_no($out_trade_no);
$input->SetTotal_fee(getfee($body_arr));
//這裏是微信,默認單位:分
$time = time();
$input->SetTime_start(date("YmdHis"), $time);
$input->SetTime_expire(date("YmdHis", $time + 600));
$input->SetNotify_url(_WXNOTIFYURL_ . 'pay/mobilepay/wxpay/interface/appnotify.php');
$input->SetTrade_type("APP");
// $WxPayUnifiedOrder->SetAttach("test");
// $input->SetGoods_tag("test");
// $input->SetProduct_id("123456789");
$retarr = WxPayApi::unifiedOrder($input);
//返回數據解析為數組了
if ($retarr['return_code'] == 'SUCCESS') {
//成功
$nostr = WxPayApi::getNonceStr();
$resp['wx_app_id'] = $retarr['appid'];
$resp['wx_partner_id'] = $retarr['mch_id'];
$resp['wx_nonce'] = $nostr;
//$retarr['nonce_str'];
$resp['wx_timestamp'] = $time;
//date("YmdHis");
$retinput = new WxPayReplyData();
if ($retarr['result_code'] == 'SUCCESS') {
$resp['wx_prepay_id'] = $retarr['prepay_id'];
$retinput->SetappId(WxPayConfig::APPID);
//公眾賬號ID
$retinput->SetnonceStr($nostr);
//隨機字符串
$retinput->Setpackage('Sign=WXPay');
$retinput->SetpartnerId($retarr['mch_id']);
$retinput->SetprepayId($retarr['prepay_id']);
$retinput->SettimeStamp($time);
//
$resp['wx_sign'] = $retinput->MakeSignSpecil();
}
$resp['wx_package'] = 'Sign=WXPay';
//固定值
} else {
$resp = $retarr;
$resp['status'] = 1046;
$resp['desc'] = '失敗';
}
return $resp;
}
示例8: getPayConfig
/**
*
* 按類型獲取支付憑證
* @param data
*/
public static function getPayConfig($data)
{
$input = self::getUnifiedOrder($data);
$config = WxPayApi::unifiedOrder($input);
if ($config['return_code'] == 'FAIL') {
throw new WxPayException($config['return_msg'], 1);
}
if ($data['trade_type'] = 'JSAPI') {
$jsapi = new WxPayJsApiPay();
$jsapi->SetAppid($config["appid"]);
$jsapi->SetTimeStamp(strtotime($data['time_start']));
$jsapi->SetNonceStr(WxPayApi::getNonceStr());
$jsapi->SetPackage("prepay_id=" . $config['prepay_id']);
$jsapi->SetSignType("MD5");
$jsapi->SetPaySign($jsapi->MakeSign());
$parameters = json_encode($jsapi->GetValues());
return $parameters;
} else {
if ($data['trade_type'] = 'APP') {
// TODO HBuilder
// // 參與簽名的字段名為appId,partnerId,prepayId,nonceStr,timeStamp,package。注意:package的值格式為Sign=WXPay
// $time_stamp = time();
// $pack = 'Sign=WXPay';
// //輸出參數列表
// $prePayParams =array();
// $prePayParams['appid'] =$config['appid'];
// $prePayParams['partnerid'] =$config['mch_id'];
// $prePayParams['prepayid'] =$config['prepay_id'];
// $prePayParams['noncestr'] =$config['nonce_str'];
// $prePayParams['package'] =$pack;
// $prePayParams['timestamp'] =$time_stamp;
// $prePayParams['sign'] =$config['sign'];
// return $prePayParams;
}
}
return $config;
}