Skip to main content

Overview

The Save Payment Method API allows you to securely store a customer’s payment credentials and charge them later—on your schedule, for any amount. Unlike fixed recurring billing, this approach gives you full control over when and how much to charge.
Key Concept: You’re creating a “billing session” where the customer authorizes you to save their payment method. Once saved, you can charge it anytime via API without the customer needing to re-enter their details.

Supported Payment Methods

Payment MethodSupported CountriesSupported CurrenciesMethod Code
Cards (Visa, Mastercard, Amex)Singapore, MalaysiaAllcard
ShopeePaySingapore, MalaysiaSGD, MYRshopee_pay
GrabPaySingapore, MalaysiaSGD, MYRgrabpay_direct
When creating the billing session, you can offer multiple payment methods (e.g., cards + ShopeePay + GrabPay) and let the customer choose their preferred option.

When to Use This

This API is ideal when you need flexibility in your billing:

Variable Billing Amounts

Charge different amounts each time based on usage, consumption, or services rendered.

On-Demand Charges

Bill customers when needed rather than on a fixed schedule (e.g., marketplace payouts, top-ups).

Subscription with Flexibility

Run subscriptions where the amount may change (upgrades, add-ons, prorated charges).

Delayed First Charge

Save the payment method now but only charge when the customer’s trial ends or service begins.

How It Works

The integration follows 3 steps:
1

Create a Billing Session

Call the /v1/recurring-billing API with save_payment_method=true. You’ll receive a checkout URL to redirect the customer.
2

Customer Attaches Payment Method

Redirect the customer to the checkout URL where they select their preferred payment method (card, ShopeePay, GrabPay, etc.) and authorize it.
3

Charge the Saved Method

Once attached, use the charge API to bill the customer any amount, anytime. No customer interaction required.

Step 1 – Create a Billing Session

Create a billing session by calling the /v1/recurring-billing API with save_payment_method=true. This returns a checkout URL where your customer can attach their payment method.

Endpoint

POST https://api.sandbox.hit-pay.com/v1/recurring-billing

Request Parameters

Required fields: name, customer_email, amount, and save_payment_method=true
ParameterDescriptionExample
nameName for this billing sessionSpotify Premium
customer_emailCustomer’s email address[email protected]
amountAmount to display (minimum 1.00)9.90
currencyCurrency codeSGD
save_payment_methodMust be true to save the payment methodtrue
payment_methods[]Payment methods to offer. Include multiple for customer choicecard, shopee_pay, grabpay_direct
redirect_urlURL to redirect customer after they attach their payment methodhttps://example.com/success
referenceYour internal reference ID to identify this customer/sessioncust_123
customer_nameCustomer’s name (optional)Paul
descriptionDescription shown to customer (optional)Spotify Membership
send_emailSend email receipt to customer. Default: falsetrue

Example Request

curl --location --request POST 'https://api.sandbox.hit-pay.com/v1/recurring-billing' \
--header 'X-BUSINESS-API-KEY: your_api_key' \
--header 'X-Requested-With: XMLHttpRequest' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'name=Spotify Premium' \
--data-urlencode 'description=Spotify Membership' \
--data-urlencode 'save_payment_method=true' \
--data-urlencode '[email protected]' \
--data-urlencode 'customer_name=Paul' \
--data-urlencode 'amount=9.90' \
--data-urlencode 'currency=SGD' \
--data-urlencode 'payment_methods[]=giro' \
--data-urlencode 'payment_methods[]=card' \
--data-urlencode 'payment_methods[]=shopee_pay' \
--data-urlencode 'payment_methods[]=grabpay_direct' \
--data-urlencode 'redirect_url=https://example.com/success' \
--data-urlencode 'reference=cust_123'

Response

{
    "id": "9741164c-06a1-4dd7-a649-72cca8f9603a",
    "business_recurring_plans_id": "",
    "customer_name": "Paul",
    "customer_email": "[email protected]",
    "name": "Spotify Premium",
    "description": "Spotify Membership",
    "reference": "cust_id_123",
    "cycle": "save_card",
    "cycle_repeat": null,
    "cycle_frequency": null,
    "currency": "sgd",
    "amount": 9.9,
    "times_to_be_charged": 3,
    "times_charged": 0,
    "status": "scheduled",
    "send_email": false,
    "save_card": 1,
    "redirect_url": "https://github.com/",
    "payment_methods": ["giro", "card", "grabpay_direct", "shopee_pay"],
    "created_at": "2022-09-13T16:33:47",
    "updated_at": "2022-09-13T16:33:47",
    "expires_at": null,
    "url": "https://securecheckout.staging.hit-pay.com/9673bdea-058c-44b5-a957-845a7c487bc2/recurring-plan/9741164c-06a1-4dd7-a649-72cca8f9603a",
    "webhook": "https://webhoo.site/test"
}
Important: Save the id from the response. You’ll need this to charge the customer later.

Step 2 – Redirect Customer to Checkout

Redirect your customer to the url returned in Step 1. This is a one-time setup where the customer selects and authorizes their preferred payment method. Checkout UI for saving payment method Once the customer completes this flow:
  • They are redirected to your redirect_url
  • Their payment method is now saved and ready to be charged

Step 3 – Charge the Saved Payment Method

After the customer has attached their payment method, you can charge them anytime by calling the charge API.

Endpoint

POST https://api.sandbox.hit-pay.com/v1/charge/recurring-billing/{id}
Replace {id} with the billing session ID from Step 1.

Request Parameters

Required fields: amount and currencyInclude header Content-Type: application/x-www-form-urlencoded
ParameterDescriptionExample
amountAmount to charge9.90
currencyCurrency codeSGD

Example Request

curl --location --request POST 'https://api.sandbox.hit-pay.com/v1/charge/recurring-billing/9741164c-06a1-4dd7-a649-72cca8f9603a' \
--header 'X-BUSINESS-API-KEY: your_api_key' \
--header 'X-Requested-With: XMLHttpRequest' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'amount=9.90' \
--data-urlencode 'currency=SGD'

Response

{
    "payment_id": "9746f906-bdbb-4064-8372-642cf5877e0c",
    "recurring_billing_id": "9746f8c2-2b7c-4c78-8832-012f203ae687",
    "amount": 9.9,
    "currency": "sgd",
    "status": "succeeded"
}
You can charge different amounts each time. The amount in Step 1 is just for display during the authorization flow—it doesn’t limit what you can charge later.

Congrats! You’ve successfully integrated the Save Payment Method API.

FAQs

No, hitpay does not support authorization or holding of card transaction.
Yes, a minimum amount of 1 is required to initiate the save-payment-method session.
Yes, once your customer has attached a payment method to the subscription, you can charge any amount using the charge the saved payment method API.
Ensure the following before moving to production - Change the base URL for all API calls to https://api.hit-pay.com/v1/ - Update API keys and Salt values from the production dashboard