WooCommerce Square - Version 2.9.1

Version Description

  • 2022.03.17 =
  • Fix - Fatal error while deactivating WooCommerce before WooCommerce Square.
Download this release

Release Info

Developer automattic
Plugin Icon 128x128 WooCommerce Square
Version 2.9.1
Comparing to
See all releases

Code changes from version 2.9.0 to 2.9.1

Files changed (43) hide show
  1. assets/blocks/credit-card/checkout-handler.js +0 -63
  2. assets/blocks/credit-card/component-card-fields.js +0 -69
  3. assets/blocks/credit-card/component-credit-card.js +0 -57
  4. assets/blocks/credit-card/component-saved-token.js +0 -47
  5. assets/blocks/credit-card/constants.js +0 -2
  6. assets/blocks/credit-card/index.js +0 -54
  7. assets/blocks/credit-card/use-after-processing-checkout.js +0 -80
  8. assets/blocks/credit-card/use-payment-form.js +0 -275
  9. assets/blocks/credit-card/use-payment-processing.js +0 -98
  10. assets/blocks/index.js +0 -12
  11. assets/blocks/square-utils/index.js +0 -1
  12. assets/blocks/square-utils/type-defs.js +0 -66
  13. assets/blocks/square-utils/utils.js +0 -127
  14. assets/css/admin/wc-square-admin.min.css +1 -2
  15. assets/css/admin/wc-square-admin.min.css.map +0 -1
  16. assets/css/admin/wc-square-admin.scss +0 -74
  17. assets/css/frontend/wc-square-cart-checkout-blocks.min.css +1 -2
  18. assets/css/frontend/wc-square-cart-checkout-blocks.min.css.map +0 -1
  19. assets/css/frontend/wc-square-cart-checkout-blocks.scss +0 -117
  20. assets/css/frontend/wc-square-digital-wallet.min.css +1 -2
  21. assets/css/frontend/wc-square-digital-wallet.min.css.map +0 -1
  22. assets/css/frontend/wc-square-digital-wallet.scss +0 -138
  23. assets/css/frontend/wc-square.min.css +1 -2
  24. assets/css/frontend/wc-square.min.css.map +0 -1
  25. assets/css/frontend/wc-square.scss +0 -76
  26. assets/js/admin/wc-square-admin-products.js +0 -489
  27. assets/js/admin/wc-square-admin-products.min.js +0 -1
  28. assets/js/admin/wc-square-admin-products.min.js.map +0 -1
  29. assets/js/admin/wc-square-admin-settings.js +0 -327
  30. assets/js/admin/wc-square-admin-settings.min.js +0 -1
  31. assets/js/admin/wc-square-admin-settings.min.js.map +0 -1
  32. assets/js/frontend/wc-square-digital-wallet.js +0 -597
  33. assets/js/frontend/wc-square-digital-wallet.min.js +1 -2
  34. assets/js/frontend/wc-square-digital-wallet.min.js.map +0 -1
  35. assets/js/frontend/wc-square.js +0 -819
  36. assets/js/frontend/wc-square.min.js +1 -2
  37. assets/js/frontend/wc-square.min.js.map +0 -1
  38. build/index.asset.php +1 -1
  39. build/index.js +1 -1
  40. i18n/languages/woocommerce-square.pot +6 -6
  41. includes/Plugin.php +1 -1
  42. readme.txt +4 -1
  43. woocommerce-square.php +14 -12
assets/blocks/credit-card/checkout-handler.js DELETED
@@ -1,63 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { useContext } from '@wordpress/element';
5
- import { Context } from 'react-square-payment-form';
6
-
7
- /**
8
- * Internal dependencies
9
- */
10
- import { usePaymentProcessing } from './use-payment-processing';
11
- import { useAfterProcessingCheckout } from './use-after-processing-checkout';
12
-
13
- /**
14
- * @typedef {import('../square-utils/type-defs').SquarePaymentFormHandler} SquarePaymentFormHandler
15
- * @typedef {import('@woocommerce/type-defs/registered-payment-method-props').EventRegistrationProps} EventRegistrationProps
16
- * @typedef {import('@woocommerce/type-defs/registered-payment-method-props').BillingDataProps} BillingDataProps
17
- * @typedef {import('@woocommerce/type-defs/registered-payment-method-props').EmitResponseProps} EmitResponseProps
18
- */
19
-
20
- /**
21
- * Handles checkout processing
22
- *
23
- * @param {Object} props Incoming props
24
- * @param {SquarePaymentFormHandler} props.checkoutFormHandler Checkout form handler
25
- * @param {EventRegistrationProps} props.eventRegistration Event registration functions.
26
- * @param {EmitResponseProps} props.emitResponse Helpers for observer response objects.
27
- */
28
- export const CheckoutHandler = ( {
29
- checkoutFormHandler,
30
- eventRegistration,
31
- emitResponse,
32
- } ) => {
33
- const square = useContext( Context );
34
-
35
- const {
36
- onPaymentProcessing,
37
- onCheckoutAfterProcessingWithError,
38
- onCheckoutAfterProcessingWithSuccess,
39
- } = eventRegistration;
40
-
41
- const {
42
- getPaymentMethodData,
43
- createNonce,
44
- verifyBuyer,
45
- } = checkoutFormHandler;
46
-
47
- usePaymentProcessing(
48
- onPaymentProcessing,
49
- emitResponse,
50
- square,
51
- getPaymentMethodData,
52
- createNonce,
53
- verifyBuyer
54
- );
55
-
56
- useAfterProcessingCheckout(
57
- onCheckoutAfterProcessingWithError,
58
- onCheckoutAfterProcessingWithSuccess,
59
- emitResponse
60
- );
61
-
62
- return null;
63
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/blocks/credit-card/component-card-fields.js DELETED
@@ -1,69 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { __ } from '@wordpress/i18n';
5
- import {
6
- CreditCardNumberInput,
7
- CreditCardExpirationDateInput,
8
- CreditCardPostalCodeInput,
9
- CreditCardCVVInput,
10
- } from 'react-square-payment-form';
11
-
12
- /**
13
- * Renders checkout card fields
14
- *
15
- * @param {string} cardType Card Type
16
- */
17
- export const ComponentCardFields = ( { cardType } ) => {
18
- return (
19
- <fieldset id="wc-square-credit-card-credit-card-form">
20
- <span className="sq-label">
21
- { __( 'Card Number', 'woocommerce-square' ) }
22
- </span>
23
- <div
24
- id="wc-square-credit-card-account-number-hosted"
25
- className={ `wc-square-credit-card-hosted-field ${
26
- cardType ? `card-type-${ cardType }` : ''
27
- }` }
28
- >
29
- <CreditCardNumberInput label={ '' } />
30
- </div>
31
-
32
- <div className="sq-form-third">
33
- <span className="sq-label">
34
- { __( 'Expiration (MM/YY)', 'woocommerce-square' ) }
35
- </span>
36
- <div
37
- id="wc-square-credit-card-expiry-hosted"
38
- className="wc-square-credit-card-hosted-field"
39
- >
40
- <CreditCardExpirationDateInput label={ '' } />
41
- </div>
42
- </div>
43
-
44
- <div className="sq-form-third">
45
- <span className="sq-label">
46
- { __( 'Card Security Code', 'woocommerce-square' ) }
47
- </span>
48
- <div
49
- id="wc-square-credit-card-csc-hosted"
50
- className="wc-square-credit-card-hosted-field"
51
- >
52
- <CreditCardCVVInput label={ '' } />
53
- </div>
54
- </div>
55
-
56
- <div className="sq-form-third">
57
- <span className="sq-label">
58
- { __( 'Postal code', 'woocommerce-square' ) }
59
- </span>
60
- <div
61
- id="wc-square-credit-card-postal-code-hosted"
62
- className="wc-square-credit-card-hosted-field"
63
- >
64
- <CreditCardPostalCodeInput label={ '' } />
65
- </div>
66
- </div>
67
- </fieldset>
68
- );
69
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/blocks/credit-card/component-credit-card.js DELETED
@@ -1,57 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { __ } from '@wordpress/i18n';
5
- import { SquarePaymentForm } from 'react-square-payment-form';
6
-
7
- /**
8
- * Internal dependencies
9
- */
10
- import { CheckoutHandler } from './checkout-handler';
11
- import { usePaymentForm } from './use-payment-form';
12
- import { getSquareServerData } from '../square-utils';
13
- import { ComponentCardFields } from './component-card-fields';
14
-
15
- /**
16
- * @typedef {import('@woocommerce/type-defs/registered-payment-method-props').RegisteredPaymentMethodProps} RegisteredPaymentMethodProps
17
- */
18
-
19
- /**
20
- * Square's credit card component
21
- *
22
- * @param {RegisteredPaymentMethodProps} props Incoming props
23
- */
24
- export const ComponentCreditCard = ( {
25
- billing,
26
- eventRegistration,
27
- emitResponse,
28
- shouldSavePayment,
29
- } ) => {
30
- const form = usePaymentForm( billing, shouldSavePayment );
31
-
32
- return (
33
- <SquarePaymentForm
34
- formId={ 'square-credit-card' }
35
- sandbox={ getSquareServerData().isSandbox }
36
- applicationId={ getSquareServerData().applicationId }
37
- locationId={ getSquareServerData().locationId }
38
- inputStyles={ getSquareServerData().inputStyles }
39
- placeholderCreditCard={ '•••• •••• •••• ••••' }
40
- placeholderExpiration={ __( 'MM / YY', 'woocommerce-square' ) }
41
- placeholderCVV={ __( 'CSC', 'woocommerce-square' ) }
42
- postalCode={ form.getPostalCode }
43
- cardNonceResponseReceived={ form.cardNonceResponseReceived }
44
- inputEventReceived={ form.handleInputReceived }
45
- paymentFormLoaded={ () => form.setLoaded( true ) }
46
- >
47
- <ComponentCardFields cardType={ form.cardType } />
48
- { form.isLoaded && (
49
- <CheckoutHandler
50
- checkoutFormHandler={ form }
51
- eventRegistration={ eventRegistration }
52
- emitResponse={ emitResponse }
53
- />
54
- ) }
55
- </SquarePaymentForm>
56
- );
57
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/blocks/credit-card/component-saved-token.js DELETED
@@ -1,47 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { SquarePaymentForm } from 'react-square-payment-form';
5
-
6
- /**
7
- * Internal dependencies
8
- */
9
- import { CheckoutHandler } from './checkout-handler';
10
- import { usePaymentForm } from './use-payment-form';
11
- import { getSquareServerData } from '../square-utils';
12
-
13
- /**
14
- * @typedef {import('@woocommerce/type-defs/registered-payment-method-props').RegisteredPaymentMethodProps} RegisteredPaymentMethodProps
15
- */
16
-
17
- /**
18
- * Square's saved credit card component
19
- *
20
- * @param {RegisteredPaymentMethodProps} props Incoming props
21
- */
22
- export const ComponentSavedToken = ( {
23
- billing,
24
- eventRegistration,
25
- emitResponse,
26
- token,
27
- } ) => {
28
- const form = usePaymentForm( billing, false, token );
29
-
30
- return (
31
- <SquarePaymentForm
32
- formId={ 'square-credit-card-saved-card' }
33
- sandbox={ getSquareServerData().isSandbox }
34
- applicationId={ getSquareServerData().applicationId }
35
- locationId={ getSquareServerData().locationId }
36
- paymentFormLoaded={ () => form.setLoaded( true ) }
37
- >
38
- { form.isLoaded && (
39
- <CheckoutHandler
40
- checkoutFormHandler={ form }
41
- eventRegistration={ eventRegistration }
42
- emitResponse={ emitResponse }
43
- />
44
- ) }
45
- </SquarePaymentForm>
46
- );
47
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/blocks/credit-card/constants.js DELETED
@@ -1,2 +0,0 @@
1
- export const PAYMENT_METHOD_NAME = 'square-credit-card';
2
- export const PAYMENT_METHOD_ID = 'square_credit_card';
 
 
assets/blocks/credit-card/index.js DELETED
@@ -1,54 +0,0 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import { ComponentCreditCard } from './component-credit-card';
5
- import { ComponentSavedToken } from './component-saved-token';
6
- import { PAYMENT_METHOD_NAME, PAYMENT_METHOD_ID } from './constants';
7
- import { getSquareServerData } from '../square-utils';
8
-
9
- /**
10
- * @typedef {import('@woocommerce/type-defs/registered-payment-method-props').RegisteredPaymentMethodProps} RegisteredPaymentMethodProps
11
- */
12
-
13
- /**
14
- * Label component
15
- *
16
- * @param {RegisteredPaymentMethodProps} props
17
- */
18
- const SquareLabel = ( props ) => {
19
- const { PaymentMethodLabel } = props.components;
20
- return <PaymentMethodLabel text={ getSquareServerData().title } />;
21
- };
22
-
23
- /**
24
- * Payment method content component
25
- *
26
- * @param {Object} props Incoming props for component (including props from Payments API)
27
- * @param {ComponentCreditCard|ComponentSavedToken} props.RenderedComponent Component to render
28
- */
29
- const SquareComponent = ( { RenderedComponent, ...props } ) => {
30
- return <RenderedComponent { ...props } />;
31
- };
32
-
33
- const squareCreditCardMethod = {
34
- name: PAYMENT_METHOD_NAME,
35
- label: <SquareLabel />,
36
- content: <SquareComponent RenderedComponent={ ComponentCreditCard } />,
37
- edit: <SquareComponent RenderedComponent={ ComponentCreditCard } />,
38
- savedTokenComponent: (
39
- <SquareComponent RenderedComponent={ ComponentSavedToken } />
40
- ),
41
- paymentMethodId: PAYMENT_METHOD_ID,
42
- ariaLabel: 'Square',
43
- canMakePayment: () =>
44
- getSquareServerData().applicationId && getSquareServerData().locationId
45
- ? true
46
- : false,
47
- supports: {
48
- features: getSquareServerData().supports,
49
- showSavedCards: getSquareServerData().showSavedCards,
50
- showSaveOption: getSquareServerData().showSaveOption,
51
- },
52
- };
53
-
54
- export default squareCreditCardMethod;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/blocks/credit-card/use-after-processing-checkout.js DELETED
@@ -1,80 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { useEffect } from '@wordpress/element';
5
-
6
- /**
7
- * @typedef {import('../square-utils/type-defs').SquarePaymentFormHandler} SquarePaymentFormHandler
8
- * @typedef {import('@woocommerce/type-defs/registered-payment-method-props').EmitResponseProps} EmitResponseProps
9
- */
10
-
11
- /**
12
- * Handle after checkout processing events.
13
- *
14
- * Once the checkout has been submitted and server-side processing has completed, check
15
- * if there's any client-side errors that need to be returned.
16
- *
17
- * Once checkout process is completed, reset the SquarePaymentFormHandler state.
18
- *
19
- * @param {Function} onCheckoutAfterProcessingWithError Callback for registering observers for after the checkout has been processed and has an error
20
- * @param {Function} onCheckoutAfterProcessingWithSuccess Callback for registering observers for after the checkout has been processed and is successful
21
- * @param {EmitResponseProps} emitResponse Helpers for observer response objects
22
- */
23
- export const useAfterProcessingCheckout = (
24
- onCheckoutAfterProcessingWithError,
25
- onCheckoutAfterProcessingWithSuccess,
26
- emitResponse
27
- ) => {
28
- useEffect( () => {
29
- /**
30
- * Before finishing the checkout with the 'success' status, check that there
31
- * are no checkout errors and return them if so.
32
- *
33
- * This function is attached onCheckoutAfterProcessingWithError and onCheckoutAfterProcessingWithSuccess hooks.
34
- *
35
- * @param {Object} checkoutResponse
36
- *
37
- * @return {Object} If checkout errors, return an error response object with message, otherwise return true.
38
- */
39
- const onCheckoutComplete = ( checkoutResponse ) => {
40
- let response = { type: emitResponse.responseTypes.SUCCESS };
41
-
42
- const {
43
- paymentStatus,
44
- paymentDetails,
45
- } = checkoutResponse.processingResponse;
46
-
47
- if (
48
- paymentStatus === emitResponse.responseTypes.ERROR &&
49
- paymentDetails.checkoutNotices
50
- ) {
51
- response = {
52
- type: emitResponse.responseTypes.ERROR,
53
- message: JSON.parse( paymentDetails.checkoutNotices ),
54
- messageContext: emitResponse.noticeContexts.PAYMENTS,
55
- retry: true,
56
- };
57
- }
58
-
59
- return response;
60
- };
61
-
62
- const unsubscribeCheckoutCompleteError = onCheckoutAfterProcessingWithError(
63
- onCheckoutComplete
64
- );
65
- const unsubscribeCheckoutCompleteSuccess = onCheckoutAfterProcessingWithSuccess(
66
- onCheckoutComplete
67
- );
68
-
69
- return () => {
70
- unsubscribeCheckoutCompleteError();
71
- unsubscribeCheckoutCompleteSuccess();
72
- };
73
- }, [
74
- onCheckoutAfterProcessingWithError,
75
- onCheckoutAfterProcessingWithSuccess,
76
- emitResponse.noticeContexts.PAYMENTS,
77
- emitResponse.responseTypes.ERROR,
78
- emitResponse.responseTypes.SUCCESS,
79
- ] );
80
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/blocks/credit-card/use-payment-form.js DELETED
@@ -1,275 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { useState, useCallback, useMemo, useRef } from '@wordpress/element';
5
-
6
- /**
7
- * Internal dependencies
8
- */
9
- import {
10
- getSquareServerData,
11
- handleErrors,
12
- log,
13
- logData,
14
- } from '../square-utils';
15
- import { PAYMENT_METHOD_NAME } from './constants';
16
-
17
- /**
18
- * @typedef {import('@woocommerce/type-defs/registered-payment-method-props').BillingDataProps} BillingDataProps
19
- * @typedef {import('../square-utils/type-defs').SquarePaymentFormHandler} SquarePaymentFormHandler
20
- * @typedef {import('../square-utils/type-defs').SquareContext} SquareContext
21
- */
22
-
23
- /**
24
- * Payment Form Handler
25
- *
26
- * @param {BillingDataProps} billing Checkout billing data.
27
- * @param {boolean} shouldSavePayment True if customer has checked box to save card. Defaults to false
28
- * @param {string} token Saved card/token ID passed from server.
29
- *
30
- * @return {SquarePaymentFormHandler} An object with properties that interact with the Square Payment Form
31
- */
32
- export const usePaymentForm = (
33
- billing,
34
- shouldSavePayment = false,
35
- token = null
36
- ) => {
37
- const [ isLoaded, setLoaded ] = useState( false );
38
- const [ cardType, setCardType ] = useState( '' );
39
- const resolveCreateNonce = useRef( null );
40
- const resolveVerifyBuyer = useRef( null );
41
-
42
- const verificationDetails = useMemo( () => {
43
- const intent = shouldSavePayment && ! token ? 'STORE' : 'CHARGE';
44
- const newVerificationDetails = {
45
- billingContact: {
46
- familyName: billing.billingData.last_name || '',
47
- givenName: billing.billingData.first_name || '',
48
- email: billing.billingData.email || '',
49
- country: billing.billingData.country || '',
50
- region: billing.billingData.state || '',
51
- city: billing.billingData.city || '',
52
- postalCode: billing.billingData.postcode || '',
53
- phone: billing.billingData.phone || '',
54
- addressLines: [
55
- billing.billingData.address_1 || '',
56
- billing.billingData.address_2 || '',
57
- ],
58
- },
59
- intent,
60
- };
61
-
62
- if ( intent === 'CHARGE' ) {
63
- newVerificationDetails.amount = (
64
- billing.cartTotal.value / 100
65
- ).toString();
66
- newVerificationDetails.currencyCode = billing.currency.code;
67
- }
68
- return newVerificationDetails;
69
- }, [
70
- billing.billingData,
71
- billing.cartTotal.value,
72
- billing.currency.code,
73
- shouldSavePayment,
74
- token,
75
- ] );
76
-
77
- const getPaymentMethodData = useCallback(
78
- ( { cardData, nonce, verificationToken, notices, logs } ) => {
79
- const data = {
80
- [ `wc-${ PAYMENT_METHOD_NAME }-card-type` ]: cardType || '',
81
- [ `wc-${ PAYMENT_METHOD_NAME }-last-four` ]:
82
- cardData?.last_4 || '',
83
- [ `wc-${ PAYMENT_METHOD_NAME }-exp-month` ]:
84
- cardData?.exp_month?.toString() || '',
85
- [ `wc-${ PAYMENT_METHOD_NAME }-exp-year` ]:
86
- cardData?.exp_year?.toString() || '',
87
- [ `wc-${ PAYMENT_METHOD_NAME }-payment-postcode` ]:
88
- cardData?.billing_postal_code || '',
89
- [ `wc-${ PAYMENT_METHOD_NAME }-payment-nonce` ]: nonce || '',
90
- [ `wc-${ PAYMENT_METHOD_NAME }-payment-token` ]: token || '',
91
- [ `wc-${ PAYMENT_METHOD_NAME }-buyer-verification-token` ]:
92
- verificationToken || '',
93
- [ `wc-${ PAYMENT_METHOD_NAME }-tokenize-payment-method` ]:
94
- shouldSavePayment || false,
95
- 'log-data': logs.length > 0 ? JSON.stringify( logs ) : '',
96
- 'checkout-notices':
97
- notices.length > 0 ? JSON.stringify( notices ) : '',
98
- };
99
-
100
- return data;
101
- },
102
- [ cardType, shouldSavePayment, token ]
103
- );
104
-
105
- /**
106
- * Handles the response from SqPaymentForm.onCreateNonce() and resolves promise
107
- *
108
- * @param {Array} errors Errors thrown by Square when attempting to create a payment nonce with given card details on checkout
109
- * @param {string} nonce Payment nonce created by Square
110
- * @param {Object} cardData Validated card data used to create payment nonce
111
- */
112
- const cardNonceResponseReceived = ( errors, nonce, cardData ) => {
113
- const response = {
114
- notices: [],
115
- logs: [],
116
- };
117
-
118
- if ( errors ) {
119
- handleErrors( errors, response );
120
- } else if ( ! nonce ) {
121
- logData( 'Nonce is missing from the Square response', response );
122
- log( 'Nonce is missing from the Square response', 'error' );
123
- handleErrors( [], response );
124
- } else {
125
- logData( cardData, response );
126
- log( 'Card data received' );
127
- log( cardData );
128
-
129
- response.cardData = cardData;
130
- response.nonce = nonce;
131
- }
132
-
133
- if ( resolveCreateNonce.current ) {
134
- resolveCreateNonce.current( response );
135
- }
136
- };
137
-
138
- /**
139
- * Generates a payment nonce
140
- *
141
- * @param {SquareContext} square Instance of SqPaymentForm to call onCreateNonce
142
- *
143
- * @return {Promise} Returns promise which will be resolved in cardNonceResponseReceived callback
144
- */
145
- const createNonce = useCallback(
146
- ( square ) => {
147
- if ( ! token ) {
148
- const promise = new Promise(
149
- ( resolve ) => ( resolveCreateNonce.current = resolve )
150
- );
151
- square.onCreateNonce();
152
- return promise;
153
- }
154
-
155
- return Promise.resolve( { token } );
156
- },
157
- [ token ]
158
- );
159
-
160
- /**
161
- * Generates a verification buyer token
162
- *
163
- * @param {SquareContext} square Instance of SqPaymentForm to call onVerifyBuyer
164
- * @param {string} paymentToken Payment Token to verify
165
- *
166
- * @return {Promise} Returns promise which will be resolved in handleVerifyBuyerResponse callback
167
- */
168
- const verifyBuyer = useCallback(
169
- ( square, paymentToken ) => {
170
- const promise = new Promise(
171
- ( resolve ) => ( resolveVerifyBuyer.current = resolve )
172
- );
173
-
174
- square.onVerifyBuyer(
175
- paymentToken,
176
- verificationDetails,
177
- handleVerifyBuyerResponse
178
- );
179
- return promise;
180
- },
181
- [ verificationDetails, handleVerifyBuyerResponse ]
182
- );
183
-
184
- /**
185
- * Handles the response from SqPaymentForm.onVerifyBuyer() and resolves promise
186
- *
187
- * @param {Array} errors Errors thrown by Square when verifying buyer credentials
188
- * @param {Object} verificationResult Verify buyer result from Square
189
- */
190
- const handleVerifyBuyerResponse = useCallback(
191
- ( errors, verificationResult ) => {
192
- const response = {
193
- notices: [],
194
- logs: [],
195
- };
196
-
197
- if ( errors ) {
198
- for ( const error of errors ) {
199
- if ( ! error.field ) {
200
- error.field = 'none';
201
- }
202
- }
203
-
204
- handleErrors( errors, response );
205
- }
206
-
207
- // no errors, but also no verification token.
208
- if ( ! verificationResult || ! verificationResult.token ) {
209
- logData(
210
- 'Verification token is missing from the Square response',
211
- response
212
- );
213
- log(
214
- 'Verification token is missing from the Square response',
215
- 'error'
216
- );
217
- handleErrors( [], response );
218
- } else {
219
- response.verificationToken = verificationResult.token;
220
- }
221
-
222
- if ( resolveVerifyBuyer.current ) {
223
- resolveVerifyBuyer.current( response );
224
- }
225
- },
226
- [ resolveVerifyBuyer ]
227
- );
228
-
229
- /**
230
- * When customers interact with the SqPaymentForm iframe elements, determine
231
- * whether the cardBrandChanged event has occurred and set card type
232
- *
233
- * @param {Object} event Input event object
234
- */
235
- const handleInputReceived = useCallback( ( event ) => {
236
- // change card icon
237
- if ( event.eventType === 'cardBrandChanged' ) {
238
- const brand = event.cardBrand;
239
- let newCardType = 'plain';
240
-
241
- if ( brand === null || brand === 'unknown' ) {
242
- newCardType = '';
243
- }
244
-
245
- if ( getSquareServerData().availableCardTypes[ brand ] !== null ) {
246
- newCardType = getSquareServerData().availableCardTypes[ brand ];
247
- }
248
-
249
- log( `Card brand changed to ${ brand }` );
250
- setCardType( newCardType );
251
- }
252
- }, [] );
253
-
254
- /**
255
- * Returns the postcode value from BillingDataProps or an empty string
256
- *
257
- * @return {string} Postal Code value or an empty string
258
- */
259
- const getPostalCode = useCallback( () => {
260
- const postalCode = billing.billingData.postcode || '';
261
- return postalCode;
262
- }, [ billing.billingData.postcode ] );
263
-
264
- return {
265
- cardNonceResponseReceived,
266
- handleInputReceived,
267
- isLoaded,
268
- setLoaded,
269
- getPostalCode,
270
- cardType,
271
- createNonce,
272
- verifyBuyer,
273
- getPaymentMethodData,
274
- };
275
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/blocks/credit-card/use-payment-processing.js DELETED
@@ -1,98 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { useEffect, useRef } from '@wordpress/element';
5
-
6
- /**
7
- * Internal dependencies
8
- */
9
- import { getSquareServerData } from '../square-utils';
10
-
11
- /**
12
- * @typedef {import('../square-utils/type-defs').SquarePaymentFormHandler} SquarePaymentFormHandler
13
- * @typedef {import('@woocommerce/type-defs/registered-payment-method-props').EmitResponseProps} EmitResponseProps
14
- * @typedef {import('../square-utils/type-defs').SquareContext} SquareContext
15
- */
16
-
17
- /**
18
- * Sets up payment details and POST data to be processed on server-side on checkout submission.
19
- *
20
- * If the checkout has a nonce, token or data to be logged to WooCommerce Status logs, this function
21
- * sends a SUCCESS request to the server with this data inside paymentMethodData.
22
- *
23
- * If the checkout has errors, we send `has-checkout-errors` to the server-side so that the status
24
- * of the request can be set to 'ERROR' before gateway validation is done.
25
- *
26
- * @param {Function} onPaymentProcessing Callback for registering observers on the payment processing event
27
- * @param {EmitResponseProps} emitResponse Helpers for observer response objects
28
- * @param {SquareContext} squareContext Square payment form context variable
29
- * @param {Function} getPaymentMethodData CreateNonce function
30
- * @param {Function} createNonce CreateNonce function
31
- * @param {Function} verifyBuyer VerifyBuyer function
32
- */
33
- export const usePaymentProcessing = (
34
- onPaymentProcessing,
35
- emitResponse,
36
- squareContext,
37
- getPaymentMethodData,
38
- createNonce,
39
- verifyBuyer
40
- ) => {
41
- const square = useRef( squareContext );
42
-
43
- useEffect( () => {
44
- square.current = squareContext;
45
- }, [ squareContext ] );
46
-
47
- useEffect( () => {
48
- const processCheckout = async () => {
49
- const response = { type: emitResponse.responseTypes.SUCCESS };
50
- const defaults = {
51
- nonce: '',
52
- notices: [],
53
- logs: [],
54
- };
55
-
56
- const createNonceResponse = await createNonce( square.current );
57
- const paymentData = { ...defaults, ...createNonceResponse };
58
- const paymentToken = paymentData.token || paymentData.nonce;
59
-
60
- if ( getSquareServerData().is3dsEnabled && paymentToken ) {
61
- const verifyBuyerResponse = await verifyBuyer(
62
- square.current,
63
- paymentToken
64
- );
65
-
66
- paymentData.verificationToken =
67
- verifyBuyerResponse.verificationToken || '';
68
- paymentData.logs = paymentData.logs.concat(
69
- verifyBuyerResponse.log || []
70
- );
71
- paymentData.errors = paymentData.notices.concat(
72
- verifyBuyerResponse.errors || []
73
- );
74
- }
75
-
76
- if ( paymentToken || paymentData.logs.length > 0 ) {
77
- response.meta = {
78
- paymentMethodData: getPaymentMethodData( paymentData ),
79
- };
80
- } else if ( paymentData.notices.length > 0 ) {
81
- response.type = emitResponse.responseTypes.ERROR;
82
- response.message = paymentData.notices;
83
- }
84
-
85
- return response;
86
- };
87
-
88
- const unsubscribe = onPaymentProcessing( processCheckout );
89
- return unsubscribe;
90
- }, [
91
- onPaymentProcessing,
92
- emitResponse.responseTypes.SUCCESS,
93
- emitResponse.responseTypes.ERROR,
94
- createNonce,
95
- verifyBuyer,
96
- getPaymentMethodData,
97
- ] );
98
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/blocks/index.js DELETED
@@ -1,12 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { registerPaymentMethod } from '@woocommerce/blocks-registry';
5
-
6
- /**
7
- * Internal dependencies
8
- */
9
- import squareCreditCardMethod from './credit-card';
10
-
11
- // Register Square Credit Card.
12
- registerPaymentMethod( squareCreditCardMethod );
 
 
 
 
 
 
 
 
 
 
 
 
assets/blocks/square-utils/index.js DELETED
@@ -1 +0,0 @@
1
- export * from './utils';
 
assets/blocks/square-utils/type-defs.js DELETED
@@ -1,66 +0,0 @@
1
- /**
2
- * @typedef {Object} SquareServerData
3
- *
4
- * @property {string} title The payment method title (used for payment method label)
5
- * @property {string} applicationId The connected Square account's application ID
6
- * @property {string} locationId The Square store location ID
7
- * @property {boolean} isSandbox Is Square set to sandbox mode
8
- * @property {boolean} is3dsEnabled Is 3D secure enabled for the connected Square accountThe type of button.
9
- * @property {Array} inputStyles Input styles for the SqPaymentForm iframe elementsThe theme for the button.
10
- * @property {Object} availableCardTypes List of available card types
11
- * @property {string} loggingEnabled Is logging enabled
12
- * @property {string} generalError General error message for unhandled errors
13
- * @property {boolean} showSavedCards Is tokenization/saved cards enabled
14
- * @property {boolean} showSaveOption Is tokenization/saved cards enabled
15
- * @property {Object} supports List of features supported by Square
16
- */
17
-
18
- /**
19
- * Client-side Square logs to be logged to WooCommerce logs on checkout submission
20
- *
21
- * @typedef {Object} SquareLogData
22
- *
23
- * @property {Array} errors Critical client-side errors to be logged
24
- * @property {Array} messages Non-critical errors to be logged
25
- */
26
-
27
- /**
28
- * Square Billing Contact
29
- *
30
- * @typedef {Object} SquareBillingContact
31
- *
32
- * @property {string} familyName The billing last name
33
- * @property {string} givenName The billing first name
34
- * @property {string} email The billing email
35
- * @property {string} country The billing contact country
36
- * @property {string} region The billing state/region
37
- * @property {string} city The billing city
38
- * @property {string} postalCode The postal/zip code
39
- * @property {string} phone The billing email
40
- * @property {Array} [addressLines] An array of address line items.
41
- */
42
-
43
- /**
44
- * Square Context object
45
- *
46
- * @typedef {Object} SquareContext
47
- *
48
- * @property {Function} onCreateNonce Triggers the SqPaymentCustomer billing data
49
- * @property {Function} onVerifyBuyer Triggers the SqPaymentForm.verifyBuyer() function
50
- */
51
-
52
- /**
53
- * Square Payment Form Handler
54
- *
55
- * @typedef {Object} SquarePaymentFormHandler
56
- *
57
- * @property {Function} cardNonceResponseReceived Function for handling response from sqPaymentForm.onCreateNonce
58
- * @property {Function} handleInputReceived Handle inputs received on sqPaymentForm
59
- * @property {boolean} isLoaded Used to determine if sqPaymentForm has finished loading
60
- * @property {Function} setLoaded Function to set isLoaded state
61
- * @property {Function} getPostalCode Function to return billingContact postalcode value
62
- * @property {Function} cardBrandClass Function to return billingContact postalcode value
63
- * @property {Function} createNonce Function to return billingContact postalcode value
64
- * @property {Function} verifyBuyer Function to return billingContact postalcode value
65
- * @property {Function} getPaymentMethodData Function to return billingContact postalcode value
66
- */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/blocks/square-utils/utils.js DELETED
@@ -1,127 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { getSetting } from '@woocommerce/settings';
5
-
6
- /**
7
- * @typedef {import('./type-defs').SquareServerData} SquareServerData
8
- */
9
-
10
- let cachedSquareData = null;
11
-
12
- /**
13
- * Square settings that comes from the server
14
- *
15
- * @return {SquareServerData} Square server data.
16
- */
17
- const getSquareServerData = () => {
18
- if ( cachedSquareData !== null ) {
19
- return cachedSquareData;
20
- }
21
-
22
- const squareData = getSetting( 'square_credit_card_data', null );
23
-
24
- if ( ! squareData ) {
25
- throw new Error( 'Square initialization data is not available' );
26
- }
27
-
28
- cachedSquareData = {
29
- title: squareData.title || '',
30
- applicationId: squareData.application_id || '',
31
- locationId: squareData.location_id || '',
32
- isSandbox: squareData.is_sandbox || false,
33
- is3dsEnabled: squareData.is_3ds_enabled || false,
34
- inputStyles: squareData.input_styles || [],
35
- availableCardTypes: squareData.available_card_types || {},
36
- loggingEnabled: squareData.logging_enabled || false,
37
- generalError: squareData.general_error || '',
38
- showSavedCards: squareData.show_saved_cards || false,
39
- showSaveOption: squareData.show_save_option || false,
40
- supports: squareData.supports || {},
41
- };
42
-
43
- return cachedSquareData;
44
- };
45
-
46
- /**
47
- * Handles errors received from Square requests
48
- *
49
- * @param {Array} errors
50
- * @param {Object} response
51
- */
52
- const handleErrors = ( errors, response = { logs: [], notices: [] } ) => {
53
- let errorFound = false;
54
-
55
- if ( errors ) {
56
- const fieldOrder = [
57
- 'none',
58
- 'cardNumber',
59
- 'expirationDate',
60
- 'cvv',
61
- 'postalCode',
62
- ];
63
-
64
- if ( errors.length >= 1 ) {
65
- // sort based on the field order without the brackets around a.field and b.field.
66
- // the precedence is different and gives different results.
67
- errors.sort( ( a, b ) => {
68
- return (
69
- fieldOrder.indexOf( a.field ) -
70
- fieldOrder.indexOf( b.field )
71
- );
72
- } );
73
- }
74
-
75
- for ( const error of errors ) {
76
- if (
77
- error.type === 'UNSUPPORTED_CARD_BRAND' ||
78
- error.type === 'VALIDATION_ERROR'
79
- ) {
80
- // To avoid confusion between CSC used in the frontend and CVV that is used in the error message.
81
- response.notices.push( error.message.replace( /CVV/, 'CSC' ) );
82
- errorFound = true;
83
- } else {
84
- logData( error, response );
85
- }
86
- }
87
- }
88
-
89
- // if no specific messages are set, display a general error.
90
- if ( ! errorFound ) {
91
- response.notices.push( getSquareServerData().generalError );
92
- }
93
- };
94
-
95
- /**
96
- * Log to the console if logging is enabled
97
- *
98
- * @param {*} data Data to log to console
99
- * @param {string} type Type of log, 'error' will log as an error
100
- */
101
- const log = ( data, type = 'notice' ) => {
102
- if ( ! getSquareServerData().loggingEnabled ) {
103
- return;
104
- }
105
-
106
- if ( type === 'error' ) {
107
- console.error( data );
108
- } else {
109
- console.log( data );
110
- }
111
- };
112
-
113
- /**
114
- * Logs data to Square Credit Card logs found in WooCommerce > Status > Logs if logging is enabled
115
- *
116
- * @param {*} data Data to log
117
- * @param {Object} response Checkout response object to attach log data to
118
- */
119
- const logData = ( data, response ) => {
120
- if ( ! getSquareServerData().loggingEnabled || ! response ) {
121
- return;
122
- }
123
-
124
- response.logs.push( data );
125
- };
126
-
127
- export { getSquareServerData, handleErrors, log, logData };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/css/admin/wc-square-admin.min.css CHANGED
@@ -1,2 +1 @@
1
- #wc-square-sync-page h2{margin-top:20px}#wc-square-sync-page #wc-square_clear-sync-records{margin-bottom:20px}.wc_square_table tr:nth-child(2n) td,.wc_square_table tr:nth-child(2n) th{background:#f9f9f9}.wc_square_table.sor{margin-bottom:20px}.wc_square_table.records .type{cursor:default}.wc_square_table.records .type mark{background:0 0;border:none;box-shadow:none;display:block;margin:5px 0;padding:0}.wc_square_table.records .type mark span{border-radius:3px;background:#c8d7e1;color:#2e4453;padding:6px 10px}.wc_square_table.records .type mark.alert span{background:#eba3a3;color:#761919}.wc_square_table.records .type mark.notice span{background:#f8dda7;color:#94660c}.wc_square_table.records .type mark.info span{background:#e5e5e5;color:#777}.wc_square_table.records .type mark.resolved span{background:#c6e1c6;color:#5b841b}.wc_square_table.records .actions .dashicons{margin-top:3px}
2
- /*# sourceMappingURL=wc-square-admin.min.css.map */
1
+ #wc-square-sync-page h2{margin-top:20px}#wc-square-sync-page #wc-square_clear-sync-records{margin-bottom:20px}.wc_square_table tr:nth-child(2n) td,.wc_square_table tr:nth-child(2n) th{background:#f9f9f9}.wc_square_table.sor{margin-bottom:20px}.wc_square_table.records .type{cursor:default}.wc_square_table.records .type mark{background:0 0;border:none;box-shadow:none;display:block;margin:5px 0;padding:0}.wc_square_table.records .type mark span{border-radius:3px;background:#c8d7e1;color:#2e4453;padding:6px 10px}.wc_square_table.records .type mark.alert span{background:#eba3a3;color:#761919}.wc_square_table.records .type mark.notice span{background:#f8dda7;color:#94660c}.wc_square_table.records .type mark.info span{background:#e5e5e5;color:#777}.wc_square_table.records .type mark.resolved span{background:#c6e1c6;color:#5b841b}.wc_square_table.records .actions .dashicons{margin-top:3px}
 
assets/css/admin/wc-square-admin.min.css.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["wc-square-admin.scss"],"names":[],"mappings":"AAEC,wBACC,WAAY,KAGb,mDACC,cAAe,KAMC,qCACA,qCAChB,WAAY,QAJE,qBAQd,cAAe,KAKf,+BAEC,OAAQ,QAER,oCAEC,WAAY,IACZ,OAAQ,KACR,WAAY,KACZ,QAAS,MACT,OAAQ,IAAA,EACR,QAAS,EAET,yCACC,cAAe,IACf,WAAY,QACZ,MAAO,QACP,QAAS,IAAA,KAGF,+CACP,WAAY,QACZ,MAAO,QAGC,gDACR,WAAY,QACZ,MAAO,QAGD,8CACN,WAAY,QACZ,MAAO,KAGG,kDACV,WAAY,QACZ,MAAO,QAOT,6CACC,WAAY"}
 
assets/css/admin/wc-square-admin.scss DELETED
@@ -1,74 +0,0 @@
1
- #wc-square-sync-page {
2
-
3
- h2 {
4
- margin-top: 20px;
5
- }
6
-
7
- #wc-square_clear-sync-records {
8
- margin-bottom: 20px;
9
- }
10
- }
11
-
12
- .wc_square_table {
13
-
14
- tr:nth-child(2n) td,
15
- tr:nth-child(2n) th {
16
- background: #F9F9F9;
17
- }
18
-
19
- &.sor {
20
- margin-bottom: 20px;
21
- }
22
-
23
- &.records {
24
-
25
- .type {
26
-
27
- cursor: default;
28
-
29
- mark {
30
-
31
- background: transparent;
32
- border: none;
33
- box-shadow: none;
34
- display: block;
35
- margin: 5px 0;
36
- padding: 0;
37
-
38
- span {
39
- border-radius: 3px;
40
- background: #C8D7E1;
41
- color: #2E4453;
42
- padding: 6px 10px;
43
- }
44
-
45
- &.alert span {
46
- background: #EBA3A3;
47
- color: #761919;
48
- }
49
-
50
- &.notice span {
51
- background: #F8DDA7;
52
- color: #94660c;
53
- }
54
-
55
- &.info span {
56
- background: #E5E5E5;
57
- color: #777777;
58
- }
59
-
60
- &.resolved span {
61
- background: #C6E1C6;
62
- color: #5B841B;
63
- }
64
- }
65
- }
66
-
67
- .actions {
68
-
69
- .dashicons {
70
- margin-top: 3px;
71
- }
72
- }
73
- }
74
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/css/frontend/wc-square-cart-checkout-blocks.min.css CHANGED
@@ -1,2 +1 @@
1
- .wc-block-checkout__payment-method div#square-credit-card .sq-payment-form{color:#373f4a;font-family:inherit;font-weight:400;position:relative;width:380px}.wc-block-checkout__payment-method div#square-credit-card #wc-square-credit-card-credit-card-form{margin:0 0 1em;padding:0;border:0;background-color:transparent}.wc-block-checkout__payment-method div#square-credit-card .sq-label{font-size:.8em;font-weight:500;line-height:24px;letter-spacing:.5;text-transform:uppercase;display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wc-block-checkout__payment-method div#square-credit-card .wc-square-credit-card-hosted-field{display:inline-block}.wc-block-checkout__payment-method div#square-credit-card .sq-input{padding:10px;border:1px solid #e0e2e3;-webkit-transition:border-color .2s ease-in-out,background .2s ease-in-out;-moz-transition:border-color .2s ease-in-out,background .2s ease-in-out;-ms-transition:border-color .2s ease-in-out,background .2s ease-in-out;transition:border-color .2s ease-in-out,background .2s ease-in-out;outline-offset:-2px;box-sizing:border-box;border-radius:4px}.wc-block-checkout__payment-method div#square-credit-card .sq-input,.wc-block-checkout__payment-method div#square-credit-card .wc-square-credit-card-hosted-field{width:100%;height:3em}.wc-block-checkout__payment-method div#square-credit-card #square-credit-card-sq-card-number{padding-right:55px;background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-cc-plain.svg);background-repeat:no-repeat;background-position:99%;background-size:50px 31px}@media only screen and (max-width:320px){.wc-block-checkout__payment-method div#square-credit-card #square-credit-card-sq-card-number{background-image:none}}.wc-block-checkout__payment-method div#square-credit-card .card-type-visa #square-credit-card-sq-card-number{background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-visa.svg)}.wc-block-checkout__payment-method div#square-credit-card .card-type-mastercard #square-credit-card-sq-card-number{background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-mastercard.svg)}.wc-block-checkout__payment-method div#square-credit-card .card-type-amex #square-credit-card-sq-card-number{background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-amex.svg)}.wc-block-checkout__payment-method div#square-credit-card .card-type-diners-club #square-credit-card-sq-card-number{background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-dinersclub.svg)}.wc-block-checkout__payment-method div#square-credit-card .card-type-maestro #square-credit-card-sq-card-number{background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-maestro.svg)}.wc-block-checkout__payment-method div#square-credit-card .card-type-jcb #square-credit-card-sq-card-number{background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-jcb.svg)}.wc-block-checkout__payment-method div#square-credit-card .card-type-discover #square-credit-card-sq-card-number{background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-discover.svg)}.wc-block-checkout__payment-method div#square-credit-card .card-type-invalid #square-credit-card-sq-card-number{background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-cc-invalid.svg)}.wc-block-checkout__payment-method div#square-credit-card .sq-input--focus{border:1px solid #4a90e2;background-color:rgba(74,144,226,.02)}.wc-block-checkout__payment-method div#square-credit-card .sq-input--error{border:1px solid #e02f2f;background-color:rgba(244,47,47,.02)}.wc-block-checkout__payment-method div#square-credit-card .sq-form-third{float:left;width:calc((100% - 32px)/ 3);padding:0;margin:0 16px 16px 0}.wc-block-checkout__payment-method div#square-credit-card .sq-form-third:last-of-type{margin-right:0}
2
- /*# sourceMappingURL=wc-square-cart-checkout-blocks.min.css.map */
1
+ .wc-block-checkout__payment-method div#square-credit-card .sq-payment-form{color:#373f4a;font-family:inherit;font-weight:400;position:relative;width:380px}.wc-block-checkout__payment-method div#square-credit-card #wc-square-credit-card-credit-card-form{margin:0 0 1em;padding:0;border:0;background-color:transparent}.wc-block-checkout__payment-method div#square-credit-card .sq-label{font-size:.8em;font-weight:500;line-height:24px;letter-spacing:.5;text-transform:uppercase;display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wc-block-checkout__payment-method div#square-credit-card .wc-square-credit-card-hosted-field{display:inline-block}.wc-block-checkout__payment-method div#square-credit-card .sq-input{padding:10px;border:1px solid #e0e2e3;-webkit-transition:border-color .2s ease-in-out,background .2s ease-in-out;-moz-transition:border-color .2s ease-in-out,background .2s ease-in-out;-ms-transition:border-color .2s ease-in-out,background .2s ease-in-out;transition:border-color .2s ease-in-out,background .2s ease-in-out;outline-offset:-2px;box-sizing:border-box;border-radius:4px}.wc-block-checkout__payment-method div#square-credit-card .sq-input,.wc-block-checkout__payment-method div#square-credit-card .wc-square-credit-card-hosted-field{width:100%;height:3em}.wc-block-checkout__payment-method div#square-credit-card #square-credit-card-sq-card-number{padding-right:55px;background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-cc-plain.svg);background-repeat:no-repeat;background-position:99%;background-size:50px 31px}@media only screen and (max-width:320px){.wc-block-checkout__payment-method div#square-credit-card #square-credit-card-sq-card-number{background-image:none}}.wc-block-checkout__payment-method div#square-credit-card .card-type-visa #square-credit-card-sq-card-number{background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-visa.svg)}.wc-block-checkout__payment-method div#square-credit-card .card-type-mastercard #square-credit-card-sq-card-number{background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-mastercard.svg)}.wc-block-checkout__payment-method div#square-credit-card .card-type-amex #square-credit-card-sq-card-number{background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-amex.svg)}.wc-block-checkout__payment-method div#square-credit-card .card-type-diners-club #square-credit-card-sq-card-number{background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-dinersclub.svg)}.wc-block-checkout__payment-method div#square-credit-card .card-type-maestro #square-credit-card-sq-card-number{background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-maestro.svg)}.wc-block-checkout__payment-method div#square-credit-card .card-type-jcb #square-credit-card-sq-card-number{background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-jcb.svg)}.wc-block-checkout__payment-method div#square-credit-card .card-type-discover #square-credit-card-sq-card-number{background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-discover.svg)}.wc-block-checkout__payment-method div#square-credit-card .card-type-invalid #square-credit-card-sq-card-number{background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-cc-invalid.svg)}.wc-block-checkout__payment-method div#square-credit-card .sq-input--focus{border:1px solid #4a90e2;background-color:rgba(74,144,226,.02)}.wc-block-checkout__payment-method div#square-credit-card .sq-input--error{border:1px solid #e02f2f;background-color:rgba(244,47,47,.02)}.wc-block-checkout__payment-method div#square-credit-card .sq-form-third{float:left;width:calc((100% - 32px)/ 3);padding:0;margin:0 16px 16px 0}.wc-block-checkout__payment-method div#square-credit-card .sq-form-third:last-of-type{margin-right:0}
 
assets/css/frontend/wc-square-cart-checkout-blocks.min.css.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["wc-square-cart-checkout-blocks.scss"],"names":[],"mappings":"AAGC,2EACC,MAAO,QACP,YAAa,QACb,YAAa,IACb,SAAU,SACV,MAAO,MAGR,kGACC,OAAQ,EAAA,EAAA,IACR,QAAS,EACT,OAAQ,EACR,iBAAkB,YAGnB,oEACC,UAAW,KACX,YAAa,IACb,YAAa,KACb,eAAgB,GAChB,eAAgB,UAChB,QAAS,MACT,SAAU,OACV,cAAe,SACf,YAAa,OAGd,8FACC,QAAS,aAGV,oEACC,QAAS,KACT,OAAQ,IAAA,MAAA,QACR,mBAAoB,aAAA,IAAA,WAAA,CAAA,WAAA,IAAA,YACpB,gBAAiB,aAAA,IAAA,WAAA,CAAA,WAAA,IAAA,YACjB,eAAgB,aAAA,IAAA,WAAA,CAAA,WAAA,IAAA,YAChB,WAAY,aAAA,IAAA,WAAA,CAAA,WAAA,IAAA,YACZ,eAAgB,KAChB,WAAY,WACZ,cAAe,IAGhB,oEACA,8FACC,MAAO,KACP,OAAQ,IAGT,6FACC,cAAe,KACf,iBAAkB,8GAClB,kBAAmB,UACnB,oBAAqB,IACrB,gBAAiB,KAAA,KAEuB,yCAPzC,6FAQE,iBAAkB,MAIJ,6GACf,iBAAkB,0GAGG,mHACrB,iBAAkB,gHAGH,6GACf,iBAAkB,0GAGI,oHACtB,iBAAkB,gHAGA,gHAClB,iBAAkB,6GAGJ,4GACd,iBAAkB,yGAGC,iHACnB,iBAAkB,8GAGA,gHAClB,iBAAkB,gHAGnB,2EACC,OAAQ,IAAA,MAAA,QACR,iBAAkB,qBAGnB,2EACC,OAAQ,IAAA,MAAA,QACR,iBAAkB,oBAGnB,yEACC,MAAO,KACP,MAAO,uBACP,QAAS,EACT,OAAQ,EAAA,KAAA,KAAA,EAGK,sFACb,aAAc"}
 
assets/css/frontend/wc-square-cart-checkout-blocks.scss DELETED
@@ -1,117 +0,0 @@
1
- $image_path: '../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images';
2
-
3
- .wc-block-checkout__payment-method div#square-credit-card {
4
- .sq-payment-form {
5
- color: #373F4A;
6
- font-family: inherit;
7
- font-weight: normal;
8
- position: relative;
9
- width: 380px;
10
- }
11
-
12
- #wc-square-credit-card-credit-card-form {
13
- margin: 0 0 1em;
14
- padding: 0;
15
- border: 0;
16
- background-color: transparent;
17
- }
18
-
19
- .sq-label {
20
- font-size: 0.8em;
21
- font-weight: 500;
22
- line-height: 24px;
23
- letter-spacing: 0.5;
24
- text-transform: uppercase;
25
- display: block;
26
- overflow: hidden;
27
- text-overflow: ellipsis;
28
- white-space: nowrap;
29
- }
30
-
31
- .wc-square-credit-card-hosted-field {
32
- display: inline-block;
33
- }
34
-
35
- .sq-input {
36
- padding: 10px;
37
- border: 1px solid #E0E2E3;
38
- -webkit-transition: border-color .2s ease-in-out, background .2s ease-in-out;
39
- -moz-transition: border-color .2s ease-in-out, background .2s ease-in-out;
40
- -ms-transition: border-color .2s ease-in-out, background .2s ease-in-out;
41
- transition: border-color .2s ease-in-out, background .2s ease-in-out;
42
- outline-offset: -2px;
43
- box-sizing: border-box;
44
- border-radius: 4px;
45
- }
46
-
47
- .sq-input,
48
- .wc-square-credit-card-hosted-field {
49
- width: 100%;
50
- height: 3em;
51
- }
52
-
53
- #square-credit-card-sq-card-number {
54
- padding-right: 55px;
55
- background-image: url('#{$image_path}/card-cc-plain.svg');
56
- background-repeat: no-repeat;
57
- background-position: 99%;
58
- background-size: 50px 31px;
59
-
60
- @media only screen and (max-width : 320px) {
61
- background-image: none;
62
- }
63
- }
64
-
65
- .card-type-visa #square-credit-card-sq-card-number {
66
- background-image: url('#{$image_path}/card-visa.svg');
67
- }
68
-
69
- .card-type-mastercard #square-credit-card-sq-card-number {
70
- background-image: url('#{$image_path}/card-mastercard.svg');
71
- }
72
-
73
- .card-type-amex #square-credit-card-sq-card-number {
74
- background-image: url('#{$image_path}/card-amex.svg');
75
- }
76
-
77
- .card-type-diners-club #square-credit-card-sq-card-number {
78
- background-image: url('#{$image_path}/card-dinersclub.svg');
79
- }
80
-
81
- .card-type-maestro #square-credit-card-sq-card-number {
82
- background-image: url('#{$image_path}/card-maestro.svg');
83
- }
84
-
85
- .card-type-jcb #square-credit-card-sq-card-number {
86
- background-image: url('#{$image_path}/card-jcb.svg');
87
- }
88
-
89
- .card-type-discover #square-credit-card-sq-card-number {
90
- background-image: url('#{$image_path}/card-discover.svg');
91
- }
92
-
93
- .card-type-invalid #square-credit-card-sq-card-number {
94
- background-image: url('#{$image_path}/card-cc-invalid.svg');
95
- }
96
-
97
- .sq-input--focus {
98
- border: 1px solid #4A90E2;
99
- background-color: rgba(74,144,226,0.02);
100
- }
101
-
102
- .sq-input--error {
103
- border: 1px solid #E02F2F;
104
- background-color: rgba(244,47,47,0.02);
105
- }
106
-
107
- .sq-form-third {
108
- float: left;
109
- width: calc((100% - 32px) / 3);
110
- padding: 0;
111
- margin: 0 16px 16px 0;
112
- }
113
-
114
- .sq-form-third:last-of-type {
115
- margin-right: 0;
116
- }
117
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/css/frontend/wc-square-digital-wallet.min.css CHANGED
@@ -1,2 +1 @@
1
- #wc-square-digital-wallet{display:none;clear:both;padding-top:1.5em;width:100%;max-width:510px;margin:0 auto}#wc-square-wallet-divider{margin-top:1em;text-align:center}.wc-square-wallet-buttons{width:99%;height:44px;margin:0 0 1em 0;cursor:pointer;display:none}.wc-square-wallet-button-black{background-color:#000}.wc-square-wallet-button-white{background-color:#fff}.google-pay-button{padding:11px 10px;background-origin:content-box;background-position:center;background-repeat:no-repeat;background-size:contain;border:0;border-radius:4px;box-shadow:0 1px 1px 0 rgba(60,64,67,.3),0 1px 3px 1px rgba(60,64,67,.15);outline:0;cursor:pointer}.google-pay-button.wc-square-wallet-button-black{background-image:url(data:image/svg+xml,%3Csvg%20width%3D%22103%22%20height%3D%2217%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cg%20fill%3D%22none%22%20fill-rule%3D%22evenodd%22%3E%3Cpath%20d%3D%22M.148%202.976h3.766c.532%200%201.024.117%201.477.35.453.233.814.555%201.085.966.27.41.406.863.406%201.358%200%20.495-.124.924-.371%201.288s-.572.64-.973.826v.084c.504.177.912.471%201.225.882.313.41.469.891.469%201.442a2.6%202.6%200%200%201-.427%201.47c-.285.43-.667.763-1.148%201.001A3.5%203.5%200%200%201%204.082%2013H.148V2.976zm3.696%204.2c.448%200%20.81-.14%201.085-.42.275-.28.413-.602.413-.966s-.133-.684-.399-.959c-.266-.275-.614-.413-1.043-.413H1.716v2.758h2.128zm.238%204.368c.476%200%20.856-.15%201.141-.448.285-.299.427-.644.427-1.036%200-.401-.147-.749-.441-1.043-.294-.294-.688-.441-1.183-.441h-2.31v2.968h2.366zm5.379.903c-.453-.518-.679-1.239-.679-2.163V5.86h1.54v4.214c0%20.579.138%201.013.413%201.302.275.29.637.434%201.085.434.364%200%20.686-.096.966-.287.28-.191.495-.446.644-.763a2.37%202.37%200%200%200%20.224-1.022V5.86h1.54V13h-1.456v-.924h-.084c-.196.336-.5.611-.91.826-.41.215-.845.322-1.302.322-.868%200-1.528-.259-1.981-.777zm9.859.161L16.352%205.86h1.722l2.016%204.858h.056l1.96-4.858H23.8l-4.41%2010.164h-1.624l1.554-3.416zm8.266-6.748h1.666l1.442%205.11h.056l1.61-5.11h1.582l1.596%205.11h.056l1.442-5.11h1.638L36.392%2013h-1.624L33.13%207.876h-.042L31.464%2013h-1.596l-2.282-7.14zm12.379-1.337a1%201%200%200%201-.301-.735%201%201%200%200%201%20.301-.735%201%201%200%200%201%20.735-.301%201%201%200%200%201%20.735.301%201%201%200%200%201%20.301.735%201%201%200%200%201-.301.735%201%201%200%200%201-.735.301%201%201%200%200%201-.735-.301zM39.93%205.86h1.54V13h-1.54V5.86zm5.568%207.098a1.967%201.967%200%200%201-.686-.406c-.401-.401-.602-.947-.602-1.638V7.218h-1.246V5.86h1.246V3.844h1.54V5.86h1.736v1.358H45.75v3.36c0%20.383.075.653.224.812.14.187.383.28.728.28.159%200%20.299-.021.42-.063.121-.042.252-.11.392-.203v1.498c-.308.14-.681.21-1.12.21-.317%200-.616-.051-.896-.154zm3.678-9.982h1.54v2.73l-.07%201.092h.07c.205-.336.511-.614.917-.833.406-.22.842-.329%201.309-.329.868%200%201.53.254%201.988.763.457.509.686%201.202.686%202.079V13h-1.54V8.688c0-.541-.142-.947-.427-1.218-.285-.27-.656-.406-1.113-.406-.345%200-.656.098-.931.294a2.042%202.042%200%200%200-.651.777%202.297%202.297%200%200%200-.238%201.029V13h-1.54V2.976zm32.35-.341v4.083h2.518c.6%200%201.096-.202%201.488-.605.403-.402.605-.882.605-1.437%200-.544-.202-1.018-.605-1.422-.392-.413-.888-.62-1.488-.62h-2.518zm0%205.52v4.736h-1.504V1.198h3.99c1.013%200%201.873.337%202.582%201.012.72.675%201.08%201.497%201.08%202.466%200%20.991-.36%201.819-1.08%202.482-.697.665-1.559.996-2.583.996h-2.485v.001zm7.668%202.287c0%20.392.166.718.499.98.332.26.722.391%201.168.391.633%200%201.196-.234%201.692-.701.497-.469.744-1.019.744-1.65-.469-.37-1.123-.555-1.962-.555-.61%200-1.12.148-1.528.442-.409.294-.613.657-.613%201.093m1.946-5.815c1.112%200%201.989.297%202.633.89.642.594.964%201.408.964%202.442v4.932h-1.439v-1.11h-.065c-.622.914-1.45%201.372-2.486%201.372-.882%200-1.621-.262-2.215-.784-.594-.523-.891-1.176-.891-1.96%200-.828.313-1.486.94-1.976s1.463-.735%202.51-.735c.892%200%201.629.163%202.206.49v-.344c0-.522-.207-.966-.621-1.33a2.132%202.132%200%200%200-1.455-.547c-.84%200-1.504.353-1.995%201.062l-1.324-.834c.73-1.045%201.81-1.568%203.238-1.568m11.853.262l-5.02%2011.53H96.42l1.864-4.034-3.302-7.496h1.635l2.387%205.749h.032l2.322-5.75z%22%20fill%3D%22%23FFF%22%2F%3E%3Cpath%20d%3D%22M75.448%207.134c0-.473-.04-.93-.116-1.366h-6.344v2.588h3.634a3.11%203.11%200%200%201-1.344%202.042v1.68h2.169c1.27-1.17%202.001-2.9%202.001-4.944%22%20fill%3D%22%234285F4%22%2F%3E%3Cpath%20d%3D%22M68.988%2013.7c1.816%200%203.344-.595%204.459-1.621l-2.169-1.681c-.603.406-1.38.643-2.29.643-1.754%200-3.244-1.182-3.776-2.774h-2.234v1.731a6.728%206.728%200%200%200%206.01%203.703%22%20fill%3D%22%2334A853%22%2F%3E%3Cpath%20d%3D%22M65.212%208.267a4.034%204.034%200%200%201%200-2.572V3.964h-2.234a6.678%206.678%200%200%200-.717%203.017c0%201.085.26%202.11.717%203.017l2.234-1.731z%22%20fill%3D%22%23FABB05%22%2F%3E%3Cpath%20d%3D%22M68.988%202.921c.992%200%201.88.34%202.58%201.008v.001l1.92-1.918c-1.165-1.084-2.685-1.75-4.5-1.75a6.728%206.728%200%200%200-6.01%203.702l2.234%201.731c.532-1.592%202.022-2.774%203.776-2.774%22%20fill%3D%22%23E94235%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E)}.google-pay-button.wc-square-wallet-button-white{background-image:url(data:image/svg+xml,%3Csvg%20width%3D%22103%22%20height%3D%2217%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cg%20fill%3D%22none%22%20fill-rule%3D%22evenodd%22%3E%3Cpath%20d%3D%22M.148%202.976h3.766c.532%200%201.024.117%201.477.35.453.233.814.555%201.085.966.27.41.406.863.406%201.358%200%20.495-.124.924-.371%201.288s-.572.64-.973.826v.084c.504.177.912.471%201.225.882.313.41.469.891.469%201.442a2.6%202.6%200%200%201-.427%201.47c-.285.43-.667.763-1.148%201.001A3.5%203.5%200%200%201%204.082%2013H.148V2.976zm3.696%204.2c.448%200%20.81-.14%201.085-.42.275-.28.413-.602.413-.966s-.133-.684-.399-.959c-.266-.275-.614-.413-1.043-.413H1.716v2.758h2.128zm.238%204.368c.476%200%20.856-.15%201.141-.448.285-.299.427-.644.427-1.036%200-.401-.147-.749-.441-1.043-.294-.294-.688-.441-1.183-.441h-2.31v2.968h2.366zm5.379.903c-.453-.518-.679-1.239-.679-2.163V5.86h1.54v4.214c0%20.579.138%201.013.413%201.302.275.29.637.434%201.085.434.364%200%20.686-.096.966-.287.28-.191.495-.446.644-.763a2.37%202.37%200%200%200%20.224-1.022V5.86h1.54V13h-1.456v-.924h-.084c-.196.336-.5.611-.91.826-.41.215-.845.322-1.302.322-.868%200-1.528-.259-1.981-.777zm9.859.161L16.352%205.86h1.722l2.016%204.858h.056l1.96-4.858H23.8l-4.41%2010.164h-1.624l1.554-3.416zm8.266-6.748h1.666l1.442%205.11h.056l1.61-5.11h1.582l1.596%205.11h.056l1.442-5.11h1.638L36.392%2013h-1.624L33.13%207.876h-.042L31.464%2013h-1.596l-2.282-7.14zm12.379-1.337a1%201%200%200%201-.301-.735%201%201%200%200%201%20.301-.735%201%201%200%200%201%20.735-.301%201%201%200%200%201%20.735.301%201%201%200%200%201%20.301.735%201%201%200%200%201-.301.735%201%201%200%200%201-.735.301%201%201%200%200%201-.735-.301zM39.93%205.86h1.54V13h-1.54V5.86zm5.568%207.098a1.967%201.967%200%200%201-.686-.406c-.401-.401-.602-.947-.602-1.638V7.218h-1.246V5.86h1.246V3.844h1.54V5.86h1.736v1.358H45.75v3.36c0%20.383.075.653.224.812.14.187.383.28.728.28.159%200%20.299-.021.42-.063.121-.042.252-.11.392-.203v1.498c-.308.14-.681.21-1.12.21-.317%200-.616-.051-.896-.154zm3.678-9.982h1.54v2.73l-.07%201.092h.07c.205-.336.511-.614.917-.833.406-.22.842-.329%201.309-.329.868%200%201.53.254%201.988.763.457.509.686%201.202.686%202.079V13h-1.54V8.688c0-.541-.142-.947-.427-1.218-.285-.27-.656-.406-1.113-.406-.345%200-.656.098-.931.294a2.042%202.042%200%200%200-.651.777%202.297%202.297%200%200%200-.238%201.029V13h-1.54V2.976zm32.35-.341v4.083h2.518c.6%200%201.096-.202%201.488-.605.403-.402.605-.882.605-1.437%200-.544-.202-1.018-.605-1.422-.392-.413-.888-.62-1.488-.62h-2.518zm0%205.52v4.736h-1.504V1.198h3.99c1.013%200%201.873.337%202.582%201.012.72.675%201.08%201.497%201.08%202.466%200%20.991-.36%201.819-1.08%202.482-.697.665-1.559.996-2.583.996h-2.485v.001zm7.668%202.287c0%20.392.166.718.499.98.332.26.722.391%201.168.391.633%200%201.196-.234%201.692-.701.497-.469.744-1.019.744-1.65-.469-.37-1.123-.555-1.962-.555-.61%200-1.12.148-1.528.442-.409.294-.613.657-.613%201.093m1.946-5.815c1.112%200%201.989.297%202.633.89.642.594.964%201.408.964%202.442v4.932h-1.439v-1.11h-.065c-.622.914-1.45%201.372-2.486%201.372-.882%200-1.621-.262-2.215-.784-.594-.523-.891-1.176-.891-1.96%200-.828.313-1.486.94-1.976s1.463-.735%202.51-.735c.892%200%201.629.163%202.206.49v-.344c0-.522-.207-.966-.621-1.33a2.132%202.132%200%200%200-1.455-.547c-.84%200-1.504.353-1.995%201.062l-1.324-.834c.73-1.045%201.81-1.568%203.238-1.568m11.853.262l-5.02%2011.53H96.42l1.864-4.034-3.302-7.496h1.635l2.387%205.749h.032l2.322-5.75z%22%20fill%3D%22%23000%22%2F%3E%3Cpath%20d%3D%22M75.448%207.134c0-.473-.04-.93-.116-1.366h-6.344v2.588h3.634a3.11%203.11%200%200%201-1.344%202.042v1.68h2.169c1.27-1.17%202.001-2.9%202.001-4.944%22%20fill%3D%22%234285F4%22%2F%3E%3Cpath%20d%3D%22M68.988%2013.7c1.816%200%203.344-.595%204.459-1.621l-2.169-1.681c-.603.406-1.38.643-2.29.643-1.754%200-3.244-1.182-3.776-2.774h-2.234v1.731a6.728%206.728%200%200%200%206.01%203.703%22%20fill%3D%22%2334A853%22%2F%3E%3Cpath%20d%3D%22M65.212%208.267a4.034%204.034%200%200%201%200-2.572V3.964h-2.234a6.678%206.678%200%200%200-.717%203.017c0%201.085.26%202.11.717%203.017l2.234-1.731z%22%20fill%3D%22%23FABB05%22%2F%3E%3Cpath%20d%3D%22M68.988%202.921c.992%200%201.88.34%202.58%201.008v.001l1.92-1.918c-1.165-1.084-2.685-1.75-4.5-1.75a6.728%206.728%200%200%200-6.01%203.702l2.234%201.731c.532-1.592%202.022-2.774%203.776-2.774%22%20fill%3D%22%23E94235%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E)}@supports (-webkit-appearance:-apple-pay-button){.apple-pay-button{-webkit-appearance:-apple-pay-button;cursor:pointer}.apple-pay-button>*{display:none}}@supports not (-webkit-appearance:-apple-pay-button){.apple-pay-button{background-size:100% 60%;background-repeat:no-repeat;background-position:50% 50%;border-radius:5px;padding:0;box-sizing:border-box;min-width:200px;min-height:32px;max-height:64px;cursor:pointer}.apple-pay-button.wc-square-wallet-button-with-text{--apple-pay-scale:1;justify-content:center;font-size:12px;background:0 0}.apple-pay-button.wc-square-wallet-button-with-text .text{font-family:-apple-system;font-size:calc(1em * var(--apple-pay-scale));font-weight:300;align-self:center;margin-right:calc(2px * var(--apple-pay-scale))}.apple-pay-button.wc-square-wallet-button-with-text .logo{width:calc(35px * var(--scale));height:100%;background-size:100% 60%;background-repeat:no-repeat;background-position:0 50%;margin-left:calc(2px * var(--apple-pay-scale));border:none}.apple-pay-button.wc-square-wallet-button-black{background-color:#000;color:#fff}.apple-pay-button.wc-square-wallet-button-black .logo{background-image:-webkit-named-image(apple-pay-logo-white);background-color:#000}.apple-pay-button.wc-square-wallet-button-white{background-color:#fff;color:#000}.apple-pay-button.wc-square-wallet-button-white .logo{background-image:-webkit-named-image(apple-pay-logo-black);background-color:#fff}.apple-pay-button.wc-square-wallet-button-white-outline{background-color:#fff;color:#000;border:.5px solid #000}.apple-pay-button.wc-square-wallet-button-white-outline .logo{background-image:-webkit-named-image(apple-pay-logo-black);background-color:#fff}}
2
- /*# sourceMappingURL=wc-square-digital-wallet.min.css.map */
1
+ #wc-square-digital-wallet{display:none;clear:both;padding-top:1.5em;width:100%;max-width:510px;margin:0 auto}#wc-square-wallet-divider{margin-top:1em;text-align:center}.wc-square-wallet-buttons{width:99%;height:44px;margin:0 0 1em 0;cursor:pointer;display:none}.wc-square-wallet-button-black{background-color:#000}.wc-square-wallet-button-white{background-color:#fff}.google-pay-button{padding:11px 10px;background-origin:content-box;background-position:center;background-repeat:no-repeat;background-size:contain;border:0;border-radius:4px;box-shadow:0 1px 1px 0 rgba(60,64,67,.3),0 1px 3px 1px rgba(60,64,67,.15);outline:0;cursor:pointer}.google-pay-button.wc-square-wallet-button-black{background-image:url(data:image/svg+xml,%3Csvg%20width%3D%22103%22%20height%3D%2217%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cg%20fill%3D%22none%22%20fill-rule%3D%22evenodd%22%3E%3Cpath%20d%3D%22M.148%202.976h3.766c.532%200%201.024.117%201.477.35.453.233.814.555%201.085.966.27.41.406.863.406%201.358%200%20.495-.124.924-.371%201.288s-.572.64-.973.826v.084c.504.177.912.471%201.225.882.313.41.469.891.469%201.442a2.6%202.6%200%200%201-.427%201.47c-.285.43-.667.763-1.148%201.001A3.5%203.5%200%200%201%204.082%2013H.148V2.976zm3.696%204.2c.448%200%20.81-.14%201.085-.42.275-.28.413-.602.413-.966s-.133-.684-.399-.959c-.266-.275-.614-.413-1.043-.413H1.716v2.758h2.128zm.238%204.368c.476%200%20.856-.15%201.141-.448.285-.299.427-.644.427-1.036%200-.401-.147-.749-.441-1.043-.294-.294-.688-.441-1.183-.441h-2.31v2.968h2.366zm5.379.903c-.453-.518-.679-1.239-.679-2.163V5.86h1.54v4.214c0%20.579.138%201.013.413%201.302.275.29.637.434%201.085.434.364%200%20.686-.096.966-.287.28-.191.495-.446.644-.763a2.37%202.37%200%200%200%20.224-1.022V5.86h1.54V13h-1.456v-.924h-.084c-.196.336-.5.611-.91.826-.41.215-.845.322-1.302.322-.868%200-1.528-.259-1.981-.777zm9.859.161L16.352%205.86h1.722l2.016%204.858h.056l1.96-4.858H23.8l-4.41%2010.164h-1.624l1.554-3.416zm8.266-6.748h1.666l1.442%205.11h.056l1.61-5.11h1.582l1.596%205.11h.056l1.442-5.11h1.638L36.392%2013h-1.624L33.13%207.876h-.042L31.464%2013h-1.596l-2.282-7.14zm12.379-1.337a1%201%200%200%201-.301-.735%201%201%200%200%201%20.301-.735%201%201%200%200%201%20.735-.301%201%201%200%200%201%20.735.301%201%201%200%200%201%20.301.735%201%201%200%200%201-.301.735%201%201%200%200%201-.735.301%201%201%200%200%201-.735-.301zM39.93%205.86h1.54V13h-1.54V5.86zm5.568%207.098a1.967%201.967%200%200%201-.686-.406c-.401-.401-.602-.947-.602-1.638V7.218h-1.246V5.86h1.246V3.844h1.54V5.86h1.736v1.358H45.75v3.36c0%20.383.075.653.224.812.14.187.383.28.728.28.159%200%20.299-.021.42-.063.121-.042.252-.11.392-.203v1.498c-.308.14-.681.21-1.12.21-.317%200-.616-.051-.896-.154zm3.678-9.982h1.54v2.73l-.07%201.092h.07c.205-.336.511-.614.917-.833.406-.22.842-.329%201.309-.329.868%200%201.53.254%201.988.763.457.509.686%201.202.686%202.079V13h-1.54V8.688c0-.541-.142-.947-.427-1.218-.285-.27-.656-.406-1.113-.406-.345%200-.656.098-.931.294a2.042%202.042%200%200%200-.651.777%202.297%202.297%200%200%200-.238%201.029V13h-1.54V2.976zm32.35-.341v4.083h2.518c.6%200%201.096-.202%201.488-.605.403-.402.605-.882.605-1.437%200-.544-.202-1.018-.605-1.422-.392-.413-.888-.62-1.488-.62h-2.518zm0%205.52v4.736h-1.504V1.198h3.99c1.013%200%201.873.337%202.582%201.012.72.675%201.08%201.497%201.08%202.466%200%20.991-.36%201.819-1.08%202.482-.697.665-1.559.996-2.583.996h-2.485v.001zm7.668%202.287c0%20.392.166.718.499.98.332.26.722.391%201.168.391.633%200%201.196-.234%201.692-.701.497-.469.744-1.019.744-1.65-.469-.37-1.123-.555-1.962-.555-.61%200-1.12.148-1.528.442-.409.294-.613.657-.613%201.093m1.946-5.815c1.112%200%201.989.297%202.633.89.642.594.964%201.408.964%202.442v4.932h-1.439v-1.11h-.065c-.622.914-1.45%201.372-2.486%201.372-.882%200-1.621-.262-2.215-.784-.594-.523-.891-1.176-.891-1.96%200-.828.313-1.486.94-1.976s1.463-.735%202.51-.735c.892%200%201.629.163%202.206.49v-.344c0-.522-.207-.966-.621-1.33a2.132%202.132%200%200%200-1.455-.547c-.84%200-1.504.353-1.995%201.062l-1.324-.834c.73-1.045%201.81-1.568%203.238-1.568m11.853.262l-5.02%2011.53H96.42l1.864-4.034-3.302-7.496h1.635l2.387%205.749h.032l2.322-5.75z%22%20fill%3D%22%23FFF%22%2F%3E%3Cpath%20d%3D%22M75.448%207.134c0-.473-.04-.93-.116-1.366h-6.344v2.588h3.634a3.11%203.11%200%200%201-1.344%202.042v1.68h2.169c1.27-1.17%202.001-2.9%202.001-4.944%22%20fill%3D%22%234285F4%22%2F%3E%3Cpath%20d%3D%22M68.988%2013.7c1.816%200%203.344-.595%204.459-1.621l-2.169-1.681c-.603.406-1.38.643-2.29.643-1.754%200-3.244-1.182-3.776-2.774h-2.234v1.731a6.728%206.728%200%200%200%206.01%203.703%22%20fill%3D%22%2334A853%22%2F%3E%3Cpath%20d%3D%22M65.212%208.267a4.034%204.034%200%200%201%200-2.572V3.964h-2.234a6.678%206.678%200%200%200-.717%203.017c0%201.085.26%202.11.717%203.017l2.234-1.731z%22%20fill%3D%22%23FABB05%22%2F%3E%3Cpath%20d%3D%22M68.988%202.921c.992%200%201.88.34%202.58%201.008v.001l1.92-1.918c-1.165-1.084-2.685-1.75-4.5-1.75a6.728%206.728%200%200%200-6.01%203.702l2.234%201.731c.532-1.592%202.022-2.774%203.776-2.774%22%20fill%3D%22%23E94235%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E)}.google-pay-button.wc-square-wallet-button-white{background-image:url(data:image/svg+xml,%3Csvg%20width%3D%22103%22%20height%3D%2217%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cg%20fill%3D%22none%22%20fill-rule%3D%22evenodd%22%3E%3Cpath%20d%3D%22M.148%202.976h3.766c.532%200%201.024.117%201.477.35.453.233.814.555%201.085.966.27.41.406.863.406%201.358%200%20.495-.124.924-.371%201.288s-.572.64-.973.826v.084c.504.177.912.471%201.225.882.313.41.469.891.469%201.442a2.6%202.6%200%200%201-.427%201.47c-.285.43-.667.763-1.148%201.001A3.5%203.5%200%200%201%204.082%2013H.148V2.976zm3.696%204.2c.448%200%20.81-.14%201.085-.42.275-.28.413-.602.413-.966s-.133-.684-.399-.959c-.266-.275-.614-.413-1.043-.413H1.716v2.758h2.128zm.238%204.368c.476%200%20.856-.15%201.141-.448.285-.299.427-.644.427-1.036%200-.401-.147-.749-.441-1.043-.294-.294-.688-.441-1.183-.441h-2.31v2.968h2.366zm5.379.903c-.453-.518-.679-1.239-.679-2.163V5.86h1.54v4.214c0%20.579.138%201.013.413%201.302.275.29.637.434%201.085.434.364%200%20.686-.096.966-.287.28-.191.495-.446.644-.763a2.37%202.37%200%200%200%20.224-1.022V5.86h1.54V13h-1.456v-.924h-.084c-.196.336-.5.611-.91.826-.41.215-.845.322-1.302.322-.868%200-1.528-.259-1.981-.777zm9.859.161L16.352%205.86h1.722l2.016%204.858h.056l1.96-4.858H23.8l-4.41%2010.164h-1.624l1.554-3.416zm8.266-6.748h1.666l1.442%205.11h.056l1.61-5.11h1.582l1.596%205.11h.056l1.442-5.11h1.638L36.392%2013h-1.624L33.13%207.876h-.042L31.464%2013h-1.596l-2.282-7.14zm12.379-1.337a1%201%200%200%201-.301-.735%201%201%200%200%201%20.301-.735%201%201%200%200%201%20.735-.301%201%201%200%200%201%20.735.301%201%201%200%200%201%20.301.735%201%201%200%200%201-.301.735%201%201%200%200%201-.735.301%201%201%200%200%201-.735-.301zM39.93%205.86h1.54V13h-1.54V5.86zm5.568%207.098a1.967%201.967%200%200%201-.686-.406c-.401-.401-.602-.947-.602-1.638V7.218h-1.246V5.86h1.246V3.844h1.54V5.86h1.736v1.358H45.75v3.36c0%20.383.075.653.224.812.14.187.383.28.728.28.159%200%20.299-.021.42-.063.121-.042.252-.11.392-.203v1.498c-.308.14-.681.21-1.12.21-.317%200-.616-.051-.896-.154zm3.678-9.982h1.54v2.73l-.07%201.092h.07c.205-.336.511-.614.917-.833.406-.22.842-.329%201.309-.329.868%200%201.53.254%201.988.763.457.509.686%201.202.686%202.079V13h-1.54V8.688c0-.541-.142-.947-.427-1.218-.285-.27-.656-.406-1.113-.406-.345%200-.656.098-.931.294a2.042%202.042%200%200%200-.651.777%202.297%202.297%200%200%200-.238%201.029V13h-1.54V2.976zm32.35-.341v4.083h2.518c.6%200%201.096-.202%201.488-.605.403-.402.605-.882.605-1.437%200-.544-.202-1.018-.605-1.422-.392-.413-.888-.62-1.488-.62h-2.518zm0%205.52v4.736h-1.504V1.198h3.99c1.013%200%201.873.337%202.582%201.012.72.675%201.08%201.497%201.08%202.466%200%20.991-.36%201.819-1.08%202.482-.697.665-1.559.996-2.583.996h-2.485v.001zm7.668%202.287c0%20.392.166.718.499.98.332.26.722.391%201.168.391.633%200%201.196-.234%201.692-.701.497-.469.744-1.019.744-1.65-.469-.37-1.123-.555-1.962-.555-.61%200-1.12.148-1.528.442-.409.294-.613.657-.613%201.093m1.946-5.815c1.112%200%201.989.297%202.633.89.642.594.964%201.408.964%202.442v4.932h-1.439v-1.11h-.065c-.622.914-1.45%201.372-2.486%201.372-.882%200-1.621-.262-2.215-.784-.594-.523-.891-1.176-.891-1.96%200-.828.313-1.486.94-1.976s1.463-.735%202.51-.735c.892%200%201.629.163%202.206.49v-.344c0-.522-.207-.966-.621-1.33a2.132%202.132%200%200%200-1.455-.547c-.84%200-1.504.353-1.995%201.062l-1.324-.834c.73-1.045%201.81-1.568%203.238-1.568m11.853.262l-5.02%2011.53H96.42l1.864-4.034-3.302-7.496h1.635l2.387%205.749h.032l2.322-5.75z%22%20fill%3D%22%23000%22%2F%3E%3Cpath%20d%3D%22M75.448%207.134c0-.473-.04-.93-.116-1.366h-6.344v2.588h3.634a3.11%203.11%200%200%201-1.344%202.042v1.68h2.169c1.27-1.17%202.001-2.9%202.001-4.944%22%20fill%3D%22%234285F4%22%2F%3E%3Cpath%20d%3D%22M68.988%2013.7c1.816%200%203.344-.595%204.459-1.621l-2.169-1.681c-.603.406-1.38.643-2.29.643-1.754%200-3.244-1.182-3.776-2.774h-2.234v1.731a6.728%206.728%200%200%200%206.01%203.703%22%20fill%3D%22%2334A853%22%2F%3E%3Cpath%20d%3D%22M65.212%208.267a4.034%204.034%200%200%201%200-2.572V3.964h-2.234a6.678%206.678%200%200%200-.717%203.017c0%201.085.26%202.11.717%203.017l2.234-1.731z%22%20fill%3D%22%23FABB05%22%2F%3E%3Cpath%20d%3D%22M68.988%202.921c.992%200%201.88.34%202.58%201.008v.001l1.92-1.918c-1.165-1.084-2.685-1.75-4.5-1.75a6.728%206.728%200%200%200-6.01%203.702l2.234%201.731c.532-1.592%202.022-2.774%203.776-2.774%22%20fill%3D%22%23E94235%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E)}@supports (-webkit-appearance:-apple-pay-button){.apple-pay-button{-webkit-appearance:-apple-pay-button;cursor:pointer}.apple-pay-button>*{display:none}}@supports not (-webkit-appearance:-apple-pay-button){.apple-pay-button{background-size:100% 60%;background-repeat:no-repeat;background-position:50% 50%;border-radius:5px;padding:0;box-sizing:border-box;min-width:200px;min-height:32px;max-height:64px;cursor:pointer}.apple-pay-button.wc-square-wallet-button-with-text{--apple-pay-scale:1;justify-content:center;font-size:12px;background:0 0}.apple-pay-button.wc-square-wallet-button-with-text .text{font-family:-apple-system;font-size:calc(1em * var(--apple-pay-scale));font-weight:300;align-self:center;margin-right:calc(2px * var(--apple-pay-scale))}.apple-pay-button.wc-square-wallet-button-with-text .logo{width:calc(35px * var(--scale));height:100%;background-size:100% 60%;background-repeat:no-repeat;background-position:0 50%;margin-left:calc(2px * var(--apple-pay-scale));border:none}.apple-pay-button.wc-square-wallet-button-black{background-color:#000;color:#fff}.apple-pay-button.wc-square-wallet-button-black .logo{background-image:-webkit-named-image(apple-pay-logo-white);background-color:#000}.apple-pay-button.wc-square-wallet-button-white{background-color:#fff;color:#000}.apple-pay-button.wc-square-wallet-button-white .logo{background-image:-webkit-named-image(apple-pay-logo-black);background-color:#fff}.apple-pay-button.wc-square-wallet-button-white-outline{background-color:#fff;color:#000;border:.5px solid #000}.apple-pay-button.wc-square-wallet-button-white-outline .logo{background-image:-webkit-named-image(apple-pay-logo-black);background-color:#fff}}
 
assets/css/frontend/wc-square-digital-wallet.min.css.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["wc-square-digital-wallet.scss"],"names":[],"mappings":"AAAA,0BACI,QAAQ,KACR,MAAO,KACP,YAAa,MACb,MAAO,KACP,UAAW,MACX,OAAQ,EAAA,KAGZ,0BACI,WAAW,IACX,WAAW,OAGf,0BACI,MAAO,IACP,OAAQ,KACR,OAAQ,EAAA,EAAA,IAAA,EACR,OAAQ,QACR,QAAS,KAGb,+BACI,iBAAkB,KAGtB,+BACI,iBAAkB,KAMtB,mBACI,QAAS,KAAA,KACT,kBAAmB,YACnB,oBAAqB,OACrB,kBAAmB,UACnB,gBAAiB,QACjB,OAAQ,EACR,cAAe,IACf,WAAY,EAAE,IAAI,IAAI,EAAE,iBAAsB,CAAE,EAAE,IAAI,IAAI,IAAI,mBAC9D,QAAS,EACT,OAAQ,QAVM,iDAaV,iBAAkB,swIAbR,iDAiBV,iBAAkB,swIAOsB,iDAC5C,kBACI,mBAAoB,kBACpB,OAAQ,QAGQ,oBAChB,QAAS,MAImC,qDAChD,kBACI,gBAAiB,KAAA,IACjB,kBAAmB,UACnB,oBAAqB,IAAA,IACrB,cAAe,IACf,QAAS,EACT,WAAY,WACZ,UAAW,MACX,WAAY,KACZ,WAAY,KACZ,OAAQ,QAVK,oDAaT,kBAAiB,EACjB,gBAAiB,OACjB,UAAW,KACX,WAAY,IAEZ,0DACI,YAAa,cACb,UAAW,mCACX,YAAa,IACb,WAAY,OACZ,aAAc,mCAGlB,0DACI,MAAO,0BACP,OAAQ,KACR,gBAAiB,KAAA,IACjB,kBAAmB,UACnB,oBAAqB,EAAA,IACrB,YAAa,mCACb,OAAQ,KAjCH,gDAsCT,iBAAkB,KAClB,MAAO,KAEP,sDACI,iBAAkB,0CAClB,iBAAkB,KA3Cb,gDAgDT,iBAAkB,KAClB,MAAO,KAEP,sDACI,iBAAkB,0CAClB,iBAAkB,KArDb,wDA0DT,iBAAkB,KAClB,MAAO,KACP,OAAQ,KAAA,MAAA,KAER,8DACI,iBAAkB,0CAClB,iBAAkB"}
 
assets/css/frontend/wc-square-digital-wallet.scss DELETED
@@ -1,138 +0,0 @@
1
- #wc-square-digital-wallet {
2
- display:none;
3
- clear: both;
4
- padding-top: 1.5em;
5
- width: 100%;
6
- max-width: 510px;
7
- margin: 0 auto;
8
- }
9
-
10
- #wc-square-wallet-divider {
11
- margin-top:1em;
12
- text-align:center;
13
- }
14
-
15
- .wc-square-wallet-buttons {
16
- width: 99%; /* Set to 99% so that Google Pay box-shadow styles aren't clipped (visible on white buttons) */
17
- height: 44px;
18
- margin: 0 0 1em 0;
19
- cursor: pointer;
20
- display: none;
21
- }
22
-
23
- .wc-square-wallet-button-black {
24
- background-color: black;
25
- }
26
-
27
- .wc-square-wallet-button-white {
28
- background-color: white;
29
- }
30
-
31
- /*
32
- * Google Pay Button Styles
33
- */
34
- .google-pay-button {
35
- padding: 11px 10px;
36
- background-origin: content-box;
37
- background-position: center;
38
- background-repeat: no-repeat;
39
- background-size: contain;
40
- border: 0;
41
- border-radius: 4px;
42
- box-shadow: 0 1px 1px 0 rgba(60, 64, 67, 0.30), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
43
- outline: 0;
44
- cursor: pointer;
45
-
46
- &.wc-square-wallet-button-black {
47
- background-image: url(data:image/svg+xml,%3Csvg%20width%3D%22103%22%20height%3D%2217%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cg%20fill%3D%22none%22%20fill-rule%3D%22evenodd%22%3E%3Cpath%20d%3D%22M.148%202.976h3.766c.532%200%201.024.117%201.477.35.453.233.814.555%201.085.966.27.41.406.863.406%201.358%200%20.495-.124.924-.371%201.288s-.572.64-.973.826v.084c.504.177.912.471%201.225.882.313.41.469.891.469%201.442a2.6%202.6%200%200%201-.427%201.47c-.285.43-.667.763-1.148%201.001A3.5%203.5%200%200%201%204.082%2013H.148V2.976zm3.696%204.2c.448%200%20.81-.14%201.085-.42.275-.28.413-.602.413-.966s-.133-.684-.399-.959c-.266-.275-.614-.413-1.043-.413H1.716v2.758h2.128zm.238%204.368c.476%200%20.856-.15%201.141-.448.285-.299.427-.644.427-1.036%200-.401-.147-.749-.441-1.043-.294-.294-.688-.441-1.183-.441h-2.31v2.968h2.366zm5.379.903c-.453-.518-.679-1.239-.679-2.163V5.86h1.54v4.214c0%20.579.138%201.013.413%201.302.275.29.637.434%201.085.434.364%200%20.686-.096.966-.287.28-.191.495-.446.644-.763a2.37%202.37%200%200%200%20.224-1.022V5.86h1.54V13h-1.456v-.924h-.084c-.196.336-.5.611-.91.826-.41.215-.845.322-1.302.322-.868%200-1.528-.259-1.981-.777zm9.859.161L16.352%205.86h1.722l2.016%204.858h.056l1.96-4.858H23.8l-4.41%2010.164h-1.624l1.554-3.416zm8.266-6.748h1.666l1.442%205.11h.056l1.61-5.11h1.582l1.596%205.11h.056l1.442-5.11h1.638L36.392%2013h-1.624L33.13%207.876h-.042L31.464%2013h-1.596l-2.282-7.14zm12.379-1.337a1%201%200%200%201-.301-.735%201%201%200%200%201%20.301-.735%201%201%200%200%201%20.735-.301%201%201%200%200%201%20.735.301%201%201%200%200%201%20.301.735%201%201%200%200%201-.301.735%201%201%200%200%201-.735.301%201%201%200%200%201-.735-.301zM39.93%205.86h1.54V13h-1.54V5.86zm5.568%207.098a1.967%201.967%200%200%201-.686-.406c-.401-.401-.602-.947-.602-1.638V7.218h-1.246V5.86h1.246V3.844h1.54V5.86h1.736v1.358H45.75v3.36c0%20.383.075.653.224.812.14.187.383.28.728.28.159%200%20.299-.021.42-.063.121-.042.252-.11.392-.203v1.498c-.308.14-.681.21-1.12.21-.317%200-.616-.051-.896-.154zm3.678-9.982h1.54v2.73l-.07%201.092h.07c.205-.336.511-.614.917-.833.406-.22.842-.329%201.309-.329.868%200%201.53.254%201.988.763.457.509.686%201.202.686%202.079V13h-1.54V8.688c0-.541-.142-.947-.427-1.218-.285-.27-.656-.406-1.113-.406-.345%200-.656.098-.931.294a2.042%202.042%200%200%200-.651.777%202.297%202.297%200%200%200-.238%201.029V13h-1.54V2.976zm32.35-.341v4.083h2.518c.6%200%201.096-.202%201.488-.605.403-.402.605-.882.605-1.437%200-.544-.202-1.018-.605-1.422-.392-.413-.888-.62-1.488-.62h-2.518zm0%205.52v4.736h-1.504V1.198h3.99c1.013%200%201.873.337%202.582%201.012.72.675%201.08%201.497%201.08%202.466%200%20.991-.36%201.819-1.08%202.482-.697.665-1.559.996-2.583.996h-2.485v.001zm7.668%202.287c0%20.392.166.718.499.98.332.26.722.391%201.168.391.633%200%201.196-.234%201.692-.701.497-.469.744-1.019.744-1.65-.469-.37-1.123-.555-1.962-.555-.61%200-1.12.148-1.528.442-.409.294-.613.657-.613%201.093m1.946-5.815c1.112%200%201.989.297%202.633.89.642.594.964%201.408.964%202.442v4.932h-1.439v-1.11h-.065c-.622.914-1.45%201.372-2.486%201.372-.882%200-1.621-.262-2.215-.784-.594-.523-.891-1.176-.891-1.96%200-.828.313-1.486.94-1.976s1.463-.735%202.51-.735c.892%200%201.629.163%202.206.49v-.344c0-.522-.207-.966-.621-1.33a2.132%202.132%200%200%200-1.455-.547c-.84%200-1.504.353-1.995%201.062l-1.324-.834c.73-1.045%201.81-1.568%203.238-1.568m11.853.262l-5.02%2011.53H96.42l1.864-4.034-3.302-7.496h1.635l2.387%205.749h.032l2.322-5.75z%22%20fill%3D%22%23FFF%22%2F%3E%3Cpath%20d%3D%22M75.448%207.134c0-.473-.04-.93-.116-1.366h-6.344v2.588h3.634a3.11%203.11%200%200%201-1.344%202.042v1.68h2.169c1.27-1.17%202.001-2.9%202.001-4.944%22%20fill%3D%22%234285F4%22%2F%3E%3Cpath%20d%3D%22M68.988%2013.7c1.816%200%203.344-.595%204.459-1.621l-2.169-1.681c-.603.406-1.38.643-2.29.643-1.754%200-3.244-1.182-3.776-2.774h-2.234v1.731a6.728%206.728%200%200%200%206.01%203.703%22%20fill%3D%22%2334A853%22%2F%3E%3Cpath%20d%3D%22M65.212%208.267a4.034%204.034%200%200%201%200-2.572V3.964h-2.234a6.678%206.678%200%200%200-.717%203.017c0%201.085.26%202.11.717%203.017l2.234-1.731z%22%20fill%3D%22%23FABB05%22%2F%3E%3Cpath%20d%3D%22M68.988%202.921c.992%200%201.88.34%202.58%201.008v.001l1.92-1.918c-1.165-1.084-2.685-1.75-4.5-1.75a6.728%206.728%200%200%200-6.01%203.702l2.234%201.731c.532-1.592%202.022-2.774%203.776-2.774%22%20fill%3D%22%23E94235%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E);
48
- }
49
-
50
- &.wc-square-wallet-button-white {
51
- background-image: url(data:image/svg+xml,%3Csvg%20width%3D%22103%22%20height%3D%2217%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cg%20fill%3D%22none%22%20fill-rule%3D%22evenodd%22%3E%3Cpath%20d%3D%22M.148%202.976h3.766c.532%200%201.024.117%201.477.35.453.233.814.555%201.085.966.27.41.406.863.406%201.358%200%20.495-.124.924-.371%201.288s-.572.64-.973.826v.084c.504.177.912.471%201.225.882.313.41.469.891.469%201.442a2.6%202.6%200%200%201-.427%201.47c-.285.43-.667.763-1.148%201.001A3.5%203.5%200%200%201%204.082%2013H.148V2.976zm3.696%204.2c.448%200%20.81-.14%201.085-.42.275-.28.413-.602.413-.966s-.133-.684-.399-.959c-.266-.275-.614-.413-1.043-.413H1.716v2.758h2.128zm.238%204.368c.476%200%20.856-.15%201.141-.448.285-.299.427-.644.427-1.036%200-.401-.147-.749-.441-1.043-.294-.294-.688-.441-1.183-.441h-2.31v2.968h2.366zm5.379.903c-.453-.518-.679-1.239-.679-2.163V5.86h1.54v4.214c0%20.579.138%201.013.413%201.302.275.29.637.434%201.085.434.364%200%20.686-.096.966-.287.28-.191.495-.446.644-.763a2.37%202.37%200%200%200%20.224-1.022V5.86h1.54V13h-1.456v-.924h-.084c-.196.336-.5.611-.91.826-.41.215-.845.322-1.302.322-.868%200-1.528-.259-1.981-.777zm9.859.161L16.352%205.86h1.722l2.016%204.858h.056l1.96-4.858H23.8l-4.41%2010.164h-1.624l1.554-3.416zm8.266-6.748h1.666l1.442%205.11h.056l1.61-5.11h1.582l1.596%205.11h.056l1.442-5.11h1.638L36.392%2013h-1.624L33.13%207.876h-.042L31.464%2013h-1.596l-2.282-7.14zm12.379-1.337a1%201%200%200%201-.301-.735%201%201%200%200%201%20.301-.735%201%201%200%200%201%20.735-.301%201%201%200%200%201%20.735.301%201%201%200%200%201%20.301.735%201%201%200%200%201-.301.735%201%201%200%200%201-.735.301%201%201%200%200%201-.735-.301zM39.93%205.86h1.54V13h-1.54V5.86zm5.568%207.098a1.967%201.967%200%200%201-.686-.406c-.401-.401-.602-.947-.602-1.638V7.218h-1.246V5.86h1.246V3.844h1.54V5.86h1.736v1.358H45.75v3.36c0%20.383.075.653.224.812.14.187.383.28.728.28.159%200%20.299-.021.42-.063.121-.042.252-.11.392-.203v1.498c-.308.14-.681.21-1.12.21-.317%200-.616-.051-.896-.154zm3.678-9.982h1.54v2.73l-.07%201.092h.07c.205-.336.511-.614.917-.833.406-.22.842-.329%201.309-.329.868%200%201.53.254%201.988.763.457.509.686%201.202.686%202.079V13h-1.54V8.688c0-.541-.142-.947-.427-1.218-.285-.27-.656-.406-1.113-.406-.345%200-.656.098-.931.294a2.042%202.042%200%200%200-.651.777%202.297%202.297%200%200%200-.238%201.029V13h-1.54V2.976zm32.35-.341v4.083h2.518c.6%200%201.096-.202%201.488-.605.403-.402.605-.882.605-1.437%200-.544-.202-1.018-.605-1.422-.392-.413-.888-.62-1.488-.62h-2.518zm0%205.52v4.736h-1.504V1.198h3.99c1.013%200%201.873.337%202.582%201.012.72.675%201.08%201.497%201.08%202.466%200%20.991-.36%201.819-1.08%202.482-.697.665-1.559.996-2.583.996h-2.485v.001zm7.668%202.287c0%20.392.166.718.499.98.332.26.722.391%201.168.391.633%200%201.196-.234%201.692-.701.497-.469.744-1.019.744-1.65-.469-.37-1.123-.555-1.962-.555-.61%200-1.12.148-1.528.442-.409.294-.613.657-.613%201.093m1.946-5.815c1.112%200%201.989.297%202.633.89.642.594.964%201.408.964%202.442v4.932h-1.439v-1.11h-.065c-.622.914-1.45%201.372-2.486%201.372-.882%200-1.621-.262-2.215-.784-.594-.523-.891-1.176-.891-1.96%200-.828.313-1.486.94-1.976s1.463-.735%202.51-.735c.892%200%201.629.163%202.206.49v-.344c0-.522-.207-.966-.621-1.33a2.132%202.132%200%200%200-1.455-.547c-.84%200-1.504.353-1.995%201.062l-1.324-.834c.73-1.045%201.81-1.568%203.238-1.568m11.853.262l-5.02%2011.53H96.42l1.864-4.034-3.302-7.496h1.635l2.387%205.749h.032l2.322-5.75z%22%20fill%3D%22%23000%22%2F%3E%3Cpath%20d%3D%22M75.448%207.134c0-.473-.04-.93-.116-1.366h-6.344v2.588h3.634a3.11%203.11%200%200%201-1.344%202.042v1.68h2.169c1.27-1.17%202.001-2.9%202.001-4.944%22%20fill%3D%22%234285F4%22%2F%3E%3Cpath%20d%3D%22M68.988%2013.7c1.816%200%203.344-.595%204.459-1.621l-2.169-1.681c-.603.406-1.38.643-2.29.643-1.754%200-3.244-1.182-3.776-2.774h-2.234v1.731a6.728%206.728%200%200%200%206.01%203.703%22%20fill%3D%22%2334A853%22%2F%3E%3Cpath%20d%3D%22M65.212%208.267a4.034%204.034%200%200%201%200-2.572V3.964h-2.234a6.678%206.678%200%200%200-.717%203.017c0%201.085.26%202.11.717%203.017l2.234-1.731z%22%20fill%3D%22%23FABB05%22%2F%3E%3Cpath%20d%3D%22M68.988%202.921c.992%200%201.88.34%202.58%201.008v.001l1.92-1.918c-1.165-1.084-2.685-1.75-4.5-1.75a6.728%206.728%200%200%200-6.01%203.702l2.234%201.731c.532-1.592%202.022-2.774%203.776-2.774%22%20fill%3D%22%23E94235%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E);
52
- }
53
- }
54
-
55
- /*
56
- * Apple Pay Button Styles
57
- */
58
- @supports (-webkit-appearance: -apple-pay-button) {
59
- .apple-pay-button {
60
- -webkit-appearance: -apple-pay-button;
61
- cursor: pointer;
62
- }
63
-
64
- .apple-pay-button > * {
65
- display: none;
66
- }
67
- }
68
-
69
- @supports not (-webkit-appearance: -apple-pay-button) {
70
- .apple-pay-button {
71
- background-size: 100% 60%;
72
- background-repeat: no-repeat;
73
- background-position: 50% 50%;
74
- border-radius: 5px;
75
- padding: 0px;
76
- box-sizing: border-box;
77
- min-width: 200px;
78
- min-height: 32px;
79
- max-height: 64px;
80
- cursor: pointer;
81
-
82
- &.wc-square-wallet-button-with-text {
83
- --apple-pay-scale: 1; /* (height / 32) */
84
- justify-content: center;
85
- font-size: 12px;
86
- background: none;
87
-
88
- .text {
89
- font-family: -apple-system;
90
- font-size: calc(1em * var(--apple-pay-scale));
91
- font-weight: 300;
92
- align-self: center;
93
- margin-right: calc(2px * var(--apple-pay-scale));
94
- }
95
-
96
- .logo {
97
- width: calc(35px * var(--scale));
98
- height: 100%;
99
- background-size: 100% 60%;
100
- background-repeat: no-repeat;
101
- background-position: 0 50%;
102
- margin-left: calc(2px * var(--apple-pay-scale));
103
- border: none;
104
- }
105
- }
106
-
107
- &.wc-square-wallet-button-black {
108
- background-color: black;
109
- color: white;
110
-
111
- .logo {
112
- background-image: -webkit-named-image(apple-pay-logo-white);
113
- background-color: black;
114
- }
115
- }
116
-
117
- &.wc-square-wallet-button-white {
118
- background-color: white;
119
- color: black;
120
-
121
- .logo {
122
- background-image: -webkit-named-image(apple-pay-logo-black);
123
- background-color: white;
124
- }
125
- }
126
-
127
- &.wc-square-wallet-button-white-outline {
128
- background-color: white;
129
- color: black;
130
- border: .5px solid black;
131
-
132
- .logo {
133
- background-image: -webkit-named-image(apple-pay-logo-black);
134
- background-color: white;
135
- }
136
- }
137
- }
138
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/css/frontend/wc-square.min.css CHANGED
@@ -1,2 +1 @@
1
- .woocommerce #payment div.payment_method_square_credit_card div.form-row{padding:3px}.woocommerce #payment div.payment_method_square_credit_card .wc-square-credit-card-hosted-field{height:3em;padding:5px;border:1px solid #ccc;border-radius:3px;transition:border-color 160ms;-webkit-transition:border-color 160ms;background-color:#fff}.woocommerce #payment div.payment_method_square_credit_card .wc-square-credit-card-hosted-field-card-number{padding-right:55px;background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-cc-plain.svg);background-repeat:no-repeat;background-position:99%;background-size:50px 31px}.woocommerce #payment div.payment_method_square_credit_card .wc-square-credit-card-hosted-field-card-number.card-type-visa{background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-visa.svg)}.woocommerce #payment div.payment_method_square_credit_card .wc-square-credit-card-hosted-field-card-number.card-type-mastercard{background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-mastercard.svg)}.woocommerce #payment div.payment_method_square_credit_card .wc-square-credit-card-hosted-field-card-number.card-type-amex{background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-amex.svg)}.woocommerce #payment div.payment_method_square_credit_card .wc-square-credit-card-hosted-field-card-number.card-type-diners-club{background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-dinersclub.svg)}.woocommerce #payment div.payment_method_square_credit_card .wc-square-credit-card-hosted-field-card-number.card-type-maestro{background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-maestro.svg)}.woocommerce #payment div.payment_method_square_credit_card .wc-square-credit-card-hosted-field-card-number.card-type-jcb{background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-jcb.svg)}.woocommerce #payment div.payment_method_square_credit_card .wc-square-credit-card-hosted-field-card-number.card-type-discover{background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-discover.svg)}.woocommerce #payment div.payment_method_square_credit_card .wc-square-credit-card-hosted-field-card-number.card-type-invalid{background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-cc-invalid.svg)}@media only screen and (max-width:320px){.woocommerce #payment div.payment_method_square_credit_card .wc-square-credit-card-hosted-field-card-number{background-image:none}}.woocommerce #payment div.payment_method_square_credit_card .wc-square-credit-card-payment-field--error{border-color:#a00}
2
- /*# sourceMappingURL=wc-square.min.css.map */
1
+ .woocommerce #payment div.payment_method_square_credit_card div.form-row{padding:3px}.woocommerce #payment div.payment_method_square_credit_card .wc-square-credit-card-hosted-field{height:3em;padding:5px;border:1px solid #ccc;border-radius:3px;transition:border-color 160ms;-webkit-transition:border-color 160ms;background-color:#fff}.woocommerce #payment div.payment_method_square_credit_card .wc-square-credit-card-hosted-field-card-number{padding-right:55px;background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-cc-plain.svg);background-repeat:no-repeat;background-position:99%;background-size:50px 31px}.woocommerce #payment div.payment_method_square_credit_card .wc-square-credit-card-hosted-field-card-number.card-type-visa{background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-visa.svg)}.woocommerce #payment div.payment_method_square_credit_card .wc-square-credit-card-hosted-field-card-number.card-type-mastercard{background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-mastercard.svg)}.woocommerce #payment div.payment_method_square_credit_card .wc-square-credit-card-hosted-field-card-number.card-type-amex{background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-amex.svg)}.woocommerce #payment div.payment_method_square_credit_card .wc-square-credit-card-hosted-field-card-number.card-type-diners-club{background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-dinersclub.svg)}.woocommerce #payment div.payment_method_square_credit_card .wc-square-credit-card-hosted-field-card-number.card-type-maestro{background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-maestro.svg)}.woocommerce #payment div.payment_method_square_credit_card .wc-square-credit-card-hosted-field-card-number.card-type-jcb{background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-jcb.svg)}.woocommerce #payment div.payment_method_square_credit_card .wc-square-credit-card-hosted-field-card-number.card-type-discover{background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-discover.svg)}.woocommerce #payment div.payment_method_square_credit_card .wc-square-credit-card-hosted-field-card-number.card-type-invalid{background-image:url(../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images/card-cc-invalid.svg)}@media only screen and (max-width:320px){.woocommerce #payment div.payment_method_square_credit_card .wc-square-credit-card-hosted-field-card-number{background-image:none}}.woocommerce #payment div.payment_method_square_credit_card .wc-square-credit-card-payment-field--error{border-color:#a00}
 
assets/css/frontend/wc-square.min.css.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["wc-square.scss"],"names":[],"mappings":"AASI,yEACF,QAAS,IAQV,gGACC,OAAQ,IACR,QAAS,IACT,OAAQ,IAAA,MAAA,KACR,cAAe,IACf,WAAY,aAAA,MACZ,mBAAoB,aAAA,MACpB,iBAAkB,KAGnB,4GACG,cAAe,KACjB,iBAAkB,8GAClB,kBAAmB,UACnB,oBAAqB,IACrB,gBAAiB,KAAA,KAL6B,2HAQ7C,iBAAkB,0GAR2B,iIAY7C,iBAAkB,gHAZ2B,2HAgB7C,iBAAkB,0GAhB2B,kIAoB7C,iBAAkB,gHApB2B,8HAwB7C,iBAAkB,6GAxB2B,0HA4B7C,iBAAkB,yGA5B2B,+HAgC7C,iBAAkB,8GAhC2B,8HAoC7C,iBAAkB,gHAGqB,yCAvCzC,4GAwCE,iBAAkB,MAIpB,wGACC,aAAc"}
 
assets/css/frontend/wc-square.scss DELETED
@@ -1,76 +0,0 @@
1
- $image_path: '../../../vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/images';
2
-
3
- // checkout, Order > Pay, and Add Payment Method pages
4
- .woocommerce #payment div.payment_method_square_credit_card {
5
-
6
- iframe {
7
-
8
- }
9
-
10
- div.form-row {
11
- padding: 3px;
12
- }
13
-
14
- .wc-square-hosted-field-parent {
15
-
16
- }
17
-
18
- // general input styling
19
- .wc-square-credit-card-hosted-field {
20
- height: 3em;
21
- padding: 5px;
22
- border: 1px solid #ccc;
23
- border-radius: 3px;
24
- transition: border-color 160ms;
25
- -webkit-transition: border-color 160ms;
26
- background-color: white;
27
- }
28
-
29
- .wc-square-credit-card-hosted-field-card-number {
30
- padding-right: 55px;
31
- background-image: url('#{$image_path}/card-cc-plain.svg');
32
- background-repeat: no-repeat;
33
- background-position: 99%;
34
- background-size: 50px 31px;
35
-
36
- &.card-type-visa {
37
- background-image: url('#{$image_path}/card-visa.svg');
38
- }
39
-
40
- &.card-type-mastercard {
41
- background-image: url('#{$image_path}/card-mastercard.svg');
42
- }
43
-
44
- &.card-type-amex {
45
- background-image: url('#{$image_path}/card-amex.svg');
46
- }
47
-
48
- &.card-type-diners-club {
49
- background-image: url('#{$image_path}/card-dinersclub.svg');
50
- }
51
-
52
- &.card-type-maestro {
53
- background-image: url('#{$image_path}/card-maestro.svg');
54
- }
55
-
56
- &.card-type-jcb {
57
- background-image: url('#{$image_path}/card-jcb.svg');
58
- }
59
-
60
- &.card-type-discover {
61
- background-image: url('#{$image_path}/card-discover.svg');
62
- }
63
-
64
- &.card-type-invalid {
65
- background-image: url('#{$image_path}/card-cc-invalid.svg');
66
- }
67
-
68
- @media only screen and (max-width : 320px) {
69
- background-image: none;
70
- }
71
- }
72
-
73
- .wc-square-credit-card-payment-field--error {
74
- border-color: #a00;
75
- }
76
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/js/admin/wc-square-admin-products.js DELETED
@@ -1,489 +0,0 @@
1
- /* global wc_square_admin_products */
2
-
3
- /**
4
- * WooCommerce Square admin general scripts for the settings page and update tab.
5
- *
6
- * @since 2.0.0
7
- */
8
- jQuery( document ).ready( ( $ ) => {
9
- const typenow = window.typenow || '';
10
- const pagenow = window.pagenow || '';
11
-
12
- // bail if not on product admin pages.
13
- if ( 'product' !== typenow ) {
14
- return;
15
- }
16
-
17
- // bail if product sync is disabled.
18
- if ( ! wc_square_admin_products.is_product_sync_enabled ) {
19
- return;
20
- }
21
-
22
- // products quick edit screen.
23
- if ( 'edit-product' === pagenow ) {
24
- // when clicking the quick edit button fetch the default Synced with Square checkbox
25
- $( '#the-list' ).on( 'click', '.editinline', ( e ) => {
26
- const $row = $( e.target ).closest( 'tr' );
27
- const postID = $row.find( 'th.check-column input' ).val();
28
- const data = {
29
- action: 'wc_square_get_quick_edit_product_details',
30
- security: wc_square_admin_products.get_quick_edit_product_details_nonce,
31
- product_id: $row.find( 'th.check-column input' ).val(),
32
- };
33
-
34
- $.post( wc_square_admin_products.ajax_url, data, ( response ) => {
35
- const $editRow = $( 'tr#edit-' + postID );
36
- const $squareSynced = $editRow.find( 'select.square-synced' );
37
- const $errors = $editRow.find( '.wc-square-sync-with-square-errors' );
38
-
39
- if ( ! response.success && response.data ) {
40
- // if the product has multiple attributes we show an inline error message and bail.
41
- if ( 'multiple_attributes' === response.data ) {
42
- $squareSynced.prop( 'checked', false );
43
- $squareSynced.prop( 'disabled', true );
44
- $errors.find( '.multiple_attributes' ).show();
45
- return;
46
-
47
- // if the product has variations without an SKU we show an inline error message and bail.
48
- } else if ( 'missing_variation_sku' === response.data ) {
49
- $squareSynced.prop( 'checked', false );
50
- $squareSynced.prop( 'disabled', true );
51
- $errors.find( '.missing_variation_sku' ).show();
52
- return;
53
- }
54
- }
55
-
56
- const $sku = $editRow.find( 'input[name=_sku]' );
57
- const $stockStatus = $editRow.find( 'select[name=_stock_status]' );
58
- const $stockQty = $editRow.find( 'input[name=_stock]' );
59
- const $manageStockLabel = $editRow.find( '.manage_stock_field .manage_stock' );
60
- const $manageStockInput = $editRow.find( 'input[name=_manage_stock]' );
61
- const $manageStockDesc = '<span class="description"><a href="' + wc_square_admin_products.settings_url + '">' + wc_square_admin_products.i18n.synced_with_square + '</a></span>';
62
- const edit_url = response.data.edit_url;
63
- const i18n = response.data.i18n;
64
- const is_variable = response.data.is_variable;
65
-
66
- $squareSynced.val( response.data.is_synced_with_square );
67
-
68
- // if the SKU changes, enabled or disable Synced with Square checkbox accordingly
69
- $sku.on( 'change keyup keypress', ( e ) => {
70
- if ( '' === $( e.target ).val() && ! is_variable ) {
71
- $squareSynced.val( 'no' ).trigger( 'change' );
72
- $squareSynced.prop( 'disabled', true );
73
- $errors.find( '.missing_sku' ).show();
74
- } else {
75
- $squareSynced.prop( 'disabled', false );
76
- $squareSynced.trigger( 'change' );
77
- return $errors.find( '.missing_sku' ).hide();
78
- }
79
- } ).trigger( 'change' );
80
-
81
- // if Synced with Square is enabled, we might as well disable stock management (without verbose explanations as in the product page).
82
- $squareSynced.on( 'change', ( e ) => {
83
- if ( 'no' === $( e.target ).val() ) {
84
- $manageStockInput.off();
85
- $manageStockInput.add( $stockQty ).css( {
86
- opacity: 1,
87
- } );
88
-
89
- $manageStockLabel.find( '.description' ).remove();
90
-
91
- // Stock input manipulation will differ depending on whether product is variable or simple.
92
- if ( is_variable ) {
93
- if ( $manageStockInput.is( ':checked' ) ) {
94
- $( '.stock_qty_field' ).show();
95
- $( '.backorder_field' ).show();
96
- } else {
97
- $( '.stock_status_field' ).show();
98
- }
99
- } else {
100
- $stockQty.prop( 'readonly', false );
101
- $stockStatus.prop( 'readonly', false );
102
- }
103
- } else {
104
- $manageStockInput.prop( 'checked', true );
105
- $manageStockInput.on( 'click', () => {
106
- return false;
107
- } );
108
-
109
- $manageStockInput.add( $stockQty ).css( {
110
- opacity: '0.5',
111
- } );
112
-
113
- $manageStockLabel.append( $manageStockDesc );
114
-
115
- if ( wc_square_admin_products.is_woocommerce_sor && edit_url && i18n ) {
116
- $manageStockLabel.append( '<p class="description"><a href="' + edit_url + '">' + i18n + '</a></p>' );
117
- }
118
-
119
- if ( is_variable ) {
120
- $( '.stock_status_field' ).hide();
121
- $( '.stock_qty_field' ).hide();
122
- $( '.backorder_field' ).hide();
123
- } else {
124
- $stockQty.prop( 'readonly', true );
125
- $stockStatus.prop( 'readonly', true );
126
- }
127
- }
128
- } ).trigger( 'change' );
129
- } );
130
- } );
131
- }
132
-
133
- // individual product edit screen.
134
- if ( 'product' === pagenow ) {
135
- const syncCheckboxID = '#_' + wc_square_admin_products.synced_with_square_taxonomy;
136
-
137
- /**
138
- * Checks whether the product is variable.
139
- *
140
- * @since 2.0.0
141
- */
142
- const isVariable = () => {
143
- return wc_square_admin_products.variable_product_types.includes( $( '#product-type' ).val() );
144
- };
145
-
146
- /**
147
- * Checks whether the product has a SKU.
148
- *
149
- * @since 2.0.0
150
- */
151
- const hasSKU = () => {
152
- return '' !== $( '#_sku' ).val().trim();
153
- };
154
-
155
- /**
156
- * Checks whether the product variations all have SKUs.
157
- *
158
- * @since 2.2.3
159
- *
160
- * @param {Array} skus
161
- */
162
- const hasVariableSKUs = ( skus ) => {
163
- if ( ! skus.length ) {
164
- return false;
165
- }
166
-
167
- const valid = skus.filter( ( sku ) => '' !== $( sku ).val().trim() );
168
-
169
- return valid.length === skus.length;
170
- };
171
-
172
- /**
173
- * Checks whether the given skus are unique.
174
- *
175
- * @since 2.2.3
176
- *
177
- * @param {Array} skus
178
- */
179
- const hasUniqueSKUs = ( skus ) => {
180
- const skuValues = skus.map( ( sku ) => $( sku ).val() );
181
-
182
- return skuValues.every( ( sku ) => skuValues.indexOf( sku ) === skuValues.lastIndexOf( sku ) );
183
- };
184
-
185
- /**
186
- * Checks whether the product has more than one variation attribute.
187
- *
188
- * @since 2.0.0
189
- */
190
- const hasMultipleAttributes = () => {
191
- const $variation_attributes = $( '.woocommerce_attribute_data input[name^="attribute_variation"]:checked' );
192
-
193
- return isVariable() && $variation_attributes && $variation_attributes.length > 1;
194
- };
195
-
196
- /**
197
- * Displays the given error and disables the sync checkbox.
198
- * Accepted errors are 'missing_sku', 'missing_variation_sku', and 'multiple_attributes'.
199
- *
200
- * @since 2.2.3
201
- *
202
- * @param {string} error
203
- */
204
- const showError = ( error ) => {
205
- $( '.wc-square-sync-with-square-error.' + error ).show();
206
- $( syncCheckboxID ).prop( 'disabled', true );
207
- $( syncCheckboxID ).prop( 'checked', false );
208
- };
209
-
210
- /**
211
- * Hides the given error and maybe enables the sync checkbox.
212
- * Accepted errors are 'missing_sku', 'missing_variation_sku', and 'multiple_attributes'.
213
- *
214
- * @since 2.2.3
215
- *
216
- * @param {string} error
217
- * @param {boolean} enable Whether to enable the sync checkbox.
218
- */
219
- const hideError = ( error, enable = true ) => {
220
- $( '.wc-square-sync-with-square-error.' + error ).hide();
221
-
222
- if ( enable ) {
223
- $( syncCheckboxID ).prop( 'disabled', false );
224
- }
225
- };
226
-
227
- /**
228
- * Handle SKU.
229
- *
230
- * Disables the Sync with Square checkbox and toggles an inline notice when no SKU is set on a product.
231
- *
232
- * @since 2.0.
233
- *
234
- * @param {string} syncCheckboxID
235
- */
236
- const handleSKU = ( syncCheckboxID ) => {
237
- if ( isVariable() ) {
238
- $( '#_sku' ).off( 'change keypress keyup' );
239
- hideError( 'missing_sku', ! hasMultipleAttributes() );
240
-
241
- const skus = $( 'input[id^="variable_sku"]' );
242
- skus.on( 'change keypress keyup', () => {
243
- if ( ! hasVariableSKUs( $.makeArray( skus ) ) || ! hasUniqueSKUs( $.makeArray( skus ) ) ) {
244
- showError( 'missing_variation_sku' );
245
- } else {
246
- hideError( 'missing_variation_sku', ! hasMultipleAttributes() );
247
- }
248
- $( syncCheckboxID ).triggerHandler( 'change' );
249
- } ).triggerHandler( 'change' );
250
- } else {
251
- $( 'input[id^="variable_sku"]' ).off( 'change keypress keyup' );
252
- hideError( 'missing_variation_sku', ! hasMultipleAttributes() );
253
-
254
- $( '#_sku' ).on( 'change keypress keyup', ( e ) => {
255
- if ( '' === $( e.target ).val().trim() ) {
256
- showError( 'missing_sku' );
257
- } else {
258
- hideError( 'missing_sku', ! hasMultipleAttributes() );
259
- }
260
- $( syncCheckboxID ).trigger( 'change' );
261
- } ).trigger( 'change' );
262
- }
263
- };
264
-
265
- /**
266
- * Disables the Sync with Square checkbox and toggles an inline notice when more than one attribute is set on the product.
267
- *
268
- * @since 2.0.0
269
- *
270
- * @param {string} syncCheckboxID
271
- */
272
- const handleAttributes = ( syncCheckboxID ) => {
273
- $( '#variable_product_options' ).on( 'reload', () => {
274
- if ( hasMultipleAttributes() ) {
275
- showError( 'multiple_attributes' );
276
- } else {
277
- hideError( 'multiple_attributes', isVariable() ? hasVariableSKUs : hasSKU() );
278
- }
279
-
280
- $( syncCheckboxID ).trigger( 'change' );
281
- } ).trigger( 'reload' );
282
- };
283
-
284
- /**
285
- * Triggers an update to the sync checkbox, checking for relevant errors.
286
- *
287
- * @since 2.2.3
288
- */
289
- const triggerUpdate = () => {
290
- handleSKU( syncCheckboxID );
291
- $( syncCheckboxID ).trigger( 'change' );
292
-
293
- // handleSKU misses cases where product is variable with no variations.
294
- if ( isVariable() && ! $( 'input[id^="variable_sku"]' ).length ) {
295
- showError( 'missing_variation_sku' );
296
- }
297
- };
298
-
299
- // fire once on page load
300
- handleAttributes( syncCheckboxID );
301
-
302
- /**
303
- * Handle stock management.
304
- *
305
- * If product is managed by Square, handle stock fields according to chosen SoR.
306
- */
307
- const $stockFields = $( '.stock_fields' );
308
- const $stockInput = $stockFields.find( '#_stock' );
309
- const $stockStatus = $( '.stock_status_field' );
310
- const $manageField = $( '._manage_stock_field' );
311
- const $manageInput = $manageField.find( '#_manage_stock' );
312
- const $manageDesc = $manageField.find( '.description' );
313
- // keep note of the original manage stock checkbox description, if we need to restore it later
314
- const manageDescOriginal = $manageDesc.text();
315
- // keep track of the original manage stock checkbox status, if we need to restore it later
316
- const manageStockOriginal = $( '#_manage_stock' ).is( ':checked' );
317
-
318
- $( syncCheckboxID ).on( 'change', ( e ) => {
319
- // only handle stock fields if inventory sync is enabled.
320
- if ( ! wc_square_admin_products.is_inventory_sync_enabled ) {
321
- return;
322
- }
323
-
324
- const variableProduct = wc_square_admin_products.variable_product_types.includes( $( '#product-type' ).val() );
325
-
326
- let useSquare;
327
-
328
- if ( $( e.target ).is( ':checked' ) && $( '#_square_item_variation_id' ).length > 0 ) {
329
- useSquare = true;
330
-
331
- $manageDesc.html( '<a href="' + wc_square_admin_products.settings_url + '">' + wc_square_admin_products.i18n.synced_with_square + '</a>' );
332
- $manageInput.prop( 'disabled', true ).prop( 'checked', ! variableProduct );
333
- $stockFields.hide();
334
- $stockStatus.hide();
335
- $stockInput.prop( 'readonly', true );
336
-
337
- if ( ! variableProduct ) {
338
- $stockFields.show();
339
- }
340
-
341
- // WooCommerce SoR - note: for variable products, the stock can be fetched for individual variations.
342
- if ( wc_square_admin_products.is_woocommerce_sor && ! variableProduct ) {
343
- // add inline note with a toggle to fetch stock from Square manually via AJAX (sanity check to avoid appending multiple times).
344
- if ( $( 'p._stock_field span.description' ).length === 0 ) {
345
- $stockInput.after(
346
- '<span class="description" style="display:block;clear:both;"><a href="#" id="fetch-stock-with-square">' + wc_square_admin_products.i18n.fetch_stock_with_square + '</a><div class="spinner" style="float:none;"></div></span>'
347
- );
348
- }
349
- $( '#fetch-stock-with-square' ).on( 'click', ( e ) => {
350
- e.preventDefault();
351
- const $spinner = $( 'p._stock_field span.description .spinner' );
352
- const data = {
353
- action: 'wc_square_fetch_product_stock_with_square',
354
- security: wc_square_admin_products.fetch_product_stock_with_square_nonce,
355
- product_id: $( '#post_ID' ).val(),
356
- };
357
-
358
- $spinner.css( 'visibility', 'visible' );
359
-
360
- $.post( wc_square_admin_products.ajax_url, data, ( response ) => {
361
- if ( response && response.success ) {
362
- const quantity = response.data;
363
-
364
- $stockInput.val( quantity );
365
- $stockFields.find( 'input[name=_original_stock]' ).val( quantity );
366
- $stockInput.prop( 'readonly', false );
367
- $( 'p._stock_field span.description' ).remove();
368
- } else {
369
- if ( response.data ) {
370
- $( '.inventory-fetch-error' ).remove();
371
- $spinner.after( '<span class="inventory-fetch-error" style="display:inline-block;color:red;">' + response.data + '</span>' );
372
- }
373
-
374
- $spinner.css( 'visibility', 'hidden' );
375
- }
376
- } );
377
- } );
378
-
379
- // Square SoR.
380
- } else if ( wc_square_admin_products.is_square_sor ) {
381
- // add inline note explaining stock is managed by Square (sanity check to avoid appending multiple times)
382
- if ( $( 'p._stock_field span.description' ).length === 0 ) {
383
- $stockInput.after( '<span class="description" style="display:block;clear:both;">' + wc_square_admin_products.i18n.managed_by_square + '</span>' );
384
- }
385
- }
386
- } else {
387
- useSquare = false;
388
-
389
- // remove any inline note to WooCommerce core stock fields that may have been added when Synced with Square is enabled.
390
- $( 'p._stock_field span.description' ).remove();
391
- $stockInput.prop( 'readonly', false );
392
- $manageDesc.html( manageDescOriginal );
393
- $manageInput.prop( 'disabled', false ).prop( 'checked', manageStockOriginal );
394
-
395
- if ( manageStockOriginal ) {
396
- $stockFields.show();
397
- $stockStatus.hide();
398
- } else {
399
- $stockStatus.show();
400
- $stockFields.hide();
401
- }
402
- }
403
-
404
- // handle variations data separately (HTML differs from parent UI!).
405
- $( '.woocommerce_variation' ).each( ( index, e ) => {
406
- // fetch relevant variables for each variation.
407
- const variationID = $( e ).find( 'h3 > a' ).attr( 'rel' );
408
- const $variationManageInput = $( e ).find( '.variable_manage_stock' );
409
- const $variationManageField = $variationManageInput.parent();
410
- const $variationStockInput = $( e ).find( '.wc_input_stock' );
411
- const $variationStockField = $variationStockInput.parent();
412
-
413
- // Square manages variations stock
414
- if ( useSquare ) {
415
- // disable stock management inputs
416
- $( '#wc_square_variation_manage_stock' ).prop( 'disabled', false );
417
- $variationStockInput.prop( 'readonly', true );
418
- $variationManageInput
419
- .prop( 'disabled', true )
420
- .prop( 'checked', true );
421
-
422
- // add a note that the variation stock is managed by square, but check if it wasn't added already to avoid duplicates.
423
- if ( 0 === $variationManageField.find( '.description' ).length ) {
424
- $variationManageInput.after( '<span class="description">(' + wc_square_admin_products.i18n.managed_by_square + ')</span>' );
425
- }
426
-
427
- if ( wc_square_admin_products.is_woocommerce_sor ) {
428
- const fetchVariationStockActionID = 'fetch-stock-with-square-' + variationID;
429
-
430
- // add inline note with a toggle to fetch stock from Square manually via AJAX (sanity check to avoid appending multiple times)
431
- if ( 0 === $variationStockField.find( 'span.description' ).length ) {
432
- $variationStockInput.after(
433
- '<span class="description" style="display:block;clear:both;"><a href="#" id="' + fetchVariationStockActionID + '">' + wc_square_admin_products.i18n.fetch_stock_with_square + '</a><div class="spinner" style="float:none;"></div></span>'
434
- );
435
- }
436
-
437
- // listen for requests to update stock with Square for the individual variation.
438
- $( '#' + fetchVariationStockActionID ).on( 'click', ( e ) => {
439
- e.preventDefault();
440
- const $spinner = $( e.target ).next( '.spinner' );
441
- const data = {
442
- action: 'wc_square_fetch_product_stock_with_square',
443
- security: wc_square_admin_products.fetch_product_stock_with_square_nonce,
444
- product_id: variationID,
445
- };
446
-
447
- $spinner.css( 'visibility', 'visible' );
448
-
449
- $.post( wc_square_admin_products.ajax_url, data, ( response ) => {
450
- if ( response && response.success ) {
451
- const quantity = response.data;
452
-
453
- $variationStockInput.val( quantity );
454
- $variationStockField.parent().find( 'input[name^="variable_original_stock"]' ).val( quantity );
455
- $variationStockInput.prop( 'readonly', false );
456
- $variationStockField.find( '.description' ).remove();
457
- } else {
458
- if ( response.data ) {
459
- $( '.inventory-fetch-error' ).remove();
460
- $spinner.after( '<span class="inventory-fetch-error" style="display:inline-block;color:red;">' + response.data + '</span>' );
461
- }
462
-
463
- $spinner.css( 'visibility', 'hidden' );
464
- }
465
- } );
466
- } );
467
- }
468
- } else {
469
- // restore WooCommerce stock when user chooses to disable Sync with Square checkbox.
470
- $variationStockInput.prop( 'readonly', false );
471
- $variationManageInput.prop( 'disabled', false );
472
- $variationManageInput.next( '.description' ).remove();
473
- $( e.target ).find( '#wc_square_variation_manage_stock' ).prop( 'disabled', true );
474
- }
475
- } );
476
- // initial page load handling.
477
- } ).trigger( 'change' );
478
-
479
- // trigger an update if the product type changes.
480
- $( '#product-type' ).on( 'change', () => {
481
- triggerUpdate();
482
- } );
483
-
484
- // trigger an update for variable products when variations are loaded, added, or removed.
485
- $( '#woocommerce-product-data' ).on( 'woocommerce_variations_loaded woocommerce_variations_added woocommerce_variations_removed', () => {
486
- triggerUpdate();
487
- } );
488
-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@@
1
  "use strict";jQuery(document).ready(function($){var typenow=window.typenow||"";var pagenow=window.pagenow||"";if("product"!==typenow){return}if(!wc_square_admin_products.is_product_sync_enabled){return}if("edit-product"===pagenow){$("#the-list").on("click",".editinline",function(e){var $row=$(e.target).closest("tr");var postID=$row.find("th.check-column input").val();var data={action:"wc_square_get_quick_edit_product_details",security:wc_square_admin_products.get_quick_edit_product_details_nonce,product_id:$row.find("th.check-column input").val()};$.post(wc_square_admin_products.ajax_url,data,function(response){var $editRow=$("tr#edit-"+postID);var $squareSynced=$editRow.find("select.square-synced");var $errors=$editRow.find(".wc-square-sync-with-square-errors");if(!response.success&&response.data){if("multiple_attributes"===response.data){$squareSynced.prop("checked",false);$squareSynced.prop("disabled",true);$errors.find(".multiple_attributes").show();return}else if("missing_variation_sku"===response.data){$squareSynced.prop("checked",false);$squareSynced.prop("disabled",true);$errors.find(".missing_variation_sku").show();return}}var $sku=$editRow.find("input[name=_sku]");var $stockStatus=$editRow.find("select[name=_stock_status]");var $stockQty=$editRow.find("input[name=_stock]");var $manageStockLabel=$editRow.find(".manage_stock_field .manage_stock");var $manageStockInput=$editRow.find("input[name=_manage_stock]");var $manageStockDesc="<span class=\"description\"><a href=\""+wc_square_admin_products.settings_url+"\">"+wc_square_admin_products.i18n.synced_with_square+"</a></span>";var edit_url=response.data.edit_url;var i18n=response.data.i18n;var is_variable=response.data.is_variable;$squareSynced.val(response.data.is_synced_with_square);$sku.on("change keyup keypress",function(e){if(""===$(e.target).val()&&!is_variable){$squareSynced.val("no").trigger("change");$squareSynced.prop("disabled",true);$errors.find(".missing_sku").show()}else{$squareSynced.prop("disabled",false);$squareSynced.trigger("change");return $errors.find(".missing_sku").hide()}}).trigger("change");$squareSynced.on("change",function(e){if("no"===$(e.target).val()){$manageStockInput.off();$manageStockInput.add($stockQty).css({opacity:1});$manageStockLabel.find(".description").remove();if(is_variable){if($manageStockInput.is(":checked")){$(".stock_qty_field").show();$(".backorder_field").show()}else{$(".stock_status_field").show()}}else{$stockQty.prop("readonly",false);$stockStatus.prop("readonly",false)}}else{$manageStockInput.prop("checked",true);$manageStockInput.on("click",function(){return false});$manageStockInput.add($stockQty).css({opacity:"0.5"});$manageStockLabel.append($manageStockDesc);if(wc_square_admin_products.is_woocommerce_sor&&edit_url&&i18n){$manageStockLabel.append("<p class=\"description\"><a href=\""+edit_url+"\">"+i18n+"</a></p>")}if(is_variable){$(".stock_status_field").hide();$(".stock_qty_field").hide();$(".backorder_field").hide()}else{$stockQty.prop("readonly",true);$stockStatus.prop("readonly",true)}}}).trigger("change")})})}if("product"===pagenow){var syncCheckboxID="#_"+wc_square_admin_products.synced_with_square_taxonomy;var isVariable=function isVariable(){return wc_square_admin_products.variable_product_types.includes($("#product-type").val())};var hasSKU=function hasSKU(){return""!==$("#_sku").val().trim()};var hasVariableSKUs=function hasVariableSKUs(skus){if(!skus.length){return false}var valid=skus.filter(function(sku){return""!==$(sku).val().trim()});return valid.length===skus.length};var hasUniqueSKUs=function hasUniqueSKUs(skus){var skuValues=skus.map(function(sku){return $(sku).val()});return skuValues.every(function(sku){return skuValues.indexOf(sku)===skuValues.lastIndexOf(sku)})};var hasMultipleAttributes=function hasMultipleAttributes(){var $variation_attributes=$(".woocommerce_attribute_data input[name^=\"attribute_variation\"]:checked");return isVariable()&&$variation_attributes&&$variation_attributes.length>1};var showError=function showError(error){$(".wc-square-sync-with-square-error."+error).show();$(syncCheckboxID).prop("disabled",true);$(syncCheckboxID).prop("checked",false)};var hideError=function hideError(error){var enable=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;$(".wc-square-sync-with-square-error."+error).hide();if(enable){$(syncCheckboxID).prop("disabled",false)}};var handleSKU=function handleSKU(syncCheckboxID){if(isVariable()){$("#_sku").off("change keypress keyup");hideError("missing_sku",!hasMultipleAttributes());var skus=$("input[id^=\"variable_sku\"]");skus.on("change keypress keyup",function(){if(!hasVariableSKUs($.makeArray(skus))||!hasUniqueSKUs($.makeArray(skus))){showError("missing_variation_sku")}else{hideError("missing_variation_sku",!hasMultipleAttributes())}$(syncCheckboxID).triggerHandler("change")}).triggerHandler("change")}else{$("input[id^=\"variable_sku\"]").off("change keypress keyup");hideError("missing_variation_sku",!hasMultipleAttributes());$("#_sku").on("change keypress keyup",function(e){if(""===$(e.target).val().trim()){showError("missing_sku")}else{hideError("missing_sku",!hasMultipleAttributes())}$(syncCheckboxID).trigger("change")}).trigger("change")}};var handleAttributes=function handleAttributes(syncCheckboxID){$("#variable_product_options").on("reload",function(){if(hasMultipleAttributes()){showError("multiple_attributes")}else{hideError("multiple_attributes",isVariable()?hasVariableSKUs:hasSKU())}$(syncCheckboxID).trigger("change")}).trigger("reload")};var triggerUpdate=function triggerUpdate(){handleSKU(syncCheckboxID);$(syncCheckboxID).trigger("change");if(isVariable()&&!$("input[id^=\"variable_sku\"]").length){showError("missing_variation_sku")}};handleAttributes(syncCheckboxID);var $stockFields=$(".stock_fields");var $stockInput=$stockFields.find("#_stock");var $stockStatus=$(".stock_status_field");var $manageField=$("._manage_stock_field");var $manageInput=$manageField.find("#_manage_stock");var $manageDesc=$manageField.find(".description");var manageDescOriginal=$manageDesc.text();var manageStockOriginal=$("#_manage_stock").is(":checked");$(syncCheckboxID).on("change",function(e){if(!wc_square_admin_products.is_inventory_sync_enabled){return}var variableProduct=wc_square_admin_products.variable_product_types.includes($("#product-type").val());var useSquare;if($(e.target).is(":checked")&&$("#_square_item_variation_id").length>0){useSquare=true;$manageDesc.html("<a href=\""+wc_square_admin_products.settings_url+"\">"+wc_square_admin_products.i18n.synced_with_square+"</a>");$manageInput.prop("disabled",true).prop("checked",!variableProduct);$stockFields.hide();$stockStatus.hide();$stockInput.prop("readonly",true);if(!variableProduct){$stockFields.show()}if(wc_square_admin_products.is_woocommerce_sor&&!variableProduct){if($("p._stock_field span.description").length===0){$stockInput.after("<span class=\"description\" style=\"display:block;clear:both;\"><a href=\"#\" id=\"fetch-stock-with-square\">"+wc_square_admin_products.i18n.fetch_stock_with_square+"</a><div class=\"spinner\" style=\"float:none;\"></div></span>")}$("#fetch-stock-with-square").on("click",function(e){e.preventDefault();var $spinner=$("p._stock_field span.description .spinner");var data={action:"wc_square_fetch_product_stock_with_square",security:wc_square_admin_products.fetch_product_stock_with_square_nonce,product_id:$("#post_ID").val()};$spinner.css("visibility","visible");$.post(wc_square_admin_products.ajax_url,data,function(response){if(response&&response.success){var quantity=response.data;$stockInput.val(quantity);$stockFields.find("input[name=_original_stock]").val(quantity);$stockInput.prop("readonly",false);$("p._stock_field span.description").remove()}else{if(response.data){$(".inventory-fetch-error").remove();$spinner.after("<span class=\"inventory-fetch-error\" style=\"display:inline-block;color:red;\">"+response.data+"</span>")}$spinner.css("visibility","hidden")}})})}else if(wc_square_admin_products.is_square_sor){if($("p._stock_field span.description").length===0){$stockInput.after("<span class=\"description\" style=\"display:block;clear:both;\">"+wc_square_admin_products.i18n.managed_by_square+"</span>")}}}else{useSquare=false;$("p._stock_field span.description").remove();$stockInput.prop("readonly",false);$manageDesc.html(manageDescOriginal);$manageInput.prop("disabled",false).prop("checked",manageStockOriginal);if(manageStockOriginal){$stockFields.show();$stockStatus.hide()}else{$stockStatus.show();$stockFields.hide()}}$(".woocommerce_variation").each(function(index,e){var variationID=$(e).find("h3 > a").attr("rel");var $variationManageInput=$(e).find(".variable_manage_stock");var $variationManageField=$variationManageInput.parent();var $variationStockInput=$(e).find(".wc_input_stock");var $variationStockField=$variationStockInput.parent();if(useSquare){$("#wc_square_variation_manage_stock").prop("disabled",false);$variationStockInput.prop("readonly",true);$variationManageInput.prop("disabled",true).prop("checked",true);if(0===$variationManageField.find(".description").length){$variationManageInput.after("<span class=\"description\">("+wc_square_admin_products.i18n.managed_by_square+")</span>")}if(wc_square_admin_products.is_woocommerce_sor){var fetchVariationStockActionID="fetch-stock-with-square-"+variationID;if(0===$variationStockField.find("span.description").length){$variationStockInput.after("<span class=\"description\" style=\"display:block;clear:both;\"><a href=\"#\" id=\""+fetchVariationStockActionID+"\">"+wc_square_admin_products.i18n.fetch_stock_with_square+"</a><div class=\"spinner\" style=\"float:none;\"></div></span>")}$("#"+fetchVariationStockActionID).on("click",function(e){e.preventDefault();var $spinner=$(e.target).next(".spinner");var data={action:"wc_square_fetch_product_stock_with_square",security:wc_square_admin_products.fetch_product_stock_with_square_nonce,product_id:variationID};$spinner.css("visibility","visible");$.post(wc_square_admin_products.ajax_url,data,function(response){if(response&&response.success){var quantity=response.data;$variationStockInput.val(quantity);$variationStockField.parent().find("input[name^=\"variable_original_stock\"]").val(quantity);$variationStockInput.prop("readonly",false);$variationStockField.find(".description").remove()}else{if(response.data){$(".inventory-fetch-error").remove();$spinner.after("<span class=\"inventory-fetch-error\" style=\"display:inline-block;color:red;\">"+response.data+"</span>")}$spinner.css("visibility","hidden")}})})}}else{$variationStockInput.prop("readonly",false);$variationManageInput.prop("disabled",false);$variationManageInput.next(".description").remove();$(e.target).find("#wc_square_variation_manage_stock").prop("disabled",true)}})}).trigger("change");$("#product-type").on("change",function(){triggerUpdate()});$("#woocommerce-product-data").on("woocommerce_variations_loaded woocommerce_variations_added woocommerce_variations_removed",function(){triggerUpdate()})}});
2
- //# sourceMappingURL=wc-square-admin-products.min.js.map
1
  "use strict";jQuery(document).ready(function($){var typenow=window.typenow||"";var pagenow=window.pagenow||"";if("product"!==typenow){return}if(!wc_square_admin_products.is_product_sync_enabled){return}if("edit-product"===pagenow){$("#the-list").on("click",".editinline",function(e){var $row=$(e.target).closest("tr");var postID=$row.find("th.check-column input").val();var data={action:"wc_square_get_quick_edit_product_details",security:wc_square_admin_products.get_quick_edit_product_details_nonce,product_id:$row.find("th.check-column input").val()};$.post(wc_square_admin_products.ajax_url,data,function(response){var $editRow=$("tr#edit-"+postID);var $squareSynced=$editRow.find("select.square-synced");var $errors=$editRow.find(".wc-square-sync-with-square-errors");if(!response.success&&response.data){if("multiple_attributes"===response.data){$squareSynced.prop("checked",false);$squareSynced.prop("disabled",true);$errors.find(".multiple_attributes").show();return}else if("missing_variation_sku"===response.data){$squareSynced.prop("checked",false);$squareSynced.prop("disabled",true);$errors.find(".missing_variation_sku").show();return}}var $sku=$editRow.find("input[name=_sku]");var $stockStatus=$editRow.find("select[name=_stock_status]");var $stockQty=$editRow.find("input[name=_stock]");var $manageStockLabel=$editRow.find(".manage_stock_field .manage_stock");var $manageStockInput=$editRow.find("input[name=_manage_stock]");var $manageStockDesc="<span class=\"description\"><a href=\""+wc_square_admin_products.settings_url+"\">"+wc_square_admin_products.i18n.synced_with_square+"</a></span>";var edit_url=response.data.edit_url;var i18n=response.data.i18n;var is_variable=response.data.is_variable;$squareSynced.val(response.data.is_synced_with_square);$sku.on("change keyup keypress",function(e){if(""===$(e.target).val()&&!is_variable){$squareSynced.val("no").trigger("change");$squareSynced.prop("disabled",true);$errors.find(".missing_sku").show()}else{$squareSynced.prop("disabled",false);$squareSynced.trigger("change");return $errors.find(".missing_sku").hide()}}).trigger("change");$squareSynced.on("change",function(e){if("no"===$(e.target).val()){$manageStockInput.off();$manageStockInput.add($stockQty).css({opacity:1});$manageStockLabel.find(".description").remove();if(is_variable){if($manageStockInput.is(":checked")){$(".stock_qty_field").show();$(".backorder_field").show()}else{$(".stock_status_field").show()}}else{$stockQty.prop("readonly",false);$stockStatus.prop("readonly",false)}}else{$manageStockInput.prop("checked",true);$manageStockInput.on("click",function(){return false});$manageStockInput.add($stockQty).css({opacity:"0.5"});$manageStockLabel.append($manageStockDesc);if(wc_square_admin_products.is_woocommerce_sor&&edit_url&&i18n){$manageStockLabel.append("<p class=\"description\"><a href=\""+edit_url+"\">"+i18n+"</a></p>")}if(is_variable){$(".stock_status_field").hide();$(".stock_qty_field").hide();$(".backorder_field").hide()}else{$stockQty.prop("readonly",true);$stockStatus.prop("readonly",true)}}}).trigger("change")})})}if("product"===pagenow){var syncCheckboxID="#_"+wc_square_admin_products.synced_with_square_taxonomy;var isVariable=function isVariable(){return wc_square_admin_products.variable_product_types.includes($("#product-type").val())};var hasSKU=function hasSKU(){return""!==$("#_sku").val().trim()};var hasVariableSKUs=function hasVariableSKUs(skus){if(!skus.length){return false}var valid=skus.filter(function(sku){return""!==$(sku).val().trim()});return valid.length===skus.length};var hasUniqueSKUs=function hasUniqueSKUs(skus){var skuValues=skus.map(function(sku){return $(sku).val()});return skuValues.every(function(sku){return skuValues.indexOf(sku)===skuValues.lastIndexOf(sku)})};var hasMultipleAttributes=function hasMultipleAttributes(){var $variation_attributes=$(".woocommerce_attribute_data input[name^=\"attribute_variation\"]:checked");return isVariable()&&$variation_attributes&&$variation_attributes.length>1};var showError=function showError(error){$(".wc-square-sync-with-square-error."+error).show();$(syncCheckboxID).prop("disabled",true);$(syncCheckboxID).prop("checked",false)};var hideError=function hideError(error){var enable=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;$(".wc-square-sync-with-square-error."+error).hide();if(enable){$(syncCheckboxID).prop("disabled",false)}};var handleSKU=function handleSKU(syncCheckboxID){if(isVariable()){$("#_sku").off("change keypress keyup");hideError("missing_sku",!hasMultipleAttributes());var skus=$("input[id^=\"variable_sku\"]");skus.on("change keypress keyup",function(){if(!hasVariableSKUs($.makeArray(skus))||!hasUniqueSKUs($.makeArray(skus))){showError("missing_variation_sku")}else{hideError("missing_variation_sku",!hasMultipleAttributes())}$(syncCheckboxID).triggerHandler("change")}).triggerHandler("change")}else{$("input[id^=\"variable_sku\"]").off("change keypress keyup");hideError("missing_variation_sku",!hasMultipleAttributes());$("#_sku").on("change keypress keyup",function(e){if(""===$(e.target).val().trim()){showError("missing_sku")}else{hideError("missing_sku",!hasMultipleAttributes())}$(syncCheckboxID).trigger("change")}).trigger("change")}};var handleAttributes=function handleAttributes(syncCheckboxID){$("#variable_product_options").on("reload",function(){if(hasMultipleAttributes()){showError("multiple_attributes")}else{hideError("multiple_attributes",isVariable()?hasVariableSKUs:hasSKU())}$(syncCheckboxID).trigger("change")}).trigger("reload")};var triggerUpdate=function triggerUpdate(){handleSKU(syncCheckboxID);$(syncCheckboxID).trigger("change");if(isVariable()&&!$("input[id^=\"variable_sku\"]").length){showError("missing_variation_sku")}};handleAttributes(syncCheckboxID);var $stockFields=$(".stock_fields");var $stockInput=$stockFields.find("#_stock");var $stockStatus=$(".stock_status_field");var $manageField=$("._manage_stock_field");var $manageInput=$manageField.find("#_manage_stock");var $manageDesc=$manageField.find(".description");var manageDescOriginal=$manageDesc.text();var manageStockOriginal=$("#_manage_stock").is(":checked");$(syncCheckboxID).on("change",function(e){if(!wc_square_admin_products.is_inventory_sync_enabled){return}var variableProduct=wc_square_admin_products.variable_product_types.includes($("#product-type").val());var useSquare;if($(e.target).is(":checked")&&$("#_square_item_variation_id").length>0){useSquare=true;$manageDesc.html("<a href=\""+wc_square_admin_products.settings_url+"\">"+wc_square_admin_products.i18n.synced_with_square+"</a>");$manageInput.prop("disabled",true).prop("checked",!variableProduct);$stockFields.hide();$stockStatus.hide();$stockInput.prop("readonly",true);if(!variableProduct){$stockFields.show()}if(wc_square_admin_products.is_woocommerce_sor&&!variableProduct){if($("p._stock_field span.description").length===0){$stockInput.after("<span class=\"description\" style=\"display:block;clear:both;\"><a href=\"#\" id=\"fetch-stock-with-square\">"+wc_square_admin_products.i18n.fetch_stock_with_square+"</a><div class=\"spinner\" style=\"float:none;\"></div></span>")}$("#fetch-stock-with-square").on("click",function(e){e.preventDefault();var $spinner=$("p._stock_field span.description .spinner");var data={action:"wc_square_fetch_product_stock_with_square",security:wc_square_admin_products.fetch_product_stock_with_square_nonce,product_id:$("#post_ID").val()};$spinner.css("visibility","visible");$.post(wc_square_admin_products.ajax_url,data,function(response){if(response&&response.success){var quantity=response.data;$stockInput.val(quantity);$stockFields.find("input[name=_original_stock]").val(quantity);$stockInput.prop("readonly",false);$("p._stock_field span.description").remove()}else{if(response.data){$(".inventory-fetch-error").remove();$spinner.after("<span class=\"inventory-fetch-error\" style=\"display:inline-block;color:red;\">"+response.data+"</span>")}$spinner.css("visibility","hidden")}})})}else if(wc_square_admin_products.is_square_sor){if($("p._stock_field span.description").length===0){$stockInput.after("<span class=\"description\" style=\"display:block;clear:both;\">"+wc_square_admin_products.i18n.managed_by_square+"</span>")}}}else{useSquare=false;$("p._stock_field span.description").remove();$stockInput.prop("readonly",false);$manageDesc.html(manageDescOriginal);$manageInput.prop("disabled",false).prop("checked",manageStockOriginal);if(manageStockOriginal){$stockFields.show();$stockStatus.hide()}else{$stockStatus.show();$stockFields.hide()}}$(".woocommerce_variation").each(function(index,e){var variationID=$(e).find("h3 > a").attr("rel");var $variationManageInput=$(e).find(".variable_manage_stock");var $variationManageField=$variationManageInput.parent();var $variationStockInput=$(e).find(".wc_input_stock");var $variationStockField=$variationStockInput.parent();if(useSquare){$("#wc_square_variation_manage_stock").prop("disabled",false);$variationStockInput.prop("readonly",true);$variationManageInput.prop("disabled",true).prop("checked",true);if(0===$variationManageField.find(".description").length){$variationManageInput.after("<span class=\"description\">("+wc_square_admin_products.i18n.managed_by_square+")</span>")}if(wc_square_admin_products.is_woocommerce_sor){var fetchVariationStockActionID="fetch-stock-with-square-"+variationID;if(0===$variationStockField.find("span.description").length){$variationStockInput.after("<span class=\"description\" style=\"display:block;clear:both;\"><a href=\"#\" id=\""+fetchVariationStockActionID+"\">"+wc_square_admin_products.i18n.fetch_stock_with_square+"</a><div class=\"spinner\" style=\"float:none;\"></div></span>")}$("#"+fetchVariationStockActionID).on("click",function(e){e.preventDefault();var $spinner=$(e.target).next(".spinner");var data={action:"wc_square_fetch_product_stock_with_square",security:wc_square_admin_products.fetch_product_stock_with_square_nonce,product_id:variationID};$spinner.css("visibility","visible");$.post(wc_square_admin_products.ajax_url,data,function(response){if(response&&response.success){var quantity=response.data;$variationStockInput.val(quantity);$variationStockField.parent().find("input[name^=\"variable_original_stock\"]").val(quantity);$variationStockInput.prop("readonly",false);$variationStockField.find(".description").remove()}else{if(response.data){$(".inventory-fetch-error").remove();$spinner.after("<span class=\"inventory-fetch-error\" style=\"display:inline-block;color:red;\">"+response.data+"</span>")}$spinner.css("visibility","hidden")}})})}}else{$variationStockInput.prop("readonly",false);$variationManageInput.prop("disabled",false);$variationManageInput.next(".description").remove();$(e.target).find("#wc_square_variation_manage_stock").prop("disabled",true)}})}).trigger("change");$("#product-type").on("change",function(){triggerUpdate()});$("#woocommerce-product-data").on("woocommerce_variations_loaded woocommerce_variations_added woocommerce_variations_removed",function(){triggerUpdate()})}});
 
assets/js/admin/wc-square-admin-products.min.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["wc-square-admin-products.js"],"names":["jQuery","document","ready","$","typenow","window","pagenow","wc_square_admin_products","is_product_sync_enabled","on","e","$row","target","closest","postID","find","val","data","action","security","get_quick_edit_product_details_nonce","product_id","post","ajax_url","response","$editRow","$squareSynced","$errors","success","prop","show","$sku","$stockStatus","$stockQty","$manageStockLabel","$manageStockInput","$manageStockDesc","settings_url","i18n","synced_with_square","edit_url","is_variable","is_synced_with_square","trigger","hide","off","add","css","opacity","remove","is","append","is_woocommerce_sor","syncCheckboxID","synced_with_square_taxonomy","isVariable","variable_product_types","includes","hasSKU","trim","hasVariableSKUs","skus","length","valid","filter","sku","hasUniqueSKUs","skuValues","map","every","indexOf","lastIndexOf","hasMultipleAttributes","$variation_attributes","showError","error","hideError","enable","handleSKU","makeArray","triggerHandler","handleAttributes","triggerUpdate","$stockFields","$stockInput","$manageField","$manageInput","$manageDesc","manageDescOriginal","text","manageStockOriginal","is_inventory_sync_enabled","variableProduct","useSquare","html","after","fetch_stock_with_square","preventDefault","$spinner","fetch_product_stock_with_square_nonce","quantity","is_square_sor","managed_by_square","each","index","variationID","attr","$variationManageInput","$variationManageField","parent","$variationStockInput","$variationStockField","fetchVariationStockActionID","next"],"mappings":"aAOAA,MAAM,CAAEC,QAAF,CAAN,CAAmBC,KAAnB,CAA0B,SAAEC,CAAF,CAAS,CAClC,GAAMC,CAAAA,OAAO,CAAGC,MAAM,CAACD,OAAP,EAAkB,EAAlC,CACA,GAAME,CAAAA,OAAO,CAAGD,MAAM,CAACC,OAAP,EAAkB,EAAlC,CAGA,GAAK,YAAcF,OAAnB,CAA6B,CA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c,IAA1D,CAAgE,UAAhE,CAA4E,IAA5E,CACA,CACD,CAtED,CAwEA,CA/JD,EA+JIc,OA/JJ,CA+Ja,QA/Jb,EAkKAxC,CAAC,CAAE,eAAF,CAAD,CAAqBM,EAArB,CAAyB,QAAzB,CAAmC,UAAM,CACxCyE,aAAa,EACb,CAFD,EAKA/E,CAAC,CAAE,2BAAF,CAAD,CAAiCM,EAAjC,CAAqC,2FAArC,CAAkI,UAAM,CACvIyE,aAAa,EACb,CAFD,CAGA,CACD,CAjeD","sourcesContent":["/* global wc_square_admin_products */\n\n/**\n * WooCommerce Square admin general scripts for the settings page and update tab.\n *\n * @since 2.0.0\n */\njQuery( document ).ready( ( $ ) => {\n\tconst typenow = window.typenow || '';\n\tconst pagenow = window.pagenow || '';\n\n\t// bail if not on product admin pages.\n\tif ( 'product' !== typenow ) {\n\t\treturn;\n\t}\n\n\t// bail if product sync is disabled.\n\tif ( ! wc_square_admin_products.is_product_sync_enabled ) {\n\t\treturn;\n\t}\n\n\t// products quick edit screen.\n\tif ( 'edit-product' === pagenow ) {\n\t\t// when clicking the quick edit button fetch the default Synced with Square checkbox\n\t\t$( '#the-list' ).on( 'click', '.editinline', ( e ) => {\n\t\t\tconst $row = $( e.target ).closest( 'tr' );\n\t\t\tconst postID = $row.find( 'th.check-column input' ).val();\n\t\t\tconst data = {\n\t\t\t\taction: 'wc_square_get_quick_edit_product_details',\n\t\t\t\tsecurity: wc_square_admin_products.get_quick_edit_product_details_nonce,\n\t\t\t\tproduct_id: $row.find( 'th.check-column input' ).val(),\n\t\t\t};\n\n\t\t\t$.post( wc_square_admin_products.ajax_url, data, ( response ) => {\n\t\t\t\tconst $editRow = $( 'tr#edit-' + postID );\n\t\t\t\tconst $squareSynced = $editRow.find( 'select.square-synced' );\n\t\t\t\tconst $errors = $editRow.find( '.wc-square-sync-with-square-errors' );\n\n\t\t\t\tif ( ! response.success && response.data ) {\n\t\t\t\t\t// if the product has multiple attributes we show an inline error message and bail.\n\t\t\t\t\tif ( 'multiple_attributes' === response.data ) {\n\t\t\t\t\t\t$squareSynced.prop( 'checked', false );\n\t\t\t\t\t\t$squareSynced.prop( 'disabled', true );\n\t\t\t\t\t\t$errors.find( '.multiple_attributes' ).show();\n\t\t\t\t\t\treturn;\n\n\t\t\t\t\t\t// if the product has variations without an SKU we show an inline error message and bail.\n\t\t\t\t\t} else if ( 'missing_variation_sku' === response.data ) {\n\t\t\t\t\t\t$squareSynced.prop( 'checked', false );\n\t\t\t\t\t\t$squareSynced.prop( 'disabled', true );\n\t\t\t\t\t\t$errors.find( '.missing_variation_sku' ).show();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst $sku = $editRow.find( 'input[name=_sku]' );\n\t\t\t\tconst $stockStatus = $editRow.find( 'select[name=_stock_status]' );\n\t\t\t\tconst $stockQty = $editRow.find( 'input[name=_stock]' );\n\t\t\t\tconst $manageStockLabel = $editRow.find( '.manage_stock_field .manage_stock' );\n\t\t\t\tconst $manageStockInput = $editRow.find( 'input[name=_manage_stock]' );\n\t\t\t\tconst $manageStockDesc = '<span class=\"description\"><a href=\"' + wc_square_admin_products.settings_url + '\">' + wc_square_admin_products.i18n.synced_with_square + '</a></span>';\n\t\t\t\tconst edit_url = response.data.edit_url;\n\t\t\t\tconst i18n = response.data.i18n;\n\t\t\t\tconst is_variable = response.data.is_variable;\n\n\t\t\t\t$squareSynced.val( response.data.is_synced_with_square );\n\n\t\t\t\t// if the SKU changes, enabled or disable Synced with Square checkbox accordingly\n\t\t\t\t$sku.on( 'change keyup keypress', ( e ) => {\n\t\t\t\t\tif ( '' === $( e.target ).val() && ! is_variable ) {\n\t\t\t\t\t\t$squareSynced.val( 'no' ).trigger( 'change' );\n\t\t\t\t\t\t$squareSynced.prop( 'disabled', true );\n\t\t\t\t\t\t$errors.find( '.missing_sku' ).show();\n\t\t\t\t\t} else {\n\t\t\t\t\t\t$squareSynced.prop( 'disabled', false );\n\t\t\t\t\t\t$squareSynced.trigger( 'change' );\n\t\t\t\t\t\treturn $errors.find( '.missing_sku' ).hide();\n\t\t\t\t\t}\n\t\t\t\t} ).trigger( 'change' );\n\n\t\t\t\t// if Synced with Square is enabled, we might as well disable stock management (without verbose explanations as in the product page).\n\t\t\t\t$squareSynced.on( 'change', ( e ) => {\n\t\t\t\t\tif ( 'no' === $( e.target ).val() ) {\n\t\t\t\t\t\t$manageStockInput.off();\n\t\t\t\t\t\t$manageStockInput.add( $stockQty ).css( {\n\t\t\t\t\t\t\topacity: 1,\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t$manageStockLabel.find( '.description' ).remove();\n\n\t\t\t\t\t\t// Stock input manipulation will differ depending on whether product is variable or simple.\n\t\t\t\t\t\tif ( is_variable ) {\n\t\t\t\t\t\t\tif ( $manageStockInput.is( ':checked' ) ) {\n\t\t\t\t\t\t\t\t$( '.stock_qty_field' ).show();\n\t\t\t\t\t\t\t\t$( '.backorder_field' ).show();\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t$( '.stock_status_field' ).show();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t$stockQty.prop( 'readonly', false );\n\t\t\t\t\t\t\t$stockStatus.prop( 'readonly', false );\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t$manageStockInput.prop( 'checked', true );\n\t\t\t\t\t\t$manageStockInput.on( 'click', () => {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t$manageStockInput.add( $stockQty ).css( {\n\t\t\t\t\t\t\topacity: '0.5',\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t$manageStockLabel.append( $manageStockDesc );\n\n\t\t\t\t\t\tif ( wc_square_admin_products.is_woocommerce_sor && edit_url && i18n ) {\n\t\t\t\t\t\t\t$manageStockLabel.append( '<p class=\"description\"><a href=\"' + edit_url + '\">' + i18n + '</a></p>' );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ( is_variable ) {\n\t\t\t\t\t\t\t$( '.stock_status_field' ).hide();\n\t\t\t\t\t\t\t$( '.stock_qty_field' ).hide();\n\t\t\t\t\t\t\t$( '.backorder_field' ).hide();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t$stockQty.prop( 'readonly', true );\n\t\t\t\t\t\t\t$stockStatus.prop( 'readonly', true );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} ).trigger( 'change' );\n\t\t\t} );\n\t\t} );\n\t}\n\n\t// individual product edit screen.\n\tif ( 'product' === pagenow ) {\n\t\tconst syncCheckboxID = '#_' + wc_square_admin_products.synced_with_square_taxonomy;\n\n\t\t/**\n\t\t * Checks whether the product is variable.\n\t\t *\n\t\t * @since 2.0.0\n\t\t */\n\t\tconst isVariable = () => {\n\t\t\treturn wc_square_admin_products.variable_product_types.includes( $( '#product-type' ).val() );\n\t\t};\n\n\t\t/**\n\t\t * Checks whether the product has a SKU.\n\t\t *\n\t\t * @since 2.0.0\n\t\t */\n\t\tconst hasSKU = () => {\n\t\t\treturn '' !== $( '#_sku' ).val().trim();\n\t\t};\n\n\t\t/**\n\t\t * Checks whether the product variations all have SKUs.\n\t\t *\n\t\t * @since 2.2.3\n\t\t *\n\t\t * @param {Array} skus\n\t\t */\n\t\tconst hasVariableSKUs = ( skus ) => {\n\t\t\tif ( ! skus.length ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst valid = skus.filter( ( sku ) => '' !== $( sku ).val().trim() );\n\n\t\t\treturn valid.length === skus.length;\n\t\t};\n\n\t\t/**\n\t\t * Checks whether the given skus are unique.\n\t\t *\n\t\t * @since 2.2.3\n\t\t *\n\t\t * @param {Array} skus\n\t\t */\n\t\tconst hasUniqueSKUs = ( skus ) => {\n\t\t\tconst skuValues = skus.map( ( sku ) => $( sku ).val() );\n\n\t\t\treturn skuValues.every( ( sku ) => skuValues.indexOf( sku ) === skuValues.lastIndexOf( sku ) );\n\t\t};\n\n\t\t/**\n\t\t * Checks whether the product has more than one variation attribute.\n\t\t *\n\t\t * @since 2.0.0\n\t\t */\n\t\tconst hasMultipleAttributes = () => {\n\t\t\tconst $variation_attributes = $( '.woocommerce_attribute_data input[name^=\"attribute_variation\"]:checked' );\n\n\t\t\treturn isVariable() && $variation_attributes && $variation_attributes.length > 1;\n\t\t};\n\n\t\t/**\n\t\t * Displays the given error and disables the sync checkbox.\n\t\t * Accepted errors are 'missing_sku', 'missing_variation_sku', and 'multiple_attributes'.\n\t\t *\n\t\t * @since 2.2.3\n\t\t *\n\t\t * @param {string} error\n\t\t */\n\t\tconst showError = ( error ) => {\n\t\t\t$( '.wc-square-sync-with-square-error.' + error ).show();\n\t\t\t$( syncCheckboxID ).prop( 'disabled', true );\n\t\t\t$( syncCheckboxID ).prop( 'checked', false );\n\t\t};\n\n\t\t/**\n\t\t * Hides the given error and maybe enables the sync checkbox.\n\t\t * Accepted errors are 'missing_sku', 'missing_variation_sku', and 'multiple_attributes'.\n\t\t *\n\t\t * @since 2.2.3\n\t\t *\n\t\t * @param {string} error\n\t\t * @param {boolean} enable Whether to enable the sync checkbox.\n\t\t */\n\t\tconst hideError = ( error, enable = true ) => {\n\t\t\t$( '.wc-square-sync-with-square-error.' + error ).hide();\n\n\t\t\tif ( enable ) {\n\t\t\t\t$( syncCheckboxID ).prop( 'disabled', false );\n\t\t\t}\n\t\t};\n\n\t\t/**\n\t\t * Handle SKU.\n\t\t *\n\t\t * Disables the Sync with Square checkbox and toggles an inline notice when no SKU is set on a product.\n\t\t *\n\t\t * @since 2.0.\n\t\t *\n\t\t * @param {string} syncCheckboxID\n\t\t */\n\t\tconst handleSKU = ( syncCheckboxID ) => {\n\t\t\tif ( isVariable() ) {\n\t\t\t\t$( '#_sku' ).off( 'change keypress keyup' );\n\t\t\t\thideError( 'missing_sku', ! hasMultipleAttributes() );\n\n\t\t\t\tconst skus = $( 'input[id^=\"variable_sku\"]' );\n\t\t\t\tskus.on( 'change keypress keyup', () => {\n\t\t\t\t\tif ( ! hasVariableSKUs( $.makeArray( skus ) ) || ! hasUniqueSKUs( $.makeArray( skus ) ) ) {\n\t\t\t\t\t\tshowError( 'missing_variation_sku' );\n\t\t\t\t\t} else {\n\t\t\t\t\t\thideError( 'missing_variation_sku', ! hasMultipleAttributes() );\n\t\t\t\t\t}\n\t\t\t\t\t$( syncCheckboxID ).triggerHandler( 'change' );\n\t\t\t\t} ).triggerHandler( 'change' );\n\t\t\t} else {\n\t\t\t\t$( 'input[id^=\"variable_sku\"]' ).off( 'change keypress keyup' );\n\t\t\t\thideError( 'missing_variation_sku', ! hasMultipleAttributes() );\n\n\t\t\t\t$( '#_sku' ).on( 'change keypress keyup', ( e ) => {\n\t\t\t\t\tif ( '' === $( e.target ).val().trim() ) {\n\t\t\t\t\t\tshowError( 'missing_sku' );\n\t\t\t\t\t} else {\n\t\t\t\t\t\thideError( 'missing_sku', ! hasMultipleAttributes() );\n\t\t\t\t\t}\n\t\t\t\t\t$( syncCheckboxID ).trigger( 'change' );\n\t\t\t\t} ).trigger( 'change' );\n\t\t\t}\n\t\t};\n\n\t\t/**\n\t\t * Disables the Sync with Square checkbox and toggles an inline notice when more than one attribute is set on the product.\n\t\t *\n\t\t * @since 2.0.0\n\t\t *\n\t\t * @param {string} syncCheckboxID\n\t\t */\n\t\tconst handleAttributes = ( syncCheckboxID ) => {\n\t\t\t$( '#variable_product_options' ).on( 'reload', () => {\n\t\t\t\tif ( hasMultipleAttributes() ) {\n\t\t\t\t\tshowError( 'multiple_attributes' );\n\t\t\t\t} else {\n\t\t\t\t\thideError( 'multiple_attributes', isVariable() ? hasVariableSKUs : hasSKU() );\n\t\t\t\t}\n\n\t\t\t\t$( syncCheckboxID ).trigger( 'change' );\n\t\t\t} ).trigger( 'reload' );\n\t\t};\n\n\t\t/**\n\t\t * Triggers an update to the sync checkbox, checking for relevant errors.\n\t\t *\n\t\t * @since 2.2.3\n\t\t */\n\t\tconst triggerUpdate = () => {\n\t\t\thandleSKU( syncCheckboxID );\n\t\t\t$( syncCheckboxID ).trigger( 'change' );\n\n\t\t\t// handleSKU misses cases where product is variable with no variations.\n\t\t\tif ( isVariable() && ! $( 'input[id^=\"variable_sku\"]' ).length ) {\n\t\t\t\tshowError( 'missing_variation_sku' );\n\t\t\t}\n\t\t};\n\n\t\t// fire once on page load\n\t\thandleAttributes( syncCheckboxID );\n\n\t\t/**\n\t\t * Handle stock management.\n\t\t *\n\t\t * If product is managed by Square, handle stock fields according to chosen SoR.\n\t\t */\n\t\tconst $stockFields = $( '.stock_fields' );\n\t\tconst $stockInput = $stockFields.find( '#_stock' );\n\t\tconst $stockStatus = $( '.stock_status_field' );\n\t\tconst $manageField = $( '._manage_stock_field' );\n\t\tconst $manageInput = $manageField.find( '#_manage_stock' );\n\t\tconst $manageDesc = $manageField.find( '.description' );\n\t\t// keep note of the original manage stock checkbox description, if we need to restore it later\n\t\tconst manageDescOriginal = $manageDesc.text();\n\t\t// keep track of the original manage stock checkbox status, if we need to restore it later\n\t\tconst manageStockOriginal = $( '#_manage_stock' ).is( ':checked' );\n\n\t\t$( syncCheckboxID ).on( 'change', ( e ) => {\n\t\t\t// only handle stock fields if inventory sync is enabled.\n\t\t\tif ( ! wc_square_admin_products.is_inventory_sync_enabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst variableProduct = wc_square_admin_products.variable_product_types.includes( $( '#product-type' ).val() );\n\n\t\t\tlet useSquare;\n\n\t\t\tif ( $( e.target ).is( ':checked' ) && $( '#_square_item_variation_id' ).length > 0 ) {\n\t\t\t\tuseSquare = true;\n\n\t\t\t\t$manageDesc.html( '<a href=\"' + wc_square_admin_products.settings_url + '\">' + wc_square_admin_products.i18n.synced_with_square + '</a>' );\n\t\t\t\t$manageInput.prop( 'disabled', true ).prop( 'checked', ! variableProduct );\n\t\t\t\t$stockFields.hide();\n\t\t\t\t$stockStatus.hide();\n\t\t\t\t$stockInput.prop( 'readonly', true );\n\n\t\t\t\tif ( ! variableProduct ) {\n\t\t\t\t\t$stockFields.show();\n\t\t\t\t}\n\n\t\t\t\t// WooCommerce SoR - note: for variable products, the stock can be fetched for individual variations.\n\t\t\t\tif ( wc_square_admin_products.is_woocommerce_sor && ! variableProduct ) {\n\t\t\t\t\t// add inline note with a toggle to fetch stock from Square manually via AJAX (sanity check to avoid appending multiple times).\n\t\t\t\t\tif ( $( 'p._stock_field span.description' ).length === 0 ) {\n\t\t\t\t\t\t$stockInput.after(\n\t\t\t\t\t\t\t'<span class=\"description\" style=\"display:block;clear:both;\"><a href=\"#\" id=\"fetch-stock-with-square\">' + wc_square_admin_products.i18n.fetch_stock_with_square + '</a><div class=\"spinner\" style=\"float:none;\"></div></span>'\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\t$( '#fetch-stock-with-square' ).on( 'click', ( e ) => {\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\tconst $spinner = $( 'p._stock_field span.description .spinner' );\n\t\t\t\t\t\tconst data = {\n\t\t\t\t\t\t\taction: 'wc_square_fetch_product_stock_with_square',\n\t\t\t\t\t\t\tsecurity: wc_square_admin_products.fetch_product_stock_with_square_nonce,\n\t\t\t\t\t\t\tproduct_id: $( '#post_ID' ).val(),\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\t$spinner.css( 'visibility', 'visible' );\n\n\t\t\t\t\t\t$.post( wc_square_admin_products.ajax_url, data, ( response ) => {\n\t\t\t\t\t\t\tif ( response && response.success ) {\n\t\t\t\t\t\t\t\tconst quantity = response.data;\n\n\t\t\t\t\t\t\t\t$stockInput.val( quantity );\n\t\t\t\t\t\t\t\t$stockFields.find( 'input[name=_original_stock]' ).val( quantity );\n\t\t\t\t\t\t\t\t$stockInput.prop( 'readonly', false );\n\t\t\t\t\t\t\t\t$( 'p._stock_field span.description' ).remove();\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tif ( response.data ) {\n\t\t\t\t\t\t\t\t\t$( '.inventory-fetch-error' ).remove();\n\t\t\t\t\t\t\t\t\t$spinner.after( '<span class=\"inventory-fetch-error\" style=\"display:inline-block;color:red;\">' + response.data + '</span>' );\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t$spinner.css( 'visibility', 'hidden' );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\n\t\t\t\t// Square SoR.\n\t\t\t\t} else if ( wc_square_admin_products.is_square_sor ) {\n\t\t\t\t\t// add inline note explaining stock is managed by Square (sanity check to avoid appending multiple times)\n\t\t\t\t\tif ( $( 'p._stock_field span.description' ).length === 0 ) {\n\t\t\t\t\t\t$stockInput.after( '<span class=\"description\" style=\"display:block;clear:both;\">' + wc_square_admin_products.i18n.managed_by_square + '</span>' );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tuseSquare = false;\n\n\t\t\t\t// remove any inline note to WooCommerce core stock fields that may have been added when Synced with Square is enabled.\n\t\t\t\t$( 'p._stock_field span.description' ).remove();\n\t\t\t\t$stockInput.prop( 'readonly', false );\n\t\t\t\t$manageDesc.html( manageDescOriginal );\n\t\t\t\t$manageInput.prop( 'disabled', false ).prop( 'checked', manageStockOriginal );\n\n\t\t\t\tif ( manageStockOriginal ) {\n\t\t\t\t\t$stockFields.show();\n\t\t\t\t\t$stockStatus.hide();\n\t\t\t\t} else {\n\t\t\t\t\t$stockStatus.show();\n\t\t\t\t\t$stockFields.hide();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// handle variations data separately (HTML differs from parent UI!).\n\t\t\t$( '.woocommerce_variation' ).each( ( index, e ) => {\n\t\t\t\t// fetch relevant variables for each variation.\n\t\t\t\tconst variationID = $( e ).find( 'h3 > a' ).attr( 'rel' );\n\t\t\t\tconst $variationManageInput = $( e ).find( '.variable_manage_stock' );\n\t\t\t\tconst $variationManageField = $variationManageInput.parent();\n\t\t\t\tconst $variationStockInput = $( e ).find( '.wc_input_stock' );\n\t\t\t\tconst $variationStockField = $variationStockInput.parent();\n\n\t\t\t\t// Square manages variations stock\n\t\t\t\tif ( useSquare ) {\n\t\t\t\t\t// disable stock management inputs\n\t\t\t\t\t$( '#wc_square_variation_manage_stock' ).prop( 'disabled', false );\n\t\t\t\t\t$variationStockInput.prop( 'readonly', true );\n\t\t\t\t\t$variationManageInput\n\t\t\t\t\t\t.prop( 'disabled', true )\n\t\t\t\t\t\t.prop( 'checked', true );\n\n\t\t\t\t\t// add a note that the variation stock is managed by square, but check if it wasn't added already to avoid duplicates.\n\t\t\t\t\tif ( 0 === $variationManageField.find( '.description' ).length ) {\n\t\t\t\t\t\t$variationManageInput.after( '<span class=\"description\">(' + wc_square_admin_products.i18n.managed_by_square + ')</span>' );\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( wc_square_admin_products.is_woocommerce_sor ) {\n\t\t\t\t\t\tconst fetchVariationStockActionID = 'fetch-stock-with-square-' + variationID;\n\n\t\t\t\t\t\t// add inline note with a toggle to fetch stock from Square manually via AJAX (sanity check to avoid appending multiple times)\n\t\t\t\t\t\tif ( 0 === $variationStockField.find( 'span.description' ).length ) {\n\t\t\t\t\t\t\t$variationStockInput.after(\n\t\t\t\t\t\t\t\t'<span class=\"description\" style=\"display:block;clear:both;\"><a href=\"#\" id=\"' + fetchVariationStockActionID + '\">' + wc_square_admin_products.i18n.fetch_stock_with_square + '</a><div class=\"spinner\" style=\"float:none;\"></div></span>'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// listen for requests to update stock with Square for the individual variation.\n\t\t\t\t\t\t$( '#' + fetchVariationStockActionID ).on( 'click', ( e ) => {\n\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\tconst $spinner = $( e.target ).next( '.spinner' );\n\t\t\t\t\t\t\tconst data = {\n\t\t\t\t\t\t\t\taction: 'wc_square_fetch_product_stock_with_square',\n\t\t\t\t\t\t\t\tsecurity: wc_square_admin_products.fetch_product_stock_with_square_nonce,\n\t\t\t\t\t\t\t\tproduct_id: variationID,\n\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\t$spinner.css( 'visibility', 'visible' );\n\n\t\t\t\t\t\t\t$.post( wc_square_admin_products.ajax_url, data, ( response ) => {\n\t\t\t\t\t\t\t\tif ( response && response.success ) {\n\t\t\t\t\t\t\t\t\tconst quantity = response.data;\n\n\t\t\t\t\t\t\t\t\t$variationStockInput.val( quantity );\n\t\t\t\t\t\t\t\t\t$variationStockField.parent().find( 'input[name^=\"variable_original_stock\"]' ).val( quantity );\n\t\t\t\t\t\t\t\t\t$variationStockInput.prop( 'readonly', false );\n\t\t\t\t\t\t\t\t\t$variationStockField.find( '.description' ).remove();\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tif ( response.data ) {\n\t\t\t\t\t\t\t\t\t\t$( '.inventory-fetch-error' ).remove();\n\t\t\t\t\t\t\t\t\t\t$spinner.after( '<span class=\"inventory-fetch-error\" style=\"display:inline-block;color:red;\">' + response.data + '</span>' );\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t$spinner.css( 'visibility', 'hidden' );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// restore WooCommerce stock when user chooses to disable Sync with Square checkbox.\n\t\t\t\t\t$variationStockInput.prop( 'readonly', false );\n\t\t\t\t\t$variationManageInput.prop( 'disabled', false );\n\t\t\t\t\t$variationManageInput.next( '.description' ).remove();\n\t\t\t\t\t$( e.target ).find( '#wc_square_variation_manage_stock' ).prop( 'disabled', true );\n\t\t\t\t}\n\t\t\t} );\n\t\t// initial page load handling.\n\t\t} ).trigger( 'change' );\n\n\t\t// trigger an update if the product type changes.\n\t\t$( '#product-type' ).on( 'change', () => {\n\t\t\ttriggerUpdate();\n\t\t} );\n\n\t\t// trigger an update for variable products when variations are loaded, added, or removed.\n\t\t$( '#woocommerce-product-data' ).on( 'woocommerce_variations_loaded woocommerce_variations_added woocommerce_variations_removed', () => {\n\t\t\ttriggerUpdate();\n\t\t} );\n\t}\n} );\n"],"file":"wc-square-admin-products.min.js"}
 
assets/js/admin/wc-square-admin-settings.js DELETED
@@ -1,327 +0,0 @@
1
- /* global wc_square_admin_settings */
2
-
3
- /**
4
- * WooCommerce Square scripts for admin product pages.
5
- *
6
- * @since 2.0.0
7
- */
8
- jQuery( document ).ready( ( $ ) => {
9
- const pagenow = window.pagenow || '';
10
-
11
- // bail if not on the admin settings page.
12
- if ( 'woocommerce_page_wc-settings' !== pagenow ) {
13
- return;
14
- }
15
-
16
- if ( ! wc_square_admin_settings.is_sandbox ) {
17
- // Hide sandbox settings if is_sandbox is set.
18
- $( '#wc_square_sandbox_settings' ).hide();
19
- $( '#wc_square_sandbox_settings' ).next().hide();
20
- $( '.wc_square_sandbox_settings' ).closest( 'tr' ).hide();
21
- }
22
-
23
- $( '#wc_square_system_of_record' ).on( 'change', ( e ) => {
24
- const system_of_record = $( e.target ).val();
25
- const $inventory_sync = $( '#wc_square_enable_inventory_sync' );
26
- const $inventory_sync_row = $inventory_sync.closest( 'tr' );
27
-
28
- // toggle the "Sync inventory" setting depending on the SOR.
29
- if ( 'square' === system_of_record || 'woocommerce' === system_of_record ) {
30
- $inventory_sync.next( 'span' ).html( wc_square_admin_settings.i18n.sync_inventory_label[ system_of_record ] );
31
- $inventory_sync_row.find( '.description' ).html( wc_square_admin_settings.i18n.sync_inventory_description[ system_of_record ] );
32
- $inventory_sync_row.show();
33
- } else {
34
- $inventory_sync.prop( 'checked', false );
35
- $inventory_sync_row.hide();
36
- }
37
-
38
- // toggle the "Hide missing products" setting depending on the SOR.
39
- if ( 'square' === system_of_record ) {
40
- $( '#wc_square_hide_missing_products' ).closest( 'tr' ).show();
41
- } else {
42
- $( '#wc_square_hide_missing_products' ).closest( 'tr' ).hide();
43
- }
44
- } ).trigger( 'change' );
45
-
46
- $( '.js-import-square-products' ).on( 'click', ( e ) => {
47
- e.preventDefault();
48
-
49
- new $.WCBackboneModal.View( {
50
- target: 'wc-square-import-products',
51
- } );
52
-
53
- $( '#btn-close' ).on( 'click', ( e ) => {
54
- e.preventDefault();
55
-
56
- $( 'button.modal-close' ).trigger( 'click' );
57
- } );
58
- } );
59
-
60
- // initiate a manual sync.
61
- $( '#wc-square-sync' ).on( 'click', ( e ) => {
62
- e.preventDefault();
63
-
64
- // open a modal dialog.
65
- new $.WCBackboneModal.View( {
66
- target: 'wc-square-sync',
67
- } );
68
-
69
- // enable cancel sync button.
70
- $( '#btn-close' ).on( 'click', ( e ) => {
71
- e.preventDefault();
72
-
73
- $( 'button.modal-close' ).trigger( 'click' );
74
- } );
75
- } );
76
-
77
- // Listen for wc_backbone_modal_response event handler.
78
- $( document.body ).on( 'wc_backbone_modal_response', ( e, target ) => {
79
- let data;
80
-
81
- switch ( target ) {
82
- case 'wc-square-import-products':
83
- // Add Block overlay since the modal exits immediately
84
- // after wc_backbone_modal_response is triggered.
85
- $( '#wpbody' ).block( {
86
- message: null,
87
- overlayCSS: {
88
- opacity: '0.2',
89
- },
90
- onBlock: function onBlock() {
91
- $( '.blockUI.blockOverlay' ).css(
92
- {
93
- position: 'fixed',
94
- }
95
- );
96
- },
97
- } );
98
-
99
- const update_during_import = $( '#wc-square-import-product-updates' ).prop( 'checked' );
100
- data = {
101
- action: 'wc_square_import_products_from_square',
102
- dispatch: wc_square_admin_settings.sync_in_background,
103
- security: wc_square_admin_settings.import_products_from_square,
104
- update_during_import,
105
- };
106
-
107
- $.post( wc_square_admin_settings.ajax_url, data, ( response ) => {
108
- const message = response.data ? response.data : null;
109
-
110
- if ( message ) {
111
- alert( message );
112
- }
113
-
114
- location.reload();
115
- } );
116
- break;
117
-
118
- case 'wc-square-sync':
119
- $( 'table.sync' ).block( {
120
- message: null,
121
- overlayCSS: {
122
- opacity: '0.2',
123
- },
124
- } );
125
-
126
- $( 'table.records' ).block( {
127
- message: null,
128
- overlayCSS: {
129
- opacity: '0.2',
130
- },
131
- } );
132
-
133
- $( '#wc-square_clear-sync-records' ).prop( 'disabled', true );
134
-
135
- data = {
136
- action: 'wc_square_sync_products_with_square',
137
- dispatch: wc_square_admin_settings.sync_in_background,
138
- security: wc_square_admin_settings.sync_products_with_square,
139
- };
140
-
141
- $.post( wc_square_admin_settings.ajax_url, data, ( response ) => {
142
- if ( response && response.success ) {
143
- location.reload();
144
- } else {
145
- $( '#wc-square_clear-sync-records' ).prop( 'disabled', false );
146
- $( 'table.sync' ).unblock();
147
- $( 'table.records' ).unblock();
148
- }
149
- } );
150
- break;
151
- }
152
- } );
153
-
154
- // Clear sync records history.
155
- const noRecordsFoundRow = '<tr><td colspan="4"><em>' + wc_square_admin_settings.i18n.no_records_found + '</em></td></tr>';
156
- $( '#wc-square_clear-sync-records' ).on( 'click', ( e ) => {
157
- e.preventDefault();
158
-
159
- $( 'table.records' ).block( {
160
- message: null,
161
- overlayCSS: {
162
- opacity: '0.2',
163
- },
164
- } );
165
-
166
- const data = {
167
- action: 'wc_square_handle_sync_records',
168
- id: 'all',
169
- handle: 'delete',
170
- security: wc_square_admin_settings.handle_sync_with_square_records,
171
- };
172
-
173
- $.post( wc_square_admin_settings.ajax_url, data, ( response ) => {
174
- if ( response && response.success ) {
175
- $( 'table.records tbody' ).html( noRecordsFoundRow );
176
- $( '#wc-square_clear-sync-records' ).prop( 'disabled', true );
177
- } else {
178
- if ( response.data ) {
179
- alert( response.data );
180
- }
181
- console.log( response );
182
- }
183
- $( 'table.records' ).unblock();
184
- } );
185
- } );
186
-
187
- // Individual sync records actions.
188
- $( '.records .actions button.action' ).on( 'click', ( e ) => {
189
- e.preventDefault();
190
-
191
- $( 'table.records' ).block( {
192
- message: null,
193
- overlayCSS: {
194
- opacity: '0.2',
195
- },
196
- } );
197
- const recordId = $( e.currentTarget ).data( 'id' );
198
- const action = $( e.currentTarget ).data( 'action' );
199
- const data = {
200
- action: 'wc_square_handle_sync_records',
201
- id: recordId,
202
- handle: action,
203
- security: wc_square_admin_settings.handle_sync_with_square_records,
204
- };
205
-
206
- $.post( wc_square_admin_settings.ajax_url, data, ( response ) => {
207
- if ( response && response.success ) {
208
- const rowId = '#record-' + recordId;
209
-
210
- if ( 'delete' === action ) {
211
- $( rowId ).remove();
212
-
213
- if ( ! $( 'table.records tbody tr' ).length ) {
214
- $( 'table.records tbody' ).html( noRecordsFoundRow );
215
- $( '#wc-square_clear-sync-records' ).prop( 'disabled', true );
216
- }
217
- } else if ( 'resolve' === action || 'unsync' === action ) {
218
- $( rowId + ' .type' ).html( '<mark class="resolved"><span>' + wc_square_admin_settings.i18n.resolved + '</span></mark>' );
219
- $( rowId + ' .actions' ).html( '&mdash;' );
220
- }
221
- } else {
222
- if ( response && response.data ) {
223
- alert( response.data );
224
- }
225
-
226
- console.log( {
227
- record: recordId,
228
- action,
229
- response,
230
- } );
231
- }
232
- $( 'table.records' ).unblock();
233
- } );
234
- } );
235
-
236
- // Add explicit square environment to post data to deal with swapping between production and sandbox in the back end.
237
- $( 'form' ).on( 'submit', ( e ) => {
238
- const environment = $( '#wc_square_enable_sandbox' ).is( ':checked' ) ? 'sandbox' : 'production';
239
-
240
- $( e.target ).append(
241
- $( '<input>',
242
- {
243
- type: 'hidden',
244
- name: 'wc_square_environment',
245
- value: environment,
246
- }
247
- )
248
- );
249
- } );
250
-
251
- /**
252
- * Returns a job sync status.
253
- *
254
- * @since 2.0.0
255
- *
256
- * @param {string} job_id
257
- */
258
- const getSyncStatus = ( job_id ) => {
259
- let $progress = $( 'span.progress' );
260
-
261
- if ( ! $progress || 0 === $progress.length ) {
262
- $( 'p.sync-result' ).append( ' <span class="progress" style="display:block"></span>' );
263
- $progress = $( 'span.progress' );
264
- }
265
-
266
- const data = {
267
- action: 'wc_square_get_sync_with_square_status',
268
- security: wc_square_admin_settings.get_sync_with_square_status_nonce,
269
- job_id,
270
- };
271
-
272
- $.post( wc_square_admin_settings.ajax_url, data, ( response ) => {
273
- if ( response && response.data ) {
274
- if ( response.success && response.data.id ) {
275
- // start the progress spinner.
276
- $( 'table.sync .spinner' ).css( 'visibility', 'visible' );
277
- // disable interacting with records as more could be added during a sync process.
278
- $( '#wc-square_clear-sync-records' ).prop( 'disabled', true );
279
- $( 'table.records .actions button' ).prop( 'disabled', true );
280
- // continue if the job is in progression.
281
- if ( 'completed' !== response.data.status && 'failed' !== response.data.status ) {
282
- let progress = ' ';
283
- // update progress info in table cell.
284
- if ( 'product_import' === response.data.action ) {
285
- progress += wc_square_admin_settings.i18n.skipped + ': ' + parseInt( response.data.skipped_products_count, 10 ) + '<br/>';
286
- progress += wc_square_admin_settings.i18n.updated + ': ' + parseInt( response.data.updated_products_count, 10 ) + '<br/>';
287
- progress += wc_square_admin_settings.i18n.imported + ': ' + parseInt( response.data.imported_products_count, 10 );
288
- } else if ( response.data.percentage ) {
289
- progress += parseInt( response.data.percentage, 10 ) + '%';
290
- }
291
-
292
- $progress.html( progress );
293
-
294
- // recursion update loop until we're 'completed' (add a long timeout to avoid missing callback return output).
295
- setTimeout( () => {
296
- getSyncStatus( response.data.id );
297
- }, 30 * 1000 );
298
- } else {
299
- // reload page, display updated sync dates and any sync records messages.
300
- location.reload(); // unlikely job processing exception.
301
- }
302
- } else {
303
- $( '#wc-square_clear-sync-records' ).prop( 'disabled', false );
304
- $( 'table.records .actions button' ).prop( 'disabled', false );
305
- $( 'table.sync .spinner' ).css( 'visibility', 'hidden' );
306
- console.log( response );
307
- }
308
- }
309
- } );
310
- };
311
-
312
- // run once on page load.
313
- if ( wc_square_admin_settings.existing_sync_job_id ) {
314
- getSyncStatus( wc_square_admin_settings.existing_sync_job_id );
315
- }
316
-
317
- // Show/hide Digital Wallet Settings on Square gateway settings page.
318
- $( '#woocommerce_square_credit_card_enable_digital_wallets' ).on( 'change', () => {
319
- const wallet_settings = $( '.wc-square-digital-wallet-options' );
320
-
321
- if ( $( '#woocommerce_square_credit_card_enable_digital_wallets' ).is( ':checked' ) ) {
322
- wallet_settings.closest( 'tr' ).show();
323
- } else {
324
- wallet_settings.closest( 'tr' ).hide();
325
- }
326
- } ).trigger( 'change' );
327
- } );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/js/admin/wc-square-admin-settings.min.js CHANGED
@@ -1,2 +1 @@
1
  "use strict";jQuery(document).ready(function($){var pagenow=window.pagenow||"";if("woocommerce_page_wc-settings"!==pagenow){return}if(!wc_square_admin_settings.is_sandbox){$("#wc_square_sandbox_settings").hide();$("#wc_square_sandbox_settings").next().hide();$(".wc_square_sandbox_settings").closest("tr").hide()}$("#wc_square_system_of_record").on("change",function(e){var system_of_record=$(e.target).val();var $inventory_sync=$("#wc_square_enable_inventory_sync");var $inventory_sync_row=$inventory_sync.closest("tr");if("square"===system_of_record||"woocommerce"===system_of_record){$inventory_sync.next("span").html(wc_square_admin_settings.i18n.sync_inventory_label[system_of_record]);$inventory_sync_row.find(".description").html(wc_square_admin_settings.i18n.sync_inventory_description[system_of_record]);$inventory_sync_row.show()}else{$inventory_sync.prop("checked",false);$inventory_sync_row.hide()}if("square"===system_of_record){$("#wc_square_hide_missing_products").closest("tr").show()}else{$("#wc_square_hide_missing_products").closest("tr").hide()}}).trigger("change");$(".js-import-square-products").on("click",function(e){e.preventDefault();new $.WCBackboneModal.View({target:"wc-square-import-products"});$("#btn-close").on("click",function(e){e.preventDefault();$("button.modal-close").trigger("click")})});$("#wc-square-sync").on("click",function(e){e.preventDefault();new $.WCBackboneModal.View({target:"wc-square-sync"});$("#btn-close").on("click",function(e){e.preventDefault();$("button.modal-close").trigger("click")})});$(document.body).on("wc_backbone_modal_response",function(e,target){var data;switch(target){case"wc-square-import-products":$("#wpbody").block({message:null,overlayCSS:{opacity:"0.2"},onBlock:function onBlock(){$(".blockUI.blockOverlay").css({position:"fixed"})}});var update_during_import=$("#wc-square-import-product-updates").prop("checked");data={action:"wc_square_import_products_from_square",dispatch:wc_square_admin_settings.sync_in_background,security:wc_square_admin_settings.import_products_from_square,update_during_import:update_during_import};$.post(wc_square_admin_settings.ajax_url,data,function(response){var message=response.data?response.data:null;if(message){alert(message)}location.reload()});break;case"wc-square-sync":$("table.sync").block({message:null,overlayCSS:{opacity:"0.2"}});$("table.records").block({message:null,overlayCSS:{opacity:"0.2"}});$("#wc-square_clear-sync-records").prop("disabled",true);data={action:"wc_square_sync_products_with_square",dispatch:wc_square_admin_settings.sync_in_background,security:wc_square_admin_settings.sync_products_with_square};$.post(wc_square_admin_settings.ajax_url,data,function(response){if(response&&response.success){location.reload()}else{$("#wc-square_clear-sync-records").prop("disabled",false);$("table.sync").unblock();$("table.records").unblock()}});break;}});var noRecordsFoundRow="<tr><td colspan=\"4\"><em>"+wc_square_admin_settings.i18n.no_records_found+"</em></td></tr>";$("#wc-square_clear-sync-records").on("click",function(e){e.preventDefault();$("table.records").block({message:null,overlayCSS:{opacity:"0.2"}});var data={action:"wc_square_handle_sync_records",id:"all",handle:"delete",security:wc_square_admin_settings.handle_sync_with_square_records};$.post(wc_square_admin_settings.ajax_url,data,function(response){if(response&&response.success){$("table.records tbody").html(noRecordsFoundRow);$("#wc-square_clear-sync-records").prop("disabled",true)}else{if(response.data){alert(response.data)}console.log(response)}$("table.records").unblock()})});$(".records .actions button.action").on("click",function(e){e.preventDefault();$("table.records").block({message:null,overlayCSS:{opacity:"0.2"}});var recordId=$(e.currentTarget).data("id");var action=$(e.currentTarget).data("action");var data={action:"wc_square_handle_sync_records",id:recordId,handle:action,security:wc_square_admin_settings.handle_sync_with_square_records};$.post(wc_square_admin_settings.ajax_url,data,function(response){if(response&&response.success){var rowId="#record-"+recordId;if("delete"===action){$(rowId).remove();if(!$("table.records tbody tr").length){$("table.records tbody").html(noRecordsFoundRow);$("#wc-square_clear-sync-records").prop("disabled",true)}}else if("resolve"===action||"unsync"===action){$(rowId+" .type").html("<mark class=\"resolved\"><span>"+wc_square_admin_settings.i18n.resolved+"</span></mark>");$(rowId+" .actions").html("&mdash;")}}else{if(response&&response.data){alert(response.data)}console.log({record:recordId,action:action,response:response})}$("table.records").unblock()})});$("form").on("submit",function(e){var environment=$("#wc_square_enable_sandbox").is(":checked")?"sandbox":"production";$(e.target).append($("<input>",{type:"hidden",name:"wc_square_environment",value:environment}))});var getSyncStatus=function getSyncStatus(job_id){var $progress=$("span.progress");if(!$progress||0===$progress.length){$("p.sync-result").append(" <span class=\"progress\" style=\"display:block\"></span>");$progress=$("span.progress")}var data={action:"wc_square_get_sync_with_square_status",security:wc_square_admin_settings.get_sync_with_square_status_nonce,job_id:job_id};$.post(wc_square_admin_settings.ajax_url,data,function(response){if(response&&response.data){if(response.success&&response.data.id){$("table.sync .spinner").css("visibility","visible");$("#wc-square_clear-sync-records").prop("disabled",true);$("table.records .actions button").prop("disabled",true);if("completed"!==response.data.status&&"failed"!==response.data.status){var progress=" ";if("product_import"===response.data.action){progress+=wc_square_admin_settings.i18n.skipped+": "+parseInt(response.data.skipped_products_count,10)+"<br/>";progress+=wc_square_admin_settings.i18n.updated+": "+parseInt(response.data.updated_products_count,10)+"<br/>";progress+=wc_square_admin_settings.i18n.imported+": "+parseInt(response.data.imported_products_count,10)}else if(response.data.percentage){progress+=parseInt(response.data.percentage,10)+"%"}$progress.html(progress);setTimeout(function(){getSyncStatus(response.data.id)},30*1000)}else{location.reload()}}else{$("#wc-square_clear-sync-records").prop("disabled",false);$("table.records .actions button").prop("disabled",false);$("table.sync .spinner").css("visibility","hidden");console.log(response)}}})};if(wc_square_admin_settings.existing_sync_job_id){getSyncStatus(wc_square_admin_settings.existing_sync_job_id)}$("#woocommerce_square_credit_card_enable_digital_wallets").on("change",function(){var wallet_settings=$(".wc-square-digital-wallet-options");if($("#woocommerce_square_credit_card_enable_digital_wallets").is(":checked")){wallet_settings.closest("tr").show()}else{wallet_settings.closest("tr").hide()}}).trigger("change")});
2
- //# sourceMappingURL=wc-square-admin-settings.min.js.map
1
  "use strict";jQuery(document).ready(function($){var pagenow=window.pagenow||"";if("woocommerce_page_wc-settings"!==pagenow){return}if(!wc_square_admin_settings.is_sandbox){$("#wc_square_sandbox_settings").hide();$("#wc_square_sandbox_settings").next().hide();$(".wc_square_sandbox_settings").closest("tr").hide()}$("#wc_square_system_of_record").on("change",function(e){var system_of_record=$(e.target).val();var $inventory_sync=$("#wc_square_enable_inventory_sync");var $inventory_sync_row=$inventory_sync.closest("tr");if("square"===system_of_record||"woocommerce"===system_of_record){$inventory_sync.next("span").html(wc_square_admin_settings.i18n.sync_inventory_label[system_of_record]);$inventory_sync_row.find(".description").html(wc_square_admin_settings.i18n.sync_inventory_description[system_of_record]);$inventory_sync_row.show()}else{$inventory_sync.prop("checked",false);$inventory_sync_row.hide()}if("square"===system_of_record){$("#wc_square_hide_missing_products").closest("tr").show()}else{$("#wc_square_hide_missing_products").closest("tr").hide()}}).trigger("change");$(".js-import-square-products").on("click",function(e){e.preventDefault();new $.WCBackboneModal.View({target:"wc-square-import-products"});$("#btn-close").on("click",function(e){e.preventDefault();$("button.modal-close").trigger("click")})});$("#wc-square-sync").on("click",function(e){e.preventDefault();new $.WCBackboneModal.View({target:"wc-square-sync"});$("#btn-close").on("click",function(e){e.preventDefault();$("button.modal-close").trigger("click")})});$(document.body).on("wc_backbone_modal_response",function(e,target){var data;switch(target){case"wc-square-import-products":$("#wpbody").block({message:null,overlayCSS:{opacity:"0.2"},onBlock:function onBlock(){$(".blockUI.blockOverlay").css({position:"fixed"})}});var update_during_import=$("#wc-square-import-product-updates").prop("checked");data={action:"wc_square_import_products_from_square",dispatch:wc_square_admin_settings.sync_in_background,security:wc_square_admin_settings.import_products_from_square,update_during_import:update_during_import};$.post(wc_square_admin_settings.ajax_url,data,function(response){var message=response.data?response.data:null;if(message){alert(message)}location.reload()});break;case"wc-square-sync":$("table.sync").block({message:null,overlayCSS:{opacity:"0.2"}});$("table.records").block({message:null,overlayCSS:{opacity:"0.2"}});$("#wc-square_clear-sync-records").prop("disabled",true);data={action:"wc_square_sync_products_with_square",dispatch:wc_square_admin_settings.sync_in_background,security:wc_square_admin_settings.sync_products_with_square};$.post(wc_square_admin_settings.ajax_url,data,function(response){if(response&&response.success){location.reload()}else{$("#wc-square_clear-sync-records").prop("disabled",false);$("table.sync").unblock();$("table.records").unblock()}});break;}});var noRecordsFoundRow="<tr><td colspan=\"4\"><em>"+wc_square_admin_settings.i18n.no_records_found+"</em></td></tr>";$("#wc-square_clear-sync-records").on("click",function(e){e.preventDefault();$("table.records").block({message:null,overlayCSS:{opacity:"0.2"}});var data={action:"wc_square_handle_sync_records",id:"all",handle:"delete",security:wc_square_admin_settings.handle_sync_with_square_records};$.post(wc_square_admin_settings.ajax_url,data,function(response){if(response&&response.success){$("table.records tbody").html(noRecordsFoundRow);$("#wc-square_clear-sync-records").prop("disabled",true)}else{if(response.data){alert(response.data)}console.log(response)}$("table.records").unblock()})});$(".records .actions button.action").on("click",function(e){e.preventDefault();$("table.records").block({message:null,overlayCSS:{opacity:"0.2"}});var recordId=$(e.currentTarget).data("id");var action=$(e.currentTarget).data("action");var data={action:"wc_square_handle_sync_records",id:recordId,handle:action,security:wc_square_admin_settings.handle_sync_with_square_records};$.post(wc_square_admin_settings.ajax_url,data,function(response){if(response&&response.success){var rowId="#record-"+recordId;if("delete"===action){$(rowId).remove();if(!$("table.records tbody tr").length){$("table.records tbody").html(noRecordsFoundRow);$("#wc-square_clear-sync-records").prop("disabled",true)}}else if("resolve"===action||"unsync"===action){$(rowId+" .type").html("<mark class=\"resolved\"><span>"+wc_square_admin_settings.i18n.resolved+"</span></mark>");$(rowId+" .actions").html("&mdash;")}}else{if(response&&response.data){alert(response.data)}console.log({record:recordId,action:action,response:response})}$("table.records").unblock()})});$("form").on("submit",function(e){var environment=$("#wc_square_enable_sandbox").is(":checked")?"sandbox":"production";$(e.target).append($("<input>",{type:"hidden",name:"wc_square_environment",value:environment}))});var getSyncStatus=function getSyncStatus(job_id){var $progress=$("span.progress");if(!$progress||0===$progress.length){$("p.sync-result").append(" <span class=\"progress\" style=\"display:block\"></span>");$progress=$("span.progress")}var data={action:"wc_square_get_sync_with_square_status",security:wc_square_admin_settings.get_sync_with_square_status_nonce,job_id:job_id};$.post(wc_square_admin_settings.ajax_url,data,function(response){if(response&&response.data){if(response.success&&response.data.id){$("table.sync .spinner").css("visibility","visible");$("#wc-square_clear-sync-records").prop("disabled",true);$("table.records .actions button").prop("disabled",true);if("completed"!==response.data.status&&"failed"!==response.data.status){var progress=" ";if("product_import"===response.data.action){progress+=wc_square_admin_settings.i18n.skipped+": "+parseInt(response.data.skipped_products_count,10)+"<br/>";progress+=wc_square_admin_settings.i18n.updated+": "+parseInt(response.data.updated_products_count,10)+"<br/>";progress+=wc_square_admin_settings.i18n.imported+": "+parseInt(response.data.imported_products_count,10)}else if(response.data.percentage){progress+=parseInt(response.data.percentage,10)+"%"}$progress.html(progress);setTimeout(function(){getSyncStatus(response.data.id)},30*1000)}else{location.reload()}}else{$("#wc-square_clear-sync-records").prop("disabled",false);$("table.records .actions button").prop("disabled",false);$("table.sync .spinner").css("visibility","hidden");console.log(response)}}})};if(wc_square_admin_settings.existing_sync_job_id){getSyncStatus(wc_square_admin_settings.existing_sync_job_id)}$("#woocommerce_square_credit_card_enable_digital_wallets").on("change",function(){var wallet_settings=$(".wc-square-digital-wallet-options");if($("#woocommerce_square_credit_card_enable_digital_wallets").is(":checked")){wallet_settings.closest("tr").show()}else{wallet_settings.closest("tr").hide()}}).trigger("change")});
 
assets/js/admin/wc-square-admin-settings.min.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["wc-square-admin-settings.js"],"names":["jQuery","document","ready","$","pagenow","window","wc_square_admin_settings","is_sandbox","hide","next","closest","on","e","system_of_record","target","val","$inventory_sync","$inventory_sync_row","html","i18n","sync_inventory_label","find","sync_inventory_description","show","prop","trigger","preventDefault","WCBackboneModal","View","body","data","block","message","overlayCSS","opacity","onBlock","css","position","update_during_import","action","dispatch","sync_in_background","security","import_products_from_square","post","ajax_url","response","alert","location","reload","sync_products_with_square","success","unblock","noRecordsFoundRow","no_records_found","id","handle","handle_sync_with_square_records","console","log","recordId","currentTarget","rowId","remove","length","resolved","record","environment","is","append","type","name","value","getSyncStatus","job_id","$progress","get_sync_with_square_status_nonce","status","progress","skipped","parseInt","skipped_products_count","updated","updated_products_count","imported","imported_products_count","percentage","setTimeout","existing_sync_job_id","wallet_settings"],"mappings":"aAOAA,MAAM,CAAEC,QAAF,CAAN,CAAmBC,KAAnB,CAA0B,SAAEC,CAAF,CAAS,CAClC,GAAMC,CAAAA,OAAO,CAAGC,MAAM,CAACD,OAAP,EAAkB,EAAlC,CAGA,GAAK,iCAAmCA,OAAxC,CAAkD,CACjD,MACA,CAED,GAAK,CAAEE,wBAAwB,CAACC,UAAhC,CAA6C,CAE5CJ,CAAC,CAAE,6BAAF,CAAD,CAAmCK,IAAnC,GACAL,CAAC,CAAE,6BAAF,CAAD,CAAmCM,IAAnC,GAA0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,OAAhB,CAAyB,IAAzB,EAAgCF,IAAhC,EACA,CACD,CARD,EAQIiB,OARJ,CAQa,QARb,CASA,CA/TD","sourcesContent":["/* global wc_square_admin_settings */\n\n/**\n * WooCommerce Square scripts for admin product pages.\n *\n * @since 2.0.0\n */\njQuery( document ).ready( ( $ ) => {\n\tconst pagenow = window.pagenow || '';\n\n\t// bail if not on the admin settings page.\n\tif ( 'woocommerce_page_wc-settings' !== pagenow ) {\n\t\treturn;\n\t}\n\n\tif ( ! wc_square_admin_settings.is_sandbox ) {\n\t\t// Hide sandbox settings if is_sandbox is set.\n\t\t$( '#wc_square_sandbox_settings' ).hide();\n\t\t$( '#wc_square_sandbox_settings' ).next().hide();\n\t\t$( '.wc_square_sandbox_settings' ).closest( 'tr' ).hide();\n\t}\n\n\t$( '#wc_square_system_of_record' ).on( 'change', ( e ) => {\n\t\tconst system_of_record = $( e.target ).val();\n\t\tconst $inventory_sync = $( '#wc_square_enable_inventory_sync' );\n\t\tconst $inventory_sync_row = $inventory_sync.closest( 'tr' );\n\n\t\t// toggle the \"Sync inventory\" setting depending on the SOR.\n\t\tif ( 'square' === system_of_record || 'woocommerce' === system_of_record ) {\n\t\t\t$inventory_sync.next( 'span' ).html( wc_square_admin_settings.i18n.sync_inventory_label[ system_of_record ] );\n\t\t\t$inventory_sync_row.find( '.description' ).html( wc_square_admin_settings.i18n.sync_inventory_description[ system_of_record ] );\n\t\t\t$inventory_sync_row.show();\n\t\t} else {\n\t\t\t$inventory_sync.prop( 'checked', false );\n\t\t\t$inventory_sync_row.hide();\n\t\t}\n\n\t\t// toggle the \"Hide missing products\" setting depending on the SOR.\n\t\tif ( 'square' === system_of_record ) {\n\t\t\t$( '#wc_square_hide_missing_products' ).closest( 'tr' ).show();\n\t\t} else {\n\t\t\t$( '#wc_square_hide_missing_products' ).closest( 'tr' ).hide();\n\t\t}\n\t} ).trigger( 'change' );\n\n\t$( '.js-import-square-products' ).on( 'click', ( e ) => {\n\t\te.preventDefault();\n\n\t\tnew $.WCBackboneModal.View( {\n\t\t\ttarget: 'wc-square-import-products',\n\t\t} );\n\n\t\t$( '#btn-close' ).on( 'click', ( e ) => {\n\t\t\te.preventDefault();\n\n\t\t\t$( 'button.modal-close' ).trigger( 'click' );\n\t\t} );\n\t} );\n\n\t// initiate a manual sync.\n\t$( '#wc-square-sync' ).on( 'click', ( e ) => {\n\t\te.preventDefault();\n\n\t\t// open a modal dialog.\n\t\tnew $.WCBackboneModal.View( {\n\t\t\ttarget: 'wc-square-sync',\n\t\t} );\n\n\t\t// enable cancel sync button.\n\t\t$( '#btn-close' ).on( 'click', ( e ) => {\n\t\t\te.preventDefault();\n\n\t\t\t$( 'button.modal-close' ).trigger( 'click' );\n\t\t} );\n\t} );\n\n\t// Listen for wc_backbone_modal_response event handler.\n\t$( document.body ).on( 'wc_backbone_modal_response', ( e, target ) => {\n\t\tlet data;\n\n\t\tswitch ( target ) {\n\t\t\tcase 'wc-square-import-products':\n\t\t\t\t// Add Block overlay since the modal exits immediately\n\t\t\t\t// after wc_backbone_modal_response is triggered.\n\t\t\t\t$( '#wpbody' ).block( {\n\t\t\t\t\tmessage: null,\n\t\t\t\t\toverlayCSS: {\n\t\t\t\t\t\topacity: '0.2',\n\t\t\t\t\t},\n\t\t\t\t\tonBlock: function onBlock() {\n\t\t\t\t\t\t$( '.blockUI.blockOverlay' ).css(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tposition: 'fixed',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t},\n\t\t\t\t} );\n\n\t\t\t\tconst update_during_import = $( '#wc-square-import-product-updates' ).prop( 'checked' );\n\t\t\t\tdata = {\n\t\t\t\t\taction: 'wc_square_import_products_from_square',\n\t\t\t\t\tdispatch: wc_square_admin_settings.sync_in_background,\n\t\t\t\t\tsecurity: wc_square_admin_settings.import_products_from_square,\n\t\t\t\t\tupdate_during_import,\n\t\t\t\t};\n\n\t\t\t\t$.post( wc_square_admin_settings.ajax_url, data, ( response ) => {\n\t\t\t\t\tconst message = response.data ? response.data : null;\n\n\t\t\t\t\tif ( message ) {\n\t\t\t\t\t\talert( message );\n\t\t\t\t\t}\n\n\t\t\t\t\tlocation.reload();\n\t\t\t\t} );\n\t\t\t\tbreak;\n\n\t\t\tcase 'wc-square-sync':\n\t\t\t\t$( 'table.sync' ).block( {\n\t\t\t\t\tmessage: null,\n\t\t\t\t\toverlayCSS: {\n\t\t\t\t\t\topacity: '0.2',\n\t\t\t\t\t},\n\t\t\t\t} );\n\n\t\t\t\t$( 'table.records' ).block( {\n\t\t\t\t\tmessage: null,\n\t\t\t\t\toverlayCSS: {\n\t\t\t\t\t\topacity: '0.2',\n\t\t\t\t\t},\n\t\t\t\t} );\n\n\t\t\t\t$( '#wc-square_clear-sync-records' ).prop( 'disabled', true );\n\n\t\t\t\tdata = {\n\t\t\t\t\taction: 'wc_square_sync_products_with_square',\n\t\t\t\t\tdispatch: wc_square_admin_settings.sync_in_background,\n\t\t\t\t\tsecurity: wc_square_admin_settings.sync_products_with_square,\n\t\t\t\t};\n\n\t\t\t\t$.post( wc_square_admin_settings.ajax_url, data, ( response ) => {\n\t\t\t\t\tif ( response && response.success ) {\n\t\t\t\t\t\tlocation.reload();\n\t\t\t\t\t} else {\n\t\t\t\t\t\t$( '#wc-square_clear-sync-records' ).prop( 'disabled', false );\n\t\t\t\t\t\t$( 'table.sync' ).unblock();\n\t\t\t\t\t\t$( 'table.records' ).unblock();\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t\tbreak;\n\t\t}\n\t} );\n\n\t// Clear sync records history.\n\tconst noRecordsFoundRow = '<tr><td colspan=\"4\"><em>' + wc_square_admin_settings.i18n.no_records_found + '</em></td></tr>';\n\t$( '#wc-square_clear-sync-records' ).on( 'click', ( e ) => {\n\t\te.preventDefault();\n\n\t\t$( 'table.records' ).block( {\n\t\t\tmessage: null,\n\t\t\toverlayCSS: {\n\t\t\t\topacity: '0.2',\n\t\t\t},\n\t\t} );\n\n\t\tconst data = {\n\t\t\taction: 'wc_square_handle_sync_records',\n\t\t\tid: 'all',\n\t\t\thandle: 'delete',\n\t\t\tsecurity: wc_square_admin_settings.handle_sync_with_square_records,\n\t\t};\n\n\t\t$.post( wc_square_admin_settings.ajax_url, data, ( response ) => {\n\t\t\tif ( response && response.success ) {\n\t\t\t\t$( 'table.records tbody' ).html( noRecordsFoundRow );\n\t\t\t\t$( '#wc-square_clear-sync-records' ).prop( 'disabled', true );\n\t\t\t} else {\n\t\t\t\tif ( response.data ) {\n\t\t\t\t\talert( response.data );\n\t\t\t\t}\n\t\t\t\tconsole.log( response );\n\t\t\t}\n\t\t\t$( 'table.records' ).unblock();\n\t\t} );\n\t} );\n\n\t// Individual sync records actions.\n\t$( '.records .actions button.action' ).on( 'click', ( e ) => {\n\t\te.preventDefault();\n\n\t\t$( 'table.records' ).block( {\n\t\t\tmessage: null,\n\t\t\toverlayCSS: {\n\t\t\t\topacity: '0.2',\n\t\t\t},\n\t\t} );\n\t\tconst recordId = $( e.currentTarget ).data( 'id' );\n\t\tconst action = $( e.currentTarget ).data( 'action' );\n\t\tconst data = {\n\t\t\taction: 'wc_square_handle_sync_records',\n\t\t\tid: recordId,\n\t\t\thandle: action,\n\t\t\tsecurity: wc_square_admin_settings.handle_sync_with_square_records,\n\t\t};\n\n\t\t$.post( wc_square_admin_settings.ajax_url, data, ( response ) => {\n\t\t\tif ( response && response.success ) {\n\t\t\t\tconst rowId = '#record-' + recordId;\n\n\t\t\t\tif ( 'delete' === action ) {\n\t\t\t\t\t$( rowId ).remove();\n\n\t\t\t\t\tif ( ! $( 'table.records tbody tr' ).length ) {\n\t\t\t\t\t\t$( 'table.records tbody' ).html( noRecordsFoundRow );\n\t\t\t\t\t\t$( '#wc-square_clear-sync-records' ).prop( 'disabled', true );\n\t\t\t\t\t}\n\t\t\t\t} else if ( 'resolve' === action || 'unsync' === action ) {\n\t\t\t\t\t$( rowId + ' .type' ).html( '<mark class=\"resolved\"><span>' + wc_square_admin_settings.i18n.resolved + '</span></mark>' );\n\t\t\t\t\t$( rowId + ' .actions' ).html( '&mdash;' );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif ( response && response.data ) {\n\t\t\t\t\talert( response.data );\n\t\t\t\t}\n\n\t\t\t\tconsole.log( {\n\t\t\t\t\trecord: recordId,\n\t\t\t\t\taction,\n\t\t\t\t\tresponse,\n\t\t\t\t} );\n\t\t\t}\n\t\t\t$( 'table.records' ).unblock();\n\t\t} );\n\t} );\n\n\t// Add explicit square environment to post data to deal with swapping between production and sandbox in the back end.\n\t$( 'form' ).on( 'submit', ( e ) => {\n\t\tconst environment = $( '#wc_square_enable_sandbox' ).is( ':checked' ) ? 'sandbox' : 'production';\n\n\t\t$( e.target ).append(\n\t\t\t$( '<input>',\n\t\t\t\t{\n\t\t\t\t\ttype: 'hidden',\n\t\t\t\t\tname: 'wc_square_environment',\n\t\t\t\t\tvalue: environment,\n\t\t\t\t}\n\t\t\t)\n\t\t);\n\t} );\n\n\t/**\n\t * Returns a job sync status.\n\t *\n\t * @since 2.0.0\n\t *\n\t * @param {string} job_id\n\t */\n\tconst getSyncStatus = ( job_id ) => {\n\t\tlet $progress = $( 'span.progress' );\n\n\t\tif ( ! $progress || 0 === $progress.length ) {\n\t\t\t$( 'p.sync-result' ).append( ' <span class=\"progress\" style=\"display:block\"></span>' );\n\t\t\t$progress = $( 'span.progress' );\n\t\t}\n\n\t\tconst data = {\n\t\t\taction: 'wc_square_get_sync_with_square_status',\n\t\t\tsecurity: wc_square_admin_settings.get_sync_with_square_status_nonce,\n\t\t\tjob_id,\n\t\t};\n\n\t\t$.post( wc_square_admin_settings.ajax_url, data, ( response ) => {\n\t\t\tif ( response && response.data ) {\n\t\t\t\tif ( response.success && response.data.id ) {\n\t\t\t\t\t// start the progress spinner.\n\t\t\t\t\t$( 'table.sync .spinner' ).css( 'visibility', 'visible' );\n\t\t\t\t\t// disable interacting with records as more could be added during a sync process.\n\t\t\t\t\t$( '#wc-square_clear-sync-records' ).prop( 'disabled', true );\n\t\t\t\t\t$( 'table.records .actions button' ).prop( 'disabled', true );\n\t\t\t\t\t// continue if the job is in progression.\n\t\t\t\t\tif ( 'completed' !== response.data.status && 'failed' !== response.data.status ) {\n\t\t\t\t\t\tlet progress = ' ';\n\t\t\t\t\t\t// update progress info in table cell.\n\t\t\t\t\t\tif ( 'product_import' === response.data.action ) {\n\t\t\t\t\t\t\tprogress += wc_square_admin_settings.i18n.skipped + ': ' + parseInt( response.data.skipped_products_count, 10 ) + '<br/>';\n\t\t\t\t\t\t\tprogress += wc_square_admin_settings.i18n.updated + ': ' + parseInt( response.data.updated_products_count, 10 ) + '<br/>';\n\t\t\t\t\t\t\tprogress += wc_square_admin_settings.i18n.imported + ': ' + parseInt( response.data.imported_products_count, 10 );\n\t\t\t\t\t\t} else if ( response.data.percentage ) {\n\t\t\t\t\t\t\tprogress += parseInt( response.data.percentage, 10 ) + '%';\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t$progress.html( progress );\n\n\t\t\t\t\t\t// recursion update loop until we're 'completed' (add a long timeout to avoid missing callback return output).\n\t\t\t\t\t\tsetTimeout( () => {\n\t\t\t\t\t\t\tgetSyncStatus( response.data.id );\n\t\t\t\t\t\t}, 30 * 1000 );\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// reload page, display updated sync dates and any sync records messages.\n\t\t\t\t\t\tlocation.reload(); // unlikely job processing exception.\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t$( '#wc-square_clear-sync-records' ).prop( 'disabled', false );\n\t\t\t\t\t$( 'table.records .actions button' ).prop( 'disabled', false );\n\t\t\t\t\t$( 'table.sync .spinner' ).css( 'visibility', 'hidden' );\n\t\t\t\t\tconsole.log( response );\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t};\n\n\t// run once on page load.\n\tif ( wc_square_admin_settings.existing_sync_job_id ) {\n\t\tgetSyncStatus( wc_square_admin_settings.existing_sync_job_id );\n\t}\n\n\t// Show/hide Digital Wallet Settings on Square gateway settings page.\n\t$( '#woocommerce_square_credit_card_enable_digital_wallets' ).on( 'change', () => {\n\t\tconst wallet_settings = $( '.wc-square-digital-wallet-options' );\n\n\t\tif ( $( '#woocommerce_square_credit_card_enable_digital_wallets' ).is( ':checked' ) ) {\n\t\t\twallet_settings.closest( 'tr' ).show();\n\t\t} else {\n\t\t\twallet_settings.closest( 'tr' ).hide();\n\t\t}\n\t} ).trigger( 'change' );\n} );\n"],"file":"wc-square-admin-settings.min.js"}
 
assets/js/frontend/wc-square-digital-wallet.js DELETED
@@ -1,597 +0,0 @@
1
- /* global wc_add_to_cart_variation_params, SqPaymentForm */
2
-
3
- /**
4
- * Square Credit Card Digital Wallet Handler class.
5
- *
6
- * @since 2.3
7
- */
8
- jQuery( document ).ready( ( $ ) => {
9
- /**
10
- * Square Credit Card Digital Wallet Handler class.
11
- *
12
- * @since 2.3
13
- */
14
- class WC_Square_Digital_Wallet_Handler {
15
- /**
16
- * Setup handler
17
- *
18
- * @param {Array} args
19
- * @since 2.3
20
- */
21
- constructor( args ) {
22
- this.args = args;
23
- this.payment_request = args.payment_request;
24
- this.total_amount = args.payment_request.total.amount;
25
- this.wallet = '#wc-square-digital-wallet';
26
- this.buttons = '.wc-square-wallet-buttons';
27
-
28
- if ( $( this.wallet ).length === 0 ) {
29
- return;
30
- }
31
-
32
- $( this.wallet ).hide();
33
- $( this.buttons ).hide();
34
-
35
- this.build_digital_wallet();
36
- this.attach_page_events();
37
- }
38
-
39
- /**
40
- * Fetch a new payment request object and reload the SqPaymentForm
41
- *
42
- * @since 2.3
43
- */
44
- build_digital_wallet() {
45
- this.block_ui();
46
- this.get_payment_request().then(
47
- ( response ) => {
48
- this.payment_request = JSON.parse( response );
49
- this.total_amount = this.payment_request.total.amount;
50
- this.load_square_form();
51
- this.unblock_ui();
52
- },
53
- ( message ) => {
54
- this.log( '[Square] Could not build payment request. ' + message, 'error' );
55
- $( this.wallet ).hide();
56
- }
57
- );
58
- }
59
-
60
- /**
61
- * Add page event listeners
62
- *
63
- * @since 2.3
64
- */
65
- attach_page_events() {
66
- if ( this.args.context === 'product' ) {
67
- const addToCartButton = $( '.single_add_to_cart_button' );
68
-
69
- $( '#wc-square-apple-pay, #wc-square-google-pay' ).on( 'click', ( e ) => {
70
- if ( addToCartButton.is( '.disabled' ) ) {
71
- e.stopImmediatePropagation();
72
-
73
- if ( addToCartButton.is( '.wc-variation-is-unavailable' ) ) {
74
- window.alert( wc_add_to_cart_variation_params.i18n_unavailable_text );
75
- } else if ( addToCartButton.is( '.wc-variation-selection-needed' ) ) {
76
- window.alert( wc_add_to_cart_variation_params.i18n_make_a_selection_text );
77
- }
78
- return;
79
- }
80
-
81
- this.add_to_cart();
82
- } );
83
-
84
- $( document.body ).on( 'woocommerce_variation_has_changed', () => this.build_digital_wallet() );
85
-
86
- $( '.quantity' ).on( 'input', '.qty', () => this.build_digital_wallet() );
87
- }
88
-
89
- if ( this.args.context === 'cart' ) {
90
- $( document.body ).on( 'updated_cart_totals', () => this.build_digital_wallet() );
91
- }
92
-
93
- if ( this.args.context === 'checkout' ) {
94
- $( document.body ).on( 'updated_checkout', () => this.build_digital_wallet() );
95
- }
96
- }
97
-
98
- /**
99
- * Load the digital wallet payment form
100
- *
101
- * @since 2.3
102
- */
103
- load_square_form() {
104
- if ( this.payment_form ) {
105
- this.log( '[Square] Destroying digital wallet payment form' );
106
- this.payment_form.destroy();
107
- }
108
-
109
- this.log( '[Square] Building digital wallet payment form' );
110
- this.payment_form = new SqPaymentForm( this.get_form_params() );
111
- this.payment_form.build();
112
- }
113
-
114
- /**
115
- * Gets the Square payment form params.
116
- *
117
- * @since 2.3
118
- */
119
- get_form_params() {
120
- const params = {
121
- applicationId: this.args.application_id,
122
- locationId: this.args.location_id,
123
- autobuild: false,
124
- applePay: {
125
- elementId: 'wc-square-apple-pay',
126
- },
127
- googlePay: {
128
- elementId: 'wc-square-google-pay',
129
- },
130
- callbacks: {
131
- paymentFormLoaded: () => this.unblock_ui(),
132
- createPaymentRequest: () => this.create_payment_request(),
133
- methodsSupported: ( methods, unsupportedReason ) => this.methods_supported( methods, unsupportedReason ),
134
- shippingContactChanged: ( shippingContact, done ) => this.handle_shipping_address_changed( shippingContact, done ),
135
- shippingOptionChanged: ( shippingOption, done ) => this.handle_shipping_option_changed( shippingOption, done ),
136
- cardNonceResponseReceived: ( errors, nonce, cardData, billingContact, shippingContact, shippingOption ) => {
137
- this.handle_card_nonce_response( errors, nonce, cardData, billingContact, shippingContact, shippingOption );
138
- },
139
- },
140
- };
141
-
142
- // Fix console errors for Google Pay when there are no shipping options set. See note in Square documentation under shippingOptions: https://developer.squareup.com/docs/api/paymentform#paymentrequestfields.
143
- if ( this.payment_request.requestShippingAddress === false ) {
144
- delete params.callbacks.shippingOptionChanged;
145
- }
146
-
147
- // Remove support for Google Pay and/or Apple Pay if chosen in settings.
148
- if ( this.args.hide_button_options.includes( 'google' ) ) {
149
- delete params.googlePay;
150
- }
151
-
152
- if ( this.args.hide_button_options.includes( 'apple' ) ) {
153
- delete params.applePay;
154
- }
155
-
156
- return params;
157
- }
158
-
159
- /**
160
- * Sets the a payment request object for the Square Payment Form
161
- *
162
- * @since 2.3
163
- */
164
- create_payment_request() {
165
- return this.payment_request;
166
- }
167
-
168
- /**
169
- * Check which methods are supported and show/hide the correct buttons on frontend
170
- * Reference: https://developer.squareup.com/docs/api/paymentform#methodssupported
171
- *
172
- * @param {Object} methods
173
- * @param {string} unsupportedReason
174
- *
175
- * @since 2.3
176
- */
177
- methods_supported( methods, unsupportedReason ) {
178
- if ( methods.applePay === true || methods.googlePay === true ) {
179
- if ( methods.applePay === true ) {
180
- $( '#wc-square-apple-pay' ).show();
181
- }
182
-
183
- if ( methods.googlePay === true ) {
184
- $( '#wc-square-google-pay' ).show();
185
- }
186
-
187
- $( this.wallet ).show();
188
- } else {
189
- this.log( unsupportedReason );
190
- }
191
- }
192
-
193
- /*
194
- * Get the payment request on a product page
195
- *
196
- * @since 2.3
197
- */
198
- get_payment_request() {
199
- return new Promise( ( resolve, reject ) => {
200
- const data = {
201
- context: this.args.context,
202
- security: this.args.payment_request_nonce,
203
- };
204
-
205
- if ( this.args.context === 'product' ) {
206
- const product_data = this.get_product_data();
207
- $.extend( data, product_data );
208
- }
209
- // retrieve a payment request object.
210
- $.post( this.get_ajax_url( 'get_payment_request' ), data, ( response ) => {
211
- if ( response.success ) {
212
- return resolve( response.data );
213
- }
214
-
215
- return reject( response.data );
216
- } );
217
- } );
218
- }
219
-
220
- /*
221
- * Handle all shipping address recalculations in the Apple/Google Pay window
222
- *
223
- * Reference: https://developer.squareup.com/docs/api/paymentform#shippingcontactchanged
224
- *
225
- * @since 2.3
226
- */
227
- handle_shipping_address_changed( shippingContact, done ) {
228
- const data = {
229
- context: this.args.context,
230
- shipping_contact: shippingContact.data,
231
- security: this.args.recalculate_totals_nonce,
232
- };
233
-
234
- // send ajax request get_shipping_options.
235
- this.recalculate_totals( data ).then( ( response ) => {
236
- return done( response );
237
- }, () => {
238
- return done( {
239
- error: 'Bad Request',
240
- } );
241
- } );
242
- }
243
-
244
- /*
245
- * Handle all shipping method changes in the Apple/Google Pay window
246
- *
247
- * Reference: https://developer.squareup.com/docs/api/paymentform#shippingoptionchanged
248
- *
249
- * @since 2.3
250
- */
251
- handle_shipping_option_changed( shippingOption, done ) {
252
- const data = {
253
- context: this.args.context,
254
- shipping_option: shippingOption.data.id,
255
- security: this.args.recalculate_totals_nonce,
256
- };
257
-
258
- this.recalculate_totals( data ).then( ( response ) => {
259
- return done( response );
260
- }, () => {
261
- return done( {
262
- error: 'Bad Request',
263
- } );
264
- } );
265
- }
266
-
267
- /*
268
- * Handle the payment response.
269
- *
270
- * On success, set the checkout billing/shipping data and submit the checkout.
271
- *
272
- * @since 2.3
273
- */
274
- handle_card_nonce_response( errors, nonce, cardData, billingContact, shippingContact, shippingOption ) {
275
- if ( errors ) {
276
- return this.render_errors( errors );
277
- }
278
-
279
- if ( ! nonce ) {
280
- return this.render_errors( this.args.general_error );
281
- }
282
-
283
- this.block_ui();
284
-
285
- const data = {
286
- action: '',
287
- _wpnonce: this.args.process_checkout_nonce,
288
- billing_first_name: billingContact.givenName ? billingContact.givenName : '',
289
- billing_last_name: billingContact.familyName ? billingContact.familyName : '',
290
- billing_company: '',
291
- billing_email: shippingContact.email ? shippingContact.email : '',
292
- billing_phone: shippingContact.phone ? shippingContact.phone : '',
293
- billing_country: billingContact.country ? billingContact.country.toUpperCase() : '',
294
- billing_address_1: billingContact.addressLines && billingContact.addressLines[ 0 ] ? billingContact.addressLines[ 0 ] : '',
295
- billing_address_2: billingContact.addressLines && billingContact.addressLines[ 1 ] ? billingContact.addressLines[ 1 ] : '',
296
- billing_city: billingContact.city ? billingContact.city : '',
297
- billing_state: billingContact.region ? billingContact.region : '',
298
- billing_postcode: billingContact.postalCode ? billingContact.postalCode : '',
299
- shipping_first_name: shippingContact.givenName ? shippingContact.givenName : '',
300
- shipping_last_name: shippingContact.familyName ? shippingContact.familyName : '',
301
- shipping_company: '',
302
- shipping_country: shippingContact.country ? shippingContact.country.toUpperCase() : '',
303
- shipping_address_1: shippingContact.addressLines && shippingContact.addressLines[ 0 ] ? shippingContact.addressLines[ 0 ] : '',
304
- shipping_address_2: shippingContact.addressLines && shippingContact.addressLines[ 1 ] ? shippingContact.addressLines[ 1 ] : '',
305
- shipping_city: shippingContact.city ? shippingContact.city : '',
306
- shipping_state: shippingContact.region ? shippingContact.region : '',
307
- shipping_postcode: shippingContact.postalCode ? shippingContact.postalCode : '',
308
- shipping_method: [ ! shippingOption ? null : shippingOption.id ],
309
- order_comments: '',
310
- payment_method: 'square_credit_card',
311
- ship_to_different_address: 1,
312
- terms: 1,
313
- 'wc-square-credit-card-payment-nonce': nonce,
314
- 'wc-square-credit-card-last-four': cardData.last_4 ? cardData.last_4 : null,
315
- 'wc-square-credit-card-exp-month': cardData.exp_month ? cardData.exp_month : null,
316
- 'wc-square-credit-card-exp-year': cardData.exp_year ? cardData.exp_year : null,
317
- 'wc-square-credit-card-payment-postcode': cardData.billing_postal_code ? cardData.billing_postal_code : null,
318
- 'wc-square-digital-wallet-type': cardData.digital_wallet_type,
319
- };
320
-
321
- // handle slightly different mapping for Google Pay (Google returns full name as a single string).
322
- if ( cardData.digital_wallet_type === 'GOOGLE_PAY' ) {
323
- if ( billingContact.givenName ) {
324
- data.billing_first_name = billingContact.givenName.split( ' ' ).slice( 0, 1 ).join( ' ' );
325
- data.billing_last_name = billingContact.givenName.split( ' ' ).slice( 1 ).join( ' ' );
326
- }
327
-
328
- if ( shippingContact.givenName ) {
329
- data.shipping_last_name = shippingContact.givenName.split( ' ' ).slice( 0, 1 ).join( ' ' );
330
- data.shipping_last_name = shippingContact.givenName.split( ' ' ).slice( 1 ).join( ' ' );
331
- }
332
- }
333
-
334
- // if the billing_phone was not found on shippingContact, use the value on billingContact if that exists.
335
- if ( ! data.billing_phone && billingContact.phone ) {
336
- data.billing_phone = billingContact.phone;
337
- }
338
-
339
- // if SCA is enabled, verify the buyer and add verification token to data.
340
- if ( this.args.is_3d_secure_enabled ) {
341
- this.log( '3DS verification enabled. Verifying buyer' );
342
-
343
- var self = this;
344
-
345
- this.payment_form.verifyBuyer(
346
- nonce,
347
- self.get_verification_details( billingContact, shippingContact ),
348
- function(err, verificationResult) {
349
- if (err == null) {
350
- // SCA verification complete. Do checkout.
351
- self.log( '3DS verification successful' );
352
- data['wc-square-credit-card-buyer-verification-token'] = verificationResult.token;
353
- self.do_checkout( data );
354
- } else {
355
- // SCA verification failed. Render errors.
356
- self.log( '3DS verification failed' );
357
- self.log(err);
358
- self.render_errors( [err.message] );
359
- }
360
- }
361
- );
362
- } else {
363
- // SCA not enabled. Do checkout.
364
- this.do_checkout( data );
365
- }
366
- }
367
-
368
- /**
369
- * Do Digital Wallet Checkout
370
- *
371
- * @since 2.4.2
372
- *
373
- * @param {Object} args
374
- */
375
- do_checkout( data ) {
376
- // AJAX process checkout.
377
- this.process_digital_wallet_checkout( data ).then(
378
- ( response ) => {
379
- window.location = response.redirect;
380
- },
381
- ( response ) => {
382
- this.log( response, 'error' );
383
- this.render_errors_html( response.messages );
384
- }
385
- );
386
- }
387
-
388
- /**
389
- * Gets a verification details object to be used in verifyBuyer()
390
- *
391
- * @since 2.4.2
392
- *
393
- * @param {Object} billingContact
394
- * @param {Object} shippingContact
395
- *
396
- * @return {Object} Verification details object.
397
- */
398
- get_verification_details( billingContact, shippingContact ) {
399
- const verification_details = {
400
- intent: 'CHARGE',
401
- amount: this.total_amount,
402
- currencyCode: this.payment_request.currencyCode,
403
- billingContact: {
404
- familyName: billingContact.familyName ? billingContact.familyName : '',
405
- givenName: billingContact.givenName ? billingContact.givenName : '',
406
- email: shippingContact.email ? shippingContact.email : '',
407
- country: billingContact.country ? billingContact.country.toUpperCase() : '',
408
- region: billingContact.region ? billingContact.region : '',
409
- city: billingContact.city ? billingContact.city : '',
410
- postalCode: billingContact.postalCode ? billingContact.postalCode : '',
411
- phone: shippingContact.phone ? shippingContact.phone : '',
412
- addressLines: billingContact.addressLines ? billingContact.addressLines : '',
413
- },
414
- }
415
-
416
- this.log( verification_details );
417
-
418
- return verification_details;
419
- }
420
-
421
- /*
422
- * Recalculate totals
423
- *
424
- * @since 2.3
425
- */
426
- recalculate_totals( data ) {
427
- return new Promise( ( resolve, reject ) => {
428
- return $.post( this.get_ajax_url( 'recalculate_totals' ), data, ( response ) => {
429
- if ( response.success ) {
430
- this.total_amount = response.data.total.amount;
431
- return resolve( response.data );
432
- }
433
- return reject( response.data );
434
- } );
435
- } );
436
- }
437
-
438
- /*
439
- * Get the product data for building the payment request on the product page
440
- *
441
- * @since 2.3
442
- */
443
- get_product_data() {
444
- let product_id = $( '.single_add_to_cart_button' ).val();
445
-
446
- const attributes = {};
447
-
448
- // Check if product is a variable product.
449
- if ( $( '.single_variation_wrap' ).length ) {
450
- product_id = $( '.single_variation_wrap' ).find( 'input[name="product_id"]' ).val();
451
- if ( $( '.variations_form' ).length ) {
452
- $( '.variations_form' ).find( '.variations select' ).each( ( index, select ) => {
453
- const attribute_name = $( select ).data( 'attribute_name' ) || $( select ).attr( 'name' );
454
- const value = $( select ).val() || '';
455
- return attributes[ attribute_name ] = value;
456
- } );
457
- }
458
- }
459
-
460
- return {
461
- product_id,
462
- quantity: $( '.quantity .qty' ).val(),
463
- attributes,
464
- };
465
- }
466
-
467
- /*
468
- * Add the product to the cart
469
- *
470
- * @since 2.3
471
- */
472
- add_to_cart() {
473
- const data = {
474
- security: this.args.add_to_cart_nonce,
475
- };
476
- const product_data = this.get_product_data();
477
- $.extend( data, product_data );
478
-
479
- // retrieve a payment request object.
480
- $.post( this.get_ajax_url( 'add_to_cart' ), data, ( response ) => {
481
- if ( response.error ) {
482
- return window.alert( response.data );
483
- }
484
-
485
- const data = JSON.parse( response.data );
486
- this.payment_request = data.payment_request;
487
- this.args.payment_request_nonce = data.payment_request_nonce;
488
- this.args.add_to_cart_nonce = data.add_to_cart_nonce;
489
- this.args.recalculate_totals_nonce = data.recalculate_totals_nonce;
490
- this.args.process_checkout_nonce = data.process_checkout_nonce;
491
- } );
492
- }
493
-
494
- /*
495
- * Process the digital wallet checkout
496
- *
497
- * @since 2.3
498
- */
499
- process_digital_wallet_checkout( data ) {
500
- return new Promise( ( resolve, reject ) => {
501
- $.post( this.get_ajax_url( 'process_checkout' ), data, ( response ) => {
502
- if ( response.result === 'success' ) {
503
- return resolve( response );
504
- }
505
-
506
- return reject( response );
507
- } );
508
- } );
509
- }
510
-
511
- /*
512
- * Helper function to return the ajax URL for the given request/action
513
- *
514
- * @since 2.3
515
- */
516
- get_ajax_url( request ) {
517
- return this.args.ajax_url.replace( '%%endpoint%%', 'square_digital_wallet_' + request );
518
- }
519
-
520
- /*
521
- * Renders errors given the error message HTML
522
- *
523
- * @since 2.3
524
- */
525
- render_errors_html( errors_html ) {
526
- // hide and remove any previous errors.
527
- $( '.woocommerce-error, .woocommerce-message' ).remove();
528
-
529
- const element = this.args.context === 'product' ? $( '.product' ) : $( '.shop_table.cart' ).closest( 'form' );
530
-
531
- // add errors
532
- element.before( errors_html );
533
-
534
- // unblock UI
535
- this.unblock_ui();
536
-
537
- // scroll to top
538
- $( 'html, body' ).animate( {
539
- scrollTop: element.offset().top - 100,
540
- }, 1000 );
541
- }
542
-
543
- /*
544
- * Renders errors
545
- *
546
- * @since 2.3
547
- */
548
- render_errors( errors ) {
549
- const error_message_html = '<ul class="woocommerce-error"><li>' + errors.join( '</li><li>' ) + '</li></ul>';
550
- this.render_errors_html( error_message_html );
551
- }
552
-
553
- /*
554
- * Block the Apple Pay and Google Pay buttons from being clicked which processing certain actions
555
- *
556
- * @since 2.3
557
- */
558
- block_ui() {
559
- $( this.buttons ).block( {
560
- message: null,
561
- overlayCSS: {
562
- background: '#fff',
563
- opacity: 0.6,
564
- },
565
- } );
566
- }
567
-
568
- /*
569
- * Unblock the wallet buttons
570
- *
571
- * @since 2.3
572
- */
573
- unblock_ui() {
574
- $( this.buttons ).unblock();
575
- }
576
-
577
- /*
578
- * Logs messages to the console when logging is turned on in the settings
579
- *
580
- * @since 2.3
581
- */
582
- log( message, type = 'notice' ) {
583
- // if logging is disabled, bail.
584
- if ( ! this.args.logging_enabled ) {
585
- return;
586
- }
587
-
588
- if ( type === 'error' ) {
589
- return console.error( message );
590
- }
591
-
592
- return console.log( message );
593
- }
594
- }
595
-
596
- window.WC_Square_Digital_Wallet_Handler = WC_Square_Digital_Wallet_Handler;
597
- } );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/js/frontend/wc-square-digital-wallet.min.js CHANGED
@@ -1,2 +1 @@
1
- "use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor}jQuery(document).ready(function($){var WC_Square_Digital_Wallet_Handler=function(){function WC_Square_Digital_Wallet_Handler(args){_classCallCheck(this,WC_Square_Digital_Wallet_Handler);this.args=args;this.payment_request=args.payment_request;this.total_amount=args.payment_request.total.amount;this.wallet="#wc-square-digital-wallet";this.buttons=".wc-square-wallet-buttons";if($(this.wallet).length===0){return}$(this.wallet).hide();$(this.buttons).hide();this.build_digital_wallet();this.attach_page_events()}_createClass(WC_Square_Digital_Wallet_Handler,[{key:"build_digital_wallet",value:function build_digital_wallet(){var _this=this;this.block_ui();this.get_payment_request().then(function(response){_this.payment_request=JSON.parse(response);_this.total_amount=_this.payment_request.total.amount;_this.load_square_form();_this.unblock_ui()},function(message){_this.log("[Square] Could not build payment request. "+message,"error");$(_this.wallet).hide()})}},{key:"attach_page_events",value:function attach_page_events(){var _this2=this;if(this.args.context==="product"){var addToCartButton=$(".single_add_to_cart_button");$("#wc-square-apple-pay, #wc-square-google-pay").on("click",function(e){if(addToCartButton.is(".disabled")){e.stopImmediatePropagation();if(addToCartButton.is(".wc-variation-is-unavailable")){window.alert(wc_add_to_cart_variation_params.i18n_unavailable_text)}else if(addToCartButton.is(".wc-variation-selection-needed")){window.alert(wc_add_to_cart_variation_params.i18n_make_a_selection_text)}return}_this2.add_to_cart()});$(document.body).on("woocommerce_variation_has_changed",function(){return _this2.build_digital_wallet()});$(".quantity").on("input",".qty",function(){return _this2.build_digital_wallet()})}if(this.args.context==="cart"){$(document.body).on("updated_cart_totals",function(){return _this2.build_digital_wallet()})}if(this.args.context==="checkout"){$(document.body).on("updated_checkout",function(){return _this2.build_digital_wallet()})}}},{key:"load_square_form",value:function load_square_form(){if(this.payment_form){this.log("[Square] Destroying digital wallet payment form");this.payment_form.destroy()}this.log("[Square] Building digital wallet payment form");this.payment_form=new SqPaymentForm(this.get_form_params());this.payment_form.build()}},{key:"get_form_params",value:function get_form_params(){var _this3=this;var params={applicationId:this.args.application_id,locationId:this.args.location_id,autobuild:false,applePay:{elementId:"wc-square-apple-pay"},googlePay:{elementId:"wc-square-google-pay"},callbacks:{paymentFormLoaded:function paymentFormLoaded(){return _this3.unblock_ui()},createPaymentRequest:function createPaymentRequest(){return _this3.create_payment_request()},methodsSupported:function methodsSupported(methods,unsupportedReason){return _this3.methods_supported(methods,unsupportedReason)},shippingContactChanged:function shippingContactChanged(shippingContact,done){return _this3.handle_shipping_address_changed(shippingContact,done)},shippingOptionChanged:function shippingOptionChanged(shippingOption,done){return _this3.handle_shipping_option_changed(shippingOption,done)},cardNonceResponseReceived:function cardNonceResponseReceived(errors,nonce,cardData,billingContact,shippingContact,shippingOption){_this3.handle_card_nonce_response(errors,nonce,cardData,billingContact,shippingContact,shippingOption)}}};if(this.payment_request.requestShippingAddress===false){delete params.callbacks.shippingOptionChanged}if(this.args.hide_button_options.includes("google")){delete params.googlePay}if(this.args.hide_button_options.includes("apple")){delete params.applePay}return params}},{key:"create_payment_request",value:function create_payment_request(){return this.payment_request}},{key:"methods_supported",value:function methods_supported(methods,unsupportedReason){if(methods.applePay===true||methods.googlePay===true){if(methods.applePay===true){$("#wc-square-apple-pay").show()}if(methods.googlePay===true){$("#wc-square-google-pay").show()}$(this.wallet).show()}else{this.log(unsupportedReason)}}},{key:"get_payment_request",value:function get_payment_request(){var _this4=this;return new Promise(function(resolve,reject){var data={context:_this4.args.context,security:_this4.args.payment_request_nonce};if(_this4.args.context==="product"){var product_data=_this4.get_product_data();$.extend(data,product_data)}$.post(_this4.get_ajax_url("get_payment_request"),data,function(response){if(response.success){return resolve(response.data)}return reject(response.data)})})}},{key:"handle_shipping_address_changed",value:function handle_shipping_address_changed(shippingContact,done){var data={context:this.args.context,shipping_contact:shippingContact.data,security:this.args.recalculate_totals_nonce};this.recalculate_totals(data).then(function(response){return done(response)},function(){return done({error:"Bad Request"})})}},{key:"handle_shipping_option_changed",value:function handle_shipping_option_changed(shippingOption,done){var data={context:this.args.context,shipping_option:shippingOption.data.id,security:this.args.recalculate_totals_nonce};this.recalculate_totals(data).then(function(response){return done(response)},function(){return done({error:"Bad Request"})})}},{key:"handle_card_nonce_response",value:function handle_card_nonce_response(errors,nonce,cardData,billingContact,shippingContact,shippingOption){if(errors){return this.render_errors(errors)}if(!nonce){return this.render_errors(this.args.general_error)}this.block_ui();var data={action:"",_wpnonce:this.args.process_checkout_nonce,billing_first_name:billingContact.givenName?billingContact.givenName:"",billing_last_name:billingContact.familyName?billingContact.familyName:"",billing_company:"",billing_email:shippingContact.email?shippingContact.email:"",billing_phone:shippingContact.phone?shippingContact.phone:"",billing_country:billingContact.country?billingContact.country.toUpperCase():"",billing_address_1:billingContact.addressLines&&billingContact.addressLines[0]?billingContact.addressLines[0]:"",billing_address_2:billingContact.addressLines&&billingContact.addressLines[1]?billingContact.addressLines[1]:"",billing_city:billingContact.city?billingContact.city:"",billing_state:billingContact.region?billingContact.region:"",billing_postcode:billingContact.postalCode?billingContact.postalCode:"",shipping_first_name:shippingContact.givenName?shippingContact.givenName:"",shipping_last_name:shippingContact.familyName?shippingContact.familyName:"",shipping_company:"",shipping_country:shippingContact.country?shippingContact.country.toUpperCase():"",shipping_address_1:shippingContact.addressLines&&shippingContact.addressLines[0]?shippingContact.addressLines[0]:"",shipping_address_2:shippingContact.addressLines&&shippingContact.addressLines[1]?shippingContact.addressLines[1]:"",shipping_city:shippingContact.city?shippingContact.city:"",shipping_state:shippingContact.region?shippingContact.region:"",shipping_postcode:shippingContact.postalCode?shippingContact.postalCode:"",shipping_method:[!shippingOption?null:shippingOption.id],order_comments:"",payment_method:"square_credit_card",ship_to_different_address:1,terms:1,"wc-square-credit-card-payment-nonce":nonce,"wc-square-credit-card-last-four":cardData.last_4?cardData.last_4:null,"wc-square-credit-card-exp-month":cardData.exp_month?cardData.exp_month:null,"wc-square-credit-card-exp-year":cardData.exp_year?cardData.exp_year:null,"wc-square-credit-card-payment-postcode":cardData.billing_postal_code?cardData.billing_postal_code:null,"wc-square-digital-wallet-type":cardData.digital_wallet_type};if(cardData.digital_wallet_type==="GOOGLE_PAY"){if(billingContact.givenName){data.billing_first_name=billingContact.givenName.split(" ").slice(0,1).join(" ");data.billing_last_name=billingContact.givenName.split(" ").slice(1).join(" ")}if(shippingContact.givenName){data.shipping_last_name=shippingContact.givenName.split(" ").slice(0,1).join(" ");data.shipping_last_name=shippingContact.givenName.split(" ").slice(1).join(" ")}}if(!data.billing_phone&&billingContact.phone){data.billing_phone=billingContact.phone}if(this.args.is_3d_secure_enabled){this.log("3DS verification enabled. Verifying buyer");var self=this;this.payment_form.verifyBuyer(nonce,self.get_verification_details(billingContact,shippingContact),function(err,verificationResult){if(err==null){self.log("3DS verification successful");data["wc-square-credit-card-buyer-verification-token"]=verificationResult.token;self.do_checkout(data)}else{self.log("3DS verification failed");self.log(err);self.render_errors([err.message])}})}else{this.do_checkout(data)}}},{key:"do_checkout",value:function do_checkout(data){var _this5=this;this.process_digital_wallet_checkout(data).then(function(response){window.location=response.redirect},function(response){_this5.log(response,"error");_this5.render_errors_html(response.messages)})}},{key:"get_verification_details",value:function get_verification_details(billingContact,shippingContact){var verification_details={intent:"CHARGE",amount:this.total_amount,currencyCode:this.payment_request.currencyCode,billingContact:{familyName:billingContact.familyName?billingContact.familyName:"",givenName:billingContact.givenName?billingContact.givenName:"",email:shippingContact.email?shippingContact.email:"",country:billingContact.country?billingContact.country.toUpperCase():"",region:billingContact.region?billingContact.region:"",city:billingContact.city?billingContact.city:"",postalCode:billingContact.postalCode?billingContact.postalCode:"",phone:shippingContact.phone?shippingContact.phone:"",addressLines:billingContact.addressLines?billingContact.addressLines:""}};this.log(verification_details);return verification_details}},{key:"recalculate_totals",value:function recalculate_totals(data){var _this6=this;return new Promise(function(resolve,reject){return $.post(_this6.get_ajax_url("recalculate_totals"),data,function(response){if(response.success){_this6.total_amount=response.data.total.amount;return resolve(response.data)}return reject(response.data)})})}},{key:"get_product_data",value:function get_product_data(){var product_id=$(".single_add_to_cart_button").val();var attributes={};if($(".single_variation_wrap").length){product_id=$(".single_variation_wrap").find("input[name=\"product_id\"]").val();if($(".variations_form").length){$(".variations_form").find(".variations select").each(function(index,select){var attribute_name=$(select).data("attribute_name")||$(select).attr("name");var value=$(select).val()||"";return attributes[attribute_name]=value})}}return{product_id:product_id,quantity:$(".quantity .qty").val(),attributes:attributes}}},{key:"add_to_cart",value:function add_to_cart(){var _this7=this;var data={security:this.args.add_to_cart_nonce};var product_data=this.get_product_data();$.extend(data,product_data);$.post(this.get_ajax_url("add_to_cart"),data,function(response){if(response.error){return window.alert(response.data)}var data=JSON.parse(response.data);_this7.payment_request=data.payment_request;_this7.args.payment_request_nonce=data.payment_request_nonce;_this7.args.add_to_cart_nonce=data.add_to_cart_nonce;_this7.args.recalculate_totals_nonce=data.recalculate_totals_nonce;_this7.args.process_checkout_nonce=data.process_checkout_nonce})}},{key:"process_digital_wallet_checkout",value:function process_digital_wallet_checkout(data){var _this8=this;return new Promise(function(resolve,reject){$.post(_this8.get_ajax_url("process_checkout"),data,function(response){if(response.result==="success"){return resolve(response)}return reject(response)})})}},{key:"get_ajax_url",value:function get_ajax_url(request){return this.args.ajax_url.replace("%%endpoint%%","square_digital_wallet_"+request)}},{key:"render_errors_html",value:function render_errors_html(errors_html){$(".woocommerce-error, .woocommerce-message").remove();var element=this.args.context==="product"?$(".product"):$(".shop_table.cart").closest("form");element.before(errors_html);this.unblock_ui();$("html, body").animate({scrollTop:element.offset().top-100},1000)}},{key:"render_errors",value:function render_errors(errors){var error_message_html="<ul class=\"woocommerce-error\"><li>"+errors.join("</li><li>")+"</li></ul>";this.render_errors_html(error_message_html)}},{key:"block_ui",value:function block_ui(){$(this.buttons).block({message:null,overlayCSS:{background:"#fff",opacity:0.6}})}},{key:"unblock_ui",value:function unblock_ui(){$(this.buttons).unblock()}},{key:"log",value:function log(message){var type=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"notice";if(!this.args.logging_enabled){return}if(type==="error"){return console.error(message)}return console.log(message)}}]);return WC_Square_Digital_Wallet_Handler}();window.WC_Square_Digital_Wallet_Handler=WC_Square_Digital_Wallet_Handler});
2
- //# sourceMappingURL=wc-square-digital-wallet.min.js.map
1
+ "use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);Object.defineProperty(Constructor,"prototype",{writable:false});return Constructor}jQuery(document).ready(function($){var WC_Square_Digital_Wallet_Handler=function(){function WC_Square_Digital_Wallet_Handler(args){_classCallCheck(this,WC_Square_Digital_Wallet_Handler);this.args=args;this.payment_request=args.payment_request;this.total_amount=args.payment_request.total.amount;this.wallet="#wc-square-digital-wallet";this.buttons=".wc-square-wallet-buttons";if($(this.wallet).length===0){return}$(this.wallet).hide();$(this.buttons).hide();this.build_digital_wallet();this.attach_page_events()}_createClass(WC_Square_Digital_Wallet_Handler,[{key:"build_digital_wallet",value:function build_digital_wallet(){var _this=this;this.block_ui();this.get_payment_request().then(function(response){_this.payment_request=JSON.parse(response);_this.total_amount=_this.payment_request.total.amount;_this.load_square_form();_this.unblock_ui()},function(message){_this.log("[Square] Could not build payment request. "+message,"error");$(_this.wallet).hide()})}},{key:"attach_page_events",value:function attach_page_events(){var _this2=this;if(this.args.context==="product"){var addToCartButton=$(".single_add_to_cart_button");$("#wc-square-apple-pay, #wc-square-google-pay").on("click",function(e){if(addToCartButton.is(".disabled")){e.stopImmediatePropagation();if(addToCartButton.is(".wc-variation-is-unavailable")){window.alert(wc_add_to_cart_variation_params.i18n_unavailable_text)}else if(addToCartButton.is(".wc-variation-selection-needed")){window.alert(wc_add_to_cart_variation_params.i18n_make_a_selection_text)}return}_this2.add_to_cart()});$(document.body).on("woocommerce_variation_has_changed",function(){return _this2.build_digital_wallet()});$(".quantity").on("input",".qty",function(){return _this2.build_digital_wallet()})}if(this.args.context==="cart"){$(document.body).on("updated_cart_totals",function(){return _this2.build_digital_wallet()})}if(this.args.context==="checkout"){$(document.body).on("updated_checkout",function(){return _this2.build_digital_wallet()})}}},{key:"load_square_form",value:function load_square_form(){if(this.payment_form){this.log("[Square] Destroying digital wallet payment form");this.payment_form.destroy()}this.log("[Square] Building digital wallet payment form");this.payment_form=new SqPaymentForm(this.get_form_params());this.payment_form.build()}},{key:"get_form_params",value:function get_form_params(){var _this3=this;var params={applicationId:this.args.application_id,locationId:this.args.location_id,autobuild:false,applePay:{elementId:"wc-square-apple-pay"},googlePay:{elementId:"wc-square-google-pay"},callbacks:{paymentFormLoaded:function paymentFormLoaded(){return _this3.unblock_ui()},createPaymentRequest:function createPaymentRequest(){return _this3.create_payment_request()},methodsSupported:function methodsSupported(methods,unsupportedReason){return _this3.methods_supported(methods,unsupportedReason)},shippingContactChanged:function shippingContactChanged(shippingContact,done){return _this3.handle_shipping_address_changed(shippingContact,done)},shippingOptionChanged:function shippingOptionChanged(shippingOption,done){return _this3.handle_shipping_option_changed(shippingOption,done)},cardNonceResponseReceived:function cardNonceResponseReceived(errors,nonce,cardData,billingContact,shippingContact,shippingOption){_this3.handle_card_nonce_response(errors,nonce,cardData,billingContact,shippingContact,shippingOption)}}};if(this.payment_request.requestShippingAddress===false){delete params.callbacks.shippingOptionChanged}if(this.args.hide_button_options.includes("google")){delete params.googlePay}if(this.args.hide_button_options.includes("apple")){delete params.applePay}return params}},{key:"create_payment_request",value:function create_payment_request(){return this.payment_request}},{key:"methods_supported",value:function methods_supported(methods,unsupportedReason){if(methods.applePay===true||methods.googlePay===true){if(methods.applePay===true){$("#wc-square-apple-pay").show()}if(methods.googlePay===true){$("#wc-square-google-pay").show()}$(this.wallet).show()}else{this.log(unsupportedReason)}}},{key:"get_payment_request",value:function get_payment_request(){var _this4=this;return new Promise(function(resolve,reject){var data={context:_this4.args.context,security:_this4.args.payment_request_nonce};if(_this4.args.context==="product"){var product_data=_this4.get_product_data();$.extend(data,product_data)}$.post(_this4.get_ajax_url("get_payment_request"),data,function(response){if(response.success){return resolve(response.data)}return reject(response.data)})})}},{key:"handle_shipping_address_changed",value:function handle_shipping_address_changed(shippingContact,done){var data={context:this.args.context,shipping_contact:shippingContact.data,security:this.args.recalculate_totals_nonce};this.recalculate_totals(data).then(function(response){return done(response)},function(){return done({error:"Bad Request"})})}},{key:"handle_shipping_option_changed",value:function handle_shipping_option_changed(shippingOption,done){var data={context:this.args.context,shipping_option:shippingOption.data.id,security:this.args.recalculate_totals_nonce};this.recalculate_totals(data).then(function(response){return done(response)},function(){return done({error:"Bad Request"})})}},{key:"handle_card_nonce_response",value:function handle_card_nonce_response(errors,nonce,cardData,billingContact,shippingContact,shippingOption){if(errors){return this.render_errors(errors)}if(!nonce){return this.render_errors(this.args.general_error)}this.block_ui();var data={action:"",_wpnonce:this.args.process_checkout_nonce,billing_first_name:billingContact.givenName?billingContact.givenName:"",billing_last_name:billingContact.familyName?billingContact.familyName:"",billing_company:"",billing_email:shippingContact.email?shippingContact.email:"",billing_phone:shippingContact.phone?shippingContact.phone:"",billing_country:billingContact.country?billingContact.country.toUpperCase():"",billing_address_1:billingContact.addressLines&&billingContact.addressLines[0]?billingContact.addressLines[0]:"",billing_address_2:billingContact.addressLines&&billingContact.addressLines[1]?billingContact.addressLines[1]:"",billing_city:billingContact.city?billingContact.city:"",billing_state:billingContact.region?billingContact.region:"",billing_postcode:billingContact.postalCode?billingContact.postalCode:"",shipping_first_name:shippingContact.givenName?shippingContact.givenName:"",shipping_last_name:shippingContact.familyName?shippingContact.familyName:"",shipping_company:"",shipping_country:shippingContact.country?shippingContact.country.toUpperCase():"",shipping_address_1:shippingContact.addressLines&&shippingContact.addressLines[0]?shippingContact.addressLines[0]:"",shipping_address_2:shippingContact.addressLines&&shippingContact.addressLines[1]?shippingContact.addressLines[1]:"",shipping_city:shippingContact.city?shippingContact.city:"",shipping_state:shippingContact.region?shippingContact.region:"",shipping_postcode:shippingContact.postalCode?shippingContact.postalCode:"",shipping_method:[!shippingOption?null:shippingOption.id],order_comments:"",payment_method:"square_credit_card",ship_to_different_address:1,terms:1,"wc-square-credit-card-payment-nonce":nonce,"wc-square-credit-card-last-four":cardData.last_4?cardData.last_4:null,"wc-square-credit-card-exp-month":cardData.exp_month?cardData.exp_month:null,"wc-square-credit-card-exp-year":cardData.exp_year?cardData.exp_year:null,"wc-square-credit-card-payment-postcode":cardData.billing_postal_code?cardData.billing_postal_code:null,"wc-square-digital-wallet-type":cardData.digital_wallet_type};if(cardData.digital_wallet_type==="GOOGLE_PAY"){if(billingContact.givenName){data.billing_first_name=billingContact.givenName.split(" ").slice(0,1).join(" ");data.billing_last_name=billingContact.givenName.split(" ").slice(1).join(" ")}if(shippingContact.givenName){data.shipping_last_name=shippingContact.givenName.split(" ").slice(0,1).join(" ");data.shipping_last_name=shippingContact.givenName.split(" ").slice(1).join(" ")}}if(!data.billing_phone&&billingContact.phone){data.billing_phone=billingContact.phone}if(this.args.is_3d_secure_enabled){this.log("3DS verification enabled. Verifying buyer");var self=this;this.payment_form.verifyBuyer(nonce,self.get_verification_details(billingContact,shippingContact),function(err,verificationResult){if(err==null){self.log("3DS verification successful");data["wc-square-credit-card-buyer-verification-token"]=verificationResult.token;self.do_checkout(data)}else{self.log("3DS verification failed");self.log(err);self.render_errors([err.message])}})}else{this.do_checkout(data)}}},{key:"do_checkout",value:function do_checkout(data){var _this5=this;this.process_digital_wallet_checkout(data).then(function(response){window.location=response.redirect},function(response){_this5.log(response,"error");_this5.render_errors_html(response.messages)})}},{key:"get_verification_details",value:function get_verification_details(billingContact,shippingContact){var verification_details={intent:"CHARGE",amount:this.total_amount,currencyCode:this.payment_request.currencyCode,billingContact:{familyName:billingContact.familyName?billingContact.familyName:"",givenName:billingContact.givenName?billingContact.givenName:"",email:shippingContact.email?shippingContact.email:"",country:billingContact.country?billingContact.country.toUpperCase():"",region:billingContact.region?billingContact.region:"",city:billingContact.city?billingContact.city:"",postalCode:billingContact.postalCode?billingContact.postalCode:"",phone:shippingContact.phone?shippingContact.phone:"",addressLines:billingContact.addressLines?billingContact.addressLines:""}};this.log(verification_details);return verification_details}},{key:"recalculate_totals",value:function recalculate_totals(data){var _this6=this;return new Promise(function(resolve,reject){return $.post(_this6.get_ajax_url("recalculate_totals"),data,function(response){if(response.success){_this6.total_amount=response.data.total.amount;return resolve(response.data)}return reject(response.data)})})}},{key:"get_product_data",value:function get_product_data(){var product_id=$(".single_add_to_cart_button").val();var attributes={};if($(".single_variation_wrap").length){product_id=$(".single_variation_wrap").find("input[name=\"product_id\"]").val();if($(".variations_form").length){$(".variations_form").find(".variations select").each(function(index,select){var attribute_name=$(select).data("attribute_name")||$(select).attr("name");var value=$(select).val()||"";return attributes[attribute_name]=value})}}return{product_id:product_id,quantity:$(".quantity .qty").val(),attributes:attributes}}},{key:"add_to_cart",value:function add_to_cart(){var _this7=this;var data={security:this.args.add_to_cart_nonce};var product_data=this.get_product_data();$.extend(data,product_data);$.post(this.get_ajax_url("add_to_cart"),data,function(response){if(response.error){return window.alert(response.data)}var data=JSON.parse(response.data);_this7.payment_request=data.payment_request;_this7.args.payment_request_nonce=data.payment_request_nonce;_this7.args.add_to_cart_nonce=data.add_to_cart_nonce;_this7.args.recalculate_totals_nonce=data.recalculate_totals_nonce;_this7.args.process_checkout_nonce=data.process_checkout_nonce})}},{key:"process_digital_wallet_checkout",value:function process_digital_wallet_checkout(data){var _this8=this;return new Promise(function(resolve,reject){$.post(_this8.get_ajax_url("process_checkout"),data,function(response){if(response.result==="success"){return resolve(response)}return reject(response)})})}},{key:"get_ajax_url",value:function get_ajax_url(request){return this.args.ajax_url.replace("%%endpoint%%","square_digital_wallet_"+request)}},{key:"render_errors_html",value:function render_errors_html(errors_html){$(".woocommerce-error, .woocommerce-message").remove();var element=this.args.context==="product"?$(".product"):$(".shop_table.cart").closest("form");element.before(errors_html);this.unblock_ui();$("html, body").animate({scrollTop:element.offset().top-100},1000)}},{key:"render_errors",value:function render_errors(errors){var error_message_html="<ul class=\"woocommerce-error\"><li>"+errors.join("</li><li>")+"</li></ul>";this.render_errors_html(error_message_html)}},{key:"block_ui",value:function block_ui(){$(this.buttons).block({message:null,overlayCSS:{background:"#fff",opacity:0.6}})}},{key:"unblock_ui",value:function unblock_ui(){$(this.buttons).unblock()}},{key:"log",value:function log(message){var type=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"notice";if(!this.args.logging_enabled){return}if(type==="error"){return console.error(message)}return console.log(message)}}]);return WC_Square_Digital_Wallet_Handler}();window.WC_Square_Digital_Wallet_Handler=WC_Square_Digital_Wallet_Handler});
 
assets/js/frontend/wc-square-digital-wallet.min.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["wc-square-digital-wallet.js"],"names":["jQuery","document","ready","$","WC_Square_Digital_Wallet_Handler","args","payment_request","total_amount","total","amount","wallet","buttons","length","hide","build_digital_wallet","attach_page_events","block_ui","get_payment_request","then","response","JSON","parse","load_square_form","unblock_ui","message","log","context","addToCartButton","on","e","is","stopImmediatePropagation","window","alert","wc_add_to_cart_variation_params","i18n_unavailable_text","i18n_make_a_selection_text","add_to_cart","body","payment_form","destroy","SqPaymentForm","get_form_params","build","params","applicationId","application_id","locationId","location_id","autobuild","applePay","elementId","googlePay","callbacks","paymentFormLoaded","createPaymentRequest","create_payment_request","methodsSupported","methods","unsupportedReason","methods_supported","shippingContactChanged","shippingContact","done","handle_shipping_address_changed","shippingOptionChanged","shippingOption","handle_shipping_option_changed","cardNonceResponseReceived","errors","nonce","cardData","billingContact","handle_card_nonce_response","requestShippingAddress","hide_button_options","includes","show","Promise","resolve","reject","data","security","payment_request_nonce","product_data","get_product_data","extend","post","get_ajax_url","success","shipping_contact","recalculate_totals_nonce","recalculate_totals","error","shipping_option","id","render_errors","general_error","action","_wpnonce","process_checkout_nonce","billing_first_name","givenName","billing_last_name","familyName","billing_company","billing_email","email","billing_phone","phone","billing_country","country","toUpperCase","billing_address_1","addressLines","billing_address_2","billing_city","city","billing_state","region","billing_postcode","postalCode","shipping_first_name","shipping_last_name","shipping_company","shipping_country","shipping_address_1","shipping_address_2","shipping_city","shipping_state","shipping_postcode","shipping_method","order_comments","payment_method","ship_to_different_address","terms","last_4","exp_month","exp_year","billing_postal_code","digital_wallet_type","split","slice","join","is_3d_secure_enabled","self","verifyBuyer","get_verification_details","err","verificationResult","token","do_checkout","process_digital_wallet_checkout","location","redirect","render_errors_html","messages","verification_details","intent","currencyCode","product_id","val","attributes","find","each","index","select","attribute_name","attr","value","quantity","add_to_cart_nonce","result","request","ajax_url","replace","errors_html","remove","element","closest","before","animate","scrollTop","offset","top","error_message_html","block","overlayCSS","background","opacity","unblock","type","logging_enabled","console"],"mappings":"ioBAOAA,MAAM,CAAEC,QAAF,CAAN,CAAmBC,KAAnB,CAA0B,SAAEC,CAAF,CAAS,IAM5BC,CAAAA,gCAN4B,YAajC,0CAAaC,IAAb,CAAoB,wDACnB,KAAKA,IAAL,CAAYA,IAAZ,CACA,KAAKC,eAAL,CAAuBD,IAAI,CAACC,eAA5B,CACA,KAAKC,YAAL,CAAoBF,IAAI,CAACC,eAAL,CAAqBE,KAArB,CAA2BC,MAA/C,CACA,KAAKC,MAAL,CAAc,2BAAd,CACA,KAAKC,OAAL,CAAe,2BAAf,CAEA,GAAKR,CAAC,CAAE,KAAKO,MAAP,CAAD,CAAiBE,MAAjB,GAA4B,CAAjC,CAAqC,CACpC,MACA,CAEDT,CAAC,CAAE,KAAKO,MAAP,CAAD,CAAiBG,IAAjB,GACAV,CAAC,CAAE,KAAKQ,OAAP,CAAD,CAAkB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AAAA,OAAO,CAACpG,KAAR,CAAerE,OAAf,CACP,CAED,MAAOyK,CAAAA,OAAO,CAACxK,GAAR,CAAaD,OAAb,CACP,CAzkBgC,+CA4kBlCQ,MAAM,CAAC5B,gCAAP,CAA0CA,gCAC1C,CA7kBD","sourcesContent":["/* global wc_add_to_cart_variation_params, SqPaymentForm */\n\n/**\n * Square Credit Card Digital Wallet Handler class.\n *\n * @since 2.3\n */\njQuery( document ).ready( ( $ ) => {\n\t/**\n\t * Square Credit Card Digital Wallet Handler class.\n\t *\n\t * @since 2.3\n\t */\n\tclass WC_Square_Digital_Wallet_Handler {\n\t\t/**\n\t\t * Setup handler\n\t\t *\n\t\t * @param {Array} args\n\t\t * @since 2.3\n\t\t */\n\t\tconstructor( args ) {\n\t\t\tthis.args = args;\n\t\t\tthis.payment_request = args.payment_request;\n\t\t\tthis.total_amount = args.payment_request.total.amount;\n\t\t\tthis.wallet = '#wc-square-digital-wallet';\n\t\t\tthis.buttons = '.wc-square-wallet-buttons';\n\n\t\t\tif ( $( this.wallet ).length === 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t$( this.wallet ).hide();\n\t\t\t$( this.buttons ).hide();\n\n\t\t\tthis.build_digital_wallet();\n\t\t\tthis.attach_page_events();\n\t\t}\n\n\t\t/**\n\t\t * Fetch a new payment request object and reload the SqPaymentForm\n\t\t *\n\t\t * @since 2.3\n\t\t */\n\t\tbuild_digital_wallet() {\n\t\t\tthis.block_ui();\n\t\t\tthis.get_payment_request().then(\n\t\t\t\t( response ) => {\n\t\t\t\t\tthis.payment_request = JSON.parse( response );\n\t\t\t\t\tthis.total_amount = this.payment_request.total.amount;\n\t\t\t\t\tthis.load_square_form();\n\t\t\t\t\tthis.unblock_ui();\n\t\t\t\t},\n\t\t\t\t( message ) => {\n\t\t\t\t\tthis.log( '[Square] Could not build payment request. ' + message, 'error' );\n\t\t\t\t\t$( this.wallet ).hide();\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\t/**\n\t\t * Add page event listeners\n\t\t *\n\t\t * @since 2.3\n\t\t */\n\t\tattach_page_events() {\n\t\t\tif ( this.args.context === 'product' ) {\n\t\t\t\tconst addToCartButton = $( '.single_add_to_cart_button' );\n\n\t\t\t\t$( '#wc-square-apple-pay, #wc-square-google-pay' ).on( 'click', ( e ) => {\n\t\t\t\t\tif ( addToCartButton.is( '.disabled' ) ) {\n\t\t\t\t\t\te.stopImmediatePropagation();\n\n\t\t\t\t\t\tif ( addToCartButton.is( '.wc-variation-is-unavailable' ) ) {\n\t\t\t\t\t\t\twindow.alert( wc_add_to_cart_variation_params.i18n_unavailable_text );\n\t\t\t\t\t\t} else if ( addToCartButton.is( '.wc-variation-selection-needed' ) ) {\n\t\t\t\t\t\t\twindow.alert( wc_add_to_cart_variation_params.i18n_make_a_selection_text );\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.add_to_cart();\n\t\t\t\t} );\n\n\t\t\t\t$( document.body ).on( 'woocommerce_variation_has_changed', () => this.build_digital_wallet() );\n\n\t\t\t\t$( '.quantity' ).on( 'input', '.qty', () => this.build_digital_wallet() );\n\t\t\t}\n\n\t\t\tif ( this.args.context === 'cart' ) {\n\t\t\t\t$( document.body ).on( 'updated_cart_totals', () => this.build_digital_wallet() );\n\t\t\t}\n\n\t\t\tif ( this.args.context === 'checkout' ) {\n\t\t\t\t$( document.body ).on( 'updated_checkout', () => this.build_digital_wallet() );\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Load the digital wallet payment form\n\t\t *\n\t\t * @since 2.3\n\t\t */\n\t\tload_square_form() {\n\t\t\tif ( this.payment_form ) {\n\t\t\t\tthis.log( '[Square] Destroying digital wallet payment form' );\n\t\t\t\tthis.payment_form.destroy();\n\t\t\t}\n\n\t\t\tthis.log( '[Square] Building digital wallet payment form' );\n\t\t\tthis.payment_form = new SqPaymentForm( this.get_form_params() );\n\t\t\tthis.payment_form.build();\n\t\t}\n\n\t\t/**\n\t\t * Gets the Square payment form params.\n\t\t *\n\t\t * @since 2.3\n\t\t */\n\t\tget_form_params() {\n\t\t\tconst params = {\n\t\t\t\tapplicationId: this.args.application_id,\n\t\t\t\tlocationId: this.args.location_id,\n\t\t\t\tautobuild: false,\n\t\t\t\tapplePay: {\n\t\t\t\t\telementId: 'wc-square-apple-pay',\n\t\t\t\t},\n\t\t\t\tgooglePay: {\n\t\t\t\t\telementId: 'wc-square-google-pay',\n\t\t\t\t},\n\t\t\t\tcallbacks: {\n\t\t\t\t\tpaymentFormLoaded: () => this.unblock_ui(),\n\t\t\t\t\tcreatePaymentRequest: () => this.create_payment_request(),\n\t\t\t\t\tmethodsSupported: ( methods, unsupportedReason ) => this.methods_supported( methods, unsupportedReason ),\n\t\t\t\t\tshippingContactChanged: ( shippingContact, done ) => this.handle_shipping_address_changed( shippingContact, done ),\n\t\t\t\t\tshippingOptionChanged: ( shippingOption, done ) => this.handle_shipping_option_changed( shippingOption, done ),\n\t\t\t\t\tcardNonceResponseReceived: ( errors, nonce, cardData, billingContact, shippingContact, shippingOption ) => {\n\t\t\t\t\t\tthis.handle_card_nonce_response( errors, nonce, cardData, billingContact, shippingContact, shippingOption );\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\n\t\t\t// Fix console errors for Google Pay when there are no shipping options set. See note in Square documentation under shippingOptions: https://developer.squareup.com/docs/api/paymentform#paymentrequestfields.\n\t\t\tif ( this.payment_request.requestShippingAddress === false ) {\n\t\t\t\tdelete params.callbacks.shippingOptionChanged;\n\t\t\t}\n\n\t\t\t// Remove support for Google Pay and/or Apple Pay if chosen in settings.\n\t\t\tif ( this.args.hide_button_options.includes( 'google' ) ) {\n\t\t\t\tdelete params.googlePay;\n\t\t\t}\n\n\t\t\tif ( this.args.hide_button_options.includes( 'apple' ) ) {\n\t\t\t\tdelete params.applePay;\n\t\t\t}\n\n\t\t\treturn params;\n\t\t}\n\n\t\t/**\n\t\t * Sets the a payment request object for the Square Payment Form\n\t\t *\n\t\t * @since 2.3\n\t\t */\n\t\tcreate_payment_request() {\n\t\t\treturn this.payment_request;\n\t\t}\n\n\t\t/**\n\t\t * Check which methods are supported and show/hide the correct buttons on frontend\n\t\t * Reference: https://developer.squareup.com/docs/api/paymentform#methodssupported\n\t\t *\n\t\t * @param {Object} methods\n\t\t * @param {string} unsupportedReason\n\t\t *\n\t\t * @since 2.3\n\t\t */\n\t\tmethods_supported( methods, unsupportedReason ) {\n\t\t\tif ( methods.applePay === true || methods.googlePay === true ) {\n\t\t\t\tif ( methods.applePay === true ) {\n\t\t\t\t\t$( '#wc-square-apple-pay' ).show();\n\t\t\t\t}\n\n\t\t\t\tif ( methods.googlePay === true ) {\n\t\t\t\t\t$( '#wc-square-google-pay' ).show();\n\t\t\t\t}\n\n\t\t\t\t$( this.wallet ).show();\n\t\t\t} else {\n\t\t\t\tthis.log( unsupportedReason );\n\t\t\t}\n\t\t}\n\n\t\t/*\n\t\t * Get the payment request on a product page\n\t\t *\n\t\t * @since 2.3\n\t\t */\n\t\tget_payment_request() {\n\t\t\treturn new Promise( ( resolve, reject ) => {\n\t\t\t\tconst data = {\n\t\t\t\t\tcontext: this.args.context,\n\t\t\t\t\tsecurity: this.args.payment_request_nonce,\n\t\t\t\t};\n\n\t\t\t\tif ( this.args.context === 'product' ) {\n\t\t\t\t\tconst product_data = this.get_product_data();\n\t\t\t\t\t$.extend( data, product_data );\n\t\t\t\t}\n\t\t\t\t// retrieve a payment request object.\n\t\t\t\t$.post( this.get_ajax_url( 'get_payment_request' ), data, ( response ) => {\n\t\t\t\t\tif ( response.success ) {\n\t\t\t\t\t\treturn resolve( response.data );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn reject( response.data );\n\t\t\t\t} );\n\t\t\t} );\n\t\t}\n\n\t\t/*\n\t\t * Handle all shipping address recalculations in the Apple/Google Pay window\n\t\t *\n\t\t * Reference: https://developer.squareup.com/docs/api/paymentform#shippingcontactchanged\n\t\t *\n\t\t * @since 2.3\n\t\t */\n\t\thandle_shipping_address_changed( shippingContact, done ) {\n\t\t\tconst data = {\n\t\t\t\tcontext: this.args.context,\n\t\t\t\tshipping_contact: shippingContact.data,\n\t\t\t\tsecurity: this.args.recalculate_totals_nonce,\n\t\t\t};\n\n\t\t\t// send ajax request get_shipping_options.\n\t\t\tthis.recalculate_totals( data ).then( ( response ) => {\n\t\t\t\treturn done( response );\n\t\t\t}, () => {\n\t\t\t\treturn done( {\n\t\t\t\t\terror: 'Bad Request',\n\t\t\t\t} );\n\t\t\t} );\n\t\t}\n\n\t\t/*\n\t\t * Handle all shipping method changes in the Apple/Google Pay window\n\t\t *\n\t\t * Reference: https://developer.squareup.com/docs/api/paymentform#shippingoptionchanged\n\t\t *\n\t\t * @since 2.3\n\t\t */\n\t\thandle_shipping_option_changed( shippingOption, done ) {\n\t\t\tconst data = {\n\t\t\t\tcontext: this.args.context,\n\t\t\t\tshipping_option: shippingOption.data.id,\n\t\t\t\tsecurity: this.args.recalculate_totals_nonce,\n\t\t\t};\n\n\t\t\tthis.recalculate_totals( data ).then( ( response ) => {\n\t\t\t\treturn done( response );\n\t\t\t}, () => {\n\t\t\t\treturn done( {\n\t\t\t\t\terror: 'Bad Request',\n\t\t\t\t} );\n\t\t\t} );\n\t\t}\n\n\t\t/*\n\t\t * Handle the payment response.\n\t\t *\n\t\t * On success, set the checkout billing/shipping data and submit the checkout.\n\t\t *\n\t\t * @since 2.3\n\t\t */\n\t\thandle_card_nonce_response( errors, nonce, cardData, billingContact, shippingContact, shippingOption ) {\n\t\t\tif ( errors ) {\n\t\t\t\treturn this.render_errors( errors );\n\t\t\t}\n\n\t\t\tif ( ! nonce ) {\n\t\t\t\treturn this.render_errors( this.args.general_error );\n\t\t\t}\n\n\t\t\tthis.block_ui();\n\n\t\t\tconst data = {\n\t\t\t\taction: '',\n\t\t\t\t_wpnonce: this.args.process_checkout_nonce,\n\t\t\t\tbilling_first_name: billingContact.givenName ? billingContact.givenName : '',\n\t\t\t\tbilling_last_name: billingContact.familyName ? billingContact.familyName : '',\n\t\t\t\tbilling_company: '',\n\t\t\t\tbilling_email: shippingContact.email ? shippingContact.email : '',\n\t\t\t\tbilling_phone: shippingContact.phone ? shippingContact.phone : '',\n\t\t\t\tbilling_country: billingContact.country ? billingContact.country.toUpperCase() : '',\n\t\t\t\tbilling_address_1: billingContact.addressLines && billingContact.addressLines[ 0 ] ? billingContact.addressLines[ 0 ] : '',\n\t\t\t\tbilling_address_2: billingContact.addressLines && billingContact.addressLines[ 1 ] ? billingContact.addressLines[ 1 ] : '',\n\t\t\t\tbilling_city: billingContact.city ? billingContact.city : '',\n\t\t\t\tbilling_state: billingContact.region ? billingContact.region : '',\n\t\t\t\tbilling_postcode: billingContact.postalCode ? billingContact.postalCode : '',\n\t\t\t\tshipping_first_name: shippingContact.givenName ? shippingContact.givenName : '',\n\t\t\t\tshipping_last_name: shippingContact.familyName ? shippingContact.familyName : '',\n\t\t\t\tshipping_company: '',\n\t\t\t\tshipping_country: shippingContact.country ? shippingContact.country.toUpperCase() : '',\n\t\t\t\tshipping_address_1: shippingContact.addressLines && shippingContact.addressLines[ 0 ] ? shippingContact.addressLines[ 0 ] : '',\n\t\t\t\tshipping_address_2: shippingContact.addressLines && shippingContact.addressLines[ 1 ] ? shippingContact.addressLines[ 1 ] : '',\n\t\t\t\tshipping_city: shippingContact.city ? shippingContact.city : '',\n\t\t\t\tshipping_state: shippingContact.region ? shippingContact.region : '',\n\t\t\t\tshipping_postcode: shippingContact.postalCode ? shippingContact.postalCode : '',\n\t\t\t\tshipping_method: [ ! shippingOption ? null : shippingOption.id ],\n\t\t\t\torder_comments: '',\n\t\t\t\tpayment_method: 'square_credit_card',\n\t\t\t\tship_to_different_address: 1,\n\t\t\t\tterms: 1,\n\t\t\t\t'wc-square-credit-card-payment-nonce': nonce,\n\t\t\t\t'wc-square-credit-card-last-four': cardData.last_4 ? cardData.last_4 : null,\n\t\t\t\t'wc-square-credit-card-exp-month': cardData.exp_month ? cardData.exp_month : null,\n\t\t\t\t'wc-square-credit-card-exp-year': cardData.exp_year ? cardData.exp_year : null,\n\t\t\t\t'wc-square-credit-card-payment-postcode': cardData.billing_postal_code ? cardData.billing_postal_code : null,\n\t\t\t\t'wc-square-digital-wallet-type': cardData.digital_wallet_type,\n\t\t\t};\n\n\t\t\t// handle slightly different mapping for Google Pay (Google returns full name as a single string).\n\t\t\tif ( cardData.digital_wallet_type === 'GOOGLE_PAY' ) {\n\t\t\t\tif ( billingContact.givenName ) {\n\t\t\t\t\tdata.billing_first_name = billingContact.givenName.split( ' ' ).slice( 0, 1 ).join( ' ' );\n\t\t\t\t\tdata.billing_last_name = billingContact.givenName.split( ' ' ).slice( 1 ).join( ' ' );\n\t\t\t\t}\n\n\t\t\t\tif ( shippingContact.givenName ) {\n\t\t\t\t\tdata.shipping_last_name = shippingContact.givenName.split( ' ' ).slice( 0, 1 ).join( ' ' );\n\t\t\t\t\tdata.shipping_last_name = shippingContact.givenName.split( ' ' ).slice( 1 ).join( ' ' );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// if the billing_phone was not found on shippingContact, use the value on billingContact if that exists.\n\t\t\tif ( ! data.billing_phone && billingContact.phone ) {\n\t\t\t\tdata.billing_phone = billingContact.phone;\n\t\t\t}\n\n\t\t\t// if SCA is enabled, verify the buyer and add verification token to data.\n\t\t\tif ( this.args.is_3d_secure_enabled ) {\n\t\t\t\tthis.log( '3DS verification enabled. Verifying buyer' );\n\n\t\t\t\tvar self = this;\n\n\t\t\t\tthis.payment_form.verifyBuyer(\n\t\t\t\t\tnonce,\n\t\t\t\t\tself.get_verification_details( billingContact, shippingContact ),\n\t\t\t\t\tfunction(err, verificationResult) {\n\t\t\t\t\t\tif (err == null) {\n\t\t\t\t\t\t\t// SCA verification complete. Do checkout.\n\t\t\t\t\t\t\tself.log( '3DS verification successful' );\n\t\t\t\t\t\t\tdata['wc-square-credit-card-buyer-verification-token'] = verificationResult.token;\n\t\t\t\t\t\t\tself.do_checkout( data );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// SCA verification failed. Render errors.\n\t\t\t\t\t\t\tself.log( '3DS verification failed' );\n\t\t\t\t\t\t\tself.log(err);\n\t\t\t\t\t\t\tself.render_errors( [err.message] );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t// SCA not enabled. Do checkout.\n\t\t\t\tthis.do_checkout( data );\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Do Digital Wallet Checkout\n\t\t *\n\t\t * @since 2.4.2\n\t\t *\n\t\t * @param {Object} args\n\t\t */\n\t\tdo_checkout( data ) {\n\t\t\t// AJAX process checkout.\n\t\t\tthis.process_digital_wallet_checkout( data ).then(\n\t\t\t\t( response ) => {\n\t\t\t\t\twindow.location = response.redirect;\n\t\t\t\t},\n\t\t\t\t( response ) => {\n\t\t\t\t\tthis.log( response, 'error' );\n\t\t\t\t\tthis.render_errors_html( response.messages );\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\t/**\n\t\t * Gets a verification details object to be used in verifyBuyer()\n\t\t *\n\t\t * @since 2.4.2\n\t\t *\n\t\t * @param {Object} billingContact\n\t\t * @param {Object} shippingContact\n\t\t *\n\t\t * @return {Object} Verification details object.\n\t\t */\n\t\tget_verification_details( billingContact, shippingContact ) {\n\t\t\tconst verification_details = {\n\t\t\t\tintent: 'CHARGE',\n\t\t\t\tamount: this.total_amount,\n\t\t\t\tcurrencyCode: this.payment_request.currencyCode,\n\t\t\t\tbillingContact: {\n\t\t\t\t\tfamilyName: billingContact.familyName ? billingContact.familyName : '',\n\t\t\t\t\tgivenName: billingContact.givenName ? billingContact.givenName : '',\n\t\t\t\t\temail: shippingContact.email ? shippingContact.email : '',\n\t\t\t\t\tcountry: billingContact.country ? billingContact.country.toUpperCase() : '',\n\t\t\t\t\tregion: billingContact.region ? billingContact.region : '',\n\t\t\t\t\tcity: billingContact.city ? billingContact.city : '',\n\t\t\t\t\tpostalCode: billingContact.postalCode ? billingContact.postalCode : '',\n\t\t\t\t\tphone: shippingContact.phone ? shippingContact.phone : '',\n\t\t\t\t\taddressLines: billingContact.addressLines ? billingContact.addressLines : '',\n\t\t\t\t},\n\t\t\t}\n\n\t\t\tthis.log( verification_details );\n\n\t\t\treturn verification_details;\n\t\t}\n\n\t\t/*\n\t\t * Recalculate totals\n\t\t *\n\t\t * @since 2.3\n\t\t */\n\t\trecalculate_totals( data ) {\n\t\t\treturn new Promise( ( resolve, reject ) => {\n\t\t\t\treturn $.post( this.get_ajax_url( 'recalculate_totals' ), data, ( response ) => {\n\t\t\t\t\tif ( response.success ) {\n\t\t\t\t\t\tthis.total_amount = response.data.total.amount;\n\t\t\t\t\t\treturn resolve( response.data );\n\t\t\t\t\t}\n\t\t\t\t\treturn reject( response.data );\n\t\t\t\t} );\n\t\t\t} );\n\t\t}\n\n\t\t/*\n\t\t * Get the product data for building the payment request on the product page\n\t\t *\n\t\t * @since 2.3\n\t\t */\n\t\tget_product_data() {\n\t\t\tlet product_id = $( '.single_add_to_cart_button' ).val();\n\n\t\t\tconst attributes = {};\n\n\t\t\t// Check if product is a variable product.\n\t\t\tif ( $( '.single_variation_wrap' ).length ) {\n\t\t\t\tproduct_id = $( '.single_variation_wrap' ).find( 'input[name=\"product_id\"]' ).val();\n\t\t\t\tif ( $( '.variations_form' ).length ) {\n\t\t\t\t\t$( '.variations_form' ).find( '.variations select' ).each( ( index, select ) => {\n\t\t\t\t\t\tconst attribute_name = $( select ).data( 'attribute_name' ) || $( select ).attr( 'name' );\n\t\t\t\t\t\tconst value = $( select ).val() || '';\n\t\t\t\t\t\treturn attributes[ attribute_name ] = value;\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tproduct_id,\n\t\t\t\tquantity: $( '.quantity .qty' ).val(),\n\t\t\t\tattributes,\n\t\t\t};\n\t\t}\n\n\t\t/*\n\t\t * Add the product to the cart\n\t\t *\n\t\t * @since 2.3\n\t\t */\n\t\tadd_to_cart() {\n\t\t\tconst data = {\n\t\t\t\tsecurity: this.args.add_to_cart_nonce,\n\t\t\t};\n\t\t\tconst product_data = this.get_product_data();\n\t\t\t$.extend( data, product_data );\n\n\t\t\t// retrieve a payment request object.\n\t\t\t$.post( this.get_ajax_url( 'add_to_cart' ), data, ( response ) => {\n\t\t\t\tif ( response.error ) {\n\t\t\t\t\treturn window.alert( response.data );\n\t\t\t\t}\n\n\t\t\t\tconst data = JSON.parse( response.data );\n\t\t\t\tthis.payment_request = data.payment_request;\n\t\t\t\tthis.args.payment_request_nonce = data.payment_request_nonce;\n\t\t\t\tthis.args.add_to_cart_nonce = data.add_to_cart_nonce;\n\t\t\t\tthis.args.recalculate_totals_nonce = data.recalculate_totals_nonce;\n\t\t\t\tthis.args.process_checkout_nonce = data.process_checkout_nonce;\n\t\t\t} );\n\t\t}\n\n\t\t/*\n\t\t * Process the digital wallet checkout\n\t\t *\n\t\t * @since 2.3\n\t\t */\n\t\tprocess_digital_wallet_checkout( data ) {\n\t\t\treturn new Promise( ( resolve, reject ) => {\n\t\t\t\t$.post( this.get_ajax_url( 'process_checkout' ), data, ( response ) => {\n\t\t\t\t\tif ( response.result === 'success' ) {\n\t\t\t\t\t\treturn resolve( response );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn reject( response );\n\t\t\t\t} );\n\t\t\t} );\n\t\t}\n\n\t\t/*\n\t\t * Helper function to return the ajax URL for the given request/action\n\t\t *\n\t\t * @since 2.3\n\t\t */\n\t\tget_ajax_url( request ) {\n\t\t\treturn this.args.ajax_url.replace( '%%endpoint%%', 'square_digital_wallet_' + request );\n\t\t}\n\n\t\t/*\n\t\t * Renders errors given the error message HTML\n\t\t *\n\t\t * @since 2.3\n\t\t */\n\t\trender_errors_html( errors_html ) {\n\t\t\t// hide and remove any previous errors.\n\t\t\t$( '.woocommerce-error, .woocommerce-message' ).remove();\n\n\t\t\tconst element = this.args.context === 'product' ? $( '.product' ) : $( '.shop_table.cart' ).closest( 'form' );\n\n\t\t\t// add errors\n\t\t\telement.before( errors_html );\n\n\t\t\t// unblock UI\n\t\t\tthis.unblock_ui();\n\n\t\t\t// scroll to top\n\t\t\t$( 'html, body' ).animate( {\n\t\t\t\tscrollTop: element.offset().top - 100,\n\t\t\t}, 1000 );\n\t\t}\n\n\t\t/*\n\t\t * Renders errors\n\t\t *\n\t\t * @since 2.3\n\t\t */\n\t\trender_errors( errors ) {\n\t\t\tconst error_message_html = '<ul class=\"woocommerce-error\"><li>' + errors.join( '</li><li>' ) + '</li></ul>';\n\t\t\tthis.render_errors_html( error_message_html );\n\t\t}\n\n\t\t/*\n\t\t * Block the Apple Pay and Google Pay buttons from being clicked which processing certain actions\n\t\t *\n\t\t * @since 2.3\n\t\t */\n\t\tblock_ui() {\n\t\t\t$( this.buttons ).block( {\n\t\t\t\tmessage: null,\n\t\t\t\toverlayCSS: {\n\t\t\t\t\tbackground: '#fff',\n\t\t\t\t\topacity: 0.6,\n\t\t\t\t},\n\t\t\t} );\n\t\t}\n\n\t\t/*\n\t\t * Unblock the wallet buttons\n\t\t *\n\t\t * @since 2.3\n\t\t */\n\t\tunblock_ui() {\n\t\t\t$( this.buttons ).unblock();\n\t\t}\n\n\t\t/*\n\t\t * Logs messages to the console when logging is turned on in the settings\n\t\t *\n\t\t * @since 2.3\n\t\t */\n\t\tlog( message, type = 'notice' ) {\n\t\t\t// if logging is disabled, bail.\n\t\t\tif ( ! this.args.logging_enabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( type === 'error' ) {\n\t\t\t\treturn console.error( message );\n\t\t\t}\n\n\t\t\treturn console.log( message );\n\t\t}\n\t}\n\n\twindow.WC_Square_Digital_Wallet_Handler = WC_Square_Digital_Wallet_Handler;\n} );\n"],"file":"wc-square-digital-wallet.min.js"}
 
assets/js/frontend/wc-square.js DELETED
@@ -1,819 +0,0 @@
1
- /* global wc_cart_fragments_params */
2
-
3
- /**
4
- * WooCommerce Square Payment Form handler.
5
- *
6
- * @since 2.0.0
7
- */
8
- jQuery( document ).ready( ( $ ) => {
9
- /**
10
- * Square Credit Card Payment Form Handler class.
11
- *
12
- * @since 2.0.0
13
- */
14
- class WC_Square_Payment_Form_Handler {
15
- /**
16
- * Setup handler.
17
- *
18
- * @since 2.3.2-1
19
- *
20
- * @param {Object} args
21
- */
22
- constructor( args ) {
23
- this.id = args.id;
24
- this.id_dasherized = args.id_dasherized;
25
- this.csc_required = args.csc_required;
26
- this.enabled_card_types = args.enabled_card_types;
27
- this.square_card_types = args.square_card_types;
28
- this.ajax_log_nonce = args.ajax_log_nonce;
29
- this.ajax_url = args.ajax_url;
30
- this.application_id = args.application_id;
31
- this.currency_code = args.currency_code;
32
- this.general_error = args.general_error;
33
- this.input_styles = args.input_styles;
34
- this.is_3ds_enabled = args.is_3d_secure_enabled;
35
- this.is_add_payment_method_page = args.is_add_payment_method_page;
36
- this.is_checkout_registration_enabled = args.is_checkout_registration_enabled;
37
- this.is_user_logged_in = args.is_user_logged_in;
38
- this.location_id = args.location_id;
39
- this.logging_enabled = args.logging_enabled;
40
- this.ajax_wc_checkout_validate_nonce = args.ajax_wc_checkout_validate_nonce;
41
- this.is_manual_order_payment = args.is_manual_order_payment;
42
- this.current_postal_code_value = '';
43
-
44
- if ( $( 'form.checkout' ).length ) {
45
- this.form = $( 'form.checkout' );
46
- this.handle_checkout_page();
47
- } else if ( $( 'form#order_review' ).length ) {
48
- this.form = $( 'form#order_review' );
49
- this.handle_pay_page();
50
- } else if ( $( 'form#add_payment_method' ).length ) {
51
- this.form = $( 'form#add_payment_method' );
52
- this.handle_add_payment_method_page();
53
- } else {
54
- this.log( 'No payment form found!' );
55
- return;
56
- }
57
-
58
- // localized error messages.
59
- this.params = window.sv_wc_payment_gateway_payment_form_params;
60
-
61
- // unblock the UI and clear any payment nonces when a server-side error occurs.
62
- $( document.body ).on( 'checkout_error', () => {
63
- $( 'input[name=wc-square-credit-card-payment-nonce]' ).val( '' );
64
- $( 'input[name=wc-square-credit-card-buyer-verification-token]' ).val( '' );
65
- } );
66
-
67
- $( document.body ).on( 'click', `#payment_method_${ this.id }`, () => {
68
- if ( this.payment_form ) {
69
- this.log( 'Recalculating payment form size' );
70
- this.payment_form.recalculateSize();
71
- }
72
- } );
73
- }
74
-
75
- /**
76
- * Public: Handle required actions on the checkout page.
77
- */
78
- handle_checkout_page() {
79
- // updated payment fields jQuery object on each checkout update (prevents stale data).
80
- $( document.body ).on( 'updated_checkout', () => this.set_payment_fields() );
81
-
82
- // handle saved payment methods note on the checkout page.
83
- // this is bound to `updated_checkout` so it fires even when other parts of the checkout are changed.
84
- $( document.body ).on( 'updated_checkout', () => this.handle_saved_payment_methods() );
85
-
86
- // validate payment data before order is submitted.
87
- this.form.on( `checkout_place_order_${ this.id }`, () => this.validate_payment_data() );
88
- }
89
-
90
- /**
91
- * Public: Handle associated actions for saved payment methods.
92
- */
93
- handle_saved_payment_methods() {
94
- // make available inside change events.
95
- const id_dasherized = this.id_dasherized;
96
- const form_handler = this;
97
- const $new_payment_method_selection = $( `div.js-wc-${ id_dasherized }-new-payment-method-form` );
98
-
99
- // show/hide the saved payment methods when a saved payment method is de-selected/selected.
100
- $( `input.js-wc-${ this.id_dasherized }-payment-token` ).on( 'change', () => {
101
- const tokenized_payment_method_selected = $( `input.js-wc-${ id_dasherized }-payment-token:checked` ).val();
102
-
103
- if ( tokenized_payment_method_selected ) {
104
- // using an existing tokenized payment method, hide the 'new method' fields.
105
- $new_payment_method_selection.slideUp( 200 );
106
- } else {
107
- // use new payment method, display the 'new method' fields.
108
- $new_payment_method_selection.slideDown( 200 );
109
- }
110
- } ).trigger( 'change' );
111
-
112
- // display the 'save payment method' option for guest checkouts if the 'create account' option is checked
113
- // but only hide the input if there is a 'create account' checkbox (some themes just display the password).
114
- $( 'input#createaccount' ).on( 'change', ( e ) => {
115
- if ( $( e.target ).is( ':checked' ) ) {
116
- form_handler.show_save_payment_checkbox( id_dasherized );
117
- } else {
118
- form_handler.hide_save_payment_checkbox( id_dasherized );
119
- }
120
- } );
121
-
122
- if ( ! $( 'input#createaccount' ).is( ':checked' ) ) {
123
- $( 'input#createaccount' ).trigger( 'change' );
124
- }
125
-
126
- // hide the 'save payment method' when account creation is not enabled and customer is not logged in.
127
- if ( ! this.is_user_logged_in && ! this.is_checkout_registration_enabled ) {
128
- this.hide_save_payment_checkbox( id_dasherized );
129
- }
130
- }
131
-
132
- /**
133
- * Public: Handle required actions on the Order > Pay page.
134
- */
135
- handle_pay_page() {
136
- this.set_payment_fields();
137
-
138
- // handle saved payment methods.
139
- this.handle_saved_payment_methods();
140
-
141
- const self = this;
142
-
143
- // validate payment data before order is submitted.
144
- // but only when one of our payment gateways is selected.
145
- this.form.on( 'submit', function() {
146
- if ( $( '#order_review input[name=payment_method]:checked' ).val() === self.id ) {
147
- return self.validate_payment_data();
148
- }
149
- } );
150
- }
151
-
152
- /**
153
- * Public: Handle required actions on the Add Payment Method page.
154
- */
155
- handle_add_payment_method_page() {
156
- this.set_payment_fields();
157
-
158
- const self = this;
159
-
160
- // validate payment data before order is submitted.
161
- // but only when one of our payment gateways is selected.
162
- this.form.on( 'submit', function() {
163
- if ( $( '#add_payment_method input[name=payment_method]:checked' ).val() === self.id ) {
164
- return self.validate_payment_data();
165
- }
166
- } );
167
- }
168
-
169
- /**
170
- * Sets up the Square payment fields.
171
- *
172
- * @since 2.0.0
173
- */
174
- set_payment_fields() {
175
- if ( ! $( `#wc-${ this.id_dasherized }-account-number-hosted` ).length ) {
176
- return;
177
- }
178
-
179
- if ( $( `#wc-${ this.id_dasherized }-account-number-hosted` ).is( 'iframe' ) ) {
180
- this.log( 'Re-adding payment form' );
181
-
182
- for ( const [ _, field ] of Object.entries( this.form_fields ) ) { // eslint-disable-line no-unused-vars
183
- $( field.attr( 'id' ) ).replaceWith( field );
184
- }
185
-
186
- this.handle_form_loaded();
187
- } else {
188
- if ( this.payment_form ) {
189
- this.log( 'Destroying payment form' );
190
- this.payment_form.destroy();
191
- this.payment_form = null;
192
- }
193
-
194
- this.log( 'Building payment form' );
195
-
196
- this.payment_form = new SqPaymentForm( this.get_form_params() ); // eslint-disable-line no-undef
197
-
198
- this.payment_form.build();
199
- }
200
- }
201
-
202
- /**
203
- * Gets the Square payment form params.
204
- *
205
- * @since 2.0.0
206
- *
207
- * @return {Object} Form params.
208
- */
209
- get_form_params() {
210
- this.form_fields = {
211
- card_number: $( `#wc-${ this.id_dasherized }-account-number-hosted` ),
212
- expiration: $( `#wc-${ this.id_dasherized }-expiry-hosted` ),
213
- csc: $( `#wc-${ this.id_dasherized }-csc-hosted` ),
214
- postal_code: $( `#wc-${ this.id_dasherized }-postal-code-hosted` ),
215
- };
216
-
217
- return {
218
- applicationId: this.application_id,
219
- locationId: this.location_id,
220
- cardNumber: {
221
- elementId: this.form_fields.card_number.attr( 'id' ),
222
- placeholder: this.form_fields.card_number.data( 'placeholder' ),
223
- },
224
- expirationDate: {
225
- elementId: this.form_fields.expiration.attr( 'id' ),
226
- placeholder: this.form_fields.expiration.data( 'placeholder' ),
227
- },
228
- cvv: {
229
- elementId: this.form_fields.csc.attr( 'id' ),
230
- placeholder: this.form_fields.csc.data( 'placeholder' ),
231
- },
232
- postalCode: {
233
- elementId: this.form_fields.postal_code.attr( 'id' ),
234
- placeholder: this.form_fields.postal_code.data( 'placeholder' ),
235
- },
236
- inputClass: `wc-${ this.id_dasherized }-payment-field`,
237
- inputStyles: this.input_styles,
238
- callbacks: {
239
- inputEventReceived: ( e ) => this.handle_input_event( e ),
240
- cardNonceResponseReceived: ( errors, nonce, cardData ) => this.handle_card_nonce_response( errors, nonce, cardData ),
241
- unsupportedBrowserDetected: () => this.handle_unsupported_browser(),
242
- paymentFormLoaded: () => this.handle_form_loaded(),
243
- },
244
- };
245
- }
246
-
247
- /**
248
- * Handles when the payment form is fully loaded.
249
- *
250
- * @since 2.0.0
251
- */
252
- handle_form_loaded() {
253
- this.log( 'Payment form loaded' );
254
-
255
- this.payment_form.setPostalCode( $( '#billing_postcode' ).val() );
256
-
257
- // hide the postcode field on the checkout page or if it already has a value.
258
- if ( $( 'form.checkout' ).length || $( '#billing_postcode' ).val() ) {
259
- $( '.wc-square-credit-card-card-postal-code-parent' ).addClass( 'hidden' );
260
- }
261
- }
262
-
263
- /**
264
- * Handles payment form input changes.
265
- *
266
- * @since 2.0.0
267
- *
268
- * @param {Object} e
269
- */
270
- handle_input_event( e ) {
271
- const $input = $( '#' + e.elementId );
272
-
273
- if ( e.eventType === 'cardBrandChanged' ) {
274
- this.handle_card_brand_change( e.cardBrand, $input );
275
- }
276
-
277
- /**
278
- * @see https://github.com/woocommerce/woocommerce-square/issues/646
279
- */
280
- if ( e.field === 'postalCode' ) {
281
- /**
282
- * Save postal code in the `current_postal_code_value`
283
- * variable whenever it is updated.
284
- */
285
- this.current_postal_code_value = e.postalCodeValue;
286
-
287
- /**
288
- * Trim and set the postal code from the
289
- * `current_postal_code_value` on blur.
290
- */
291
- if ( e.eventType === 'focusClassRemoved' ) {
292
- this.payment_form.setPostalCode(
293
- this.current_postal_code_value.trim()
294
- );
295
- }
296
- }
297
- }
298
-
299
- /**
300
- * Handles card number brand changes.
301
- *
302
- * @since 2.0.0
303
- *
304
- * @param {string} brand
305
- * @param {Object} $input
306
- */
307
- handle_card_brand_change( brand, $input ) {
308
- this.log( `Card brand changed to ${ brand }` );
309
-
310
- // clear any existing card type class
311
- $input.attr( 'class', ( i, c ) => {
312
- return c.replace( /(^|\s)card-type-\S+/g, '' );
313
- } );
314
-
315
- let card_class = 'plain';
316
-
317
- if ( null === brand || 'unknown' === brand ) {
318
- brand = '';
319
- }
320
-
321
- if ( null !== this.square_card_types[ brand ] ) {
322
- brand = this.square_card_types[ brand ];
323
- }
324
-
325
- if ( brand && ! this.enabled_card_types.includes( brand ) ) {
326
- card_class = 'invalid';
327
- } else {
328
- card_class = brand;
329
- }
330
-
331
- $( `input[name=wc-${ this.id_dasherized }-card-type]` ).val( brand );
332
-
333
- $input.addClass( `card-type-${ card_class }` );
334
- }
335
-
336
- /**
337
- * Used to request a card nonce and submit the form.
338
- *
339
- * @since 2.0.0
340
- */
341
- validate_payment_data() {
342
- if ( this.form.is( '.processing' ) ) {
343
- // bail when already processing.
344
- return false;
345
- }
346
-
347
- // let through if nonce is already present - nonce is only present on non-tokenized payments.
348
- if ( this.has_nonce() ) {
349
- this.log( 'Payment nonce present, placing order' );
350
- return true;
351
- }
352
-
353
- const tokenized_card_id = this.get_tokenized_payment_method_id();
354
-
355
- if ( tokenized_card_id ) {
356
- if ( ! this.is_3ds_enabled ) {
357
- // if 3DS is disabled and paying with a saved method, no further validation needed.
358
- return true;
359
- }
360
-
361
- if ( this.has_verification_token() ) {
362
- this.log( 'Tokenized payment verification token present, placing order' );
363
- return true;
364
- }
365
-
366
- this.log( 'Requesting verification token for tokenized payment' );
367
-
368
- this.block_ui();
369
- this.payment_form.verifyBuyer( tokenized_card_id, this.get_verification_details(), this.handle_verify_buyer_response.bind( this ) );
370
- return false;
371
- }
372
-
373
- this.log( 'Requesting payment nonce' );
374
- this.block_ui();
375
- this.payment_form.requestCardNonce();
376
- return false;
377
- }
378
-
379
- /**
380
- * Gets the selected tokenized payment method ID, if there is one.
381
- *
382
- * @since 2.1.0
383
- *
384
- * @return {string} Tokenized payment method ID.
385
- */
386
- get_tokenized_payment_method_id() {
387
- return $( `.payment_method_${ this.id }` ).find( '.js-wc-square-credit-card-payment-token:checked' ).val();
388
- }
389
-
390
- /**
391
- * Handles the Square payment form card nonce response.
392
- *
393
- * @since 2.1.0
394
- *
395
- * @param {Object} errors Validation errors, if any.
396
- * @param {string} nonce Payment nonce.
397
- * @param {Object} cardData Non-confidential info about the card used.
398
- */
399
- handle_card_nonce_response( errors, nonce, cardData ) {
400
- // if we have real errors to display from Square.
401
- if ( errors ) {
402
- return this.handle_errors( errors );
403
- }
404
-
405
- // no errors, but also no payment data.
406
- if ( ! nonce ) {
407
- const message = 'Nonce is missing from the Square response';
408
-
409
- this.log( message, 'error' );
410
- this.log_data( message, 'response' );
411
- return this.handle_errors();
412
- }
413
-
414
- // if we made it this far, we have payment data.
415
- this.log( 'Card data received' );
416
- this.log( cardData );
417
- this.log_data( cardData, 'response' );
418
-
419
- if ( cardData.last_4 ) {
420
- $( `input[name=wc-${ this.id_dasherized }-last-four]` ).val( cardData.last_4 );
421
- }
422
-
423
- if ( cardData.exp_month ) {
424
- $( `input[name=wc-${ this.id_dasherized }-exp-month]` ).val( cardData.exp_month );
425
- }
426
-
427
- if ( cardData.exp_year ) {
428
- $( `input[name=wc-${ this.id_dasherized }-exp-year]` ).val( cardData.exp_year );
429
- }
430
-
431
- if ( cardData.billing_postal_code ) {
432
- $( `input[name=wc-${ this.id_dasherized }-payment-postcode]` ).val( cardData.billing_postal_code );
433
- }
434
-
435
- // payment nonce data.
436
- $( `input[name=wc-${ this.id_dasherized }-payment-nonce]` ).val( nonce );
437
-
438
- // if 3ds is enabled, we need to verify the buyer and record the verification token before continuing.
439
- if ( this.is_3ds_enabled ) {
440
- this.log( 'Verifying buyer' );
441
-
442
- this.payment_form.verifyBuyer( nonce, this.get_verification_details(), this.handle_verify_buyer_response.bind( this ) );
443
-
444
- return;
445
- }
446
-
447
- // now that we have a nonce, resubmit the form.
448
- this.form.trigger( 'submit' );
449
- }
450
-
451
- /**
452
- * Handles the response from a call to verifyBuyer()
453
- *
454
- * @since 2.1.0
455
- *
456
- * @param {Object} errors Verification errors, if any.
457
- * @param {Object} verification_result Results of verification.
458
- */
459
- handle_verify_buyer_response( errors, verification_result ) {
460
- if ( errors ) {
461
- $( errors ).each( ( index, error ) => {
462
- if ( ! error.field ) {
463
- error.field = 'none';
464
- }
465
- } );
466
-
467
- return this.handle_errors( errors );
468
- }
469
-
470
- // no errors, but also no verification token.
471
- if ( ! verification_result || ! verification_result.token ) {
472
- const message = 'Verification token is missing from the Square response';
473
-
474
- this.log( message, 'error' );
475
- this.log_data( message, 'response' );
476
-
477
- return this.handle_errors();
478
- }
479
-
480
- this.log( 'Verification result received' );
481
- this.log( verification_result );
482
-
483
- $( `input[name=wc-${ this.id_dasherized }-buyer-verification-token]` ).val( verification_result.token );
484
-
485
- this.form.trigger( 'submit' );
486
- }
487
-
488
- /**
489
- * Gets a verification details object to be used in verifyBuyer()
490
- *
491
- * @since 2.1.0
492
- *
493
- * @return {Object} Verification details object.
494
- */
495
- get_verification_details() {
496
- const verification_details = {
497
- billingContact: {
498
- familyName: $( '#billing_last_name' ).val() || '',
499
- givenName: $( '#billing_first_name' ).val() || '',
500
- email: $( '#billing_email' ).val() || '',
501
- country: $( '#billing_country' ).val() || '',
502
- region: $( '#billing_state' ).val() || '',
503
- city: $( '#billing_city' ).val() || '',
504
- postalCode: $( '#billing_postcode' ).val() || '',
505
- phone: $( '#billing_phone' ).val() || '',
506
- addressLines: [ $( '#billing_address_1' ).val() || '', $( '#billing_address_2' ).val() || '' ],
507
- },
508
- intent: this.get_intent(),
509
- };
510
-
511
- if ( 'CHARGE' === verification_details.intent ) {
512
- verification_details.amount = this.get_amount();
513
- verification_details.currencyCode = this.currency_code;
514
- }
515
-
516
- this.log( verification_details );
517
-
518
- return verification_details;
519
- }
520
-
521
- /**
522
- * Gets the intent of this processing - either 'CHARGE' or 'STORE'
523
- *
524
- * The gateway stores cards before processing a payment, so this checks whether the customer checked "save method"
525
- * at checkout, and isn't otherwise using a saved method already.
526
- *
527
- * @since 2.1.0
528
- *
529
- * @return {string} {'CHARGE'|'STORE'}
530
- */
531
- get_intent() {
532
- const $save_method_input = $( '#wc-square-credit-card-tokenize-payment-method' );
533
-
534
- let save_payment_method;
535
-
536
- if ( $save_method_input.is( 'input:checkbox' ) ) {
537
- save_payment_method = $save_method_input.is( ':checked' );
538
- } else {
539
- save_payment_method = 'true' === $save_method_input.val();
540
- }
541
-
542
- if ( ! this.get_tokenized_payment_method_id() && save_payment_method ) {
543
- return 'STORE';
544
- }
545
-
546
- return 'CHARGE';
547
- }
548
-
549
- /**
550
- * Gets the amount of this payment.
551
- *
552
- * @since 2.1.0
553
- *
554
- * @return {string} Payment amount.
555
- */
556
- get_amount() {
557
- return $( `input[name=wc-${ this.id_dasherized }-amount]` ).val();
558
- }
559
-
560
- /**
561
- * Handles unsupported browsers.
562
- *
563
- * @since 2.0.0
564
- */
565
- handle_unsupported_browser() {}
566
-
567
- /**
568
- * Handle error data.
569
- *
570
- * @since 2.0.0
571
- *
572
- * @param {Object|null} errors
573
- */
574
- handle_errors( errors = null ) {
575
- this.log( 'Error getting payment data', 'error' );
576
-
577
- // clear any previous nonces
578
- $( 'input[name=wc-square-credit-card-payment-nonce]' ).val( '' );
579
- $( 'input[name=wc-square-credit-card-buyer-verification-token]' ).val( '' );
580
-
581
- const messages = [];
582
-
583
- if ( errors ) {
584
- const field_order = [ 'none', 'cardNumber', 'expirationDate', 'cvv', 'postalCode' ];
585
-
586
- if ( errors.length >= 1 ) {
587
- // sort based on the field order without the brackets around a.field and b.field.
588
- // the precedence is different and gives different results.
589
- errors.sort( ( a, b ) => {
590
- return field_order.indexOf( a.field ) - field_order.indexOf( b.field );
591
- } );
592
- }
593
-
594
- $( errors ).each( ( index, error ) => {
595
- // only display the errors that can be helped by the customer.
596
- if ( 'UNSUPPORTED_CARD_BRAND' === error.type || 'VALIDATION_ERROR' === error.type ) {
597
- // To avoid confusion between CSC used in the frontend and CVV that is used in the error message.
598
- return messages.push( error.message.replace( /CVV/, 'CSC' ) );
599
- }
600
-
601
- // otherwise, log more serious errors to the debug log.
602
- return this.log_data( errors, 'response' );
603
- } );
604
- }
605
-
606
- // if no specific messages are set, display a general error.
607
- if ( messages.length === 0 ) {
608
- messages.push( this.general_error );
609
- }
610
-
611
- // Conditionally process error rendering.
612
- if ( ! this.is_add_payment_method_page && ! this.is_manual_order_payment ) {
613
- this.render_checkout_errors( messages );
614
- } else {
615
- this.render_errors( messages );
616
- }
617
-
618
- this.unblock_ui();
619
- }
620
-
621
- /**
622
- * Public: Render any new errors and bring them into the viewport.
623
- *
624
- * @param {Array} errors
625
- */
626
- render_errors( errors ) {
627
- // hide and remove any previous errors.
628
- $( '.woocommerce-error, .woocommerce-message' ).remove();
629
-
630
- // add errors.
631
- this.form.prepend( '<ul class="woocommerce-error"><li>' + errors.join( '</li><li>' ) + '</li></ul>' );
632
-
633
- // unblock UI
634
- this.form.removeClass( 'processing' ).unblock();
635
- this.form.find( '.input-text, select' ).trigger( 'blur' );
636
-
637
- // scroll to top
638
- $( 'html, body' ).animate( {
639
- scrollTop: this.form.offset().top - 100,
640
- }, 1000 );
641
- }
642
-
643
- /**
644
- * Blocks the payment form UI.
645
- *
646
- * @since 3.0.0
647
- */
648
- block_ui() {
649
- this.form.block( {
650
- message: null,
651
- overlayCSS: {
652
- background: '#fff',
653
- opacity: 0.6,
654
- },
655
- } );
656
- }
657
-
658
- /**
659
- * Unblocks the payment form UI.
660
- *
661
- * @since 3.0.0
662
- */
663
- unblock_ui() {
664
- return this.form.unblock();
665
- }
666
-
667
- /**
668
- * Hides save payment method checkbox.
669
- *
670
- * @since 2.1.2
671
- *
672
- * @param {string} id_dasherized
673
- */
674
- hide_save_payment_checkbox( id_dasherized ) {
675
- const $parent_row = $( `input.js-wc-${ id_dasherized }-tokenize-payment-method` ).closest( 'p.form-row' );
676
-
677
- $parent_row.hide();
678
- $parent_row.next().hide();
679
- }
680
-
681
- /**
682
- * Shows save payment method checkbox.
683
- *
684
- * @since 2.1.2
685
- *
686
- * @param {string} id_dasherized
687
- */
688
- show_save_payment_checkbox( id_dasherized ) {
689
- const $parent_row = $( `input.js-wc-${ id_dasherized }-tokenize-payment-method` ).closest( 'p.form-row' );
690
-
691
- $parent_row.slideDown();
692
- $parent_row.next().show();
693
- }
694
-
695
- /**
696
- * Determines if a nonce is present in the hidden input.
697
- *
698
- * @since 2.0.0
699
- *
700
- * @return {boolean} True if nonce is present, otherwise false.
701
- */
702
- has_nonce() {
703
- return $( `input[name=wc-${ this.id_dasherized }-payment-nonce]` ).val();
704
- }
705
-
706
- /**
707
- * Determines if a verification token is present in the hidden input.
708
- *
709
- * @since 2.1.0
710
- *
711
- * @return {boolean} True if verification token is present, otherwise false.
712
- */
713
- has_verification_token() {
714
- return $( `input[name=wc-${ this.id_dasherized }-buyer-verification-token]` ).val();
715
- }
716
-
717
- /**
718
- * Logs data to the debug log via AJAX.
719
- *
720
- * @since 2.0.0
721
- *
722
- * @param {Object} data Request data.
723
- * @param {string} type Data type.
724
- */
725
- log_data( data, type ) {
726
- // if logging is disabled, bail.
727
- if ( ! this.logging_enabled ) {
728
- return;
729
- }
730
-
731
- const ajax_data = {
732
- action: 'wc_' + this.id + '_log_js_data',
733
- security: this.ajax_log_nonce,
734
- type,
735
- data,
736
- };
737
-
738
- $.ajax( {
739
- url: this.ajax_url,
740
- data: ajax_data,
741
- } );
742
- }
743
-
744
- /**
745
- * Logs any messages or errors to the console.
746
- *
747
- * @since 2.0.0
748
- *
749
- * @param {string} message
750
- * @param {string} type Data type.
751
- */
752
- log( message, type = 'notice' ) {
753
- // if logging is disabled, bail.
754
- if ( ! this.logging_enabled ) {
755
- return;
756
- }
757
-
758
- if ( 'error' === type ) {
759
- console.error( 'Square Error: ' + message );
760
- } else {
761
- console.log( 'Square: ' + message );
762
- }
763
- }
764
-
765
- /**
766
- * AJAX validate WooCommerce form data.
767
- *
768
- * Triggered only if errors are present on Square payment form.
769
- *
770
- * @since 2.2
771
- *
772
- * @param {Array} square_errors Square validation errors.
773
- */
774
- render_checkout_errors( square_errors ) {
775
- const ajax_url = wc_cart_fragments_params.wc_ajax_url.toString().replace( '%%endpoint%%', this.id + '_checkout_handler' );
776
- const square_handler = this;
777
-
778
- const form_data = this.form.serializeArray();
779
-
780
- // Add action field to data for nonce verification.
781
- form_data.push( {
782
- name: 'wc_' + this.id + '_checkout_validate_nonce',
783
- value: this.ajax_wc_checkout_validate_nonce,
784
- } );
785
-
786
- return $.ajax( {
787
- url: ajax_url,
788
- method: 'post',
789
- cache: false,
790
- data: form_data,
791
- complete: ( response ) => {
792
- const result = response.responseJSON;
793
-
794
- // If validation is not triggered and WooCommerce returns failure.
795
- // Temporary workaround to fix problems when user email is invalid.
796
- if ( result.hasOwnProperty( 'result' ) && 'failure' === result.result ) {
797
- $( result.messages ).map( ( message ) => {
798
- const errors = [];
799
-
800
- $( message ).children( 'li' ).each( () => {
801
- errors.push( $( this ).text().trim() );
802
- } );
803
-
804
- return square_errors.unshift( ...errors );
805
- } );
806
-
807
- // If validation is complete and WooCommerce returns validaiton errors.
808
- } else if ( result.hasOwnProperty( 'success' ) && ! result.success ) {
809
- square_errors.unshift( ...result.data.messages );
810
- }
811
-
812
- square_handler.render_errors( square_errors );
813
- },
814
- } );
815
- }
816
- }
817
-
818
- window.WC_Square_Payment_Form_Handler = WC_Square_Payment_Form_Handler;
819
- } );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 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_arrayWithoutHoles(arr)||_iterableToArray(arr)||_unsupportedIterableToArray(arr)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray(iter){if(typeof Symbol!=="undefined"&&Symbol.iterator in Object(iter))return Array.from(iter)}function _arrayWithoutHoles(arr){if(Array.isArray(arr))return _arrayLikeToArray(arr)}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i]}return arr2}function _iterableToArrayLimit(arr,i){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(arr)))return;var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor}jQuery(document).ready(function($){var WC_Square_Payment_Form_Handler=function(){function WC_Square_Payment_Form_Handler(args){var _this=this;_classCallCheck(this,WC_Square_Payment_Form_Handler);this.id=args.id;this.id_dasherized=args.id_dasherized;this.csc_required=args.csc_required;this.enabled_card_types=args.enabled_card_types;this.square_card_types=args.square_card_types;this.ajax_log_nonce=args.ajax_log_nonce;this.ajax_url=args.ajax_url;this.application_id=args.application_id;this.currency_code=args.currency_code;this.general_error=args.general_error;this.input_styles=args.input_styles;this.is_3ds_enabled=args.is_3d_secure_enabled;this.is_add_payment_method_page=args.is_add_payment_method_page;this.is_checkout_registration_enabled=args.is_checkout_registration_enabled;this.is_user_logged_in=args.is_user_logged_in;this.location_id=args.location_id;this.logging_enabled=args.logging_enabled;this.ajax_wc_checkout_validate_nonce=args.ajax_wc_checkout_validate_nonce;this.is_manual_order_payment=args.is_manual_order_payment;this.current_postal_code_value="";if($("form.checkout").length){this.form=$("form.checkout");this.handle_checkout_page()}else if($("form#order_review").length){this.form=$("form#order_review");this.handle_pay_page()}else if($("form#add_payment_method").length){this.form=$("form#add_payment_method");this.handle_add_payment_method_page()}else{this.log("No payment form found!");return}this.params=window.sv_wc_payment_gateway_payment_form_params;$(document.body).on("checkout_error",function(){$("input[name=wc-square-credit-card-payment-nonce]").val("");$("input[name=wc-square-credit-card-buyer-verification-token]").val("")});$(document.body).on("click","#payment_method_".concat(this.id),function(){if(_this.payment_form){_this.log("Recalculating payment form size");_this.payment_form.recalculateSize()}})}_createClass(WC_Square_Payment_Form_Handler,[{key:"handle_checkout_page",value:function handle_checkout_page(){var _this2=this;$(document.body).on("updated_checkout",function(){return _this2.set_payment_fields()});$(document.body).on("updated_checkout",function(){return _this2.handle_saved_payment_methods()});this.form.on("checkout_place_order_".concat(this.id),function(){return _this2.validate_payment_data()})}},{key:"handle_saved_payment_methods",value:function handle_saved_payment_methods(){var id_dasherized=this.id_dasherized;var form_handler=this;var $new_payment_method_selection=$("div.js-wc-".concat(id_dasherized,"-new-payment-method-form"));$("input.js-wc-".concat(this.id_dasherized,"-payment-token")).on("change",function(){var tokenized_payment_method_selected=$("input.js-wc-".concat(id_dasherized,"-payment-token:checked")).val();if(tokenized_payment_method_selected){$new_payment_method_selection.slideUp(200)}else{$new_payment_method_selection.slideDown(200)}}).trigger("change");$("input#createaccount").on("change",function(e){if($(e.target).is(":checked")){form_handler.show_save_payment_checkbox(id_dasherized)}else{form_handler.hide_save_payment_checkbox(id_dasherized)}});if(!$("input#createaccount").is(":checked")){$("input#createaccount").trigger("change")}if(!this.is_user_logged_in&&!this.is_checkout_registration_enabled){this.hide_save_payment_checkbox(id_dasherized)}}},{key:"handle_pay_page",value:function handle_pay_page(){this.set_payment_fields();this.handle_saved_payment_methods();var self=this;this.form.on("submit",function(){if($("#order_review input[name=payment_method]:checked").val()===self.id){return self.validate_payment_data()}})}},{key:"handle_add_payment_method_page",value:function handle_add_payment_method_page(){this.set_payment_fields();var self=this;this.form.on("submit",function(){if($("#add_payment_method input[name=payment_method]:checked").val()===self.id){return self.validate_payment_data()}})}},{key:"set_payment_fields",value:function set_payment_fields(){if(!$("#wc-".concat(this.id_dasherized,"-account-number-hosted")).length){return}if($("#wc-".concat(this.id_dasherized,"-account-number-hosted")).is("iframe")){this.log("Re-adding payment form");for(var _i=0,_Object$entries=Object.entries(this.form_fields);_i<_Object$entries.length;_i++){var _Object$entries$_i=_slicedToArray(_Object$entries[_i],2),_=_Object$entries$_i[0],field=_Object$entries$_i[1];$(field.attr("id")).replaceWith(field)}this.handle_form_loaded()}else{if(this.payment_form){this.log("Destroying payment form");this.payment_form.destroy();this.payment_form=null}this.log("Building payment form");this.payment_form=new SqPaymentForm(this.get_form_params());this.payment_form.build()}}},{key:"get_form_params",value:function get_form_params(){var _this3=this;this.form_fields={card_number:$("#wc-".concat(this.id_dasherized,"-account-number-hosted")),expiration:$("#wc-".concat(this.id_dasherized,"-expiry-hosted")),csc:$("#wc-".concat(this.id_dasherized,"-csc-hosted")),postal_code:$("#wc-".concat(this.id_dasherized,"-postal-code-hosted"))};return{applicationId:this.application_id,locationId:this.location_id,cardNumber:{elementId:this.form_fields.card_number.attr("id"),placeholder:this.form_fields.card_number.data("placeholder")},expirationDate:{elementId:this.form_fields.expiration.attr("id"),placeholder:this.form_fields.expiration.data("placeholder")},cvv:{elementId:this.form_fields.csc.attr("id"),placeholder:this.form_fields.csc.data("placeholder")},postalCode:{elementId:this.form_fields.postal_code.attr("id"),placeholder:this.form_fields.postal_code.data("placeholder")},inputClass:"wc-".concat(this.id_dasherized,"-payment-field"),inputStyles:this.input_styles,callbacks:{inputEventReceived:function inputEventReceived(e){return _this3.handle_input_event(e)},cardNonceResponseReceived:function cardNonceResponseReceived(errors,nonce,cardData){return _this3.handle_card_nonce_response(errors,nonce,cardData)},unsupportedBrowserDetected:function unsupportedBrowserDetected(){return _this3.handle_unsupported_browser()},paymentFormLoaded:function paymentFormLoaded(){return _this3.handle_form_loaded()}}}}},{key:"handle_form_loaded",value:function handle_form_loaded(){this.log("Payment form loaded");this.payment_form.setPostalCode($("#billing_postcode").val());if($("form.checkout").length||$("#billing_postcode").val()){$(".wc-square-credit-card-card-postal-code-parent").addClass("hidden")}}},{key:"handle_input_event",value:function handle_input_event(e){var $input=$("#"+e.elementId);if(e.eventType==="cardBrandChanged"){this.handle_card_brand_change(e.cardBrand,$input)}if(e.field==="postalCode"){this.current_postal_code_value=e.postalCodeValue;if(e.eventType==="focusClassRemoved"){this.payment_form.setPostalCode(this.current_postal_code_value.trim())}}}},{key:"handle_card_brand_change",value:function handle_card_brand_change(brand,$input){this.log("Card brand changed to ".concat(brand));$input.attr("class",function(i,c){return c.replace(/(^|\s)card-type-\S+/g,"")});var card_class="plain";if(null===brand||"unknown"===brand){brand=""}if(null!==this.square_card_types[brand]){brand=this.square_card_types[brand]}if(brand&&!this.enabled_card_types.includes(brand)){card_class="invalid"}else{card_class=brand}$("input[name=wc-".concat(this.id_dasherized,"-card-type]")).val(brand);$input.addClass("card-type-".concat(card_class))}},{key:"validate_payment_data",value:function validate_payment_data(){if(this.form.is(".processing")){return false}if(this.has_nonce()){this.log("Payment nonce present, placing order");return true}var tokenized_card_id=this.get_tokenized_payment_method_id();if(tokenized_card_id){if(!this.is_3ds_enabled){return true}if(this.has_verification_token()){this.log("Tokenized payment verification token present, placing order");return true}this.log("Requesting verification token for tokenized payment");this.block_ui();this.payment_form.verifyBuyer(tokenized_card_id,this.get_verification_details(),this.handle_verify_buyer_response.bind(this));return false}this.log("Requesting payment nonce");this.block_ui();this.payment_form.requestCardNonce();return false}},{key:"get_tokenized_payment_method_id",value:function get_tokenized_payment_method_id(){return $(".payment_method_".concat(this.id)).find(".js-wc-square-credit-card-payment-token:checked").val()}},{key:"handle_card_nonce_response",value:function handle_card_nonce_response(errors,nonce,cardData){if(errors){return this.handle_errors(errors)}if(!nonce){var message="Nonce is missing from the Square response";this.log(message,"error");this.log_data(message,"response");return this.handle_errors()}this.log("Card data received");this.log(cardData);this.log_data(cardData,"response");if(cardData.last_4){$("input[name=wc-".concat(this.id_dasherized,"-last-four]")).val(cardData.last_4)}if(cardData.exp_month){$("input[name=wc-".concat(this.id_dasherized,"-exp-month]")).val(cardData.exp_month)}if(cardData.exp_year){$("input[name=wc-".concat(this.id_dasherized,"-exp-year]")).val(cardData.exp_year)}if(cardData.billing_postal_code){$("input[name=wc-".concat(this.id_dasherized,"-payment-postcode]")).val(cardData.billing_postal_code)}$("input[name=wc-".concat(this.id_dasherized,"-payment-nonce]")).val(nonce);if(this.is_3ds_enabled){this.log("Verifying buyer");this.payment_form.verifyBuyer(nonce,this.get_verification_details(),this.handle_verify_buyer_response.bind(this));return}this.form.trigger("submit")}},{key:"handle_verify_buyer_response",value:function handle_verify_buyer_response(errors,verification_result){if(errors){$(errors).each(function(index,error){if(!error.field){error.field="none"}});return this.handle_errors(errors)}if(!verification_result||!verification_result.token){var message="Verification token is missing from the Square response";this.log(message,"error");this.log_data(message,"response");return this.handle_errors()}this.log("Verification result received");this.log(verification_result);$("input[name=wc-".concat(this.id_dasherized,"-buyer-verification-token]")).val(verification_result.token);this.form.trigger("submit")}},{key:"get_verification_details",value:function get_verification_details(){var verification_details={billingContact:{familyName:$("#billing_last_name").val()||"",givenName:$("#billing_first_name").val()||"",email:$("#billing_email").val()||"",country:$("#billing_country").val()||"",region:$("#billing_state").val()||"",city:$("#billing_city").val()||"",postalCode:$("#billing_postcode").val()||"",phone:$("#billing_phone").val()||"",addressLines:[$("#billing_address_1").val()||"",$("#billing_address_2").val()||""]},intent:this.get_intent()};if("CHARGE"===verification_details.intent){verification_details.amount=this.get_amount();verification_details.currencyCode=this.currency_code}this.log(verification_details);return verification_details}},{key:"get_intent",value:function get_intent(){var $save_method_input=$("#wc-square-credit-card-tokenize-payment-method");var save_payment_method;if($save_method_input.is("input:checkbox")){save_payment_method=$save_method_input.is(":checked")}else{save_payment_method="true"===$save_method_input.val()}if(!this.get_tokenized_payment_method_id()&&save_payment_method){return"STORE"}return"CHARGE"}},{key:"get_amount",value:function get_amount(){return $("input[name=wc-".concat(this.id_dasherized,"-amount]")).val()}},{key:"handle_unsupported_browser",value:function handle_unsupported_browser(){}},{key:"handle_errors",value:function handle_errors(){var _this4=this;var errors=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;this.log("Error getting payment data","error");$("input[name=wc-square-credit-card-payment-nonce]").val("");$("input[name=wc-square-credit-card-buyer-verification-token]").val("");var messages=[];if(errors){var field_order=["none","cardNumber","expirationDate","cvv","postalCode"];if(errors.length>=1){errors.sort(function(a,b){return field_order.indexOf(a.field)-field_order.indexOf(b.field)})}$(errors).each(function(index,error){if("UNSUPPORTED_CARD_BRAND"===error.type||"VALIDATION_ERROR"===error.type){return messages.push(error.message.replace(/CVV/,"CSC"))}return _this4.log_data(errors,"response")})}if(messages.length===0){messages.push(this.general_error)}if(!this.is_add_payment_method_page&&!this.is_manual_order_payment){this.render_checkout_errors(messages)}else{this.render_errors(messages)}this.unblock_ui()}},{key:"render_errors",value:function render_errors(errors){$(".woocommerce-error, .woocommerce-message").remove();this.form.prepend("<ul class=\"woocommerce-error\"><li>"+errors.join("</li><li>")+"</li></ul>");this.form.removeClass("processing").unblock();this.form.find(".input-text, select").trigger("blur");$("html, body").animate({scrollTop:this.form.offset().top-100},1000)}},{key:"block_ui",value:function block_ui(){this.form.block({message:null,overlayCSS:{background:"#fff",opacity:0.6}})}},{key:"unblock_ui",value:function unblock_ui(){return this.form.unblock()}},{key:"hide_save_payment_checkbox",value:function hide_save_payment_checkbox(id_dasherized){var $parent_row=$("input.js-wc-".concat(id_dasherized,"-tokenize-payment-method")).closest("p.form-row");$parent_row.hide();$parent_row.next().hide()}},{key:"show_save_payment_checkbox",value:function show_save_payment_checkbox(id_dasherized){var $parent_row=$("input.js-wc-".concat(id_dasherized,"-tokenize-payment-method")).closest("p.form-row");$parent_row.slideDown();$parent_row.next().show()}},{key:"has_nonce",value:function has_nonce(){return $("input[name=wc-".concat(this.id_dasherized,"-payment-nonce]")).val()}},{key:"has_verification_token",value:function has_verification_token(){return $("input[name=wc-".concat(this.id_dasherized,"-buyer-verification-token]")).val()}},{key:"log_data",value:function log_data(data,type){if(!this.logging_enabled){return}var ajax_data={action:"wc_"+this.id+"_log_js_data",security:this.ajax_log_nonce,type:type,data:data};$.ajax({url:this.ajax_url,data:ajax_data})}},{key:"log",value:function log(message){var type=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"notice";if(!this.logging_enabled){return}if("error"===type){console.error("Square Error: "+message)}else{console.log("Square: "+message)}}},{key:"render_checkout_errors",value:function render_checkout_errors(square_errors){var _this5=this;var ajax_url=wc_cart_fragments_params.wc_ajax_url.toString().replace("%%endpoint%%",this.id+"_checkout_handler");var square_handler=this;var form_data=this.form.serializeArray();form_data.push({name:"wc_"+this.id+"_checkout_validate_nonce",value:this.ajax_wc_checkout_validate_nonce});return $.ajax({url:ajax_url,method:"post",cache:false,data:form_data,complete:function complete(response){var result=response.responseJSON;if(result.hasOwnProperty("result")&&"failure"===result.result){$(result.messages).map(function(message){var errors=[];$(message).children("li").each(function(){errors.push($(_this5).text().trim())});return square_errors.unshift.apply(square_errors,errors)})}else if(result.hasOwnProperty("success")&&!result.success){square_errors.unshift.apply(square_errors,_toConsumableArray(result.data.messages))}square_handler.render_errors(square_errors)}})}}]);return WC_Square_Payment_Form_Handler}();window.WC_Square_Payment_Form_Handler=WC_Square_Payment_Form_Handler});
2
- //# sourceMappingURL=wc-square.min.js.map
1
+ "use strict";function _toConsumableArray(arr){return _arrayWithoutHoles(arr)||_iterableToArray(arr)||_unsupportedIterableToArray(arr)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray(iter){if(typeof Symbol!=="undefined"&&iter[Symbol.iterator]!=null||iter["@@iterator"]!=null)return Array.from(iter)}function _arrayWithoutHoles(arr){if(Array.isArray(arr))return _arrayLikeToArray(arr)}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i]}return arr2}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);Object.defineProperty(Constructor,"prototype",{writable:false});return Constructor}jQuery(document).ready(function($){var WC_Square_Payment_Form_Handler=function(){function WC_Square_Payment_Form_Handler(args){var _this=this;_classCallCheck(this,WC_Square_Payment_Form_Handler);this.id=args.id;this.id_dasherized=args.id_dasherized;this.csc_required=args.csc_required;this.enabled_card_types=args.enabled_card_types;this.square_card_types=args.square_card_types;this.ajax_log_nonce=args.ajax_log_nonce;this.ajax_url=args.ajax_url;this.application_id=args.application_id;this.currency_code=args.currency_code;this.general_error=args.general_error;this.input_styles=args.input_styles;this.is_3ds_enabled=args.is_3d_secure_enabled;this.is_add_payment_method_page=args.is_add_payment_method_page;this.is_checkout_registration_enabled=args.is_checkout_registration_enabled;this.is_user_logged_in=args.is_user_logged_in;this.location_id=args.location_id;this.logging_enabled=args.logging_enabled;this.ajax_wc_checkout_validate_nonce=args.ajax_wc_checkout_validate_nonce;this.is_manual_order_payment=args.is_manual_order_payment;this.current_postal_code_value="";if($("form.checkout").length){this.form=$("form.checkout");this.handle_checkout_page()}else if($("form#order_review").length){this.form=$("form#order_review");this.handle_pay_page()}else if($("form#add_payment_method").length){this.form=$("form#add_payment_method");this.handle_add_payment_method_page()}else{this.log("No payment form found!");return}this.params=window.sv_wc_payment_gateway_payment_form_params;$(document.body).on("checkout_error",function(){$("input[name=wc-square-credit-card-payment-nonce]").val("");$("input[name=wc-square-credit-card-buyer-verification-token]").val("")});$(document.body).on("click","#payment_method_".concat(this.id),function(){if(_this.payment_form){_this.log("Recalculating payment form size");_this.payment_form.recalculateSize()}})}_createClass(WC_Square_Payment_Form_Handler,[{key:"handle_checkout_page",value:function handle_checkout_page(){var _this2=this;$(document.body).on("updated_checkout",function(){return _this2.set_payment_fields()});$(document.body).on("updated_checkout",function(){return _this2.handle_saved_payment_methods()});this.form.on("checkout_place_order_".concat(this.id),function(){return _this2.validate_payment_data()})}},{key:"handle_saved_payment_methods",value:function handle_saved_payment_methods(){var id_dasherized=this.id_dasherized;var form_handler=this;var $new_payment_method_selection=$("div.js-wc-".concat(id_dasherized,"-new-payment-method-form"));$("input.js-wc-".concat(this.id_dasherized,"-payment-token")).on("change",function(){var tokenized_payment_method_selected=$("input.js-wc-".concat(id_dasherized,"-payment-token:checked")).val();if(tokenized_payment_method_selected){$new_payment_method_selection.slideUp(200)}else{$new_payment_method_selection.slideDown(200)}}).trigger("change");$("input#createaccount").on("change",function(e){if($(e.target).is(":checked")){form_handler.show_save_payment_checkbox(id_dasherized)}else{form_handler.hide_save_payment_checkbox(id_dasherized)}});if(!$("input#createaccount").is(":checked")){$("input#createaccount").trigger("change")}if(!this.is_user_logged_in&&!this.is_checkout_registration_enabled){this.hide_save_payment_checkbox(id_dasherized)}}},{key:"handle_pay_page",value:function handle_pay_page(){this.set_payment_fields();this.handle_saved_payment_methods();var self=this;this.form.on("submit",function(){if($("#order_review input[name=payment_method]:checked").val()===self.id){return self.validate_payment_data()}})}},{key:"handle_add_payment_method_page",value:function handle_add_payment_method_page(){this.set_payment_fields();var self=this;this.form.on("submit",function(){if($("#add_payment_method input[name=payment_method]:checked").val()===self.id){return self.validate_payment_data()}})}},{key:"set_payment_fields",value:function set_payment_fields(){if(!$("#wc-".concat(this.id_dasherized,"-account-number-hosted")).length){return}if($("#wc-".concat(this.id_dasherized,"-account-number-hosted")).is("iframe")){this.log("Re-adding payment form");for(var _i=0,_Object$entries=Object.entries(this.form_fields);_i<_Object$entries.length;_i++){var _Object$entries$_i=_slicedToArray(_Object$entries[_i],2),_=_Object$entries$_i[0],field=_Object$entries$_i[1];$(field.attr("id")).replaceWith(field)}this.handle_form_loaded()}else{if(this.payment_form){this.log("Destroying payment form");this.payment_form.destroy();this.payment_form=null}this.log("Building payment form");this.payment_form=new SqPaymentForm(this.get_form_params());this.payment_form.build()}}},{key:"get_form_params",value:function get_form_params(){var _this3=this;this.form_fields={card_number:$("#wc-".concat(this.id_dasherized,"-account-number-hosted")),expiration:$("#wc-".concat(this.id_dasherized,"-expiry-hosted")),csc:$("#wc-".concat(this.id_dasherized,"-csc-hosted")),postal_code:$("#wc-".concat(this.id_dasherized,"-postal-code-hosted"))};return{applicationId:this.application_id,locationId:this.location_id,cardNumber:{elementId:this.form_fields.card_number.attr("id"),placeholder:this.form_fields.card_number.data("placeholder")},expirationDate:{elementId:this.form_fields.expiration.attr("id"),placeholder:this.form_fields.expiration.data("placeholder")},cvv:{elementId:this.form_fields.csc.attr("id"),placeholder:this.form_fields.csc.data("placeholder")},postalCode:{elementId:this.form_fields.postal_code.attr("id"),placeholder:this.form_fields.postal_code.data("placeholder")},inputClass:"wc-".concat(this.id_dasherized,"-payment-field"),inputStyles:this.input_styles,callbacks:{inputEventReceived:function inputEventReceived(e){return _this3.handle_input_event(e)},cardNonceResponseReceived:function cardNonceResponseReceived(errors,nonce,cardData){return _this3.handle_card_nonce_response(errors,nonce,cardData)},unsupportedBrowserDetected:function unsupportedBrowserDetected(){return _this3.handle_unsupported_browser()},paymentFormLoaded:function paymentFormLoaded(){return _this3.handle_form_loaded()}}}}},{key:"handle_form_loaded",value:function handle_form_loaded(){this.log("Payment form loaded");this.payment_form.setPostalCode($("#billing_postcode").val());if($("form.checkout").length||$("#billing_postcode").val()){$(".wc-square-credit-card-card-postal-code-parent").addClass("hidden")}}},{key:"handle_input_event",value:function handle_input_event(e){var $input=$("#"+e.elementId);if(e.eventType==="cardBrandChanged"){this.handle_card_brand_change(e.cardBrand,$input)}if(e.field==="postalCode"){this.current_postal_code_value=e.postalCodeValue;if(e.eventType==="focusClassRemoved"){this.payment_form.setPostalCode(this.current_postal_code_value.trim())}}}},{key:"handle_card_brand_change",value:function handle_card_brand_change(brand,$input){this.log("Card brand changed to ".concat(brand));$input.attr("class",function(i,c){return c.replace(/(^|\s)card-type-\S+/g,"")});var card_class="plain";if(null===brand||"unknown"===brand){brand=""}if(null!==this.square_card_types[brand]){brand=this.square_card_types[brand]}if(brand&&!this.enabled_card_types.includes(brand)){card_class="invalid"}else{card_class=brand}$("input[name=wc-".concat(this.id_dasherized,"-card-type]")).val(brand);$input.addClass("card-type-".concat(card_class))}},{key:"validate_payment_data",value:function validate_payment_data(){if(this.form.is(".processing")){return false}if(this.has_nonce()){this.log("Payment nonce present, placing order");return true}var tokenized_card_id=this.get_tokenized_payment_method_id();if(tokenized_card_id){if(!this.is_3ds_enabled){return true}if(this.has_verification_token()){this.log("Tokenized payment verification token present, placing order");return true}this.log("Requesting verification token for tokenized payment");this.block_ui();this.payment_form.verifyBuyer(tokenized_card_id,this.get_verification_details(),this.handle_verify_buyer_response.bind(this));return false}this.log("Requesting payment nonce");this.block_ui();this.payment_form.requestCardNonce();return false}},{key:"get_tokenized_payment_method_id",value:function get_tokenized_payment_method_id(){return $(".payment_method_".concat(this.id)).find(".js-wc-square-credit-card-payment-token:checked").val()}},{key:"handle_card_nonce_response",value:function handle_card_nonce_response(errors,nonce,cardData){if(errors){return this.handle_errors(errors)}if(!nonce){var message="Nonce is missing from the Square response";this.log(message,"error");this.log_data(message,"response");return this.handle_errors()}this.log("Card data received");this.log(cardData);this.log_data(cardData,"response");if(cardData.last_4){$("input[name=wc-".concat(this.id_dasherized,"-last-four]")).val(cardData.last_4)}if(cardData.exp_month){$("input[name=wc-".concat(this.id_dasherized,"-exp-month]")).val(cardData.exp_month)}if(cardData.exp_year){$("input[name=wc-".concat(this.id_dasherized,"-exp-year]")).val(cardData.exp_year)}if(cardData.billing_postal_code){$("input[name=wc-".concat(this.id_dasherized,"-payment-postcode]")).val(cardData.billing_postal_code)}$("input[name=wc-".concat(this.id_dasherized,"-payment-nonce]")).val(nonce);if(this.is_3ds_enabled){this.log("Verifying buyer");this.payment_form.verifyBuyer(nonce,this.get_verification_details(),this.handle_verify_buyer_response.bind(this));return}this.form.trigger("submit")}},{key:"handle_verify_buyer_response",value:function handle_verify_buyer_response(errors,verification_result){if(errors){$(errors).each(function(index,error){if(!error.field){error.field="none"}});return this.handle_errors(errors)}if(!verification_result||!verification_result.token){var message="Verification token is missing from the Square response";this.log(message,"error");this.log_data(message,"response");return this.handle_errors()}this.log("Verification result received");this.log(verification_result);$("input[name=wc-".concat(this.id_dasherized,"-buyer-verification-token]")).val(verification_result.token);this.form.trigger("submit")}},{key:"get_verification_details",value:function get_verification_details(){var verification_details={billingContact:{familyName:$("#billing_last_name").val()||"",givenName:$("#billing_first_name").val()||"",email:$("#billing_email").val()||"",country:$("#billing_country").val()||"",region:$("#billing_state").val()||"",city:$("#billing_city").val()||"",postalCode:$("#billing_postcode").val()||"",phone:$("#billing_phone").val()||"",addressLines:[$("#billing_address_1").val()||"",$("#billing_address_2").val()||""]},intent:this.get_intent()};if("CHARGE"===verification_details.intent){verification_details.amount=this.get_amount();verification_details.currencyCode=this.currency_code}this.log(verification_details);return verification_details}},{key:"get_intent",value:function get_intent(){var $save_method_input=$("#wc-square-credit-card-tokenize-payment-method");var save_payment_method;if($save_method_input.is("input:checkbox")){save_payment_method=$save_method_input.is(":checked")}else{save_payment_method="true"===$save_method_input.val()}if(!this.get_tokenized_payment_method_id()&&save_payment_method){return"STORE"}return"CHARGE"}},{key:"get_amount",value:function get_amount(){return $("input[name=wc-".concat(this.id_dasherized,"-amount]")).val()}},{key:"handle_unsupported_browser",value:function handle_unsupported_browser(){}},{key:"handle_errors",value:function handle_errors(){var _this4=this;var errors=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;this.log("Error getting payment data","error");$("input[name=wc-square-credit-card-payment-nonce]").val("");$("input[name=wc-square-credit-card-buyer-verification-token]").val("");var messages=[];if(errors){var field_order=["none","cardNumber","expirationDate","cvv","postalCode"];if(errors.length>=1){errors.sort(function(a,b){return field_order.indexOf(a.field)-field_order.indexOf(b.field)})}$(errors).each(function(index,error){if("UNSUPPORTED_CARD_BRAND"===error.type||"VALIDATION_ERROR"===error.type){return messages.push(error.message.replace(/CVV/,"CSC"))}return _this4.log_data(errors,"response")})}if(messages.length===0){messages.push(this.general_error)}if(!this.is_add_payment_method_page&&!this.is_manual_order_payment){this.render_checkout_errors(messages)}else{this.render_errors(messages)}this.unblock_ui()}},{key:"render_errors",value:function render_errors(errors){$(".woocommerce-error, .woocommerce-message").remove();this.form.prepend("<ul class=\"woocommerce-error\"><li>"+errors.join("</li><li>")+"</li></ul>");this.form.removeClass("processing").unblock();this.form.find(".input-text, select").trigger("blur");$("html, body").animate({scrollTop:this.form.offset().top-100},1000)}},{key:"block_ui",value:function block_ui(){this.form.block({message:null,overlayCSS:{background:"#fff",opacity:0.6}})}},{key:"unblock_ui",value:function unblock_ui(){return this.form.unblock()}},{key:"hide_save_payment_checkbox",value:function hide_save_payment_checkbox(id_dasherized){var $parent_row=$("input.js-wc-".concat(id_dasherized,"-tokenize-payment-method")).closest("p.form-row");$parent_row.hide();$parent_row.next().hide()}},{key:"show_save_payment_checkbox",value:function show_save_payment_checkbox(id_dasherized){var $parent_row=$("input.js-wc-".concat(id_dasherized,"-tokenize-payment-method")).closest("p.form-row");$parent_row.slideDown();$parent_row.next().show()}},{key:"has_nonce",value:function has_nonce(){return $("input[name=wc-".concat(this.id_dasherized,"-payment-nonce]")).val()}},{key:"has_verification_token",value:function has_verification_token(){return $("input[name=wc-".concat(this.id_dasherized,"-buyer-verification-token]")).val()}},{key:"log_data",value:function log_data(data,type){if(!this.logging_enabled){return}var ajax_data={action:"wc_"+this.id+"_log_js_data",security:this.ajax_log_nonce,type:type,data:data};$.ajax({url:this.ajax_url,data:ajax_data})}},{key:"log",value:function log(message){var type=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"notice";if(!this.logging_enabled){return}if("error"===type){console.error("Square Error: "+message)}else{console.log("Square: "+message)}}},{key:"render_checkout_errors",value:function render_checkout_errors(square_errors){var _this5=this;var ajax_url=wc_cart_fragments_params.wc_ajax_url.toString().replace("%%endpoint%%",this.id+"_checkout_handler");var square_handler=this;var form_data=this.form.serializeArray();form_data.push({name:"wc_"+this.id+"_checkout_validate_nonce",value:this.ajax_wc_checkout_validate_nonce});return $.ajax({url:ajax_url,method:"post",cache:false,data:form_data,complete:function complete(response){var result=response.responseJSON;if(result.hasOwnProperty("result")&&"failure"===result.result){$(result.messages).map(function(message){var errors=[];$(message).children("li").each(function(){errors.push($(_this5).text().trim())});return square_errors.unshift.apply(square_errors,errors)})}else if(result.hasOwnProperty("success")&&!result.success){square_errors.unshift.apply(square_errors,_toConsumableArray(result.data.messages))}square_handler.render_errors(square_errors)}})}}]);return WC_Square_Payment_Form_Handler}();window.WC_Square_Payment_Form_Handler=WC_Square_Payment_Form_Handler});
 
assets/js/frontend/wc-square.min.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["wc-square.js"],"names":["jQuery","document","ready","$","WC_Square_Payment_Form_Handler","args","id","id_dasherized","csc_required","enabled_card_types","square_card_types","ajax_log_nonce","ajax_url","application_id","currency_code","general_error","input_styles","is_3ds_enabled","is_3d_secure_enabled","is_add_payment_method_page","is_checkout_registration_enabled","is_user_logged_in","location_id","logging_enabled","ajax_wc_checkout_validate_nonce","is_manual_order_payment","length","form","handle_checkout_page","handle_pay_page","handle_add_payment_method_page","log","params","window","sv_wc_payment_gateway_payment_form_params","body","on","val","payment_form","recalculateSize","set_payment_fields","handle_saved_payment_methods","validate_payment_data","form_handler","$new_payment_method_selection","tokenized_payment_method_selected","slideUp","slideDown","trigger","e","target","is","show_save_payment_checkbox","hide_save_payment_checkbox","self","Object","entries","form_fields","_","field","attr","replaceWith","handle_form_loaded","destroy","SqPaymentForm","get_form_params","build","card_number","expiration","csc","postal_code","applicationId","locationId","cardNumber","elementId","placeholder","data","expirationDate","cvv","postalCode","inputClass","inputStyles","callbacks","inputEventReceived","handle_input_event","cardNonceResponseReceived","errors","nonce","cardData","handle_card_nonce_response","unsupportedBrowserDetected","handle_unsupported_browser","paymentFormLoaded","setPostalCode","addClass","$input","eventType","handle_card_brand_change","cardBrand","brand","i","c","replace","card_class","includes","has_nonce","tokenized_card_id","get_tokenized_payment_method_id","has_verification_token","block_ui","verifyBuyer","get_verification_details","handle_verify_buyer_response","bind","requestCardNonce","find","handle_errors","message","log_data","last_4","exp_month","exp_year","billing_postal_code","verification_result","each","index","error","token","verification_details","billingContact","familyName","givenName","email","country","region","city","phone","addressLines","intent","get_intent","amount","get_amount","currencyCode","$save_method_input","save_payment_method","messages","field_order","sort","a","b","indexOf","type","push","render_checkout_errors","render_errors","unblock_ui","remove","prepend","join","removeClass","unblock","animate","scrollTop","offset","top","block","overlayCSS","background","opacity","$parent_row","closest","hide","next","show","ajax_data","action","security","ajax","url","console","square_errors","wc_cart_fragments_params","wc_ajax_url","toString","square_handler","form_data","serializeArray","name","value","method","cache","complete","response","result","responseJSON","hasOwnProperty","map","children","text","trim","unshift","success"],"mappings":"q8EAOAA,MAAM,CAAEC,QAAF,CAAN,CAAmBC,KAAnB,CAA0B,SAAEC,CAAF,CAAS,IAM5BC,CAAAA,8BAN4B,YAcjC,wCAAaC,IAAb,CAAoB,qEACnB,KAAKC,EAAL,CAAUD,IAAI,CAACC,EAAf,CACA,KAAKC,aAAL,CAAqBF,IAAI,CAACE,aAA1B,CACA,KAAKC,YA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,OAAd,OAAApB,aAAa,oBAAaa,MAAM,CAACrH,IAAP,CAAYqE,QAAzB,EACb,CAEDuC,cAAc,CAAC9B,aAAf,CAA8B0B,aAA9B,CACA,CA3Ba,CAAR,CA6BP,CAjxBgC,6CAoxBlCnJ,MAAM,CAAC7B,8BAAP,CAAwCA,8BACxC,CArxBD","sourcesContent":["/* global wc_cart_fragments_params */\n\n/**\n * WooCommerce Square Payment Form handler.\n *\n * @since 2.0.0\n */\njQuery( document ).ready( ( $ ) => {\n\t/**\n\t * Square Credit Card Payment Form Handler class.\n\t *\n\t * @since 2.0.0\n\t */\n\tclass WC_Square_Payment_Form_Handler {\n\t\t/**\n\t\t * Setup handler.\n\t\t *\n\t\t * @since 2.3.2-1\n\t\t *\n\t\t * @param {Object} args\n\t\t */\n\t\tconstructor( args ) {\n\t\t\tthis.id = args.id;\n\t\t\tthis.id_dasherized = args.id_dasherized;\n\t\t\tthis.csc_required = args.csc_required;\n\t\t\tthis.enabled_card_types = args.enabled_card_types;\n\t\t\tthis.square_card_types = args.square_card_types;\n\t\t\tthis.ajax_log_nonce = args.ajax_log_nonce;\n\t\t\tthis.ajax_url = args.ajax_url;\n\t\t\tthis.application_id = args.application_id;\n\t\t\tthis.currency_code = args.currency_code;\n\t\t\tthis.general_error = args.general_error;\n\t\t\tthis.input_styles = args.input_styles;\n\t\t\tthis.is_3ds_enabled = args.is_3d_secure_enabled;\n\t\t\tthis.is_add_payment_method_page = args.is_add_payment_method_page;\n\t\t\tthis.is_checkout_registration_enabled = args.is_checkout_registration_enabled;\n\t\t\tthis.is_user_logged_in = args.is_user_logged_in;\n\t\t\tthis.location_id = args.location_id;\n\t\t\tthis.logging_enabled = args.logging_enabled;\n\t\t\tthis.ajax_wc_checkout_validate_nonce = args.ajax_wc_checkout_validate_nonce;\n\t\t\tthis.is_manual_order_payment = args.is_manual_order_payment;\n\n\t\t\tif ( $( 'form.checkout' ).length ) {\n\t\t\t\tthis.form = $( 'form.checkout' );\n\t\t\t\tthis.handle_checkout_page();\n\t\t\t} else if ( $( 'form#order_review' ).length ) {\n\t\t\t\tthis.form = $( 'form#order_review' );\n\t\t\t\tthis.handle_pay_page();\n\t\t\t} else if ( $( 'form#add_payment_method' ).length ) {\n\t\t\t\tthis.form = $( 'form#add_payment_method' );\n\t\t\t\tthis.handle_add_payment_method_page();\n\t\t\t} else {\n\t\t\t\tthis.log( 'No payment form found!' );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// localized error messages.\n\t\t\tthis.params = window.sv_wc_payment_gateway_payment_form_params;\n\n\t\t\t// unblock the UI and clear any payment nonces when a server-side error occurs.\n\t\t\t$( document.body ).on( 'checkout_error', () => {\n\t\t\t\t$( 'input[name=wc-square-credit-card-payment-nonce]' ).val( '' );\n\t\t\t\t$( 'input[name=wc-square-credit-card-buyer-verification-token]' ).val( '' );\n\t\t\t} );\n\n\t\t\t$( document.body ).on( 'click', `#payment_method_${ this.id }`, () => {\n\t\t\t\tif ( this.payment_form ) {\n\t\t\t\t\tthis.log( 'Recalculating payment form size' );\n\t\t\t\t\tthis.payment_form.recalculateSize();\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Public: Handle required actions on the checkout page.\n\t\t */\n\t\thandle_checkout_page() {\n\t\t\t// updated payment fields jQuery object on each checkout update (prevents stale data).\n\t\t\t$( document.body ).on( 'updated_checkout', () => this.set_payment_fields() );\n\n\t\t\t// handle saved payment methods note on the checkout page.\n\t\t\t// this is bound to `updated_checkout` so it fires even when other parts of the checkout are changed.\n\t\t\t$( document.body ).on( 'updated_checkout', () => this.handle_saved_payment_methods() );\n\n\t\t\t// validate payment data before order is submitted.\n\t\t\tthis.form.on( `checkout_place_order_${ this.id }`, () => this.validate_payment_data() );\n\t\t}\n\n\t\t/**\n\t\t * Public: Handle associated actions for saved payment methods.\n\t\t */\n\t\thandle_saved_payment_methods() {\n\t\t\t// make available inside change events.\n\t\t\tconst id_dasherized = this.id_dasherized;\n\t\t\tconst form_handler = this;\n\t\t\tconst $new_payment_method_selection = $( `div.js-wc-${ id_dasherized }-new-payment-method-form` );\n\n\t\t\t// show/hide the saved payment methods when a saved payment method is de-selected/selected.\n\t\t\t$( `input.js-wc-${ this.id_dasherized }-payment-token` ).on( 'change', () => {\n\t\t\t\tconst tokenized_payment_method_selected = $( `input.js-wc-${ id_dasherized }-payment-token:checked` ).val();\n\n\t\t\t\tif ( tokenized_payment_method_selected ) {\n\t\t\t\t\t// using an existing tokenized payment method, hide the 'new method' fields.\n\t\t\t\t\t$new_payment_method_selection.slideUp( 200 );\n\t\t\t\t} else {\n\t\t\t\t\t// use new payment method, display the 'new method' fields.\n\t\t\t\t\t$new_payment_method_selection.slideDown( 200 );\n\t\t\t\t}\n\t\t\t} ).trigger( 'change' );\n\n\t\t\t// display the 'save payment method' option for guest checkouts if the 'create account' option is checked\n\t\t\t// but only hide the input if there is a 'create account' checkbox (some themes just display the password).\n\t\t\t$( 'input#createaccount' ).on( 'change', ( e ) => {\n\t\t\t\tif ( $( e.target ).is( ':checked' ) ) {\n\t\t\t\t\tform_handler.show_save_payment_checkbox( id_dasherized );\n\t\t\t\t} else {\n\t\t\t\t\tform_handler.hide_save_payment_checkbox( id_dasherized );\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\tif ( ! $( 'input#createaccount' ).is( ':checked' ) ) {\n\t\t\t\t$( 'input#createaccount' ).trigger( 'change' );\n\t\t\t}\n\n\t\t\t// hide the 'save payment method' when account creation is not enabled and customer is not logged in.\n\t\t\tif ( ! this.is_user_logged_in && ! this.is_checkout_registration_enabled ) {\n\t\t\t\tthis.hide_save_payment_checkbox( id_dasherized );\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Public: Handle required actions on the Order > Pay page.\n\t\t */\n\t\thandle_pay_page() {\n\t\t\tthis.set_payment_fields();\n\n\t\t\t// handle saved payment methods.\n\t\t\tthis.handle_saved_payment_methods();\n\n\t\t\tconst self = this;\n\n\t\t\t// validate payment data before order is submitted.\n\t\t\t// but only when one of our payment gateways is selected.\n\t\t\tthis.form.on( 'submit', function() {\n\t\t\t\tif ( $( '#order_review input[name=payment_method]:checked' ).val() === self.id ) {\n\t\t\t\t\treturn self.validate_payment_data();\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Public: Handle required actions on the Add Payment Method page.\n\t\t */\n\t\thandle_add_payment_method_page() {\n\t\t\tthis.set_payment_fields();\n\n\t\t\tconst self = this;\n\n\t\t\t// validate payment data before order is submitted.\n\t\t\t// but only when one of our payment gateways is selected.\n\t\t\tthis.form.on( 'submit', function() {\n\t\t\t\tif ( $( '#add_payment_method input[name=payment_method]:checked' ).val() === self.id ) {\n\t\t\t\t\treturn self.validate_payment_data();\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Sets up the Square payment fields.\n\t\t *\n\t\t * @since 2.0.0\n\t\t */\n\t\tset_payment_fields() {\n\t\t\tif ( ! $( `#wc-${ this.id_dasherized }-account-number-hosted` ).length ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( $( `#wc-${ this.id_dasherized }-account-number-hosted` ).is( 'iframe' ) ) {\n\t\t\t\tthis.log( 'Re-adding payment form' );\n\n\t\t\t\tfor ( const [ _, field ] of Object.entries( this.form_fields ) ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\t$( field.attr( 'id' ) ).replaceWith( field );\n\t\t\t\t}\n\n\t\t\t\tthis.handle_form_loaded();\n\t\t\t} else {\n\t\t\t\tif ( this.payment_form ) {\n\t\t\t\t\tthis.log( 'Destroying payment form' );\n\t\t\t\t\tthis.payment_form.destroy();\n\t\t\t\t\tthis.payment_form = null;\n\t\t\t\t}\n\n\t\t\t\tthis.log( 'Building payment form' );\n\n\t\t\t\tthis.payment_form = new SqPaymentForm( this.get_form_params() ); // eslint-disable-line no-undef\n\n\t\t\t\tthis.payment_form.build();\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Gets the Square payment form params.\n\t\t *\n\t\t * @since 2.0.0\n\t\t *\n\t\t * @return {Object} Form params.\n\t\t */\n\t\tget_form_params() {\n\t\t\tthis.form_fields = {\n\t\t\t\tcard_number: $( `#wc-${ this.id_dasherized }-account-number-hosted` ),\n\t\t\t\texpiration: $( `#wc-${ this.id_dasherized }-expiry-hosted` ),\n\t\t\t\tcsc: $( `#wc-${ this.id_dasherized }-csc-hosted` ),\n\t\t\t\tpostal_code: $( `#wc-${ this.id_dasherized }-postal-code-hosted` ),\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\tapplicationId: this.application_id,\n\t\t\t\tlocationId: this.location_id,\n\t\t\t\tcardNumber: {\n\t\t\t\t\telementId: this.form_fields.card_number.attr( 'id' ),\n\t\t\t\t\tplaceholder: this.form_fields.card_number.data( 'placeholder' ),\n\t\t\t\t},\n\t\t\t\texpirationDate: {\n\t\t\t\t\telementId: this.form_fields.expiration.attr( 'id' ),\n\t\t\t\t\tplaceholder: this.form_fields.expiration.data( 'placeholder' ),\n\t\t\t\t},\n\t\t\t\tcvv: {\n\t\t\t\t\telementId: this.form_fields.csc.attr( 'id' ),\n\t\t\t\t\tplaceholder: this.form_fields.csc.data( 'placeholder' ),\n\t\t\t\t},\n\t\t\t\tpostalCode: {\n\t\t\t\t\telementId: this.form_fields.postal_code.attr( 'id' ),\n\t\t\t\t\tplaceholder: this.form_fields.postal_code.data( 'placeholder' ),\n\t\t\t\t},\n\t\t\t\tinputClass: `wc-${ this.id_dasherized }-payment-field`,\n\t\t\t\tinputStyles: this.input_styles,\n\t\t\t\tcallbacks: {\n\t\t\t\t\tinputEventReceived: ( e ) => this.handle_input_event( e ),\n\t\t\t\t\tcardNonceResponseReceived: ( errors, nonce, cardData ) => this.handle_card_nonce_response( errors, nonce, cardData ),\n\t\t\t\t\tunsupportedBrowserDetected: () => this.handle_unsupported_browser(),\n\t\t\t\t\tpaymentFormLoaded: () => this.handle_form_loaded(),\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * Handles when the payment form is fully loaded.\n\t\t *\n\t\t * @since 2.0.0\n\t\t */\n\t\thandle_form_loaded() {\n\t\t\tthis.log( 'Payment form loaded' );\n\n\t\t\tthis.payment_form.setPostalCode( $( '#billing_postcode' ).val() );\n\n\t\t\t// hide the postcode field on the checkout page or if it already has a value.\n\t\t\tif ( $( 'form.checkout' ).length || $( '#billing_postcode' ).val() ) {\n\t\t\t\t$( '.wc-square-credit-card-card-postal-code-parent' ).addClass( 'hidden' );\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Handles payment form input changes.\n\t\t *\n\t\t * @since 2.0.0\n\t\t *\n\t\t * @param {Object} e\n\t\t */\n\t\thandle_input_event( e ) {\n\t\t\tconst $input = $( '#' + e.elementId );\n\n\t\t\tif ( e.eventType === 'cardBrandChanged' ) {\n\t\t\t\tthis.handle_card_brand_change( e.cardBrand, $input );\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Handles card number brand changes.\n\t\t *\n\t\t * @since 2.0.0\n\t\t *\n\t\t * @param {string} brand\n\t\t * @param {Object} $input\n\t\t */\n\t\thandle_card_brand_change( brand, $input ) {\n\t\t\tthis.log( `Card brand changed to ${ brand }` );\n\n\t\t\t// clear any existing card type class\n\t\t\t$input.attr( 'class', ( i, c ) => {\n\t\t\t\treturn c.replace( /(^|\\s)card-type-\\S+/g, '' );\n\t\t\t} );\n\n\t\t\tlet card_class = 'plain';\n\n\t\t\tif ( null === brand || 'unknown' === brand ) {\n\t\t\t\tbrand = '';\n\t\t\t}\n\n\t\t\tif ( null !== this.square_card_types[ brand ] ) {\n\t\t\t\tbrand = this.square_card_types[ brand ];\n\t\t\t}\n\n\t\t\tif ( brand && ! this.enabled_card_types.includes( brand ) ) {\n\t\t\t\tcard_class = 'invalid';\n\t\t\t} else {\n\t\t\t\tcard_class = brand;\n\t\t\t}\n\n\t\t\t$( `input[name=wc-${ this.id_dasherized }-card-type]` ).val( brand );\n\n\t\t\t$input.addClass( `card-type-${ card_class }` );\n\t\t}\n\n\t\t/**\n\t\t * Used to request a card nonce and submit the form.\n\t\t *\n\t\t * @since 2.0.0\n\t\t */\n\t\tvalidate_payment_data() {\n\t\t\tif ( this.form.is( '.processing' ) ) {\n\t\t\t\t// bail when already processing.\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// let through if nonce is already present - nonce is only present on non-tokenized payments.\n\t\t\tif ( this.has_nonce() ) {\n\t\t\t\tthis.log( 'Payment nonce present, placing order' );\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tconst tokenized_card_id = this.get_tokenized_payment_method_id();\n\n\t\t\tif ( tokenized_card_id ) {\n\t\t\t\tif ( ! this.is_3ds_enabled ) {\n\t\t\t\t\t// if 3DS is disabled and paying with a saved method, no further validation needed.\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tif ( this.has_verification_token() ) {\n\t\t\t\t\tthis.log( 'Tokenized payment verification token present, placing order' );\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tthis.log( 'Requesting verification token for tokenized payment' );\n\n\t\t\t\tthis.block_ui();\n\t\t\t\tthis.payment_form.verifyBuyer( tokenized_card_id, this.get_verification_details(), this.handle_verify_buyer_response.bind( this ) );\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tthis.log( 'Requesting payment nonce' );\n\t\t\tthis.block_ui();\n\t\t\tthis.payment_form.requestCardNonce();\n\t\t\treturn false;\n\t\t}\n\n\t\t/**\n\t\t * Gets the selected tokenized payment method ID, if there is one.\n\t\t *\n\t\t * @since 2.1.0\n\t\t *\n\t\t * @return {string} Tokenized payment method ID.\n\t\t */\n\t\tget_tokenized_payment_method_id() {\n\t\t\treturn $( `.payment_method_${ this.id }` ).find( '.js-wc-square-credit-card-payment-token:checked' ).val();\n\t\t}\n\n\t\t/**\n\t\t * Handles the Square payment form card nonce response.\n\t\t *\n\t\t * @since 2.1.0\n\t\t *\n\t\t * @param {Object} errors Validation errors, if any.\n\t\t * @param {string} nonce Payment nonce.\n\t\t * @param {Object} cardData Non-confidential info about the card used.\n\t\t */\n\t\thandle_card_nonce_response( errors, nonce, cardData ) {\n\t\t\t// if we have real errors to display from Square.\n\t\t\tif ( errors ) {\n\t\t\t\treturn this.handle_errors( errors );\n\t\t\t}\n\n\t\t\t// no errors, but also no payment data.\n\t\t\tif ( ! nonce ) {\n\t\t\t\tconst message = 'Nonce is missing from the Square response';\n\n\t\t\t\tthis.log( message, 'error' );\n\t\t\t\tthis.log_data( message, 'response' );\n\t\t\t\treturn this.handle_errors();\n\t\t\t}\n\n\t\t\t// if we made it this far, we have payment data.\n\t\t\tthis.log( 'Card data received' );\n\t\t\tthis.log( cardData );\n\t\t\tthis.log_data( cardData, 'response' );\n\n\t\t\tif ( cardData.last_4 ) {\n\t\t\t\t$( `input[name=wc-${ this.id_dasherized }-last-four]` ).val( cardData.last_4 );\n\t\t\t}\n\n\t\t\tif ( cardData.exp_month ) {\n\t\t\t\t$( `input[name=wc-${ this.id_dasherized }-exp-month]` ).val( cardData.exp_month );\n\t\t\t}\n\n\t\t\tif ( cardData.exp_year ) {\n\t\t\t\t$( `input[name=wc-${ this.id_dasherized }-exp-year]` ).val( cardData.exp_year );\n\t\t\t}\n\n\t\t\tif ( cardData.billing_postal_code ) {\n\t\t\t\t$( `input[name=wc-${ this.id_dasherized }-payment-postcode]` ).val( cardData.billing_postal_code );\n\t\t\t}\n\n\t\t\t// payment nonce data.\n\t\t\t$( `input[name=wc-${ this.id_dasherized }-payment-nonce]` ).val( nonce );\n\n\t\t\t// if 3ds is enabled, we need to verify the buyer and record the verification token before continuing.\n\t\t\tif ( this.is_3ds_enabled ) {\n\t\t\t\tthis.log( 'Verifying buyer' );\n\n\t\t\t\tthis.payment_form.verifyBuyer( nonce, this.get_verification_details(), this.handle_verify_buyer_response.bind( this ) );\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// now that we have a nonce, resubmit the form.\n\t\t\tthis.form.trigger( 'submit' );\n\t\t}\n\n\t\t/**\n\t\t * Handles the response from a call to verifyBuyer()\n\t\t *\n\t\t * @since 2.1.0\n\t\t *\n\t\t * @param {Object} errors Verification errors, if any.\n\t\t * @param {Object} verification_result Results of verification.\n\t\t */\n\t\thandle_verify_buyer_response( errors, verification_result ) {\n\t\t\tif ( errors ) {\n\t\t\t\t$( errors ).each( ( index, error ) => {\n\t\t\t\t\tif ( ! error.field ) {\n\t\t\t\t\t\terror.field = 'none';\n\t\t\t\t\t}\n\t\t\t\t} );\n\n\t\t\t\treturn this.handle_errors( errors );\n\t\t\t}\n\n\t\t\t// no errors, but also no verification token.\n\t\t\tif ( ! verification_result || ! verification_result.token ) {\n\t\t\t\tconst message = 'Verification token is missing from the Square response';\n\n\t\t\t\tthis.log( message, 'error' );\n\t\t\t\tthis.log_data( message, 'response' );\n\n\t\t\t\treturn this.handle_errors();\n\t\t\t}\n\n\t\t\tthis.log( 'Verification result received' );\n\t\t\tthis.log( verification_result );\n\n\t\t\t$( `input[name=wc-${ this.id_dasherized }-buyer-verification-token]` ).val( verification_result.token );\n\n\t\t\tthis.form.trigger( 'submit' );\n\t\t}\n\n\t\t/**\n\t\t * Gets a verification details object to be used in verifyBuyer()\n\t\t *\n\t\t * @since 2.1.0\n\t\t *\n\t\t * @return {Object} Verification details object.\n\t\t */\n\t\tget_verification_details() {\n\t\t\tconst verification_details = {\n\t\t\t\tbillingContact: {\n\t\t\t\t\tfamilyName: $( '#billing_last_name' ).val() || '',\n\t\t\t\t\tgivenName: $( '#billing_first_name' ).val() || '',\n\t\t\t\t\temail: $( '#billing_email' ).val() || '',\n\t\t\t\t\tcountry: $( '#billing_country' ).val() || '',\n\t\t\t\t\tregion: $( '#billing_state' ).val() || '',\n\t\t\t\t\tcity: $( '#billing_city' ).val() || '',\n\t\t\t\t\tpostalCode: $( '#billing_postcode' ).val() || '',\n\t\t\t\t\tphone: $( '#billing_phone' ).val() || '',\n\t\t\t\t\taddressLines: [ $( '#billing_address_1' ).val() || '', $( '#billing_address_2' ).val() || '' ],\n\t\t\t\t},\n\t\t\t\tintent: this.get_intent(),\n\t\t\t};\n\n\t\t\tif ( 'CHARGE' === verification_details.intent ) {\n\t\t\t\tverification_details.amount = this.get_amount();\n\t\t\t\tverification_details.currencyCode = this.currency_code;\n\t\t\t}\n\n\t\t\tthis.log( verification_details );\n\n\t\t\treturn verification_details;\n\t\t}\n\n\t\t/**\n\t\t * Gets the intent of this processing - either 'CHARGE' or 'STORE'\n\t\t *\n\t\t * The gateway stores cards before processing a payment, so this checks whether the customer checked \"save method\"\n\t\t * at checkout, and isn't otherwise using a saved method already.\n\t\t *\n\t\t * @since 2.1.0\n\t\t *\n\t\t * @return {string} {'CHARGE'|'STORE'}\n\t\t */\n\t\tget_intent() {\n\t\t\tconst $save_method_input = $( '#wc-square-credit-card-tokenize-payment-method' );\n\n\t\t\tlet save_payment_method;\n\n\t\t\tif ( $save_method_input.is( 'input:checkbox' ) ) {\n\t\t\t\tsave_payment_method = $save_method_input.is( ':checked' );\n\t\t\t} else {\n\t\t\t\tsave_payment_method = 'true' === $save_method_input.val();\n\t\t\t}\n\n\t\t\tif ( ! this.get_tokenized_payment_method_id() && save_payment_method ) {\n\t\t\t\treturn 'STORE';\n\t\t\t}\n\n\t\t\treturn 'CHARGE';\n\t\t}\n\n\t\t/**\n\t\t * Gets the amount of this payment.\n\t\t *\n\t\t * @since 2.1.0\n\t\t *\n\t\t * @return {string} Payment amount.\n\t\t */\n\t\tget_amount() {\n\t\t\treturn $( `input[name=wc-${ this.id_dasherized }-amount]` ).val();\n\t\t}\n\n\t\t/**\n\t\t * Handles unsupported browsers.\n\t\t *\n\t\t * @since 2.0.0\n\t\t */\n\t\thandle_unsupported_browser() {}\n\n\t\t/**\n\t\t * Handle error data.\n\t\t *\n\t\t * @since 2.0.0\n\t\t *\n\t\t * @param {Object|null} errors\n\t\t */\n\t\thandle_errors( errors = null ) {\n\t\t\tthis.log( 'Error getting payment data', 'error' );\n\n\t\t\t// clear any previous nonces\n\t\t\t$( 'input[name=wc-square-credit-card-payment-nonce]' ).val( '' );\n\t\t\t$( 'input[name=wc-square-credit-card-buyer-verification-token]' ).val( '' );\n\n\t\t\tconst messages = [];\n\n\t\t\tif ( errors ) {\n\t\t\t\tconst field_order = [ 'none', 'cardNumber', 'expirationDate', 'cvv', 'postalCode' ];\n\n\t\t\t\tif ( errors.length >= 1 ) {\n\t\t\t\t\t// sort based on the field order without the brackets around a.field and b.field.\n\t\t\t\t\t// the precedence is different and gives different results.\n\t\t\t\t\terrors.sort( ( a, b ) => {\n\t\t\t\t\t\treturn field_order.indexOf( a.field ) - field_order.indexOf( b.field );\n\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\t$( errors ).each( ( index, error ) => {\n\t\t\t\t\t// only display the errors that can be helped by the customer.\n\t\t\t\t\tif ( 'UNSUPPORTED_CARD_BRAND' === error.type || 'VALIDATION_ERROR' === error.type ) {\n\t\t\t\t\t\t// To avoid confusion between CSC used in the frontend and CVV that is used in the error message.\n\t\t\t\t\t\treturn messages.push( error.message.replace( /CVV/, 'CSC' ) );\n\t\t\t\t\t}\n\n\t\t\t\t\t// otherwise, log more serious errors to the debug log.\n\t\t\t\t\treturn this.log_data( errors, 'response' );\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\t// if no specific messages are set, display a general error.\n\t\t\tif ( messages.length === 0 ) {\n\t\t\t\tmessages.push( this.general_error );\n\t\t\t}\n\n\t\t\t// Conditionally process error rendering.\n\t\t\tif ( ! this.is_add_payment_method_page && ! this.is_manual_order_payment ) {\n\t\t\t\tthis.render_checkout_errors( messages );\n\t\t\t} else {\n\t\t\t\tthis.render_errors( messages );\n\t\t\t}\n\n\t\t\tthis.unblock_ui();\n\t\t}\n\n\t\t/**\n\t\t * Public: Render any new errors and bring them into the viewport.\n\t\t *\n\t\t * @param {Array} errors\n\t\t */\n\t\trender_errors( errors ) {\n\t\t\t// hide and remove any previous errors.\n\t\t\t$( '.woocommerce-error, .woocommerce-message' ).remove();\n\n\t\t\t// add errors.\n\t\t\tthis.form.prepend( '<ul class=\"woocommerce-error\"><li>' + errors.join( '</li><li>' ) + '</li></ul>' );\n\n\t\t\t// unblock UI\n\t\t\tthis.form.removeClass( 'processing' ).unblock();\n\t\t\tthis.form.find( '.input-text, select' ).trigger( 'blur' );\n\n\t\t\t// scroll to top\n\t\t\t$( 'html, body' ).animate( {\n\t\t\t\tscrollTop: this.form.offset().top - 100,\n\t\t\t}, 1000 );\n\t\t}\n\n\t\t/**\n\t\t * Blocks the payment form UI.\n\t\t *\n\t\t * @since 3.0.0\n\t\t */\n\t\tblock_ui() {\n\t\t\tthis.form.block( {\n\t\t\t\tmessage: null,\n\t\t\t\toverlayCSS: {\n\t\t\t\t\tbackground: '#fff',\n\t\t\t\t\topacity: 0.6,\n\t\t\t\t},\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Unblocks the payment form UI.\n\t\t *\n\t\t * @since 3.0.0\n\t\t */\n\t\tunblock_ui() {\n\t\t\treturn this.form.unblock();\n\t\t}\n\n\t\t/**\n\t\t * Hides save payment method checkbox.\n\t\t *\n\t\t * @since 2.1.2\n\t\t *\n\t\t * @param {string} id_dasherized\n\t\t */\n\t\thide_save_payment_checkbox( id_dasherized ) {\n\t\t\tconst $parent_row = $( `input.js-wc-${ id_dasherized }-tokenize-payment-method` ).closest( 'p.form-row' );\n\n\t\t\t$parent_row.hide();\n\t\t\t$parent_row.next().hide();\n\t\t}\n\n\t\t/**\n\t\t * Shows save payment method checkbox.\n\t\t *\n\t\t * @since 2.1.2\n\t\t *\n\t\t * @param {string} id_dasherized\n\t\t */\n\t\tshow_save_payment_checkbox( id_dasherized ) {\n\t\t\tconst $parent_row = $( `input.js-wc-${ id_dasherized }-tokenize-payment-method` ).closest( 'p.form-row' );\n\n\t\t\t$parent_row.slideDown();\n\t\t\t$parent_row.next().show();\n\t\t}\n\n\t\t/**\n\t\t * Determines if a nonce is present in the hidden input.\n\t\t *\n\t\t * @since 2.0.0\n\t\t *\n\t\t * @return {boolean} True if nonce is present, otherwise false.\n\t\t */\n\t\thas_nonce() {\n\t\t\treturn $( `input[name=wc-${ this.id_dasherized }-payment-nonce]` ).val();\n\t\t}\n\n\t\t/**\n\t\t * Determines if a verification token is present in the hidden input.\n\t\t *\n\t\t * @since 2.1.0\n\t\t *\n\t\t * @return {boolean} True if verification token is present, otherwise false.\n\t\t */\n\t\thas_verification_token() {\n\t\t\treturn $( `input[name=wc-${ this.id_dasherized }-buyer-verification-token]` ).val();\n\t\t}\n\n\t\t/**\n\t\t * Logs data to the debug log via AJAX.\n\t\t *\n\t\t * @since 2.0.0\n\t\t *\n\t\t * @param {Object} data Request data.\n\t\t * @param {string} type Data type.\n\t\t */\n\t\tlog_data( data, type ) {\n\t\t\t// if logging is disabled, bail.\n\t\t\tif ( ! this.logging_enabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst ajax_data = {\n\t\t\t\taction: 'wc_' + this.id + '_log_js_data',\n\t\t\t\tsecurity: this.ajax_log_nonce,\n\t\t\t\ttype,\n\t\t\t\tdata,\n\t\t\t};\n\n\t\t\t$.ajax( {\n\t\t\t\turl: this.ajax_url,\n\t\t\t\tdata: ajax_data,\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Logs any messages or errors to the console.\n\t\t *\n\t\t * @since 2.0.0\n\t\t *\n\t\t * @param {string} message\n\t\t * @param {string} type Data type.\n\t\t */\n\t\tlog( message, type = 'notice' ) {\n\t\t\t// if logging is disabled, bail.\n\t\t\tif ( ! this.logging_enabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( 'error' === type ) {\n\t\t\t\tconsole.error( 'Square Error: ' + message );\n\t\t\t} else {\n\t\t\t\tconsole.log( 'Square: ' + message );\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * AJAX validate WooCommerce form data.\n\t\t *\n\t\t * Triggered only if errors are present on Square payment form.\n\t\t *\n\t\t * @since 2.2\n\t\t *\n\t\t * @param {Array} square_errors Square validation errors.\n\t\t */\n\t\trender_checkout_errors( square_errors ) {\n\t\t\tconst ajax_url = wc_cart_fragments_params.wc_ajax_url.toString().replace( '%%endpoint%%', this.id + '_checkout_handler' );\n\t\t\tconst square_handler = this;\n\n\t\t\tconst form_data = this.form.serializeArray();\n\n\t\t\t// Add action field to data for nonce verification.\n\t\t\tform_data.push( {\n\t\t\t\tname: 'wc_' + this.id + '_checkout_validate_nonce',\n\t\t\t\tvalue: this.ajax_wc_checkout_validate_nonce,\n\t\t\t} );\n\n\t\t\treturn $.ajax( {\n\t\t\t\turl: ajax_url,\n\t\t\t\tmethod: 'post',\n\t\t\t\tcache: false,\n\t\t\t\tdata: form_data,\n\t\t\t\tcomplete: ( response ) => {\n\t\t\t\t\tconst result = response.responseJSON;\n\n\t\t\t\t\t// If validation is not triggered and WooCommerce returns failure.\n\t\t\t\t\t// Temporary workaround to fix problems when user email is invalid.\n\t\t\t\t\tif ( result.hasOwnProperty( 'result' ) && 'failure' === result.result ) {\n\t\t\t\t\t\t$( result.messages ).map( ( message ) => {\n\t\t\t\t\t\t\tconst errors = [];\n\n\t\t\t\t\t\t\t$( message ).children( 'li' ).each( () => {\n\t\t\t\t\t\t\t\terrors.push( $( this ).text().trim() );\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\treturn square_errors.unshift( ...errors );\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t// If validation is complete and WooCommerce returns validaiton errors.\n\t\t\t\t\t} else if ( result.hasOwnProperty( 'success' ) && ! result.success ) {\n\t\t\t\t\t\tsquare_errors.unshift( ...result.data.messages );\n\t\t\t\t\t}\n\n\t\t\t\t\tsquare_handler.render_errors( square_errors );\n\t\t\t\t},\n\t\t\t} );\n\t\t}\n\t}\n\n\twindow.WC_Square_Payment_Form_Handler = WC_Square_Payment_Form_Handler;\n} );\n"],"file":"wc-square.min.js"}
 
build/index.asset.php CHANGED
@@ -1 +1 @@
1
- <?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '0b5b2202560893ec45752e4f994681b3');
1
+ <?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '3b8457821db6fd492c3826662c0891b7');
build/index.js CHANGED
@@ -1 +1 @@
1
- !function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=30)}([function(e,t){e.exports=window.wp.element},function(e,t){e.exports=function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=window.React},function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});var a=n(r(2));t.Context=a.createContext({applePayState:"loading",formId:"",googlePayState:"loading",masterpassState:"loading",onCreateNonce:function(){},onVerifyBuyer:function(e,t,r){}}),t.default=t.Context},function(e,t,r){"use strict";function n(e){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}Object.defineProperty(t,"__esModule",{value:!0});var a=r(8);n(r(15)),n(r(3)),n(r(16)),n(r(17)),n(r(18)),n(r(19)),n(r(20)),n(r(21)),n(r(22)),n(r(23)),n(r(24)),n(r(8)),t.default=a.SquarePaymentForm},function(e,t){e.exports=window.wp.i18n},function(e,t){e.exports=window.regeneratorRuntime},function(e,t,r){var n=r(25),a=r(26),o=r(27),i=r(29);e.exports=function(e,t){return n(e)||a(e,t)||o(e,t)||i()},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(r(2)),i=a(r(14)),l=a(r(3));t.SquarePaymentForm=function(e){var t=o.useState("loading"),r=t[0],n=t[1],a=o.useState("loading"),c=a[0],u=a[1],s=o.useState("loading"),d=s[0],f=s[1],p=o.useState(""),m=p[0],v=p[1],y=o.useState(!1),b=y[0],g=y[1],h=o.useState(void 0),_=h[0],O=h[1],C=o.useState(!1),S=C[0],E=C[1],j=i.default((function(t,r,n,a,o,i){!t&&e.createVerificationDetails?_&&_.verifyBuyer(r,e.createVerificationDetails(),(function(t,l){e.cardNonceResponseReceived(t?[t]:null,r,n,l?l.token:void 0,a,o,i)})):e.cardNonceResponseReceived(t,r,n,"",a,o,i)}));function x(t){var r=Object.keys(t);r.includes("masterpass")&&f(!0===t.masterpass?"ready":"unavailable"),r.includes("applePay")&&n(!0===t.applePay?"ready":"unavailable"),r.includes("googlePay")&&u(!0===t.googlePay?"ready":"unavailable"),e.methodsSupported&&e.methodsSupported(t)}var w=function(){E(!0),e.paymentFormLoaded&&e.paymentFormLoaded()};if(o.useEffect((function(){S&&_&&(_.recalculateSize(),e.postalCode&&_.setPostalCode(e.postalCode()),e.focusField&&_.focus(e.focusField()))}),[S,_]),o.useEffect((function(){!function(t,r){if(document.getElementById("sq-payment-form-script")&&"function"==typeof SqPaymentForm)t&&t();else{var n=document.createElement("script");n.id="sq-payment-form-script",e.sandbox?n.src="https://js.squareupsandbox.com/v2/paymentform":n.src="https://js.squareup.com/v2/paymentform",n.onload=function(){t&&t()},n.onerror=function(){r&&r()},document.body.appendChild(n)}}((function(){return g(!0)}),(function(){return v("Unable to load Square payment library")}))}),[]),o.useEffect((function(){return function(){if(!(!b||_||m.length>0))try{var t=new SqPaymentForm(function(e){var t={apiWrapper:e.apiWrapper,applicationId:e.applicationId,autoBuild:!1,callbacks:{cardNonceResponseReceived:e.cardNonceResponseReceived?j:null,createPaymentRequest:e.createPaymentRequest,inputEventReceived:e.inputEventReceived,methodsSupported:x,paymentFormLoaded:w,shippingContactChanged:e.shippingContactChanged,shippingOptionChanged:e.shippingOptionChanged,unsupportedBrowserDetected:e.unsupportedBrowserDetected},locationId:e.locationId};return document.getElementById(e.formId+"-sq-card")?t.card={elementId:e.formId+"-sq-card",inputStyle:e.inputStyles&&e.inputStyles[0]}:document.getElementById(e.formId+"-sq-gift-card")?(t.giftCard={elementId:e.formId+"-sq-gift-card",placeholder:e.placeholderGiftCard||"• • • • • • • • • • • • • • • •"},t.inputClass=e.inputClass||"sq-input",t.inputStyles=e.inputStyles):(t.inputClass=e.inputClass||"sq-input",t.inputStyles=e.inputStyles,document.getElementById(e.formId+"-sq-apple-pay")&&(t.applePay={elementId:e.formId+"-sq-apple-pay"}),document.getElementById(e.formId+"-sq-google-pay")&&(t.googlePay={elementId:e.formId+"-sq-google-pay"}),document.getElementById(e.formId+"-sq-masterpass")&&(t.masterpass={elementId:e.formId+"-sq-masterpass"}),document.getElementById(e.formId+"-sq-card-number")&&(t.cardNumber={elementId:e.formId+"-sq-card-number",placeholder:e.placeholderCreditCard||"• • • • • • • • • • • • • • • •"}),document.getElementById(e.formId+"-sq-cvv")&&(t.cvv={elementId:e.formId+"-sq-cvv",placeholder:e.placeholderCVV||"CVV "}),document.getElementById(e.formId+"-sq-postal-code")?t.postalCode={elementId:e.formId+"-sq-postal-code",placeholder:e.placeholderPostal||"12345"}:t.postalCode=!1,document.getElementById(e.formId+"-sq-expiration-date")&&(t.expirationDate={elementId:e.formId+"-sq-expiration-date",placeholder:e.placeholderExpiration||"MM/YY"})),t}(e));t.build(),O(t)}catch(e){var r=e.message||"Unable to build Square payment form";v(r)}}(),function(){_&&(_.destroy(),O(void 0))}}),[b]),o.useEffect((function(){if(_&&"ready"===d){var t=document.getElementById(e.formId+"-sq-masterpass");if(t){var r=_.masterpassImageUrl();t.style.display="inline-block",t.style.backgroundImage="url("+r+")"}}}),[_,d]),m)return o.default.createElement("div",{className:"sq-payment-form"},o.default.createElement("div",{className:"sq-error-message"},m));var P={applePayState:r,formId:e.formId,googlePayState:c,masterpassState:d,onCreateNonce:function(){_&&_.requestCardNonce()},onVerifyBuyer:function(e,t,r){_&&_.verifyBuyer(e,t,r)}};return o.default.createElement(l.default.Provider,{value:P},o.default.createElement("div",{id:e.formId,className:"sq-payment-form"},e.children))},t.SquarePaymentForm.defaultProps={apiWrapper:"reactjs/0.7.2",formId:"sq-payment-form",inputStyles:[{_mozOsxFontSmoothing:"grayscale",_webkitFontSmoothing:"antialiased",backgroundColor:"transparent",color:"#373F4A",fontFamily:"Helvetica Neue",fontSize:"16px",lineHeight:"24px",padding:"16px",placeholderColor:"#CCC"}],sandbox:!1}},function(e,t){e.exports=window.wc.wcBlocksRegistry},function(e,t,r){var n=r(13);e.exports=function(e,t){if(null==e)return{};var r,a,o=n(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)r=i[a],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){function r(e,t,r,n,a,o,i){try{var l=e[o](i),c=l.value}catch(e){return void r(e)}l.done?t(c):Promise.resolve(c).then(n,a)}e.exports=function(e){return function(){var t=this,n=arguments;return new Promise((function(a,o){var i=e.apply(t,n);function l(e){r(i,a,o,l,c,"next",e)}function c(e){r(i,a,o,l,c,"throw",e)}l(void 0)}))}},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=window.wc.wcSettings},function(e,t){e.exports=function(e,t){if(null==e)return{};var r,n,a={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(a[r]=e[r]);return a},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(2);t.default=function(e){var t=n.useRef(e);return n.useLayoutEffect((function(){t.current=e}),[e]),n.useCallback((function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return t.current.apply(t,e)}),[])}},function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(r(2)),i=a(r(3));t.ApplePayButton=function(e){var t=o.useContext(i.default);return o.default.createElement("div",null,o.default.createElement("button",{id:t.formId+"-sq-apple-pay",className:"sq-apple-pay",style:{display:"ready"===t.applePayState?"block":"none"}}),"loading"===t.applePayState&&e.loadingView,"unavailable"===t.applePayState&&e.unavailableView)}},function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(r(2)),i=a(r(3));t.CreditCardCVVInput=function(e){var t=o.useContext(i.default);return o.default.createElement("div",null,e.label&&o.default.createElement("span",{className:"sq-label"},e.label),o.default.createElement("div",{id:t.formId+"-sq-cvv"}))},t.CreditCardCVVInput.defaultProps={label:"CVV"}},function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(r(2)),i=a(r(3));t.CreditCardExpirationDateInput=function(e){var t=o.useContext(i.default);return o.default.createElement("div",null,e.label&&o.default.createElement("span",{className:"sq-label"},e.label),o.default.createElement("div",{id:t.formId+"-sq-expiration-date"}))},t.CreditCardExpirationDateInput.defaultProps={label:"Expiration"}},function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(r(2)),i=a(r(3));t.CreditCardNumberInput=function(e){var t=o.useContext(i.default);return o.default.createElement("div",null,e.label&&o.default.createElement("span",{className:"sq-label"},e.label),o.default.createElement("div",{id:t.formId+"-sq-card-number"}))},t.CreditCardNumberInput.defaultProps={label:"Credit Card"}},function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(r(2)),i=a(r(3));t.CreditCardPostalCodeInput=function(e){var t=o.useContext(i.default);return o.default.createElement("div",null,e.label&&o.default.createElement("span",{className:"sq-label"},e.label),o.default.createElement("div",{id:t.formId+"-sq-postal-code"}))},t.CreditCardPostalCodeInput.defaultProps={label:"Postal"}},function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(r(2)),i=a(r(3));t.CreditCardSubmitButton=function(e){var t=o.useContext(i.default);return o.default.createElement("button",{className:"sq-creditcard",onClick:t.onCreateNonce},e.children?e.children:"Pay")}},function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(r(2)),i=a(r(3));t.GiftCardInput=function(e){var t=o.useContext(i.default);return o.default.createElement("div",null,e.label&&o.default.createElement("span",{className:"sq-label"},e.label),o.default.createElement("div",{id:t.formId+"-sq-gift-card"}))},t.GiftCardInput.defaultProps={label:"Gift Card"}},function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(r(2)),i=a(r(3));t.GooglePayButton=function(e){var t=o.useContext(i.default);return o.default.createElement("div",null,o.default.createElement("button",{id:t.formId+"-sq-google-pay",className:"sq-google-pay",style:{display:"ready"===t.googlePayState?"block":"none"}}),"loading"===t.googlePayState&&e.loadingView,"unavailable"===t.googlePayState&&e.unavailableView)}},function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(r(2)),i=a(r(3));t.MasterpassButton=function(e){var t=o.useContext(i.default);return o.default.createElement("div",null,o.default.createElement("button",{id:t.formId+"-sq-masterpass",className:"sq-masterpass",style:{display:"ready"===t.masterpassState?"block":"none"}}),"loading"===t.masterpassState&&e.loadingView,"unavailable"===t.masterpassState&&e.unavailableView)}},function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(r(2)),i=a(r(3));t.SimpleCard=function(){var e=o.useContext(i.default);return o.default.createElement("div",{id:e.formId+"-sq-card"})}},function(e,t){e.exports=function(e){if(Array.isArray(e))return e},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var r=[],_n=!0,n=!1,a=void 0;try{for(var o,i=e[Symbol.iterator]();!(_n=(o=i.next()).done)&&(r.push(o.value),!t||r.length!==t);_n=!0);}catch(e){n=!0,a=e}finally{try{_n||null==i.return||i.return()}finally{if(n)throw a}}return r}},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,r){var n=r(28);e.exports=function(e,t){if(e){if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,r){"use strict";r.r(t);var n=r(9),a=r(10),o=r.n(a),i=r(0),l=r(5),c=r(4),u=r(1),s=r.n(u),d=r(11),f=r.n(d),p=r(6),m=r.n(p),v=r(12);function y(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return b(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?b(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,l=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return i=e.done,e},e:function(e){l=!0,o=e},f:function(){try{i||null==r.return||r.return()}finally{if(l)throw o}}}}function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var g=null,h=function(){if(null!==g)return g;var e=Object(v.getSetting)("square_credit_card_data",null);if(!e)throw new Error("Square initialization data is not available");return g={title:e.title||"",applicationId:e.application_id||"",locationId:e.location_id||"",isSandbox:e.is_sandbox||!1,is3dsEnabled:e.is_3ds_enabled||!1,inputStyles:e.input_styles||[],availableCardTypes:e.available_card_types||{},loggingEnabled:e.logging_enabled||!1,generalError:e.general_error||"",showSavedCards:e.show_saved_cards||!1,showSaveOption:e.show_save_option||!1,supports:e.supports||{}}},_=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{logs:[],notices:[]},r=!1;if(e){var n=["none","cardNumber","expirationDate","cvv","postalCode"];e.length>=1&&e.sort((function(e,t){return n.indexOf(e.field)-n.indexOf(t.field)}));var a,o=y(e);try{for(o.s();!(a=o.n()).done;){var i=a.value;"UNSUPPORTED_CARD_BRAND"===i.type||"VALIDATION_ERROR"===i.type?(t.notices.push(i.message.replace(/CVV/,"CSC")),r=!0):C(i,t)}}catch(e){o.e(e)}finally{o.f()}}r||t.notices.push(h().generalError)},O=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"notice";h().loggingEnabled&&("error"===t?console.error(e):console.log(e))},C=function(e,t){h().loggingEnabled&&t&&t.logs.push(e)};function S(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function E(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?S(Object(r),!0).forEach((function(t){s()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):S(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var j=function(e){var t=e.checkoutFormHandler,r=e.eventRegistration,n=e.emitResponse,a=Object(i.useContext)(c.Context),o=r.onPaymentProcessing,l=r.onCheckoutAfterProcessingWithError,u=r.onCheckoutAfterProcessingWithSuccess;return function(e,t,r,n,a,o){var l=Object(i.useRef)(r);Object(i.useEffect)((function(){l.current=r}),[r]),Object(i.useEffect)((function(){return e(function(){var e=f()(m.a.mark((function e(){var r,i,c,u,s,d;return m.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={type:t.responseTypes.SUCCESS},i={nonce:"",notices:[],logs:[]},e.next=4,a(l.current);case 4:if(c=e.sent,u=E(E({},i),c),s=u.token||u.nonce,!h().is3dsEnabled||!s){e.next=14;break}return e.next=10,o(l.current,s);case 10:d=e.sent,u.verificationToken=d.verificationToken||"",u.logs=u.logs.concat(d.log||[]),u.errors=u.notices.concat(d.errors||[]);case 14:return s||u.logs.length>0?r.meta={paymentMethodData:n(u)}:u.notices.length>0&&(r.type=t.responseTypes.ERROR,r.message=u.notices),e.abrupt("return",r);case 16:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}())}),[e,t.responseTypes.SUCCESS,t.responseTypes.ERROR,a,o,n])}(o,n,a,t.getPaymentMethodData,t.createNonce,t.verifyBuyer),function(e,t,r){Object(i.useEffect)((function(){var n=function(e){var t={type:r.responseTypes.SUCCESS},n=e.processingResponse,a=n.paymentStatus,o=n.paymentDetails;return a===r.responseTypes.ERROR&&o.checkoutNotices&&(t={type:r.responseTypes.ERROR,message:JSON.parse(o.checkoutNotices),messageContext:r.noticeContexts.PAYMENTS,retry:!0}),t},a=e(n),o=t(n);return function(){a(),o()}}),[e,t,r.noticeContexts.PAYMENTS,r.responseTypes.ERROR,r.responseTypes.SUCCESS])}(l,u,n),null},x=r(7),w=r.n(x);function P(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return I(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?I(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,l=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return i=e.done,e},e:function(e){l=!0,o=e},f:function(){try{i||null==r.return||r.return()}finally{if(l)throw o}}}}function I(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var q=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=Object(i.useState)(!1),a=w()(n,2),o=a[0],l=a[1],c=Object(i.useState)(""),u=w()(c,2),d=u[0],f=u[1],p=Object(i.useRef)(null),m=Object(i.useRef)(null),v=Object(i.useMemo)((function(){var n=t&&!r?"STORE":"CHARGE",a={billingContact:{familyName:e.billingData.last_name||"",givenName:e.billingData.first_name||"",email:e.billingData.email||"",country:e.billingData.country||"",region:e.billingData.state||"",city:e.billingData.city||"",postalCode:e.billingData.postcode||"",phone:e.billingData.phone||"",addressLines:[e.billingData.address_1||"",e.billingData.address_2||""]},intent:n};return"CHARGE"===n&&(a.amount=(e.cartTotal.value/100).toString(),a.currencyCode=e.currency.code),a}),[e.billingData,e.cartTotal.value,e.currency.code,t,r]),y=Object(i.useCallback)((function(e){var n,a,o,i=e.cardData,l=e.nonce,c=e.verificationToken,u=e.notices,f=e.logs;return o={},s()(o,"wc-".concat("square-credit-card","-card-type"),d||""),s()(o,"wc-".concat("square-credit-card","-last-four"),(null==i?void 0:i.last_4)||""),s()(o,"wc-".concat("square-credit-card","-exp-month"),(null==i||null===(n=i.exp_month)||void 0===n?void 0:n.toString())||""),s()(o,"wc-".concat("square-credit-card","-exp-year"),(null==i||null===(a=i.exp_year)||void 0===a?void 0:a.toString())||""),s()(o,"wc-".concat("square-credit-card","-payment-postcode"),(null==i?void 0:i.billing_postal_code)||""),s()(o,"wc-".concat("square-credit-card","-payment-nonce"),l||""),s()(o,"wc-".concat("square-credit-card","-payment-token"),r||""),s()(o,"wc-".concat("square-credit-card","-buyer-verification-token"),c||""),s()(o,"wc-".concat("square-credit-card","-tokenize-payment-method"),t||!1),s()(o,"log-data",f.length>0?JSON.stringify(f):""),s()(o,"checkout-notices",u.length>0?JSON.stringify(u):""),o}),[d,t,r]),b=function(e,t,r){var n={notices:[],logs:[]};e?_(e,n):t?(C(r,n),O("Card data received"),O(r),n.cardData=r,n.nonce=t):(C("Nonce is missing from the Square response",n),O("Nonce is missing from the Square response","error"),_([],n)),p.current&&p.current(n)},g=Object(i.useCallback)((function(e){if(!r){var t=new Promise((function(e){return p.current=e}));return e.onCreateNonce(),t}return Promise.resolve({token:r})}),[r]),S=Object(i.useCallback)((function(e,t){var r=new Promise((function(e){return m.current=e}));return e.onVerifyBuyer(t,v,E),r}),[v,E]),E=Object(i.useCallback)((function(e,t){var r={notices:[],logs:[]};if(e){var n,a=P(e);try{for(a.s();!(n=a.n()).done;){var o=n.value;o.field||(o.field="none")}}catch(e){a.e(e)}finally{a.f()}_(e,r)}t&&t.token?r.verificationToken=t.token:(C("Verification token is missing from the Square response",r),O("Verification token is missing from the Square response","error"),_([],r)),m.current&&m.current(r)}),[m]),j=Object(i.useCallback)((function(e){if("cardBrandChanged"===e.eventType){var t=e.cardBrand,r="plain";null!==t&&"unknown"!==t||(r=""),null!==h().availableCardTypes[t]&&(r=h().availableCardTypes[t]),O("Card brand changed to ".concat(t)),f(r)}}),[]),x=Object(i.useCallback)((function(){return e.billingData.postcode||""}),[e.billingData.postcode]);return{cardNonceResponseReceived:b,handleInputReceived:j,isLoaded:o,setLoaded:l,getPostalCode:x,cardType:d,createNonce:g,verifyBuyer:S,getPaymentMethodData:y}},M=function(e){var t=e.cardType;return Object(i.createElement)("fieldset",{id:"wc-square-credit-card-credit-card-form"},Object(i.createElement)("span",{className:"sq-label"},Object(l.__)("Card Number","woocommerce-square")),Object(i.createElement)("div",{id:"wc-square-credit-card-account-number-hosted",className:"wc-square-credit-card-hosted-field ".concat(t?"card-type-".concat(t):"")},Object(i.createElement)(c.CreditCardNumberInput,{label:""})),Object(i.createElement)("div",{className:"sq-form-third"},Object(i.createElement)("span",{className:"sq-label"},Object(l.__)("Expiration (MM/YY)","woocommerce-square")),Object(i.createElement)("div",{id:"wc-square-credit-card-expiry-hosted",className:"wc-square-credit-card-hosted-field"},Object(i.createElement)(c.CreditCardExpirationDateInput,{label:""}))),Object(i.createElement)("div",{className:"sq-form-third"},Object(i.createElement)("span",{className:"sq-label"},Object(l.__)("Card Security Code","woocommerce-square")),Object(i.createElement)("div",{id:"wc-square-credit-card-csc-hosted",className:"wc-square-credit-card-hosted-field"},Object(i.createElement)(c.CreditCardCVVInput,{label:""}))),Object(i.createElement)("div",{className:"sq-form-third"},Object(i.createElement)("span",{className:"sq-label"},Object(l.__)("Postal code","woocommerce-square")),Object(i.createElement)("div",{id:"wc-square-credit-card-postal-code-hosted",className:"wc-square-credit-card-hosted-field"},Object(i.createElement)(c.CreditCardPostalCodeInput,{label:""}))))},R=function(e){var t=e.billing,r=e.eventRegistration,n=e.emitResponse,a=e.shouldSavePayment,o=q(t,a);return Object(i.createElement)(c.SquarePaymentForm,{formId:"square-credit-card",sandbox:h().isSandbox,applicationId:h().applicationId,locationId:h().locationId,inputStyles:h().inputStyles,placeholderCreditCard:"•••• •••• •••• ••••",placeholderExpiration:Object(l.__)("MM / YY","woocommerce-square"),placeholderCVV:Object(l.__)("CSC","woocommerce-square"),postalCode:o.getPostalCode,cardNonceResponseReceived:o.cardNonceResponseReceived,inputEventReceived:o.handleInputReceived,paymentFormLoaded:function(){return o.setLoaded(!0)}},Object(i.createElement)(M,{cardType:o.cardType}),o.isLoaded&&Object(i.createElement)(j,{checkoutFormHandler:o,eventRegistration:r,emitResponse:n}))},N=function(e){var t=e.RenderedComponent,r=o()(e,["RenderedComponent"]);return Object(i.createElement)(t,r)},k={name:"square-credit-card",label:Object(i.createElement)((function(e){var t=e.components.PaymentMethodLabel;return Object(i.createElement)(t,{text:h().title})}),null),content:Object(i.createElement)(N,{RenderedComponent:R}),edit:Object(i.createElement)(N,{RenderedComponent:R}),savedTokenComponent:Object(i.createElement)(N,{RenderedComponent:function(e){var t=e.billing,r=e.eventRegistration,n=e.emitResponse,a=e.token,o=q(t,!1,a);return Object(i.createElement)(c.SquarePaymentForm,{formId:"square-credit-card-saved-card",sandbox:h().isSandbox,applicationId:h().applicationId,locationId:h().locationId,paymentFormLoaded:function(){return o.setLoaded(!0)}},o.isLoaded&&Object(i.createElement)(j,{checkoutFormHandler:o,eventRegistration:r,emitResponse:n}))}}),paymentMethodId:"square_credit_card",ariaLabel:"Square",canMakePayment:function(){return!(!h().applicationId||!h().locationId)},supports:{features:h().supports,showSavedCards:h().showSavedCards,showSaveOption:h().showSaveOption}};Object(n.registerPaymentMethod)(k)}]);
1
+ !function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=30)}([function(e,t){e.exports=window.wp.element},function(e,t){e.exports=function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=window.React},function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});var a=n(r(2));t.Context=a.createContext({applePayState:"loading",formId:"",googlePayState:"loading",masterpassState:"loading",onCreateNonce:function(){},onVerifyBuyer:function(e,t,r){}}),t.default=t.Context},function(e,t,r){"use strict";function n(e){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}Object.defineProperty(t,"__esModule",{value:!0});var a=r(8);n(r(15)),n(r(3)),n(r(16)),n(r(17)),n(r(18)),n(r(19)),n(r(20)),n(r(21)),n(r(22)),n(r(23)),n(r(24)),n(r(8)),t.default=a.SquarePaymentForm},function(e,t){e.exports=window.wp.i18n},function(e,t){e.exports=window.regeneratorRuntime},function(e,t,r){var n=r(25),a=r(26),o=r(27),i=r(29);e.exports=function(e,t){return n(e)||a(e,t)||o(e,t)||i()},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(r(2)),i=a(r(14)),l=a(r(3));t.SquarePaymentForm=function(e){var t=o.useState("loading"),r=t[0],n=t[1],a=o.useState("loading"),c=a[0],u=a[1],s=o.useState("loading"),d=s[0],f=s[1],p=o.useState(""),m=p[0],v=p[1],y=o.useState(!1),b=y[0],g=y[1],h=o.useState(void 0),_=h[0],O=h[1],C=o.useState(!1),S=C[0],E=C[1],j=i.default((function(t,r,n,a,o,i){!t&&e.createVerificationDetails?_&&_.verifyBuyer(r,e.createVerificationDetails(),(function(t,l){e.cardNonceResponseReceived(t?[t]:null,r,n,l?l.token:void 0,a,o,i)})):e.cardNonceResponseReceived(t,r,n,"",a,o,i)}));function x(t){var r=Object.keys(t);r.includes("masterpass")&&f(!0===t.masterpass?"ready":"unavailable"),r.includes("applePay")&&n(!0===t.applePay?"ready":"unavailable"),r.includes("googlePay")&&u(!0===t.googlePay?"ready":"unavailable"),e.methodsSupported&&e.methodsSupported(t)}var w=function(){E(!0),e.paymentFormLoaded&&e.paymentFormLoaded()};if(o.useEffect((function(){S&&_&&(_.recalculateSize(),e.postalCode&&_.setPostalCode(e.postalCode()),e.focusField&&_.focus(e.focusField()))}),[S,_]),o.useEffect((function(){!function(t,r){if(document.getElementById("sq-payment-form-script")&&"function"==typeof SqPaymentForm)t&&t();else{var n=document.createElement("script");n.id="sq-payment-form-script",e.sandbox?n.src="https://js.squareupsandbox.com/v2/paymentform":n.src="https://js.squareup.com/v2/paymentform",n.onload=function(){t&&t()},n.onerror=function(){r&&r()},document.body.appendChild(n)}}((function(){return g(!0)}),(function(){return v("Unable to load Square payment library")}))}),[]),o.useEffect((function(){return function(){if(!(!b||_||m.length>0))try{var t=new SqPaymentForm(function(e){var t={apiWrapper:e.apiWrapper,applicationId:e.applicationId,autoBuild:!1,callbacks:{cardNonceResponseReceived:e.cardNonceResponseReceived?j:null,createPaymentRequest:e.createPaymentRequest,inputEventReceived:e.inputEventReceived,methodsSupported:x,paymentFormLoaded:w,shippingContactChanged:e.shippingContactChanged,shippingOptionChanged:e.shippingOptionChanged,unsupportedBrowserDetected:e.unsupportedBrowserDetected},locationId:e.locationId};return document.getElementById(e.formId+"-sq-card")?t.card={elementId:e.formId+"-sq-card",inputStyle:e.inputStyles&&e.inputStyles[0]}:document.getElementById(e.formId+"-sq-gift-card")?(t.giftCard={elementId:e.formId+"-sq-gift-card",placeholder:e.placeholderGiftCard||"• • • • • • • • • • • • • • • •"},t.inputClass=e.inputClass||"sq-input",t.inputStyles=e.inputStyles):(t.inputClass=e.inputClass||"sq-input",t.inputStyles=e.inputStyles,document.getElementById(e.formId+"-sq-apple-pay")&&(t.applePay={elementId:e.formId+"-sq-apple-pay"}),document.getElementById(e.formId+"-sq-google-pay")&&(t.googlePay={elementId:e.formId+"-sq-google-pay"}),document.getElementById(e.formId+"-sq-masterpass")&&(t.masterpass={elementId:e.formId+"-sq-masterpass"}),document.getElementById(e.formId+"-sq-card-number")&&(t.cardNumber={elementId:e.formId+"-sq-card-number",placeholder:e.placeholderCreditCard||"• • • • • • • • • • • • • • • •"}),document.getElementById(e.formId+"-sq-cvv")&&(t.cvv={elementId:e.formId+"-sq-cvv",placeholder:e.placeholderCVV||"CVV "}),document.getElementById(e.formId+"-sq-postal-code")?t.postalCode={elementId:e.formId+"-sq-postal-code",placeholder:e.placeholderPostal||"12345"}:t.postalCode=!1,document.getElementById(e.formId+"-sq-expiration-date")&&(t.expirationDate={elementId:e.formId+"-sq-expiration-date",placeholder:e.placeholderExpiration||"MM/YY"})),t}(e));t.build(),O(t)}catch(e){var r=e.message||"Unable to build Square payment form";v(r)}}(),function(){_&&(_.destroy(),O(void 0))}}),[b]),o.useEffect((function(){if(_&&"ready"===d){var t=document.getElementById(e.formId+"-sq-masterpass");if(t){var r=_.masterpassImageUrl();t.style.display="inline-block",t.style.backgroundImage="url("+r+")"}}}),[_,d]),m)return o.default.createElement("div",{className:"sq-payment-form"},o.default.createElement("div",{className:"sq-error-message"},m));var P={applePayState:r,formId:e.formId,googlePayState:c,masterpassState:d,onCreateNonce:function(){_&&_.requestCardNonce()},onVerifyBuyer:function(e,t,r){_&&_.verifyBuyer(e,t,r)}};return o.default.createElement(l.default.Provider,{value:P},o.default.createElement("div",{id:e.formId,className:"sq-payment-form"},e.children))},t.SquarePaymentForm.defaultProps={apiWrapper:"reactjs/0.7.2",formId:"sq-payment-form",inputStyles:[{_mozOsxFontSmoothing:"grayscale",_webkitFontSmoothing:"antialiased",backgroundColor:"transparent",color:"#373F4A",fontFamily:"Helvetica Neue",fontSize:"16px",lineHeight:"24px",padding:"16px",placeholderColor:"#CCC"}],sandbox:!1}},function(e,t){e.exports=window.wc.wcBlocksRegistry},function(e,t,r){var n=r(13);e.exports=function(e,t){if(null==e)return{};var r,a,o=n(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)r=i[a],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){function r(e,t,r,n,a,o,i){try{var l=e[o](i),c=l.value}catch(e){return void r(e)}l.done?t(c):Promise.resolve(c).then(n,a)}e.exports=function(e){return function(){var t=this,n=arguments;return new Promise((function(a,o){var i=e.apply(t,n);function l(e){r(i,a,o,l,c,"next",e)}function c(e){r(i,a,o,l,c,"throw",e)}l(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=window.wc.wcSettings},function(e,t){e.exports=function(e,t){if(null==e)return{};var r,n,a={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(a[r]=e[r]);return a},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(2);t.default=function(e){var t=n.useRef(e);return n.useLayoutEffect((function(){t.current=e}),[e]),n.useCallback((function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return t.current.apply(t,e)}),[])}},function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(r(2)),i=a(r(3));t.ApplePayButton=function(e){var t=o.useContext(i.default);return o.default.createElement("div",null,o.default.createElement("button",{id:t.formId+"-sq-apple-pay",className:"sq-apple-pay",style:{display:"ready"===t.applePayState?"block":"none"}}),"loading"===t.applePayState&&e.loadingView,"unavailable"===t.applePayState&&e.unavailableView)}},function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(r(2)),i=a(r(3));t.CreditCardCVVInput=function(e){var t=o.useContext(i.default);return o.default.createElement("div",null,e.label&&o.default.createElement("span",{className:"sq-label"},e.label),o.default.createElement("div",{id:t.formId+"-sq-cvv"}))},t.CreditCardCVVInput.defaultProps={label:"CVV"}},function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(r(2)),i=a(r(3));t.CreditCardExpirationDateInput=function(e){var t=o.useContext(i.default);return o.default.createElement("div",null,e.label&&o.default.createElement("span",{className:"sq-label"},e.label),o.default.createElement("div",{id:t.formId+"-sq-expiration-date"}))},t.CreditCardExpirationDateInput.defaultProps={label:"Expiration"}},function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(r(2)),i=a(r(3));t.CreditCardNumberInput=function(e){var t=o.useContext(i.default);return o.default.createElement("div",null,e.label&&o.default.createElement("span",{className:"sq-label"},e.label),o.default.createElement("div",{id:t.formId+"-sq-card-number"}))},t.CreditCardNumberInput.defaultProps={label:"Credit Card"}},function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(r(2)),i=a(r(3));t.CreditCardPostalCodeInput=function(e){var t=o.useContext(i.default);return o.default.createElement("div",null,e.label&&o.default.createElement("span",{className:"sq-label"},e.label),o.default.createElement("div",{id:t.formId+"-sq-postal-code"}))},t.CreditCardPostalCodeInput.defaultProps={label:"Postal"}},function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(r(2)),i=a(r(3));t.CreditCardSubmitButton=function(e){var t=o.useContext(i.default);return o.default.createElement("button",{className:"sq-creditcard",onClick:t.onCreateNonce},e.children?e.children:"Pay")}},function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(r(2)),i=a(r(3));t.GiftCardInput=function(e){var t=o.useContext(i.default);return o.default.createElement("div",null,e.label&&o.default.createElement("span",{className:"sq-label"},e.label),o.default.createElement("div",{id:t.formId+"-sq-gift-card"}))},t.GiftCardInput.defaultProps={label:"Gift Card"}},function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(r(2)),i=a(r(3));t.GooglePayButton=function(e){var t=o.useContext(i.default);return o.default.createElement("div",null,o.default.createElement("button",{id:t.formId+"-sq-google-pay",className:"sq-google-pay",style:{display:"ready"===t.googlePayState?"block":"none"}}),"loading"===t.googlePayState&&e.loadingView,"unavailable"===t.googlePayState&&e.unavailableView)}},function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(r(2)),i=a(r(3));t.MasterpassButton=function(e){var t=o.useContext(i.default);return o.default.createElement("div",null,o.default.createElement("button",{id:t.formId+"-sq-masterpass",className:"sq-masterpass",style:{display:"ready"===t.masterpassState?"block":"none"}}),"loading"===t.masterpassState&&e.loadingView,"unavailable"===t.masterpassState&&e.unavailableView)}},function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(r(2)),i=a(r(3));t.SimpleCard=function(){var e=o.useContext(i.default);return o.default.createElement("div",{id:e.formId+"-sq-card"})}},function(e,t){e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,a,o=[],_n=!0,i=!1;try{for(r=r.call(e);!(_n=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);_n=!0);}catch(e){i=!0,a=e}finally{try{_n||null==r.return||r.return()}finally{if(i)throw a}}return o}},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(28);e.exports=function(e,t){if(e){if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){"use strict";r.r(t);var n=r(9),a=r(10),o=r.n(a),i=r(0),l=r(5),c=r(4),u=r(1),s=r.n(u),d=r(11),f=r.n(d),p=r(6),m=r.n(p),v=r(12);function y(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return b(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?b(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,l=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){l=!0,o=e},f:function(){try{i||null==r.return||r.return()}finally{if(l)throw o}}}}function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var g=null,h=function(){if(null!==g)return g;var e=Object(v.getSetting)("square_credit_card_data",null);if(!e)throw new Error("Square initialization data is not available");return g={title:e.title||"",applicationId:e.application_id||"",locationId:e.location_id||"",isSandbox:e.is_sandbox||!1,is3dsEnabled:e.is_3ds_enabled||!1,inputStyles:e.input_styles||[],availableCardTypes:e.available_card_types||{},loggingEnabled:e.logging_enabled||!1,generalError:e.general_error||"",showSavedCards:e.show_saved_cards||!1,showSaveOption:e.show_save_option||!1,supports:e.supports||{}}},_=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{logs:[],notices:[]},r=!1;if(e){var n=["none","cardNumber","expirationDate","cvv","postalCode"];e.length>=1&&e.sort((function(e,t){return n.indexOf(e.field)-n.indexOf(t.field)}));var a,o=y(e);try{for(o.s();!(a=o.n()).done;){var i=a.value;"UNSUPPORTED_CARD_BRAND"===i.type||"VALIDATION_ERROR"===i.type?(t.notices.push(i.message.replace(/CVV/,"CSC")),r=!0):C(i,t)}}catch(e){o.e(e)}finally{o.f()}}r||t.notices.push(h().generalError)},O=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"notice";h().loggingEnabled&&("error"===t?console.error(e):console.log(e))},C=function(e,t){h().loggingEnabled&&t&&t.logs.push(e)};function S(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function E(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?S(Object(r),!0).forEach((function(t){s()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):S(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var j=function(e){var t=e.checkoutFormHandler,r=e.eventRegistration,n=e.emitResponse,a=Object(i.useContext)(c.Context),o=r.onPaymentProcessing,l=r.onCheckoutAfterProcessingWithError,u=r.onCheckoutAfterProcessingWithSuccess;return function(e,t,r,n,a,o){var l=Object(i.useRef)(r);Object(i.useEffect)((function(){l.current=r}),[r]),Object(i.useEffect)((function(){return e(function(){var e=f()(m.a.mark((function e(){var r,i,c,u,s,d;return m.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={type:t.responseTypes.SUCCESS},i={nonce:"",notices:[],logs:[]},e.next=4,a(l.current);case 4:if(c=e.sent,u=E(E({},i),c),s=u.token||u.nonce,!h().is3dsEnabled||!s){e.next=14;break}return e.next=10,o(l.current,s);case 10:d=e.sent,u.verificationToken=d.verificationToken||"",u.logs=u.logs.concat(d.log||[]),u.errors=u.notices.concat(d.errors||[]);case 14:return s||u.logs.length>0?r.meta={paymentMethodData:n(u)}:u.notices.length>0&&(r.type=t.responseTypes.ERROR,r.message=u.notices),e.abrupt("return",r);case 16:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}())}),[e,t.responseTypes.SUCCESS,t.responseTypes.ERROR,a,o,n])}(o,n,a,t.getPaymentMethodData,t.createNonce,t.verifyBuyer),function(e,t,r){Object(i.useEffect)((function(){var n=function(e){var t={type:r.responseTypes.SUCCESS},n=e.processingResponse,a=n.paymentStatus,o=n.paymentDetails;return a===r.responseTypes.ERROR&&o.checkoutNotices&&(t={type:r.responseTypes.ERROR,message:JSON.parse(o.checkoutNotices),messageContext:r.noticeContexts.PAYMENTS,retry:!0}),t},a=e(n),o=t(n);return function(){a(),o()}}),[e,t,r.noticeContexts.PAYMENTS,r.responseTypes.ERROR,r.responseTypes.SUCCESS])}(l,u,n),null},x=r(7),w=r.n(x);function P(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return I(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?I(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,l=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){l=!0,o=e},f:function(){try{i||null==r.return||r.return()}finally{if(l)throw o}}}}function I(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var q=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=Object(i.useState)(!1),a=w()(n,2),o=a[0],l=a[1],c=Object(i.useState)(""),u=w()(c,2),d=u[0],f=u[1],p=Object(i.useRef)(null),m=Object(i.useRef)(null),v=Object(i.useMemo)((function(){var n=t&&!r?"STORE":"CHARGE",a={billingContact:{familyName:e.billingData.last_name||"",givenName:e.billingData.first_name||"",email:e.billingData.email||"",country:e.billingData.country||"",region:e.billingData.state||"",city:e.billingData.city||"",postalCode:e.billingData.postcode||"",phone:e.billingData.phone||"",addressLines:[e.billingData.address_1||"",e.billingData.address_2||""]},intent:n};return"CHARGE"===n&&(a.amount=(e.cartTotal.value/100).toString(),a.currencyCode=e.currency.code),a}),[e.billingData,e.cartTotal.value,e.currency.code,t,r]),y=Object(i.useCallback)((function(e){var n,a,o,i=e.cardData,l=e.nonce,c=e.verificationToken,u=e.notices,f=e.logs;return o={},s()(o,"wc-".concat("square-credit-card","-card-type"),d||""),s()(o,"wc-".concat("square-credit-card","-last-four"),(null==i?void 0:i.last_4)||""),s()(o,"wc-".concat("square-credit-card","-exp-month"),(null==i||null===(n=i.exp_month)||void 0===n?void 0:n.toString())||""),s()(o,"wc-".concat("square-credit-card","-exp-year"),(null==i||null===(a=i.exp_year)||void 0===a?void 0:a.toString())||""),s()(o,"wc-".concat("square-credit-card","-payment-postcode"),(null==i?void 0:i.billing_postal_code)||""),s()(o,"wc-".concat("square-credit-card","-payment-nonce"),l||""),s()(o,"wc-".concat("square-credit-card","-payment-token"),r||""),s()(o,"wc-".concat("square-credit-card","-buyer-verification-token"),c||""),s()(o,"wc-".concat("square-credit-card","-tokenize-payment-method"),t||!1),s()(o,"log-data",f.length>0?JSON.stringify(f):""),s()(o,"checkout-notices",u.length>0?JSON.stringify(u):""),o}),[d,t,r]),b=function(e,t,r){var n={notices:[],logs:[]};e?_(e,n):t?(C(r,n),O("Card data received"),O(r),n.cardData=r,n.nonce=t):(C("Nonce is missing from the Square response",n),O("Nonce is missing from the Square response","error"),_([],n)),p.current&&p.current(n)},g=Object(i.useCallback)((function(e){if(!r){var t=new Promise((function(e){return p.current=e}));return e.onCreateNonce(),t}return Promise.resolve({token:r})}),[r]),S=Object(i.useCallback)((function(e,t){var r=new Promise((function(e){return m.current=e}));return e.onVerifyBuyer(t,v,E),r}),[v,E]),E=Object(i.useCallback)((function(e,t){var r={notices:[],logs:[]};if(e){var n,a=P(e);try{for(a.s();!(n=a.n()).done;){var o=n.value;o.field||(o.field="none")}}catch(e){a.e(e)}finally{a.f()}_(e,r)}t&&t.token?r.verificationToken=t.token:(C("Verification token is missing from the Square response",r),O("Verification token is missing from the Square response","error"),_([],r)),m.current&&m.current(r)}),[m]),j=Object(i.useCallback)((function(e){if("cardBrandChanged"===e.eventType){var t=e.cardBrand,r="plain";null!==t&&"unknown"!==t||(r=""),null!==h().availableCardTypes[t]&&(r=h().availableCardTypes[t]),O("Card brand changed to ".concat(t)),f(r)}}),[]),x=Object(i.useCallback)((function(){return e.billingData.postcode||""}),[e.billingData.postcode]);return{cardNonceResponseReceived:b,handleInputReceived:j,isLoaded:o,setLoaded:l,getPostalCode:x,cardType:d,createNonce:g,verifyBuyer:S,getPaymentMethodData:y}},M=function(e){var t=e.cardType;return Object(i.createElement)("fieldset",{id:"wc-square-credit-card-credit-card-form"},Object(i.createElement)("span",{className:"sq-label"},Object(l.__)("Card Number","woocommerce-square")),Object(i.createElement)("div",{id:"wc-square-credit-card-account-number-hosted",className:"wc-square-credit-card-hosted-field ".concat(t?"card-type-".concat(t):"")},Object(i.createElement)(c.CreditCardNumberInput,{label:""})),Object(i.createElement)("div",{className:"sq-form-third"},Object(i.createElement)("span",{className:"sq-label"},Object(l.__)("Expiration (MM/YY)","woocommerce-square")),Object(i.createElement)("div",{id:"wc-square-credit-card-expiry-hosted",className:"wc-square-credit-card-hosted-field"},Object(i.createElement)(c.CreditCardExpirationDateInput,{label:""}))),Object(i.createElement)("div",{className:"sq-form-third"},Object(i.createElement)("span",{className:"sq-label"},Object(l.__)("Card Security Code","woocommerce-square")),Object(i.createElement)("div",{id:"wc-square-credit-card-csc-hosted",className:"wc-square-credit-card-hosted-field"},Object(i.createElement)(c.CreditCardCVVInput,{label:""}))),Object(i.createElement)("div",{className:"sq-form-third"},Object(i.createElement)("span",{className:"sq-label"},Object(l.__)("Postal code","woocommerce-square")),Object(i.createElement)("div",{id:"wc-square-credit-card-postal-code-hosted",className:"wc-square-credit-card-hosted-field"},Object(i.createElement)(c.CreditCardPostalCodeInput,{label:""}))))},R=function(e){var t=e.billing,r=e.eventRegistration,n=e.emitResponse,a=e.shouldSavePayment,o=q(t,a);return Object(i.createElement)(c.SquarePaymentForm,{formId:"square-credit-card",sandbox:h().isSandbox,applicationId:h().applicationId,locationId:h().locationId,inputStyles:h().inputStyles,placeholderCreditCard:"•••• •••• •••• ••••",placeholderExpiration:Object(l.__)("MM / YY","woocommerce-square"),placeholderCVV:Object(l.__)("CSC","woocommerce-square"),postalCode:o.getPostalCode,cardNonceResponseReceived:o.cardNonceResponseReceived,inputEventReceived:o.handleInputReceived,paymentFormLoaded:function(){return o.setLoaded(!0)}},Object(i.createElement)(M,{cardType:o.cardType}),o.isLoaded&&Object(i.createElement)(j,{checkoutFormHandler:o,eventRegistration:r,emitResponse:n}))},N=["RenderedComponent"],k=function(e){var t=e.RenderedComponent,r=o()(e,N);return Object(i.createElement)(t,r)},D={name:"square-credit-card",label:Object(i.createElement)((function(e){var t=e.components.PaymentMethodLabel;return Object(i.createElement)(t,{text:h().title})}),null),content:Object(i.createElement)(k,{RenderedComponent:R}),edit:Object(i.createElement)(k,{RenderedComponent:R}),savedTokenComponent:Object(i.createElement)(k,{RenderedComponent:function(e){var t=e.billing,r=e.eventRegistration,n=e.emitResponse,a=e.token,o=q(t,!1,a);return Object(i.createElement)(c.SquarePaymentForm,{formId:"square-credit-card-saved-card",sandbox:h().isSandbox,applicationId:h().applicationId,locationId:h().locationId,paymentFormLoaded:function(){return o.setLoaded(!0)}},o.isLoaded&&Object(i.createElement)(j,{checkoutFormHandler:o,eventRegistration:r,emitResponse:n}))}}),paymentMethodId:"square_credit_card",ariaLabel:"Square",canMakePayment:function(){return!(!h().applicationId||!h().locationId)},supports:{features:h().supports,showSavedCards:h().showSavedCards,showSaveOption:h().showSaveOption}};Object(n.registerPaymentMethod)(D)}]);
i18n/languages/woocommerce-square.pot CHANGED
@@ -2,10 +2,10 @@
2
  # This file is distributed under the GNU General Public License v3.0.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: WooCommerce Square 2.9.0\n"
6
  "Report-Msgid-Bugs-To: "
7
  "https://wordpress.org/support/plugin/woocommerce-square\n"
8
- "POT-Creation-Date: 2022-02-17 06:05:29+00:00\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=utf-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
@@ -1857,15 +1857,15 @@ msgstr ""
1857
  msgid "Docs"
1858
  msgstr ""
1859
 
1860
- #: vendor/skyverge/wc-plugin-framework/woocommerce/class-sv-wc-plugin.php:621
1861
  msgid "%1$s - A minimum of %2$s is required."
1862
  msgstr ""
1863
 
1864
- #: vendor/skyverge/wc-plugin-framework/woocommerce/class-sv-wc-plugin.php:630
1865
  msgid "Set as %1$s - %2$s is required."
1866
  msgstr ""
1867
 
1868
- #: vendor/skyverge/wc-plugin-framework/woocommerce/class-sv-wc-plugin.php:853
1869
  msgid "Configure"
1870
  msgstr ""
1871
 
@@ -3228,7 +3228,7 @@ msgid ""
3228
  "has loopback connections enabled."
3229
  msgstr ""
3230
 
3231
- #: woocommerce-square.php:250
3232
  msgid ""
3233
  "Note that our next WooCommerce Square release will be a major update "
3234
  "(v3.0.0) that will include bumping the minimum PHP support from 5.6 to 7.1 "
2
  # This file is distributed under the GNU General Public License v3.0.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: WooCommerce Square 2.9.1\n"
6
  "Report-Msgid-Bugs-To: "
7
  "https://wordpress.org/support/plugin/woocommerce-square\n"
8
+ "POT-Creation-Date: 2022-03-17 05:15:45+00:00\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=utf-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
1857
  msgid "Docs"
1858
  msgstr ""
1859
 
1860
+ #: vendor/skyverge/wc-plugin-framework/woocommerce/class-sv-wc-plugin.php:622
1861
  msgid "%1$s - A minimum of %2$s is required."
1862
  msgstr ""
1863
 
1864
+ #: vendor/skyverge/wc-plugin-framework/woocommerce/class-sv-wc-plugin.php:631
1865
  msgid "Set as %1$s - %2$s is required."
1866
  msgstr ""
1867
 
1868
+ #: vendor/skyverge/wc-plugin-framework/woocommerce/class-sv-wc-plugin.php:854
1869
  msgid "Configure"
1870
  msgstr ""
1871
 
3228
  "has loopback connections enabled."
3229
  msgstr ""
3230
 
3231
+ #: woocommerce-square.php:251
3232
  msgid ""
3233
  "Note that our next WooCommerce Square release will be a major update "
3234
  "(v3.0.0) that will include bumping the minimum PHP support from 5.6 to 7.1 "
includes/Plugin.php CHANGED
@@ -42,7 +42,7 @@ class Plugin extends Framework\SV_WC_Payment_Gateway_Plugin {
42
 
43
 
44
  /** plugin version number */
45
- const VERSION = '2.9.0';
46
 
47
  /** plugin ID */
48
  const PLUGIN_ID = 'square';
42
 
43
 
44
  /** plugin version number */
45
+ const VERSION = '2.9.1';
46
 
47
  /** plugin ID */
48
  const PLUGIN_ID = 'square';
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: credit card, square, woocommerce, inventory sync
4
  Requires at least: 4.6
5
  Tested up to: 5.9
6
  Requires PHP: 5.6
7
- Stable tag: 2.9.0
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -71,6 +71,9 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
71
  2. The payment gateway settings.
72
 
73
  == Changelog ==
 
 
 
74
  = 2.9.0 - 2022.02.17 =
75
  * New - Added admin notice about v3 major update. PR#707
76
  * Fix - Trim spaces from postal code at prefix and suffix positions. PR#654
4
  Requires at least: 4.6
5
  Tested up to: 5.9
6
  Requires PHP: 5.6
7
+ Stable tag: 2.9.1
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
71
  2. The payment gateway settings.
72
 
73
  == Changelog ==
74
+ = 2.9.1 - 2022.03.17 =
75
+ * Fix - Fatal error while deactivating WooCommerce before WooCommerce Square.
76
+
77
  = 2.9.0 - 2022.02.17 =
78
  * New - Added admin notice about v3 major update. PR#707
79
  * Fix - Trim spaces from postal code at prefix and suffix positions. PR#654
woocommerce-square.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * Plugin Name: WooCommerce Square
4
- * Version: 2.9.0
5
  * Plugin URI: https://woocommerce.com/products/square/
6
  * Description: Adds ability to sync inventory between WooCommerce and Square POS. In addition, you can also make purchases through the Square payment gateway.
7
  * Author: WooCommerce
@@ -19,7 +19,7 @@
19
  * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
20
  *
21
  * WC requires at least: 3.0
22
- * WC tested up to: 6.2
23
  * Tested up to: 5.9
24
  */
25
 
@@ -245,16 +245,18 @@ class WooCommerce_Square_Loader {
245
  );
246
  }
247
 
248
- wc_square()->get_admin_notice_handler()->add_admin_notice(
249
- sprintf(
250
- esc_html__( "Note that our next WooCommerce Square release will be a major update (v3.0.0) that will include bumping the minimum PHP support from 5.6 to 7.1 and migrating Square's SDK from v2.2 to v15.0.0. This will allow us to provide significant enhancements into the future and while we fully test all releases, please allow yourself some time and space to similarly test the update before applying it to your live sites.", 'woocommerce-square' )
251
- ),
252
- 'wc-square-v3-upgrade-info',
253
- array(
254
- 'notice_class' => 'notice-info',
255
- 'dismissible' => true,
256
- )
257
- );
 
 
258
  }
259
 
260
 
1
  <?php
2
  /**
3
  * Plugin Name: WooCommerce Square
4
+ * Version: 2.9.1
5
  * Plugin URI: https://woocommerce.com/products/square/
6
  * Description: Adds ability to sync inventory between WooCommerce and Square POS. In addition, you can also make purchases through the Square payment gateway.
7
  * Author: WooCommerce
19
  * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
20
  *
21
  * WC requires at least: 3.0
22
+ * WC tested up to: 6.3
23
  * Tested up to: 5.9
24
  */
25
 
245
  );
246
  }
247
 
248
+ if ( $this->plugins_compatible() ) {
249
+ wc_square()->get_admin_notice_handler()->add_admin_notice(
250
+ sprintf(
251
+ esc_html__( "Note that our next WooCommerce Square release will be a major update (v3.0.0) that will include bumping the minimum PHP support from 5.6 to 7.1 and migrating Square's SDK from v2.2 to v15.0.0. This will allow us to provide significant enhancements into the future and while we fully test all releases, please allow yourself some time and space to similarly test the update before applying it to your live sites.", 'woocommerce-square' )
252
+ ),
253
+ 'wc-square-v3-upgrade-info',
254
+ array(
255
+ 'notice_class' => 'notice-info',
256
+ 'dismissible' => true,
257
+ )
258
+ );
259
+ }
260
  }
261
 
262