Headless mobile v2.16 to v2.17
Headless Universal Checkout has changed to solidify the integration experience and make the interfaces clearer and more consistent.
Below is a summary of the changes and examples of how to migrate to this new integration, however we recommend you consult the full documentation during integration.
Starting Headless Universal Checkout
Like before, you still prepare the PrimerHeadlessUniversalCheckoutListener
and start headless universal checkout with your client token.
onAvailablePaymentMethodsLoaded
now returns a list of payment methods with improved functionality.
Instead of just a string, each payment method returned contains the following:
paymentMethodType
a unique string identifier for the payment method.paymentMethodManagerCategories
a list that defines the payment method managers that can be used with this payment method (i.e.NATIVE_UI
orRAW_DATA
).- [Optional]
requiredInputDataClass
this is provided whenpaymentMethodManagerCategories
containsRAW_DATA
and indicates the type of data that should be captured for the payment method. supportedPrimerSessionIntents
a list ofPrimerSessionIntent
which defines what intents can be used with this payment method (i.e.CHECKOUT
orVAULT
).
See an example below:
Building your UI
Before when building your UI, you could create your own buttons using headlessUniversalCheckout.makeView
like in the example below:
You can now import the PrimerHeadlessUniversalCheckoutAssetsManager
that provides payment method assets per payment method type. See below:
The payment method asset contains the following:
paymentMethodType
a unique string identifier for the payment method.paymentMethodName
a user friendly English localized string identifier for the payment method (e.g.Google Pay
)paymentMethodLogo
an instance of the PrimerPaymentMethodLogopaymentMethodBackgroundColor
an instance of thePrimerPaymentMethodBackgroundColor
The PrimerPaymentMethodLogo
holds Drawable
objects for different scenarios
- [Optional]
colored
aDrawable
to be used anywhere - [Optional]
dark
aDrawable
to be used in dark mode - [Optional]
light
aDrawable
to be used in light mode
The PrimerPaymentMethodBackgroundColor
holds @ColorInt
objects for different scenarios
[Optional] colored
a @ColorInt
to be used anywhere
[Optional] dark
a @ColorInt
to be used in dark mode
[Optional] light
a @ColorInt
to be used in light mode
With the above images and colors you can build your own payment method buttons 💪
Handling Payment Methods
Before, you had to call showPaymentMethod
directly for some payment methods while having managers for others.
Now each payment method belongs to a payment method manager, as indicated by paymentMethodManagerCategories
on the list of available payment methods.
Native UI Manager
Used for any payment method that needs to present its own UI, like Google Pay. See example integration below:
Raw Data Manager
Used for payment methods that require you to pass data to the SDK, for example for cards. As before, you have to render your own input elements and capture the required data before finally calling submit
on the raw data manager. See example integration below:
Other changes
PrimerHeadlessUniversalCheckoutUiListener addition
We have created new listener in order to separate payment events and UI ones. You can attach a listener by calling PrimerHeadlessUniversalCheckout.current.start(uiListener = )
.
PrimerHeadlessUniversalCheckoutListener updates
Some listener functions have been renamed.
Before v2.17.0 | After 2.17.0 |
---|---|
fun onResumeSuccess | Renamed to onCheckoutResume |
fun onAdditionalInfoReceived | Renamed to onCheckoutAdditionalInfoReceived |
Some listener functions have been removed and moved to different classes.
Before v2.17.0 | After 2.17.0 |
---|---|
func onPreparationStarted(paymentMethodType: String) | Moved to PrimerHeadlessUniversalCheckoutUiListener |
func onPaymentMethodShowed(paymentMethodType: String) | Moved to PrimerHeadlessUniversalCheckoutUiListener |
Resume handler updates Some listener functions provide a decision handler.
You can process the data provided and once you’re ready you can call the decision handler with your relevant decision. Once you do, the SDK will continue the flow. We have changed the handler class name and signature of following functions have changed:
Miscellaneous changes
Models that need to be passed to the SDK when using Raw Data Managers
have changed structures and naming:
Starting Headless Universal Checkout
Like before, you still prepare the PrimerHeadlessUniversalCheckoutListener
and start headless universal checkout with your client token.
onAvailablePaymentMethodsLoaded
now returns a list of payment methods with improved functionality.
Instead of just a string, each payment method returned contains the following:
paymentMethodType
a unique string identifier for the payment method.paymentMethodManagerCategories
a list that defines the payment method managers that can be used with this payment method (i.e.NATIVE_UI
orRAW_DATA
).- [Optional]
requiredInputDataClass
this is provided whenpaymentMethodManagerCategories
containsRAW_DATA
and indicates the type of data that should be captured for the payment method. supportedPrimerSessionIntents
a list ofPrimerSessionIntent
which defines what intents can be used with this payment method (i.e.CHECKOUT
orVAULT
).
See an example below:
Building your UI
Before when building your UI, you could create your own buttons using headlessUniversalCheckout.makeView
like in the example below:
You can now import the PrimerHeadlessUniversalCheckoutAssetsManager
that provides payment method assets per payment method type. See below:
The payment method asset contains the following:
paymentMethodType
a unique string identifier for the payment method.paymentMethodName
a user friendly English localized string identifier for the payment method (e.g.Google Pay
)paymentMethodLogo
an instance of the PrimerPaymentMethodLogopaymentMethodBackgroundColor
an instance of thePrimerPaymentMethodBackgroundColor
The PrimerPaymentMethodLogo
holds Drawable
objects for different scenarios
- [Optional]
colored
aDrawable
to be used anywhere - [Optional]
dark
aDrawable
to be used in dark mode - [Optional]
light
aDrawable
to be used in light mode
The PrimerPaymentMethodBackgroundColor
holds @ColorInt
objects for different scenarios
[Optional] colored
a @ColorInt
to be used anywhere
[Optional] dark
a @ColorInt
to be used in dark mode
[Optional] light
a @ColorInt
to be used in light mode
With the above images and colors you can build your own payment method buttons 💪
Handling Payment Methods
Before, you had to call showPaymentMethod
directly for some payment methods while having managers for others.
Now each payment method belongs to a payment method manager, as indicated by paymentMethodManagerCategories
on the list of available payment methods.
Native UI Manager
Used for any payment method that needs to present its own UI, like Google Pay. See example integration below:
Raw Data Manager
Used for payment methods that require you to pass data to the SDK, for example for cards. As before, you have to render your own input elements and capture the required data before finally calling submit
on the raw data manager. See example integration below:
Other changes
PrimerHeadlessUniversalCheckoutUiListener addition
We have created new listener in order to separate payment events and UI ones. You can attach a listener by calling PrimerHeadlessUniversalCheckout.current.start(uiListener = )
.
PrimerHeadlessUniversalCheckoutListener updates
Some listener functions have been renamed.
Before v2.17.0 | After 2.17.0 |
---|---|
fun onResumeSuccess | Renamed to onCheckoutResume |
fun onAdditionalInfoReceived | Renamed to onCheckoutAdditionalInfoReceived |
Some listener functions have been removed and moved to different classes.
Before v2.17.0 | After 2.17.0 |
---|---|
func onPreparationStarted(paymentMethodType: String) | Moved to PrimerHeadlessUniversalCheckoutUiListener |
func onPaymentMethodShowed(paymentMethodType: String) | Moved to PrimerHeadlessUniversalCheckoutUiListener |
Resume handler updates Some listener functions provide a decision handler.
You can process the data provided and once you’re ready you can call the decision handler with your relevant decision. Once you do, the SDK will continue the flow. We have changed the handler class name and signature of following functions have changed:
Miscellaneous changes
Models that need to be passed to the SDK when using Raw Data Managers
have changed structures and naming:
Starting Headless Universal Checkout
Like before, you still set Headless Universal Checkout delegate, conform to PrimerHeadlessUniversalCheckoutDelegate
to handle the callbacks that happen during the checkout’s lifecycle, and start headless universal checkout with your client token.
The completion handler returns the available payment methods for the session when you start PrimerHeadlessUniversalCheckout
.
Instead of just a string, each payment method returned contains the following:
paymentMethodType
a unique string identifier for the payment method.paymentMethodManagerCategories
an array that defines the payment method managers that can be used with this payment method (i.e..cardComponents
,.nativeUI
or.rawData
). Use this to know which payment method managers to create.- [Optional]
requiredInputDataClass
this is provided whenpaymentMethodManagerCategories
contains.rawData
and indicates the type of data that should be captured for the payment method. supportedPrimerSessionIntents
an array ofPrimerSessionIntent
which defines what intents can be used with this payment method (i.e..checkout
or.vault
).
See an example below:
Building your UI
Before, when building your UI you could create your own buttons using PrimerHeadlessUniversalCheckout.makeButton
like in the example below:
PrimerHeadlessUniversalCheckout
now includes an AssetsManager
that provides payment method assets per payment method type. See below:
The payment method asset contains the following:
-
paymentMethodType
a unique string identifier for the payment method. -
paymentMethodName
a user friendly English localized string identifier for the payment method (e.g.Apple Pay
) -
paymentMethodLogo
an instance of thePrimerPaymentMethodLogo
(see more information below) -
paymentMethodBackgroundColor
an instance of thePrimerPaymentMethodBackgroundColor
The PrimerPaymentMethodLogo
holds UIImage
objects for different scenarios
- [Optional] colored
a
UIImage
to be used anywhere - [Optional] dark
a
UIImage
to be used in dark mode - [Optional]
light
aUIImage
to be used in light mode
The PrimerPaymentMethodBackgroundColor
holds UIColor
objects for different scenarios
- [Optional]
colored
aUIColor
to be used anywhere - [Optional]
dark
aUIColor
to be used in dark mode - [Optional]
light
aUIColor
to be used in light mode With the above images and colors, you can build your own payment method buttons 💪
Handling Payment Methods
Before you had to call showPaymentMethod
directly for some payment methods while having managers for others. Now each payment method belongs to a payment method manager, as indicated by paymentMethodManagerCategories
on the list of available payment methods.
Native UI Manager
Used for any payment method that needs to present its own UI, like Apple Pay. See an example integration below:
Raw Data Manager
Used for payment methods that require you to pass data to the SDK, for example for cards. As before, you have to render your own input elements and capture the required data before finally calling submit() on the raw data manager. See an example integration below:
Other changes
PrimerHeadlessUniversalCheckoutUIDelegate addition
New delegates have been introduced to separate payment events from UI events.
You can set the UI delegate in the start function
PrimerHeadlessUniversalCheckoutDelegate updates
Some delegate functions have been renamed:
Before v2.17.0 | After 2.17.0 |
---|---|
func primerHeadlessUniversalCheckoutTokenizationDidStart(for paymentMethodType: String) | Renamed to func primerHeadlessUniversalCheckoutDidStartTokenization(for paymentMethodType: String) |
func primerHeadlessUniversalCheckoutClientSessionWillUpdate() | Renamed to func primerHeadlessUniversalCheckoutWillUpdateClientSession() |
func primerHeadlessUniversalCheckoutClientSessionDidUpdate(_ clientSession: PrimerClientSession) | Renamed to func primerHeadlessUniversalCheckoutDidUpdateClientSession(_ clientSession: PrimerClientSession) |
Some delegate functions have been renamed and moved to other delegates:
Before v2.17.0 | After 2.17.0 |
---|---|
func primerHeadlessUniversalCheckoutPreparationDidStart(for paymentMethodType: String) | Moved to PrimerHeadlessUniversalCheckoutUIDelegate as func primerHeadlessUniversalCheckoutUIDidStartPreparation(for paymentMethodType: String) |
func primerHeadlessUniversalCheckoutPaymentMethodDidShow(for paymentMethodType: String) | Moved to PrimerHeadlessUniversalCheckoutUIDelegate as func primerHeadlessUniversalCheckoutUIDidShowPaymentMethod(for paymentMethodType: String) |
Resume handler updates
Some listener functions provide a decision handler that you can call with the relevant decision to continue the flow.
The handler class name and signature of the following functions have changed:
Miscellaneous changes Models that need to be passed to the SDK when using Raw Data Managers have changed structures and naming:
🚀 Starting Headless Universal Checkout
As before, you still set Headless Universal Checkout callbacks to handle events during the checkout’s lifecycle.
Previously you passed all the individual callbacks in PrimerSettings
, like below:
Now these callbacks can be set on the headlessUniversalCheckoutCallbacks
property of PrimerSettings
:
In addition, for the availablePaymentMethods
returned when headless universal checkout is created, the payload will change.
Instead of just a string, each payment method returned contains the following:
paymentMethodType
a unique string identifier for the payment method.paymentMethodManagerCategories
an array which defines the payment method managers that can be used with this payment method (i.e. NATIVE_UI or RAW_DATA). Use this to know which payment method managers to create.- [Optional]
requiredInputDataClass
this is provided with the RAW_DATA payment method manager and indicates the type of data that should be captured for the payment method. supportedPrimerSessionIntents
an array ofSessionIntent
which defines what intents can be used with this payment method (i.e..checkout
or.vault
).
Building your UI
You can build your UI by using the AssetsManager. You can access the payment methods’ assets like below:
The payment method asset contains the following:
-
paymentMethodType
: a unique string identifier for the payment method. -
paymentMethodName
a user friendly English localized string identifier for the payment method (e.g.Apple Pay
)paymentMethodLogo
which contains the logos’ local URLscolored?: string
: Local URL for the colored value of the logodark?: string
: Local URL for the dark value of the logolight?: string
: Local URL for the light value of the logo
-
paymentMethodBackgroundColor
which contains the background colors hex valuescolored?: string
: Color hex value for the colored background colordark?: string
: Color hex value for the dark mode background colorlight?: string
: Color hex value for the light mode background color With the above images and colors, you can build your own payment method buttons 💪
Handling Payment Methods
Before you had to call showPaymentMethod
directly for some payment methods while having managers for others. Now each payment method belongs to a payment method manager, as indicated by paymentMethodManagerCategories
on the list of available payment methods.
Native UI Manager
Used for any payment method that needs to present its own UI, like Apple Pay. See example integration below:
Raw Data Manager
Used for payment methods that require you to pass data to the SDK, for example for cards. As before, you have to render your own input elements and capture the required data before finally calling submit
on the raw data manager. See an example integration below:
Other changes
Callback updates
Some callbacks have been renamed:
Before v2.17.0 | After 2.17.0 |
---|---|
onHUCAvailablePaymentMethodsLoaded | Renamed to onAvailablePaymentMethodsLoad |
onHUCPrepareStart | Renamed to onPreparationStart |
onHUCTokenizeStart | Renamed to onTokenizationStart |
onHUCPaymentMethodShow | Renamed to onPaymentMethodShow |
onResumePending | Renamed to onCheckoutPending |
onCheckoutReceivedAdditionalInfo | Renamed to onCheckoutAdditionalInfo |
Resume handler updates Some listener functions provide a decision handler that you can call with the relevant decision to continue the flow.
The handler class name and signature of the following functions have changed:
Miscellaneous changes
The interfaces that need to be passed to the SDK when using Raw Data Managers have changed structures and names: