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

Support partial payments #310

Merged
merged 22 commits into from
Dec 19, 2024
Merged

Support partial payments #310

merged 22 commits into from
Dec 19, 2024

Conversation

Robert-SD
Copy link
Collaborator

No description provided.

Copy link

LCOV of commit 5d3dafd during Check PR #937

Summary coverage rate:
  lines......: 10.1% (136 of 1353 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate:
                                                                                                |Lines       |Functions  |Branches    
  Filename                                                                                      |Rate     Num|Rate    Num|Rate     Num
  ====================================================================================================================================
  lib/src/common/adyen_checkout_session.dart                                                    | 0.0%     25|    -     0|    -      0
  lib/src/common/model/checkout.dart                                                            | 0.0%      2|    -     0|    -      0
  lib/src/common/model/partial_payment/order_cancel_response.dart                               | 0.0%      1|    -     0|    -      0
  lib/src/common/model/partial_payment/partial_payment.dart                                     | 0.0%      1|    -     0|    -      0
  lib/src/common/model/payment_event.dart                                                       | 0.0%      4|    -     0|    -      0
  lib/src/drop_in/drop_in.dart                                                                  | 0.0%    163|    -     0|    -      0
  lib/src/drop_in/drop_in_platform_api.dart                                                     | 0.0%     18|    -     0|    -      0
  lib/src/util/dto_mapper.dart                                                                  |63.8%    185|    -     0|    -      0
  lib/src/util/payment_event_handler.dart                                                       | 0.0%     14|    -     0|    -      0

Copy link

LCOV of commit 9dbcbb5 during Check PR #938

Summary coverage rate:
  lines......: 10.1% (136 of 1353 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate:
                                                                                                |Lines       |Functions  |Branches    
  Filename                                                                                      |Rate     Num|Rate    Num|Rate     Num
  ====================================================================================================================================
  lib/src/common/adyen_checkout_session.dart                                                    | 0.0%     25|    -     0|    -      0
  lib/src/common/model/checkout.dart                                                            | 0.0%      2|    -     0|    -      0
  lib/src/common/model/partial_payment/order_cancel_response.dart                               | 0.0%      1|    -     0|    -      0
  lib/src/common/model/partial_payment/partial_payment.dart                                     | 0.0%      1|    -     0|    -      0
  lib/src/common/model/payment_event.dart                                                       | 0.0%      4|    -     0|    -      0
  lib/src/drop_in/drop_in.dart                                                                  | 0.0%    163|    -     0|    -      0
  lib/src/drop_in/drop_in_platform_api.dart                                                     | 0.0%     18|    -     0|    -      0
  lib/src/util/dto_mapper.dart                                                                  |63.8%    185|    -     0|    -      0
  lib/src/util/payment_event_handler.dart                                                       | 0.0%     14|    -     0|    -      0

Copy link

LCOV of commit ba5938d during Check PR #939

Summary coverage rate:
  lines......: 10.1% (136 of 1353 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate:
                                                                                                |Lines       |Functions  |Branches    
  Filename                                                                                      |Rate     Num|Rate    Num|Rate     Num
  ====================================================================================================================================
  lib/src/common/adyen_checkout_session.dart                                                    | 0.0%     25|    -     0|    -      0
  lib/src/common/model/checkout.dart                                                            | 0.0%      2|    -     0|    -      0
  lib/src/common/model/partial_payment/order_cancel_response.dart                               | 0.0%      1|    -     0|    -      0
  lib/src/common/model/partial_payment/partial_payment.dart                                     | 0.0%      1|    -     0|    -      0
  lib/src/common/model/payment_event.dart                                                       | 0.0%      4|    -     0|    -      0
  lib/src/drop_in/drop_in.dart                                                                  | 0.0%    163|    -     0|    -      0
  lib/src/drop_in/drop_in_platform_api.dart                                                     | 0.0%     18|    -     0|    -      0
  lib/src/util/dto_mapper.dart                                                                  |63.8%    185|    -     0|    -      0
  lib/src/util/payment_event_handler.dart                                                       | 0.0%     14|    -     0|    -      0

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generated code - no review required.

Copy link

LCOV of commit e068042 during Check PR #940

Summary coverage rate:
  lines......: 10.1% (136 of 1353 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate:
                                                                                                |Lines       |Functions  |Branches    
  Filename                                                                                      |Rate     Num|Rate    Num|Rate     Num
  ====================================================================================================================================
  lib/src/common/adyen_checkout_session.dart                                                    | 0.0%     25|    -     0|    -      0
  lib/src/common/model/checkout.dart                                                            | 0.0%      2|    -     0|    -      0
  lib/src/common/model/partial_payment/order_cancel_response.dart                               | 0.0%      1|    -     0|    -      0
  lib/src/common/model/partial_payment/partial_payment.dart                                     | 0.0%      1|    -     0|    -      0
  lib/src/common/model/payment_event.dart                                                       | 0.0%      4|    -     0|    -      0
  lib/src/drop_in/drop_in.dart                                                                  | 0.0%    163|    -     0|    -      0
  lib/src/drop_in/drop_in_platform_api.dart                                                     | 0.0%     18|    -     0|    -      0
  lib/src/util/dto_mapper.dart                                                                  |63.8%    185|    -     0|    -      0
  lib/src/util/payment_event_handler.dart                                                       | 0.0%     14|    -     0|    -      0

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generated code - no review required.

Copy link

LCOV of commit 6e6b94f during Check PR #941

Summary coverage rate:
  lines......: 10.1% (136 of 1353 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate:
                                                                                                |Lines       |Functions  |Branches    
  Filename                                                                                      |Rate     Num|Rate    Num|Rate     Num
  ====================================================================================================================================
  lib/src/common/adyen_checkout_session.dart                                                    | 0.0%     25|    -     0|    -      0
  lib/src/common/model/checkout.dart                                                            | 0.0%      2|    -     0|    -      0
  lib/src/common/model/partial_payment/order_cancel_response.dart                               | 0.0%      1|    -     0|    -      0
  lib/src/common/model/partial_payment/partial_payment.dart                                     | 0.0%      1|    -     0|    -      0
  lib/src/common/model/payment_event.dart                                                       | 0.0%      4|    -     0|    -      0
  lib/src/drop_in/drop_in.dart                                                                  | 0.0%    163|    -     0|    -      0
  lib/src/drop_in/drop_in_platform_api.dart                                                     | 0.0%     18|    -     0|    -      0
  lib/src/util/dto_mapper.dart                                                                  |63.8%    185|    -     0|    -      0
  lib/src/util/payment_event_handler.dart                                                       | 0.0%     14|    -     0|    -      0

Copy link

LCOV of commit 4754226 during Check PR #942

Summary coverage rate:
  lines......: 10.1% (136 of 1352 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate:
                                                                                                |Lines       |Functions  |Branches    
  Filename                                                                                      |Rate     Num|Rate    Num|Rate     Num
  ====================================================================================================================================
  lib/src/common/adyen_checkout_session.dart                                                    | 0.0%     25|    -     0|    -      0
  lib/src/common/model/checkout.dart                                                            | 0.0%      2|    -     0|    -      0
  lib/src/common/model/partial_payment/order_cancel_result.dart                                 | 0.0%      1|    -     0|    -      0
  lib/src/common/model/partial_payment/partial_payment.dart                                     | 0.0%      1|    -     0|    -      0
  lib/src/common/model/payment_event.dart                                                       | 0.0%      4|    -     0|    -      0
  lib/src/drop_in/drop_in.dart                                                                  | 0.0%    163|    -     0|    -      0
  lib/src/drop_in/drop_in_platform_api.dart                                                     | 0.0%     18|    -     0|    -      0
  lib/src/util/dto_mapper.dart                                                                  |64.1%    184|    -     0|    -      0
  lib/src/util/payment_event_handler.dart                                                       | 0.0%     14|    -     0|    -      0

Copy link

LCOV of commit 0db23b6 during Check PR #943

Summary coverage rate:
  lines......: 10.1% (136 of 1349 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate:
                                                                                                |Lines       |Functions  |Branches    
  Filename                                                                                      |Rate     Num|Rate    Num|Rate     Num
  ====================================================================================================================================
  lib/src/common/adyen_checkout_session.dart                                                    | 0.0%     25|    -     0|    -      0
  lib/src/common/model/checkout.dart                                                            | 0.0%      2|    -     0|    -      0
  lib/src/common/model/partial_payment/order_cancel_result.dart                                 | 0.0%      1|    -     0|    -      0
  lib/src/common/model/partial_payment/partial_payment.dart                                     | 0.0%      1|    -     0|    -      0
  lib/src/common/model/payment_event.dart                                                       | 0.0%      4|    -     0|    -      0
  lib/src/drop_in/drop_in.dart                                                                  | 0.0%    160|    -     0|    -      0
  lib/src/drop_in/drop_in_platform_api.dart                                                     | 0.0%     18|    -     0|    -      0
  lib/src/util/dto_mapper.dart                                                                  |64.1%    184|    -     0|    -      0
  lib/src/util/payment_event_handler.dart                                                       | 0.0%     14|    -     0|    -      0

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generated code - no review required.

Copy link

LCOV of commit 3858cae during Check PR #944

Summary coverage rate:
  lines......: 10.1% (136 of 1349 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate:
                                                                                                |Lines       |Functions  |Branches    
  Filename                                                                                      |Rate     Num|Rate    Num|Rate     Num
  ====================================================================================================================================
  lib/src/common/adyen_checkout_session.dart                                                    | 0.0%     25|    -     0|    -      0
  lib/src/common/model/checkout.dart                                                            | 0.0%      2|    -     0|    -      0
  lib/src/common/model/partial_payment/order_cancel_result.dart                                 | 0.0%      1|    -     0|    -      0
  lib/src/common/model/partial_payment/partial_payment.dart                                     | 0.0%      1|    -     0|    -      0
  lib/src/common/model/payment_event.dart                                                       | 0.0%      4|    -     0|    -      0
  lib/src/drop_in/drop_in.dart                                                                  | 0.0%    160|    -     0|    -      0
  lib/src/drop_in/drop_in_platform_api.dart                                                     | 0.0%     18|    -     0|    -      0
  lib/src/util/dto_mapper.dart                                                                  |64.1%    184|    -     0|    -      0
  lib/src/util/payment_event_handler.dart                                                       | 0.0%     14|    -     0|    -      0

Copy link

LCOV of commit d79c350 during Check PR #945

Summary coverage rate:
  lines......: 10.1% (136 of 1349 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate:
                                                                                                |Lines       |Functions  |Branches    
  Filename                                                                                      |Rate     Num|Rate    Num|Rate     Num
  ====================================================================================================================================
  lib/src/common/adyen_checkout_session.dart                                                    | 0.0%     25|    -     0|    -      0
  lib/src/common/model/checkout.dart                                                            | 0.0%      2|    -     0|    -      0
  lib/src/common/model/partial_payment/order_cancel_result.dart                                 | 0.0%      1|    -     0|    -      0
  lib/src/common/model/partial_payment/partial_payment.dart                                     | 0.0%      1|    -     0|    -      0
  lib/src/common/model/payment_event.dart                                                       | 0.0%      4|    -     0|    -      0
  lib/src/drop_in/drop_in.dart                                                                  | 0.0%    160|    -     0|    -      0
  lib/src/drop_in/drop_in_platform_api.dart                                                     | 0.0%     18|    -     0|    -      0
  lib/src/util/dto_mapper.dart                                                                  |64.1%    184|    -     0|    -      0
  lib/src/util/payment_event_handler.dart                                                       | 0.0%     14|    -     0|    -      0

@Robert-SD Robert-SD marked this pull request as ready for review November 28, 2024 09:36
@Robert-SD Robert-SD force-pushed the feature/addPartialPayments branch from d79c350 to 1307490 Compare November 28, 2024 12:23
Copy link

LCOV of commit 1307490 during Check PR #956

Summary coverage rate:
  lines......: 10.1% (136 of 1344 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate:
                                                                                                |Lines       |Functions  |Branches    
  Filename                                                                                      |Rate     Num|Rate    Num|Rate     Num
  ====================================================================================================================================
  lib/src/common/adyen_checkout_session.dart                                                    | 0.0%     25|    -     0|    -      0
  lib/src/common/model/checkout.dart                                                            | 0.0%      2|    -     0|    -      0
  lib/src/common/model/partial_payment/order_cancel_result.dart                                 | 0.0%      1|    -     0|    -      0
  lib/src/common/model/partial_payment/partial_payment.dart                                     | 0.0%      1|    -     0|    -      0
  lib/src/common/model/payment_event.dart                                                       | 0.0%      4|    -     0|    -      0
  lib/src/drop_in/drop_in.dart                                                                  | 0.0%    160|    -     0|    -      0
  lib/src/drop_in/drop_in_platform_api.dart                                                     | 0.0%     18|    -     0|    -      0
  lib/src/util/dto_mapper.dart                                                                  |64.1%    184|    -     0|    -      0
  lib/src/util/payment_event_handler.dart                                                       | 0.0%     14|    -     0|    -      0

@Robert-SD Robert-SD force-pushed the feature/addPartialPayments branch from 1307490 to 9cc78f6 Compare December 10, 2024 10:22
Copy link

LCOV of commit 9cc78f6 during Check PR #965

Summary coverage rate:
  lines......: 10.1% (136 of 1344 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate:
                                                                                                |Lines       |Functions  |Branches    
  Filename                                                                                      |Rate     Num|Rate    Num|Rate     Num
  ====================================================================================================================================
  lib/src/common/adyen_checkout_session.dart                                                    | 0.0%     25|    -     0|    -      0
  lib/src/common/model/checkout.dart                                                            | 0.0%      2|    -     0|    -      0
  lib/src/common/model/partial_payment/order_cancel_result.dart                                 | 0.0%      1|    -     0|    -      0
  lib/src/common/model/partial_payment/partial_payment.dart                                     | 0.0%      1|    -     0|    -      0
  lib/src/common/model/payment_event.dart                                                       | 0.0%      4|    -     0|    -      0
  lib/src/drop_in/drop_in.dart                                                                  | 0.0%    160|    -     0|    -      0
  lib/src/drop_in/drop_in_platform_api.dart                                                     | 0.0%     18|    -     0|    -      0
  lib/src/util/dto_mapper.dart                                                                  |64.1%    184|    -     0|    -      0
  lib/src/util/payment_event_handler.dart                                                       | 0.0%     14|    -     0|    -      0

Copy link

LCOV of commit c0c7a8d during Check PR #970

Summary coverage rate:
  lines......: 10.1% (136 of 1344 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate:
                                                                                                |Lines       |Functions  |Branches    
  Filename                                                                                      |Rate     Num|Rate    Num|Rate     Num
  ====================================================================================================================================
  lib/src/common/adyen_checkout_session.dart                                                    | 0.0%     25|    -     0|    -      0
  lib/src/common/model/checkout.dart                                                            | 0.0%      2|    -     0|    -      0
  lib/src/common/model/partial_payment/order_cancel_result.dart                                 | 0.0%      1|    -     0|    -      0
  lib/src/common/model/partial_payment/partial_payment.dart                                     | 0.0%      1|    -     0|    -      0
  lib/src/common/model/payment_event.dart                                                       | 0.0%      4|    -     0|    -      0
  lib/src/drop_in/drop_in.dart                                                                  | 0.0%    160|    -     0|    -      0
  lib/src/drop_in/drop_in_platform_api.dart                                                     | 0.0%     18|    -     0|    -      0
  lib/src/util/dto_mapper.dart                                                                  |64.1%    184|    -     0|    -      0
  lib/src/util/payment_event_handler.dart                                                       | 0.0%     14|    -     0|    -      0


private func removeGiftCardPaymentMethods(paymentMethods: PaymentMethods) -> PaymentMethods {
private func removeGiftCardPaymentMethods(paymentMethods: PaymentMethods, isPartialPaymentSupported: Bool) -> PaymentMethods {
if isPartialPaymentSupported {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be more Swifty it could be guard as a common syntax for early exits.

ios/Classes/dropIn/DropInPlatformApi.swift Show resolved Hide resolved
ios/Classes/dropIn/DropInPlatformApi.swift Show resolved Hide resolved
ios/Classes/dropIn/DropInPlatformApi.swift Show resolved Hide resolved
@@ -51,12 +51,14 @@ class InstantAdvancedComponent: BaseInstantComponent, InstantComponentProtocol {
onError(paymentEventDTO: paymentEventDTO)
case .action:
onAction(paymentEventDTO: paymentEventDTO)
case .update:
return
Copy link

@atmamont atmamont Dec 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some components silently return for case update. Apple Pay has a dedicated comment for code clarity, just an observation, maybe it is worth to add same comments?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion, will add a comment here as well to enhance code clarity.


val balanceResult = mapToBalanceDropInServiceResult(message.contentIfNotHandled as String)
lifecycleScope.launch {
delay(300)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this delay necessary?

Copy link

LCOV of commit 3be8f10 during Check PR #977

Summary coverage rate:
  lines......: 10.1% (136 of 1344 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate:
                                                                                                |Lines       |Functions  |Branches    
  Filename                                                                                      |Rate     Num|Rate    Num|Rate     Num
  ====================================================================================================================================
  lib/src/common/adyen_checkout_session.dart                                                    | 0.0%     25|    -     0|    -      0
  lib/src/common/model/checkout.dart                                                            | 0.0%      2|    -     0|    -      0
  lib/src/common/model/partial_payment/order_cancel_result.dart                                 | 0.0%      1|    -     0|    -      0
  lib/src/common/model/partial_payment/partial_payment.dart                                     | 0.0%      1|    -     0|    -      0
  lib/src/common/model/payment_event.dart                                                       | 0.0%      4|    -     0|    -      0
  lib/src/drop_in/drop_in.dart                                                                  | 0.0%    160|    -     0|    -      0
  lib/src/drop_in/drop_in_platform_api.dart                                                     | 0.0%     18|    -     0|    -      0
  lib/src/util/dto_mapper.dart                                                                  |64.1%    184|    -     0|    -      0
  lib/src/util/payment_event_handler.dart                                                       | 0.0%     14|    -     0|    -      0

araratthehero
araratthehero previously approved these changes Dec 18, 2024
atmamont
atmamont previously approved these changes Dec 19, 2024
@Robert-SD Robert-SD dismissed stale reviews from atmamont and araratthehero via 2b05fee December 19, 2024 09:46
Copy link

LCOV of commit 2b05fee during Check PR #978

Summary coverage rate:
  lines......: 10.1% (136 of 1344 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate:
                                                                                                |Lines       |Functions  |Branches    
  Filename                                                                                      |Rate     Num|Rate    Num|Rate     Num
  ====================================================================================================================================
  lib/src/common/adyen_checkout_session.dart                                                    | 0.0%     25|    -     0|    -      0
  lib/src/common/model/checkout.dart                                                            | 0.0%      2|    -     0|    -      0
  lib/src/common/model/partial_payment/order_cancel_result.dart                                 | 0.0%      1|    -     0|    -      0
  lib/src/common/model/partial_payment/partial_payment.dart                                     | 0.0%      1|    -     0|    -      0
  lib/src/common/model/payment_event.dart                                                       | 0.0%      4|    -     0|    -      0
  lib/src/drop_in/drop_in.dart                                                                  | 0.0%    160|    -     0|    -      0
  lib/src/drop_in/drop_in_platform_api.dart                                                     | 0.0%     18|    -     0|    -      0
  lib/src/util/dto_mapper.dart                                                                  |64.1%    184|    -     0|    -      0
  lib/src/util/payment_event_handler.dart                                                       | 0.0%     14|    -     0|    -      0

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generated code. No review required.

Comment on lines 281 to 283
guard !isPartialPaymentSupported else {
return paymentMethods
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this one is hard to read now 😅

Simple IF is better, since guard is for validation or edge-casese and here it is a pure Business logic.

if isPartialPaymentSupported {
    return paymentMethods
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙈

@@ -69,7 +69,7 @@ class AdyenCheckoutSession {
InstantPaymentType.applePay,
);
} else if (configuration is DropInConfiguration) {
return configuration.toDTO(sdkVersionNumber);
return configuration.toDTO(sdkVersionNumber, true);
Copy link
Contributor

@descorp descorp Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe make this one a constant? Like:

configuration.toDTO(sdkVersionNumber, alwaysSupportPartialPayments);

Copy link

LCOV of commit 63affaa during Check PR #982

Summary coverage rate:
  lines......: 10.1% (136 of 1344 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate:
                                                                                                |Lines       |Functions  |Branches    
  Filename                                                                                      |Rate     Num|Rate    Num|Rate     Num
  ====================================================================================================================================
  lib/src/common/adyen_checkout_session.dart                                                    | 0.0%     25|    -     0|    -      0
  lib/src/common/model/checkout.dart                                                            | 0.0%      2|    -     0|    -      0
  lib/src/common/model/partial_payment/order_cancel_result.dart                                 | 0.0%      1|    -     0|    -      0
  lib/src/common/model/partial_payment/partial_payment.dart                                     | 0.0%      1|    -     0|    -      0
  lib/src/common/model/payment_event.dart                                                       | 0.0%      4|    -     0|    -      0
  lib/src/drop_in/drop_in.dart                                                                  | 0.0%    160|    -     0|    -      0
  lib/src/drop_in/drop_in_platform_api.dart                                                     | 0.0%     18|    -     0|    -      0
  lib/src/util/dto_mapper.dart                                                                  |64.1%    184|    -     0|    -      0
  lib/src/util/payment_event_handler.dart                                                       | 0.0%     14|    -     0|    -      0

@Robert-SD Robert-SD merged commit adf1967 into main Dec 19, 2024
13 checks passed
@Robert-SD Robert-SD deleted the feature/addPartialPayments branch December 19, 2024 16:33
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants