Skip to main content

Recurring Payment

Create and manage subscriptions and recurring payment

How subscription works

API Environment

Environment NameURL
Sandboxhttps://openapi-int.qfapi.com

API Resources

For build and manage subscriptions, the following API resources are required:

API Resources
Customer
Payment Token
Product
Subscription

Create subscription steps

enter image description here

Subscription state

state diagram All subscription state will be pushed to merchant's backend service once triggered

Common API response parameter

AttributeTypeDescription
respcdStringReturn code, 0000 = API call succeeded
resperrStringresult description
respmsgStringinformation description
pageIntpage no.,present in inquiry API
page_sizeIntpage size,presented in inquiry API
dataObjectresult, JSON object or list of JSON object

Customer

Customer is an API resource for merchant to store customer's information. This object can be used in PaymentToken, Subscription APIs

Create customer object

Endpoint : /customer/v1/create

Method : POST

Request parameters

AttributeTypeMandatoryDescription
nameStringNocustomer name
phoneStringNocustomer contact no.
emailStringNocustomer email address
billing_addressStringNocustomer billing address, stringify JSON object

Response parameters in data field

AttributeTypeDescription
customer_idStringunqiue customer ID in QF system
nameStringcustomer name
phoneStringcustomer contact no.
emailStringcustomer email address
billing_addressJSONcustomer billing address

Update customer object

Endpoint : /customer/v1/update

Method : POST

Request parameters:

AttributeTypeMandatoryDescription
customer_idStringYesunqiue customer ID in QF system
nameStringNocustomer name
phoneStringNocustomer contact no.
emailStringNocustomer email address
billing_addressJSONNocustomer billing address

Response parameters in data field:

AttributeTypeDescription
customer_idStringunqiue customer ID in QF system
nameStringcustomer name
phoneStringcustomer contact no.
emailStringcustomer email address
billing_addressJSONcustomer billing address

Inquiry customer object

Endpoint : /customer/v1/query

Method : POST

Request parameters

AttributeTypeMandatoryDescription
customer_idStringNounqiue customer Id in QF system
nameStringNocustomer name
phoneStringNocustomer contact no.
emailStringNocustomer email address
pageIntNodefault value = 1
page_sizeIntNodefault value = 10, the max value is 100

Response parameters in data field

AttributeTypeDescription
customer_idStringunqiue customer ID in QF system
nameStringcustomer name
phoneStringcustomer contact no.
emailStringcustomer email address

Delete customer object

permanently delete customer object, cannot be undo. Any subscription plan associated with the deleted customer will be cancelled.

Endpoint : /customer/v1/delete

Method : POST

Request parameters

AttributeTypeMandatoryDescription
customer_idStringYesunique customer identifier in QF system

Product

Products are the model for goods or services that merchants will provide to the customers. It defines transaction amount, transaction currency and billing cycles(if applicable). This object will be used in subscription API.

Create product object

create a new product

Endpoint : /product/v1/create

Method : POST

Request parameters

AttributeTypeMandatoryDescription
nameStringYesproduct name that displays to the customer
typeStringNodefault value=onetime, possible values: onetime, recurring
descriptionStringNoproduct descritpion
txamtIntYestransaction amount, e.g. $1=100
txcurrcdStringYestransaction currency, e.g. HKD
intervalStringNopossible values: monthly, yearly, mandatory for recurring product
interval_countIntNointerval between 2 charges, maximum 1 year allowed, mandatory for recurring product
usage_typeStringNodefault value=licensed, possible values: licensed

Response parameters in data field

AttributeTypeDescription
product_idStringunique identifer generated in QF system
nameStringproduct name that displays to the customer
typeStringdefault value=onetime, possible values: onetime, recurring
descriptionStringproduct descritpion
txamtInttransaction amount, e.g. $1=100
txcurrcdStringtransaction currency, e.g. HKD
intervalStringpossible values: monthly, yearly
interval_countIntinterval between 2 charges
usage_typeStringdefault value=licensed, possible values: licensed

Update product object

update current product information

Endpoint : /product/v1/update

Method : POST

Request parameters

AttributeTypeMandatoryDescription
product_idStringYesunique identifier generated in QF system
nameStringNoproduct name that displays to the customer
descriptionStringNoproduct descritpion

Response parameters in data field

AttributeTypeDescription
product_idStringunique product identifer generated in QF system
nameStringproduct name that displays to the customer
typeStringdefault value=onetime, possible values: onetime, recurring
descriptionStringproduct descritpion
txamtInttransaction amount, e.g. $1=100
txcurrcdStringtransaction currency, e.g. HKD
intervalStringpossible values: monthly, yearly
interval_countIntinterval between 2 charges
usage_typeStringdefault value=licensed, possible values: licensed

