- Events go from the widget to your app. Subscribe with
sdk.on(). - Commands go from your app to the widget. Send them with
sdk.send().
Subscribing
sdk.on(eventType, callback) returns the instance, so calls chain. sdk.off(eventType, callback) unsubscribes and takes the same forms.
Events
Use theRampnowEventType enum:
status and paymentStatus use the same values as the API and webhooks. See Order Status.
CryptoTxnInfo
Available in ORDER_CREATED and ORDER_COMPLETED payloads:
Example: full event handling
Commands
sdk.send(commandType, payload) sends a command to the widget iframe and returns the instance. Use the RampnowCommandType enum.
Example: submit a transaction hash from your wallet
On a sell order, if your wallet sends the crypto for the user, pass the hash to the widget so it can match the transfer:Next steps
Webhooks
Confirm order status on your backend
Sandbox Testing
Run every order outcome before going live