Cashier SDK
Overview
The Cashier SDK is a JavaScript library that enables you to embed a payment/cashier interface into your web application.
Installation
Include the Cashier SDK script in your HTML file:
<script src="https://stage.papaya.ninja/v2/js/cashier.js?v=X.X.X"></script>Replace X.X.X with the desired version number.
The SDK will be available globally as window.Cashier .
Rendering Modes
The Cashier SDK supports two rendering modes that you can specify during initialization:
Direct Mode (Default)
In direct mode, the cashier interface is rendered directly into your DOM. The cashier's HTML, CSS, and JavaScript are injected and executed in your page's context. This means:
DOM Manipulation: The cashier has full access to your page's DOM and can directly manipulate elements. CSS styles are loaded into your document head, and components are rendered as native DOM elements within your container.
Security: Since code executes in the same context as your application, there's no isolation boundary. The cashier shares the same JavaScript execution environment and has access to your page's window object and variables.
iFrame Mode
In iframe mode, the cashier interface is loaded inside an iframe element. The cashier runs in a completely separate browsing context. This means:
DOM Manipulation: The cashier's DOM is completely isolated within the iframe. It cannot directly access or modify your page's DOM. Communication happens through the postMessage API. The iframe automatically resizes based on content.
Security: The iframe provides a strong security boundary. The cashier code cannot access your page's JavaScript variables, cookies (if cross-origin), or localStorage. This is ideal when loading the cashier from a different domain or when you need strict isolation.
Step-by-Step Integration
Send Events
Trigger actions in the cashier by sending events:
For a complete list of available methods, see the API Reference section.
API Reference
Methods
Cashier.Init(config, rootElement)
Cashier.Init(config, rootElement)Initializes the Cashier SDK and prepares it for display.
Parameters:
config
Object
Configuration object
config.url
string
Base URL of the cashier application
config.renderMode
string
Rendering mode: "direct" or "iframe". Default: "direct"
rootElement
HTMLElement
DOM element where the cashier will be mounted
Returns: Promise<void> - Resolves when initialization is complete
Example:
Cashier.Display(params)
Cashier.Display(params)Displays the cashier interface with specified parameters.
Parameters:
params.key
string
Session key for the cashier
params.balance
number/string
User's current balance
params.header
boolean
Show header. Default: false
params.nav
boolean
Show navigation. Default: false
params.lang
string
Language code (e.g., "en", "es")
params.mode
string
Display mode: "deposit" (default), "withdraw", "saved_methods", or "buy_crypto"
params.force_open_method
Object
Force specific opening method and payment group
params.force_open_method.type
string
Method type: "deposit" or "withdraw"
params.force_open_method.pg
number
Payment Group ID
params.process_crypto
boolean
Enable crypto processing
params.hideBuyCryptoNavigation
boolean
Hide buy crypto navigation
Returns: Promise<void> — Resolves when display is complete
Example:
Cashier.UpdateBalance(balance)
Cashier.UpdateBalance(balance)Updates the displayed balance in the cashier.
Parameters:
balance
Object
Balance information
balance.amount
number
Balance amount
balance.currency
string
Currency code (e.g., "USD")
Returns: void
Example:
Cashier.RouterPushBack()
Cashier.RouterPushBack()Navigates back in the cashier's internal router.
Parameters: None
Returns: void
Example:
Cashier.OpenDepositPage()
Cashier.OpenDepositPage()Opens the deposit page in the cashier.
Parameters: None
Returns: void
Example:
Cashier.OpenWithdrawPage()
Cashier.OpenWithdrawPage()Opens the withdraw page in the cashier.
Parameters: None
Returns: void
Example:
Cashier.OpenBuyCryptoPage()
Cashier.OpenBuyCryptoPage()Opens the buy crypto page in the cashier.
Parameters: None
Returns: void
Example:
javascript
Cashier.Remove()
Cashier.Remove()Removes the cashier from the DOM and cleans up all event listeners.
Parameters: None
Returns: void
Example:
Cashier.on(event, callback)
Cashier.on(event, callback)Subscribes to a cashier event.
Parameters:
event
string
Event name (see Events)
callback
Function
Callback function to handle the event
Returns: Function - Unsubscribe function
Example:
Events
The Cashier SDK emits various events that you can subscribe to:
init
Fired when cashier initialization is complete
{ timestamp: string, version: string, displayTimestamp: string, mode: string }
resize_iframe
Fired when iframe needs to be resized (iframe mode only)
{ height: number }
change_header_title
Fired when header title changes
`{ title: string, canGoBack: boolean, methodPG: number \
deposit_page_open
Fired when deposit page is opened
{} (empty object)
withdraw_page_open
Fired when withdraw page is opened
{} (empty object)
buy_crypto_page_open
Fired when buy crypto page is opened
{} (empty object)
payin_form_open
Fired when pay-in form is opened
{} (empty object)
payout_form_open
Fired when payout form is opened
{} (empty object)
amount_change
Fired when amount value changes
{ amount: number, currency: string }
pay_with_crypto
Fired when user chooses to pay with crypto
{ amount: number, smart_contract_currency: string, smart_contract: string, address: string, coinAmount: number }
Examples
React Integration
Vanilla JavaScript Example (Direct Mode)
Version Information
Current SDK Version: 1.0.0
The SDK automatically detects its version from the script URL query parameter or defaults to the latest version.
Last updated
