コード例 #1
0
 /**
  * @return array|Data\Provider[]
  */
 protected function getProviders()
 {
     $providersXml = $this->loadFixture('GetProviders.xml');
     $providersResponse = new GetProvidersResponse();
     QPayXMLParser::parseResponse($providersXml, $providersResponse);
     return $providersResponse->getProviders();
 }
コード例 #2
0
 /**
  * @param ResponseInterface|null $response
  *
  * @throws ApiErrorHappenException
  */
 public function __construct(ResponseInterface $response = null)
 {
     if ($response) {
         $this->setXml($response->getBody()->getContents());
         $this->response = QPayXMLParser::parseResponse($this->getXml(), $this);
         //response with failure code always thrown a exception
         if ($this->getErrorCode() > 0) {
             throw new ApiErrorHappenException($this->getErrorMessage());
         }
     }
 }
コード例 #3
0
 /**
  * @inheritdoc
  */
 public function buildRequest(ApiRequestBuilder $requestBuilder, ApiInterface $api)
 {
     /** @var QPayApi $api */
     $data = Object2ArrayBuilder::create()->build()->createArray($this);
     if (array_key_exists('urn:Header', $data)) {
         $data['urn:Header'] = ['urn1:CertPublicKey' => $api->getCredentials()->getCertificateSerialNumber(), 'urn1:UIID' => $api->getCredentials()->getUuid(), 'urn1:User' => 'system'];
     }
     if (array_key_exists('urn:RequestToken', $data)) {
         $data['urn:RequestToken'] = Object2ArrayBuilder::create()->build()->createArray($api->getRequestToken());
     }
     //build the request url
     $uri = sprintf('https://pos.qpay123.biz/%s/Gateway.svc', $api->getCredentials()->getMerchantName());
     $xml = QPayXMLParser::createRequest($this->getActionName(), $data);
     $requestBuilder->withUri($uri)->withMethod('POST')->withXMLBody($xml)->options()->setCurlOption(CURLOPT_CAINFO, $api->getCredentials()->getAuthorityCertificateFile())->setCurlOption(CURLOPT_SSLCERT, $api->getCredentials()->getClientCertificateFile())->setCurlOption(CURLOPT_SSLKEY, $api->getCredentials()->getCertificateKeyFile())->setCurlOption(CURLOPT_SSLCERTPASSWD, $api->getCredentials()->getCertificatePassword())->SSLVerification(false);
 }