From 490cd1958b7b64f75765862c4c7aef67b5239fa0 Mon Sep 17 00:00:00 2001
From: Philipp Stracker
Date: Tue, 30 Jul 2024 13:51:16 +0200
Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Move=20config=20object=20t?=
=?UTF-8?q?o=20appropriate=20file?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../js/modules/Helper/CheckoutMethodState.js | 24 +++++++++++++++++++
.../resources/js/GooglepayButton.js | 19 +--------------
2 files changed, 25 insertions(+), 18 deletions(-)
diff --git a/modules/ppcp-button/resources/js/modules/Helper/CheckoutMethodState.js b/modules/ppcp-button/resources/js/modules/Helper/CheckoutMethodState.js
index 3e284c8ef..aecf434f4 100644
--- a/modules/ppcp-button/resources/js/modules/Helper/CheckoutMethodState.js
+++ b/modules/ppcp-button/resources/js/modules/Helper/CheckoutMethodState.js
@@ -6,6 +6,30 @@ export const PaymentMethods = {
GOOGLEPAY: 'ppcp-googlepay',
};
+/**
+ * List of valid context values that the button can have.
+ *
+ * The "context" describes the placement or page where a payment button might be displayed.
+ *
+ * @type {Object}
+ */
+export const PaymentContext = {
+ Product: 'product',
+ Cart: 'cart',
+ Checkout: 'checkout',
+ PayNow: 'pay-now',
+ MiniCart: 'mini-cart',
+ BlockCart: 'cart-block',
+ BlockCheckout: 'checkout-block',
+ Preview: 'preview',
+
+ // Block editor contexts.
+ Blocks: [ 'cart-block', 'checkout-block' ],
+
+ // Custom gateway contexts.
+ Gateways: [ 'checkout', 'pay-now' ],
+};
+
export const ORDER_BUTTON_SELECTOR = '#place_order';
export const getCurrentPaymentMethod = () => {
diff --git a/modules/ppcp-googlepay/resources/js/GooglepayButton.js b/modules/ppcp-googlepay/resources/js/GooglepayButton.js
index 364a6f4e3..b682ce7d3 100644
--- a/modules/ppcp-googlepay/resources/js/GooglepayButton.js
+++ b/modules/ppcp-googlepay/resources/js/GooglepayButton.js
@@ -6,6 +6,7 @@ import { setEnabled } from '../../../ppcp-button/resources/js/modules/Helper/But
import widgetBuilder from '../../../ppcp-button/resources/js/modules/Renderer/WidgetBuilder';
import UpdatePaymentData from './Helper/UpdatePaymentData';
import { apmButtonsInit } from '../../../ppcp-button/resources/js/modules/Helper/ApmButtons';
+import { PaymentContext as CONTEXT } from '../../../ppcp-button/resources/js/modules/Helper/CheckoutMethodState';
/**
* Plugin-specific styling.
@@ -26,24 +27,6 @@ import { apmButtonsInit } from '../../../ppcp-button/resources/js/modules/Helper
* @property {string} language - The locale; an empty string will apply the user-agent's language.
*/
-/**
- * List of valid context values that the button can have.
- *
- * @type {Object}
- */
-const CONTEXT = {
- Product: 'product',
- Cart: 'cart',
- Checkout: 'checkout',
- PayNow: 'pay-now',
- MiniCart: 'mini-cart',
- BlockCart: 'cart-block',
- BlockCheckout: 'checkout-block',
- Preview: 'preview', // Block editor contexts.
- Blocks: [ 'cart-block', 'checkout-block' ], // Custom gateway contexts.
- Gateways: [ 'checkout', 'pay-now' ],
-};
-
class GooglepayButton {
#wrapperId = '';
#ppcpButtonWrapperId = '';