How to make recurring payement
The recurring payment are call subscription in Contodeo, a subscription is a composition of three objects :
- Payment plan which give the billing frequency
- Product whitch give the amount to bill
- Wallet which idenitfy the client
- CreditCard which identify the payment tool
The payment plan and product have to be create before the subscription registration. The wallet and card can be grab in an interractive
payment panel. Plan and product have to be create using the REST API for futher information read PLAN and PRODUCT specification sections.
There is to way to make a subscription depending of the customer :
- A subscription for a new custumer will be done using the interractive way describe in the subscription example
- A subscription for an already registered customer can be achieved directly using API
The interractive way can also be used for an already registered customer.
Making interractive registration need to do a subscription initiation on the specific endpoint /subscriptions/init
Several parameters are common with /transactions/init for panel customization.
Subscription validation
A interractive subscription need to be confirmed. The result of an interractive subscription is the same than a transaction, it returns a trx_id.
The confirmation of the transaction will validate the subscription and will return the subcription identifier (subscription_id):
{ "amount": 10,
"authorization_date": "2016-08-29T09:12:33.001Z",
"authorization_timeout_date": "2016-08-29T09:12:33.001Z",
"creation_date": "2016-08-29T09:12:33.001Z",
"creditcard_id": "CC-90e6-d701748f0851",
"external_id": "M_TRX_0000001",
"id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
"status": "CONFIRM",
"subscription_id": "d290ac2ee-6c54-4b01-90e6-d701748f0851",
"type": "PAYMENT",
"wallet_id": "WA-d701748f0851"
}
A subscription done by rest API call don't need a validation. The subscription is directly in an active status if the initial payment as been done.
Subscription details
You can retrieve subscription information using the rest API using the subscription_id GET /subscriptions/d290ac2ee-6c54-4b01-90e6-d701748f0851
.
The API will be used to managed the subscription to consult or to cancel it. Subscription can be listed using /subscriptions
endpoint. You will be be able to find subscriptions using wallet_id , product_id, plan_id, product_id and status.
Subscription charging
Automatic payment are called charge. Charges are created seven day before the billing anniversary. All charges are linked to a subscription. There can be listed, consulted, paused, relaunched and cancelled using the REST API. You can also edit the charge amount before it billing. All operations are done on /charges
endpoint.
The payment processing of a charge will lead to make one or many transaction(s), which will be references in the charges. Many transactions are done only if a previous transaction failed. You can automatically relaunch a charge in failed status using the REST API. By default 3 attempt are done before switching the charge in failed status.
For futher details read the specifcications documentations charge chapter.