curl --request POST \
--url https://api.sandbox.primer.io/payments \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"orderId": "order-abc",
"currencyCode": "EUR",
"amount": 42,
"paymentMethodToken": "heNwnqaeRiqvY1UcslfQc3wxNjEzOTIxNjc4",
"customerId": "customer-123",
"customer": {
"emailAddress": "customer123@gmail.com"
},
"metadata": {
"productId": 123,
"merchantId": "a13bsd62s"
},
"paymentMethod": {
"paymentType": "SUBSCRIPTION",
"vaultOnSuccess": true,
"authorizationType": "ESTIMATED"
}
}
'import requests
url = "https://api.sandbox.primer.io/payments"
payload = {
"orderId": "order-abc",
"currencyCode": "EUR",
"amount": 42,
"paymentMethodToken": "heNwnqaeRiqvY1UcslfQc3wxNjEzOTIxNjc4",
"customerId": "customer-123",
"customer": { "emailAddress": "customer123@gmail.com" },
"metadata": {
"productId": 123,
"merchantId": "a13bsd62s"
},
"paymentMethod": {
"paymentType": "SUBSCRIPTION",
"vaultOnSuccess": True,
"authorizationType": "ESTIMATED"
}
}
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
orderId: 'order-abc',
currencyCode: 'EUR',
amount: 42,
paymentMethodToken: 'heNwnqaeRiqvY1UcslfQc3wxNjEzOTIxNjc4',
customerId: 'customer-123',
customer: {emailAddress: 'customer123@gmail.com'},
metadata: {productId: 123, merchantId: 'a13bsd62s'},
paymentMethod: {
paymentType: 'SUBSCRIPTION',
vaultOnSuccess: true,
authorizationType: 'ESTIMATED'
}
})
};
fetch('https://api.sandbox.primer.io/payments', 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/payments",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'orderId' => 'order-abc',
'currencyCode' => 'EUR',
'amount' => 42,
'paymentMethodToken' => 'heNwnqaeRiqvY1UcslfQc3wxNjEzOTIxNjc4',
'customerId' => 'customer-123',
'customer' => [
'emailAddress' => 'customer123@gmail.com'
],
'metadata' => [
'productId' => 123,
'merchantId' => 'a13bsd62s'
],
'paymentMethod' => [
'paymentType' => 'SUBSCRIPTION',
'vaultOnSuccess' => true,
'authorizationType' => 'ESTIMATED'
]
]),
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/payments"
payload := strings.NewReader("{\n \"orderId\": \"order-abc\",\n \"currencyCode\": \"EUR\",\n \"amount\": 42,\n \"paymentMethodToken\": \"heNwnqaeRiqvY1UcslfQc3wxNjEzOTIxNjc4\",\n \"customerId\": \"customer-123\",\n \"customer\": {\n \"emailAddress\": \"customer123@gmail.com\"\n },\n \"metadata\": {\n \"productId\": 123,\n \"merchantId\": \"a13bsd62s\"\n },\n \"paymentMethod\": {\n \"paymentType\": \"SUBSCRIPTION\",\n \"vaultOnSuccess\": true,\n \"authorizationType\": \"ESTIMATED\"\n }\n}")
req, _ := http.NewRequest("POST", 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.post("https://api.sandbox.primer.io/payments")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"orderId\": \"order-abc\",\n \"currencyCode\": \"EUR\",\n \"amount\": 42,\n \"paymentMethodToken\": \"heNwnqaeRiqvY1UcslfQc3wxNjEzOTIxNjc4\",\n \"customerId\": \"customer-123\",\n \"customer\": {\n \"emailAddress\": \"customer123@gmail.com\"\n },\n \"metadata\": {\n \"productId\": 123,\n \"merchantId\": \"a13bsd62s\"\n },\n \"paymentMethod\": {\n \"paymentType\": \"SUBSCRIPTION\",\n \"vaultOnSuccess\": true,\n \"authorizationType\": \"ESTIMATED\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.primer.io/payments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"orderId\": \"order-abc\",\n \"currencyCode\": \"EUR\",\n \"amount\": 42,\n \"paymentMethodToken\": \"heNwnqaeRiqvY1UcslfQc3wxNjEzOTIxNjc4\",\n \"customerId\": \"customer-123\",\n \"customer\": {\n \"emailAddress\": \"customer123@gmail.com\"\n },\n \"metadata\": {\n \"productId\": 123,\n \"merchantId\": \"a13bsd62s\"\n },\n \"paymentMethod\": {\n \"paymentType\": \"SUBSCRIPTION\",\n \"vaultOnSuccess\": true,\n \"authorizationType\": \"ESTIMATED\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "kHdEw9EG",
"date": "2021-02-21T15:36:16.367687",
"dateUpdated": "2021-02-21T15:36:17.133701",
"status": "AUTHORIZED",
"orderId": "order-abc",
"currencyCode": "EUR",
"amount": 42,
"customerId": "customer-123",
"customer": {
"email": "customer123@gmail.com"
},
"cardTokenType": "CARD_PAN",
"paymentMethod": {
"paymentType": "SUBSCRIPTION",
"paymentMethodToken": "heNwnqaeRiqvY1UcslfQc3wxNjEzOTIxNjc4",
"isVaulted": true,
"authorizationType": "FINAL",
"descriptor": "Purchase: Socks",
"analyticsId": "VtkMDAxZW5isH0HsbbNxZ3lo",
"paymentMethodType": "PAYMENT_CARD",
"paymentMethodData": {
"first6Digits": "411111",
"firstDigits": "41111111",
"last4Digits": "1111",
"expirationMonth": "12",
"expirationYear": "2030",
"cardholderName": "John Biggins",
"network": "Visa",
"isNetworkTokenized": false,
"binData": {
"network": "VISA",
"regionalRestriction": "UNKNOWN",
"accountNumberType": "UNKNOWN",
"accountFundingType": "UNKNOWN",
"prepaidReloadableIndicator": "NOT_APPLICABLE",
"productUsageType": "UNKNOWN",
"productCode": "VISA",
"productName": "VISA"
}
}
},
"processor": {
"name": "STRIPE",
"processorMerchantId": "acct_stripe_1234",
"amountCaptured": 0,
"amountRefunded": 0
},
"transactions": [
{
"type": "SALE",
"processorStatus": "AUTHORIZED",
"processorName": "STRIPE",
"processorMerchantId": "acct_stripe_1234",
"processorTransactionId": "54c4eb5b3ef8a",
"cardTokenType": "CARD_PAN"
}
],
"metadata": {
"productId": 123,
"merchantId": "a13bsd62s"
},
"riskData": {
"fraudChecks": {
"source": "FRAUD_PROVIDER",
"preAuthorizationResult": "THREE_DS",
"postAuthorizationResult": "ACCEPT"
},
"cvvCheck": {
"source": "PROCESSOR",
"result": "MATCHED"
},
"avsCheck": {
"source": "PROCESSOR",
"result": {
"streetAddress": "NOT_MATCHED",
"postalCode": "NOT_VERIFIED"
}
}
}
}Create a payment
Create and authorize a payment for a given customer order. You should provide a payment method token here to avoid PCI implications.
If only a payment method token is passed, the values passed with the Client Session is used to determine the amount, currency etc.
Note: amount, currencyCode and orderId are required during payment creation. Make sure to pass these fields when creating a client session, or if not yet available, when creating a payment.
All fields provided on this request will take preference over any field on the order associated with the client session. E.g. if you pass amount on this request, it will override the amount on the order associated with the Client Session.
Parameters that are not on this request will be fetched from previously created Client Session and merged. E.g. if you specify customer.billingAddress in Client Session and then pass customer.emailAddress data with this request, it will automatically merge the customer fields and use both billingAddress and emailAddress for later calculations.
curl --request POST \
--url https://api.sandbox.primer.io/payments \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"orderId": "order-abc",
"currencyCode": "EUR",
"amount": 42,
"paymentMethodToken": "heNwnqaeRiqvY1UcslfQc3wxNjEzOTIxNjc4",
"customerId": "customer-123",
"customer": {
"emailAddress": "customer123@gmail.com"
},
"metadata": {
"productId": 123,
"merchantId": "a13bsd62s"
},
"paymentMethod": {
"paymentType": "SUBSCRIPTION",
"vaultOnSuccess": true,
"authorizationType": "ESTIMATED"
}
}
'import requests
url = "https://api.sandbox.primer.io/payments"
payload = {
"orderId": "order-abc",
"currencyCode": "EUR",
"amount": 42,
"paymentMethodToken": "heNwnqaeRiqvY1UcslfQc3wxNjEzOTIxNjc4",
"customerId": "customer-123",
"customer": { "emailAddress": "customer123@gmail.com" },
"metadata": {
"productId": 123,
"merchantId": "a13bsd62s"
},
"paymentMethod": {
"paymentType": "SUBSCRIPTION",
"vaultOnSuccess": True,
"authorizationType": "ESTIMATED"
}
}
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
orderId: 'order-abc',
currencyCode: 'EUR',
amount: 42,
paymentMethodToken: 'heNwnqaeRiqvY1UcslfQc3wxNjEzOTIxNjc4',
customerId: 'customer-123',
customer: {emailAddress: 'customer123@gmail.com'},
metadata: {productId: 123, merchantId: 'a13bsd62s'},
paymentMethod: {
paymentType: 'SUBSCRIPTION',
vaultOnSuccess: true,
authorizationType: 'ESTIMATED'
}
})
};
fetch('https://api.sandbox.primer.io/payments', 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/payments",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'orderId' => 'order-abc',
'currencyCode' => 'EUR',
'amount' => 42,
'paymentMethodToken' => 'heNwnqaeRiqvY1UcslfQc3wxNjEzOTIxNjc4',
'customerId' => 'customer-123',
'customer' => [
'emailAddress' => 'customer123@gmail.com'
],
'metadata' => [
'productId' => 123,
'merchantId' => 'a13bsd62s'
],
'paymentMethod' => [
'paymentType' => 'SUBSCRIPTION',
'vaultOnSuccess' => true,
'authorizationType' => 'ESTIMATED'
]
]),
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/payments"
payload := strings.NewReader("{\n \"orderId\": \"order-abc\",\n \"currencyCode\": \"EUR\",\n \"amount\": 42,\n \"paymentMethodToken\": \"heNwnqaeRiqvY1UcslfQc3wxNjEzOTIxNjc4\",\n \"customerId\": \"customer-123\",\n \"customer\": {\n \"emailAddress\": \"customer123@gmail.com\"\n },\n \"metadata\": {\n \"productId\": 123,\n \"merchantId\": \"a13bsd62s\"\n },\n \"paymentMethod\": {\n \"paymentType\": \"SUBSCRIPTION\",\n \"vaultOnSuccess\": true,\n \"authorizationType\": \"ESTIMATED\"\n }\n}")
req, _ := http.NewRequest("POST", 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.post("https://api.sandbox.primer.io/payments")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"orderId\": \"order-abc\",\n \"currencyCode\": \"EUR\",\n \"amount\": 42,\n \"paymentMethodToken\": \"heNwnqaeRiqvY1UcslfQc3wxNjEzOTIxNjc4\",\n \"customerId\": \"customer-123\",\n \"customer\": {\n \"emailAddress\": \"customer123@gmail.com\"\n },\n \"metadata\": {\n \"productId\": 123,\n \"merchantId\": \"a13bsd62s\"\n },\n \"paymentMethod\": {\n \"paymentType\": \"SUBSCRIPTION\",\n \"vaultOnSuccess\": true,\n \"authorizationType\": \"ESTIMATED\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.primer.io/payments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"orderId\": \"order-abc\",\n \"currencyCode\": \"EUR\",\n \"amount\": 42,\n \"paymentMethodToken\": \"heNwnqaeRiqvY1UcslfQc3wxNjEzOTIxNjc4\",\n \"customerId\": \"customer-123\",\n \"customer\": {\n \"emailAddress\": \"customer123@gmail.com\"\n },\n \"metadata\": {\n \"productId\": 123,\n \"merchantId\": \"a13bsd62s\"\n },\n \"paymentMethod\": {\n \"paymentType\": \"SUBSCRIPTION\",\n \"vaultOnSuccess\": true,\n \"authorizationType\": \"ESTIMATED\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "kHdEw9EG",
"date": "2021-02-21T15:36:16.367687",
"dateUpdated": "2021-02-21T15:36:17.133701",
"status": "AUTHORIZED",
"orderId": "order-abc",
"currencyCode": "EUR",
"amount": 42,
"customerId": "customer-123",
"customer": {
"email": "customer123@gmail.com"
},
"cardTokenType": "CARD_PAN",
"paymentMethod": {
"paymentType": "SUBSCRIPTION",
"paymentMethodToken": "heNwnqaeRiqvY1UcslfQc3wxNjEzOTIxNjc4",
"isVaulted": true,
"authorizationType": "FINAL",
"descriptor": "Purchase: Socks",
"analyticsId": "VtkMDAxZW5isH0HsbbNxZ3lo",
"paymentMethodType": "PAYMENT_CARD",
"paymentMethodData": {
"first6Digits": "411111",
"firstDigits": "41111111",
"last4Digits": "1111",
"expirationMonth": "12",
"expirationYear": "2030",
"cardholderName": "John Biggins",
"network": "Visa",
"isNetworkTokenized": false,
"binData": {
"network": "VISA",
"regionalRestriction": "UNKNOWN",
"accountNumberType": "UNKNOWN",
"accountFundingType": "UNKNOWN",
"prepaidReloadableIndicator": "NOT_APPLICABLE",
"productUsageType": "UNKNOWN",
"productCode": "VISA",
"productName": "VISA"
}
}
},
"processor": {
"name": "STRIPE",
"processorMerchantId": "acct_stripe_1234",
"amountCaptured": 0,
"amountRefunded": 0
},
"transactions": [
{
"type": "SALE",
"processorStatus": "AUTHORIZED",
"processorName": "STRIPE",
"processorMerchantId": "acct_stripe_1234",
"processorTransactionId": "54c4eb5b3ef8a",
"cardTokenType": "CARD_PAN"
}
],
"metadata": {
"productId": 123,
"merchantId": "a13bsd62s"
},
"riskData": {
"fraudChecks": {
"source": "FRAUD_PROVIDER",
"preAuthorizationResult": "THREE_DS",
"postAuthorizationResult": "ACCEPT"
},
"cvvCheck": {
"source": "PROCESSOR",
"result": "MATCHED"
},
"avsCheck": {
"source": "PROCESSOR",
"result": {
"streetAddress": "NOT_MATCHED",
"postalCode": "NOT_VERIFIED"
}
}
}
}Headers
Body
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 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. The minimum amount is 0. The maximum amount is the limit of int64.
x >= 0Additional 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"}
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
See the payment status table for more information.
PENDING, FAILED, AUTHORIZED, SETTLING, PARTIALLY_SETTLED, SETTLED, DECLINED, CANCELLED 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