예제 #1
0
 /**
  * Test isInvalid().
  */
 public function testIsValid()
 {
     $params = ['foo' => 'bar', 'hi' => 'here'];
     $params['sign'] = \EasyWeChat\Payment\generate_sign($params, 'sign_key');
     $request = Request::create('/callback', 'POST', [], [], [], [], XML::build($params));
     $notify = new Notify(new Merchant(['key' => 'sign_key']), $request);
     $this->assertTrue($notify->isValid());
     $notify = new Notify(new Merchant(['key' => 'different_sign_key']), $request);
     $this->assertFalse($notify->isValid());
 }
예제 #2
0
파일: API.php 프로젝트: zerozh/wechat
 /**
  * Make a API request.
  *
  * @param string $api
  * @param array  $params
  * @param string $method
  *
  * @return \EasyWeChat\Support\Collection
  */
 protected function request($api, array $params, $method = 'post')
 {
     $params = array_filter($params);
     $params['mch_id'] = $this->merchant->merchant_id;
     $params['nonce_str'] = uniqid();
     $params['sign'] = \EasyWeChat\Payment\generate_sign($params, $this->merchant->key, 'md5');
     $options = ['body' => XML::build($params), 'cert' => $this->merchant->get('cert_path'), 'ssl_key' => $this->merchant->get('key_path')];
     return $this->parseResponse($this->getHttp()->request($api, $method, $options));
 }