Ejemplo n.º 1
0
 /**
  * 提交被扫支付API
  * 收银员使用扫码设备读取微信用户刷卡授权码以后,二维码或条码信息传送至商户收银台,
  * 由商户收银台或者商户后台调用该接口发起支付。
  * WxPayWxPayMicroPay中body、out_trade_no、total_fee、auth_code参数必填
  * appid、mchid、spbill_create_ip、nonce_str不需要填入
  * @param WxPayWxPayMicroPay $inputObj
  * @param int $timeOut
  */
 public function micropay($inputObj, $timeOut = 10)
 {
     //		$url = "https://api.mch.weixin.qq.com/pay/micropay";
     //检测必填参数
     if (!$inputObj->IsBodySet()) {
         throw new WxPayException("提交被扫支付API接口中,缺少必填参数body!");
     } else {
         if (!$inputObj->IsOut_trade_noSet()) {
             throw new WxPayException("提交被扫支付API接口中,缺少必填参数out_trade_no!");
         } else {
             if (!$inputObj->IsTotal_feeSet()) {
                 throw new WxPayException("提交被扫支付API接口中,缺少必填参数total_fee!");
             } else {
                 if (!$inputObj->IsAuth_codeSet()) {
                     throw new WxPayException("提交被扫支付API接口中,缺少必填参数auth_code!");
                 }
             }
         }
     }
     $inputObj->SetSpbill_create_ip($_SERVER['REMOTE_ADDR']);
     //终端ip
     $result = $this->init_obj($inputObj, self::MICRO_PAY, false);
     return $result;
 }
Ejemplo n.º 2
0
 /**
  * 提交被扫支付API
  * 收银员使用扫码设备读取微信用户刷卡授权码以后,二维码或条码信息传送至商户收银台,
  * 由商户收银台或者商户后台调用该接口发起支付。
  * WxPayWxPayMicroPay中body、out_trade_no、total_fee、auth_code参数必填
  * appid、mchid、spbill_create_ip、nonce_str不需要填入
  * @param WxPayWxPayMicroPay $inputObj
  * @param int $timeOut
  */
 public static function micropay($inputObj, $timeOut = 10)
 {
     $url = "https://api.mch.weixin.qq.com/pay/micropay";
     //检测必填参数
     if (!$inputObj->IsBodySet()) {
         throw new WxPayException("提交被扫支付API接口中,缺少必填参数body!");
     } else {
         if (!$inputObj->IsOut_trade_noSet()) {
             throw new WxPayException("提交被扫支付API接口中,缺少必填参数out_trade_no!");
         } else {
             if (!$inputObj->IsTotal_feeSet()) {
                 throw new WxPayException("提交被扫支付API接口中,缺少必填参数total_fee!");
             } else {
                 if (!$inputObj->IsAuth_codeSet()) {
                     throw new WxPayException("提交被扫支付API接口中,缺少必填参数auth_code!");
                 }
             }
         }
     }
     $inputObj->SetSpbill_create_ip($_SERVER['REMOTE_ADDR']);
     //终端ip
     $inputObj->SetAppid(WxPayConfig::APPID);
     //公众账号ID
     $inputObj->SetMch_id(WxPayConfig::MCHID);
     //商户号
     $inputObj->SetNonce_str(self::getNonceStr());
     //随机字符串
     $inputObj->SetSign();
     //签名
     $xml = $inputObj->ToXml();
     $startTimeStamp = self::getMillisecond();
     //请求开始时间
     $response = self::postXmlCurl($xml, $url, false, $timeOut);
     $result = WxPayResults::Init($response);
     self::reportCostTime($url, $startTimeStamp, $result);
     //上报请求花费时间
     return $result;
 }
Ejemplo n.º 3
0
 /**
  * 企业付款给用户的API
  * 企业通过用户openid 主动给用户转账,可以应用在部分奖励、或者用户提现的场景,
  * WxPayTransfer中partner_trade_no、openid、check_name、amount、desc参数必填
  * appid、mchid、spbill_create_ip、nonce_str不需要填入
  * @param WxPayWxPayMicroPay $inputObj
  * @param int $timeOut
  */
 public function transferCash($inputObj, $timeOut = 10)
 {
     $url = "https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers";
     //检测必填参数
     if (!$inputObj->isPartnerTradeNoSet()) {
         throw new WxPayException("提交被扫支付API接口中,缺少必填参数partner_trade_no!");
     } else {
         if (!$inputObj->isOpenidSet()) {
             throw new WxPayException("提交被扫支付API接口中,缺少必填参数openid!");
         } else {
             if (!$inputObj->isCheckNameSet()) {
                 throw new WxPayException("提交被扫支付API接口中,缺少必填参数check_name!");
             } else {
                 if (!$inputObj->isAmountSet()) {
                     throw new WxPayException("提交被扫支付API接口中,缺少必填参数amount!");
                 } else {
                     if (!$inputObj->isDescSet()) {
                         throw new WxPayException("提交被扫支付API接口中,缺少必填参数desc!");
                     } else {
                         if ($inputObj->isCheckNameSet() && $inputObj->getCheckName() != WxPayTransfer::NO_CHECK && !$inputObj->isReUserNameSet()) {
                             throw new WxPayException("提交被扫支付API接口中,缺少必填参数re_user_name!");
                         }
                     }
                 }
             }
         }
     }
     $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1';
     $inputObj->setSpbillCreateIp($ip);
     //终端ip
     $inputObj->setAppid($this->apiConfig->appid);
     //公众账号ID
     $inputObj->setMchId($this->apiConfig->mchid);
     //商户号
     $inputObj->setMchKey($this->apiConfig->mchkey);
     //商户密钥
     $inputObj->setNonceStr($this->getNonceStr());
     //随机字符串
     $inputObj->setSign();
     //签名
     $xml = $inputObj->toXml();
     $response = $this->postXmlCurl($xml, $url, true, $timeOut);
     return $response;
 }