Stripe API Help

I am creating a payment form for a contest page. I was following this YouTube tutorial (pasting exact moment in video where I’m stuck) Accepting Payments in Wix - Stripe Integration - The Non Coding Founder's Guide - YouTube

When I get to the part of creating changeState(); I get the error “changeState is not defined” even though the person in the video doesn’t seem to have an issue.

Below, here is the complete code:

import { createToken, encodeCard } from “public/stripeAPI.js”;
import { charge } from ‘backend/stripeProxy’;
var payment;

export function payNow(event) {
createToken(encodeCard(createCard()))
.then((token) => {
console.log("Card token: " + token);
charge(token, payment)
.then((chargeResponse) => {
console.log("Charge ID: " + chargeResponse.id);
});
});

function createCard() {
return {
“name”: $w(“#cardName”).value,
“number”: $w(“#cardNumber”).value,
“cvc”: $w(“#cvc”).value,
“exp_year”: $w(“#exYear”).value,
“exp_month”: $w(“#exMonth”).value,
};
}

function changeState() {
payment = {
“amount”: ($w(“#amount”).value * 100),
“currency”: “USD”,
“description”: $w(“#description”).value
}
}
}

export function payFee_click(event) {
payNow(event);
}
export function amount_change(event) {
changeState();
}
export function description_change(event) {
changeState();
}

Any help would be appreciated!

See my comments in the code

import { createToken, encodeCard } from "public/stripeAPI.js";
import { charge } from 'backend/stripeProxy';
var payment;

export function payNow(event) {
    createToken(encodeCard(createCard()))
        .then((token) => {
            console.log("Card token: " + token);
            charge(token, payment)
                .then((chargeResponse) => {
                    console.log("Charge ID: " + chargeResponse.id);
                });
        });
    } //<------------------------------------------------Add This

 function createCard() {
 return {
 "name": $w("#cardName").value,
 "number": $w("#cardNumber").value,
 "cvc": $w("#cvc").value,
 "exp_year": $w("#exYear").value,
 "exp_month": $w("#exMonth").value,
        };
    }

 function changeState() {
        payment = {
 "amount": ($w("#amount").value * 100),
 "currency": "USD",
 "description": $w("#description").value
        }
    }
} //<----------------------------------------------Remove This
 
export function payFee_click(event) {
    payNow(event);
}
export function amount_change(event) {
    changeState();
}
export function description_change(event) {
    changeState();
}


Thank you so much! Now it seems that my problem is, I only get the Card token, and not the charge ID I go to the testing page and it doesn’t look like it collected the payment. I added the public and backend codes and entered the test keys, and somethings not working. What am I missing?

Thank you so much Shan!!!