Skip to content

Calculate an invoice

POST https://api.leapa.co/v2/invoices/calculate

This endpoint needs your API key

Send it as a bearer token in the Authorization header. A request without one is answered with 401. See Authentication for where to find your key and how to keep it secret.

Request

curl -X POST "https://api.leapa.co/v2/invoices/calculate" \
  -H "Authorization: Bearer $LEAPA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "description": "Room 204, two nights",
    "affiliate": "dwelinn",
    "sendForManualPayment": false,
    "customer_id": "cus_3d8e51fa20",
    "products": [
      {
        "quantity": 1,
        "product_id": "prd_84c2e7f019",
        "rate_ids": []
      }
    ],
    "due_date": "2026-01-31",
    "source_id": "src_0e7b3c95af",
    "manual_payment": false,
    "rate_id": "rat_20b6df3c9e",
    "amount_to_paid": 45000,
    "custom_fields": {
      "obr_code": "ADB_REGISTRE_COMMERCE"
    }
  }'

Response

OK

{
  "currency": "BIF",
  "amount_due": 45000,
  "rate_id": "rat_20b6df3c9e"
}

Request body

application/json

Required. Send it as JSON.

  • descriptionstringrequired

    Description of the invoice. Constraints: Not null, min=3 and max=120

    Must be:3 to 120 characters
  • affiliatestring

    affiliate that can be used on this invoice

    Allowed values:dwelinn
  • sendForManualPaymentboolean
  • customer_idstringrequired

    Customer Id. Constraints: Not null

  • productsarray of ItemRequestrequired

    List of product and quantity. Constraints: Not null, Not Empty

  • due_datestring<date>required

    Invoice due date. Constraints: Not null, format(YYYY-MM-DD)

  • source_idstring

    Customer existing source information.

  • manual_paymentboolean

    Collection Method of this invoice: If the payment is automatic then the system will charge against the customer register card. If it is manual the system will send an email to the customer with payment instruction.

  • rate_idstring

    Rate Id that can be used on this invoice.

  • amount_to_paidnumber<double>

    this is for partial payment of an invoice

  • custom_fieldsobject

    Extra key/value pairs carried with the invoice. Every value has to be a string. For Burundi tax collection, set obr_code to the OBR payment code the payment belongs to, for example ADB_REGISTRE_COMMERCE. Leapa sends that code to OBR when the invoice is paid and puts the quittance number OBR issues on the invoice, as quittance_number. Write once: the invoice does not return custom_fields, and updating an invoice cannot change it, so keep your own record of which code you sent.

    Example:{"obr_code":"ADB_REGISTRE_COMMERCE"}

Response

application/json
  • currencystring

    Currency of the amount in the invoice.

    Allowed values:BIFUSDKESXAF
  • amount_dueinteger<int64>

    amount upon applying the rate to be paid for this Invoice.

  • rate_idstring

    Rate Id that can be used on this invoice.

Status codes

  • 200OK
  • 400Bad request
  • 401Unauthorized
  • 402Payment required
  • 403Forbidden
  • 404Not found
  • 428Precondition required
  • 500Server error

Request

curl -X POST "https://api.leapa.co/v2/invoices/calculate" \
  -H "Authorization: Bearer $LEAPA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "description": "Room 204, two nights",
    "affiliate": "dwelinn",
    "sendForManualPayment": false,
    "customer_id": "cus_3d8e51fa20",
    "products": [
      {
        "quantity": 1,
        "product_id": "prd_84c2e7f019",
        "rate_ids": []
      }
    ],
    "due_date": "2026-01-31",
    "source_id": "src_0e7b3c95af",
    "manual_payment": false,
    "rate_id": "rat_20b6df3c9e",
    "amount_to_paid": 45000,
    "custom_fields": {
      "obr_code": "ADB_REGISTRE_COMMERCE"
    }
  }'

Response

OK

{
  "currency": "BIF",
  "amount_due": 45000,
  "rate_id": "rat_20b6df3c9e"
}