Esempio n. 1
0
 /**
  * Create request without checking conditions
  * @param array $data
  * @return boolean
  */
 private static function createRequest($data)
 {
     try {
         $curl = new DotpayCurl();
         $curl->addOption(CURLOPT_URL, self::$config->getDotpayTargetUrl() . self::$target)->addOption(CURLOPT_SSL_VERIFYPEER, TRUE)->addOption(CURLOPT_SSL_VERIFYHOST, 2)->addOption(CURLOPT_RETURNTRANSFER, 1)->addOption(CURLOPT_TIMEOUT, 100)->addOption(CURLOPT_USERPWD, self::$config->getDotpayApiUsername() . ':' . self::$config->getDotpayApiPassword())->addOption(CURLOPT_POST, 1)->addOption(CURLOPT_POSTFIELDS, $data)->addOption(CURLOPT_HTTPHEADER, array('Accept: application/json; indent=4', 'content-type: application/json'));
         $resultJson = $curl->exec();
         $resultStatus = $curl->getInfo();
     } catch (Exception $exc) {
         $resultJson = false;
     }
     if ($curl) {
         $curl->close();
     }
     if (false !== $resultJson && $resultStatus['http_code'] == 201) {
         return json_decode($resultJson, true);
     }
     return false;
 }
Esempio n. 2
0
 /**
  * Checks if seller account is right
  * @param type $sellerId
  * @return boolean
  */
 public function checkSellerId($sellerId)
 {
     if (empty($sellerId)) {
         return false;
     }
     $dotpayUrl = $this->config->getDotpayTargetUrl();
     $curlUrl = "{$dotpayUrl}payment_api/channels/?id={$sellerId}";
     try {
         $curl = new DotpayCurl();
         $curl->addOption(CURLOPT_SSL_VERIFYPEER, false)->addOption(CURLOPT_HEADER, false)->addOption(CURLOPT_URL, $curlUrl)->addOption(CURLOPT_REFERER, $curlUrl)->addOption(CURLOPT_RETURNTRANSFER, true);
         $resultJson = $curl->exec();
     } catch (Exception $exc) {
         $resultJson = false;
     }
     if ($curl) {
         $curl->close();
     }
     $result = json_decode($resultJson, true);
     return !(isset($result['error_code']) && $result['error_code'] == 'UNKNOWN_ACCOUNT');
 }
Esempio n. 3
0
 /**
  * Returns string with channels data JSON from Dotpay server
  * @return string|boolean
  */
 private function getApiChannelsFromServer($pv = false)
 {
     $dotpayUrl = $this->config->getDotpayTargetUrl();
     $paymentCurrency = $this->parent->getDotCurrency();
     if ($pv) {
         $dotpayId = $this->config->getDotpayPvId();
     } else {
         $dotpayId = $this->config->getDotpayId();
     }
     $orderAmount = $this->parent->getDotAmount();
     $dotpayLang = $this->parent->getDotLang();
     $curlUrl = "{$dotpayUrl}payment_api/channels/";
     $curlUrl .= "?currency={$paymentCurrency}";
     $curlUrl .= "&id={$dotpayId}";
     $curlUrl .= "&amount={$orderAmount}";
     $curlUrl .= "&lang={$dotpayLang}";
     try {
         $curl = new DotpayCurl();
         $curl->addOption(CURLOPT_SSL_VERIFYPEER, false)->addOption(CURLOPT_HEADER, false)->addOption(CURLOPT_URL, $curlUrl)->addOption(CURLOPT_REFERER, $curlUrl)->addOption(CURLOPT_RETURNTRANSFER, true);
         $resultJson = $curl->exec();
     } catch (Exception $exc) {
         $resultJson = false;
     }
     if ($curl) {
         $curl->close();
     }
     return json_decode($resultJson, true);
 }