showView is invoked when the SDK has a view ready to be presented. Either a form to collect input from the user, or an action view such as a QR code. Override this controller to embed the view in your own layout instead of letting the SDK present it full-screen.
WebViews: for example, 3DS challenges or redirects required by some payment methods, are always presented by the SDK full-screen. They do not come through
showView, so overriding it does not change that behavior.showView is available on iOS and Android. On Web the SDK renders the form inside the element you pass as elementSelector, so there is no view to hand over. To submit that form from your own button, see Web: submit from your own button.
Behavior
If you do not override this controller, the SDK presents the view full-screen with its own header and submit button. When you override it, the SDK delivers the view to your handler along with aTransactionProcess control object. You place the view wherever you want in your layout, and you call process.onSubmit() to tell the SDK the user has triggered submission.
You are responsible for removing the view from your layout once the transaction has moved past that step.
The controller can be invoked more than once per transaction. The step parameter indicates which step the view belongs to. For example, FORM for the data-capture form and ACTION for an action view such as a QR code. Use it to differentiate how you embed each view if needed.
On iOS, FORM carries the payment or enrollment form, and ACTION carries the screens the SDK renders for a method after the form: payment instructions such as a QR or a payment code, and OTP entry. view is nil when the SDK could not build an ACTION screen; there is nothing to embed in that case, and the transaction reports its outcome through onStatus.
To hand a step back to the SDK from your override, call SdkPayments.defaultShowView(view:process:step:). For example, embed the form and let the SDK present the action views:
Signature
- iOS
- Android
TransactionProcess
TransactionProcess is the control object the SDK passes alongside the view. It exposes a single method:
process.onSubmit() when the user triggers submission from your own UI (for example, when they tap your custom submit button). The SDK validates the form and, if valid, continues the transaction.
You don’t need to handle success or failure here. The result of submission flows through createPayment (if overridden) and onStatus.
TransactionViewStep
TransactionViewStep indicates which step the view corresponds to.
Threading
On iOS and Android,showView is invoked on the main thread. You can update UI directly from inside this handler.
Web: submit from your own button
On Web, hide the SDK’s Pay button withshowPayButton: false and call transaction.submit() from your own button. It is the Web counterpart of process.onSubmit().
submit() validates the form and, if valid, continues the transaction. If the form is not valid, onStatus receives INTERNAL_ERROR with code FORM_INVALID. That status is not final: the form stays mounted. The result of a valid submission flows through createPayment (if overridden) and onStatus, the same as when the user clicks the SDK’s Pay button.
Related
- Transactions. How a payment flows through Yuno.
createPayment. Receives the token after submission.onStatus. Receives the final status.