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.
2

Capture Card Data

Use your own native UI components to collect the card number, expiry date, and CVV.
3

Vault via SDK

Pass the card data and checkout session ID to the native SDK.
4

Process Payment

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

Implementation

1. Initialize the SDK

First, ensure the SDK is initialized with your Gr4vy ID and the correct environment.
import Gr4vy

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

2. Vault card details

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)")
    }
}

3. Backend Authorization

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]"
    },
    ...
}