Last active
February 23, 2019 14:18
-
-
Save aphilippi/3f681d070392cee0ae09 to your computer and use it in GitHub Desktop.
Factureaza.ro API: payment examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//set BASE_URL to https://factureaza.ro/api/v1/ for production | |
define('BASE_URL', 'https://sandbox.factureaza.ro/api/v1/'); | |
//replace with the api key provided in the backend | |
define('API_KEY', '72543f4dc00474bc40a27916d172eb93339fae894ec7a6f2dceb4751d965'); | |
$currency_id = 183; // 183 -> RON | |
$invoice_id = 1065253795; // your invoice id here | |
$attributes = array( | |
"payment" => array( | |
"amount" => '1001.11', | |
"currency_id" => $currency_id, | |
"payment_date" => '2015-02-20', | |
"description" => 'prin ordin de plata - Banca Transilvania', | |
"invoice_id" => $invoice_id | |
) | |
); | |
$url = BASE_URL . 'payments.xml'; | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_POST, 1); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($ch, CURLOPT_USERPWD, API_KEY . ":x"); | |
curl_setopt($ch, CURLOPT_URL, $url ); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($attributes)); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | |
$result = curl_exec($ch); | |
$header = curl_getinfo($ch); | |
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); | |
curl_close($ch); | |
if ($httpCode == 201) { | |
echo 'Created successfully'; | |
} else { | |
echo '<pre> Error occured: ' . $httpCode . ':' . $result . '</pre>'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment