The invokeIntent() method retrieves payment credentials (tokenized card number, expiration, and dynamic cryptogram) from a previously registered intent. These credentials are single-use and scoped to the specific merchant and amount.
No additional authentication required: If the intent was already authorized with Passkey during registration, invoking it does not trigger another authentication prompt.
// User authorizes purchase for laterconst intent = await prava.registerIntent({ cardId: 'card_123', merchantName: 'Grocery Store', declineThreshold: { amount: 150, currency: 'USD' }, effectiveUntilTime: new Date('2024-12-31').toISOString(), // Valid until end of day consumerPrompt: 'Grocery delivery up to $150'});// Store intentId in databaseawait db.schedules.create({ userId: 'user_123', intentId: intent.intentId, scheduledFor: '2024-12-31T18:00:00Z'});// Later, when scheduled time arrivesconst credentials = await prava.invokeIntent(intent.intentId);await placeGroceryOrder(credentials);
Never log or store credentials: The payment token and DAVV are sensitive. Never write them to logs, databases, or error messages.
Credentials are merchant-specific: The network validates that the merchant receiving the payment matches the merchantName/merchantUrl from the intent. Mismatches will be declined.
30-minute window: After invoking, you have 30 minutes to use the credentials. Plan your checkout automation to complete within this time.
In sandbox mode, you can invoke intents multiple times for testing:
Copy
const prava = new PravaSDK({ publishableKey: 'pk_sandbox_your_key', environment: 'sandbox' // Allows multiple invokes});// Sandbox: Can invoke multiple timesconst credentials1 = await prava.invokeIntent(intentId);const credentials2 = await prava.invokeIntent(intentId); // Works in sandbox// Production: Second invoke would fail with CREDENTIALS_ALREADY_USED
// Check if credentials are still validfunction isCredentialValid(credentials: PaymentCredentials) { const generatedAt = new Date(credentials.generatedAt); const expiresAt = new Date(generatedAt.getTime() + 30 * 60 * 1000); // 30 min return new Date() < expiresAt;}// Use credentials before expirationconst credentials = await prava.invokeIntent(intentId);if (isCredentialValid(credentials)) { await automateCheckout(credentials);} else { console.error('Credentials expired before use'); // Re-invoke if within intent validity period}