C#
using RestSharp;
var options = new RestClientOptions("https://api.sandbox.{id}.gr4vy.app/payment-methods/{payment_method_id}/detokenization");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);package main
import(
"context"
"os"
gr4vygo "github.com/gr4vy/gr4vy-go"
"log"
)
func main() {
ctx := context.Background()
s := gr4vy.New(
gr4vy.WithID("example"),
gr4vy.WithServer(gr4vy.ServerSandbox),
gr4vy.WithSecuritySource(withToken),
gr4vy.WithMerchantAccountID("default"),
)
res, err := s.PaymentMethods.Detokenize(ctx, "ef9496d8-53a5-4aad-8ca2-00eb68334389", nil)
if err != nil {
log.Fatal(err)
}
if res != nil {
// handle response
}
}package hello.world;
import com.gr4vy.sdk.Gr4vy;
import com.gr4vy.sdk.models.errors.*;
import com.gr4vy.sdk.models.operations.DetokenizePaymentMethodResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws Exception {
Gr4vy sdk = Gr4vy.builder()
.id("example")
.server(AvailableServers.SANDBOX)
.merchantAccountId("default")
.securitySource(new BearerSecuritySource.Builder(privateKey).build())
.build();
DetokenizePaymentMethodResponse res = sdk.paymentMethods().detokenize()
.paymentMethodId("ef9496d8-53a5-4aad-8ca2-00eb68334389")
.call();
if (res.detokenization().isPresent()) {
System.out.println(res.detokenization().get());
}
}
}declare(strict_types=1);
require 'vendor/autoload.php';
use Gr4vy;
$sdk = Gr4vy\SDK::builder()
->setId('example')
->setServer('sandbox')
->setSecuritySource(Auth::withToken($privateKey))
->setMerchantAccountId('default')
->build();
$response = $sdk->paymentMethods->detokenize(
paymentMethodId: 'ef9496d8-53a5-4aad-8ca2-00eb68334389'
);
if ($response->detokenization !== null) {
// handle response
}from gr4vy import Gr4vy
import os
with Gr4vy(
merchant_account_id="default",
bearer_auth=os.getenv("GR4VY_BEARER_AUTH"),
) as g_client:
res = g_client.payment_methods.detokenize(payment_method_id="ef9496d8-53a5-4aad-8ca2-00eb68334389")
# Handle response
print(res)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.sandbox.{id}.gr4vy.app/payment-methods/{payment_method_id}/detokenization', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://api.sandbox.{id}.gr4vy.app/payment-methods/{payment_method_id}/detokenization \
--header 'Authorization: Bearer <token>'{
"encrypted_payload": "eyJhbGciOiJSU0EtT0FFUC0yNTYiLCJlbmMiOi...",
"type": "payment-method-detokenization"
}{
"type": "error",
"code": "bad_request",
"status": 400,
"message": "Request failed validation",
"details": []
}{
"type": "error",
"code": "unauthorized",
"status": 401,
"message": "No valid API authentication found",
"details": []
}{
"type": "error",
"code": "forbidden",
"status": 403,
"message": "Request failed validation",
"details": []
}{
"type": "error",
"code": "not_found",
"status": 404,
"message": "The resource could not be found",
"details": []
}{
"type": "error",
"code": "method_not_allowed",
"status": 405,
"message": "Method Not Allowed",
"details": []
}{
"type": "error",
"code": "duplicate_record",
"status": 409,
"message": "Request failed validation",
"details": [],
"resource_id": "cdc70639-cb9c-4222-a73f-b8ce39f7821b"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}{
"type": "error",
"code": "too_early",
"status": 425,
"message": "Request failed validation",
"details": []
}{
"type": "error",
"code": "too_many_requests",
"status": 429,
"message": "Request failed validation",
"details": []
}{
"type": "error",
"code": "server_error",
"status": 500,
"message": "Request could not be processed",
"details": []
}{
"type": "error",
"code": "bad_gateway",
"status": 502,
"message": "Request could not be processed",
"details": []
}{
"type": "error",
"code": "gateway_timeout",
"status": 504,
"message": "Request could not be processed",
"details": []
}Detokenize a payment method
Retrieve the card number and expiration date of a stored card, encrypted to the merchant account’s public key. Requests are rate limited.
POST
/
payment-methods
/
{payment_method_id}
/
detokenization
C#
using RestSharp;
var options = new RestClientOptions("https://api.sandbox.{id}.gr4vy.app/payment-methods/{payment_method_id}/detokenization");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);package main
import(
"context"
"os"
gr4vygo "github.com/gr4vy/gr4vy-go"
"log"
)
func main() {
ctx := context.Background()
s := gr4vy.New(
gr4vy.WithID("example"),
gr4vy.WithServer(gr4vy.ServerSandbox),
gr4vy.WithSecuritySource(withToken),
gr4vy.WithMerchantAccountID("default"),
)
res, err := s.PaymentMethods.Detokenize(ctx, "ef9496d8-53a5-4aad-8ca2-00eb68334389", nil)
if err != nil {
log.Fatal(err)
}
if res != nil {
// handle response
}
}package hello.world;
import com.gr4vy.sdk.Gr4vy;
import com.gr4vy.sdk.models.errors.*;
import com.gr4vy.sdk.models.operations.DetokenizePaymentMethodResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws Exception {
Gr4vy sdk = Gr4vy.builder()
.id("example")
.server(AvailableServers.SANDBOX)
.merchantAccountId("default")
.securitySource(new BearerSecuritySource.Builder(privateKey).build())
.build();
DetokenizePaymentMethodResponse res = sdk.paymentMethods().detokenize()
.paymentMethodId("ef9496d8-53a5-4aad-8ca2-00eb68334389")
.call();
if (res.detokenization().isPresent()) {
System.out.println(res.detokenization().get());
}
}
}declare(strict_types=1);
require 'vendor/autoload.php';
use Gr4vy;
$sdk = Gr4vy\SDK::builder()
->setId('example')
->setServer('sandbox')
->setSecuritySource(Auth::withToken($privateKey))
->setMerchantAccountId('default')
->build();
$response = $sdk->paymentMethods->detokenize(
paymentMethodId: 'ef9496d8-53a5-4aad-8ca2-00eb68334389'
);
if ($response->detokenization !== null) {
// handle response
}from gr4vy import Gr4vy
import os
with Gr4vy(
merchant_account_id="default",
bearer_auth=os.getenv("GR4VY_BEARER_AUTH"),
) as g_client:
res = g_client.payment_methods.detokenize(payment_method_id="ef9496d8-53a5-4aad-8ca2-00eb68334389")
# Handle response
print(res)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.sandbox.{id}.gr4vy.app/payment-methods/{payment_method_id}/detokenization', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://api.sandbox.{id}.gr4vy.app/payment-methods/{payment_method_id}/detokenization \
--header 'Authorization: Bearer <token>'{
"encrypted_payload": "eyJhbGciOiJSU0EtT0FFUC0yNTYiLCJlbmMiOi...",
"type": "payment-method-detokenization"
}{
"type": "error",
"code": "bad_request",
"status": 400,
"message": "Request failed validation",
"details": []
}{
"type": "error",
"code": "unauthorized",
"status": 401,
"message": "No valid API authentication found",
"details": []
}{
"type": "error",
"code": "forbidden",
"status": 403,
"message": "Request failed validation",
"details": []
}{
"type": "error",
"code": "not_found",
"status": 404,
"message": "The resource could not be found",
"details": []
}{
"type": "error",
"code": "method_not_allowed",
"status": 405,
"message": "Method Not Allowed",
"details": []
}{
"type": "error",
"code": "duplicate_record",
"status": 409,
"message": "Request failed validation",
"details": [],
"resource_id": "cdc70639-cb9c-4222-a73f-b8ce39f7821b"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}{
"type": "error",
"code": "too_early",
"status": 425,
"message": "Request failed validation",
"details": []
}{
"type": "error",
"code": "too_many_requests",
"status": 429,
"message": "Request failed validation",
"details": []
}{
"type": "error",
"code": "server_error",
"status": 500,
"message": "Request could not be processed",
"details": []
}{
"type": "error",
"code": "bad_gateway",
"status": 502,
"message": "Request could not be processed",
"details": []
}{
"type": "error",
"code": "gateway_timeout",
"status": 504,
"message": "Request could not be processed",
"details": []
}This endpoint requires the
payment-methods.detokenization.read scope.
Detokenization is in early access and isn’t enabled by default.
To request access, contact your Gr4vy account manager.
See Detokenize a card for how to decrypt the response.Authorizations
Headers
Path Parameters
Response
Successful Response
Was this page helpful?