@@ -16,7 +16,7 @@ import com.processout.example.ui.screen.nativeapm.NativeApmUiState.*
1616import com.processout.sdk.core.onFailure
1717import com.processout.sdk.core.onSuccess
1818import com.processout.sdk.ui.napm.PONativeAlternativePaymentConfiguration
19- import com.processout.sdk.ui.napm.PONativeAlternativePaymentConfiguration.Button
19+ import com.processout.sdk.ui.napm.PONativeAlternativePaymentConfiguration.*
2020import com.processout.sdk.ui.napm.PONativeAlternativePaymentLauncher
2121import com.processout.sdk.ui.napm.delegate.PONativeAlternativePaymentDelegate
2222import com.processout.sdk.ui.nativeapm.PONativeAlternativePaymentMethodConfiguration
@@ -73,18 +73,26 @@ class NativeApmFragment : BaseFragment<FragmentNativeApmBinding>(
7373 }
7474
7575 private fun setOnClickListeners () {
76- binding.launchNativeApmButton .setOnClickListener {
77- onSubmitClick(launchCompose = false )
76+ binding.buttonAuthorizeLegacy .setOnClickListener {
77+ onSubmitClick(launchCompose = false , tokenize = false )
7878 }
79- binding.launchNativeApmComposeButton.setOnClickListener {
80- onSubmitClick(launchCompose = true )
79+ binding.buttonAuthorizeCompose.setOnClickListener {
80+ onSubmitClick(launchCompose = true , tokenize = false )
81+ }
82+ binding.buttonTokenizeCompose.setOnClickListener {
83+ onSubmitClick(launchCompose = true , tokenize = true )
8184 }
8285 }
8386
84- private fun onSubmitClick (launchCompose : Boolean ) {
87+ private fun onSubmitClick (launchCompose : Boolean , tokenize : Boolean ) {
8588 val amount = binding.amountInput.text.toString()
8689 val currency = binding.currencyInput.text.toString()
87- viewModel.createInvoice(amount, currency, launchCompose)
90+ viewModel.createInvoice(
91+ amount = amount,
92+ currency = currency,
93+ launchCompose = launchCompose,
94+ tokenize = tokenize
95+ )
8896 }
8997
9098 private fun handle (uiState : NativeApmUiState ) {
@@ -98,13 +106,36 @@ class NativeApmFragment : BaseFragment<FragmentNativeApmBinding>(
98106
99107 private fun launch (uiModel : NativeApmUiModel ) {
100108 if (uiModel.launchCompose) {
101- launcherCompose.launch(
102- PONativeAlternativePaymentConfiguration (
103- invoiceId = uiModel.invoiceId,
104- gatewayConfigurationId = uiModel.gatewayConfigurationId,
105- submitButton = Button ()
109+ if (uiModel.tokenize) {
110+ launcherCompose.launch(
111+ PONativeAlternativePaymentConfiguration (
112+ flow = Flow .Tokenization (
113+ customerId = uiModel.customerId,
114+ customerTokenId = uiModel.customerTokenId,
115+ gatewayConfigurationId = uiModel.gatewayConfigurationId
116+ ),
117+ cancelButton = CancelButton (),
118+ paymentConfirmation = PaymentConfirmationConfiguration (
119+ confirmButton = Button (),
120+ cancelButton = CancelButton (disabledForSeconds = 3 )
121+ )
122+ )
106123 )
107- )
124+ } else {
125+ launcherCompose.launch(
126+ PONativeAlternativePaymentConfiguration (
127+ flow = Flow .Authorization (
128+ invoiceId = uiModel.invoiceId,
129+ gatewayConfigurationId = uiModel.gatewayConfigurationId
130+ ),
131+ cancelButton = CancelButton (),
132+ paymentConfirmation = PaymentConfirmationConfiguration (
133+ confirmButton = Button (),
134+ cancelButton = CancelButton (disabledForSeconds = 3 )
135+ )
136+ )
137+ )
138+ }
108139 } else {
109140 launcher.launch(
110141 PONativeAlternativePaymentMethodConfiguration (
@@ -128,8 +159,9 @@ class NativeApmFragment : BaseFragment<FragmentNativeApmBinding>(
128159 with (binding) {
129160 amountInput.isEnabled = isEnabled
130161 currencyInput.isEnabled = isEnabled
131- launchNativeApmButton.isClickable = isEnabled
132- launchNativeApmComposeButton.isClickable = isEnabled
162+ buttonAuthorizeLegacy.isClickable = isEnabled
163+ buttonAuthorizeCompose.isClickable = isEnabled
164+ buttonTokenizeCompose.isClickable = isEnabled
133165 amountInput.clearFocus()
134166 currencyInput.clearFocus()
135167 }
0 commit comments