/**
  * Send the request with specified data
  *
  * @param  mixed $data The data to send
  *
  * @return ResponseInterface
  */
 public function sendData($data)
 {
     $request = $this->httpClient->post($this->endpoint)->setBody(Helper::array2xml($data));
     $response = $request->send()->getBody();
     $responseData = Helper::xml2array($response);
     return $this->response = new CreateOrderResponse($this, $responseData);
 }
 /**
  * Get the raw data array for this message. The format of this varies from gateway to
  * gateway, but will usually be either an associative array, or a SimpleXMLElement.
  *
  * @return mixed
  */
 public function getData()
 {
     $data = $this->getRequestParams();
     if (is_string($data)) {
         $data = Helper::xml2array($data);
     }
     return $data;
 }
 public function getOrderData()
 {
     if ($this->isSuccessful()) {
         $data = array('app_id' => $this->request->getAppId(), 'mch_id' => $this->request->getMchId(), 'prepay_id' => $this->getPrepayId(), 'package' => 'Sign=WXPay', 'nonce' => md5(uniqid()), 'timestamp' => time());
         $data['sign'] = Helper::sign($data, $this->request->getApiKey());
     } else {
         $data = null;
     }
     return $data;
 }
 public function getJSOrderData()
 {
     if ($this->isSuccessful()) {
         $data = array('appId' => $this->request->getAppId(), 'package' => 'prepay_id=' . $this->getPrepayId(), 'nonceStr' => md5(uniqid()), 'timeStamp' => time());
         $data['signType'] = 'MD5';
         $data['paySign'] = Helper::sign($data, $this->request->getApiKey());
     } else {
         $data = null;
     }
     return $data;
 }
 /**
  * Send the request with specified data
  *
  * @param  mixed $data The data to send
  *
  * @return ResponseInterface
  */
 public function sendData($data)
 {
     $data = $this->getData();
     $sign = Helper::sign($data, $this->getApiKey());
     $responseData = array();
     if (isset($data['sign']) && $data['sign'] && $sign === $data['sign']) {
         $responseData['sign_match'] = true;
     } else {
         $responseData['sign_match'] = false;
     }
     if ($responseData['sign_match'] && isset($data['result_code']) && $data['result_code'] == 'SUCCESS') {
         $responseData['paid'] = true;
     } else {
         $responseData['paid'] = false;
     }
     return $this->response = new CompletePurchaseResponse($this, $responseData);
 }
 /**
  * Send the request with specified data
  *
  * @param  mixed $data The data to send
  *
  * @return ResponseInterface
  */
 public function sendData($data)
 {
     $responseData = Helper::post($this->endpoint, $data);
     return $this->response = new CloseOrderResponse($this, $responseData);
 }
 /**
  * Send the request with specified data
  *
  * @param  mixed $data The data to send
  *
  * @return ResponseInterface
  */
 public function sendData($data)
 {
     $responseData = Helper::post($this->endpoint, $data);
     return $this->response = new ShortenUrlResponse($this, $responseData);
 }
 /**
  * Send the request with specified data
  *
  * @param  mixed $data The data to send
  *
  * @return ResponseInterface
  */
 public function sendData($data)
 {
     $options = array(CURLOPT_SSL_VERIFYPEER => true, CURLOPT_SSL_VERIFYHOST => 2, CURLOPT_SSLCERTTYPE => 'PEM', CURLOPT_SSLKEYTYPE => 'PEM', CURLOPT_SSLCERT => $this->getCertPath(), CURLOPT_SSLKEY => $this->getKeyPath());
     $body = Helper::array2xml($data);
     $request = $this->httpClient->post($this->endpoint, null, $data)->setBody($body);
     $request->getCurlOptions()->overwriteWith($options);
     $response = $request->send()->getBody();
     $responseData = Helper::xml2array($response);
     return $this->response = new CloseOrderResponse($this, $responseData);
 }
 /**
  * Send the request with specified data
  *
  * @param  mixed $data The data to send
  *
  * @return ResponseInterface
  */
 public function sendData($data)
 {
     $responseData = Helper::post($this->endpoint, $data);
     return $this->response = new QueryRefundResponse($this, $responseData);
 }
 /**
  * Send the request with specified data
  *
  * @param  mixed $data The data to send
  *
  * @return ResponseInterface
  */
 public function sendData($data)
 {
     $options = array(CURLOPT_SSL_VERIFYPEER => true, CURLOPT_SSL_VERIFYHOST => 2, CURLOPT_SSLCERTTYPE => 'PEM', CURLOPT_SSLKEYTYPE => 'PEM', CURLOPT_SSLCERT => $this->getCertPath(), CURLOPT_SSLKEY => $this->getKeyPath());
     $responseData = Helper::post($this->endpoint, $data, 3, $options);
     return $this->response = new CloseOrderResponse($this, $responseData);
 }
 private function post($url, $data = array(), $timeout = 3)
 {
     $ch = curl_init($url);
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_POSTFIELDS, Helper::array2xml($data));
     curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     $result = curl_exec($ch);
     if (preg_match('#return_code#', $result)) {
         $result = Helper::xml2array($result);
     } else {
         $result = array(['return_code' => 'SUCCESS', 'raw' => $result]);
     }
     return $result;
 }