Exemple #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;
 }
Exemple #2
0
 /**
  * Makes a return payment and returns infos about a result of this operation
  * @param string $username
  * @param string $password
  * @param string $payment
  * @param float $amount
  * @param type $control
  * @param type $description
  * @return type
  */
 public function makeReturnMoney($username, $password, $payment, $amount, $control, $description)
 {
     $url = $this->_baseurl . $this->getDotPaymentApi() . 'payments/' . $payment . '/refund/';
     $data = array('amount' => str_replace(',', '.', $amount), 'description' => $description, 'control' => $control);
     $curl = new DotpayCurl();
     $curl->addOption(CURLOPT_URL, $url)->addOption(CURLOPT_USERPWD, $username . ':' . $password)->addOption(CURLOPT_POST, 1)->addOption(CURLOPT_POSTFIELDS, json_encode($data))->addOption(CURLOPT_SSL_VERIFYPEER, TRUE)->addOption(CURLOPT_SSL_VERIFYHOST, 2)->addOption(CURLOPT_RETURNTRANSFER, 1)->addOption(CURLOPT_TIMEOUT, 100)->addOption(CURLOPT_HTTPHEADER, array('Accept: application/json; indent=4', 'content-type: application/json'));
     $resp = json_decode($curl->exec(), true);
     return $curl->getInfo() + $resp;
 }