Glench / ExtPay

The JavaScript library for ExtensionPay.com — payments for your browser extensions, no server needed.
https://extensionpay.com
Other
517 stars 65 forks source link

Help: onPaid listener is not triggering while testing #27

Closed complanboy2 closed 2 years ago

complanboy2 commented 2 years ago

is extPay.onPaid.addListener() is only limited for real payment. When I'm changing the status to 'Active' during testing, it's NOT triggered.

Kindly help, thanks.

Glench commented 2 years ago

Well, technically that's not the first payment so I don't think it makes sense to trigger that event when changing the subscriptions status in development. To test the onPaid listener , I would uninstall and reinstall the extension to reset your user to unpaid, then "pay" using the development flow.

TwistedMexi commented 1 year ago

Wait, is the onPaid event not meant to capture each time a user pays (and thus becomes active again)?

If not, then what should we use to re-enable the features after they renew their plan?

Thanks.

Glench commented 1 year ago

Please use the normal extpay.getUser() function and check the paid field. It is much better to check that each time than just check once in an onPaid listener.

TwistedMexi commented 1 year ago

Yeah I understand that, but I want to activate the features for all existing tabs the moment they pay, so an event on payment is important.

I have it working if I rename the extension folder and reimport it. The first time I "pay" it triggers properly.

So I guess my concern is, is this just a bug with the developer status changes, or does this event really only trigger on their first every payment?

On Wed, Oct 11, 2023, 2:26 PM Glen Chiacchieri @.***> wrote:

Please use the normal extpay.getUser() function and check the paid field. It is much better to check that each time than just check once in an onPaid listener.

— Reply to this email directly, view it on GitHub https://github.com/Glench/ExtPay/issues/27#issuecomment-1758260834, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVGSNKZVWKB4EBAQ4ENFLLX63QF7ANCNFSM5UYOUKCA . You are receiving this because you commented.Message ID: @.***>

Glench commented 1 year ago

Yes, the onPaid event listener triggers on the first payment, just as you described. It does not trigger for later subscription payments. If you need that, then I would architect your application to use the extpay.getUser() and not rely on a single "on/off" moment of the user paying.

TwistedMexi commented 1 year ago

Ok I feel like we're not communicating clearly.

My extension modifies the DOM when active, which activates the features. The extension doesn't have much of a hand in user activity from that point forward, it's more of an on/off switch.

So the issue is I need an event to "flip that switch" immediately when their subscription becomes active again. Unless you want me to have a timer setup and poll getUser() every couple of seconds (which I would never do, that is not a valid solution. I don't want users to resubscribe and think it's not working because they haven't refreshed the page.

I'm not sure why the onPaid event listener even exists in such a manner - what use is it to have it only fire on the first ever payment? If it fired on every payment, then you could just check the user's details to decide if it's the first ever payment if you really needed that functionality.

I understand you seem to have other projects that are your focus right now but I'd ask that you heavily consider fixing/improving this event.

On Fri, Oct 13, 2023 at 12:52 PM Glen Chiacchieri @.***> wrote:

Yes, the onPaid event listener triggers on the first payment, just as you described. It does not trigger for later subscription payments. If you need that, then I would architect your application to use the extpay.getUser() and not rely on a single "on/off" moment of the user paying.

— Reply to this email directly, view it on GitHub https://github.com/Glench/ExtPay/issues/27#issuecomment-1761817683, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVGSNL34KWO4AGS3GQC6O3X7FWT5AVCNFSM5UYOUKCKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCNZWGE4DCNZWHAZQ . You are receiving this because you commented.Message ID: @.***>

Glench commented 1 year ago

Hey TwistedMexi, I'm sorry you don't feel like we're communicating clearly. I understand exactly what you're saying but I'm afraid I don't have an answer that will satisfy you. There is no technical way to know that a user's subscription state changed apart from polling, which as you said is not a good solution (it would cause a lot of server load). That is the same exact solution I would have to implement in ExtPay (as far as I know) to make such a feature work which is why it isn't implemented as you hope it would.

I'm glad you shared your use case for such a feature you're asking for. Instead, I would attempt to use the existing browser and ExtPay APIs to accomplish your means. For example, you could check when a user refocuses a tab to "flip" the DOM state if the paid status has changed.

I'm sorry if this isn't good enough for your use case. If you need something different maybe you require another solution besides ExtPay 🙏