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

Feat/improve payment detected behavior #403

Merged
merged 10 commits into from
Aug 14, 2024

Conversation

lissavxo
Copy link
Collaborator

@lissavxo lissavxo commented Apr 19, 2024

Related to #378

Description

  • Fixed logic to trigger success and transaction callback
  • Fixed sound to play only if the tx was successful
  • Isolate logic to trigger success
  • Added tests to shouldTriggerSuccess function
  • Removed unnecessary comments

Test plan

Open the project, run yarn clean:build make a payment and check if we trigger success correctly as described here #378

@Klakurka
Copy link
Member

when we have [sound:true hide-toasts: true] will we display sound ?

Yes

@lissavxo
Copy link
Collaborator Author

when we have [sound:true hide-toasts: true] will we display sound ?

Yes

Fixed

Copy link
Member

@Klakurka Klakurka left a comment

Choose a reason for hiding this comment

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

After changing the amount within an editable dialog, paying to it doesn't trigger on-success.

image

Copy link
Member

@Klakurka Klakurka left a comment

Choose a reason for hiding this comment

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

Let's add some tests for this branch.

We can talk about it together with @chedieck to see what we can + should do. It's tedious and unreliable to be testing things manually. The bug with the editable dialog is an example of something that is easy to miss during manual testing.

@lissavxo lissavxo force-pushed the feat/improve-payment-detected-behavior branch from cc23896 to bf722dc Compare May 1, 2024 04:09
@lissavxo lissavxo requested a review from Klakurka May 1, 2024 04:17
Copy link
Collaborator

@chedieck chedieck left a comment

Choose a reason for hiding this comment

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

Left some remarks about test naming, also pushed a commit improving a little on a test

I found that in the button generator:

  • Editable toggle set to false still allows it to be editable
  • Sending a TX to the address with the same amount, same payment id (in the opReturn) but different data (so different opReturn but same paymentId) triggers onSuccess, not onTransaction. For what I gathered from Ensure proper thing happens when payment is received #378 this is not desired behavior.
  • If we have paymentId disabled, then sending the tx with the correct amount and no paymentId still doesn't trigger onSuccess. My suspicion is that the "shouldTriggerOnSuccess" function is comparing undefined with '' or smth like that.

When solving the bugs above, make sure you first write tests that catch them, then solve them.

Finally, would be good to also:

  • add the yarn test:coverage command to the root folder
  • put min=0 in the amount & goal amount fields of the button generator

react/lib/tests/util/currency.test.ts Outdated Show resolved Hide resolved
react/lib/tests/util/currency.test.ts Outdated Show resolved Hide resolved
react/lib/util/api-client.ts Outdated Show resolved Hide resolved
@lissavxo lissavxo requested a review from chedieck May 7, 2024 14:19
Copy link
Collaborator

@chedieck chedieck left a comment

Choose a reason for hiding this comment

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

onSuccess triggered twice.
изображение

To reproduce the screenshot, go to chedieck.com/paybutton, and send 30XEC to the button with name "ONOPEN".

@lissavxo
Copy link
Collaborator Author

lissavxo commented May 7, 2024

onSuccess triggered twice. изображение

To reproduce the screenshot, go to chedieck.com/paybutton, and send 30XEC to the button with name "ONOPEN".

this happens on master too, I believe It is due to having a widget and a button with the same address in the same page, they are not isolated. For example, when you pay in the widget and you have two widgets to the same address both will change the qrcode to the check mark, this is why the callback is called twice.

@chedieck
Copy link
Collaborator

chedieck commented May 8, 2024

Okay, so let's start by breaking this into multiple PRs. I see some changes are really isolated from the rest, so separating those should be easy. By just reading the PR description, I would suggest:

Fixed logic to call OnSuccess and OnTransaction

1

Added a Vue.js paybutton generator to the dev page

2

Added css improvements to the html dev page

2

Cleaned the component widget container

1

added a new command to help testing yarn dev:refresh it will rebuild the react project and run dev

2

fix docs can-edit -> editable

1

fixed sound not playing even if sound:true

1

refactored utils

3

added new utils and hooks to remove extra responsibilities of components

3

added test:coverage command to generate coverage files from tests

