From bc4054f8fd5712165bb572d63d99fbd60f576172 Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Thu, 13 Nov 2025 00:49:58 -0700 Subject: [PATCH] Update payment processor example to show handling a saved card decline error --- examples/payment-processor/plugin.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/payment-processor/plugin.js b/examples/payment-processor/plugin.js index 55d97a7..56d2784 100644 --- a/examples/payment-processor/plugin.js +++ b/examples/payment-processor/plugin.js @@ -160,6 +160,11 @@ exports.init = function () { // Same as checkout() except using a payment method already on file. // customerID and paymentMethodID are provided by getSavedPaymentMethods below. await global.apis.util.delay(1000); // Replace this with something useful! + var error = false; + if (error) { + // If you can't charge the payment method, throw an Error with a string to display to the user. + throw new Error("The saved card didn't work."); + } global.apis.pos.addReceiptPayment( new global.apis.pos.ReceiptPayment( (amount / 100).toFixed(2) * 1,