Skip to main content
The Transfer class emits events during the payment flow. Use on() and off() to subscribe and unsubscribe.

Events

complete

Fired when the payment completes successfully. The handler receives a DepositResult.
transfer.on('complete', (result: DepositResult) => {
  console.log('Transfer ID:', result.transfer.id);
  console.log('Status:', result.transfer.status);
});

error

Fired when the payment flow fails. The handler receives a TransferError.
transfer.on('error', (error: TransferError) => {
  console.error('Transfer failed:', error.code, error.message);
});

close

Fired when the transfer iframe is dismissed (user tapped backdrop, pressed Escape, or the flow was closed programmatically).
transfer.on('close', () => {
  console.log('Transfer closed');
});

status-change

Fired on every status transition. The handler receives the new TransferStatus.
transfer.on('status-change', (status: TransferStatus) => {
  console.log('Status:', status);
});

Status transitions

StatusMeaning
idleNo active flow. Initial state and state after close() or destroy().
signer-loadingThe SDK is calling the merchant signer endpoint.
iframe-activeThe hosted flow iframe is open. Waiting for the user to complete payment.
completedTransfer succeeded. result is available.
errorSomething failed. error is available.

Subscribing and unsubscribing

const onComplete = (result: DepositResult) => {
  updateUI(result);
};

// Subscribe
transfer.on('complete', onComplete);

// Unsubscribe
transfer.off('complete', onComplete);
Both on() and off() return this for chaining:
transfer
  .on('complete', handleComplete)
  .on('error', handleError)
  .on('close', handleClose);

Lifecycle management

close()

Closes the transfer iframe and resets status to idle. Fires the close event. Does not destroy the instance — you can call requestDeposit() again.
transfer.close();

destroy()

Closes the iframe, removes all event listeners, and marks the instance as destroyed. Subsequent calls to requestDeposit() will reject with INVALID_REQUEST. Call this when the component unmounts or the page unloads.
// Vanilla JS — on page unload
window.addEventListener('beforeunload', () => transfer.destroy());

// React — handled automatically by useBlinkTransfer
Always call destroy() when the transfer is no longer needed to prevent memory leaks from lingering event listeners.

React lifecycle

The useBlinkTransfer hook manages the Transfer instance lifecycle automatically:
  • Creates the instance on first render.
  • Subscribes to status-change, complete, and error events.
  • Cleans up all subscriptions and calls destroy() on unmount.
You do not need to call destroy() manually when using the React hook.