Rocketfuel SDK Client

1. Introduction

The Rocketfuel SDK enables quick integration of payment and verification features into your web app or site. Use it to display age verification prompts or securely process payments within your flow.

Demo: https://zkp-demo.rocketfuel.inc/

You can use the SDK:

  • Via CDN script in traditional HTML/JS projects.

  • Via npm package in React, Vue, Angular, or other frontend frameworks.

Features supported:

  • Age Verification (AGE_VERIFICATION)

  • Payment Collection (PAYIN)

2. Integration

a. Installation and import

React (or Module Bundler) Integration

npm install @rkfl/transact-client
import { RkflPlugin } from '@rkfl/transact-client';

Or add the SDK at the bottom of your page:

Using defer ensures the script loads after the HTML has been parsed. (Not mandatory).

b. Preparing Container Elements

Create HTML elements with IDs where the SDK will render widgets:

c. Initialize SDK with Plugins

Example initialization to enable AGE_VERIFICATION and PAYIN at the same time:

d. Trigger the age verification/payment modal manually

The launchAgeVerificationWidget The function is used to trigger a modal or iframe-based age verification UI. It is typically called when a user attempts to access age-restricted content or initiate an action that requires age verification, such as connecting a wallet.

The launchPaymentWidget function is used to trigger a modal or iframe-based payment interface. It is typically called when a user initiates a transaction, such as making a purchase, subscribing to a service, or completing a checkout flow. The widget handles secure payment collection.

Note: Make sure your SDK is initialized, and if you don't want to use the injected button, you can pass the inject parameter as false with the plugin object, for example:

e. Setting up user info

You can optionally provide user details before launching the widget using the setUserInfo() method. This is useful if you want to prefill user information or associate the verification with a specific refId in your system.

Note:

  1. If setUserInfo() is not called, the widget will still launch and return results normally. In this case, the user ref is automatically created and returned at the verification success response.

f. Age Verification Status Check

The sdk.verifyAgeVerification function allows the client application (e.g., browser frontend) to check the status of an age verification request by passing the auditId received from the verification flow.

It returns the same verification result object as the server-side function and can be used to unlock restricted UI elements or content.

Response:

Field
Type
Description

id

string

Unique identifier of the verification record (audit ID).

status

string

Current verification status (see Status Values below).

verifiedOn

string (ISO datetime)

Timestamp when the user was successfully verified (only available if verified).

createdAt

string (ISO datetime)

Timestamp when the verification request was created.

timezone

string

Timezone used in the verification process.

Status
Description

expired

The verification session expired before completion.

status_initiated

Age verification process has started but not yet completed.

status_verified

User successfully completed age verification.

status_failed

Age verification attempt failed.

widget_started

The verification widget was launched, but final status not yet determined.

3. Window Events

NOTE: This feature is only available when you don't use the redirect mode. i.e, your redirect : true

  • Both integrations communicate important state changes (like age verification results or payment completion) via the same standard window event messages.

  • You listen to them using the same code:

Allowed Domains Validation for PostMessage Events

  1. Define allowed domains Only production and sandbox payment domains are allowed:

  1. Validate message origin Every incoming message is checked against the allowedDomains array. Messages from untrusted origins are ignored and logged:

  • Security: Prevents scripts from unknown domains from sending messages or executing actions in your app.

  • Controlled communication: Ensures only production and sandbox payment environments can interact with your client via postMessage.

Sample Success Response for Age Verification:

Sample Event for Audit log ID

When a user initiates the age verification flow, the SDK emits a window event containing the generated audit ID.

Developers can listen for this event, store the auditId, and later use it with the verifyAgeVerification function to check the user’s verification status.

Event data

Sample Success Response for Payment Confirmation:

Every Rocketfuel SDK plugin you use—whether initialized through a <script> tag or imported as a JavaScript module—will send events to the window when a user completes a step (age check, checkout, etc.), using the same event types and payloads. You can write your logic and UI reactions for these events in a single, unified way across your full app.

Additional Integration Tips

  • Order Management: Store cart/order details in localStorage or your app state, and use SDKs prepareOrder(uuid) (for PAYIN) with a backend-generated order UUID to track transactions.

  • Backend Invoice Generation: Call your backend API to generate an invoice/order UUID, then pass it to sdk.prepareOrder(uuid) to link the frontend SDK with the backend order data.

  • Redirect Flow: Optionally enable redirect: true in SDK options for redirect-based flows instead of inline widgets.

  • Security:

    • Keep clientId and merchantId secure, do not expose sensitive data publicly.

    • Only accept window messages from trusted origins.

Summary of Important Fields

  1. feature : (required) What plugin to load, e.g., "AGE_VERIFICATION", "PAYIN"

  2. containerId: (optional) DOM element ID where the widget will be rendered. default: sdk-buttons-container

  3. clientId : (required) Your Rocketfuel client ID.

  4. merchantId: (required) Merchant ID (required for payments).

  5. environment :(optional) 'production', 'sandbox' default: 'production'.

  6. redirect: (optional) Optional boolean to enable redirect flows. default: true

Last updated

Was this helpful?