Creating a recurring payment works similar to creating a deposit session, but with the /api/session.create_recurring_payment endpoint and requested_start_date with country_id properties as required parameter.
API Reference: api/session.create_recurring_payment
Requested Start Date must be at least one day in the future and for some banks it’s not allowed to start on a week-end or bank holiday which will cause the start day to move to the next bank day.
The expected date for the payment will be returned in the ETA parameter when getting the transaction status. transaction.get
All recurring transactions created will be unique and have their own transaction id hence for recurring transactions it’s good practice to add your customer id to the callback url. for example: https://example.com/brite-recurring-callback/<customer_id>
This would enable you to see directly for which customer the transaction applies to. for more details about the transaction the api transaction.get can be used.
REQUEST:
POST /api/session.create_recurring_payment
{
"amount": 1,
"country_id": "se",
"currency_id": "sek",
"requested_start_date": "2022-05-25",
"callbacks": [
{"url": "https://example.com/brite-session-callback", "session_state": 2},
{"url": "https://example.com/brite-session-callback", "session_state": 10},
{"url": "https://example.com/brite-session-callback", "session_state": 11},
{"url": "https://example.com/brite-session-callback", "session_state": 12},
{"url": "https://example.com/brite-callback", "transaction_state": 1},
{"url": "https://example.com/brite-callback", "transaction_state": 2},
{"url": "https://example.com/brite-callback", "transaction_state": 3},
{"url": "https://example.com/brite-callback", "transaction_state": 5}
]
}
Recurring Callbacks
Callbacks are sent as normal also for recurring transactions so when a transaction is created there are callbacks if it’s failed or successful, i.e. transaction_state callbacks are used.
Brite backend supports the following callbacks for transaction states in Recurring Payment:
STATE_PENDING= 1
STATE_ABORTED= 2
STATE_FAILED= 3
STATE_CREDIT= 5
Pending Transactions
When a recurring transaction is created it will be in status pending until it continues into credit and settled status. If funds are missing or the subscription has been canceled by the user on their bank account the transaction will remain in pending status and needs to be taken care of.
To get information about transactions being created, subscribe to the callback function for pending transaction status and use and transaction.get for getting the details.
"callbacks": [ {"url": "https://example.com/brite-callback", "transaction_state": 1} ]
If a transaction does not move into a settled status identify the transaction and act accordingly, for example notify end user that funds are missing or cancel the subscription.