Skip to main content

Subscription API Reference

This page documents the available API endpoints for recurring payments. Make sure you have read the Recurring Overview before using these APIs.


1. Create Customer

POST /customer/v1/create

Creates a new customer profile.

Request Parameters

ParameterTypeRequiredDescription
nameStringNoCustomer name
phoneStringNoContact number
emailStringNoEmail address
billing_addressString (JSON)NoJSON string of billing address

Response

Returns the customer_id.


2. Update Customer

POST /customer/v1/update

Updates an existing customer.

Request Parameters

ParameterTypeRequiredDescription
customer_idStringYesQFPay system customer ID
nameStringNoCustomer name
phoneStringNoContact number
emailStringNoEmail address
billing_addressJSONNoJSON object of billing address

Response

Returns number of affected rows.


3. Query Customers

POST /customer/v1/query

Search for customers.

Request Parameters

ParameterTypeRequiredDescription
customer_idStringNoCustomer ID
nameStringNoCustomer name
phoneStringNoContact number
emailStringNoEmail address
pageIntNoDefault = 1
page_sizeIntNoDefault = 10, max = 100

Response

List of matching customers.


4. Delete Customer

POST /customer/v1/delete

Deletes a customer. Irreversible.

Request Parameters

ParameterTypeRequiredDescription
customer_idStringYesCustomer ID to delete

Response

Returns deleted customer ID and row count.


5. Create Product

POST /product/v1/create

Creates a recurring billing product.

Request Parameters

ParameterTypeRequiredDescription
nameStringYesProduct name
typeStringYesrecurring
descriptionStringNoProduct description
txamtIntYesAmount in cents (100 = $1)
txcurrcdStringYesCurrency (e.g. HKD)
intervalStringYesBilling cycle: monthly, yearly, etc.
interval_countIntYesInterval count (e.g. 1 month = 1)
usage_typeStringYeslicensed
note

In sandbox environment, minutes and hours can be used in the interval field for testing

Response

Returns generated product_id.


6. Update Product

POST /product/v1/update

Updates product metadata.

Request Parameters

ParameterTypeRequiredDescription
product_idStringYesProduct ID to update
nameStringNoNew name
descriptionStringNoNew description

Response

Returns number of affected rows.


7. Query Products

POST /product/v1/query

Search for products.

Request Parameters

ParameterTypeRequiredDescription
product_idStringNoProduct ID
nameStringNoProduct name
descriptionStringNoDescription
txcurrcdStringNoCurrency
intervalStringNomonthly / yearly
pageIntNoDefault = 1
page_sizeIntNoDefault = 10, max = 100

Response

List of matching products.


8. Delete Product

POST /product/v1/delete

Deletes a product (must not be linked to subscriptions).

Request Parameters

ParameterTypeRequiredDescription
product_idStringYesProduct ID to delete

Response

Returns deleted product ID and row count.


9. Create Subscription

tip

You must create customer_id, product_id, and token_id before calling the subscription API.

POST /subscription/v1/create

Creates a recurring subscription plan.

Request Parameters

ParameterTypeRequiredDescription
customer_idStringYesLinked customer ID
token_idStringYesLinked payment token
productsListYesProduct ID and quantity
total_billing_cyclesIntNoTotal number of billing periods (null = indefinite)
start_timeStringNoISO timestamp to start subscription

Parameters inside products

AttributeTypeMandatoryDescription
product_idStringYesUnique product identifier in QFPay system
quantityIntNoDefault value=1

Example Request

{
"products": [
{
"product_id": "prod_54c3772d******9a54b236e09ec74f",
"quantity": 1
}
],
"customer_id": "cust_aaf6aae94******982c54c9cae5ba32",
"token_id": "tk_a99892fd*********d3417d168a18bb",
"total_billing_cycles": 2,
"start_time": "2020-05-14 12:32:56"
}

Response Parameters (in data field)

Returns subscription_id and initial state.

AttributeTypeDescription
subscription_idStringUnique subscription identifier in QFPay system (e.g. sub_xxxxxxx)
stateStringInitial state of the subscription. Possible values: ACTIVE, INCOMPLETE, COMPLETED

