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
Parameter | Type | Required | Description |
---|---|---|---|
projectId | string | Yes | The project id that owns the purchase intent |
purchaseIntentId | string | Yes | The 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
Property | Type | Description |
---|---|---|
id | string | The purchase intent id. |
status | string | The purchase intent status: active , verify or unavailable . |