I need help with Wix Paid Plans API - Direct Purchase of a Paid Plan

I need help with the paid plans api. I do have the standard paid plans page that was automatically generated but I would like to design a more mobile friendly paid plans page and individually plan page for each service and for my buy now button to start the direct purchase for that selected paid plan using the purchasePlan() function.

I am new to the Corvid coding so bare with me. I’ve tried the purchasePlan() function for one of my service pages and the button does request to have me sign in or sign up but once logged in and I select the same buy now button nothing happens.

Do I need to customize this code from the corvid reference or add anything to the backend?
I did change the Get the plan ID for a non-free plan with my plan ID and export function id. Any help would be greatly appreciated.

mport wixPaidPlans from ‘wix-paid-plans’;
import wixPay from ‘wix-paid-plans’;

let planId = // 7a00f46f-333d-47fd-b397-8e545ab6bfce

$w.onReady( function () {
//TODO: write your page related code here…
});

export function button3_click(event) {
wixPaidPlans.purchasePlan(planId)
.then( (myPurchase) => {
let myOrderId = myPurchase.orderId;
let myWixPayOrderId = myPurchase.wixPayOrderId;
let myWixPayStatus = myPurchase.wixPayStatus;
} );
}

/* myPurchase:

  • {
  • “orderId”: "b3fb3a4d-c223-4040-8bc3-8dfdefb1bafc",
  • “wixPayOrderId”: "06af8fd6-6c82-4b51-bc08-0b556aad6f4f",
  • “wixPayStatus”: "Successful"
  • }
    */

Hello, Was there a conclusion to this post? I’m having an issue whereby I am using the code from the API (pasted in the original post above), with my specific plan Id and button identifier but when I click the button, nothing happens.

It looks like you haven’t connected the “onClick” method of your button element to the button3_click function. That needs to be done in the onReady method.

Look into examples of connecting buttons to functions.

Or… here:

$w.onReady( function () {
$w( ‘#REPLACEWITHYOURBUTTONID’ ).onClick((event) => {
button3_click(event);
});
});

Hello,

Just wondering if this has ever been fixed? I am having the same problem I found this post after I posted a similar question myself sorry so I can go ahead and delete it to prevent duplication but here is my code and it does not work on my repeater.

import{checkout}from'wix-pricing-plans';

$w.onReady(function() {

letplanId=$w("#dataset1").getCurrentItem();
console.log(planId);

$w('#button1').onClick((event) => {
checkout.startOnlinePurchase(planId)
.then((purchase)=> {
const myOrderId = purchase.order._id;
const myWixPayOrderId = purchase.order.wixPayOrderId;
const myWixPayStatus = purchase.wixPayStatus;
     });
})
});

Thanks in advance!