当前位置: 首页>>代码示例>>PHP>>正文


PHP RequestHandler::genPackage方法代码示例

本文整理汇总了PHP中RequestHandler::genPackage方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestHandler::genPackage方法的具体用法?PHP RequestHandler::genPackage怎么用?PHP RequestHandler::genPackage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RequestHandler的用法示例。


在下文中一共展示了RequestHandler::genPackage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: time

 $packageParams['fee_type'] = '1';
 //银行币种
 $packageParams['input_charset'] = 'UTF-8';
 //字符集
 $packageParams['notify_url'] = $notify_url;
 //通知地址
 $packageParams['out_trade_no'] = $out_trade_no;
 //商户订单号
 $packageParams['partner'] = $PARTNER;
 //设置商户号
 $packageParams['total_fee'] = $total_fee;
 //商品总金额,以分为单位
 $packageParams['spbill_create_ip'] = $_SERVER['REMOTE_ADDR'];
 //支付机器IP
 //获取package包
 $package = $reqHandler->genPackage($packageParams);
 $time_stamp = time();
 $nonce_str = md5(rand());
 //设置支付参数
 $signParams = array();
 $signParams['appid'] = $APP_ID;
 $signParams['appkey'] = $APP_KEY;
 $signParams['noncestr'] = $nonce_str;
 $signParams['package'] = $package;
 $signParams['timestamp'] = $time_stamp;
 $signParams['traceid'] = 'mytraceid_001';
 //生成支付签名
 $sign = $reqHandler->createSHA1Sign($signParams);
 //增加非参与签名的额外参数
 $signParams['sign_method'] = 'sha1';
 $signParams['app_signature'] = $sign;
开发者ID:cyokvip,项目名称:ci-weixin,代码行数:31,代码来源:index.php

示例2: wechatAction

 /**
  * 微信支付
  */
 public function wechatAction()
 {
     $babyId = $this->devices->getBabyIdByShoeId($this->userInfo['uid'], $this->_sanReq['shoe_id']);
     if (!$babyId) {
         $this->_showMsg(self::NON_SHOE, $this->di['flagmsg'][self::NON_SHOE]);
     }
     //角色名
     if (!empty($rel) && $rel['family_rolename'] != '') {
         $rolename = $rel['family_rolename'];
     } else {
         $rolename = '';
     }
     //获取套餐
     $renew = $this->renew->getRenew($serviceId, 1);
     if (!$renew) {
         $this->_showMsg(self::NON_PACKAGE, $this->di['flagmsg'][self::NON_PACKAGE]);
     }
     //订单号
     $orderNo = (string) Common::makeOrderSn();
     //生成续费订单,入库
     if (($res = $this->renew->renewUpdate($shoeId, $this->userInfo['uid'], $serviceId, $_SERVER['REQUEST_TIME'], 1, $orderNo, 3, $renew['cr_real_price'], $renew['cr_name'], $renew['cr_period'], $renew['cr_coins'], $rolename, $babyId['baby_id'], $babyId['dev_imei'])) != self::SUCCESS) {
         $this->_showMsg($res, $this->di['flagmsg'][$res]);
     }
     include_once __DIR__ . '/../../utils/wechat/classes/RequestHandler.class.php';
     include_once __DIR__ . '/../../utils/wechat/tenpay_config.php';
     include __DIR__ . '/../../utils/wechat/classes/client/TenpayHttpClient.class.php';
     //获取token值
     $reqHandler = new RequestHandler();
     //配置
     $wechatConf = $this->di->get('sysconfig')['payment']['wechat'];
     $reqHandler->init($wechatConf['app_id'], $wechatConf['app_secret'], $wechatConf['partner_key'], $wechatConf['app_key']);
     $Token = $reqHandler->GetToken();
     if ($Token != '') {
         //设置package支付参数
         $packageParams = array();
         $packageParams['bank_type'] = 'WX';
         //支付类型
         $packageParams['body'] = $renew['cr_name'];
         //商品描述
         $packageParams['fee_type'] = '1';
         //银行币种
         $packageParams['input_charset'] = 'UTF-8';
         //字符集  renewServer
         $packageParams['notify_url'] = $this->di->get['sysconfig']['renewServer'] . $wechatConf['notify_url'];
         //通知地址
         $packageParams['out_trade_no'] = $orderNo;
         //商户订单号
         $packageParams['partner'] = $wechatConf['partner'];
         //设置商户号
         $packageParams['spbill_create_ip'] = $_SERVER['REMOTE_ADDR'];
         //支付机器IP
         $packageParams['total_fee'] = $renew['cr_real_price'] * 100;
         //商品总金额,以分为单位
         $package = $reqHandler->genPackage($packageParams);
         $time_stamp = (string) time();
         $nonce_str = md5(rand());
         //设置支付参数
         $signParams = array();
         $signParams['appid'] = $APP_ID;
         $signParams['appkey'] = $APP_KEY;
         $signParams['noncestr'] = $nonce_str;
         $signParams['package'] = $package;
         $signParams['timestamp'] = $time_stamp;
         $signParams['traceid'] = 'yunduo_wechat';
         //生成支付签名
         $sign = $reqHandler->createSHA1Sign($signParams);
         //增加非参与签名的额外参数
         $signParams['sign_method'] = 'sha1';
         $signParams['app_signature'] = $sign;
         //剔除appkey
         unset($signParams['appkey']);
         //获取prepayid
         $prepayid = $reqHandler->sendPrepay($signParams);
         if ($prepayid != null) {
             $pack = 'Sign=WXPay';
             //输出参数列表
             $prePayParams = array();
             $prePayParams['appid'] = $APP_ID;
             $prePayParams['appkey'] = $APP_KEY;
             $prePayParams['noncestr'] = $nonce_str;
             $prePayParams['package'] = $pack;
             $prePayParams['partnerid'] = $PARTNER;
             $prePayParams['prepayid'] = $prepayid;
             $prePayParams['timestamp'] = $time_stamp;
             //生成签名
             $sign = $reqHandler->createSHA1Sign($prePayParams);
             $outparams['retcode'] = '0';
             $outparams['retmsg'] = 'ok';
             $outparams['partnerid'] = $PARTNER;
             $outparams['noncestr'] = $nonce_str;
             $outparams['package'] = $pack;
             $outparams['prepayid'] = $prepayid;
             $outparams['timestamp'] = $time_stamp;
             $outparams['sign'] = $sign;
             //增加返回相关产品信息
             $outparams['order_no'] = $orderNo;
             $outparams['order_subject'] = $renew['cr_name'];
//.........这里部分代码省略.........
开发者ID:nicklos17,项目名称:appserver,代码行数:101,代码来源:RenewController.php


注:本文中的RequestHandler::genPackage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。