diff --git a/app/src/main/java/ru/cloudpayments/demo/screens/main/MainActivity.kt b/app/src/main/java/ru/cloudpayments/demo/screens/main/MainActivity.kt index 32c0532..89813d1 100644 --- a/app/src/main/java/ru/cloudpayments/demo/screens/main/MainActivity.kt +++ b/app/src/main/java/ru/cloudpayments/demo/screens/main/MainActivity.kt @@ -11,7 +11,6 @@ import ru.cloudpayments.sdk.configuration.CloudpaymentsSDK import ru.cloudpayments.sdk.configuration.PaymentConfiguration import ru.cloudpayments.sdk.configuration.PaymentData - class MainActivity : BaseActivity() { private val cpSdkLauncher = CloudpaymentsSDK.getInstance().launcher(this, result = { @@ -39,66 +38,74 @@ class MainActivity : BaseActivity() { val view = binding.root setContentView(view) - binding.buttonRun.setOnClickListener { + binding.buttonRunTop.setOnClickListener { + runCpSdk() + } - val apiUrl = binding.editApiUrl.text.toString() - val publicId = binding.editPublicId.text.toString() - val amount = binding.editAmount.text.toString() - val currency = binding.editCurrency.text.toString() - val invoiceId = binding.editInvoiceId.text.toString() - val description = binding.editDescription.text.toString() - val accountId = binding.editAccountId.text.toString() - val email = binding.editEmail.text.toString() - - val payerFirstName = binding.editPayerFirstName.text.toString() - val payerLastName = binding.editPayerLastName.text.toString() - val payerMiddleName = binding.editPayerMiddleName.text.toString() - val payerBirthDay = binding.editPayerBirth.text.toString() - val payerAddress = binding.editPayerAddress.text.toString() - val payerStreet = binding.editPayerStreet.text.toString() - val payerCity = binding.editPayerCity.text.toString() - val payerCountry = binding.editPayerCountry.text.toString() - val payerPhone = binding.editPayerPhone.text.toString() - val payerPostcode = binding.editPayerPostcode.text.toString() - - val jsonData = binding.editJsonData.text.toString() - val isDualMessagePayment = binding.checkboxDualMessagePayment.isChecked - - var payer = PaymentDataPayer() - payer.firstName = payerFirstName - payer.lastName = payerLastName - payer.middleName = payerMiddleName - payer.birthDay = payerBirthDay - payer.address = payerAddress - payer.street = payerStreet - payer.city = payerCity - payer.country = payerCountry - payer.phone = payerPhone - payer.postcode = payerPostcode - - val paymentData = PaymentData( - amount = amount, - currency = currency, - invoiceId = invoiceId, - description = description, - accountId = accountId, - email = email, - payer = payer, - jsonData = jsonData - ) - - val configuration = PaymentConfiguration( - publicId = publicId, - paymentData = paymentData, - scanner = CardIOScanner(), - showEmailField = true, - useDualMessagePayment = isDualMessagePayment, - disableGPay = false, - disableYandexPay = false, - yandexPayMerchantID = "1423423564546767575", - apiUrl = apiUrl - ) - cpSdkLauncher.launch(configuration) + binding.buttonRun.setOnClickListener { + runCpSdk() } } + + private fun runCpSdk() { + + val apiUrl = binding.editApiUrl.text.toString() + val publicId = binding.editPublicId.text.toString() + val amount = binding.editAmount.text.toString() + val currency = binding.editCurrency.text.toString() + val invoiceId = binding.editInvoiceId.text.toString() + val description = binding.editDescription.text.toString() + val accountId = binding.editAccountId.text.toString() + val email = binding.editEmail.text.toString() + + val payerFirstName = binding.editPayerFirstName.text.toString() + val payerLastName = binding.editPayerLastName.text.toString() + val payerMiddleName = binding.editPayerMiddleName.text.toString() + val payerBirthDay = binding.editPayerBirth.text.toString() + val payerAddress = binding.editPayerAddress.text.toString() + val payerStreet = binding.editPayerStreet.text.toString() + val payerCity = binding.editPayerCity.text.toString() + val payerCountry = binding.editPayerCountry.text.toString() + val payerPhone = binding.editPayerPhone.text.toString() + val payerPostcode = binding.editPayerPostcode.text.toString() + + val jsonData = binding.editJsonData.text.toString() + val isDualMessagePayment = binding.checkboxDualMessagePayment.isChecked + + var payer = PaymentDataPayer() + payer.firstName = payerFirstName + payer.lastName = payerLastName + payer.middleName = payerMiddleName + payer.birthDay = payerBirthDay + payer.address = payerAddress + payer.street = payerStreet + payer.city = payerCity + payer.country = payerCountry + payer.phone = payerPhone + payer.postcode = payerPostcode + + val paymentData = PaymentData( + amount = amount, + currency = currency, + invoiceId = invoiceId, + description = description, + accountId = accountId, + email = email, + payer = payer, + jsonData = jsonData + ) + + val configuration = PaymentConfiguration( + publicId = publicId, + paymentData = paymentData, + scanner = CardIOScanner(), + requireEmail = false, + useDualMessagePayment = isDualMessagePayment, + disableGPay = false, + disableYandexPay = false, + yandexPayMerchantID = "", + apiUrl = apiUrl + ) + cpSdkLauncher.launch(configuration) + } } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_checkout.xml b/app/src/main/res/layout/activity_checkout.xml index 689d9df..aafcfdf 100644 --- a/app/src/main/res/layout/activity_checkout.xml +++ b/app/src/main/res/layout/activity_checkout.xml @@ -144,8 +144,7 @@ android:layout_marginTop="@dimen/ui_margin_16dp" android:layout_marginRight="@dimen/ui_margin_16dp" android:text="@string/checkout_payment" - app:backgroundTint="@color/colorAccent" - style="@style/cpsdk_UnelevatedButton"/> + app:backgroundTint="@color/colorAccent"/> - + android:background="@android:color/white"> +