Expire a Snap Session

Set a custom expiry time for a Snap session with the following methods.

Set a custom expiry for the Snap page only (default is 24 hours)



As long as Snap page is not expired, said page can be reopened again even after customer closes the page by reopening the URL with the specific session's Snap token. Page expiry can be set via Snap Preference or specified during get token via API request.


Set via Snap Preference


To set, go to Snap Preference > System Settings, then configure the Page Expiry Settings. Page expiry settings will not affect payment methods with configurable expiry time via Payment Expiry Settings section in Snap Preference.

Note : minimum accepted expiry is 5 mins, max is 7 days.


Specify via API Request


Specify during Snap token creation via API request. Page expiry is optional.


Request Body (JSON Parameters)

...
"page_expiry": {
    "duration": 3,
    "unit": "hours"
}
...
curl -X POST \
  https://app.sandbox.midtrans.com/snap/v1/transactions \
  -H 'Accept: application/json'\
  -H 'Authorization: Basic U0ItTWlkLXNlcnZlci1UT3ExYTJBVnVpeWhoT2p2ZnMzVV7LZU87' \
  -H 'Content-Type: application/json' \
  -d '{
  "transaction_details": {
    "order_id": "CustOrder-102",
    "gross_amount": 13000
  },
  "page_expiry": {
    "duration": 3,
    "unit": "hours"
  }
}'
ParameterDescriptionTypeRequired
durationPage expiry duration in numbersIntegerRequired
unitExpiry unit. Options: day, hour, minute (plural terms also accepted).StringRequired

Set a custom expiry for payment methods



Configure individual payment method's expiry time by going to Snap Preference > System Settings > Payment Expiry Settings. Check said section for more info on each payment method's default expiry time.

If payment method expiry is longer than page expiry time, customer can still make payment as long as they have the VA number/QRIS image/OTC payment code even though Snap page is expired and no longer accessible.


📘

Expiry Behavior for Card Payment

  • Card form's expiry time will follow Snap Page expiry settings (there's no separate payment method expiry settings for it). If Snap page has already expired, customer will not be able to access the card payment form.
  • However, once customer has clicked Pay upon filling the card payment details and reached the OTP/3DS page, expiry time will then follow issuing bank's OTP page expiry time.

Specify blanket expiry for Snap page and payment methods via API request



Configure blanket expiry (for both Snap page and payment methods) for a specific transaction.


Sample Request


...
  "expiry": {
    "start_time": "2020-04-13 18:11:08 +0700",
    "unit": "minutes",
    "duration": 180
  }
...
curl -X POST \
  https://app.sandbox.midtrans.com/snap/v1/transactions \
  -H 'Accept: application/json'\
  -H 'Authorization: Basic U0ItTWlkLXNlcnZlci1UT3ExYTJBVnVpeWhoT2p2ZnMzVV7LZU87' \
  -H 'Content-Type: application/json' \
  -d '{
  "transaction_details": {
    "order_id": "CustOrder-102",
    "gross_amount": 13000
  },
  "expiry": {
    "start_time": "2020-04-13 18:11:08 +0700",
    "unit": "minutes",
    "duration": 180
  }
}'
ParameterDescriptionTypeRequired
start_timeTimestamp in YYYY-MM-DD HH:MM:SS +0700.
If not specified, transaction time will be used as start time (when customer confirm payment channel). Time Zone is Western Indonesian Time (WIT).
String(255)Optional*
durationExpiry duration in numbersIntegerRequired
unitExpiry unit. Options: day, hour, minute (plural term also accepted).StringRequired

Additional Info



  • Minimum accepted expiry is 5 mins, max is 7 days.
  • Priority hierarchy for expiry (if transaction is not created yet) from most to least prioritized :
    a. page_expiry object in API
    b. expiry object in API (custom expiry)
    c. Page expiry settings in Snap Preference
  • Once customer chooses a payment method and if expiry object is not specified, expiry counter in Snap checkout page will be updated to follow individual payment method's expiry settings as specified in Snap Preference > System Settings.