Hello everyone, new here. Hoping someone can help with this issue I’m having. I want to remove the option for customers to choose payment method later. I have tried building payment customization and adding the app to the store but that doesn’t do it. My store URL is https://wholesale-blindbarber.myshopify.com/pages/line-sheet
Any help would be appreciated!
// -check
/**
* @typedef {import("../generated/api").RunInput} RunInput
* @typedef {import("../generated/api").FunctionRunResult} FunctionRunResult
*/
/**
* {FunctionRunResult}
*/
const NO_CHANGES = {
operations: [],
};
/**
* {RunInput} input
* @returns {FunctionRunResult}
*/
export function run(input) {
// Define a type for your configuration, and parse it from the metafield
/**
* {{
* paymentMethodName: string
* cartTotal: number
* }}
*/
const configuration = JSON.parse(
input?.paymentCustomization?.metafield?.value ?? "{}"
);
if (!configuration.paymentMethodName || !configuration.cartTotal) {
return NO_CHANGES;
}
const cartTotal = parseFloat(input.cart.cost.totalAmount.amount ?? "0.1");
// Use the configured cart total instead of a hardcoded value
if (cartTotal < configuration.cartTotal) {
console.error("Hiding payment method");
return NO_CHANGES;
}
// Use the configured payment method name instead of a hardcoded value
const hidePaymentMethod = input.paymentMethods
.find(method => method.name.includes(configuration.paymentMethodName));
if (!hidePaymentMethod) {
return NO_CHANGES;
}
return {
operations: [{
hide: {
paymentMethodId: hidePaymentMethod.id
}
}]
};
};

