@burkedunnweb
Of course it will just work if you also provide an productId.
You are calling a function called → createMyPayment ( productId, VARIABLE )
which is in your Back-End (from your Front-End).
This function needs 2 values —> productId, VARIABLE.
That means, if you call it like this…
createMyPayment(VARIABLE)
…you provide just one of the 2 needed VARIABLES to the Back-End (but the function need 2!!!)
That means, this one would be the right one…
createMyPayment(productId, VARIABLE)
You put in a —> productId & a —> VARIABLE into it.
let VARIABLE = "XYZ" //<---- what ever
let productId = "9983483" //<---whatever
createMyPayment(productId, VARIABLE)
Back-End accept the values…
export async function createMyPayment(productId, VARIABLE) {
return wixData.query(VARIABLE)
.find()
.then((product) => {
let paymentInfo = ({
items: [{
name: 'The Cool Product:<br> Serial Key:<br> ' + product.items[0].serialKey + '<br>Password:<br>' + product.items[0].password,
price: 1
}],
amount: 1
});
return wixPay.createPayment(paymentInfo);
});
}
But when i take a closer look onto your Back-End-Code, it seems that something is missing???
And after some following seconds i recognized your wished scenario.
What you need is …
- The name of the collection as a —> VARIABLE
- A second VARIABLE —> “productId”
…to pass them to Back-End. I think this is all you wanted to do, like…
export async function createMyPayment(productId, VARIABLE) {
return wixData.query(VARIABLE)
.eq("FIELD",productId) //<---"FIELD" = the right COLUMN in your DATABASE
.find()
.then((product) => {console.log(product)
let paymentInfo = ({
items: [{
name: 'The Cool Product:<br> Serial Key:<br> ' + product.items[0].serialKey + '<br>Password:<br>' + product.items[0].password,
price: 1
}],
amount: 1
});
return wixPay.createPayment(paymentInfo);
});
}
You could also provide the FIELD, and tell your CODE in which COLUM in your DB it should do the search.
Front-End:
let VARIABLE = "myCollection" //<---- Collection-Name / DB-Name/ID
let productId = "9983483" //<---whatever
let FIELD = "dataField" //<--- the right COLUMN in DB
createMyPayment(productId, VARIABLE, FIELD)
Back-End:
export async function createMyPayment(productId, VARIABLE, FIELD) {
return wixData.query(VARIABLE)
.eq("FIELD",productId) //<---"FIELD" = the right COLUMN in your DATABASE
.find()
.then((product) => {console.log(product)
let paymentInfo = ({
items: [{
name: 'The Cool Product:<br> Serial Key:<br> ' + product.items[0].serialKey + '<br>Password:<br>' + product.items[0].password,
price: 1
}],
amount: 1
});
return wixPay.createPayment(paymentInfo);
});
}
You can see the resulting OUTPUT in CONSOLE!
Press F-12 in google-chrome-browser and navigate to → CONSOLE!
I hope, it’s a little bit clearer now for you. It is not recommended to use some code by copy&paste, but do not understand it 
