Verify Purchase Intent

The verifyPurchaseIntent function handles payment verification and processing workflows. This function will start all of the consent flows (2FA and Passkey) to ensure a payment method is properly confirmed to allow full access to all credential types.

Usage with Hooks

verifyPurchaseIntent

Hook for managing purchase intent verification.

import { useBasisTheory } from '@btai/react-sdk';
 
function VerificationComponent() {
  const { verifyPurchaseIntent } = useBasisTheory();
 
  const handleVerify = async () => {
    try {
      const result = await verifyPurchaseIntent(projectId, purchaseIntentId);
      console.log('Verification result:', result);
    } catch (error) {
      console.error('Verification failed:', error);
    }
  };
 
  return (
    <button onClick={handleVerify}>
      Verify Purchase Intent
    </button>
  );
}

Direct SDK Examples

import { btAi } from '@btai/js-sdk';
 
// ... get signed jwt from your backend
 
// initialize sdk
const btAi = await btAi.init(jwt);
const purchaseIntent = verifyPurchaseIntent("project_1234", "purchase_intent_1234");

Parameters

ParameterTypeRequiredDescription
projectIdstringYesThe project id that owns the purchase intent
purchaseIntentIdstringYesThe ID of the purchase intent to verify

Return Value

Returns a Promise that resolves to a PurchaseIntentResult object:

{
  "id": "46c029d2-485a-4928-83b5-4326c4866722",
  "status": "active",
}

Response Properties

PropertyTypeDescription
idstringThe purchase intent id.
statusstringThe purchase intent status: active, verify or unavailable.