I’m using the payments API to allow users order things from our site, and I’d like to use the onPaymentUpdate() function to add confirmed orders to a database (collection) and display a custom message once they have paid for the item.
The issues I’m having are 1) that there seems to be no way to test this without actually placing an order and paying, and 2) the onPaymentUpdate() function doesn’t seem to be called when I cancel a payment (the documentation says that the status can return as “failed” or “cancelled”, which suggests that the event should fire if I cancel a payment). I’m using both a collection and http://webhook.site/ to test if the event is called, and nothing pops up.
How are you supposed to use this function? I’ve followed the documentation and examples and I can’t get it to work
I really need to get my site up and running ASAP, so any help would be appreciated.
So after looking at the ‘site events’ logger in the dashboard, I’ve found this error occurs when loading the page: “Error loading function from web module backend/events.js: function ‘wixPay_onPaymentUpdate’ not found”
The event documentation says to name the function as “_(event) { }”, does wixAppName actually refer to the name of the site? I’ve tried putting in the site name and that didn’t make a difference.
Regarding the first issue, I just set up a bogus product for ten cents and “bought” it. I didn’t see any other way of testing it all the way through. Maybe someone else has found a better way?
I was hesitant to do that for testing in case there were any fees that paypal took (if you buy with credit card there is a 30 cent fee for each purchase), which would add up pretty quickly during testing.
As a workaround I’ve decided to just use the paypal API directly, which involves using some backend code and a custom html iframe with paypal’s buttons.
Hi Shrey, I’m trying to do the same type of payment status handling and not seeing the onPaymentUpdate fire either on a cancel or declined payment. One thing I noted though is you put the function in ‘events.js’ when the Tutorial I saw said to call it ‘events.jsw’. As I said, I cant see it firing yet on a declined transaction still. Any luck on your end yet?
@jeff46425 I tried both ‘events.js’ and ‘events.jsw’ and neither worked.
I ended up just implementing paypal’s API by myself using fetch() and get requests, which also gives me much more control over the checkout flow as a nice bonus. I could post the code and link to paypal’s documentation if you’d like (although I’d recommend using something like Braintree or Stripe if you can, here is a tutorial for Stripe if you’re interested: https://www.wix.com/corvid/forum/wix-tips-and-updates/example-stripe-payment-processing).
Yeah, Wix really sucks with the lack of documentation, missing features and various bugs like this. I feel like Wordpress is a much better system, and I’m really thinking of switching our site over to it (or just doing it properly and using AWS, if my organisation lets me).
I also wish that wix support would at least try to help with corvid, instead of telling us to go to the forums where we’re unlikely to get any official response
All, it helped that the testing that I did with the pay API was with an organization that I support both through volunteering and financial contributions. I agree that with real rigorous testing, especially if there is a gnarly challenge at hand, those 30 cent PayPal fees could add up in a hurry.
Hi Shrey, that link didnt work but for others here this thread had the code needed for Stripe integration: https://www.wix.com/corvid/forum/community-discussion/stripe-on-successful-payment . I just got my test page up and working with test data! Stripe has amazing testing capacity-- separate tokens for test vs live, dummy credit card numbers, webhooks, etc. Key for me was trapping the charge success or failure in the page and updating our internal customer database (via fetch API call) to reflect a payment was made. I am now looking at the webhooks facility because this can put a robust notification system in place at Stripe-- hit our server with a payment notification until we say we got it.
It took a DAY of searching around, past TWO different youtube videos with bad code links to finally find the Wix page and backend code needed to integrate with Stripe!! Even then I had to tweak it to get the charge to happen properly but I am there! If anyone needs help I can shorten the learning curve a lot! The solution I have now is perfect and pretty compact-- I cant believe there aren’t more examples posted!
@shreypasricha Wordpress has some advantages and some disadvantages…AWS I’m definitely not a fan of. I do appreciate that Wix has been ramping up A LOT of features in the past year and that I can get support on the Experts forum reliably, but that isn’t everyone’s experience.