Saving Payment Method

Setting up and managing recurring payments

Juspay Hyperswitch supports the following ways of saving a payment method used in a successful payment:

  1. Saving for future customer on-session payments (COF-CIT)

  2. Saving for future customer off-session payments (MIT)

Saving a payment method for future on-session payments (COF CIT)

To improve conversion rates and eliminate friction for the customer during checkout, you can save the customer's card so that they wouldn't have to enter the card details every time. This also minimises the risk of the customer entering incorrect card details.

Saving for future on-session payments implies that the customer will be available online during the checkout and can authenticate the payment by entering CVV or complete 3DS verification. These are known as Card-on-File Customer Initiated Transactions (COF-CIT).

This is typically limited for card payment methods and not for wallets (viz. Apple Pay) and other APMs.

To save a customer's payment method used in a successful transaction for future CIT payments:

Follow Steps for SDK integration

Pass the following field in the /payments create request to indicate your intention to save the payment method

curl --location 'https://sandbox.hyperswitch.io/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: <enter your Hyperswitch API key here>' \
--data-raw '{
    "amount": 6540,
    "currency": "USD",
    "profile_id": <enter the relevant profile id>,
    "setup_future_usage":"on_session", 
    "customer_id": "customer123",
    "description": "Its my first payment request",
    "return_url": "https://example.com", // 
}'

Note: Ensure to enable this functionality using the displaySavedPaymentMethodsCheckbox property during SDK integration

If you are using the Hyperswitch SDK, the customer_acceptance is sent in the /payments/:id:/confirm request on the basis of customer clicking the save card radio button

The customer's consent to save their card is expressed through this checkbox
Follow Steps For API Integration

Step 1 --

Pass the following field in the /payments create request to indicate your intention to save the payment method

curl --location 'https://sandbox.hyperswitch.io/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: <enter your Hyperswitch API key here>' \
--data-raw '{
    "amount": 6540,
    "currency": "USD",
    "profile_id": <enter the relevant profile id>,
    "setup_future_usage":"on_session", 
    "customer_id": "customer123",
    "description": "Its my first payment request",
    "return_url": "https://example.com", // 
}'

Step 2 --

During the payment confirm call pass the customer's consent to store the card in the request

"customer_acceptance": {
        "acceptance_type": "online",
        "accepted_at": "1963-05-03T04:07:52.723Z",
        "online": {
            "ip_address": "in sit",
            "user_agent": "amet irure esse"
        }
    }

Saving a payment method for future MIT payments

Let's say, you want to save a customer's payment method to charge them at a later point without the need for additional cardholder authentication. This is done by raising an MIT (Merchant Initiated Transaction) exemption to the card network by the payment processor with reference to an initial transaction where the customer has authorised recurring charges. These are typically used when you want to charge a customer periodically/sporadically with a flexibility on the amount to be charged and number of charges.

Based on the payment processors support, this functionality is also available for other payment methods like Apple Pay and Google Pay Wallets.

To save a customer's payment method used in a successful transaction for future MIT payments:

Follow Steps for SDK integration

Pass the following field in the /payments create request to indicate your intention to save the payment method

If you are using the Hyperswitch SDK, the customer_acceptance is sent in the /payments/:id:/confirm request on the basis of customer clicking the save card radio button

Note: Ensure to enable this functionality using the displaySavedPaymentMethodsCheckbox property during SDK integration

Retrieve the payment_method_id that was created against the above payment by retrieving the payment. You will get the payment_method_id in the response. Store this ID for making subsequent MIT payments.

Follow Steps for API integration

Pass the following field in the /payments create request to indicate your intention to save the payment method

During the payment confirm call pass the customer's consent to store the card in the request

Retrieve the payment_method_id that was created against the above payment by retrieving the payment. You will get the payment_method_id in the response. Store this ID for making subsequent MIT payments.


Using a saved payment method to do a MIT payment

Once a customer's payment method is saved for MIT payments you can start charging the customer by sending the following details in the /payments request

You would be using the same payment_method_id that was returned in the /payments/:id:/retrieve response for the initial transaction where the customer authorized saving for future use.

To get all the payment methods saved for a customer use the List Customer Payment Methods API.


Processing MIT Payments Without a Saved Payment Method

If a merchant is PCI-compliant and has the customer payment method details stored, an MIT payment can be performed by passing the card details and the network transaction id directly in the confirm call.


Last updated

Was this helpful?