Customizing the SDK with a transaction controller

The transaction controller can be used to customize the SDK. The TransactionController interface has the methods that intercept authorize events, as follows. To call the PayPal-Here API directly, your app would override these two methods:

  • onPreAuthorize. Invoked by the SDK right before the SDK calls the PayPal Here Payments API, for taking a payment (authorizing a payment). The Invoice object (in inv) and the request payload string (invoice ID and card data, in preAuthJSON ) are passed to the onPreAuthorize method.
  • onPostAuthorize. Invoked by the SDK after a payment call, the onPostAuthorize method passes a didFail boolean value to indicate whether the attempted authorization was successful.

If your application requires that the SDK display UI while processing payments, the application must implement the methods defined in TransactionController. For more information about the TransactionController methods, refer to the TransactionController javadocs.

If you want the SDK to collect the card data, and make payment API calls, your app could either:

  • Refrain from implementing the onPreAuthorize and onPostAuthorize methods of TransactionController interface, or
  • Implement the TransactionController interface, and in the onPreAuthorize method, return the TransactionControlAction.CONTINUE enum, to tell the SDK that it must make the payment-related API call.

If you want your app to fill in the card data and make its own payment API call, your app could use the preAuthJSON string, containing the missing card data, and make the payment API call.