FactPlus RESTful API Versão 1.0

Demos

  1. 1. CRIAR UM DOCUMENTO

Factura / Factura-Recibo / Proforma

     
     {
     "apicall":"CREATE",
      "apikey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
      "document": {
        "type": "factura",
        "date": "2020-08-18",
        "duedate": "2020-08-25",
        "vref": "XPTO001 ",
        "serie":"2020",
        "currency":"AOA",
        "exchange_rate":"0",
        "observation":"Simples docuemnto",
        "retention":"6.5"
        },
      "client":{
        "name": "John Doe",
        "nif": "000000000",
        "email": "johndoe@gmail.com",
        "city": "Luanda",
        "address":"Av. Fidel Castro",
        "postalcode":"",
        "country":"Angola"
      },
       "items": [
                {
                    "itemcode": "sfB001",
                    "description": "Softwares",
                    "price": "1000000",
                    "quantity": "1",
                    "tax": "14",
                    "discount": "0",
                    "exemption_code": "",
                    "retention": ""
                },
                {
                    "itemcode": "WEB001",
                    "description": "Website",
                    "price": "200000",
                    "quantity": "2",
                    "tax": "14",
                    "discount": "0",
                    "exemption_code": "",
                    "retention": ""
                }
               
            ]
    }
        
   

$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.factplus.co.ao",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS =>"{\r\n      \"apicall\":\"CREATE\",\r\n      \"apikey\": \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\",\r\n      \"document\": {\r\n        \"type\": \"factura\",\r\n        \"date\": \"2020-08-18\",\r\n        \"duedate\": \"2020-08-25\",\r\n        \"vref\": \"XPTO001\",\r\n        \"serie\":\"2020\",\r\n        \"currency\":\"AOA\",\r\n        \"exchange_rate\":\"0\",\r\n        \"observation\":\"Documento simples\",\r\n        \"retention\":\"6.5\"\r\n        },\r\n      \"client\":{\r\n        \"name\": \"john Doe\",\r\n        \"nif\": \"000000000\",\r\n        \"email\": \"cliente@gmail.com\",\r\n        \"city\": \"Luanda\",\r\n        \"address\":\"Av Fidel Castro\",\r\n        \"postalcode\":\"\",\r\n        \"country\":\"Angola\"\r\n      },\r\n       \"items\": [\r\n                {\r\n                    \"itemcode\": \"WEB001\",\r\n                    \"description\": \"Software\",\r\n                    \"price\": \"1000000\",\r\n                    \"quantity\": \"1\",\r\n                    \"tax\": \"14\",\r\n                    \"discount\": \"0\",\r\n                    \"exemption_code\": \"\",\r\n                    \"retention\": \"\"\r\n                },\r\n                {\r\n                    \"itemcode\": \"WEB001\",\r\n                    \"description\": \"Website\",\r\n                    \"price\": \"200000\",\r\n                    \"quantity\": \"2\",\r\n                    \"tax\": \"14\",\r\n                    \"discount\": \"0\",\r\n                    \"exemption_code\": \"\",\r\n                    \"retention\": \"\"\r\n                }\r\n               \r\n            ]\r\n    }",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

{"result":"success","message":"Operação realizada com successo!","data":"1599648519"}

  1. 2. VISUALIZAR DOCUMENTO

Factura / Factura-Recibo / Proforma

     
{
    "apicall" : "VIEW",
    "apikey" : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "document" : {
        "reference" : "",
        "type" : "factura"
    }
} 


   

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.factplus.co.ao",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS =>"{\r\n    \"apicall\" : \"VIEW\",\r\n    \"apikey\" : \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\",\r\n    \"document\" : {\r\n        \"reference\" : \"1599644233\",\r\n        \"type\" : \"factura\"\r\n    }\r\n}   \r\n",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: text/plain"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
{"result":"success","message":"Operação realizada com successo!","data":{"document":{"type":"Factura","reference":"1599644233","status":"settled","number":"2020\/167","serie":"2020","date":"2020-09-09","duedate":"2020-09-09","vref":"TBH","currency":"","exchange_rate":"0.000000000","observation":"Chando pela API ","retention":"0.0000","archived":"0","cancel_reason":"","exemption_reason":"","createdat":"2020-09-09 10:37:12"},"client":{"name":"John Doe","nif":"","email":"johndoe@gmail.com","telephone":"0","address":" Viana","city":"Luanda"},"items":[{"itemcode":"ppo","description":"Auscutadores","price":"19000.0000","quantity":"2.00","tax":"0.0000","discount":"0.0000","exemption_code":"M00"}],"summary":{"sum":"38000.00","discount":"0.0000","retention":"0.0000","stax":"38000.00","wtax":"0.0000","total":"38000.00"}}}

  1. 3. FINALIZAR DOCUMENTO

Factura

     
{

    "apicall" : "ALTER",
    "apikey" : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "document" : {
        "type" : "factura",
        "reference" : "1597239608",
        "status" : "sent",
        "reason":"From API"
    }
    
}
     
{

    "apicall" : "ALTER",
    "apikey" : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "document" : {
        "type" : "factura",
        "reference" : "1597239608",
        "status" : "canceled",
        "reason":"From API"
    }
    
}
   

require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://api.factplus.co.ao');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Content-Type' => 'text/plain'
));
$request->setBody('{
\n
\n    "apicall" : "ALTER",
\n    "apikey" : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
\n    "document" : {
\n        "type" : "factura",
\n        "reference" : "1599660733",
\n        "status" : "sent",
\n        "reason":"From API"
\n    }
\n    
\n}
\n        
\n');
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}
{"result":"success","message":"Operação realizada com successo!","data":true}

  1. 4. PAGAMENTO RECIBO

Factura / Factura-Recibo

     
    {
  "apicall":"RECEIPT",
  "apikey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "document": {
    "reference": "1599661085",
    "type": "factura"
    },
  "payment":{
    "amount": "20000.00",
    "date":"2020-09-09",
    "serie": "2020",
    "pm": "TB",
    "observation": "pagamento concluído pela API."
  }
}

   
var settings = {
  "url": "https://api.factplus.co.ao",
  "method": "POST",
  "timeout": 0,
  "headers": {
    "Content-Type": "application/json"
  },
  "data": JSON.stringify({"apicall":"RECEIPT","apikey":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","document":{"reference":"1599661085","type":"factura"},"payment":{"amount":"20000.00","date":"2020-09-09","serie":"2020","pm":"TB","observation":"pagamento concluído."}}),
};

$.ajax(settings).done(function (response) {
  console.log(response);
});
{"result":"success","message":"Operação realizada com successo!","data":true}

  1. 5. ENVIAR DOCUMENTO

Factura / Factura-Recibo / Proforma

     
     {
  "apicall":"RECEIPT",
  "apikey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "document": {
    "reference": "1599661085",
    "type": "factura"
    },
  "payment":{
    "amount": "20000.00",
    "date":"2020-09-09",
    "serie": "2020",
    "pm": "TB",
    "observation": "pagamento concluído."
  }
}



        


   
var axios = require('axios');
var data = JSON.stringify({"apicall":"RECEIPT","apikey":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","document":{"reference":"1599661085","type":"factura"},"payment":{"amount":"20000.00","date":"2020-09-09","serie":"2020","pm":"TB","observation":"pagamento concluído."}});

var config = {
  method: 'post',
  url: 'https://api.factplus.co.ao',
  headers: { 
    'Content-Type': 'application/json'
  },
  data : data
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});

{"result":"success","message":"Operação realizada com successo!","data":true}