Wix Payments API Retuning "Undefined" As Payment Status

Can someone help me figure out why my code is returning an “Undefined” status after a payment. It doesn’t matter if I use Wix payment debit, or manual payment, it always returns “Undefined”. It is extremely vital for my code to return with an accurate payment statues so that the next action is performed properly. Please take a look at the code below and let me know your thoughts!

//Front-End Code

import wixData from 'wix-data';
import { createMyPayment } from 'backend/photoPay';
import wixPayFrontend from 'wix-pay-frontend';

export function paymentButton_click(event, $w) {
    const firstName = parentFirstName
    const lastName = parentLastName
    const phone = parentPhoneNumber
    const email = parentEmailAddress
    const countryCode = 'USA'
    let packFullName = productName
    console.log(packFullName)

    createMyPayment({ firstName, lastName, phone, email, countryCode }, packageCostSelected, packFullName)
        .then((payment) => {
            wixPayFrontend.startPayment(payment.id)
                .then((result) => {
                    console.log(result)
                    if (result.status === "Successful") {
                        $w("#statebox").changeState("finished");
                        let toInsert = {
                            "title": productName,
                            "package": packageId,
                            "amountPayed": packageCostSelected,
                            "paymentStatus": payment.status,
                            "paymentId": payment.id,
                            "parentFirst": parentFirstName,
                            "parentLast": parentLastName,
                            "email": parentEmailAddress,
                            "phone": parentPhoneNumber,
                            "address": parentAddress,
                            "playerFirst": playerFirstName, // corrected
                            "playerLast": playerLastName, // corrected
                            "program": programId,
                            "team": teamId,
                            "division": divisonId,
                        }
                        wixData.insert("PhotoRegistration", toInsert)
                            .then((item) => {
                                console.log(item); //see item below
                            })
                            .catch((err) => {
                                console.log(err);
                            });
                        // handle payment success
                    } else if (result.status === "Failed") {
                        $w("#statebox").changeState("error")
                        $w('#backToStart').onClick((event) => {
                            $w("#statebox").changeState("programSelection")
                        })
                    } else if (result.status === "Pending") {
                        $w("#statebox").changeState("error")
                        $w('#backToStart').onClick((event) => {
                            $w("#statebox").changeState("programSelection")
                        })
                    } else if (result.status === "Cancelled") {
                        $w("#statebox").changeState("error")
                        $w('#backToStart').onClick((event) => {
                            $w("#statebox").changeState("programSelection")
                        })
                    }
                });
        });
}

//Backend Code

import wixPayBackend from 'wix-pay-backend';

export function createMyPayment(userInfo, packageCostSelected, packFullName) {
  return wixPayBackend.createPayment({
    items: [{
      name: packFullName,
      price: packageCostSelected,
      quantity: 1
    }],
    amount: packageCostSelected,
    userInfo
  });
}

Hello! Are you running this code in preview mode? That may be the issue.

Yeah, I reached out on discord and found that to be the issue. Thank you.