NAV

Introduction

Welcome to the Fena invoice integration guide.

How the Fena invoice API Works

Get Access Token

POST /merchant/login/token

Parameter Default Description
Content-Type application/json Payload type is json

Body / Payload Parameters

Parameter Description
id Merchant ID from Fena Support
secret API_SECRET from Fena Support

Payload

{
"id" : "123",
"secret": "API_SECRET"
}

Successful Response

{
"token": "ABC",
"status": {
    "maxTransactionSize": "XXXX.XX"
  }
}

Create New Invoice

POST /merchant/invoice-payment-requests/

Parameter Default Description
Content-Type application/json Payload type is json
Authorization Bearer {TOKEN from step 2 response} Bearer Token

Body / Payload Parameters

Parameter Example Value Description
amount "0.50" 2 decimal place formatted number as string - must be equal to or higher than 0.50 and lower than your maxTransactionSize from step 2
internalInvoiceNumber "ABC" A unique internal invoice number, must be string. Max 255 characters
note "electric bill" A optional note shown to customer when paying the invoice, can be empty string
name "John Doe" A name of customer, must be string. Max 255 characters. Can be empty
email "john@fena.co" If you want to automatically send an email to customer, it must be a valid email address. Can be empty
emailCC "doe@fena.co" If you want to send email to an additional email address. It must be a valid email address. Can be empty
file "..." A base64 encoded data of pdf file - can be empty
dueDate "2022-01-30" Due date of invoice - Format (YYYY-mm-dd) - can be empty

Payload

{
"amount": "0.50",
"internalInvoiceNumber" : "A10033",
"note" : "electric bill",
"name" : "John Doe",
"email": "john@fena.co",
"emailCC" :"doe@fena.co",
"file" : "BASE64 Encoded File Data of PDF",
"dueDate" : "2022-01-30"
}

Successful Response

{
  "id": XXX
}

Get Invoice QR code and Payment Link

GET /merchant/invoice-payment-requests/{X from step 3 response}

Parameter Default Description
Content-Type application/json Payload type is json
Authorization Bearer {TOKEN from step 2 response} Bearer Token

Successful Response

{
  "data": {
    "id": xxx,
    "amount": "1.00",
    "internalInvoiceNumber": "test123",
    "note": "testaaa",
    "paid": false,
    "createdAt": "2021-04-21 10:30",
    "completedAt": "",
    "payment": {
          ....
    }
  },
  "payment-link": {
    "link": "https://app.faizpay.com/r/??",
    "qrCode": "https://qr-code.faizpay.com/?data=??"
  }
}

"payment-link" of the response contains the a weblink for payment and image link for QR code.

List Invoice

GET /merchant/invoice-payment-requests/?page=1&status=0

Parameter Default Description
Content-Type application/json Payload type is json
Authorization Bearer {TOKEN from step 2 response} Bearer Token

Query Parameter

Parameter Default Description
page 1 page number to fetch invoice
status 0 0 for all invoices, 1 for paid invoices, 2 for pending invoices

Successful Response

{
  "totalItems": 13,
  "currentPage": 1,
  "totalPages": 1,
  "invoices": [
    {
      "id": xx,
      "amount": "0.50",
      "internalInvoiceNumber": "A10033",
      "note": "electric bill",
      "paid": false,
      "createdAt": "2021-06-06 16:35",
      "completedAt": ""
    },
    ...
  ]
}

Delete Invoice

You can only delete invoice if it has not been paid yet.

DELETE /merchant/invoice-payment-requests/{invoice-id}

Parameter Default Description
Content-Type application/json Payload type is json
Authorization Bearer {TOKEN from step 2 response} Bearer Token

Successful Response

{
  "deleted": true
}