Wix pay API issue while sending an array for item in createPayment()

I have got a problem while sending an array of multiple items while creating a payment in the backend where I want to initialize items variable with the multiple items array. Here is my code for doing such task can you please help me out why it’s returning an empty error.
Please help me ASAP!
import wixPay from ‘wix-pay-backend’;
import wixData from ‘wix-data’;
import wixUsers from ‘wix-users’;
export function createPayment() {
let products=wixData.query(‘Cart’).eq(‘userId’,wixUsers.currentUser.id).find().
then((result)=>{
let items=;
if (result.items.length>0) {
for ( var i = 0; i < result.items.length; i++) {
let option={
name:result.items[i].productName,
price:result.items[i].productPrice,
quantity:1
}
items.push(option)
}
}
return (items);
}). catch ((err)=>{
return (err.message);
})
console.log(products)
let total=0;
for ( var i = 0; i < products.length; i++) {
total=total+products[i].price;
}
let option={
items:products,
amount:total,
currency:‘USD’
}
return wixPay.createPayment(option)
}
//Here is the frontend code

export function checkout_click(event) {
createPayment().then((payment)=>{
wixPay.startPayment(payment.id)
}). catch (err=>console.log(err))
}

Your page code… Do you have the imports at the top as you have them listed on your backend already?

import {createMyPayment} from 'backend/pay';
import wixPay from 'wix-pay';

$w.onReady(function () {

//rest of code...//

Assuming too that you already know about the Wix Pay API and all relevant docs for it.
https://www.wix.com/corvid/reference/wix-pay.html
https://www.wix.com/corvid/reference/wix-pay-backend.html
https://support.wix.com/en/article/corvid-tutorial-processing-payments
https://support.wix.com/en/article/corvid-tutorial-using-the-corvid-pay-api-to-collect-payments-for-a-single-product
https://support.wix.com/en/article/corvid-tutorial-using-the-corvid-pay-api-to-collect-payments-for-products-in-a-database-collection

Plus this tutorial from Nayeli (Code Queen)
https://support.totallycodable.com/en/article/setting-up-wix-pay-api-using-wix-code

#givemewhisky actually in nayelli she has no cart system but in my site I am using cart system where user can add product which he/she would like to buy and after adding all selected products into the cart then he/she can move to the cart page where their would be a button down at our cart products list “checkout” and when user click on that button then the item’s in “Cart” database would be added into our createPayment() items objects.
Here is the link of the website from where you can see the functionality of the site
https://www.doncornue.com/