Inquiry product object

Endpoint : /product/v1/create

Method : POST

Request parameters

AttributeTypeMandatoryDescription
product_idStringNounique product identifier generated in QF system
nameStringNoproduct name that displays to the customer
descriptionStringNoproduct descritpion
txcurrcdStringNotransaction currency
intervalStringNopossible values: monthly,yearly
pageIntNopage no., default value=1
page_sizeIntNopage size, default value=10,max value=100

Response parameters in data field

AttributeTypeDescription
product_idStringunique identifer generated in QF system
nameStringproduct name that displays to the customer
typeStringpossible values: onetime, recurring
descriptionStringproduct descritpion
txamtInttransaction amount, e.g. $1=100
txcurrcdStringtransaction currency, e.g. HKD
intervalStringpossible values: monthly, yearly
interval_countIntinterval between 2 charges
usage_typeStringpossible values: licensed

Delete product object

note

only can delete product that is not assoicated with any subscription object

Endpoint : /product/v1/delete

Method : POST

Request parameters

AttributeTypeMandatoryDescription
product_idStringNounique product identifier generated in QF system

Subscription

QFPay automatically charges the customers on every billing cycle based on the product with the provided Payment Token until the subscription is finished or cancelled. Before create subscription, payment token, customer and product must be created.

Create subscription object

Endpoint : /subscription/v1/create

Method : POST

Request parameters

AttributeTypeMandatoryDescription
customer_idStringYesunique customer identifier in QF system
token_idStringYesunique payment token identifier in QF system
productsObjectYeslist of unique product identifier in QF system and quantity
total_billing_cyclesIntNothe total billing cycles of the subscirption, infinity if null value
start_timeStringNothe time subscription will start to work, the first payment will be

parameters in products:

AttributeTypeMandatoryDescription
product_idStringYesunique production identifier in QF system
quantityIntNodefault value=1

Response parameters in data field

AttributeTypeDescription
customer_idStringunique customer identifier in QF system
token_idStringunique payment token identifier in QF system
productsObjectlist of unique product identifier in QF system and quantity
total_billing_cyclesIntthe total billing cycles of the subscirption, infinity cycles if null value
start_timeStringthe time subscription will start to work

Update subscription object

update current subscription

Endpoint : /subscription/v1/update

Method : POST

Request parameters

AttributeTypeMandatoryDescription
subscription_idStringYesunique subscription identifier in QF system
total_billing_cyclesIntNothe total billing cycles of the subscirption, infinity if null value
start_timeStringNothe time that subscription will start to work, it will be the first subscription payment time
token_idStringNounique payment token identifier in QF system
productsObjectNolist of unique product identifier in QF system and quantity

Response parameters in data field

AttributeTypeDescription
subscription_idStringunique subscription identifier in QF system
customer_idStringunique customer identifier in QF system
token_idStringunique payment token identifier in QF system
productsObjectlist of unique product identifier in QF system and quantity
total_billing_cyclesIntthe total billing cycles of the subscirption, infinity cycles if null value
start_timeStringthe time that subscription will start to work, it will be the first subscription payment time
stateStringsubscription state

Inquiry subscription object

Endpoint : /subscription/v1/query

Method : POST

Request parameters

AttributeTypeMandatoryDescription
pageIntNopage no.,default value=1
page_sizeIntNopage size, default value=10, max value=100
subscritpion_idStringNounique subscription identifier in QF system
customer_idStringNounique customer identifier in QF system
token_idStringNounique payment otken identifier in QF system
stateStringNosubscription state, e.g. incompelete, active,...

Response parameters in data field

AttributeTypeDescription
subscription_idStringunique subscription identifier in QF system
customer_idStringunique customer identifier in QF system
token_idStringunique payment token identifier in QF system
productsObjectlist of unique product identifier in QF system and quantity
total_billing_cyclesIntthe total billing cycles of the subscirption, infinity cycles if null value
stateStringsubscription state
next_billing_timeStringnext fund deduct time
last_billing_timeStringprevious fund deduct time
completed_billing_iterationInthow many billing cycles completed
start_timeStringthe time that subscription will start to work, it will be the first subscription payment time

Cancel subscription object

cancel customer's subscription immediately

Endpoint : /subscription/v1/cancel

Method : POST

Request parameters

AttributeTypeMandatoryDescription
subscription_idStringYesunique ID of subscription object