Exemplo n.º 1
0
 public function refund($params = array())
 {
     $request = new PagarMe_Request(self::getUrl() . '/' . $this->id . '/refund', 'POST');
     $request->setParameters($params);
     $response = $request->run();
     $this->refresh($response);
 }
Exemplo n.º 2
0
 /**
  * @param $transactionId
  * @param $payableId
  * @return mixed
  * @throws Exception
  * @throws PagarMe_Exception
  */
 public static function findTrasactionById($transactionId, $payableId)
 {
     $request = new PagarMe_Request(self::ENDPOINT_TRANSACTIONS . '/' . $transactionId . self::ENDPOINT_PAYABLES . '/' . $payableId, 'GET');
     $response = $request->run();
     $class = get_called_class();
     return new $class($response);
 }
 public static function calculateInstallmentsAmount($amount, $interest_rate, $max_installments, $free_instalments)
 {
     $request = new PagarMe_Request(self::getUrl() . '/calculate_installments_amount', 'GET');
     $params = array('amount' => $amount, 'interest_rate' => $interest_rate, 'max_installments' => $max_installments, 'free_installments' => $free_instalments);
     $request->setParameters($params);
     $response = $request->run();
     return $response;
 }
Exemplo n.º 4
0
	public function charge($amount, $installments=1) {
			$this->amount = $amount;
			$this->installments = $installments;
			$request = new PagarMe_Request(self::getUrl(). '/' . $this->id . '/transactions', 'POST');
			$request->setParameters($this->unsavedArray());
			$response = $request->run();

			$request = new PagarMe_Request(self::getUrl() . '/' . $this->id, 'GET');
			$response = $request->run();
			$this->refresh($response);
	}
Exemplo n.º 5
0
 public static function all($page = 1, $count = 10)
 {
     $request = new PagarMe_Request(self::getUrl(), 'GET');
     $request->setParameters(array("page" => $page, "count" => $count));
     $response = $request->run();
     $return_array = array();
     $class = get_called_class();
     foreach ($response as $r) {
         $return_array[] = new $class($r);
     }
     return $return_array;
 }
Exemplo n.º 6
0
 public function generateCardHash()
 {
     $request = new PagarMe_Request('/transactions/card_hash_key', 'GET');
     $response = $request->run();
     $key = openssl_get_publickey($response['public_key']);
     $params = array("card_number" => $this->card_number, "card_holder_name" => $this->card_holder_name, "card_expiration_date" => sprintf("%02d", $this->card_expiration_month) . $this->card_expiration_year, "card_cvv" => $this->card_cvv);
     $str = "";
     foreach ($params as $k => $v) {
         $str .= $k . "=" . $v . "&";
     }
     $str = substr($str, 0, -1);
     openssl_public_encrypt($str, $encrypt, $key);
     return $response['id'] . '_' . base64_encode($encrypt);
 }