Hi, I am creating a service based website and need some help with Stripe payments.
So far I have made it possible for customers to choose different options (hours, upgrades). This calculates the total and deposit value. I have been able to create a charge and it shows on the Stripe testing page that it’s been processed.
Here’s the code I used for the charge:
export function payNow(event) {
var accepted = false ;
createToken(encodeCard(createCard()))
.then((token) => {
console.log("Card token: " + token);
charge(token, payment)
.then((chargeResponse) => {
console.log("Charge ID: " + chargeResponse.id);
if (chargeResponse.id !== undefined) {
$w(“#info”).show();
$w(“#info”).text = “Payment Successful!”;
accepted = true ;
}
});
});
setTimeout( function () {
if (!accepted) {
$w(“#info”).show();
$w(“#info”).text = “Paymenet Declined”;
}
}, 3200);
}
function createCard() {
return {
“name”: $w(“#cardOwner”).value,
“number”: $w(“#cardNumber”).value,
“cvc”: $w(“#cvc”).value,
“exp_year”: $w(“#cardYear”).value,
“exp_month”: $w(“#cardMonth”).value
}
}
function changeState(finalTotal) {
payment = {
“amount”: (finalTotal) * 100,
“currency”: “USD”,
}
}
I want to be able to create an invoice automatically and create a list of the options selected by the customer. I’m not sure if I’m right but it seems like instead of creating a charge I would have to create a customer to do this.
I was looking through this thread but was a little confused on how to implement this. It looks like the code doing this uses an html iframe which I’m not using.
Sorry if this isn’t clear enough. If I need to give more information then I’d be happy to do so. Thank you!
#stripe