Skip to main content
Vaulting allows you to securely capture and store card details within a Checkout Session without handling 3DS authentication immediately. This is useful for simple payment flows or scenarios where you want to tokenize a card for later use.

Installation

The official Gr4vy mobile SDKs are available for both iOS and Android platforms. Add them to your project to get started.
The official Gr4vy Swift SDK is available via Swift Package Manager.
  1. In Xcode, select File -> Add Packages
  2. Enter the repository URL: https://github.com/gr4vy/gr4vy-swift
  3. Select the version or branch you wish to use.

The vaulting flow

1

Initialize Checkout Session

Create a checkout session on your backend with the transaction details to store the vaulted card data.
2

Initialize the SDK

Initialize the SDK with your Gr4vy ID, then use your own native UI components to collect the card number, expiry date, and CVV.
3

Vault via SDK

Pass the collected card data and checkout session ID to the native SDK to securely vault the card without 3DS authentication.
4

Process Payment

Use the vaulted session ID on your backend to create a transaction or store the card for future use.

Implementation

1. Initialize Checkout Session

First, create a checkout session on your backend. This session stores the vaulted card data.
using Gr4vy;
using Gr4vy.Models.Components;

var sdk = new Gr4vySDK(
    merchantAccountId: "default",
    bearerAuth: "<YOUR_BEARER_TOKEN_HERE>"
);

var checkoutSession = await sdk.CheckoutSessions.CreateAsync();

// Return the session ID to your mobile app
var sessionId = checkoutSession.CheckoutSession.Id;
Pass this session ID to your mobile app so it can be used in the next step.

2. Initialize the SDK

In your mobile app, initialize the SDK with your Gr4vy ID and the correct environment. Then use your own UI components to collect the card number, expiry date, and CVV.
import Gr4vy

let gr4vy = Gr4vy(
    gr4vyId: "your-gr4vy-id",
    environment: .sandbox
)

3. Vault via SDK

Use the tokenize method to send the card details to Gr4vy. In this basic flow, set the authenticate parameter to false to skip the 3DS process.
// Create card data
let cardData = Gr4vyCardData(
    paymentMethod: .card(CardPaymentMethod(
        number: "4111111111111111",
        expirationDate: "12/25",
        securityCode: "123"
    ))
)

// Tokenize card data into checkout session
do {
    try await gr4vy.tokenize(
        checkoutSessionId: "session_123",
        cardData: cardData
    )
    print("Payment method tokenization complete")
} catch {
    print("Error tokenizing payment method: \(error)")
}

// Completion handler
gr4vy.tokenize(
    checkoutSessionId: "session_123",
    cardData: cardData
) { result in
    switch result {
    case .success:
        print("Payment method tokenization complete")
    case .failure(let error):
        print("Error tokenizing payment method: \(error)")
    }
}

4. Process payment

Once the SDK returns a success result, your backend can use that checkout_session_id to create a transaction. Since 3DS was skipped, this can be processed as a standard non-3DS transaction.
POST /transactions
{

    "amount": 1800,
    "currency": "EUR",
    "country": "DE",
    "intent": "capture",
    "payment_method": {
        "method": "checkout-session",
        "id": "[checkout-session-id]"
    },
    ...
}