- 20 Jun 2023
- 2 Minutes to read
- DarkLight
Pay Monthly at Checkout
- Updated on 20 Jun 2023
- 2 Minutes to read
- DarkLight
Requesting an offer from Uplift
To request an offer at checkout, call setTripInfoForCheckout
with an up-to-date ULPMTripInfo
. Every time the trip itinerary has changed/updated, simply call the same method with the new ULPMTripInfo
to update the offer displayed.
The Uplift SDK maintains the current order. If there is need to reset and remove the existing order, call the same method with the ULPMTripInfo
as well as a renewOrderId
flag set to true/yes. This will refresh the order id and restart the Pay Monthly application. For all other cases, this flag should be set to false/no.
/**
* You can find a Kotlin example in the example project's PayViewModel.kt file
* in the "handleAction" method.
*/
val trip: ULPMTripInfo = your_trip_info
val error: ULError? = ULOrderManager.setTripInfoForCheckout(tripInfo!!, false)
setTripInfoForCheckout
method can return with an ULError
in case of error happens in the body. To be able to get any feedback about the offer status ULCheckoutCallback
need to be provided to the ULOrderManager
.
Checkout Flow callback
In order to receive information about the checkout flow, you need to provide a ULCheckoutCallback
to the ULOrderManager
. This callback will delegate every important piece of information to the host application. When the offer status changes, offerStatusReceived
will be called with the corresponding state and monthly amount. If the ULPMTripInfo
qualifies, the hasOffer
boolean will be set to true. In this case, Uplift's checkout flow should be presented.
If hasOffer
boolean is false/no, the trip does not qualify and Uplift’s checkout flow should not be presented. Please contact your Uplift representitive to discuss why a trip might not qualify.
val callback = object : ULCheckoutCallback {
override fun viewCreated() {
// Callback method which is be called after the checkout view has created.
}
override fun viewDestroyed() {
// Callback method which is be called after the checkout view has destroyed.
}
override fun offerStatusReceived(hasOffer: Boolean, payMonthlyAmount: Int?) {
// Callback method which is called when an offer update is received.
}
override fun virtualCardReceived(virtualCard: ULPMVirtualCard) {
// Callback method which is called when the checkout is finished successfully.
}
override fun onError(error: ULError) {
// Callback method which is called when an error has happened during the checkout flow.
}
}
ULOrderManager.setCheckoutCallback(callback)
Presenting the Checkout Flow
There are two ways to present the checkout flow.
Embed Mode
Presenting the checkout flow in a container.
/**
* You can find a Kotlin example in the example project's PayActivity.kt file.
*/
val checkoutFragment = ULOrderManager.getCheckoutFragment()
if (checkoutFragment.isSuccess) {
supportFragmentManager.beginTransaction()
.replace(R.id.container, checkoutFragment.getOrThrow())
.commit()
} else {
// error has happened
}
Full Screen Mode
Presenting the checkout flow in full screen mode.
val error: ULError? = ULOrderManager.presentCheckoutFullScreen(this)
presentCheckoutFullScreen
method can return with an ULError in case of error happens in the body.
Configuration of the Checkout flow
There are several options available to customize the checkout flow and improve the user experience. These options can be found in the ULCheckoutConfiguration
class. To set a configuration, you can set up the API's ULConfiguration
with an ULCheckoutConfiguration
object.
/**
* You can find a Kotlin example in the example project's SplashActivity.kt.
**/
val apikey = "your api key goes here"
val upCode = "UP-xxxxxx-xx"
val checkoutConfiguration = ULCheckoutConfiguration(
showCloseButton = true,
screenTimeOut = 30L
)
val configuration = ULConfiguration(
upCode = upCode,
apiKey = apiKey,
checkoutConfiguration = checkoutConfiguration,
apiTimeout = 30L
)
ULUpliftSDK.setConfiguration(context, configuration, object : ConfigurationCallback {
override fun onSuccess() {
// This method will triggered when the initialize method succeeded
}
override fun onError(error: ULError) {
// This method will triggered when the initialize method failed
}
})