Recurring Payment
Recurring Payment Process Documentation
Overview
The recurringPayment function in the provided script is designed to automate the process of handling recurring payments. It ensures that payments due on the current date are processed and managed accordingly.
Key Functions
-
processNon3DSPayment: Handles the actual payment processing using a non-3D Secure endpoint. It accepts a token, billing details, and the amount, sending these details to the specified endpoint and awaiting a response.
-
recurringPayment: Orchestrates the recurring payment process. It identifies payments due on the current date, processes each payment, and handles post-payment actions.
Process Flow
- Identify Due Payments: The function first finds all payments that are due on the current day and are marked as recurring and pending.
- User Verification: For each due payment, it verifies the existence of the user and their FAC token. Absence of either skips the payment.
- Billing Details: Retrieves the billing details from the
BillingDetailsModel. If specific billing details are not found, it defaults to the user’s default billing details. - Payment Processing: Calls
processNon3DSPaymentfor each due payment. On successful payment, it updates the payment status and schedules the next recurring payment if needed. - Error Handling: In case of payment failure, it logs the error. Ideally, it should also trigger an email notification to the user regarding the payment failure.
Importance
This automated process is crucial for managing recurring payments efficiently, ensuring timely collection and processing while reducing manual oversight. It enhances the reliability of the payment system, particularly for subscription-based services.