SDK Reference
Client-side SDKs that pair with the RAMFi API. SDKs handle the sensitive, user-facing steps so account credentials and raw card numbers never touch your application. Your backend then operates on the tokens and linked resources they produce.
Four SDKs are available: End User Agreement for hosted consent capture during onboarding, Bank Connection for open-banking account linking, PayPal Connect for linking a PayPal account for disbursement payouts, and Card Capture for tokenising debit card details — card capture is not enabled yet.
Installation
Basic Usage
Configuration Options
| Parameter | Type | Description |
|---|---|---|
| userId | string | Unique identifier for the user (matches clientID from NewClient endpoint). |
| onError | function | Error handler callback: function(error). |
| Callback | Parameters | Description |
|---|---|---|
| onAgreementAccepted | result | Called when the user accepts the agreement: function(result). |
| onAgreementDeclined | result | Called when the user declines the agreement: function(result). |
Result Structure
The open() method returns a Promise that resolves with a result object.
SDK Methods
| Method | Description |
|---|---|
| sdk.init(config) | Initializes the SDK with your configuration. Returns a Promise that resolves when initialization is complete. Must be called before calling open(). |
| sdk.open() | Displays the end user agreement dialog. Returns a Promise that resolves with a result object when the user accepts, declines, or an error occurs. The dialog is modal and blocks user interaction until a choice is made. |
| sdk.destroy() | Cleans up and destroys the SDK instance. Removes event listeners, clears DOM elements, and frees up resources. Important for SPAs to prevent memory leaks. |
Integration Pattern: Client Onboarding
Create Client
Call POST /api/FE/NewClient to create the client account.
Initialize Agreement SDK
Use the returned clientID as the userId parameter.
Present Agreement
Call sdk.open() to display the terms and conditions.
Handle Acceptance
If the user accepts, proceed with bank connection or the next onboarding step.
Handle Decline
If the user declines, display a message and optionally prevent further access.
Continue Onboarding
Proceed with the Bank Connection SDK or other integration steps.
Best Practices
onError and onLinkExit) are notification-only and do not receive any data parameters.
Quick Start
Include the SDK
Add the SDK stylesheet and script to your HTML page.
Replace {environment} and {version} with the values provided during onboarding.
Initialize and Open
Initialize the SDK with your configuration and open the bank connection widget.
Configuration Options
| Parameter | Type | Description |
|---|---|---|
| clientToken | Guid | Your user's unique ID (returned after the user is created). |
| onError | function | Error handler callback: function(error). |
| Callback | Parameters | Description |
|---|---|---|
| onLinkExit | exitData | Called when the user exits the connection flow: function(exitData). |
| onLinkedDefaultAccount | none | Called when a default account is selected by the user (notification only). |
Callback Reference
Called when an error occurs during initialization or the connection process. The error object has the following properties:
| Property | Description |
|---|---|
| error.code | Error code (see Error Codes below). |
| error.message | Human-readable error message. |
| error.details | Additional error details (optional). |
Common Error Codes: INIT_ERROR (SDK initialization failed), WIDGET_ERROR (error in bank selection widget), NO_TOKEN (missing or invalid clientToken), Error_Saving_Banking_Details (failed to save banking details to RAMFi servers).
Called when the user exits the bank connection flow, either successfully or by cancellation. The exitData object has the following properties:
| Property | Description |
|---|---|
| exitData.status | SUCCESS, ACTION_ABANDONED, or FAILED. |
| exitData.userId | RAMFi user identifier. |
| exitData.reason | bank_connected, user_cancelled, terms_declined, connection_failed, or api_save_failed. |
Note: Banking details (account/routing numbers) are not included in exitData, they are server-side only.
Parameters: none (notification only). Called when a default account is selected by the user during the connection flow.
SDK Methods
| Method | Description |
|---|---|
| sdk.init(config) | Initializes the SDK with your configuration. Returns a Promise that resolves when initialization is complete. Must be called and awaited before calling any other SDK methods (especially open()). |
| sdk.open() | Opens the bank connection widget UI. Call after successful initialization, typically in response to a user action. Returns a Promise that resolves when the widget closes. |
| sdk.destroy() | Cleans up and destroys the SDK instance. Removes event listeners and frees up resources. Important for Single Page Applications (SPAs). |
Integration Pattern: New Client Onboarding
Create Client
Call POST /api/FE/NewClient to create the client account (without bank details).
Initialize SDK
Use the returned clientID as the clientToken parameter.
Connect Bank
User completes bank connection via the SDK widget.
Verify Connection
onLinkExit fires with status: 'SUCCESS', banking details are saved server-side.
Upload ACH Agreement
Call POST /api/FE/AddDocument to upload the signed ACH authorization.
Begin Transactions
Client is ready for ACH drafts using POST /api/FE/AddClientFunds.
Best Practices
cardId token for use in subsequent API calls.
Quick Start
Generate a Short-Lived Token (Backend)
On your server, call POST /api/FE/ProvisionToken to generate a short-lived bearer token. Pass this token to your browser via your own authenticated session, never expose your Main Token client-side.
Include the SDK
Add the SDK stylesheet and script to your HTML page.
Initialize and Open
Initialize with the short-lived bearer token and the clientID. The SDK renders a PCI-compliant hosted input form, card data never touches your page.
cardId in the result is a permanent token for this card. Store it in your system and use it for all future PullFromCard and PushToCard calls.Configuration Options
| Parameter | Type | Description |
|---|---|---|
| bearerToken | string | Short-lived bearer token generated on your backend via POST /api/FE/ProvisionToken. Single-use and time-limited. Never hardcode or expose your Main Token. |
| clientID | string (UUID) | The client's unique ID, returned by NewClient. Binds the captured card to this client account. |
| onError | function(error) | Error handler callback. Always implement this to surface initialization and capture failures. |
| Callback | Parameters | Description |
|---|---|---|
| onCardCaptured | none | Notification-only. Called when card data is successfully captured and tokenized server-side. No card data is passed to this callback. |
| onLinkExit | exitData |
Called when the user exits the card entry flow. See Exit Data Properties below. |
sdk.open() Result Object
onError. Error Codes
| Error Code | Description |
|---|---|
| INIT_ERROR | SDK failed to initialize. Check network, bearerToken, and clientID. |
| NOT_INITIALIZED | open() was called before init() completed. |
| WIDGET_ERROR | Error occurred within the card capture widget. |
| INVALID_TOKEN | Missing, malformed, or expired bearerToken. Generate a new token via ProvisionToken. |
| TOKEN_EXPIRED | Bearer token expired during the session. Re-fetch from your backend and re-init. |
| CARD_INELIGIBLE | Card type not supported for pull/push operations (e.g. credit card, prepaid). |
| CONNECTION_ERROR | Network or API failure during tokenization. |
SDK Methods
Initializes the SDK. Returns a Promise that resolves when initialization is complete. Must be awaited before calling open().
Renders the card entry widget. Returns a Promise resolving with a result object containing status and, on success, the cardId token. Call after successful init, typically on a user action.
Cleans up event listeners and DOM elements. Required for Single Page Applications (SPAs), call on component unmount or page navigation to prevent memory leaks.
React / SPA Integration
Integration Pattern: Card Onboarding
Create Client
Call POST /api/FE/NewClient to create the client account and obtain the clientID.
Generate Short-Lived Token
On your backend, call POST /api/FE/ProvisionToken to generate a short-lived bearer token. Pass it to the browser via your authenticated session.
Present Agreement
Use the End User Agreement SDK to capture consent before collecting card details.
Initialize Card Capture SDK
Pass the bearerToken and clientID. Await init() before calling open().
Tokenize Card
User enters card details in the hosted widget. On success, the cardId token is returned to your app. Store this securely.
Transact
Use the cardId token in PullFromCard (collect payment) or PushToCard (send funds) as needed.
Best Practices
last4 and cardBrand so users can identify saved cards.open() before init() completes will fail with NOT_INITIALIZED.sdk.destroy() when navigating away in single-page apps to prevent memory leaks.CARD_INELIGIBLE.The RAMFi PayPal Connect SDK opens the PayPal login, processes the authorisation, and validates the connection with RAMFi’s backend, then notifies your application of the result via a callback. On success you receive a RAMFi transactionId that your backend passes to WalletTransfer to initiate the payout.
sdk.open() must be called directly inside a user gesture such as a button click — never from a timer or async callback.Prerequisites
- A RAMFi user ID for the authenticated user — provided by RAMFi when the user account is created.
- A backend endpoint that returns a fresh
tokenandtotpfrom RAMFi’s auth service for each SDK session. - Pages served over HTTPS — PayPal OAuth does not work on plain HTTP.
Quick Start
Include the SDK
Add the SDK script to your HTML page.
Initialise the SDK
Create an SDK instance and call init() with the RAMFi user ID and event callbacks. Do this once when the page loads.
Open the PayPal flow on button click
When the user clicks Connect, fetch a fresh token and totp from your backend and pass them to sdk.open(). Fetch these immediately before each call — do not cache them between sessions.
User Flow
| Step | What happens |
|---|---|
| Click Connect | User clicks the connect button — the SDK opens a centered popup immediately. |
| Loading screen | The popup shows a “Connecting to PayPal…” spinner while the session is prepared. |
| PayPal login | The popup navigates to the PayPal login page. |
| Authorise | User logs in to PayPal and grants permission to link their account. |
| Connecting screen | The popup shows a connecting screen while RAMFi validates the authorisation. |
| Popup closes | The popup closes automatically once validation is complete. On mobile browsers where auto-close is blocked, a Return to app button is shown instead. |
| Result | The onLinkExit callback fires with the outcome. |
Configuration Reference
| Parameter | Type | Required | Description |
|---|---|---|---|
| userId | string | REQUIRED | The RAMFi user ID of the account being linked. Obtain it from your backend after the user authenticates with RAMFi. |
| onError | function | REQUIRED | Called when an SDK-level error occurs. See Callback Reference below. |
| onLinkExit | function | OPTIONAL | Called when the PayPal flow ends for any reason — success, failure, or the user closed the popup. |
Must be called directly from a user gesture (button click). Fetch credentials from your backend immediately before each call.
| Parameter | Type | Description |
|---|---|---|
| token | string | RAMFi API bearer token for the authenticated user. Obtain it from your backend — never hardcode it in client-side code. |
| totp | string | One-time security code generated by your backend using the RAMFi-provided secret. Fetch fresh for each open() call — do not reuse across sessions. |
Callback Reference
Called when the PayPal flow ends for any reason. Check result.status: SUCCESS (linked and validated), FAILED (could not be validated), or ACTION_ABANDONED (user closed the popup without completing).
| Property | Type | When present | Description |
|---|---|---|---|
| status | string | Always | 'SUCCESS' | 'FAILED' | 'ACTION_ABANDONED' |
| transactionId | string | SUCCESS, FAILED | The RAMFi transaction ID for this linking session. On SUCCESS, pass it to your backend to initiate a WalletTransfer. |
| errorMessage | string | FAILED | Human-readable reason the connection failed. Safe to display directly to the user (e.g. “Your name on PayPal doesn’t match our records.”). |
Called when an SDK-level error occurs before or during the flow. The error object has a code and a message.
| Code | Cause |
|---|---|
OPEN_ERROR | Failed to start the PayPal session — check that the credentials are valid. |
POPUP_ERROR | An unexpected error occurred in the popup. |
STATE_ERROR | The response from PayPal could not be verified — do not retry automatically. |
STATE_MISMATCH | The response from PayPal does not match the initiated session — possible replay attack. |
VALIDATE_ERROR | RAMFi could not validate the PayPal authorisation. |
TIMEOUT_ERROR | The session expired before the flow could complete — ask the user to try again. |
Complete Example
React Integration Example
Required Backend API Calls
The SDK handles the PayPal OAuth flow entirely, but your server must also call these RAMFi backend endpoints.
Call this before initialising the SDK. If userRegistered is true, skip the SDK flow and proceed directly to WalletTransfer using the returned transactionId.
| Parameter | Location | Type | Description |
|---|---|---|---|
| userId | Route | Guid | The RAMFi user ID. |
| paymentType | Route | int | Payment type — use 6 for PayPal. |
Response — WalletInformation
| Property | Type | Description |
|---|---|---|
| userRegistered | boolean | true if the user has an active, linked PayPal transfer method on file. |
| transactionId | string | The existing portal request token — pass to WalletTransfer if userRegistered is true to skip the SDK flow. |
Your backend must obtain a fresh token and totp for each SDK session — the standard RAMFi auth values: obtain the bearer token via the authentication flow and generate the TOTP from the RAMFi-provided secret.
After onLinkExit fires with status: 'SUCCESS', your backend calls WalletTransfer to initiate the disbursement.
| Parameter | Location | Type | Description |
|---|---|---|---|
| campaignId | Route | Guid | The RAMFi campaign identifier for this disbursement. |
| disbursementToken | Route | Guid | The user’s disbursement access token. |
| transactionId | Route | string | The transactionId received from onLinkExit on SUCCESS. |
| amount | Body | decimal | Optional. Override disbursement amount; if omitted, the amount on the disbursement record is used. |
Integration Pattern: PayPal Disbursement Onboarding
Get credentials
Your backend fetches a fresh token and totp for the user’s RAMFi session.
Initialise SDK
Call sdk.init() with the user’s RAMFi user ID and callbacks — once per page load.
Connect PayPal
On button click, pass the fresh credentials to sdk.open().
Handle result
onLinkExit fires — check result.status.
Initiate transfer (SUCCESS only)
Your backend calls WalletTransfer with result.transactionId.
Show outcome
Display confirmation or error based on the WalletTransfer response.
Best Practices
sdk.open() directly from a click handler — browsers block popups opened outside a user gesture.token and totp immediately before each sdk.open(); never cache or reuse them across sessions.onLinkExit with status: 'FAILED' and errorMessage: 'Session expired. Please try again.'sdk.destroy() on unmount to clean up listeners.result.transactionId with WalletTransfer only when status is SUCCESS.