curl --request PATCH \
--url https://api.sandbox.primer.io/client-session \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"clientToken": "client-session-token",
"customerId": "customer-123",
"orderId": "order-abc",
"customer": {
"emailAddress": "john@primer.io"
},
"amount": 500,
"paymentMethod": {
"authorizationType": "FINAL"
},
"order": {
"lineItems": [
{
"itemId": "shoe-123",
"description": "Blue Shoe",
"amount": 100,
"quantity": 10
}
],
"countryCode": "FR"
}
}
'import requests
url = "https://api.sandbox.primer.io/client-session"
payload = {
"clientToken": "client-session-token",
"customerId": "customer-123",
"orderId": "order-abc",
"customer": { "emailAddress": "john@primer.io" },
"amount": 500,
"paymentMethod": { "authorizationType": "FINAL" },
"order": {
"lineItems": [
{
"itemId": "shoe-123",
"description": "Blue Shoe",
"amount": 100,
"quantity": 10
}
],
"countryCode": "FR"
}
}
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
clientToken: 'client-session-token',
customerId: 'customer-123',
orderId: 'order-abc',
customer: {emailAddress: 'john@primer.io'},
amount: 500,
paymentMethod: {authorizationType: 'FINAL'},
order: {
lineItems: [{itemId: 'shoe-123', description: 'Blue Shoe', amount: 100, quantity: 10}],
countryCode: 'FR'
}
})
};
fetch('https://api.sandbox.primer.io/client-session', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sandbox.primer.io/client-session",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'clientToken' => 'client-session-token',
'customerId' => 'customer-123',
'orderId' => 'order-abc',
'customer' => [
'emailAddress' => 'john@primer.io'
],
'amount' => 500,
'paymentMethod' => [
'authorizationType' => 'FINAL'
],
'order' => [
'lineItems' => [
[
'itemId' => 'shoe-123',
'description' => 'Blue Shoe',
'amount' => 100,
'quantity' => 10
]
],
'countryCode' => 'FR'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sandbox.primer.io/client-session"
payload := strings.NewReader("{\n \"clientToken\": \"client-session-token\",\n \"customerId\": \"customer-123\",\n \"orderId\": \"order-abc\",\n \"customer\": {\n \"emailAddress\": \"john@primer.io\"\n },\n \"amount\": 500,\n \"paymentMethod\": {\n \"authorizationType\": \"FINAL\"\n },\n \"order\": {\n \"lineItems\": [\n {\n \"itemId\": \"shoe-123\",\n \"description\": \"Blue Shoe\",\n \"amount\": 100,\n \"quantity\": 10\n }\n ],\n \"countryCode\": \"FR\"\n }\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("X-API-KEY", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.sandbox.primer.io/client-session")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"clientToken\": \"client-session-token\",\n \"customerId\": \"customer-123\",\n \"orderId\": \"order-abc\",\n \"customer\": {\n \"emailAddress\": \"john@primer.io\"\n },\n \"amount\": 500,\n \"paymentMethod\": {\n \"authorizationType\": \"FINAL\"\n },\n \"order\": {\n \"lineItems\": [\n {\n \"itemId\": \"shoe-123\",\n \"description\": \"Blue Shoe\",\n \"amount\": 100,\n \"quantity\": 10\n }\n ],\n \"countryCode\": \"FR\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.primer.io/client-session")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"clientToken\": \"client-session-token\",\n \"customerId\": \"customer-123\",\n \"orderId\": \"order-abc\",\n \"customer\": {\n \"emailAddress\": \"john@primer.io\"\n },\n \"amount\": 500,\n \"paymentMethod\": {\n \"authorizationType\": \"FINAL\"\n },\n \"order\": {\n \"lineItems\": [\n {\n \"itemId\": \"shoe-123\",\n \"description\": \"Blue Shoe\",\n \"amount\": 100,\n \"quantity\": 10\n }\n ],\n \"countryCode\": \"FR\"\n }\n}"
response = http.request(request)
puts response.read_body{
"customerId": "customer-123",
"orderId": "order-abc",
"currencyCode": "GBP",
"amount": 650,
"metadata": {
"productType": "Clothing"
},
"customer": {
"emailAddress": "john@primer.io"
},
"order": {
"lineItems": [
{
"itemId": "t-shirt-1",
"description": "White T-Shirt",
"amount": 500,
"quantity": 1
}
],
"fees": [
{
"type": "SURCHARGE",
"amount": 100
}
],
"shipping": {
"amount": 50
},
"paymentMethod": {
"vaultOnSuccess": false,
"vaultOn3DS": false,
"options": {
"GOOGLE_PAY": {
"surcharge": {
"amount": 100
}
},
"PAYMENT_CARD": {
"networks": {
"VISA": {
"surcharge": {
"amount": 10
}
},
"MASTERCARD": {
"surcharge": {
"amount": 20
}
}
}
},
"PAY_NL_IDEAL": {
"surcharge": {
"amount": 50
}
}
}
},
"authorizationType": "ESTIMATED"
}
}Update client session
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 to be updated are arrays (e.g.lineItems), you need to provide the entire array, including any new or modified items. Primer will replace the full array with whatever is sent in the request. If you want to keep existing items, make sure to include them in your request, anything omitted will be removed.
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.
curl --request PATCH \
--url https://api.sandbox.primer.io/client-session \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"clientToken": "client-session-token",
"customerId": "customer-123",
"orderId": "order-abc",
"customer": {
"emailAddress": "john@primer.io"
},
"amount": 500,
"paymentMethod": {
"authorizationType": "FINAL"
},
"order": {
"lineItems": [
{
"itemId": "shoe-123",
"description": "Blue Shoe",
"amount": 100,
"quantity": 10
}
],
"countryCode": "FR"
}
}
'import requests
url = "https://api.sandbox.primer.io/client-session"
payload = {
"clientToken": "client-session-token",
"customerId": "customer-123",
"orderId": "order-abc",
"customer": { "emailAddress": "john@primer.io" },
"amount": 500,
"paymentMethod": { "authorizationType": "FINAL" },
"order": {
"lineItems": [
{
"itemId": "shoe-123",
"description": "Blue Shoe",
"amount": 100,
"quantity": 10
}
],
"countryCode": "FR"
}
}
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
clientToken: 'client-session-token',
customerId: 'customer-123',
orderId: 'order-abc',
customer: {emailAddress: 'john@primer.io'},
amount: 500,
paymentMethod: {authorizationType: 'FINAL'},
order: {
lineItems: [{itemId: 'shoe-123', description: 'Blue Shoe', amount: 100, quantity: 10}],
countryCode: 'FR'
}
})
};
fetch('https://api.sandbox.primer.io/client-session', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sandbox.primer.io/client-session",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'clientToken' => 'client-session-token',
'customerId' => 'customer-123',
'orderId' => 'order-abc',
'customer' => [
'emailAddress' => 'john@primer.io'
],
'amount' => 500,
'paymentMethod' => [
'authorizationType' => 'FINAL'
],
'order' => [
'lineItems' => [
[
'itemId' => 'shoe-123',
'description' => 'Blue Shoe',
'amount' => 100,
'quantity' => 10
]
],
'countryCode' => 'FR'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sandbox.primer.io/client-session"
payload := strings.NewReader("{\n \"clientToken\": \"client-session-token\",\n \"customerId\": \"customer-123\",\n \"orderId\": \"order-abc\",\n \"customer\": {\n \"emailAddress\": \"john@primer.io\"\n },\n \"amount\": 500,\n \"paymentMethod\": {\n \"authorizationType\": \"FINAL\"\n },\n \"order\": {\n \"lineItems\": [\n {\n \"itemId\": \"shoe-123\",\n \"description\": \"Blue Shoe\",\n \"amount\": 100,\n \"quantity\": 10\n }\n ],\n \"countryCode\": \"FR\"\n }\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("X-API-KEY", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.sandbox.primer.io/client-session")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"clientToken\": \"client-session-token\",\n \"customerId\": \"customer-123\",\n \"orderId\": \"order-abc\",\n \"customer\": {\n \"emailAddress\": \"john@primer.io\"\n },\n \"amount\": 500,\n \"paymentMethod\": {\n \"authorizationType\": \"FINAL\"\n },\n \"order\": {\n \"lineItems\": [\n {\n \"itemId\": \"shoe-123\",\n \"description\": \"Blue Shoe\",\n \"amount\": 100,\n \"quantity\": 10\n }\n ],\n \"countryCode\": \"FR\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.primer.io/client-session")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"clientToken\": \"client-session-token\",\n \"customerId\": \"customer-123\",\n \"orderId\": \"order-abc\",\n \"customer\": {\n \"emailAddress\": \"john@primer.io\"\n },\n \"amount\": 500,\n \"paymentMethod\": {\n \"authorizationType\": \"FINAL\"\n },\n \"order\": {\n \"lineItems\": [\n {\n \"itemId\": \"shoe-123\",\n \"description\": \"Blue Shoe\",\n \"amount\": 100,\n \"quantity\": 10\n }\n ],\n \"countryCode\": \"FR\"\n }\n}"
response = http.request(request)
puts response.read_body{
"customerId": "customer-123",
"orderId": "order-abc",
"currencyCode": "GBP",
"amount": 650,
"metadata": {
"productType": "Clothing"
},
"customer": {
"emailAddress": "john@primer.io"
},
"order": {
"lineItems": [
{
"itemId": "t-shirt-1",
"description": "White T-Shirt",
"amount": 500,
"quantity": 1
}
],
"fees": [
{
"type": "SURCHARGE",
"amount": 100
}
],
"shipping": {
"amount": 50
},
"paymentMethod": {
"vaultOnSuccess": false,
"vaultOn3DS": false,
"options": {
"GOOGLE_PAY": {
"surcharge": {
"amount": 100
}
},
"PAYMENT_CARD": {
"networks": {
"VISA": {
"surcharge": {
"amount": 10
}
},
"MASTERCARD": {
"surcharge": {
"amount": 20
}
}
}
},
"PAY_NL_IDEAL": {
"surcharge": {
"amount": 50
}
}
}
},
"authorizationType": "ESTIMATED"
}
}Body
The 3-letter currency code in ISO 4217 format. e.g. use USD for US dollars.
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.
x >= 0Additional data to be used throughout the payment lifecycle.
Provide the entire object to update it. Anything provided previously will be overwritten.
The size of metadata must not exceed 300 KB (307,200 bytes) when
serialized as JSON. Larger payloads are rejected with a
PaymentMetadataSizeExceeded error.
Response
Successful Response
The 3-letter currency code in ISO 4217 format. e.g. use USD for US dollars.
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, 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, SLE, SOS, SRD, SSP, STN, SVC, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, UYU, UZS, VED, VES, VND, VUV, WST, XAF, XCD, XCG, XOF, XPF, YER, ZAR, ZMW, ZWG, ZWL The ordered list of card networks accepted for this client session, as resolved from paymentMethod.orderedAllowedCardNetworks and the default list.
The list of available card networks.
AMEX, CARTES_BANCAIRES, DANKORT, DINERS_CLUB, DISCOVER, EFTPOS, ENROUTE, ELO, HIPER, INTERAC, JCB, MAESTRO, MASTERCARD, MIR, PRIVATE_LABEL, UNIONPAY, VISA, OTHER