4

... where 1-4 are branches which each of these changes should belong to. Bear in mind this is just a suggestion by reading what are the changes, I may well be putting together things that having nothing to do with each other (diffwise) and separating things that do.

@lissavxo
Copy link
Collaborator Author

lissavxo commented May 8, 2024

Okay, so let's start by breaking this into multiple PRs. I see some changes are really isolated from the rest, so separating those should be easy. By just reading the PR description, I would suggest:

Fixed logic to call OnSuccess and OnTransaction

1

Added a Vue.js paybutton generator to the dev page

2

Added css improvements to the html dev page

2

Cleaned the component widget container

1

added a new command to help testing yarn dev:refresh it will rebuild the react project and run dev

2

fix docs can-edit -> editable

1

fixed sound not playing even if sound:true

1

refactored utils

3

added new utils and hooks to remove extra responsibilities of components

3

added test:coverage command to generate coverage files from tests

4

... where 1-4 are branches which each of these changes should belong to. Bear in mind this is just a suggestion by reading what are the changes, I may well be putting together things that having nothing to do with each other (diffwise) and separating things that do.

thanks for the suggestion, breaking up these changes in smaller branches sounds like a good plan, will work on that, thanks

@lissavxo lissavxo force-pushed the feat/improve-payment-detected-behavior branch 7 times, most recently from 445f519 to e32950c Compare June 4, 2024 17:15
@lissavxo lissavxo force-pushed the feat/improve-payment-detected-behavior branch 5 times, most recently from ec82fda to efc4545 Compare June 4, 2024 19:52
@lissavxo lissavxo requested a review from chedieck June 4, 2024 19:57
@lissavxo lissavxo force-pushed the feat/improve-payment-detected-behavior branch from cb5f3ba to 5809521 Compare July 19, 2024 18:10
@lissavxo lissavxo requested a review from Klakurka July 19, 2024 23:40
@chedieck
Copy link
Collaborator

Tested on my server chedieck.com/paybutton

By trying to pay the first widget visible on the page, both get triggered to success, even though their OPRETURN and amount differs.

Now what I get is that success is not triggered on neither.

@lissavxo
Copy link
Collaborator Author

lissavxo commented Aug 1, 2024

Tested on my server chedieck.com/paybutton
By trying to pay the first widget visible on the page, both get triggered to success, even though their OPRETURN and amount differs.

Now what I get is that success is not triggered on neither.

This was due to rawMessage not being returned from server, when I tested on local server on master it works because local server returned rawMessage. Even though I did a change to consider the message if there is no rawMessage in transaction.
So the logic is , if there is a rawMessage we compare with the rawMessage if not we compare with message if exists.

@Klakurka
Copy link
Member

Klakurka commented Aug 1, 2024

Conflicts.

@lissavxo lissavxo force-pushed the feat/improve-payment-detected-behavior branch 2 times, most recently from 6c62da8 to 4516f81 Compare August 7, 2024 04:21
@lissavxo lissavxo force-pushed the feat/improve-payment-detected-behavior branch from 4516f81 to 89e269b Compare August 7, 2024 04:56
@lissavxo lissavxo requested a review from chedieck August 7, 2024 14:07
@chedieck
Copy link
Collaborator

chedieck commented Aug 7, 2024

Same issue as before when I tested. This was tested in my localhost, having paybutton-server running locally.

image

Receiving a 20XEC tx activates success in a paybutton with 20USD of amount. Even if there is only the 20USD widget there.

This is wrong not only because the amount is not being taken into account to activate it, but neither is the paymentId.

@lissavxo
Copy link
Collaborator Author

lissavxo commented Aug 7, 2024

Can you provide more info on this ? like the code you used to test it like the html code ?

@lissavxo lissavxo requested review from chedieck and removed request for chedieck August 13, 2024 19:01
Klakurka
Klakurka approved these changes Aug 13, 2024
@Klakurka Klakurka self-requested a review August 13, 2024 21:01
Copy link
Collaborator

@chedieck chedieck left a comment

Choose a reason for hiding this comment

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

LGTM!

@Klakurka Klakurka merged commit bf58c4f into master Aug 14, 2024
1 check passed
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

3 participants