I need to pass a custom payment value in Wix forms.

Hello Wix Community!

I have a form where i need to pass a custom calculated value to to update the payment value.
This is the code I tried but I don’t know how to update the final value on the payment form or after I press the submit button how to update the value on payment form with the calculated value as per the quantity selected.

Please help me as i dont know how to pass the value to payment screen.

Client side code

 import {createMyPayment} from 'backend/pay';
import wixPay from 'wix-pay';
import wixWindow from 'wix-window';

export function checkout_click(event) {
  createMyPayment()
    .then( (payment) => {
      wixPay.startPayment(payment. id, {
          "showThankYouPage": false,
          "termsAndConditionsLink": " terms"
      })
        .then( (result) => {
          if (result.status === "Successful") {
            wixWindow.openLightbox("Success Box");
          } else if (result.status === "Pending") {
            wixWindow.openLightbox("Pending Box");
          }
      } );
    } );
}
$w.onReady(function () {
    getPrice();
});

function getPrice() {
 var totalPrice = 0;
    console.log(totalPrice);
}
export function calculate_change(event) {
    getPrice();
}

Client code is in member page

pay.jsw

import wixPay from 'wix-pay-backend';
export function createMyPayment() {
  let paymentInfo = {
   amount: 29.98
  }
  return wixPay.createPayment(paymentInfo);
}

events.js

export function add(param1, param2) {
  return param1 + param2;
}
export function wixPay_onPaymentUpdate(event) {
  let paymentId = event.payment. id;
  let newTransactionStatus = event.status;
  let userInfo = event.userInfo;
}