Trying to Create A Serialized Coupon For Purchased Plans

I want to create a “serialized” coupon when someone purchases one of my paid plans. I also want the coupon to be specific to a paid plan. For example, if the client purchases a gold plan he gets the 20% off coupon and not the 10% off one. The below is what I have but can’t figure out to recall what plan the user just purchased and if it is gold or silver or bronze. I have a test plan that is free that I am using sort of as a sandbox.

import wixData from 'wix-data';
import wixMarketing from 'wix-marketing-backend';
import wixUsers from 'wix-users-backend';
export function createCoupon() {
    wixData.query("Members/PrivateMembersData")
        .eq("_id", wixUsers.currentUser.id)
        .find()
        .then((results) => {
            let slug = results.items[0].slug;
            let lastname = results.items[0].lastName;
            let firstname = results.items[0].firstName
            let email = results.items[0].loginEmail

            let couponDataBronze= { //Bronze Discount
                "name": firstname + " " + lastname + " " + "(Bronze)",
                "code": email,
                "startTime": new Date(),
                "limitedToOneItem": true,
                "active": true,
                "scope": { "namespace": "bookings" },
                "percentOffRate": 10,
            };
            let couponDataSilver= { //Silver Discount
                "name": firstname + " " + lastname + " " + "(Silver)",
                "code": email,
                "startTime": new Date(),
                "limitedToOneItem": true,
                "active": true,
                "scope": { "namespace": "bookings" },
                "percentOffRate": 15,
            };
            let couponDataGold= { //Gold Discount
                "name": firstname + " " + lastname + " " + "(Gold)",
                "code": email,
                "startTime": new Date(),
                "limitedToOneItem": true,
                "active": true,
                "scope": { "namespace": "bookings" },
                "percentOffRate": 20,
            };
            
           return wixMarketing.coupons.createCoupon(couponDataBronze);
        })
}

export function wixPaidPlans_onPlanPurchased(event) {
    if (event.order.price.amount === 0) {
        createCoupon();
    } else {}
}