API Documentation - sciventures/bitmarket GitHub Wiki
Introduction
A typical Bitcoin payment is initiated as such:
- Make sure to authenticate all requests.
- Generate an invoice. You will get an
Invoice ID
. - Use that
Invoice ID
to generate a paylink. - Your callback URL should get a POST request when the user has successfully paid. You will get an
Invoice ID
andPayment ID
from this POST. - Use that
Payment ID
to get more info on the payment.
Authentication
All requests should include your generated API token in its header content in the following key-pair format:
'Authorization' : 'bitmarket-sec <generated token>'
Invoice Endpoint
Create an Invoice
This endpoint allows you to create a Bitcoin invoice.
POST https://api.bitmarket.ph/invoice
Send a POST request with the following payload encoded in JSON:
amount
- Value in Philippine Pesos you want to invoice.callback
- Your URL where we will be sending payment confirmations.redirectURL
- Your URL where we will be sending the user after a successful transaction.
Our server will respond with a JSON object with the following keys: 'success' => 'invoice created', 'id' => $invoice->id)
success
- This key will have a value of "invoice created".id
- ID of the invoice generated.
Heads up! If there was an error in the generation of an invoice, the response will be a JSON object with an error
key and the error message as its value.
CURL example POST:
echo "Hello World"
PHP example POST:
echo "Hello world";
Python example POST:
printf("Hello World")
Callback URL
Your callback URL (passed in the invoice creation) will be hit with the following POST request:
timestamp
- Timestamp formatted ininvoice_id
- Invoice IDpayment_id
- Payment ID
Read an Invoice
You may also retrieve an invoice via a GET request:
Paylink Endpoint
This endpoint allows you to build a Bitmarket.ph Paylink.
GET https://api.bitmarket.ph/invoice/{id}/paylink
{id}
- Invoice ID.
Our server will respond with a JSON object with the code
key. This code
should be used to build the Paylink URL which you would redirect to or insert inside an iFrame like this:
https://pay.bitmarket.ph/{code}
Optionally, you can append ?iframe=true
to the Paylink if you want to insert the invoice page inside an iframe.
https://pay.bitmarket.ph/{code}?iframe=true
Payment Endpoint
This endpoint allows you to build a Bitmarket.ph Paylink.
GET https://api.bitmarket.ph/payment/{id}
{id}
- Payment ID.
Our server will respond with a JSON encoded Payment object with the following details:
id
- Payment IDtimestamp
- Timestampbtcamount
- Amount in Bitcoinstatus_id
= Status of paymentinvoice
- Invoice objectcompany
- Company objectclient
- Client object
What's important to note is the status_id
which will be 1
if status of payment is "for remittance" or 2
if status of payment is "remitted". status_id
of 1
or 2
means that the transaction is complete as far as the customer is concerned.
Websocket Notification
Allows you to subscribe to invoice payment notifications via socket.io
ws://api.bitmarket.ph:8080
To subscribe to a notification for invoice {id}
socket.emit('subscribe', {channel:[{name: 'invoice', invoice_id:
invoice
}]});
When an invoice is paid, our server will send a paid
socket.io message including the invoice id