Hi all! Hoping to get some help with coding! I’ve been working diligently on researching and learning the platform! I feel like I’m missing some code to link my concepts together in regards to the PayAPI and userInfo. Thanks in advance if anyone is able to help! I really appreciate it!
What I’m trying to accomplish: A “quick pay” function for clients where they input the amount they would like to pay along with other pertinent information needed.
So, I’ve tried to incorporate information found from two sources.
- This corvid forum post
https://www.wix.com/corvid/forum/community-discussion/custom-payment-amounts-with-pay-api - This corvid reference page
https://www.wix.com/corvid/reference/wix-pay.html
CLIENT CODE ISSUE
- Background info: #input1 is the numerical user input box on the client side for the customamount on my backend and feel like there isn’t a connection from the client side to backside to import the amount they may enter.
-
I receive a parsing error on Line 6 of the Client Code of “Unexpected token const”
-
Am I unable to change the const parameters as I have done below by adding the extra information and dropping the countryCode as it is by default?
-
Do I have to incorporate a database for this to work? If so, where would that code need to go in relation to rest of my code so as to generate the next page?
-
I tried using the code from the reply in my 1st source verbatim but couldn’t get it to work. I’ve also removed the “Product Description” as shown in the first source because I was unsure if I would need that.
-
I click the “GO” button and nothing happens (accepting payments is enabled and setup and site is published)
BACKEND CODE -
I receive a caution indicator on line 8 of “Unreachable code” for userInfo
- Using pay.jsw
Will using the payAPI interfere with my WixStores orders?
import {createMyPayment} from ‘backend/pay’;
import wixPay from ‘wix-pay’;
export function button1_click(event, $w) {
const firstName = // the user’s first name
const lastName = // the user’s last name
const phone = // the user’s phone number
const email = // the user’s email address
const schoolName = // the user’s school name
const childName = // the user’s childs name;
createMyPayment( { firstName, lastName, phone, email, schoolName, childName,$w(‘#input1’.value) } )
.then( (payment) => {
wixPay.startPayment(payment.id);
} );
}
import wixPay from ‘wix-pay-backend’;
export function createMyPayment(userInfo,customamount) {
let cPaymentString = { amount: customamount,
items:
[{price: customamount}] };
return wixPay.createPayment(cPaymentString);
userInfo
}