OpenMAVN / PM

OpenMAVN project management
MIT License
0 stars 3 forks source link

Continue Purchase of Reserved Vouchers from mobile app #165

Closed Mamyako closed 4 years ago

Mamyako commented 4 years ago

Continued from #54 (backend part is supposed to be ready under #54)

As a customer who hasn't finalized purchasing a voucher I want to be able to continue voucher payment from mobile app

  1. Since a customer can only have 1 reserved voucher at a given time, If a customer already has a reserved voucher, the customer should not be able to reserve another voucher until this reservation is over (paid or canceled). GIVEN I am logged in as a customer AND I have a reserved voucher (not paid yet) WHEN I open a voucher from the Offers list AND I try to reserve the voucher THEN I get error message ” You have another voucher purchase in progress. Please finalize or cancel it and try again.” with button “Go to reserved voucher” AND If I click “Go to reserved voucher” button I am redirected to Voucher Details Page where I can either cancel or continue purchasing the currently reserved voucher. (AND once I finalize the purchase or cancel it, then I can reserve another voucher)
pddimitrova commented 4 years ago

@ElenaBelyavskaya @MarlonMaercz This has already been done as part of #54 . Is there anything else that needs to be done that is missing in the current implementation?

pddimitrova commented 4 years ago

@MarlonMaercz Part 2 of the ACs is not as simple as it sounds. Vouchers have pagination, which means that there is no guarantee that we have info whether a certain voucher is pending or not at the moment when the user attempts to purchase it. I suggest another simpler method for handling this for now: The BE returns an error when a user tries to purchase ANY voucher while they have one in pending state. I suggest we just show an error message instead of fetching all vouchers in advance and adding additional complexity at this point. What do you think?

ElenaBelyavskaya commented 4 years ago

@pddimitrova by ANY ("The BE returns an error when a user tries to purchase ANY voucher while they have one in pending state."), do you mean incl. voucher of any other type, not just another instance of the same voucher? If yes, that is not good from the user perspective - we should let the user buy a voucher, even if the user has another voucher reserved (otherwise we would trouble users with additional actions when trying to make a particular purchase).

I see that there's an issue with detecting pending vouchers when showing the list of offers. As a compromise, we can follow the approach with the same 'Buy Voucher' button: if a user tries to purchase a voucher while he already has a reserved instance of this voucher, when clicking the Buy button the check is done if there is already a reserved instance of this particular voucher for this customer, and if yes - the customer is redirected to finalize the purchase he earlier started. Would it work efficiently?

pddimitrova commented 4 years ago

@starkmsu Could you please confirm or am I wrong? If I have reserved a voucher, I cannot reserve any other voucher from any campaign? @ElenaBelyavskaya Yes, if BE returns an error that the voucher is already reserved, we can fetch the payment URL and redirect them to continue their purchase. Shouldn't take more that 1-2 additional seconds

pddimitrova commented 4 years ago

@ElenaBelyavskaya I actually made a mistake in my previous comment. In order to get url for payment of the reserved voucher, we need to fetch ALL vouchers, then find the one that is the same as this campaign and only then fetch the payment url. We can do this if you find it very important and is worth the effort, but I suggest at this point we just show error " You have already reserved this voucher. Continue your purchase in your voucher wallet" or something like that. I am not saying this is not important, I am trying to say we have lots of important new features and this somehow feels like less of a priority. The user can already do this flow from their voucher wallet.

ElenaBelyavskaya commented 4 years ago

@pddimitrova and how big is the effort? Definitely, the initially proposed approach is much more comfortable for the user, than the alternative one. If we follow the simplified alternative way with the error, at least it's preferable to add a link to go directly to this voucher in the wallet after the error-which will add some dev effort too, but still will require additional actions from the user... How does the comparison of the time consumption look lie for the two implementation options?

ElenaBelyavskaya commented 4 years ago

In fact once the feature with finalizing the purchase via Wallet is working, we can go with a button 'Finalize purchase in your wallet' for vouchers with reservations in the Offers list, click on which would lead to this reserved voucher instance in the customer's wallet.

pddimitrova commented 4 years ago

@ElenaBelyavskaya Dev effort will be fine, we can do it in 2 days max. The flow seems a bit excessive since we will fetch all vouchers. Filter, then do another request and then filter and do another request, which takes time and the user just stands there waiting. @starkmsu Is there an option to add an endpoint that we can use in such case? For example, the user has a voucher from campaign X reserved. They go to campaigns, select campaign X and try to reserve another voucher. I have two ideas here:

  1. Instead of error, just return the payment url for the already reserved voucher.
  2. Return error, but expose an endpoint that could simplify the flow, for example get payment url by campaignID for reserved vouchers.

Do you think any of these is a good idea? Are they doable?

ElenaBelyavskaya commented 4 years ago

@pddimitrova I added one more comment - probably the effort would be less (since it's inside the particular voucher - less filtering, right?)

pddimitrova commented 4 years ago

@ElenaBelyavskaya No, it doesn't make any difference unless @starkmsu agrees to expose an endpoint to help with this flow.

starkmsu commented 4 years ago

@pddimitrova , I suggest to adjust on BE the implementation like this: On reservation attempt, BE will return error code (None or PendingReservations) and a list of short codes of existing reserved vouchers (for the future - in case we allow concurrent reservations for different campaigns) Is that ok?

starkmsu commented 4 years ago

Actually it makes sense to return only 1 short code, cause if we allow only 1 pending reservation at a time then 1 code is enough, if we allow multiple then only 1 voucher from the same campaign might prevent the current reservation attempt.

pddimitrova commented 4 years ago

@starkmsu Hm can you give an example? This is the json that is currently returned when user has a reserved voucher: { "error": "CustomerHaveAnotherReservedVoucher", "message": "The customer have another voucher in reserved state so he can't reserve another one" }

Do you mean we'll add another property in the json?

How about exposing a GET /paymentUrl that accepts a campaignId and returns the payment url for this campaignId if the user already has a reservation and an error if they don't?

ElenaBelyavskaya commented 4 years ago

@pddimitrova @starkmsu I have adjusted the desc counting a second reservation cannot be done currently, in accordance with the approach we all seem to agree