An invoice is a statement of what a user will need to pay to another user. Reason behind the transaction can range from providing services, selling an item or simply sending money to another user.
In an invoice there will always be two entities involved:
- The receiver who will receive the payment (the merchant).
- The sender who will send the payment to fulfill the invoice (the customer).
Creating Invoices
A POST
to the invoice endpoint will create an invoice.
POST
https://api.coins.asia/v1/invoices/
Headers
Content-Type
:application/json
Body
amount
- The amount expected from the customer.currency
- Currency of transaction.external_transaction_id
- A transaction ID provided by the merchant.supported_payment_collectors
- Payment options available to the user when viewing the payment request ie["coins_peso_wallet", "cash_payment"]
.expires_at
- The expiration of the invoice. Expects date time format ISO 8601 (e.g.2016-10-20T13:00:00.000000Z
) or time delta from current time (e.g.1w 3d 2h 32m 5s
).
Payment Options
You can specify specific payment options that a payment request will present to the paying user. Options that can be passed to the supported_payment_collectors
attribute are the following:
Code | Description |
---|---|
coins_peso_wallet | Pay with the user's Peso Coins wallet. |
cash_payment | Pay with any of the payment options that requires the user to pay over the counter. (Currently won't include bayad_deposit and palawan_deposit) |
seven_connect_deposit | Pay over the counter at any 7-eleven convenience store. |
mlhuillier_deposit | Pay over the counter at any Mlhuillier branch. |
cebuana_lhuillier_deposit | Pay over the counter at any Cebuana Lhuillier branch. |
bayad_deposit | Pay over the counter at any Bayad Center branch. |
Example Request
import json
import requests
url = "https://api.coins.asia/v3/invoices/"
TOKEN = 'YOUR TOKEN'
headers = {
'Authorization': 'Bearer {}'.format(TOKEN),
'Content-Type': 'application/json;charset=UTF-8',
'Accept': 'application/json'
}
body = json.dumps({
"amount": 120,
"currency": "PHP",
"external_transaction_id": "89723952",
"supported_payment_collectors": ["coins_peso_wallet","cash_payment"]
})
requests.post(url, headers=headers, data=body)
print(response.text)
Example Response
{
"invoice": {
"id": "voro5v750qyig7dayil9wkteokfc90kg",
"note": "",
"note_scope": "private",
"status": "pending",
"category": "merchant",
"amount": "120.00000000",
"currency": "PHP",
"amount_due": "120.00000000",
"locked_rate": "340000.00000000",
"initial_rate": "340000.00000000",
"incoming_address": "389CxLbGhWUAQmebVUXyfjHWa1roziM6HY",
"external_transaction_id": "89723969",
"payment_url": "https://coins.ph/payment/invoice/voro5v750...",
"metadata": {},
"created_at": "2017-10-20T20:25:00.000000Z",
"updated_at": "2017-10-20T20:25:00.000000Z",
"expires_at": "2017-10-20T20:40:00.000000Z",
"sender_name": "",
"sender_email": "",
"sender_mobile_number": "",
"payment_collector_fee_placement": "top",
"supported_payment_collectors": ["coins_peso_wallet","cash_payment"],
"payments": [],
"receiver": "GnTFcQmJAfVvGEygpbFUWrnKzhgmNzUP",
"btc_amount_due": "0.00035294",
"expires_in_seconds": "800",
"current_payment_reference_number": ""
}
}
Retrieving Invoices
A GET
to the invoice endpoint will retrieve a list of the merchant's invoices, or a particular invoice if :id
is provided
GET
https://api.coins.asia/v1/invoices/:id
Example Request
import requests
url = "https://api.coins.asia/v3/invoices/5edc263fac7f4f61b87632cb5710050f/"
TOKEN = 'YOUR TOKEN'
headers = {
'Authorization': 'Bearer {}'.format(TOKEN),
'Content-Type': 'application/json;charset=UTF-8',
'Accept': 'application/json'
}
response = requests.get(url, headers=headers)
print(response.text)
Example Response
{
"invoice": {
"id": "voro5v750qyig7dayil9wkteokfc90kg",
"note": "",
"note_scope": "private",
"status": "pending",
"category": "merchant",
"amount": "120.00000000",
"currency": "PHP",
"amount_due": "120.00000000",
"locked_rate": "340000.00000000",
"initial_rate": "340000.00000000",
"incoming_address": "389CxLbGhWUAQmebVUXyfjHWa1roziM6HY",
"external_transaction_id": "89723969",
"payment_url": "https://coins.ph/payment/invoice/voro5v750...",
"metadata": {},
"created_at": "2017-10-20T20:25:00.000000Z",
"updated_at": "2017-10-20T20:25:00.000000Z",
"expires_at": "2017-10-20T20:40:00.000000Z",
"sender_name": "",
"sender_email": "",
"sender_mobile_number": "",
"payment_collector_fee_placement": "top",
"supported_payment_collectors": ["cash_payment"],
"payments": [],
"receiver": "GnTFcQmJAfVvGEygpbFUWrnKzhgmNzUP",
"btc_amount_due": "0.00035294",
"expires_in_seconds": "800",
"current_payment_reference_number": ""
}
}