Client Session API

Update client session

PATCH

You can update a clients session created earlier with the PATCH /client-session API call.

The only required field for the request is clientToken. Other supported request fields are same as for the POST /client-session API call.

You need to specify only the fields you wish to update. However, if the items that are to be updated are of type array, then you need to provide the complete array along with modified items.

If you wish to update nested fields on the client session, such as the customer emailAddress field, you can pass the customer object with only one field, emailAddress, to update.

If you simply wish to clear the value of the field, pass null as your input.

You can update paymentMethod.vaultOnSuccess field but updating of the paymentMethod.options field through PATCH /client-session is not supported.

The response will contain all the fields of the client session including the ones that were changed.

Request

This endpoint expects an object.
clientToken
stringOptional

Client token for use in the Primer-JS SDK obtained via POST /client-session API call.

customerId
stringOptional
A unique identifier for your customer.
orderId
stringOptional
Your reference for the order.
currencyCode
stringOptional

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

amount
integerOptional

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.

metadata
map from strings to anyOptional

Additional data to be used throughout the payment lifecycle.

Provide the entire object to update it. Anything provided previously will be overwritten.

customer
objectOptional

More information associated with the customer.

Each of the fields in this object must be updated in its entirety, i.e. provide the entire object to update it. Anything provided previously will be overwritten.

order
objectOptional

More information associated with the order.

Each of the fields in this object must be updated in its entirety, i.e. provide the entire object to update it. Anything provided previously will be overwritten.

paymentMethod
objectOptional
Enable certain options associated with the payment method. Provide the entire object to update it. Anything provided previously will be overwritten.

Response

This endpoint returns an object
customerId
stringOptional
A unique identifier for your customer.
orderId
stringOptional
Your reference for the payment.
currencyCode
enumOptional

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

amount
integerOptional

The amount you are going to charge the customer, in minor units. This amount is calculated from the line items, shipping and other amounts provided in the order. If a top-level amount is provided, it would override any calculated amount.

metadata
map from strings to anyOptional
Additional data to be used throughout the payment lifecycle.
customer
objectOptional
More information associated with the customer.
order
objectOptional
More information associated with the order.
paymentMethod
objectOptional
Enable certain options associated with the payment methods.

Errors

PATCH
$curl -X PATCH https://api.sandbox.primer.io/client-session \
> -H "X-API-KEY: <apiKey>" \
> -H "Content-Type: application/json" \
> -d '{
> "customer": {
> "billingAddress": {
> "countryCode": "AW"
> },
> "shippingAddress": {
> "countryCode": "AW"
> }
> },
> "order": {
> "lineItems": [
> {
> "amount": 1,
> "productType": "PHYSICAL",
> "productData": {}
> }
> ],
> "countryCode": "AW",
> "retailerCountryCode": "AW",
> "fees": [
> {
> "amount": 1
> }
> ],
> "shipping": {}
> },
> "paymentMethod": {
> "paymentType": "FIRST_PAYMENT",
> "orderedAllowedCardNetworks": [
> "AMEX"
> ],
> "options": {
> "<PAYMENT_METHOD_TYPE>": {
> "surcharge": {}
> },
> "PAYMENT_CARD": {
> "networks": {
> "AMEX": {
> "surcharge": {}
> },
> "CARTES_BANCAIRES": {
> "surcharge": {}
> },
> "DANKORT": {
> "surcharge": {}
> },
> "DINERS_CLUB": {
> "surcharge": {}
> },
> "DISCOVER": {
> "surcharge": {}
> },
> "ENROUTE": {
> "surcharge": {}
> },
> "ELO": {
> "surcharge": {}
> },
> "HIPER": {
> "surcharge": {}
> },
> "INTERAC": {
> "surcharge": {}
> },
> "JCB": {
> "surcharge": {}
> },
> "MAESTRO": {
> "surcharge": {}
> },
> "MASTERCARD": {
> "surcharge": {}
> },
> "MIR": {
> "surcharge": {}
> },
> "PRIVATE_LABEL": {
> "surcharge": {}
> },
> "UNIONPAY": {
> "surcharge": {}
> },
> "VISA": {
> "surcharge": {}
> },
> "OTHER": {
> "surcharge": {}
> }
> }
> }
> },
> "authorizationType": "ESTIMATED"
> }
>}'
Response
1{
2 "currencyCode": "AED",
3 "customer": {
4 "billingAddress": {
5 "countryCode": "AW"
6 },
7 "shippingAddress": {
8 "countryCode": "AW"
9 }
10 },
11 "order": {
12 "lineItems": [
13 {
14 "amount": 1,
15 "productType": "PHYSICAL",
16 "productData": {}
17 }
18 ],
19 "countryCode": "AW",
20 "retailerCountryCode": "AW",
21 "fees": [
22 {
23 "amount": 1
24 }
25 ],
26 "shipping": {}
27 },
28 "paymentMethod": {
29 "paymentType": "FIRST_PAYMENT",
30 "orderedAllowedCardNetworks": [
31 "AMEX"
32 ],
33 "options": {
34 "<PAYMENT_METHOD_TYPE>": {
35 "surcharge": {}
36 },
37 "PAYMENT_CARD": {
38 "networks": {
39 "AMEX": {
40 "surcharge": {}
41 },
42 "CARTES_BANCAIRES": {
43 "surcharge": {}
44 },
45 "DANKORT": {
46 "surcharge": {}
47 },
48 "DINERS_CLUB": {
49 "surcharge": {}
50 },
51 "DISCOVER": {
52 "surcharge": {}
53 },
54 "ENROUTE": {
55 "surcharge": {}
56 },
57 "ELO": {
58 "surcharge": {}
59 },
60 "HIPER": {
61 "surcharge": {}
62 },
63 "INTERAC": {
64 "surcharge": {}
65 },
66 "JCB": {
67 "surcharge": {}
68 },
69 "MAESTRO": {
70 "surcharge": {}
71 },
72 "MASTERCARD": {
73 "surcharge": {}
74 },
75 "MIR": {
76 "surcharge": {}
77 },
78 "PRIVATE_LABEL": {
79 "surcharge": {}
80 },
81 "UNIONPAY": {
82 "surcharge": {}
83 },
84 "VISA": {
85 "surcharge": {}
86 },
87 "OTHER": {
88 "surcharge": {}
89 }
90 }
91 }
92 },
93 "authorizationType": "ESTIMATED"
94 }
95}