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

[HOLD] [$1000] iOS: Paypal.me payment method disappears when deleting a PayPal user name offline #22064

Closed
1 of 6 tasks
kavimuru opened this issue Jul 2, 2023 · 38 comments
Closed
1 of 6 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors Weekly KSv2

Comments

@kavimuru
Copy link

kavimuru commented Jul 2, 2023

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Action Performed:

  1. Go to settings then choose Payments
  2. Click on Add payment method button.
  3. Choose paypal.me
  4. Now turn off your internet connection and be offline
  5. Insert user name and click on Add Paypal Account
  6. Now click the account you added and Delete the account.
  7. Now turn on your internet connection and be online.
  8. Now click the Add Payment Method button. Notice that the paypal.me choice is not there.

Expected Result:

Paypal.me payment method should be there

Actual Result:

Paypal.me payment method is not there

Workaround:

Can the user still use Expensify without this being fixed? Have you informed them of the workaround?

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.3.35-5
Reproducible in staging?: y
Reproducible in production?: y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation

RPReplay_Final1687804398.MP4
PayPall.0107.mp4

Expensify/Expensify Issue URL:
Issue reported by: @daveSeife
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1687805526273609

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01424c2ea7e73e9df8
  • Upwork Job ID: 1675717205927723008
  • Last Price Increase: 2023-07-10
@kavimuru kavimuru added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jul 2, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 2, 2023

Triggered auto assignment to @sophiepintoraetz (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@melvin-bot
Copy link

melvin-bot bot commented Jul 2, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@sophiepintoraetz
Copy link
Contributor

@sophiepintoraetz sophiepintoraetz added the External Added to denote the issue can be worked on by a contributor label Jul 3, 2023
@melvin-bot melvin-bot bot changed the title iOS: Paypal.me payment method disappears when deleting a PayPal user name offline [$1000] iOS: Paypal.me payment method disappears when deleting a PayPal user name offline Jul 3, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 3, 2023

Job added to Upwork: https://www.upwork.com/jobs/~01424c2ea7e73e9df8

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jul 3, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 3, 2023

Current assignee @sophiepintoraetz is eligible for the External assigner, not assigning anyone new.

@melvin-bot
Copy link

melvin-bot bot commented Jul 3, 2023

Triggered auto assignment to Contributor-plus team member for initial proposal review - @s77rt (External)

@asadath1395
Copy link

asadath1395 commented Jul 3, 2023

Proposal

Please re-state the problem that we are trying to solve in this issue.

Paypal.me payment method disappears when deleting a PayPal user name offline

What is the root cause of that problem?

Its happening because of mixing onyx merge and set methods. We can see the error in the console after following the reproduction method and going online. The doc also mentions not to mix both the methods. As a result of mixing both the methods, seems like the set method which is supposed to remove the key gets ignored. Also when the user is online and he tries to delete the Paypal.me method, we are setting the optimisticData different inorder to show the user the payment is being deleted, the following is the API response we get

  {
      "jsonCode": 200,
      "requestID": "7e0cf514bf8c2fe3-CNN",
      "onyxData": [
          {
              "onyxMethod": "set",
              "key": "paypal",
              "value": null
          }
      ]
  }

but in the code we have the following optimistic data

const optimisticData = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.PAYPAL,
value: {pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE},
},
];

We can see that the onyxMethod and value is not matching with the API response. Because of wrong optimistic data, the list is getting filtered here
if (!network.isOffline) {
combinedPaymentMethods = _.filter(
combinedPaymentMethods,
(paymentMethod) => paymentMethod.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || !_.isEmpty(paymentMethod.errors),
);
}
because the pendingAction is set to CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE. Even after the user coming online and the API being successful, the wrong data still lies in the Onyx store and the set method is ignored resulting in stale data in onyx store and the above filter removes it always. Also on a side-note, the value set here
const successData = [
{
onyxMethod: Onyx.METHOD.SET,
key: ONYXKEYS.PAYPAL,
value: {},
},
];
is not correct, as the API gives null in the response we are setting it as {}

What changes do you think we should make in order to solve the problem?

  1. We can update the optimistic data to match the API response the problem with this approach is the feedback of showing user the payment method is getting deleted will be lost
  2. Fix the API response to make both the add and delete consistent method

What alternative solutions did you explore? (Optional)

NA

@manjesh-yadav
Copy link
Contributor

Proposal

Please re-state the problem that we are trying to solve in this issue.

