Invoices
Introduction
Invoices are a powerful tool for businesses to bill customers for goods or services. Sonic Payment Gateway provides a simple and secure way to create, manage, and track invoices. In this section, we will cover how to create, retrieve, update, and delete invoices using our API.
Create an invoice
To create an invoice, you will need to make a POST request to the /invoices endpoint. You can include the following parameters in the request body:
amount
integer
The total amount of the invoice in the smallest denomination of the currency (e.g. cents for USD)
currency
string
The ISO 4217 currency code
customer_email
string
The email address of the customer
customer_name
string
The name of the customer
line_items
array
An array of line items for the invoice. Each line item should include the following parameters: name
, amount
, and quantity
.
due_date
string (YYYY-MM-DD)
The date the invoice is due in ISO 8601 format
metadata
object
Additional metadata to associate with the invoice
Creating an invoice
POST
https://api.sonicpay.org/invoices
Request Body
amount*
10000
currency*
USDT
customer_email*
customer@example.com
customer_name*
John Doe
line_items*
"name": "Product 1", "amount": 5000, "quantity": 2
due_date*
2022-05-30
metadata*
"order_id": "12345"
Here is an example curl request for creating an invoice:
Get an invoice
To retrieve an invoice, you will need to make a GET request to the /invoices/{invoice_id} endpoint, where {invoice_id} is the ID of the invoice you wish to retrieve.
GET
https://api.sonicpay.org/invoices/invoice_id
Path Parameters
invoice_id*
32322
Headers
Content-Type*
application/json
Authorization: Bearer*
your_api_key
Update an invoice
To update an invoice, you will need to make a PUT request to the /invoices/{invoice_id} endpoint, where {invoice_id} is the ID of the invoice you wish to update. You can include any of the parameters from the create invoice request in the request body.
PATCH
PATCH https://api.sonicpay.org/invoices/{invoice_id}
Path Parameters
invoice_id*
23424
Authorization: Bearer*
your_api_key
Content-Type*
application/json
Request Body
description*
New Description
amount*
100
currency*
Doge
shipping*
Pending
metadata*
"order_id": "12345"
This endpoint is used to update an existing invoice. The following parameters can be updated:
description
string
A description of the invoice
amount
number
The total amount of the invoice
currency
string
The currency of the invoice (e.g. USD, EUR, etc.)
shipping
object
An object containing information about the shipping costs associated with the invoice. Can contain the following properties:<br>- amount: The amount of the shipping costs<br>- address: An object containing information about the shipping address. Can contain the following properties:<br> - name: The name of the recipient<br> - address1: The first line of the shipping address<br> - address2: The second line of the shipping address (optional)<br> - city: The city of the shipping address<br> - state: The state of the shipping address<br> - country: The country of the shipping address<br> - postal_code: The postal code of the shipping address
metadata
object
An object containing additional information about the invoice
Example Request
Example Response:
Get all Invoices
Make a GET request to the /invoices
endpoint. This will return a list of all invoices associated with your account, including their ID, status, and amount.
GET
https://api.sonicpay.org/v1/invoices
Headers
Authorization: Bearer
YOUR_API_KEY
You can also include query parameters to filter the invoices returned in the response. For example, you can filter by invoice status (paid, unpaid, etc) or by a specific date range.
Alternatively, you can use the Sonic Payment Gateway SDK to get all invoices in your desired programming language. The SDK will handle the API call and return the result in a format that is easy to work with in your code.
Response:
Last updated