POST
/
payment-methods
/
{payment_method_id}
/
payment-service-tokens
C#
using Gr4vy;
using Gr4vy.Models.Components;

var sdk = new Gr4vySDK(
    id: "example",
    server: SDKConfig.Server.Sandbox,
    bearerAuthSource: Auth.WithToken(privateKey),
    merchantAccountId: "default"
);

var res = await sdk.PaymentMethods.PaymentServiceTokens.CreateAsync(
    paymentMethodId: "ef9496d8-53a5-4aad-8ca2-00eb68334389",
    paymentServiceTokenCreate: new PaymentServiceTokenCreate() {
        PaymentServiceId = "fffd152a-9532-4087-9a4f-de58754210f0",
        RedirectUrl = "https://dual-futon.biz",
    }
);

// handle response
{
  "type": "payment-service-token",
  "id": "07e70d14-a0c0-4ff5-bd4a-509959af0e4d",
  "approval_url": "https://gr4vy.app/redirect/12345",
  "payment_method_id": "ef9496d8-53a5-4aad-8ca2-00eb68334389",
  "payment_service_id": "fffd152a-9532-4087-9a4f-de58754210f0",
  "status": "succeeded",
  "token": "pm_12345",
  "created_at": "2013-07-16T19:23:00.000+00:00",
  "updated_at": "2013-07-16T19:23:00.000+00:00"
}
This endpoint requires the payment-methods.write scope.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Headers

x-gr4vy-merchant-account-id
string | null

The ID of the merchant account to use for this request.

Examples:

"default"

Path Parameters

payment_method_id
string<uuid>
required

The ID of the payment method

Examples:

"ef9496d8-53a5-4aad-8ca2-00eb68334389"

Body

application/json
payment_service_id
string<uuid>
required

The ID of the payment method to use.

Examples:

"fffd152a-9532-4087-9a4f-de58754210f0"

redirect_url
required

The redirect URL to redirect a buyer to after they have authorized the payment method.

Examples:

"https://example.com/callback"

security_code
string | null

The 3 or 4 digit security code often found on the card. This often referred to as the CVV or CVD.

Required string length: 3 - 4
Examples:

"123"

Response

Successful Response

id
string<uuid>
required

The ID for the payment service token.

Examples:

"07e70d14-a0c0-4ff5-bd4a-509959af0e4d"

payment_method_id
string<uuid>
required

The ID of the payment method used to generate this token

Examples:

"ef9496d8-53a5-4aad-8ca2-00eb68334389"

payment_service_id
string<uuid>
required

The ID of the payment method used to generate this token.

Examples:

"fffd152a-9532-4087-9a4f-de58754210f0"

status
enum<string>
required

The state of the payment service token.

Available options:
processing,
buyer_approval_required,
succeeded,
failed,
paused
Examples:

"succeeded"

created_at
string<date-time>
required

The date and time when this payment service token was first created in our system.

Examples:

"2013-07-16T19:23:00.000+00:00"

updated_at
string<date-time>
required

The date and time when this payment service token was last updated in our system.

Examples:

"2013-07-16T19:23:00.000+00:00"

type
string
default:payment-service-token

Always payment-service-token.

Allowed value: "payment-service-token"
Examples:

"payment-service-token"

approval_url
string | null

The optional URL that the buyer needs to be redirected to to further authorize the token creation.

Examples:

"https://gr4vy.app/redirect/12345"

token
string | null

The token value. Will be present if succeeded.

Required string length: 1 - 300
Examples:

"pm_12345"