Two buttons using Paid Plans API, only one works?

I’ve set up a page using the Paid Plans API, where I have two purchase buttons of seperate “course memberships”, and only one of them works at a time. I’ve also set up a “discount code” system onto the buttons, but it seems to be working as intended (on the one which is working).

Maybe there’s something wrong with my code?

import wixPaidPlans from 'wix-paid-plans';
import wixPay from 'wix-paid-plans';
import wixData from 'wix-data';

export function button4_click(event) {

 $w("#input1").onCustomValidation( (value) => {
 if(value === "discountcode") {
    wixPaidPlans.purchasePlan("PlanID1")
    .then( (myPurchase) => {
 let myOrderId = myPurchase.orderId;
 let myWixPayOrderId = myPurchase.wixPayOrderId;
 let myWixPayStatus = myPurchase.wixPayStatus;
    } );
  } 
 
 else {
    wixPaidPlans.purchasePlan("PlanID2")
    .then( (myPurchase) => {
 let myOrderId = myPurchase.orderId;
 let myWixPayOrderId = myPurchase.wixPayOrderId;
 let myWixPayStatus = myPurchase.wixPayStatus;
    } );

  }
 
});
}

export function button5_click(event) {

 $w("#input2").onCustomValidation( (value) => {
 if(value === "discountcode2") {
    wixPaidPlans.purchasePlan("PlanID3")
    .then( (myPurchase) => {
 let myOrderId = myPurchase.orderId;
 let myWixPayOrderId = myPurchase.wixPayOrderId;
 let myWixPayStatus = myPurchase.wixPayStatus;
    } );
  } 
 
 else {
    wixPaidPlans.purchasePlan("PlanID4")
    .then( (myPurchase) => {
 let myOrderId = myPurchase.orderId;
 let myWixPayOrderId = myPurchase.wixPayOrderId;
 let myWixPayStatus = myPurchase.wixPayStatus;
    } );

  }
 
});
}