onramp-payments-sdk
v1.0.50
Published
SDK for payments iframe
Readme
How to install
Run this command to install this package; it will install the latest version of the package
npm install onramp-payments-sdkHow to import it
After installing this package, now import it where you want to use it.
import PaymentsSDK from 'onramp-payments-sdk'How to invoke the SDK to render the widget
Template
This is the container div that holds the widget
<div id="onramp-payments-sdk"> </div>JS Part
Write the following method and provide the necessary parameters like containerId, token, and environment
const openSdk = () => {
const token = '' // Token you got from the server side
const containerId = 'onramp-payments-sdk' //keep it same; if you want to change it, change in the template (container holding the widget) as well
const environment = '' // we have two environments right now, `sandbox` and `production`
const payload = {
token,
environment,
containerId,
}
sdkInstance = new PaymentsSDK(payload)
sdkInstance.onCloseLoader(() => {
// If the host has a loader, then it must be stopped from here
//This is called when the widget is fully ready
})
sdkInstance.onClose(() => {
// This is the callback for unmounting the widget.
})
sdkInstance.onSuccess((data) => {
// When the transaction is successful, this method will be triggered as a callback
})
sdkInstance.onError((error) => {
// This callback will be invoked when an error occurs.
})
sdkInstance.init() // This is the method that renders the widget.
}