10.Update Subscription

Update an existing subscription.

Endpoint: /subscription/v1/update
Method: POST

Request Parameters

AttributeTypeMandatoryDescription
subscription_idStringYesUnique subscription identifier in QFPay system
total_billing_cyclesIntNoTotal billing cycles. If null, the subscription will run indefinitely
start_timeStringNoThe time at which the subscription starts. Determines the first billing time
token_idStringNoUnique payment token identifier in QFPay system
productsObjectNoList of product objects. Each object includes product_id and optional quantity

Response Parameters (in data field)

AttributeTypeDescription
subscription_idStringUnique subscription ID
rowAffectedIntNumber of records updated

11. Query Subscription

Query subscription objects.

Endpoint: /subscription/v1/query
Method: POST

Request Parameters

AttributeTypeMandatoryDescription
pageIntNoPage number. Default = 1
page_sizeIntNoPage size. Default = 10. Max = 100
subscription_idStringNoUnique subscription ID in QFPay system
customer_idStringNoUnique customer ID in QFPay system
stateStringNoSubscription state (e.g. INCOMPLETE, ACTIVE, etc.)

Response Parameters (in data field)

An array of subscription objects containing the following attributes:

AttributeTypeDescription
subscription_idStringUnique subscription ID
customer_idStringUnique customer ID
token_idStringUnique payment token ID
productsObjectList of product items (product_id + optional quantity)
total_billing_cyclesIntTotal billing cycles (null if unlimited)
stateStringSubscription state
next_billing_timeStringTime of the next billing event
last_billing_timeStringTime of the previous billing event
completed_billing_iterationIntNumber of completed billing cycles
start_timeStringSubscription start time

Sample Response

{
"resperr": "success",
"respcd": "0000",
"respmsg": "success",
"data": [
{
"total_billing_cycles": 3,
"last_billing_time": "2024-11-21T11:12:06Z",
"is_available": 1,
"userid": 2510351,
"last_billing_status": "SUCCESS",
"state": "ACTIVE",
"products": [
{ "product_id": "prod_8efecd0bd******b9aa1ec5ec01", "quantity": 1 }
],
"retry_attempts": 0,
"completed_iteration": 1,
"token_id": "tk_9ac510017*******69b614e8f7ee",
"subscription_id": "sub_e120378de*******da066f690da75",
"customer_id": "cust_5ba1539f*******c9bda11d12c854e36",
"next_billing_time": "2024-11-21T11:13:06Z"
}
]
}

12. Cancel Subscription

Cancel a subscription immediately.

Endpoint: /subscription/v1/cancel
Method: POST

Request Parameters

AttributeTypeMandatoryDescription
subscription_idStringYesUnique subscription ID in QFPay system

13. Query Subscription Orders

Query all billing orders under a specific subscription.

Endpoint: /subscription/billing_order/v1/list
Method: POST

Request Parameters

AttributeTypeMandatoryDescription
subscription_idStringYesUnique subscription ID
pageIntNoPage number. Default = 1
page_sizeIntNoPage size. Default = 10, Max = 100

Response Parameters (in data field)

Array of subscription billing orders:

AttributeTypeDescription
subscription_order_idStringUnique order ID, format: sub_ord_{subscription_id}_{0001} for the N-th billing of subscription
subscription_idStringSubscription ID this billing belongs to
trigger_byStringTrigger type: auto (QF system) or manual
sequence_noIntIteration number of this billing in the subscription

14. Manual Charge a Subscription

Trigger a manual charge on a failed subscription order.

Endpoint: /subscription/v1/charge
Method: POST

Request Parameters

AttributeTypeMandatoryDescription
subscription_idStringYesUnique subscription ID
subscription_order_idStringNoSpecific order ID to retry (optional, for fine control)
note

This API is only valid for subscriptions with a failed billing and a current state of UNPAID, INCOMPLETE, or PAST_DUE.

  • If the manual charge is before the next billing time, the subscription remains ACTIVE.
  • If the charge is after the next billing time, the subscription will be cancelled.
  • If the manual charge fails, the subscription state remains unchanged.