Save a payment method token
curl --request POST \
--url https://api.sandbox.primer.io/payment-instruments/{token}/vault \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"customerId": "<string>"
}
'import requests
url = "https://api.sandbox.primer.io/payment-instruments/{token}/vault"
payload = { "customerId": "<string>" }
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({customerId: '<string>'})
};
fetch('https://api.sandbox.primer.io/payment-instruments/{token}/vault', 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/payment-instruments/{token}/vault",
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([
'customerId' => '<string>'
]),
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/payment-instruments/{token}/vault"
payload := strings.NewReader("{\n \"customerId\": \"<string>\"\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/payment-instruments/{token}/vault")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"customerId\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.primer.io/payment-instruments/{token}/vault")
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 \"customerId\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"createdAt": "2021-03-01T12:00:00.123456",
"token": "_xlXlmBcTnuFxc2N3HAI73wxNjE1NTU5ODY5",
"tokenType": "MULTI_USE",
"analyticsId": "vuXhpZouWxaZpRZ-x_brZmtT",
"paymentMethodType": "PAYMENT_CARD",
"paymentMethodData": {
"last4Digits": "1111",
"expirationMonth": "12",
"expirationYear": "2030",
"cardholderName": "John Biggins",
"network": "Visa",
"networkTransactionId": "020210628190752",
"accountFundingType": "DEBIT"
},
"customerId": "customer-123",
"deleted": false,
"default": true
}{
"error": {
"errorId": "RequestValidationError",
"description": "We were unable to validate your request, please check your payload against /docs/api",
"diagnosticsId": "1234567898",
"validationErrors": [
{
"model": "VaultPaymentInstrumentAPIRequest",
"errors": [
{
"path": "$.customerId",
"description": "Ensure this value has at least 1 characters"
}
]
}
]
}
}Save a payment method token
Save a SINGLE_USE payment method token so it can be used again later.
If you try to vault an already vaulted token, you will get the existing vaulted token back.
POST
/
payment-instruments
/
{token}
/
vault
Save a payment method token
curl --request POST \
--url https://api.sandbox.primer.io/payment-instruments/{token}/vault \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"customerId": "<string>"
}
'import requests
url = "https://api.sandbox.primer.io/payment-instruments/{token}/vault"
payload = { "customerId": "<string>" }
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({customerId: '<string>'})
};
fetch('https://api.sandbox.primer.io/payment-instruments/{token}/vault', 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/payment-instruments/{token}/vault",
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([
'customerId' => '<string>'
]),
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/payment-instruments/{token}/vault"
payload := strings.NewReader("{\n \"customerId\": \"<string>\"\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/payment-instruments/{token}/vault")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"customerId\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.primer.io/payment-instruments/{token}/vault")
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 \"customerId\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"createdAt": "2021-03-01T12:00:00.123456",
"token": "_xlXlmBcTnuFxc2N3HAI73wxNjE1NTU5ODY5",
"tokenType": "MULTI_USE",
"analyticsId": "vuXhpZouWxaZpRZ-x_brZmtT",
"paymentMethodType": "PAYMENT_CARD",
"paymentMethodData": {
"last4Digits": "1111",
"expirationMonth": "12",
"expirationYear": "2030",
"cardholderName": "John Biggins",
"network": "Visa",
"networkTransactionId": "020210628190752",
"accountFundingType": "DEBIT"
},
"customerId": "customer-123",
"deleted": false,
"default": true
}{
"error": {
"errorId": "RequestValidationError",
"description": "We were unable to validate your request, please check your payload against /docs/api",
"diagnosticsId": "1234567898",
"validationErrors": [
{
"model": "VaultPaymentInstrumentAPIRequest",
"errors": [
{
"path": "$.customerId",
"description": "Ensure this value has at least 1 characters"
}
]
}
]
}
}Authorizations
Path Parameters
Payment method token
Body
application/json
The ID representing the customer
Minimum string length:
1Response
Successful Response
Creation date & time of the object (UTC)
Date & time when this object was revoked. (UTC)
Whether or not this object has been revoked.
The vaulted payment method token.
MULTI_USEa vaulted token that can be re-used with subsequent payments
Unique analytics identifier corresponding to a payment method
Payment method type associated with a token.
Available options:
PAYMENT_CARD, PAYPAL_ORDER, PAYPAL_BILLING_AGREEMENT, KLARNA_AUTHORIZATION_TOKEN, KLARNA_CUSTOMER_TOKEN, PAY_NL_IDEAL, APAYA, OFF_SESSION_PAYMENT, CARD_OFF_SESSION_PAYMENT, APPLE_PAY, APPLE_PAY_ENCRYPTED_TOKEN, GOOGLE_PAY, AUTOMATED_CLEARING_HOUSE Used exclusively by the Payment Methods API
- PaymentCardTokenAPISchemaPaymentMethodsAPI
- PayPalBillingAgreementAPISchema
- GoCardlessMandateAPISchema
- KlarnaCustomerTokenAPISchema
- ApayaCustomerTokenAPISchema
Show child attributes
Show child attributes
The ID representing the customer
Whether or not this payment method is the default