POST
/
v2
/
payment-method-sessions
Payment Method Session - Create
curl --request POST \
  --url https://sandbox.hyperswitch.io/v2/payment-method-sessions \
  --header 'Content-Type: application/json' \
  --header 'api-key: <api-key>' \
  --data '{
  "customer_id": "12345_cus_abcdefghijklmnopqrstuvwxyz"
}'
{
  "id": "12345_pms_01926c58bc6e77c09e809964e72af8c8",
  "customer_id": "12345_cus_01926c58bc6e77c09e809964e72af8c8",
  "billing": {
    "address": {
      "city": "New York",
      "country": "AF",
      "line1": "123, King Street",
      "line2": "Powelson Avenue",
      "line3": "Bridgewater",
      "zip": "08807",
      "state": "New York",
      "first_name": "John",
      "last_name": "Doe",
      "origin_zip": "08807"
    },
    "phone": {
      "number": "9123456789",
      "country_code": "+1"
    },
    "email": "<string>"
  },
  "psp_tokenization": {
    "tokenization_type": "single_use",
    "connector_id": "<string>"
  },
  "network_tokenization": {
    "enable": "Enable"
  },
  "tokenization_data": "<any>",
  "expires_at": "2023-01-18T11:04:09.922Z",
  "client_secret": "<string>",
  "return_url": "<string>",
  "next_action": {
    "redirect_to_url": "<string>",
    "type": "redirect_to_url"
  },
  "authentication_details": {
    "status": "succeeded",
    "error": {
      "code": "<string>",
      "message": "<string>",
      "unified_code": "<string>",
      "unified_message": "<string>",
      "network_advice_code": "<string>",
      "network_decline_code": "<string>",
      "network_error_message": "<string>"
    }
  },
  "associated_payment_methods": [
    "<string>"
  ],
  "associated_token_id": "12345_tok_01926c58bc6e77c09e809964e72af8c8"
}

Authorizations

api-key
string
header
required

Use the API key created under your merchant account from the HyperSwitch dashboard. API key is used to authenticate API requests from your merchant server only. Don't expose this key on a website or embed it in a mobile application.

Body

application/json
customer_id
string
required

The customer id for which the payment methods session is to be created

Example:

"cus_y3oqhf46pyzuxjbcn2giaqnb44"

billing
object
return_url
string | null

The return url to which the customer should be redirected to after adding the payment method

psp_tokenization
object

The Payment Service Provider Configuration for payment methods that are created using the payment method session

network_tokenization
object

The network tokenization configuration for creating the payment method session

expires_in
integer | null
default:900

The time (seconds ) when the session will expire If not provided, the session will expire in 15 minutes

Required range: x >= 0
Example:

900

tokenization_data
any

Contains data to be passed on to tokenization service ( if present ) to create token_id for given JSON data

Response

Create the payment method session

id
string
required
Example:

"12345_pms_01926c58bc6e77c09e809964e72af8c8"

customer_id
string
required

The customer id for which the payment methods session is to be created

Example:

"12345_cus_01926c58bc6e77c09e809964e72af8c8"

expires_at
string<date-time>
required

The iso timestamp when the session will expire Trying to retrieve the session or any operations on the session after this time will result in an error

Example:

"2023-01-18T11:04:09.922Z"

client_secret
string
required

Client Secret

billing
object
psp_tokenization
object

The Payment Service Provider Configuration for payment methods that are created using the payment method session

network_tokenization
object

The network tokenization configuration for creating the payment method session

tokenization_data
any

Contains data to be passed on to tokenization service ( if present ) to create token_id for given JSON data

return_url
string | null

The return url to which the user should be redirected to

next_action
object

Contains the url for redirection flow

authentication_details
object
associated_payment_methods
string[] | null

The payment method that was created using this payment method session

associated_token_id
string | null

The token-id created if there is tokenization_data present

Example:

"12345_tok_01926c58bc6e77c09e809964e72af8c8"