Recurring Payments
Enable recurring payments with Qorepay using tokenization to store card information securely and charge it without needing user interaction each time. Here’s how to set it up:
1. Create Initial Purchase
Store Purchase ID: Create an initial purchase and store the id
of this transaction. This ID will serve as the card token and is marked with an is_recurring_token field set to true.
2. Enable Tokenization
Direct Post URL: Append remember_card=on to the Direct Post URL to initiate tokenization during the client checkout process. This flags the purchase as eligible for recurring charges.
Customer Opt-In: Alternatively, include an option on the checkout page for customers to select "Remember card". This should also pass remember_card=on in the body of the direct_post_url.
3. Charge the Tokenized Card
Create a Second Purchase: When you're ready to charge the card again, create a new Purchase. Execute Charge Command: Use the following API call to charge the card:
POST https://gate.qorepay.com/api/v1/purchases/[new_purchase_id]/charge/
Include the following JSON body in your request:
1{
2 brand_id: "brand_id",
3 recurring_token: "first_purchase_id"
4}
Successful Charge: A successful response (200 OK) indicates that the new purchase is paid. The recurring_token for the tokenized card is stored in the recurring_token field of the new Purchase.
4. Manage Tokens
Delete Recurring Token: If you need to discontinue recurring charges and remove the stored token, issue the following request:
POST https://gate.qorepay.com/api/v1/purchases/{initial_purchase_id}/delete_recurring_token/
This resets the is_recurring_token
field to false.