Paypal.me payment method disappears when deleting a PayPal user name offline

What is the root cause of that problem?

  • We add Paypal.me in offline mode and then Delete the same Paypal.me in offline mode.
  • That makes two API calls persisted to disk addPaypalMeAddress and deletePaypalMeAddress
  • When we go online that two API call simultaneously

Unfortunately, we use Onyx.merge for addPaypalMeAddress and Onyx.set for deletePaypalMeAddress with same key Onyx key paypal but it is recommended use set or merge at once not both

Screenshot 2023-07-03 at 11 47 24 AM

Actually, we use Onyx.set for deletePaypalMeAddress for solving issue in PR

// Success data required for Android, more info here https://github.com/Expensify/App/pull/17903#discussion_r1175763081
const successData = [
{
onyxMethod: Onyx.METHOD.SET,
key: ONYXKEYS.PAYPAL,
value: {},
},
];

What changes do you think we should make in order to solve the problem?

Solution 1

We can also use Onyx.METHOD.SET (Onyx.set) for addPaypalMeAddress to avoid conflict.

Soluciton 2

I check we hide add payment method button in offline mode for the Debit card and Bank accounts we can also hide it for Papal.me to avoid conflict.

What alternative solutions did you explore? (Optional)

Hide payment method for Papal.me in offline mode

@pradeepmdk
Copy link
Contributor

pradeepmdk commented Jul 3, 2023

Proposal

Please re-state the problem that we are trying to solve in this issue.

Paypal.me payment method disappears when deleting a PayPal user name offline

What is the root cause of that problem

When offline mode add the paypal method and delete after that coming to online onyx set or merge conflict throwing the error so that set not happen
Screenshot 2023-07-03 at 12 12 06 PM

Screenshot 2023-07-03 at 12 14 01 PM assets/16595846/aa674505-60c0-4c15-9ace-34fbb9bed4fc"> Screenshot 2023-07-03 at 12 17 42 PM

What changes do you think we should make in order to solve the problem?

we need merge the data
Screenshot 2023-07-03 at 12 14 15 PM

What alternative solutions did you explore? (Optional)

N/A

@s77rt
Copy link
Contributor

s77rt commented Jul 3, 2023

@asadath1395 Thanks for the proposal. Your RCA is correct. The first solution would work but it's basically a revert of #17903 which will reintroduce #17795. The second solution is not clear i.e. what data should we work with and which method?

@s77rt
Copy link
Contributor

s77rt commented Jul 3, 2023

@manjesh-yadav Thanks for the proposal. Your RCA is correct. The first solution (same note as above ^) it's a revert of #17903 which will reintroduce #17795. We would still need to fix #17795 if we go with the revert approach. The second solution does not seem much relevant here, how would that fix the root cause, we would still be using two different Onyx methods.

@s77rt
Copy link
Contributor

s77rt commented Jul 3, 2023

@pradeepmdk Thanks for the proposal. Your RCA is correct. Your suggested solution makes sense but it's hard to maintain every object key. I think we should clear the object root directly instead of clearing each key separately. This may require some data restructure.

@pradeepmdk
Copy link
Contributor

pradeepmdk commented Jul 4, 2023

@s77rt yes. we can use the root key for this. so that we can just define undefined the root key.

@asadath1395
Copy link

@s77rt This seems like an issue in the library. There is already an issue opened Expensify/react-native-onyx#266

@s77rt
Copy link
Contributor

s77rt commented Jul 4, 2023

@pradeepmdk Can you please elaborate how would that work? Merging an empty object seems to be a noop.

@s77rt
Copy link
Contributor

s77rt commented Jul 4, 2023

@asadath1395 I'm not sure we are looking at the same issue. That issue is about order inconsistency while this one is about the SET method not taking effect at all and we get a thrown error. I think we should try to avoid mixing the methods for now as mixed methods (for same key) does not seem to be supported (it's more like limitation than a bug).

@pradeepmdk
Copy link
Contributor

@pradeepmdk Can you please elaborate how would that work? Merging an empty object seems to be a noop.

@s77rt I thought it will work... but still merging with object only. because when come to online two more api call happen
ReconnectApp and OpenPaymentsPage that also having the paypal key with merge. so object only merged.
const successData = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PAYPAL, value: '', }, ];
as per the documentation, we can't use both. when come online due to a conflict other api also has this key its happen.
Screenshot 2023-07-05 at 10 42 11 AM

Alternative Solution

