API-v2

Application Programming Interface

InvoiceXpress Documentation



Generate Payment/Receipt


POST /documents/:document-id/partial_payments.json

Creates a payment which generates a receipt. This endpoint is only available for invoices, simplified_invoices and vat_moss_invoices.

Example Request

curl

curl --request POST \
  --url 'https://account_name.app.invoicexpress.com/documents/:document-id/partial_payments.json?api_key=YOUR%20API%20KEY%20HERE' \
  --header 'accept: application/json' \
  --header 'content-type: application/json' \
  --data '{"partial_payment":{"payment_mechanism":"TB","note":"Observations","serie":"A","amount":100.0,"payment_date":"26/10/2017"}}'

Ruby

require 'uri'
require 'net/http'

url = URI("https://account_name.app.invoicexpress.com/documents/:document-id/partial_payments.json?api_key=YOUR%20API%20KEY%20HERE")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url)
request["accept"] = 'application/json'
request["content-type"] = 'application/json'
request.body = "{\"partial_payment\":{\"payment_mechanism\":\"TB\",\"note\":\"Observations\",\"serie\":\"A\",\"amount\":100.0,\"payment_date\":\"26/10/2017\"}}"

response = http.request(request)
puts response.read_body

Node

var http = require("https");

var options = {
  "method": "POST",
  "hostname": "account_name.app.invoicexpress.com",
  "port": null,
  "path": "/documents/:document-id/partial_payments.json?api_key=YOUR%20API%20KEY%20HERE",
  "headers": {
    "accept": "application/json",
    "content-type": "application/json"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({ partial_payment:
   { payment_mechanism: 'TB',
     note: 'Observations',
     serie: 'A',
     amount: 100,
     payment_date: '26/10/2017' } }));
req.end();

Python

import http.client

conn = http.client.HTTPSConnection("account_name.app.invoicexpress.com")

payload = "{\"partial_payment\":{\"payment_mechanism\":\"TB\",\"note\":\"Observations\",\"serie\":\"A\",\"amount\":100.0,\"payment_date\":\"26/10/2017\"}}"

headers = {
    'accept': "application/json",
    'content-type': "application/json"
    }

conn.request("POST", "/documents/:document-id/partial_payments.json?api_key=YOUR%20API%20KEY%20HERE", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))

PHP

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://account_name.app.invoicexpress.com/documents/:document-id/partial_payments.json?api_key=YOUR%20API%20KEY%20HERE",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "{\"partial_payment\":{\"payment_mechanism\":\"TB\",\"note\":\"Observations\",\"serie\":\"A\",\"amount\":100.0,\"payment_date\":\"26/10/2017\"}}",
  CURLOPT_HTTPHEADER => array(
    "accept: application/json",
    "content-type: application/json"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

Go

package main

import (
    "fmt"
    "strings"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "https://account_name.app.invoicexpress.com/documents/:document-id/partial_payments.json?api_key=YOUR%20API%20KEY%20HERE"

    payload := strings.NewReader("{\"partial_payment\":{\"payment_mechanism\":\"TB\",\"note\":\"Observations\",\"serie\":\"A\",\"amount\":100.0,\"payment_date\":\"26/10/2017\"}}")

    req, _ := http.NewRequest("POST", url, payload)

    req.Header.Add("accept", "application/json")
    req.Header.Add("content-type", "application/json")

    res, _ := http.DefaultClient.Do(req)

    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))

}

Path Parameters

Name Type Required Description Example
document-id Integer Required The ID of the invoice, simplified_invoice or vat_moss_invoice for which you want to make a payment and generate a receipt. 1

Request Body

Name Type Required Description
partial_payment Object Required Payment data
payment_mechanism String How the payment was made. Check the appendix for possible values. Defaults to client settings or account settings if defined. Otherwise, defaults to ‘TB’.
note String Observations.
serie String Document serie. It can be obtained with this endpoint. Defaults to the serie of the document passed in the url.
amount Number Required Amount of the partial payment. Must be a value greater or equal to zero.
payment_date String Date of the payment. Defaults to today.

Example Request Body

{
  "partial_payment": {
    "payment_mechanism": "TB",
    "note": "Observations",
    "serie": "A",
    "amount": 100.0,
    "payment_date": "26/10/2017"
  }
}

Responses

200 SUCCESS
Payment was made successfully and the receipt was generated.
Invoices Receipt
401 ACCESS DENIED
The API Key parameter is missing or is incorrectly entered.
(Empty Response)
404 NOT FOUND
The supplied :document-id doesn’t match any existing document.
(Empty Response)
422 UNPROCESSABLE ENTITY
Some parameters sent were incorrect.
(Empty Response)

Example Response Body

{
  "receipt": {
    "id": 541793,
    "status": "final",
    "archived": true,
    "type": "Invoice",
    "sequence_number": "28/A",
    "inverted_sequence_number": "A/28",
    "date": "27/06/2017",
    "due_date": "27/06/2017",
    "reference": "foo",
    "observations": "foo",
    "retention": "foo",
    "permalink": "https://www.app.invoicexpress.com/documents/541793e1ab2ebd5c06def40c346ffbe0ff2b463eb1c0f0",
    "saft_hash": "Tdik",
    "sum": 1,
    "discount": 0,
    "before_taxes": 1,
    "taxes": 0.07,
    "total": 1.07,
    "currency": "Euro",
    "client": {
      "id": 1310176,
      "name": "John",
      "country": "Portugal"
    },
    "items": [
      {
        "name": " iPhone ",
        "description": "foo",
        "unit_price": "1.0",
        "unit": "foo",
        "quantity": "1.0",
        "tax": {
          "id": 31597,
          "name": "IVA7",
          "value": 7
        },
        "discount": 0,
        "subtotal": 1,
        "tax_amount": 0.07,
        "discount_amount": 0,
        "total": 1.07
      }
    ],
    "sequence_id": "12345",
    "tax_exemption": "M01"
  }
}
Livro de Reclamação