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

MBL-1285: Implement CompleteOnSessionCheckoutMutation for new and existing cards #2005

Conversation

amy-at-kickstarter
Copy link
Contributor

@amy-at-kickstarter amy-at-kickstarter commented Mar 28, 2024

📲 What

Implement CompleteOnSessionCheckoutMutation for new and existing cards in the late-pledge flow

🤔 Why

This is the last mutation call required to actually complete the pledge!

This PR is intentionally incomplete, to keep the changes a bit more manageable. Follow-up PRs will do the following:

  • Implement CompleteOnSessionCheckoutMutation for ApplePay
  • Route successful transactions to the Thanks page
  • Route unsuccessful transactions back to the Select Reward page

👀 See

Screenshot 2024-03-28 at 11 05 56 AM

@amy-at-kickstarter amy-at-kickstarter force-pushed the feat/adyer/MBL-1285/completeonsessioncheckout-new-and-existing-cards branch 2 times, most recently from 978d902 to f68029a Compare March 28, 2024 17:25
@amy-at-kickstarter amy-at-kickstarter changed the title MBL-1285: implement CompleteOnSessionCheckoutMutation for new and existing cards MBL-1285: Implement CompleteOnSessionCheckoutMutation for new and existing cards Mar 28, 2024
@amy-at-kickstarter amy-at-kickstarter marked this pull request as ready for review March 28, 2024 17:41
Copy link
Contributor

@ifosli ifosli left a comment

Choose a reason for hiding this comment

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

I have one major concern about possibly duplicating complete checkout; otherwise just a couple nits. We're almost there!


#if DEBUG
let serverError = error.errorMessages.first ?? ""
let message = "\(Strings.Something_went_wrong_please_try_again())\n\(serverError)"
Copy link
Contributor

Choose a reason for hiding this comment

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

I like this pattern!

@@ -1,6 +1,6 @@
import Foundation

extension GraphAPI.ApplePayInput {
public extension GraphAPI.ApplePayInput {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Should this change be in this pr?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope! Fixed.

@@ -335,7 +343,57 @@ public class PostCampaignCheckoutViewModel: PostCampaignCheckoutViewModelType,

// MARK: CompleteOnSessionCheckout

// TODO: Call .completeOnSessionCheckout when self.confirmPaymentSuccessfulProperty.signal is called
let completeCheckoutWithExistingCardInput: Signal<GraphAPI.CompleteOnSessionCheckoutInput, Never> = Signal
.combineLatest(self.confirmPaymentSuccessfulProperty.signal.skipNil(), checkoutId, selectedExistingCard)
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 is going to have the same issue as before. Let's say I first select an existing card, then add a new card. Now both selectedExistingCard and selectedNewCard will have values set (the existing one is outdated, but it doesn't know that). Once confirmPaymentSuccessfulProperty has an updated value, both this and the new card version of it will fire. I'm pretty sure that, in order to prevent this from happening, we need to add a filter after the combineLatest.

Alternatively, if we want to be able to just use selectedNewCard/selectedExistingCard we could map the opposite version to nil and filter on that (or return early/map to nil in the map/ect). Ie make sure that these signals won't both have valid cards at the same time.

For this specific call, though, I think it'd be easiest to just have one completeCheckoutWithCardInput method and switch on card.isNewPaymentMethod for the one field that's different.

AppEnvironment.current.apiService.completeOnSessionCheckout(input: input).materialize()
}

self.checkoutComplete = checkoutCompleteSignal.signal.ignoreValues()
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I'm not sure about this, but I think this might need to be checkoutCompleteSignal.signal.values().ignoreValues() in order to prevent it from also firing if there's an error. Will you test it if you haven't already?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ha, yup, you're right. Happened to me a few times.

amy-at-kickstarter added a commit that referenced this pull request Mar 28, 2024
amy-at-kickstarter added a commit that referenced this pull request Mar 28, 2024
@amy-at-kickstarter amy-at-kickstarter force-pushed the feat/adyer/MBL-1285/completeonsessioncheckout-new-and-existing-cards branch from cbd6aa2 to a7390cb Compare March 28, 2024 20:55
@amy-at-kickstarter amy-at-kickstarter force-pushed the feat/adyer/MBL-1285/completeonsessioncheckout-new-and-existing-cards branch from a7390cb to 0dae26b Compare April 1, 2024 13:49
@amy-at-kickstarter amy-at-kickstarter merged commit cfe6054 into main Apr 1, 2024
5 checks passed
@amy-at-kickstarter amy-at-kickstarter deleted the feat/adyer/MBL-1285/completeonsessioncheckout-new-and-existing-cards branch April 1, 2024 14:38
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.

None yet

2 participants