Save Card for Billing
API to save the card details securely for billing
Overview
If your business model requires the amount to be dynamic and does not have a fixed billing cycle, you can use the “save card” feature of the recurring billing.
This API integration includes 4 Steps
Create a Recurring Billing
Create a recurring billing with “save card” configuration
Present the Checkout UI
Present the checkout user interface to the customer for subscription confirmation
Charge the saved card
Call the charge card API to charge the saved card
Step 1 - Save card for billing
NOTE: Similar API as creating a recurring billing with save_card set to true, plan_id should be null and start_date is not required.
HTTP Request
Query Parameters
Mandatory fields are name
, customer_email
, and amount
. Remember to include the header Content-Type: application/x-www-form-urlencoded
.
Parameter | Description | Example |
---|---|---|
name | Plan name | Spotify Premium |
description | description of the plan | Spotify Membership |
save_card | Save the card to charge the customer later | true |
customer_email | Customer email | paul@hitpayapp.com |
customer_name | Customer name | Paul |
amount | Amount related to the recurring billing | 9.90 |
currency | Currency related to the recurring billing | SGD |
payment_methods[] | Choice of payment methods you want to offer the customer. Default value is card | giro, card |
redirect_url | URL where hitpay redirects the user after the users enters the card details and the subscription is active. Query arguments reference (subscription id) and status are sent along | https://spotify.com/subscription-completed |
reference | Arbitrary reference number that you can map to your internal reference number. This value cannot be edited by the customer | XXXX123 |
webhook | Optional URL value to which hitpay will send a POST request when there is a new charge or if there is an error charging the card | https://webhoo.site/test |
send_email | Hitpay to send email receipts to the customer. Default value is false | true |
Response
Step 2 - Redirect customer to recurring billing page (One time set up)
Redirect the customer to the “url” value.
Once the customer enters the payment information, the card will be saved and you can charge the card anytime using the charge the saved card API.
Step 3 - Charge the saved card
Once the card is saved you can charged the card anytime using the following endpoint
HTTP Request
recurring-billing-id is the id value from step 1 response.
Query Parameters
Parameter | Description | Example |
---|---|---|
currency | Currency related to the recurring billing | SGD |
amount | Amount related to the recurring billing | 9.90 |
Response
Congrats! You have now successfully completed the recurring billing integration by saving the card.
FAQs
Was this page helpful?