I am using custom code to have customers pay online.
The payments are going thru, the issue is the customer and I am getting two confirmation / thank you emails for each payment submission. The thank you email look identical and the both reference the same payment ID.
Below is my client side code and server side code.
Thank you for any input.
—Code on web Page Client Side
export function paynow_click(event) {
//Add your code for this event here:
const Paymentamt = parseFloat($w(“#amttopay”).value)
if (Paymentamt >= 5 && Paymentamt < 501) {
const firstName = first_name; // the user's first name
const lastName = last_name; // the user's last name
const phone = PhoneNbr
let email = userEmail
const countryCode = "" // the user's country code
const name = "AcctID:" + CustNbr
const quantity = 1
const price = Paymentamt
createMyPayment(Paymentamt, { name, quantity, price }, { firstName, lastName, phone, email, countryCode })
.then((payment) => {
wixPay.startPayment(payment.id)
.then((result) => {
savepaymentinfo(result) //save all payment results
session.clear();
if (result.status === "Successful") {
// handle payment success
$w("#loginmess").text = "Payment - Thank you!"
wixWindow.openLightbox("Thank you for Payment");
} else if (result.status === "Failed") {
// handle payment failure
$w("#loginmess").text = "Payment Failed, please try again later"
} else if (result.status === "Pending") {
// handle payment pending
$w("#loginmess").text = "Payment is Pending"
} else if (result.status === "Cancelled") {
// handle user closing payment panel
$w("#loginmess").text = "User Canceled Payment"
}
});
});
} else {
$w("#loginmess").text = "Please Enter a Payment 5 to $500."
}
}
----SERVER SIDE
export function createMyPayment(Paymentamt, PaymentItem, PaymentUserInfo) {
return wixPay.createPayment({
items: [PaymentItem],
amount: Paymentamt * 1.00,
userInfo: PaymentUserInfo
});
}