Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/adjust configuration #35

Merged
merged 21 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
227013b
Added configuration class for the different payment flows
Robert-SD Sep 11, 2023
854a1c5
Added android configuration values
Robert-SD Sep 14, 2023
21d940e
Added usage of DropInConfigurationDTO for iOS
Robert-SD Sep 15, 2023
ef8d540
Added apple pay configuration
Robert-SD Sep 15, 2023
90576c6
Rebased onto main and applied ktlint format
Robert-SD Sep 18, 2023
6aaa00a
Added google pay configuration and improved naming of config properties
Robert-SD Sep 18, 2023
bef8253
Improved usage of google pay configuration
Robert-SD Sep 18, 2023
4861aa2
Adjusted configurations and added cash app pay
Robert-SD Sep 19, 2023
8daacb1
Adjusted cash app pay configuration
Robert-SD Sep 20, 2023
14ee502
Introduced dto for session class
Robert-SD Sep 20, 2023
74fca87
Migrated to amount and order response dto
Robert-SD Sep 20, 2023
04346bf
Migrated payment result to dto as well
Robert-SD Sep 20, 2023
aa93c3e
Adjusted order response parsing and usage of correct model
Robert-SD Sep 20, 2023
5cb2c61
Adjusted google pay configuration
Robert-SD Sep 21, 2023
240aab2
Extracted configuration mappers to external classes
Robert-SD Sep 21, 2023
50355ec
Update ios/Classes/utils/ConfigurationMapper.swift
Robert-SD Sep 21, 2023
62a215e
Update ios/Classes/utils/ConfigurationMapper.swift
Robert-SD Sep 21, 2023
aecb7ab
Update ios/Classes/utils/ConfigurationMapper.swift
Robert-SD Sep 21, 2023
0e406a3
Update ios/Classes/utils/ConfigurationMapper.swift
Robert-SD Sep 21, 2023
7df3b9e
Update ios/Classes/utils/ConfigurationMapper.swift
Robert-SD Sep 21, 2023
8b83bd3
Applied changes from code review
Robert-SD Sep 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ package com.adyen.adyen_checkout

import CheckoutFlutterApi
import CheckoutPlatformInterface
import PaymentResult
import PaymentResultDTO
import PaymentResultEnum
import PaymentResultModel
import PaymentResultModelDTO
import PlatformCommunicationModel
import PlatformCommunicationType
import androidx.fragment.app.FragmentActivity
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleEventObserver
import com.adyen.adyen_checkout.utils.ConfigurationMapper.mapToOrderResponseModel
import com.adyen.adyen_checkout.utils.Constants.Companion.WRONG_FLUTTER_ACTIVITY_USAGE_ERROR_MESSAGE
import com.adyen.adyen_checkout.utils.Mapper.mapToOrderResponseModel
import com.adyen.checkout.dropin.DropIn
import com.adyen.checkout.dropin.DropInCallback
import com.adyen.checkout.dropin.DropInResult
Expand Down Expand Up @@ -86,19 +86,19 @@ class AdyenCheckoutPlugin : FlutterPlugin, ActivityAware {
}

