예제 #1
0
 /**
  * 构造方法
  */
 public function __construct(Wechat $wechat, array $options)
 {
     if (!$wechat->offsetExists('mchid')) {
         throw new \InvalidArgumentException('The required options "mch_id" are missing.');
     }
     if (!$wechat->offsetExists('mchkey')) {
         throw new \InvalidArgumentException('The required options "mch_key" are missing.');
     }
     $this->wechat = $wechat;
     parent::__construct($options);
 }
예제 #2
0
 /**
  * 构造方法
  */
 public function __construct(Wechat $wechat, array $optionsForUnifiedorder)
 {
     // 将 trade_type 强制设为 JSAPI
     $optionsForUnifiedorder['trade_type'] = self::TRADE_TYPE;
     // 去统一下单接口下单
     $unifiedorder = new Unifiedorder($wechat, $optionsForUnifiedorder);
     // 下单结果中的 prepay_id
     $response = $unifiedorder->getResponse();
     $this->wechat = $wechat;
     parent::__construct(array('package' => sprintf('prepay_id=%s', $response['prepay_id'])));
 }
예제 #3
0
파일: User.php 프로젝트: Oppaa/wechat
 /**
  * 构造方法
  */
 public function __construct(AccessToken $accessToken)
 {
     if (!$accessToken->isValid()) {
         $accessToken->refresh();
     }
     $request = Http::get(self::USERINFO_URL, array('query' => array('access_token' => $accessToken['access_token'], 'openid' => $accessToken['openid'])));
     $response = $request->json();
     if (array_key_exists('errcode', $response) && array_key_exists('errmsg', $response)) {
         throw new \Exception($response['errcode'] . ': ' . $response['errmsg']);
     }
     parent::__construct($response);
 }
예제 #4
0
파일: Request.php 프로젝트: Oppaa/wechat
 /**
  * 构造方法
  */
 public function __construct()
 {
     $this->content = file_get_contents('php://input');
     if (!empty($this->content)) {
         $data = Serialize::decode($this->content, 'xml');
         try {
             parent::__construct($data);
             $this->valid = true;
         } catch (\InvalidArgumentException $e) {
             $this->error = $e->getMessage();
         }
     }
 }
예제 #5
0
 /**
  * 构造方法
  */
 public function __construct(Wechat $wechat, array $options)
 {
     $this->wechat = $wechat;
     parent::__construct($options);
 }
예제 #6
0
파일: Wechat.php 프로젝트: Oppaa/wechat
 /**
  * 构造方法
  */
 public function __construct(array $options)
 {
     parent::__construct($options);
 }