Skip to main content

Overview

The registerIntent() method registers a payment intent (mandate). Internally it maps the merchant to an MCC code, generates a card network mandate, and prompts the user to approve via passkey. Returns an intentId that the AI App uses to invoke purchases — immediately, on a schedule, or recurring.
Requires Passkey: This method triggers biometric/device authentication to ensure the user explicitly authorizes the purchase.

Method Signature

prava.registerIntent(params: RegisterIntentParams): Promise<RegisterIntentResult>

Parameters

params
RegisterIntentParams
required

Return Value

result
RegisterIntentResult

Example

import { PravaSDK } from '@prava-sdk/core';

const prava = new PravaSDK({ publishableKey: 'pk_live_xxx' });

// User says: "Order me food from Uber Eats every week"
const intent = await prava.registerIntent({
  cardId: 'enr_abc123',
  merchant: 'Uber Eats',
  amount: 25.00,
  currency: 'USD',
  itemCount: 1,
  productUrl: 'https://ubereats.com/order/xyz',
  useLimit: 5,
  frequency: 'weekly',
});

console.log(intent.intentId);  // "int_m7kx9..."
console.log(intent.status);    // "approved"
console.log(intent.mcc);       // "5812" (Eating Places, Restaurants)

Under the Hood

When you call registerIntent():
1

Merchant Resolution

SDK resolves the merchant name → MCC code via Prava’s merchant directory.
2

Mandate Generation

A card network mandate is generated with the specified constraints (amount, merchant, frequency, limits).
3

Passkey Prompt

The user’s device triggers a passkey prompt (WebAuthn) for biometric/device confirmation.
4

Mandate Activation

On approval, the mandate is activated with the card network.
5

Result

The intentId is returned — your AI App stores this to invoke later.

Passkey Authentication Flow

Error Handling

CodeCauseResolution
PASSKEY_REJECTEDUser declined the passkey promptAllow retry
PASSKEY_UNAVAILABLEDevice doesn’t support WebAuthnInform user
CARD_NOT_FOUNDCard ID is invalid or removedRefresh card list
MANDATE_VIOLATIONAmount/merchant doesn’t match constraintsCheck params

Best Practices

Use Limits and Frequency

// ✅ One-time purchase
await prava.registerIntent({
  cardId, merchant: 'Amazon', amount: 29.99, currency: 'USD',
  useLimit: 1,
});

// ✅ Weekly recurring (max 4 times)
await prava.registerIntent({
  cardId, merchant: 'DoorDash', amount: 50.00, currency: 'USD',
  useLimit: 4, frequency: 'weekly',
});

// ✅ Open-ended with expiry
await prava.registerIntent({
  cardId, merchant: 'Spotify', amount: 9.99, currency: 'USD',
  frequency: 'monthly',
  expiresAt: '2027-01-01T00:00:00Z',
});
For instant “Buy Now” flows where you don’t need to store a mandate for later, use registerAndInvokeIntent() instead.

Next Steps