Skip to content

Commit

Permalink
Remove MCI, update sdk versions, update deps (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
regdos authored Jan 20, 2025
1 parent 8092727 commit dcd489b
Show file tree
Hide file tree
Showing 53 changed files with 156 additions and 1,466 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
exit 1
- name: Run test
run: ./gradlew test
- name: Run lint
run: ./gradlew lint
- name: Create release in artifactory
env:
REPOSITORY_USERNAME: ${{ secrets.REPOSITORY_USERNAME }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ jobs:
java-version: 17
- name: Run test
run: ./gradlew test
- name: Run lint
run: ./gradlew lint
- name: Run build
run: ./gradlew assembleDebug
1 change: 1 addition & 0 deletions .java-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
17
14 changes: 9 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ android {
namespace 'com.payu.android.front.sdk.frontsdk'

}

kotlin {
jvmToolchain(project.javaVersion)
}

dependencies {
implementation "androidx.fragment:fragment:$fragmentVersion"

Expand All @@ -43,10 +48,10 @@ dependencies {
kapt "com.github.bumptech.glide:compiler:$project.glideVersion"

// Dagger
kapt "com.google.dagger:dagger-compiler:2.50"
kapt "com.google.dagger:dagger-android-processor:2.50"
implementation "com.google.dagger:dagger:2.50"
implementation "com.google.dagger:dagger-android-support:2.50"
kapt "com.google.dagger:dagger-compiler:$project.daggerVersion"
kapt "com.google.dagger:dagger-android-processor:$project.daggerVersion"
implementation "com.google.dagger:dagger:$project.daggerVersion"
implementation "com.google.dagger:dagger-android-support:$project.daggerVersion"

// RxJava
implementation 'io.reactivex.rxjava2:rxjava:2.2.8'
Expand All @@ -66,7 +71,6 @@ dependencies {
implementation project(path: ':payment-library-webview-module')
implementation project(path: ':payment-library-google-pay-module')
implementation project(path: ':payment-library-google-pay-adapter')
implementation project(path: ':payment-installments')
implementation project(path: ':marketplace-terms-condition')

testImplementation "junit:junit:$project.junitVersion"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ import com.payu.android.front.sdk.demo.repository.InstallmentRepository
import com.payu.android.front.sdk.demo.repository.PaymentMethodsRepository
import com.payu.android.front.sdk.demo.repository.PersistentRepository
import com.payu.android.front.sdk.demo.ui.login.LoginActivity
import com.payu.android.front.sdk.payment_library_core.external.listener.InstallmentCallback
import com.payu.android.front.sdk.payment_library_core.external.model.Installment
import com.payu.android.front.sdk.payment_library_core.external.model.InstallmentOption
import com.payu.android.front.sdk.payment_library_payment_chooser.payment_method.external.listener.PaymentMethodsCallback
import com.payu.android.front.sdk.payment_library_payment_chooser.payment_method.external.listener.PosIdListener
import com.payu.android.front.sdk.payment_library_payment_chooser.payment_method.internal.providers.PaymentMethodActions
Expand Down Expand Up @@ -79,49 +76,4 @@ class PaymentMethodsProvider(context: Context) : PaymentMethodActions(context) {
}
)
}

override fun provideInstallments(callback: InstallmentCallback) {
val disposable = installmentRepository.getInstallmentOption(persistenceRepository.proposalId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
{
if (it.installmentDecision != null) {
//merchant could display an information regarding this flow
println("Installment previously taken: $it")
return@subscribe
}

val installmentList: ArrayList<InstallmentOption> = ArrayList()
it.installmentOptions.forEach { item ->
installmentList.add(
InstallmentOption.Builder()
.withId(item.id)
.withFirstInstallments(item.firstInstallmentAmount ?: 0)
.withNumberOfInstallments(item.numberOfInstallments ?: 0)
.withTotalValue(item.totalAmountDue)
.withAnnualPercentageRate(item.annualPercentageRate)
.withInstallmentAmount(item.installmentAmount ?: 0)
.withInstallmentFeeAmount(item.installmentFeeAmount)
.withInterestRate(item.interestRate)
.build()
)

}

val installment: Installment = Installment.Builder()
.withCurrency(it.currencyCode)
.withProposalId(persistenceRepository.proposalId)
.withInstallmentType(it.installmentOptionFormat)
.withInstallmentOptionList(installmentList)
.withMaxNumberOfInstallments(it.maxNumberOfInstallments ?: 0)
.withMinNumberOfInstallments(it.minNumberOfInstallments ?: 0)
.build()
callback.onFetched(installment)

}, {
println("Error during fetching installments: $it")
})

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.payu.android.front.sdk.demo.ui.samples

import android.content.Intent
import android.os.Bundle
import android.os.Build
import androidx.appcompat.app.AppCompatActivity
import com.payu.android.front.sdk.payment_library_core_android.events.AuthorizationDetails
import com.payu.android.front.sdk.payment_library_webview_module.web.event.PaymentDetails
Expand All @@ -21,8 +22,12 @@ class WebPaymentDemoActivity : AppCompatActivity() {

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (requestCode == WebPaymentService.REQUEST_CODE) {
val paymentDetails: PaymentDetails? = data?.getParcelableExtra(WebPaymentService.INTENT_WEB_PAYMENT_EXTRA)

val paymentDetails: PaymentDetails? = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
data?.getParcelableExtra(WebPaymentService.INTENT_WEB_PAYMENT_EXTRA, PaymentDetails::class.java)
} else {
@Suppress("DEPRECATION")
data?.getParcelableExtra(WebPaymentService.INTENT_WEB_PAYMENT_EXTRA)
}
println(paymentDetails.toString())
finish()
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,23 @@ package com.payu.android.front.sdk.demo.ui.summary

import android.app.Activity
import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.Toast
import androidx.annotation.StringRes
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Observer
import com.payu.android.front.sdk.demo.api.model.installments.InstallmentSelected
import com.payu.android.front.sdk.demo.model.RollModel
import com.payu.android.front.sdk.demo.ui.base.ActivityWithMenu
import com.payu.android.front.sdk.demo.ui.login.LoginActivity
import com.payu.android.front.sdk.demo.ui.main.BUNDLE_DATA
import com.payu.android.front.sdk.frontsdk.R
import com.payu.android.front.sdk.frontsdk.databinding.ActivityRollSummaryBinding
import com.payu.android.front.sdk.payment_add_card_module.service.CvvValidationService
import com.payu.android.front.sdk.payment_installments.mastercard.offer.model.SelectedInstallment
import com.payu.android.front.sdk.payment_installments.mastercard.offer.view.OfferInstallmentsActivity
import com.payu.android.front.sdk.payment_library_card_scanner.scanner.pay.card.PayCardScanner
import com.payu.android.front.sdk.payment_library_core.external.model.InstallmentType
import com.payu.android.front.sdk.payment_library_core_android.events.AuthorizationDetails
import com.payu.android.front.sdk.payment_library_core_android.events.PaymentAuthorization
import com.payu.android.front.sdk.payment_library_google_pay_adapter.GooglePayAdapter
import com.payu.android.front.sdk.payment_library_google_pay_module.builder.Cart
import com.payu.android.front.sdk.payment_library_google_pay_module.model.Currency
Expand Down Expand Up @@ -52,7 +48,13 @@ class RollSummaryActivity : ActivityWithMenu() {
}

private fun populateData() {
val rollModel = intent.getParcelableExtra<RollModel>(BUNDLE_DATA)
val rollModel: RollModel? = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
intent.getParcelableExtra(BUNDLE_DATA, RollModel::class.java)
} else {
@Suppress("DEPRECATION")
intent.getParcelableExtra(BUNDLE_DATA)
}

viewModel.rollModel = rollModel
viewModel.paymentChooserController = getPaymentChooserController()

Expand Down Expand Up @@ -96,12 +98,6 @@ class RollSummaryActivity : ActivityWithMenu() {
})
}

private fun observeInstallmentAlreadyTaken() {
viewModel.installmentAlreadyTaken.observe(this, {
Toast.makeText(this, getString(R.string.installment_taken), Toast.LENGTH_SHORT).show()
})
}

private fun observeMessageSuccessEvent() {
viewModel.paymentSuccessEvent.observe(this, Observer { messageStringRes ->
messageStringRes?.let { showSuccess(it) }
Expand Down Expand Up @@ -132,12 +128,6 @@ class RollSummaryActivity : ActivityWithMenu() {
})
}

private fun observeInstallmentEvent() {
viewModel.installmentProposalEvent.observe(this, {
OfferInstallmentsActivity.startForResult(this)
})
}

private fun observePaymentEvent() {
viewModel.paymentEvent.observe(this, Observer { authorizationDetails ->
authorizationDetails?.let { WebPaymentService.pay(this, it) }
Expand Down Expand Up @@ -166,17 +156,18 @@ class RollSummaryActivity : ActivityWithMenu() {

private fun showSuccess(message: String) {
showToast(message)
binding.success.postDelayed({
binding.success.visibility = View.VISIBLE
}, 1
binding.success.postDelayed(
{
binding.success.visibility = View.VISIBLE
}, 1

)
binding.success.postDelayed(
{
binding.success.visibility = View.GONE
viewModel.showProgress.set(false)
},
2000
{
binding.success.visibility = View.GONE
viewModel.showProgress.set(false)
},
2000
)
}

Expand All @@ -188,19 +179,19 @@ class RollSummaryActivity : ActivityWithMenu() {
showToast(message)
binding.error.visibility = View.VISIBLE
binding.error.postDelayed(
{
binding.error.visibility = View.GONE
viewModel.showProgress.set(false)
},
2000
{
binding.error.visibility = View.GONE
viewModel.showProgress.set(false)
},
2000
)
}

private fun createCart() = viewModel.rollModel?.rollPrice?.let { price ->
Cart.Builder()
.withTotalPrice(price)
.withCurrency(Currency.PLN)
.build()
.withTotalPrice(price)
.withCurrency(Currency.PLN)
.build()
} ?: Cart.Builder().build()

private fun handlePaymentResult(requestCode: Int, data: Intent, resultCode: Int) {
Expand All @@ -213,17 +204,11 @@ class RollSummaryActivity : ActivityWithMenu() {
showToast(getString(R.string.payment_blik_ambiguity, it.toString()))
}
}
GooglePayService.REQUEST_CODE_GOOGLE_PAY_PAYMENT -> handleGooglePayResult(resultCode, data)
//TODO: create a service for it
OfferInstallmentsActivity.INSTALLMENT_REQUEST_CODE -> {
val selectedInstallment: SelectedInstallment = data.getParcelableExtra(OfferInstallmentsActivity.INSTALLMENT_KEY)!!
val installmentSelected: InstallmentSelected =
if (selectedInstallment.installmentType == InstallmentType.OPTIONS.toString())
InstallmentSelected(selectedInstallment.id)
else InstallmentSelected(numberOfInstallments = selectedInstallment.id.toInt())
viewModel.requestInstallment(installmentSelected, selectedInstallment.proposalId!!)
Toast.makeText(this, "Installment finished", Toast.LENGTH_SHORT).show()
}

GooglePayService.REQUEST_CODE_GOOGLE_PAY_PAYMENT -> handleGooglePayResult(
resultCode,
data
)
}
}

Expand All @@ -236,19 +221,21 @@ class RollSummaryActivity : ActivityWithMenu() {
showToast(R.string.payment_status_warning_continue_cvv)
handleCvvValidation(paymentDetails.continuePaymentUrl.get())
}

WebPaymentStatus.CANCEL_PAYMENT -> showError(R.string.payment_cancel)
WebPaymentStatus.PAYMENT_ERROR,
WebPaymentStatus.SSL_VALIDATION_ERROR -> showError(R.string.payment_status_error)

else -> showError(R.string.payment_status_error)
}
}

private fun handleCvvValidation(cvvPaymentUrl: String) {
CvvValidationService.validateCvv(
supportFragmentManager,
AuthorizationDetails.Builder()
.withLink(cvvPaymentUrl)
.build()
supportFragmentManager,
AuthorizationDetails.Builder()
.withLink(cvvPaymentUrl)
.build()
) { showSuccess("Cvv validation completed!") }
}

Expand All @@ -260,14 +247,17 @@ class RollSummaryActivity : ActivityWithMenu() {
viewModel.createOrder(it, googlePayTokenResponse?.googlePayToken)
}
}

Activity.RESULT_CANCELED -> {
//User has canceled payment
showError("Payment canceled")
}

GooglePayService.RESULT_ERROR -> {
val status = googlePayService.handleGooglePayErrorStatus(data)
showError(status.errorMessage ?: "GooglePay Error")
}

else -> showError("Payment process has failed for the user")
}
}
Expand All @@ -289,9 +279,7 @@ class RollSummaryActivity : ActivityWithMenu() {
observeGooglePayEvent()
observeBlikAmbiguityEvent()
observePaymentEvent()
observeInstallmentEvent()
observePaymentMethodChange()
observeInstallmentAlreadyTaken()

//for 3DS SoftAccept Test
retrieveStatusFromSoftAccept()
Expand All @@ -312,10 +300,21 @@ class RollSummaryActivity : ActivityWithMenu() {
}

fun retrieveStatusFromSoftAccept() {
supportFragmentManager.setFragmentResultListener(SoftAcceptService.KEY_REQUEST_BUNDLE, this, { _, bundle ->
val result = bundle.getParcelable<SoftAcceptTransactionDetail>(SoftAcceptService.KEY_SOFT_ACCEPT_RESPONSE_DETAIL)
Log.v("SoftAcceptTest", "Response with: " + result?.softAcceptTransactionStatus.toString())
supportFragmentManager.setFragmentResultListener(
SoftAcceptService.KEY_REQUEST_BUNDLE,
this,
{ _, bundle ->
val result: SoftAcceptTransactionDetail? = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
bundle.getParcelable(SoftAcceptService.KEY_SOFT_ACCEPT_RESPONSE_DETAIL, SoftAcceptTransactionDetail::class.java)
} else {
@Suppress("DEPRECATION")
bundle.getParcelable(SoftAcceptService.KEY_SOFT_ACCEPT_RESPONSE_DETAIL)
}
Log.v(
"SoftAcceptTest",
"Response with: " + result?.softAcceptTransactionStatus.toString()
)

});
});
}
}
Loading

0 comments on commit dcd489b

Please sign in to comment.