Schedule Payment
Introduction
A scheduled payment is a payment that happens automatically at a fixed time and for a fixed amount based on a predefined agreement. It starts with a customer initiated transaction (CITR – Customer Initiated Transaction for Registration), where the customer subscribes their payment method and gives consent. After that, the next payments are merchant initiated transactions (MITR – Merchant Initiated Transaction Recurring), where the merchant automatically charges the customer at the agreed time and amount (for example, a monthly subscription). In this case, both the timing and the amount are fixed, and no action is needed from the customer after the initial setup.
Understanding Token Flags
To classify the type of the transaction, PayWay uses the token_flag parameter to define the Transaction Context.
| Flag | Full name | Amount | Use case | API Endpoint |
|---|---|---|---|---|
CITR_FIX | CIT Recurring | Fixed | Registration: The customer starts a subscription and authorizes the fixed amount/frequency (e.g., signing up for a $20 gym plan). | Subscription |
MITR_FIX | MIT Recurring | Fixed | Subsequent Billing: The merchant's server automatically charges the agreed fixed amount at the scheduled interval (e.g., the monthly $20 gym fee). | Payment |
How it works
Subscribe using ABA Account
Subsequent Transaction
- Batch Identification: Every day, the Merchant Server runs a scheduled job to identify all active subscriptions due for billing.
- Execution: For every identified record, the server calls the PayWay Purchase API using the stored payment token.
- Confirmation: PayWay processes the payment and sends an asynchronous Payment Notification (Webhook) to the merchant's server.
- Verification: In the event of a missing callback, the Merchant Server performs a Transaction Status Query to ensure the database stays synchronized with the actual payment state.
Set up your UI
Before integrating the API, build a section in your app where customers can:
- Subscribe – allow customers to link their payment method and give consent for future scheduled or recurring payments.
- View subscription – allow customers to see all active subscriptions, including details like merchant name, amount, and billing frequency.
- Unsubscribe – allow customers to cancel an existing subscription so no future payments will be charged.
You must follow PayWay Credential on file guidelines to ensure proper customer card/account storage.
Integration Steps
Initiate the subscription by calling the subscription API after the customer selects a plan (with predefined amount and frequency). This step is a CITR (Customer Initiated Transaction for Registration) where the customer provides consent and links their payment method.
Sample Request
PayWay will respond with a HTML response that contains the checkout interface, which you must render on your website/platform for the customer to complete the payment.
Once the customer completes the payment, PayWay will send two callback notification to merchant.
Your callback_url endpoint must:
- Accept the HTTP POST method
- Accept Content-Type: application/json
We highly recommend securing this URL to ensure that only PayWay has access to it.
1) Payment completion callback notification
Upon completion of the customer’s payment, PayWay transmits the transaction details and critical metadata to the callback_url specified in your request parameters. If no parameter is provided, PayWay defaults to the callback_url configured within your API Settings.
If you provide a custom callback_url in your API request, ensure the domain is whitelisted within your merchant profile to allow PayWay to communicate securely with your server.
Sample Pushback Data
Transaction ID sent during the initial payment process.
Transaction approval code.
Payment status
Extra information sent to the payment gateway during the payment initiation request.
Verify Callback Signature
For security purposes, PayWay includes a hash signature in the request header.
You should verify this signature to confirm that the callback was sent by PayWay and that the data has not been modified.
Below is an example in PHP demonstrating how to:
- Read the callback data
- Generate the signature
- Compare it with the signature received in the header
PHP Example
2) Token callback
PayWay will use callback_url configured within your Outlet Profile > Services > Credential on File to delivery the token information.
Sample Callback Data
Your original requst ID.
Your consumer identification number.
PWT (PayWay Token) is a unique token automatically generated by the PayWay system and is used to complete the purchase..
This field displays either the card number or the ABA account number, depending on the payer's selected payment method. For security reasons, the number is masked and only the last 4 digits are shown.
Visa- Visa cardMC- MastercardCUP- UnionPay cardJCB- JCB cardABA ACCOUNT- ABA Account
0- Token has been removed.1- Token is active.2- Token has been frozen.
Expiry date of the token.
Possible values: CITR_FIX.
Possible value are 1W - Weekly, 1M - Monthly, 2M - Every 2 months.
The subscribed_amount is the fixed monetary value authorized by the customer during the registration phase (CITR_FIX)
For scheduled payments, the amount_limit_per_tran is automatically locked to the subscribed_amount. Users are restricted from adjusting this limit in their ABA Mobile app, guaranteeing that the authorized payment can always be processed.
Payment amount limit transaction currency. Possible value KHR or USD.
Once the subscription is done, all future payments are automatically triggered by the merchant as MITR (Merchant Initiated Transaction Recurring). These transactions follow the fixed schedule and fixed amount defined during the subscription setup, without requiring further customer action.
Please use the Payment API to trigger each subsequent transaction.