POST
/
client-session
Create a client session
curl --request POST \
  --url https://api.sandbox.primer.io/client-session \
  --header 'Content-Type: application/json' \
  --header 'X-API-KEY: <api-key>' \
  --header 'X-API-VERSION: <x-api-version>' \
  --data '{
  "orderId": "order-abc",
  "currencyCode": "GBP",
  "amount": 1000,
  "order": {
    "countryCode": "FR,",
    "lineItems": [
      {
        "itemId": "shoe-123",
        "description": "Blue Shoe",
        "amount": 100,
        "quantity": 10
      }
    ]
  },
  "customerId": "customer-123",
  "customer": {
    "emailAddress": "john@primer.io"
  },
  "metadata": {
    "productType": "Shoes"
  },
  "paymentMethod": {
    "descriptor": "Purchase: Shoes",
    "paymentMethodType": "PAYMENT_CARD",
    "vaultOnSuccess": true,
    "vaultOn3DS": false,
    "options": {
      "PAYMENT_CARD": {
        "networks": {
          "VISA": {
            "surcharge": {
              "amount": 10
            }
          }
        }
      },
      "GOOGLE_PAY": {
        "surcharge": {
          "amount": 20
        }
      }
    },
    "authorizationType": "ESTIMATED"
  }
}'
{
"clientToken": "client-session-token",
"clientExpirationDate": "2019-08-24T14:15:22Z",
"customerId": "customer-123",
"orderId": "order-abc",
"currencyCode": "GBP",
"metadata": {
"productType": "Shoe"
},
"customer": {
"emailAddress": "john@primer.io"
},
"amount": 20,
"order": {
"countryCode": "FR",
"fees": [
{
"type": "SURCHARGE",
"amount": 20
}
]
},
"paymentMethod": {
"vaultOnSuccess": true,
"vaultOn3DS": false,
"options": {
"PAYMENT_CARD": {
"networks": {
"VISA": {
"surcharge": {
"amount": 10
}
}
},
"captureVaultedCardCvv": true
},
"GOOGLE_PAY": {
"surcharge": {
"amount": 20
}
}
},
"authorizationType": "ESTIMATED"
},
"warnings": [
{
"type": "TAXJAR",
"code": "MISSING_DATA",
"message": "Shipping details are required for calculating tax."
}
]
}

Authorizations

X-API-KEY
string
header
required

Headers

X-API-VERSION
string
required

Specifies the version of the API to use. This must be set to 2.4.

Example:

"2.4"

Body

application/json
orderId
string

Your reference for the payment.

Required string length: 1 - 256
currencyCode
enum<string>

The 3-letter currency code in ISO 4217 format. e.g. use USD for US dollars.

Available options:
AED,
AFN,
ALL,
AMD,
ANG,
AOA,
ARS,
AUD,
AWG,
AZN,
BAM,
BBD,
BDT,
BGN,
BHD,
BIF,
BMD,
BND,
BOB,
BOV,
BRL,
BSD,
BTN,
BWP,
BYR,
BYN,
BZD,
CAD,
CDF,
CHE,
CHF,
CHW,
CLP,
CNY,
COP,
COU,
CRC,
CUC,
CUP,
CVE,
CZK,
DJF,
DKK,
DOP,
DZD,
EGP,
ERN,
ETB,
EUR,
FJD,
FKP,
GBP,
GEL,
GHS,
GIP,
GMD,
GNF,
GTQ,
GYD,
HKD,
HNL,
HRK,
HTG,
HUF,
IDR,
ILS,
INR,
IQD,
IRR,
ISK,
JMD,
JOD,
JPY,
KES,
KGS,
KHR,
KMF,
KPW,
KRW,
KWD,
KYD,
KZT,
LAK,
LBP,
LKR,
LRD,
LSL,
LYD,
MAD,
MDL,
MKD,
MMK,
MNT,
MOP,
MRO,
MUR,
MVR,
MWK,
MXN,
MXV,
MYR,
MZN,
NAD,
NGN,
NIO,
NOK,
NPR,
NZD,
OMR,
PAB,
PEN,
PGK,
PHP,
PKR,
PLN,
PYG,
QAR,
RON,
RSD,
RUB,
RWF,
SAR,
SBD,
SCR,
SDG,
SEK,
SGD,
SHP,
SOS,
SRD,
SSP,
SVC,
SYP,
SZL,
THB,
TJS,
TMT,
TND,
TOP,
TRY,
TTD,
TWD,
TZS,
UAH,
UGX,
USD,
UYU,
UZS,
VND,
VUV,
WST,
XAF,
XAG,
XAU,
XBA,
XBB,
XBC,
XBD,
XCD,
XDR,
XFU,
XOF,
XPD,
XPF,
XPT,
XSU,
XTS,
XUA,
YER,
ZAR,
ZMW,
ZWL
amount
integer

The amount you would like to charge the customer, in minor units. e.g. for $7, use 700.

Some currencies, such as Japanese Yen, do not have minor units. In this case you should use the value as it is, without any formatting. For example for ¥100, use 100.

If the amount is provided on this level, it would override any amount calculated from the provided line items, shipping and other amounts.

Required range: x >= 0
order
object

More information associated with the order.

customerId
string

A unique identifier for your customer. Create a client session token with a customerId to enable the client-side SDK to retrieve and manage your customer's saved payment methods. A client session token also enables saving payment methods against this customer id.

Required string length: 1 - 256
customer
object

More information associated with the customer.

metadata
object

Additional data to be used throughout the payment lifecycle.

A dictionary of key-value pairs where the values can only be strings or integers.

e.g. {"productId": 1001, "merchantId": "a13bsd62s"}

paymentMethod
object

Enable certain options associated with the payment method.

Response

Successful Response

clientToken
string
required

Client token used to initialize the SDK on all platforms.

clientTokenExpirationDate
string<date-time>
required

Expiration date & time of the client token (UTC with no timezoneinfo).

orderId
string

Your reference for the payment.

currencyCode
string

The 3-letter currency code in ISO 4217 format. e.g. use USD for US dollars.

amount
integer

The amount you would like to charge the customer, in minor units. e.g. for $7, use 700.

Some currencies, such as Japanese Yen, do not have minor units. In this case you should use the value as it is, without any formatting. For example for ¥100, use 100.

If the amount is provided on this level, it would override any amount calculated from the provided line items, shipping and other amounts.

Required range: x >= 0
order
object

More information associated with the order.

customerId
string

A unique identifier for your customer.

customer
object

More information associated with the customer.

metadata
object

Additional data to be used throughout the payment lifecycle.

paymentMethod
object

Enable certain options associated with the payment methods.

warnings
object

Warning messages to indicate missing information that are required for payment methods, checkout modules and other features; or when third-party services are unavailable.