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

Refactor / align payment (upgrade) integration flows #565

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

ChristiaanScheermeijer
Copy link
Collaborator

Description

This proposal PR is my attempt to align the subscription switch logic discrepancy between the JWP and Cleeng integration. These two features (doing the same) were implemented differently.

Motivated by #562 and #555 I'm hoping we can simplify flows and eliminate differences between providers. To disable features, we should be using the integration feature flags to keep the code intact for other providers (as long we don't have alternatives).

Copy link

github-actions bot commented Jul 1, 2024

Visit the preview URL for this PR (updated for commit fb0d284):

https://ottwebapp--pr565-refactor-payment-con-dffj8f27.web.app

(expires Wed, 31 Jul 2024 10:43:50 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: c198f8a3a199ba8747819f7f1e45cf602b777529

@ChristiaanScheermeijer ChristiaanScheermeijer added JWP Audit This PR needs a review from an JWP employee Needs discussion This PR needs to be discussed before merging labels Jul 1, 2024

await this.accountService.updateCustomer({
metadata: {
[`${subscription.subscriptionId}_pending_downgrade`]: toOfferId,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh...this part was in the hook previously. Makes sense to have it here.

@borkopetrovicc
Copy link
Contributor

borkopetrovicc commented Jul 3, 2024

Screenshot 2024-07-03 at 13 28 40

I see the Renew subscription button on JWP side. This is not aligned wit our design where we should only have cancel subscription you can see in the link: https://www.figma.com/design/qLl8KxBOOr640h18ICx0H6/Web-app?t=UrJZI5RpFBxrWajc-0
Screenshot 2024-07-03 at 13 36 40

I have this #565 pr that solves the problem without impacting the cleeng flow simply by using feature flag.I think we should merge this and then if we need we can refractor it later

@@ -61,7 +61,7 @@ export default class JWPAccountService extends AccountService {
canUpdateEmail: false,
canSupportEmptyFullName: false,
canChangePasswordWithOldPassword: true,
canRenewSubscription: false,
canRenewSubscription: true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like it can't be done for JWP now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, this should be reverted and solved with a canSwitchSubscription flag instead.


getOrder = undefined;

switchSubscription = undefined;
switchSubscription: SwitchSubscription = async (payload) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we also remove changeSubscription method from subscription service?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes!

@@ -159,58 +115,39 @@ const Payment = ({
}
}

const showChangeSubscriptionButton = (!isExternalPaymentProvider && offerSwitchesAvailable) || (!isChangingOffer && !canRenewSubscription);
const showChangeSubscriptionButton = !isExternalPaymentProvider && offerSwitchesAvailable;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we should also add canChangeSubscription feature flag to hide the button even though we get some offers?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, that would even be better. I think the canRenewSubscription flag is used were it shouldn't and this can fix that as well.

@AntonLantukh
Copy link
Collaborator

@ChristiaanScheermeijer looks great, thank you! Just some small comments. Probably some e2e tests also need changes.

@ChristiaanScheermeijer
Copy link
Collaborator Author

@AntonLantukh thanks, this is still pretty POC'ish. Do you think it's worth to finish this PR? Perhaps we should do that when #563 is merged?

!isGrantedSubscription &&
!isChangingOffer &&
canRenewSubscription ? (
{(activeSubscription.status === 'active' || activeSubscription.status === 'active_trial') && !isGrantedSubscription && canRenewSubscription ? (
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This condition should be checked. I think the canRenewSubscription should be removed for the cancel subscription button. So:

  1. has subscription and is active -> Show "Cancel Subscription" button
  2. has subscription and is not active and canRenewSubscription -> show "Renew Subscription" button

@AntonLantukh
Copy link
Collaborator

@AntonLantukh thanks, this is still pretty POC'ish. Do you think it's worth to finish this PR? Perhaps we should do that when #563 is merged?

@ChristiaanScheermeijer I find this approach cleaner than what we have when we try to build additional complexity on top of current logic. You can finish it if you have some time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JWP Audit This PR needs a review from an JWP employee Needs discussion This PR needs to be discussed before merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants