Initialization

Now, initialize the Checkout via the Bridge instance:

bridge.init(this, configModel, object : ICheckoutPurchase {  
    override fun onInitialized() {  
        onResult("Initialize Complete")  
    }  
    
    override fun onInitializeFailed(error: ErrorMessage) {  
        onResult("Initialization failed - $error") 
    }
  
 		override fun onPurchaseSuccess(order: OrderResponseModel) 
        // Handle purchase success  
        runOnUiThread {   
            onResult("Purchase complete $order")  
        }  
    }  

    override fun onPurchaseFailed(error: ErrorMessage)
        // Handle purchase failure  
        runOnUiThread {  
            onResult("Purchase fail - $error")  
        }  
    }  
            
    override fun onPricePointsSuccess(pricePoints: PricePointsModel) {
        runOnUiThread {  
            onResult("Price points complete - $pricePoints")  
        }  
    }
    
    override fun onPricePointsFail(error: ErrorMessage) { 
        runOnUiThread {    
            onResult("Price points fail - $error")  
        }  
    }
    
    override fun onPurchaseConsumed(consumed: Boolean) {
    	runOnUiThread {
        if (consumed) {
            onResult("Purchase Consumed")
        }
        else {
            onResult("Purchase complete failed")
        }
   		 }
		}
})

The bridge initialization requires three arguments:

ArgumentDescription
ContextThe current/main Activity context
ConfigModelConfiguration options for initialization
ICheckoutPurchaseCheckout interface will be used as callback

The ICheckoutPurchase interface exposes 6 methods:

MethodDescription
onInitializedTriggered when checkout initialization is complete.
onInitializeFailedTriggered when checkout initialization failed.
onPurchaseSuccessTriggered when checkout initialization is successfully completed.
onPurchaseFailedTriggered when the purchase has failed. An error message will be presented.
onPricePointsSuccessTriggered when the price points have successfully been retrieved.
onPricePointsFailTriggered when no price points are available, could not be retrieved.
onPurchaseConsumedTriggered when the consumed action is either successful or has failed. The consumed argument indicates whether the action was a success or a failure.