val mappedResult = when (sessionDropInResult) {
is SessionDropInResult.CancelledByUser -> PaymentResult(
is SessionDropInResult.CancelledByUser -> PaymentResultDTO(
PaymentResultEnum.CANCELLEDBYUSER
)

is SessionDropInResult.Error -> PaymentResult(
is SessionDropInResult.Error -> PaymentResultDTO(
PaymentResultEnum.ERROR,
reason = sessionDropInResult.reason
)

is SessionDropInResult.Finished -> PaymentResult(
is SessionDropInResult.Finished -> PaymentResultDTO(
PaymentResultEnum.FINISHED,
result = with(sessionDropInResult.result) {
PaymentResultModel(
PaymentResultModelDTO(
sessionId,
sessionData,
resultCode,
Expand All @@ -116,18 +116,18 @@ class AdyenCheckoutPlugin : FlutterPlugin, ActivityAware {
}

val mappedResult = when (dropInAdvancedFlowResult) {
is DropInResult.CancelledByUser -> PaymentResult(
is DropInResult.CancelledByUser -> PaymentResultDTO(
PaymentResultEnum.CANCELLEDBYUSER
)

is DropInResult.Error -> PaymentResult(
is DropInResult.Error -> PaymentResultDTO(
PaymentResultEnum.ERROR,
reason = dropInAdvancedFlowResult.reason
)

is DropInResult.Finished -> PaymentResult(
is DropInResult.Finished -> PaymentResultDTO(
PaymentResultEnum.FINISHED,
result = PaymentResultModel(
result = PaymentResultModelDTO(
resultCode = dropInAdvancedFlowResult.result
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package com.adyen.adyen_checkout

import CheckoutFlutterApi
import CheckoutPlatformInterface
import DropInConfiguration
import DropInResult
import DropInConfigurationDTO
import DropInResultDTO
import DropInResultType
import PlatformCommunicationModel
import PlatformCommunicationType
import Session
import SessionDTO
import androidx.activity.result.ActivityResultLauncher
import androidx.fragment.app.FragmentActivity
import androidx.lifecycle.lifecycleScope
Expand All @@ -16,9 +16,9 @@ import com.adyen.adyen_checkout.dropInAdvancedFlow.DropInAdditionalDetailsPlatfo
import com.adyen.adyen_checkout.dropInAdvancedFlow.DropInAdditionalDetailsResultMessenger
import com.adyen.adyen_checkout.dropInAdvancedFlow.DropInPaymentResultMessenger
import com.adyen.adyen_checkout.dropInAdvancedFlow.DropInServiceResultMessenger
import com.adyen.adyen_checkout.utils.ConfigurationMapper.mapToDropInConfiguration
import com.adyen.adyen_checkout.utils.ConfigurationMapper.mapToSession
import com.adyen.adyen_checkout.utils.Constants.Companion.WRONG_FLUTTER_ACTIVITY_USAGE_ERROR_MESSAGE
import com.adyen.adyen_checkout.utils.Mapper.mapToDropInConfiguration
import com.adyen.adyen_checkout.utils.Mapper.mapToSession
import com.adyen.checkout.components.core.PaymentMethodsApiResponse
import com.adyen.checkout.dropin.DropIn
import com.adyen.checkout.dropin.internal.ui.model.DropInResultContractParams
Expand Down Expand Up @@ -49,14 +49,14 @@ class CheckoutPlatformApi(private val checkoutFlutterApi: CheckoutFlutterApi?) :
}

override fun startDropInSessionPayment(
dropInConfiguration: DropInConfiguration,
session: Session,
dropInConfigurationDTO: DropInConfigurationDTO,
session: SessionDTO,
) {
checkForFlutterFragmentActivity()
activity.lifecycleScope.launch(Dispatchers.IO) {
val sessionModel = session.mapToSession()
val dropInConfiguration =
dropInConfiguration.mapToDropInConfiguration(activity.applicationContext)
dropInConfigurationDTO.mapToDropInConfiguration(activity.applicationContext)
val checkoutSession = createCheckoutSession(sessionModel, dropInConfiguration)
withContext(Dispatchers.Main) {
DropIn.startPayment(
Expand All @@ -70,7 +70,7 @@ class CheckoutPlatformApi(private val checkoutFlutterApi: CheckoutFlutterApi?) :
}

override fun startDropInAdvancedFlowPayment(
dropInConfiguration: DropInConfiguration,
dropInConfigurationDTO: DropInConfigurationDTO,
paymentMethodsResponse: String,
) {
checkForFlutterFragmentActivity()
Expand All @@ -82,7 +82,7 @@ class CheckoutPlatformApi(private val checkoutFlutterApi: CheckoutFlutterApi?) :
val paymentMethodsWithoutGiftCards =
removeGiftCardPaymentMethods(paymentMethodsApiResponse)
val dropInConfiguration =
dropInConfiguration.mapToDropInConfiguration(activity.applicationContext)
dropInConfigurationDTO.mapToDropInConfiguration(activity.applicationContext)
withContext(Dispatchers.Main) {
DropIn.startPayment(
activity.applicationContext,
Expand All @@ -95,15 +95,15 @@ class CheckoutPlatformApi(private val checkoutFlutterApi: CheckoutFlutterApi?) :
}
}

override fun onPaymentsResult(paymentsResult: DropInResult) {
override fun onPaymentsResult(paymentsResult: DropInResultDTO) {
if (paymentsResult.dropInResultType == DropInResultType.ACTION) {
setAdvanceFlowDropInAdditionalDetailsMessengerObserver()
}

DropInPaymentResultMessenger.sendResult(paymentsResult)
}

override fun onPaymentsDetailsResult(paymentsDetailsResult: DropInResult) {
override fun onPaymentsDetailsResult(paymentsDetailsResult: DropInResultDTO) {
DropInAdditionalDetailsResultMessenger.sendResult(paymentsDetailsResult)
}

Expand Down
Loading