Skip to main content
Controllers are how your code receives the SDK’s events and, when needed, overrides default behavior. Implement only the ones you need.

Defaults

Implement onStatus in every integration. The others are optional. Web has no showView: the SDK renders the form inside your elementSelector. To submit it from your own button, set showPayButton: false and call transaction.submit().

How to wire controllers

  • Web. Each event is a plain function set on the transaction config. onStatus, showLoading, createPayment and onChange are top-level fields. onInstallmentSelected goes inside card (card: { onInstallmentSelected }) and onShippingAddressChanged inside externalButtons (externalButtons: { onShippingAddressChanged }).
  • iOS, Android. Implement TransactionController on the object that should react to events (your view model, activity, or a dedicated class) and pass it through the controller field of TransactionConfig. Each event maps to a method on that object. showView is available on mobile only.
  • React Native. Pass a plain object as the controller field of TransactionConfig. Each event maps to a method of that object, and the methods you leave out keep the SDK default. To hand one call back to the SDK from a method you implement, call SdkPayments.defaultShowView, SdkPayments.defaultShowLoading or SdkPayments.defaultCreatePayment with the arguments it received.

Threading

On iOS and Android, every controller method is invoked on the main thread. You can update UI directly from inside it. Move any blocking work (e.g. backend calls inside createPayment) off the main thread yourself. On React Native, controller methods run on the JavaScript thread.

Per-controller pages