Пример #1
0
 public function before()
 {
     if (func_num_args() != 1) {
         throw new InvalidParamsException();
     }
     $this->gateway->setKey(Configuration::get('wechat.pay_key'));
 }
Пример #2
0
 public function doing()
 {
     $args = func_get_arg(0);
     $this->gateway->setPartner(Configuration::get('alipay.id'));
     $this->gateway->setKey(Configuration::get('alipay.key'));
     $this->gateway->setSellerEmail(Configuration::get('alipay.email'));
     $this->gateway->setSellerId(Configuration::get('alipay.id'));
     $this->gateway->setSignType('MD5');
     $response = $this->gateway->purchase(['payment_type' => '1', 'out_trade_no' => $args['out_trade_no'], 'total_fee' => $args['total_fee'], 'subject' => $args['subject'], 'body' => $args['body'], 'notify_url' => $args['notify_url'], 'return_url' => $args['return_url']])->send();
     $this->result = $response;
 }
Пример #3
0
 public function before()
 {
     $args = func_get_args();
     if (count($args) != 1 || !is_array($args[0])) {
         throw new InvalidParamsException();
     }
     foreach ($this->keys as $key) {
         if (!array_key_exists($key, $args[0])) {
             throw new InvalidParamsException();
         }
     }
     $this->gateway->setMchId(Configuration::get('wechat.mchid'));
     $this->gateway->setKey(Configuration::get('wechat.pay_key'));
     $this->gateway->setAppId(Configuration::get('wechat.app.appid'));
 }
Пример #4
0
 /**
  * [doing description]
  * @throws WechatPayException
  * @return [type] [description]
  */
 public function doing()
 {
     $args = func_get_arg(0);
     $this->gateway->setParameter('wxappid', Configuration::get('wechat.appid'));
     $this->gateway->setMchId(Configuration::get('wechat.mchid'));
     $this->gateway->setKey(Configuration::get('wechat.pay_key'));
     $billno = array_key_exists('mch_billno', $args) ? $args['mch_billno'] : null;
     $response = $this->gateway->redPack(['mch_billno' => $billno, 'send_name' => $args['send_name'], 're_openid' => $args['re_openid'], 'total_amount' => round($args['total_amount']), 'total_num' => $args['total_num'], 'wishing' => $args['wishing'], 'client_ip' => $args['client_ip'], 'act_name' => $args['act_name'], 'remark' => $args['remark'], 'ssl_cert_path' => Configuration::get('wechat.ssl_cert_path'), 'ssl_key_path' => Configuration::get('wechat.ssl_key_path')])->send();
     if (!$response->isResponseSuccessful()) {
         throw new WechatPayException($response->getReturnMsg());
     }
     if (!$response->isResultSuccessful()) {
         throw new WechatPayException($response->getErrCodeDes());
     }
     $this->result = $response;
 }
Пример #5
0
 /**
  * [doing description]
  * @throws AlipayNoticeException
  *         AlipayRequestFailException
  * @return [type] [description]
  */
 public function doing()
 {
     $body = func_get_arg(0);
     try {
         $this->gateway->setPartner(Configuration::get('alipay.id'));
         $this->gateway->setKey(Configuration::get('alipay.key'));
         $this->gateway->setSellerEmail(Configuration::get('alipay.email'));
         $this->gateway->setAlipayPublicKey(Configuration::get('alipay.ali_public_key'));
         $response = $this->gateway->completePurchase(['request_params' => $body])->send();
         if (!$response->isSuccessful()) {
             throw new AlipayException('签名校验失败');
         }
         if (!$response->isPaid()) {
             throw new AlipayException('支付失败');
         }
         $this->result = $response;
     } catch (Exception $e) {
         throw new AlipayException($e->getMessage());
     }
 }