As for your code on your existing page and backend jsw file, try something like this below.
Plus note that you need to have setup your site to accept payments and that you will need to save and publish your site as backend events won’t work in preview…
https://www.wix.com/corvid/reference/wix-pay.html#startPayment
Before using the startPayment() function, you will need to set up your site to accept payments. To learn more, see About Accepting Payments . When setting up your site to accept payments, be sure to select the payment methods you want to offer and set your payment currency .
pay.jsw
import wixPay from 'wix-pay-backend';
export function createMyPayment(charge) {
return wixPay.createPayment({
items: [{
name: 'Driving Course',
price: charge
//you will need to change this to a price, like in the API and example
}],
amount: charge
//you will need to change this to a price. like in the API and example
});
}
page code
import {createMyPayment} from 'backend/pay';
import wixPay from 'wix-pay'
function calculate() {
var charge = Number($w("#dropdown2").value) + Number($w("#dropdown3").value) + Number($w("#dropdown4").value);
return charge;
}
export function button9_click(event, $w) {
var x = calculate();
$w("#text52").text = x.toString();
$w("#group2").show();
}
export function button19_click(event, $w) {
createMyPayment()
.then( (payment) => {
wixPay.startPayment(payment.id);
});
}