on delete success instead of set we can use merge with some key for identifying for API is success ex:
const successData = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.PAYPAL,
value: {deletedSuccess: true},
},
];
after that using connect we can set an empty object

Onyx.connect({
key: ONYXKEYS.PAYPAL,
callback: (val) => {
console.log(val);
if(val && val.deletedSuccess) {
Onyx.set(ONYXKEYS.PAYPAL, {});
}
},
});

@s77rt
Copy link
Contributor

s77rt commented Jul 5, 2023

@pradeepmdk Thanks for the update. I don't think the alternative solution is something that we should do, it looks too hacky.

@melvin-bot melvin-bot bot added the Overdue label Jul 7, 2023
@s77rt
Copy link
Contributor

s77rt commented Jul 8, 2023

Not overdue. Still looking for proposals...

@melvin-bot melvin-bot bot removed the Overdue label Jul 8, 2023
@pradeepmdk
Copy link
Contributor

@s77rt
another alternative solution
actually, they are hiding the paypal.me option based on the description in the AddPaymentMethodMenu.js. on that, we can add one more condition this
...(props.shouldShowPaypal && (!props.payPalMeData.description || props.payPalMeData.pendingAction == CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE)
in the same way we need empty the pendingAction on addpaypal address

Screenshot 2023-07-08 at 8 00 34 AM

@melvin-bot melvin-bot bot removed the Overdue label Jul 11, 2023
@s77rt
Copy link
Contributor

s77rt commented Jul 11, 2023

@sophiepintoraetz We are still looking for more proposals here.

@s77rt
Copy link
Contributor

s77rt commented Jul 11, 2023

Had a discussion here https://expensify.slack.com/archives/C01GTK53T8Q/p1689031771678159 where we encountered a similar onyx problem. I think we may just hold for Expensify/react-native-onyx#266 but I'm not sure if that would actually fix the issue. Yet seems a safe call. cc @neil-marcellini

@pradeepmdk
Copy link
Contributor

@s77rt In the latest code we are facing new issue delete is not happing.when offline to online
https://github.com/Expensify/App/assets/16595846/4c5445f6-2380-4767-850d-adc06ea5e3bc

@s77rt
Copy link
Contributor

s77rt commented Jul 12, 2023

@pradeepmdk It could be related to the same issue. The onyx SET does not seem to take effect.

@sophiepintoraetz
Copy link
Contributor

@s77rt - so is your recommendation to hold or solicit more proposals or do both?

@s77rt
Copy link
Contributor

s77rt commented Jul 14, 2023

@sophiepintoraetz Let's hold for Expensify/react-native-onyx#266

@sophiepintoraetz sophiepintoraetz changed the title [$1000] iOS: Paypal.me payment method disappears when deleting a PayPal user name offline [HOLD] [$1000] iOS: Paypal.me payment method disappears when deleting a PayPal user name offline Jul 14, 2023
@sophiepintoraetz sophiepintoraetz added Weekly KSv2 and removed Daily KSv2 labels Jul 14, 2023
@melvin-bot melvin-bot bot added the Overdue label Jul 24, 2023
@sophiepintoraetz
Copy link
Contributor

Still holding.

@sophiepintoraetz
Copy link
Contributor

Still holding.

@melvin-bot melvin-bot bot added the Overdue label Aug 10, 2023
@s77rt
Copy link
Contributor

s77rt commented Aug 10, 2023

Still on hold

@melvin-bot melvin-bot bot removed the Overdue label Aug 10, 2023
@melvin-bot melvin-bot bot added the Overdue label Aug 21, 2023
@sophiepintoraetz
Copy link
Contributor

Still holding

@melvin-bot melvin-bot bot removed the Overdue label Aug 21, 2023
@melvin-bot melvin-bot bot added the Overdue label Aug 30, 2023
@s77rt
Copy link
Contributor

s77rt commented Aug 30, 2023

Still on hold. Expensify/react-native-onyx#266

@melvin-bot melvin-bot bot removed the Overdue label Aug 30, 2023
@pradeepmdk
Copy link
Contributor

I think PayPal going to deprecate #26368

@sophiepintoraetz
Copy link
Contributor

Great spot - thanks @pradeepmdk

@sophiepintoraetz
Copy link
Contributor

Checking in slack

@sophiepintoraetz
Copy link
Contributor

Closing, we are deprecating Paypal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors Weekly KSv2
Projects
None yet
Development

No branches or pull requests

6 participants