Card Payment - Subscription (One Click)

In addition to two clicks feature, Snap also supports one click transaction which will also capture card CVV. With this, customer can directly proceed to charge without input any information.

To ease card saving process, Snap provides card token storage feature. So, merchants don't have to store and manage credit card token by themselves. Merchants can easily integrate credit card token storage feature to Snap by providing unique user_id that associate with customer account on merchant's system, in addition to enabling credit_card.save_card flag.

Snap will then decide to store credit card token as one click token based on two criteria:

  1. Merchant has recurring MID enabled
  2. Initial transaction is 3DS-enabled

If those two conditions are met, credit card token will be saved as one click token. Otherwise, it will be saved as two clicks token.

To activate subscriptions/recurring for your merchant account in production, please reach out to your Midtrans PIC or Support team.

Similar to two clicks flow, there are two steps required to utilize credit card token storage feature on Snap:




Initial Transaction


  • Create SNAP_TOKEN with user_id and credit_card.save_card set to true
  • user_id is a unique identifier that represents a customer. Its value can be any string with a maximum length of 255. Avoid using values that could be easily linked to a customer like email, id of records in database etc. Instead use something like sha512(email/record.id + salt). Don't expose the user_id to frontends like browser or mobile.
  • Customer will be presented with save option when they fill out the credit card details
  • If customer chooses the save option, Snap will store credit card token and associate it with user_id
  • If you want to enable one click feature, make sure to activate recurring MID and set credit_card.secure to true. Otherwise, credit card token will be saved as two clicks.



Successive Transaction (One Time and Recurring)


  • Create SNAP_TOKEN with the same user_id as in initial transaction
  • It's not necessary to have credit_card.save_card flag set to true on successive transaction
  • Customer can choose between multiple saved cards if they have saved some cards before
  • If selected card was saved as one click token, customer will be presented with pre-filled credit card number, expiry date, cvv, email and phone number. Then, customer can directly proceed to charge (this process will bypass 3DS).
  • If selected card was saved as two clicks token, customer will need to enter CVV and going through 3DS process when necessary (same as two clicks flow)
  • For cards saved as one click token, merchant can charge recurring payments by utilizing our Subscription API to perform the subsequent charges. Read more about our Subscription API here.

Sample Implementation


{
  "transaction_details": {
    "order_id": "ORDER-101",
    "gross_amount": 10000
  },
  "credit_card": {
    "secure": true,
    "save_card": true
  },
  "user_id": "customer-nR6DCOzqGis"
}