How to use the cancelOrder() API reference?

Question:

How do I implement the cancelOrder() API reference to my site?

I’ve got Wix Pricing Plans, but my customers can’t cancel their subscription themselves…

(I can’t + won’t use Members Area, I have custom Members, so I can’t use the My Subscriptions page)

Product:

Wix Editor + Developer Mode

What are you trying to achieve:

I’d like an onClick solution that calls cancelOrder for the currentUser, such that the signed-in member stops recurring payments by pressing a button.

What have you already tried:

I’ve tried implementing Members Area, but it’s not a fit for my site (and I can’t work with the CMS).

I’ve tried using Zapier to update the corresponding Stripe customer, but I need Zapier Premium to do so (multiple steps).

I’ve asked ChatGPT for help.

I’ve asked customer support, but they can’t do code-support.

Etc.

The API reference looks like this:

I’m simply a noob and don’t know how to make it work.

I’m willing to donate for your time and help.

Cheers.

Anyone able to help?

MAybe i can take a look on it later, send me an invitation to → velo-ninja@outlook.com

Just added you, now I’ll just cross my fingers that you’re a good guy, haha :crossed_fingers:

Ok, i am back, hopefuly the time of your invitation is not ran out yet… will check now.

The right one ?
2024-01-05 21_02_43-Home _ Wix.com und 2 weitere Seiten - Persönlich – Microsoft​ Edge

Jup, that’s the right one.

1 Like

I’d love to be able to have the user do the cancellation on the “8” dynamic page.

There’s both a custom submit form and a normal onClick button.

onClick preferred

Which language do you speak ?

Danish. Should I update anything to english while you’re having a look?

It’s ok, but just a suggestion → a programmer always works in english, it is the best choice for programming, even if your own language is another one.

It would be surely easier to work in english.

Hmm, but my programming language is in english already?

It’s only my site language that’s danish, because of my target group of possible members.

You right, my bad.

Is somethng missing on your page?

2024-01-05 21_25_14-Wix Website Editor _ Kreativt Hold und 3 weitere Seiten - Persönlich – Microsoft

You deleted a dataset?

I need first to make an overview and understand whats going on on your website, can take a while.

No, I got that specific code from the Velo API:

But I haven’t been able to connect it to Wix Pricing Plans Dataset, and I don’t know if it’s possible.

I was actually told that it’s better to use backend API and cancelOrder()

Which is here:

I also have no clue how to connect that – the example code says:

import { orders } from ‘wix-pricing-plans-backend’;

/* Sample orderId value: ‘a8c4a1b2-b5e8-4b33-9693-057ec93e9a27’
*

  • Sample effectiveAt value: ‘IMMEDIATELY’
  • Sample options value:
  • {
  • suppressAuth: true
  • }
    */

export async function myCancelOrderWithOptionsFunction(orderId, effectiveAt, options) {
try {
const order = await orders.cancelOrder(orderId, effectiveAt, options);

return order;

} catch (error) {
console.error(error);
}
}

// Returns a promise that resolves to void

By the way, I gave myself (as a logged in member) a 100% discount to test out the plan.

So, there is a user in the system with a plan that can be cancelled. You’re welcome to try it out if you can.

AND

My Wix Pricing Plans are connected to stripe, in case that matters. I can see the user there as well.

(I have even tried to work with Zapier.com zaps to let a wix action cancel a stripe customer)

Maybe you are just mixing something up, i see a lot of errors.
Everything what is red marked —> is not good!

I need to know the exact process-flow of your website.

For example a step-by-step description…

  1. User logs-in (but wait, you do not use the Wix-Members-App (why ever i don’t know) .
  2. describe the following steps…

I need to know how it should work in regular mode, so i can see what you expect and make sure i understood your requirement.

If you do not use Wix-Members-APP, how user do register on your website?

This is your own created CMS ?

Yes, seems to be your own collection.
2024-01-05 21_36_55-Wix Website Editor _ Kreativt Hold und 3 weitere Seiten - Persönlich – Microsoft

At this point again the question → WHY NOT USING THE WIX-MEMBERS-APP ???

-firstname
-lastname
-email
-phone-numbers
-profile-pics

and some more, are already covered by the wix-members-app. And all additional can be stored in a separate (additional) DATABASE, like you created.

My recommendation would be to use Wix-Members-APP at this point, but maybe i do not know every detail of your project yet.

I also do not see a password-field inside your own created database (what would be not the best idea).

How do people register on your website?

Found a login-button on your website …
2024-01-05 21_46_26-Wix Website Editor _ Kreativt Hold und 3 weitere Seiten - Persönlich – Microsoft

But this login-button do not even exist inside of your code!

I also see a lot of more different errors and bugs, i think you have much more problems then just the → CANCEL-ORDER-ISSUE… take a look onto your own code, full of red marked buggy coding…

And always when you are working with datasets —> your dataset, must first be ready before start to interact with it. —> dataset.onReady() completely missing inside of your code.

Sorry, when i say it, but i see a lot of CHAOS. Maybe we should first eleminate all already existing bugs first → before continuing?

I am happy that you do not have that much code on your backend, yet. :grin:

Ok, i will have to investigate more for a while…

This is correct, everything what is done on backend, is surely the better way.
And i am almost sure, you can do it only on backend.

1 Like

First off, I don’t have any red lines anywhere, except on the “8” dynamic page.

Currently I can’t see the page you’ve screen-shotted, because you’re in my editor, and I would have to kick you out to see it. But it’s worked perfectly before. Maybe you get the red lines because you are translating the element strings to english?

I do have code for the login-button. It’s in the Master.js handler.
Click on the header and you will see an option to open Master code page.

ALSO
I have tried to work with Members Area – But I was not able to add fields and work with the CMS as I wanted to, because it is restricted.

So I gave up the Members Area and instead I have the code that you should check in the Master.js code page

masterpage
Above: Click that and you’ll see the code for the login-button and creation of custom Member CMS.

Below: No red lines…

But if you tell me that I really really really can edit and let my members update their own data with Wix Members Area, then I will try again again.

I just have had SO much trouble with the Members Area, that I had to make my own.

So if I can solve this by using cancelOrder(), that is much preferred!

I’ll definitely tip you for your help at the end of all this, when we find a solution