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

PayPal: Remove Checkout Listener Pattern #307

Merged
merged 6 commits into from
Dec 12, 2024

Conversation

sshropshire
Copy link
Collaborator

Summary of changes

  • This PR migrates the PayPalClient checkout flow away from the listener pattern.
  • Migration Guide updates will come in a later PR
  • Users must now balance calls to PayPalWebCheckoutClient.start() with calls to PayPalWebCheckoutClient.finishStart() to complete a vault flow

Checklist

  • Added a changelog entry

Authors

List GitHub usernames for everyone who contributed to this pull request.

Comment on lines +8 to +9
* Remove `CardClient.approveOrderListener` property
* Remove `CardClient.cardVaultListener` property
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I realized these should be added to CardClient as well.

@sshropshire sshropshire marked this pull request as ready for review December 11, 2024 16:39
@sshropshire sshropshire requested a review from a team as a code owner December 11, 2024 16:39
@@ -173,6 +154,25 @@ class PayPalWebViewModel @Inject constructor(
}

fun handleBrowserSwitchResult(activity: ComponentActivity) {
authState?.let { paypalClient?.completeAuthChallenge(activity.intent, it) }
val result = authState?.let { paypalClient?.finishStart(activity.intent, it) }
Copy link
Collaborator

@KunJeongPark KunJeongPark Dec 12, 2024

Choose a reason for hiding this comment

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

I had to do a double take on this because our checkout main function is "start"
But it goes with the pattern. finish[function]

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah honestly I wouldn't mind renaming it to either checkout() or confirmPaymentSource(). It might be nice to have CardClient.confirmPaymentSource() as well instead of approveOrder() to align with PPaaS.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Then it would be finishCheckout() or finishConfirmPaymentSource().

Copy link
Collaborator

@KunJeongPark KunJeongPark Dec 12, 2024

Choose a reason for hiding this comment

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

I like checkout() but maybe it's misleading because we provide intermediate steps in our SDK.
In CardClient, we have approveOrder, which is what we do. maybe that makes sense
approveOrder for both CardClient and PayPalwebCheckout but let's hold on changing that
so we can address it on different PRs. wdyt?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My bad I missed this. I agree we should hold off on re-naming until we're closer to GA.

}
} else {
PayPalWebCheckoutFinishStartResult.NoResult
Copy link
Collaborator

Choose a reason for hiding this comment

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

I c. this is possible although just theoretically, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

NoResult really means the SDK doesn't have enough information to determine the state of the browser switched flow. We don't receive a "close" event with Chrome Custom Tabs or anything, so when the merchant app comes back into the foreground we have to parse the deep link to determine if it was successful.

Some merchants may choose to support other browser-switch enabled payment methods in the same view. E.g. we have to make sure that we don't provide a false-postive result for PayPal success when the deep link indicates that the success event is actually for Card. So if the deep link is for another payment method other than PayPal, PayPalWebCheckoutClient returns NoResult.

@sshropshire sshropshire merged commit 4afcf91 into main Dec 12, 2024
6 checks passed
@sshropshire sshropshire deleted the paypal_remove_checkout_listener branch December 12, 2024 18:40
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.

2 participants