With Headless Vault you can choose to process payments directly on your own backend by requesting a payment processor token from WhenThen.
Use the Vault API to create customers and associate payment methods. This allows you to perform recurring charges, and to track multiple charges, that are associated with the same customer all while using a tokenised payment method.
Create a customer (optional)
API Reference Create Customer.
First we can optionally create a new customer
curl
-X POST
-H "Content-Type: application/json"
-H "Authorization: Bearer xxxxxxx"
-d '{
"query": "mutation createCustomer($data: CustomerInput!){
createCustomer(data: $data)
}",
"variables": {
"customer": {
"email": "john@example.com",
"name": "John Smith",
"phone": "406-694-3629"
}
}
}'
https://api.whenthen.com/api/graphql
Tokenise Payment Method
API Reference Tokenise Payment Method.
curl
-X POST
-H "Content-Type: application/json"
-H "Authorization: Bearer xxxxxxx"
-d '{
"query": "mutation tokenisePaymentMethod($data: TokenInput!){
tokenisePaymentMethod(data: $data) {
id
token
createdDate
}
}",
"variables": {
"paymentMethod": {
"card": {
"number":"4000056655665556",
"expMonth": 8,
"expYear": 2026,
"cvc": "342",
"name": "John Smith",
"isDefault": true
}
},
"customer": {
"id": "421dd9b0-0af6-41ee-9fc5-48f42d5ad640"
}
}
}'
https://api.whenthen.com/api/graphql
Headless Request Payment Processor Token
API Reference Request Payment Processor Token.
curl
-X POST
-H "Content-Type: application/json"
-H "Authorization: Bearer xxxxxxx"
-d '{
"query": "mutation headlessRequestPaymentProcessorToken($tokenRequest: HeadlessPaymentProcessorTokenRequest!){
headlessRequestPaymentProcessorToken(tokenRequest: $tokenRequest) {
token
}
}",
"variables": {
"tokenRequest": {
"vaultToken": "KbQHOIcQTpOXKmxr",
"paymentProcessorConnectionId": "connection-provider:ff8705dc-7d94-4a44-abe2-a206d5c833d9",
"currencyCode": "USD",
"threeDSecureRedirectUrl": "https://merchant.com/handle-3ds"
}
}'
https://api.whenthen.com/api/graphql