Hello. Would you be so kind as to help me figure out how to adjust the payment form and my page code to calculate the total in a way very similar to what you’ve done here? The primary difference with my options is that the user will select the level of service which will determine the base price for a single page. They will then select the number of pages they’d like to have edited. Each additional page will add $10 to the base price. I’d like the total to be calculated based on those factors. Here’s a screenshot of my current page:
And here’s the code I’m currently using:
import {
createToken, encodeCard
}
from "public/stripeAPI.js";
import {
charge
}
from 'backend/stripeProxy';
var payment;
export function payNow() {
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("#cname").value,
"number": $w("#card").value,
"cvc": $w("#cvc").value,
"exp_year": $w("#yr").value,
"exp_month": $w("#mon").value
};
}
function changeState() {
payment = {
"amount": ($w("#amount").value * 100),
"currency": "USD",
"description": $w("#desc").value,
"receipt_email": $w("#email").value
};
}
export function button58_onclick() {
payNow();
}
export function amount_change() {
changeState();
}
export function desc_change() {
changeState();
}
export function email_onchange() {
changeState();
}