Invoices
An invoice records a one-off sales transaction between you and your customers. It includes the units and price of the product that you sell, as well as relevant payment information.
GET /api/v1/billing/invoices/{id}GET /api/v1/billing/invoicesPOST /api/v1/billing/invoices/previewGET /api/v1/billing/invoices/{id}/items/{item_id}GET /api/v1/billing/invoices/{id}/items
Retrieve an invoice
GET /api/v1/billing/invoices/{id}
Retrieves the details of an Invoice.
Unique identifier of the Invoice object.
Time when this invoice was created.
The currency of the invoice (in 3-letter ISO-4217 format).
Unique identifier of the customer who will be charged.
Unique identifier of the Invoice object.
Time of last payment attempt.
Time of next payment attempt.
Time when this invoice was paid.
The number of payment attempts made on this invoice so far.
Unique identifier of the PaymentIntent that is associated with this invoice, if any.
The end of the billing period associated with this invoice. This value is exclusive.
The start of the billing period associated with this invoice. This value is inclusive.
The number of the remaining payment attempts. If 0, no more payment attempts would be triggered automatically for this invoice.
The status of the invoice, one of SENT, PAID and PAYMENT_FAILED.
Once the invoice is sent out for payment, its status is SENT. If the payment is successful, the status becomes PAID. If Airwallex is unable to collect the payment after exhausted all charge attempts, then the status becomes PAYMENT_FAILED.
Unique identifier of the subscription which generated this invoice, if any.
The total amount of the invoice.
Time when this invoice was last updated.
| Error status | Description |
|---|---|
| 400 | Bad Request. Possible error codes: |
| 401 | Unauthorized. Possible error codes: |
| 404 | Not Found. Possible error codes: |
| 500 | Server Error. Possible error codes: |
$curl --request GET \> --url 'https://api-demo.airwallex.com/api/v1/billing/invoices/invoice_id' \> --header 'Authorization: Bearer {{ACCESS_TOKEN}}' \> --header 'Content-Type: application/json'
1{2 "created_at": "2022-01-01T10:15:30Z",3 "currency": "USD",4 "customer_id": "cus_ps8e0ZgQzd2QnCxVpzJrHD6KOVu",5 "id": "inv_hkpd49cskgblns6iimw",6 "last_payment_attempt_at": "2022-12-05T10:15:30+0000",7 "next_payment_attempt_at": "2022-12-05T10:15:30+0000",8 "paid_at": "2022-12-05T10:15:30+0000",9 "past_payment_attempt_count": 1,10 "payment_intent_id": "int_e65tkXCSzJrsMpTrzoFrjaau53",11 "period_end_at": "2022-01-05T10:15:30+0000",12 "period_start_at": "2022-01-01T10:15:30+0000",13 "remaining_payment_attempt_count": 1,14 "status": "SENT",15 "subscription_id": "sub_hkpdkcmxdgazzq53jbk",16 "total_amount": 100,17 "updated_at": "2022-01-01T10:15:30Z"18}
Get list of invoices
GET /api/v1/billing/invoices
Retrieve a list of Invoices based on the query parameters.
Unique identifier of the customer who will be charged.
The start date of created_at in ISO8601 format (inclusive).
Page number starting from 0. Defaults to 0.
Number of Invoices per page. Defaults to 20.
The status of the invoice, one of SENT, PAID and PAYMENT_FAILED.
When the invoice is sent out for payment, its status is SENT. If the payment is successful, the invoice moves to PAID status. If Airwallex cannot collect the payment from the customer after all attempts, the invoice moves to PAYMENT_FAILED status.
Unique identifier of the subscription which generated this invoice, if any.
The end date of created_at in ISO8601 format (exclusive).
A flag which identifies whether there are more results.
Paged results.
Time when this invoice was created.
The currency of the invoice (in 3-letter ISO-4217 format).
Unique identifier of the customer who will be charged.
Unique identifier of the Invoice object.
Time of last payment attempt.
Time of next payment attempt.
Time when this invoice was paid.
The number of payment attempts made on this invoice so far.
Unique identifier of the PaymentIntent that is associated with this invoice, if any.
The end of the billing period associated with this invoice. This value is exclusive.
The start of the billing period associated with this invoice. This value is inclusive.
The number of the remaining payment attempts. If 0, no more payment attempts would be triggered automatically for this invoice.
The status of the invoice, one of SENT, PAID and PAYMENT_FAILED.
Once the invoice is sent out for payment, its status is SENT. If the payment is successful, the status becomes PAID. If Airwallex is unable to collect the payment after exhausted all charge attempts, then the status becomes PAYMENT_FAILED.
Unique identifier of the subscription which generated this invoice, if any.
The total amount of the invoice.
Time when this invoice was last updated.
| Error status | Description |
|---|---|
| 400 | Bad Request. Possible error codes: |
| 401 | Unauthorized. Possible error codes: |
| 500 | Server Error. Possible error codes: |
$curl --request GET \> --url 'https://api-demo.airwallex.com/api/v1/billing/invoices' \> --header 'Authorization: Bearer {{ACCESS_TOKEN}}' \> --header 'Content-Type: application/json'
1{2 "has_more": false,3 "items": [4 {5 "created_at": "2022-01-01T10:15:30Z",6 "currency": "USD",7 "customer_id": "cus_ps8e0ZgQzd2QnCxVpzJrHD6KOVu",8 "id": "inv_hkpd49cskgblns6iimw",9 "last_payment_attempt_at": "2022-12-05T10:15:30+0000",10 "next_payment_attempt_at": "2022-12-05T10:15:30+0000",11 "paid_at": "2022-12-05T10:15:30+0000",12 "past_payment_attempt_count": 1,13 "payment_intent_id": "int_e65tkXCSzJrsMpTrzoFrjaau53",14 "period_end_at": "2022-01-05T10:15:30+0000",15 "period_start_at": "2022-01-01T10:15:30+0000",16 "remaining_payment_attempt_count": 1,17 "status": "SENT",18 "subscription_id": "sub_hkpdkcmxdgazzq53jbk",19 "total_amount": 100,20 "updated_at": "2022-01-01T10:15:30Z"21 }22 ]23}
Preview an upcoming invoice
POST /api/v1/billing/invoices/preview
Preview the upcoming invoice of an existing subscription (specified by the subscription_id), or the first invoice before creating a new subscription (when the subscription_id is not provided).
Unique identifier of the customer who subscribes to this subscription.
List of SubscriptionItems.
Unique identifier of the Price subscribed by the customer. The Price's recurring values must match the recurring values set out in this subscription.
The product quantity. Defaults to 1.
The billing cycle for recurring charges.
Specifies billing frequency. One of DAY, WEEK, MONTH or YEAR.
The number of period units between subscription billing cycles. For example, the billing cycle is bi-monthly if period=2 and period_unit=MONTH.
Unique identifier of the Subscription object.
The end time of the trial if applicable.
Time when this invoice will be created.
The currency of the invoice (in 3-letter ISO-4217 format).
Unique identifier of the customer who will be charged.
The InvoiceItems of this invoice.
The amount of the invoice item.
The currency of the invoice item (in 3-letter ISO-4217 format).
The end of the billing period associated with this invoice item. This value is exclusive.
The start of the billing period associated with this invoice item. This value is inclusive.
Price subscribed by the customer.
true if the price is available for new purchases, false otherwise.
Currency of the price (in 3-letter ISO-4217 format).
Price description.
The fixed amount to be charged. Applicable for flat pricing model only.
Unique identifier of the Price object.
A set of key-value pairs that you can attach to this object for storing additional information.
Price name.
Specify how to calculate the total billing amount when a quantity is provided.
flat: a fixed price.per_unit: a fixed price per unit quantity.volume: the unit price is taken based on which tier the total quantity falls in.tiered: the unit price changes as the quantity grows.
Unique identifier of the Product object this price is associated with.
The billing cycle for recurring charges. Exists when type=RECURRING.
The number of period units between subscription billing cycles. For example, the billing cycle is bi-monthly if period=2 and period_unit=MONTH.
Specifies billing frequency. One of DAY, WEEK, MONTH or YEAR.
Unique request identifier specified by the merchant in the last operation.
List of quantity-based pricing tiers for this price. Applicable for volume and tiered pricing models.
The per-unit amount to be charged for this tier when the pricing model is volume or tiered.
The fixed amount to be charged for this tier when the pricing model is volume or tiered.
The upper quantity limit of this tier. This tier is applicable when the quantity does not exceed the upper bound of this tier, and is greater than the upper bound of the tier below it(or 0 if this is the first tier). For the last tier, the upper bound must be left empty.
The type of the Price. Use ONE_OFF for one-off purchases and RECURRING for recurring purchases (subscriptions).
The amount to be charged per product unit. Applicable for per_unit pricing model only.
The product quantity.
Unique identifier of the subscription which generated this invoice, if any.
The total amount of the invoice.
| Error status | Description |
|---|---|
| 400 | Bad Request. Possible error codes: |
| 401 | Unauthorized. Possible error codes: |
| 404 | Not Found. No upcoming invoice for the subscription |
| 500 | Server Error. Possible error codes: |
$curl --request POST \> --url 'https://api-demo.airwallex.com/api/v1/billing/invoices/preview' \> --header 'Authorization: Bearer {{ACCESS_TOKEN}}' \> --header 'Content-Type: application/json' \> --data '{> "customer_id": "cus_ps8e0ZgQzd2QnCxVpzJrHD6KOVu",> "items": [> {> "price_id": "pri_hkpd7fedfgb004apkvs",> "quantity": 1> }> ],> "recurring": {> "period": 1,> "period_unit": "MONTH"> },> "subscription_id": "sub_hkpdkcmxdgazzq53jbk",> "trial_end_at": "2022-01-01T10:15:30+0000">}'
1{2 "created_at": "2022-01-01T10:15:30+0000",3 "currency": "USD",4 "customer_id": "cus_ps8e0ZgQzd2QnCxVpzJrHD6KOVu",5 "items": [6 {7 "amount": 10,8 "currency": "USD",9 "period_end_at": "2022-01-05T10:15:30+0000",10 "period_start_at": "2022-01-01T10:15:30+0000",11 "price": {12 "active": true,13 "currency": "USD",14 "description": "Standard option: $10 / month.",15 "flat_amount": "null",16 "id": "pri_hkpd7fedfgb004apkvs",17 "metadata": {18 "foo": "bar"19 },20 "name": "Standard option",21 "pricing_model": "tiered",22 "product_id": "prd_hkpd1x2gbgazzvcd42w",23 "recurring": {24 "period": 1,25 "period_unit": "MONTH"26 },27 "request_id": "ee939540-3203-4a2c-9172-89a566485dd9",28 "tiers": [29 {30 "amount": 10,31 "upper_bound": 2032 },33 {34 "amount": 2035 }36 ],37 "type": "RECURRING",38 "unit_amount": "null"39 },40 "quantity": 141 }42 ],43 "subscription_id": "sub_hkpdkcmxdgazzq53jbk",44 "total_amount": 1045}
Retrieve an InvoiceItem
GET /api/v1/billing/invoices/{id}/items/{item_id}
Retrieves the details of an InvoiceItem.
Unique identifier of the invoice object that this invoice item belongs to.
Unique identifier of the InvoiceItem object.
The amount of the invoice item.
The currency of the invoice item (in 3-letter ISO-4217 format).
Unique identifier of the InvoiceItem object.
Unique identifier of the Invoice object that this invoice item belongs to.
The end of the billing period associated with this invoice item. This value is exclusive.
The start of the billing period associated with this invoice item. This value is inclusive.
Price subscribed by the customer.
true if the price is available for new purchases, false otherwise.
Currency of the price (in 3-letter ISO-4217 format).
Price description.
The fixed amount to be charged. Applicable for flat pricing model only.
Unique identifier of the Price object.
A set of key-value pairs that you can attach to this object for storing additional information.
Price name.
Specify how to calculate the total billing amount when a quantity is provided.
flat: a fixed price.per_unit: a fixed price per unit quantity.volume: the unit price is taken based on which tier the total quantity falls in.tiered: the unit price changes as the quantity grows.
Unique identifier of the Product object this price is associated with.
The billing cycle for recurring charges. Exists when type=RECURRING.
The number of period units between subscription billing cycles. For example, the billing cycle is bi-monthly if period=2 and period_unit=MONTH.
Specifies billing frequency. One of DAY, WEEK, MONTH or YEAR.
Unique request identifier specified by the merchant in the last operation.
List of quantity-based pricing tiers for this price. Applicable for volume and tiered pricing models.
The per-unit amount to be charged for this tier when the pricing model is volume or tiered.
The fixed amount to be charged for this tier when the pricing model is volume or tiered.
The upper quantity limit of this tier. This tier is applicable when the quantity does not exceed the upper bound of this tier, and is greater than the upper bound of the tier below it(or 0 if this is the first tier). For the last tier, the upper bound must be left empty.
The type of the Price. Use ONE_OFF for one-off purchases and RECURRING for recurring purchases (subscriptions).
The amount to be charged per product unit. Applicable for per_unit pricing model only.
The product quantity.
| Error status | Description |
|---|---|
| 400 | Bad Request. Possible error codes: |
| 401 | Unauthorized. Possible error codes: |
| 404 | Not Found. Possible error codes: |
| 500 | Server Error. Possible error codes: |
$curl --request GET \> --url 'https://api-demo.airwallex.com/api/v1/billing/invoices/invoice_id/items/item_id' \> --header 'Authorization: Bearer {{ACCESS_TOKEN}}' \> --header 'Content-Type: application/json'
1{2 "amount": 2,3 "currency": "USD",4 "id": "iit_hkpd49cskgblnsnzgm1",5 "invoice_id": "inv_hkpd49cskgblns6iimw",6 "period_end_at": "2022-01-05T10:15:30+0000",7 "period_start_at": "2022-01-01T10:15:30+0000",8 "price": {9 "active": true,10 "currency": "USD",11 "description": "Standard option: $10 / month.",12 "flat_amount": "null",13 "id": "pri_hkpd7fedfgb004apkvs",14 "metadata": {15 "foo": "bar"16 },17 "name": "Standard option",18 "pricing_model": "tiered",19 "product_id": "prd_hkpd1x2gbgazzvcd42w",20 "recurring": {21 "period": 1,22 "period_unit": "MONTH"23 },24 "request_id": "ee939540-3203-4a2c-9172-89a566485dd9",25 "tiers": [26 {27 "amount": 10,28 "upper_bound": 2029 },30 {31 "amount": 2032 }33 ],34 "type": "RECURRING",35 "unit_amount": "null"36 },37 "quantity": 138}
Get list of InvoiceItems
GET /api/v1/billing/invoices/{id}/items
Retrieves a list of InvoiceItems based on the query parameters.
Unique identifier of the Invoice object that the invoice items belong to.
Page number starting from 0. Defaults to 0.
Number of invoiceItems per page. Defaults to 20.
A flag which identifies whether there are more results.
Paged results.
The amount of the invoice item.
The currency of the invoice item (in 3-letter ISO-4217 format).
Unique identifier of the InvoiceItem object.
Unique identifier of the Invoice object that this invoice item belongs to.
The end of the billing period associated with this invoice item. This value is exclusive.
The start of the billing period associated with this invoice item. This value is inclusive.
Price subscribed by the customer.
true if the price is available for new purchases, false otherwise.
Currency of the price (in 3-letter ISO-4217 format).
Price description.
The fixed amount to be charged. Applicable for flat pricing model only.
Unique identifier of the Price object.
A set of key-value pairs that you can attach to this object for storing additional information.
Price name.
Specify how to calculate the total billing amount when a quantity is provided.
flat: a fixed price.per_unit: a fixed price per unit quantity.volume: the unit price is taken based on which tier the total quantity falls in.tiered: the unit price changes as the quantity grows.
Unique identifier of the Product object this price is associated with.
The billing cycle for recurring charges. Exists when type=RECURRING.
The number of period units between subscription billing cycles. For example, the billing cycle is bi-monthly if period=2 and period_unit=MONTH.
Specifies billing frequency. One of DAY, WEEK, MONTH or YEAR.
Unique request identifier specified by the merchant in the last operation.
List of quantity-based pricing tiers for this price. Applicable for volume and tiered pricing models.
The per-unit amount to be charged for this tier when the pricing model is volume or tiered.
The fixed amount to be charged for this tier when the pricing model is volume or tiered.
The upper quantity limit of this tier. This tier is applicable when the quantity does not exceed the upper bound of this tier, and is greater than the upper bound of the tier below it(or 0 if this is the first tier). For the last tier, the upper bound must be left empty.
The type of the Price. Use ONE_OFF for one-off purchases and RECURRING for recurring purchases (subscriptions).
The amount to be charged per product unit. Applicable for per_unit pricing model only.
The product quantity.
| Error status | Description |
|---|---|
| 400 | Bad Request. Possible error codes: |
| 401 | Unauthorized. Possible error codes: |
| 404 | Not Found. Possible error codes: |
| 500 | Server Error. Possible error codes: |
$curl --request GET \> --url 'https://api-demo.airwallex.com/api/v1/billing/invoices/invoice_id/items' \> --header 'Authorization: Bearer {{ACCESS_TOKEN}}' \> --header 'Content-Type: application/json'
1{2 "has_more": false,3 "items": [4 {5 "amount": 2,6 "currency": "USD",7 "id": "iit_hkpd49cskgblnsnzgm1",8 "invoice_id": "inv_hkpd49cskgblns6iimw",9 "period_end_at": "2022-01-05T10:15:30+0000",10 "period_start_at": "2022-01-01T10:15:30+0000",11 "price": {12 "active": true,13 "currency": "USD",14 "description": "Standard option: $10 / month.",15 "flat_amount": "null",16 "id": "pri_hkpd7fedfgb004apkvs",17 "metadata": {18 "foo": "bar"19 },20 "name": "Standard option",21 "pricing_model": "tiered",22 "product_id": "prd_hkpd1x2gbgazzvcd42w",23 "recurring": {24 "period": 1,25 "period_unit": "MONTH"26 },27 "request_id": "ee939540-3203-4a2c-9172-89a566485dd9",28 "tiers": [29 {30 "amount": 10,31 "upper_bound": 2032 },33 {34 "amount": 2035 }36 ],37 "type": "RECURRING",38 "unit_amount": "null"39 },40 "quantity": 141 }42 ]43}