* Allows custom validation rules to be applied to fields - in this case, email address
* Add local state to only push valid changes
* Do not need required
* unused isString
* Move to push level
* Update packages/checkout/components/text-input/validated-text-input.tsx
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update packages/checkout/components/text-input/validated-text-input.tsx
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update packages/checkout/components/text-input/validated-text-input.tsx
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update packages/checkout/components/text-input/validated-text-input.tsx
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Validate when the data store changes
Co-authored-by: Niels Lange <info@nielslange.de>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Add clearValidationErrors to validation data store actions
* Add reducer case for CLEAR_VALIDATION_ERRORS
* Add tests for CLEAR_VALIDATION_ERRORS
* Add documentation for clearValidationErrors
* Deprecate clearAllValidationErrors in actions.ts
* Remove CLEAR_VALIDATION_ERRORS action and reducer case
* Update reducer test for clearAllValidationErrors
* Make error message in test describe the test better
* Update reducer to handle CLEAR_VALIDATION_ERRORS with no error passed
* Update documentation for validation data store
* Remove unnecessary linebreaks in documentation
* Moved all payment utils functions in a utils folder
* Delete as it's not being used
* bot: update checkstyle.xml
* bot: update checkstyle.xml
* Fix TS error
* bot: update checkstyle.xml
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Add actions and selectors for new paymemt status
* Remove set_complete from reducer
* Replace all usages of getCurrentStatus with specific sepectors
* Replace all `setCurrentStatus` with individual actions
* Update docs
* Removed currentStatus
* bot: update checkstyle.xml
* Update docs/third-party-developers/extensibility/data-store/payment.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Address Thomas feedback
* Add link to deprecated message
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Remove the experimental flag that's used to include thunks in wp.data
* bot: update checkstyle.xml
* Fix ts error from previous PR
* bot: update checkstyle.xml
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Remove isExpressPaymentMethodActive and paymentStatus.isDoingExpressPayment from the payment store
* Remove uneccessary paymentStatuses key from the payments store
* Add non-debounced versions of updatePaymentMethods
* Call undebounced function until store is ready then call debounced
* Reset debounce timer to 1 second
* Add better comments
* Try setting the trail setting of the debounce function
* Revert "Try setting the trail setting of the debounce function"
This reverts commit 040fb63cb612c19ac396396d1949b6429f402616.
Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
* Add rate limiting to cart endpoints based on session
* Handle nonce and rate checks in permission_callback
* Rate limit checkout only
* Debug
* Unused AbstractRoute
* Code standards
* Modify core rate limit table
* Add rate limit at rest api level, not route level
* Rate limit helper
* Remove rate limit from routes
* Usused dep
* Remove custom error logic no longer needed
* Remove dependency
* Remove custom permission_callback
* Hash IP and handle null
* Remove error response handler
* revert error_to_response changes
* Remove add_response_headers
* Remove IDENTIFIER
* Remove white space
* Increase limit
* Missing class comment
* Move rate limiting code within store api codebase
* white space
* Fix return type
* Check rate limit expiry greater than now
* Remove x- prefix
* reorder functions
* remove table
* pass request to add_nonce_headers
* return early and avoid elseif on AbstractCartRoute:get_response()
* Refactor get_ip_address() before implementing options for functionality
* Change rate limit to 5 requests
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
* Change rate limit window to 60 seconds
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
* Disable rate limiting by default
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
* Updated limits comment
* Example for Forwarded header
* Updated "woocommerce_store_api_enable_rate_limit_check" filter doc
* Added filter for the Store API rate limit check proxy support
* Add an action here that carries over the IP address being blocked.
* Added logic around setting the action_id, and returns an error when ip cannot be determined for users not logged in.
* Renamed action for limit exceeded.
* Common rate limiting header naming prefix, and fixed comment typos.
* Doc for Rate Limiting (wip)
* Example for Rate Limiting docs
* Remove private IP range block for rate limiting
* Refactored get_response() to add nonce headers to response instead of request
* Disable batching for Checkout calls to prevent bypassing Rate Limiting.
* Removed redundant arg.
* package-lock.json update
* Removed repeated func calls.
* Fix failing tests.
* Tests wip.
* Request limit and timeframe are now constants for RateLimits utility class.
* Tests for Rate Limit headers.
* Reverted PHPUnit config to enable all tests again.
* Update src/StoreApi/Authentication.php comment wording
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Removed possibly unnecessary get_ip_address() call.
* Changed wording on comment for get_ip_address() method.
* Simplified validate_ip() method.
* Fixed wrong header entry for "Forwarded" check.
* Unit testing for Authentication::get_ip_address()
* Comment explaining the reason to use ReflectionClass for testing get_ip_address().
* Support for error output outside batch request.
* MD linting.
* Refactor to implement options through a single filter.
* fixed md lint error and config file
* reverted accidental default func arg value removal
* re-enabled batch support for checkout
* action for limit exceed now also triggered in case we can't resolve the IP.
* Doc tweak.
* Return unresolved IP address when REMOTE_ADDR isn't set with proxy support disabled.
* Group unresolved ips for rate limiting
* Fixed bug where current limit wasn't properly initialized.
Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Improve the performance of checking payment methods
* Use the default names of imports from @wordpress/data
* Fix circular dependency
* Fix __internalUpdateAvailablePaymentMethods
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
* Construct args for canMakePayment with correct keys
* When the CheckoutEventsContext mounts, initialize payment store
* Destructure useSelect correctly
* Dispatch __internalInitializePaymentStore in selector tests
* Update selector name to __internalUpdateAvailablePaymentMethods
* Remove check for editor when registering checkout store
* Add check for when express payment methods have updated too
* Ensure billingAddress key exists in canMakePayment arg
* Use editor context to know if we're in editor
* Refresh the default payment method only if the active one is unavailable
* Add new type for serializable data store payment method
* Update uses of PaymentMethods/ExpressPaymentMethods to the plain version
* Add tests for setAvailablePaymentMethods action
* Update data store key in tests
* Rename payment-method-data-context to payment-event-context and tidy up types and things
* Rename uses of PAYMENT_METHOD_DATA_STORE_KEY to PAYMENT_STORE_KEY
* Rename __internalInitializePaymentMethodDataStore and unsubscribeInitializePaymentMethodDataStore
* Rename unsubscribeInitializePaymentMethodDataStore
* Rename setProcessingResponse to setPaymentResult and remove setOrderId from the checkout data store actions
* Fix accidentally changing data exposed to the observers
* Rename all checkout actions with the __internal prefix
* Prefix all payment method data store actions with __internal
* Pedantic spacing
* Fix ts error
* Remove setPristine as it's not used
* Comment checkout actions
* Rename setProcessingResponse to setPaymentResult and remove setOrderId from the checkout data store actions
* Add comments to payment actions
* Update documentation with data stores
* Fix accidentally changing data exposed to the observers
* Document missing parameters for actions
* Convert checkout context to data store - part 1 (https://github.com/woocommerce/woocommerce-blocks/pull/6232)
* Add checkout data store
* wip on checkout data store
* CheckoutContext now uses the checkout store
* Investigated and removed setting the redirectUrl on the default state
* update extension and address hooks to use checkout data store
* use checkout data store in checkout-processor and use-checkout-button
* trim useCheckoutContext from use-payment-method-interface && use-store-cart-item-quantity
* Remove useCheckoutContext from shipping provider
* Remove isCalculating from state
* Removed useCheckoutContext from lots of places
* Remove useCheckoutContext from checkout-payment-block
* Remove useCheckoutContext in checkout-shipping-methods-block and checkout-shipping-address-block
* add isCart selector and action and update the checkoutstate context
* Fixed redirectUrl bug by using thunks
* Remove dispatchActions from checkout-state
* Change SET_HAS_ERROR action to be neater
* Thomas' feedback
* Tidy up
* Oops, deleted things I shouldn't have
* Typescript
* Fix types
* Fix tests
* Remove isCart
* Update docs and remove unecessary getRedirectUrl() selector
* set correct type for preloadedCheckoutData
* Remove duplicate Address type
* Fix missing addresses from type-defs index
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Revert feedback changes
* REvert feedback formatting
* Update docs formatting
* Delete empty types.ts file
* remove merge conflict from docs
* Correct linting in docs
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Move checkout state code into thunks and rename `CheckoutState` context to `CheckoutEvents` (https://github.com/woocommerce/woocommerce-blocks/pull/6455)
* Add checkout data store
* wip on checkout data store
* CheckoutContext now uses the checkout store
* Investigated and removed setting the redirectUrl on the default state
* update extension and address hooks to use checkout data store
* use checkout data store in checkout-processor and use-checkout-button
* trim useCheckoutContext from use-payment-method-interface && use-store-cart-item-quantity
* Remove useCheckoutContext from shipping provider
* Remove isCalculating from state
* Removed useCheckoutContext from lots of places
* Remove useCheckoutContext from checkout-payment-block
* Remove useCheckoutContext in checkout-shipping-methods-block and checkout-shipping-address-block
* add isCart selector and action and update the checkoutstate context
* Fixed redirectUrl bug by using thunks
* Remove dispatchActions from checkout-state
* Change SET_HAS_ERROR action to be neater
* Thomas' feedback
* Tidy up
* Oops, deleted things I shouldn't have
* Typescript
* Fix types
* Fix tests
* Remove isCart
* Update docs and remove unecessary getRedirectUrl() selector
* validate event emitter button
* Added thunks in a separate file
* Call thunks from checkout-state
* Checkout logic tested and working
* Remove dependency injection as much as poss, tidy up and fix some TS errors
* Fix types in thunks.ts
* Fixed some ts errors
* WIP
* Fixed bug
* Shift side effects from checkout-state to checkout-processor
* Revert "Shift side effects from checkout-state to checkout-processor"
This reverts commit 059533da4eb34f9982f66cd4adacc7b2c24f939f.
* Rename CheckoutState to CheckoutEvents
* Move status check outside the thunk
* remove duplicate EVENTS constant
* remove temp buttons
* Remove console logs
* Augment @wordpress/data package with our new store types
* Add correct type for CheckoutAction
* Remove createErrorNotice arg from runCheckoutAfterProcessingWithErrorObservers
* Remove createErrorNotice from emit event types
* Use type keyword when importing types
* Add correct types for dispatch and select in thunks
* Update wordpress/data types
* Replace store creation with new preferred method
* Set correct action type on reducer
* Remove unnecessary async from thunk
* add CHECKOUT_ prefix to checkout events again
* export EVENTS with eveything else in checkout0-events/event-emit
* Remove duplicate SelectFromMap and TailParameters
* Updated type for paymentStatus
* TODO remove wp/data experimental thunks
* Remove `setCustomerId` from events and `processCheckoutResponseHeaders` (https://github.com/woocommerce/woocommerce-blocks/pull/6586)
* Prevent passing dispatch, instead get actions direct from store
* Get setCustomerId from the store instead of passing it to processCheckoutResponseHeaders
* Revert "Prevent passing dispatch, instead get actions direct from store"
This reverts commit 4479a2ef5599d9c8d99c3629616b3d662210fc08.
* Auto stash before revert of "Prevent passing dispatch, instead get actions direct from store"
* Remove duplicate dispatch
* Fix unit tests
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Refactor selectors to not return functions anymore
This is a poor DevEx and naming did not reflect what the selector was returning.
* Update combobox to be more explicit when selecting validation error
* Update useValidation to use the new getValidationError selector
* Include @woocommerce/base-hooks in tsconfig
* Update ValidationInputError to use new selector
* Update ValidatedTextInput to use new selectors
* Prevent reference errors when getting validation errors in ComboBox
* Defend against case where message prop of error object is undefined
* Fix totals/coupon to use new validation selector
* Use validation data store in CheckoutTerms block
* Update AddressForm to use new validation selector
* Update AttributeSelectControl to use new validation selector
* Fix syntax error in ValidatedTextInput
* Fix multiple import error from rebase
* Fix lint issue in useStoreCartItemQantity
* Fix tests to reflect new selector API
* Remove unused validation prop from CheckoutTermsBlock
* Change CheckoutTermsBlock unit tests to use validation data store
* Fix JSDOC syntax
* fix merge conflict in checkout-api.md
Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
Co-authored-by: Niels Lange <info@nielslange.de>
* Mock getCartTotals
* Change test to use data store instead of context
* Move payment method context test to data store selectors
* Change description of test suite
* Bump commit to trigger tests
* Fix path in test
* update package lock
* Set correct state payment method reducer tests/use correct actions
* Get saved payment methods from store not context
* Mock stores and update tests to allow switching payment methods
* Update tests to get onSubmit from checkoutEventsContext
* Remove cartTotalsLoaded check from payment method initialize check
* Make PaymentMethods test wait until payments initialized
* initialize payment method data store when cart is loaded
* Remove unneeded actions and add initializePaymentMethodDataStore
* Remove check for cart totals loaded in checkPaymentMethods
* Remove updateAvilablePaymentMethods from registry
* Remove unneeded mock
* Remove unused import
* Rename imports to fix eslint errors
* Remove unused imports
* Remove return false from checkPaymentMethods
* Remove unnecessary setPaymentMethodsInitialized call
* Add todo comment to track refactoring opportunity
* Remove savedpayment methods from payment method context and rename it
* Rename payment method data context to payment method events context
* Add tests for setDefaultPaymentMethods
* Optimize the availablePaymentMethods state data
Store only the "name" attribute for now.
* Get list of payment methods from the registry instead of the store
We are using this hook to get some React elements in the payment method
object. So, we are getting the raw data directly from the registry instead
of the store.
* Fix payment state not loading on the Checkout edit page
* Handle checkout edit page case
* Fix infinite loop error on C&C Blocks
* Include @wordpress/redux-routine in transformIgnorePatterns jest config
Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
* Move paymentMethodDataProvider into a data store (https://github.com/woocommerce/woocommerce-blocks/pull/6208)
* Fix typographical error on LegacyRegisterExpressPaymentMethodFunction type
* Add default state for PaymentMethod data store
* Add preliminary action types
* Add preliminary action dispatchers
* Create payment method data store
* Add preliminary reducers for payment method data store
* Add preliminary selectors for payment method data store
* Add reducers/actions for registering payment methods
* Export payment method data store key
* Add test for payment method data reducers
* Add shouldSavePaymentMethod selector
* Add store key as constant
* Add more action types for registering and initializing payment methods
* Get active payment method from data store instead of from context
* Add registered methods to default state of payment method data store
* Dispatch name of registered payment method to payment method data store
* Remove setShouldSavePayment from payment method dispatcher and types
* Get payment methods from registry instead of payment context
* Add available payment methods to store
* Add function to check whether payment methods are allowed to be used
* Add selector to check if payments are initialised
* Remove resolvers and add controls to payment method data store
* Change type of payment requirements to string[]
* Turn addRegistered and addRegisteredExpress into generators
This is so we can check each payment method's validity before adding it to the list of available payment methods
* Add action type for setting express payments as initialized
* Only select from available methods in payment method options
* Remove argument from addRegisteredPaymentMethod in payment method registry
* Rename folder and store name to not contain the word data
* Add selectors for express payment methods and their initialisation
* Delete controls again in favour of thunks
* Rename payment-method-data to payment-methdods
* Create new setDefaultPaymentMethod function
This will set the payment method when the cart loads.
* Add CustomerPaymentMethodConfiguration type
* Make getAvailableExpressPaymentMethods return correct data
* Check express methods and normal methods when cart changes
* Add action for setting active express payment methods
* Handle express methods in checkPaymentMethodCanPay
* Hide express payments area if none are available
* Add selector for paymentMethodData
* Add customer data to default state and add selector for it
* Add setPaymentStatus action and reducer case
* Set the default payment method when one isn't selected
* Correct types on getCustomerPaymentMethods
* Set status in data store alongside context status
* Comment out active gateway selection - remove later
* Set status in express payment methods in data store
* Use correct key in payment method data context
* Directly check payment methods from the list in blocks-registry
* Add semicolon to import statement
* Fix payment method data state call
* Get paymentMethodData from store not context
* Fix linting issues
Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
* Rebase on the update/checkout-data-store branch & Fix failed payments (https://github.com/woocommerce/woocommerce-blocks/pull/6587)
* Add checkout data store
* wip on checkout data store
* CheckoutContext now uses the checkout store
* Investigated and removed setting the redirectUrl on the default state
* update extension and address hooks to use checkout data store
* use checkout data store in checkout-processor and use-checkout-button
* trim useCheckoutContext from use-payment-method-interface && use-store-cart-item-quantity
* Remove useCheckoutContext from shipping provider
* Remove isCalculating from state
* Removed useCheckoutContext from lots of places
* Remove useCheckoutContext from checkout-payment-block
* Remove useCheckoutContext in checkout-shipping-methods-block and checkout-shipping-address-block
* add isCart selector and action and update the checkoutstate context
* Fixed redirectUrl bug by using thunks
* Remove dispatchActions from checkout-state
* Change SET_HAS_ERROR action to be neater
* Thomas' feedback
* Tidy up
* Oops, deleted things I shouldn't have
* Typescript
* Fix types
* Fix tests
* Remove isCart
* Update docs and remove unecessary getRedirectUrl() selector
* set correct type for preloadedCheckoutData
* Remove duplicate Address type
* Fix missing addresses from type-defs index
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Revert feedback changes
* REvert feedback formatting
* Update docs formatting
* Fix typographical error on LegacyRegisterExpressPaymentMethodFunction type
* Add default state for PaymentMethod data store
* Add preliminary action types
* Add preliminary action dispatchers
* Create payment method data store
* Add preliminary reducers for payment method data store
* Add preliminary selectors for payment method data store
* Add reducers/actions for registering payment methods
* Export payment method data store key
* Add test for payment method data reducers
* Add shouldSavePaymentMethod selector
* Add store key as constant
* Add more action types for registering and initializing payment methods
* Get active payment method from data store instead of from context
* Add registered methods to default state of payment method data store
* Dispatch name of registered payment method to payment method data store
* Remove setShouldSavePayment from payment method dispatcher and types
* Get payment methods from registry instead of payment context
* Add available payment methods to store
* Add function to check whether payment methods are allowed to be used
* Add selector to check if payments are initialised
* Remove resolvers and add controls to payment method data store
* Change type of payment requirements to string[]
* Turn addRegistered and addRegisteredExpress into generators
This is so we can check each payment method's validity before adding it to the list of available payment methods
* Add action type for setting express payments as initialized
* Only select from available methods in payment method options
* Remove argument from addRegisteredPaymentMethod in payment method registry
* Rename folder and store name to not contain the word data
* Add selectors for express payment methods and their initialisation
* Delete controls again in favour of thunks
* Rename payment-method-data to payment-methdods
* Create new setDefaultPaymentMethod function
This will set the payment method when the cart loads.
* Add CustomerPaymentMethodConfiguration type
* Make getAvailableExpressPaymentMethods return correct data
* Check express methods and normal methods when cart changes
* Add action for setting active express payment methods
* Handle express methods in checkPaymentMethodCanPay
* Hide express payments area if none are available
* Add selector for paymentMethodData
* Add customer data to default state and add selector for it
* Add setPaymentStatus action and reducer case
* Set the default payment method when one isn't selected
* Correct types on getCustomerPaymentMethods
* Set status in data store alongside context status
* Comment out active gateway selection - remove later
* Set status in express payment methods in data store
* Directly check payment methods from the list in blocks-registry
* Add semicolon to import statement
* Fix payment method data state call
* Get paymentMethodData from store not context
* Add addPaymentMethodData action/reducer case
* Update payment method on payment success
* Add 'getCurrentStatus' selector
* Remove the temporary solution
For getting payment method data into the data store
* Prevent the 'success' context action from being dispatched
* Update the "setPaymentStatus" data store action
Accept status as an object instead of string
* Fix the "currentStatus" reducer state update value
* Get payment data into data store
* Set the correct payment status to data store
* Get the success status of payment from data store
* Use store data in the payment dispatchers
Replace the React useReducers action in the payment dispatchers file with
the payment method data store
* Get payment status from data store
* Use data store for the payment error status
* Use payment data store failed status
* Use payment data store for the isFinished status
Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
* Fix merge conflict error
* Set & get the provider's state from our data store instead of React's useReducer (https://github.com/woocommerce/woocommerce-blocks/pull/6588)
* Add checkout data store
* wip on checkout data store
* CheckoutContext now uses the checkout store
* Investigated and removed setting the redirectUrl on the default state
* update extension and address hooks to use checkout data store
* use checkout data store in checkout-processor and use-checkout-button
* trim useCheckoutContext from use-payment-method-interface && use-store-cart-item-quantity
* Remove useCheckoutContext from shipping provider
* Remove isCalculating from state
* Removed useCheckoutContext from lots of places
* Remove useCheckoutContext from checkout-payment-block
* Remove useCheckoutContext in checkout-shipping-methods-block and checkout-shipping-address-block
* add isCart selector and action and update the checkoutstate context
* Fixed redirectUrl bug by using thunks
* Remove dispatchActions from checkout-state
* Change SET_HAS_ERROR action to be neater
* Thomas' feedback
* Tidy up
* Oops, deleted things I shouldn't have
* Typescript
* Fix types
* Fix tests
* Remove isCart
* Update docs and remove unecessary getRedirectUrl() selector
* set correct type for preloadedCheckoutData
* Remove duplicate Address type
* Fix missing addresses from type-defs index
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Revert feedback changes
* REvert feedback formatting
* Update docs formatting
* Fix typographical error on LegacyRegisterExpressPaymentMethodFunction type
* Add default state for PaymentMethod data store
* Add preliminary action types
* Add preliminary action dispatchers
* Create payment method data store
* Add preliminary reducers for payment method data store
* Add preliminary selectors for payment method data store
* Add reducers/actions for registering payment methods
* Export payment method data store key
* Add test for payment method data reducers
* Add shouldSavePaymentMethod selector
* Add store key as constant
* Add more action types for registering and initializing payment methods
* Get active payment method from data store instead of from context
* Add registered methods to default state of payment method data store
* Dispatch name of registered payment method to payment method data store
* Remove setShouldSavePayment from payment method dispatcher and types
* Get payment methods from registry instead of payment context
* Add available payment methods to store
* Add function to check whether payment methods are allowed to be used
* Add selector to check if payments are initialised
* Remove resolvers and add controls to payment method data store
* Change type of payment requirements to string[]
* Turn addRegistered and addRegisteredExpress into generators
This is so we can check each payment method's validity before adding it to the list of available payment methods
* Add action type for setting express payments as initialized
* Only select from available methods in payment method options
* Remove argument from addRegisteredPaymentMethod in payment method registry
* Rename folder and store name to not contain the word data
* Add selectors for express payment methods and their initialisation
* Delete controls again in favour of thunks
* Rename payment-method-data to payment-methdods
* Create new setDefaultPaymentMethod function
This will set the payment method when the cart loads.
* Add CustomerPaymentMethodConfiguration type
* Make getAvailableExpressPaymentMethods return correct data
* Check express methods and normal methods when cart changes
* Add action for setting active express payment methods
* Handle express methods in checkPaymentMethodCanPay
* Hide express payments area if none are available
* Add selector for paymentMethodData
* Add customer data to default state and add selector for it
* Add setPaymentStatus action and reducer case
* Set the default payment method when one isn't selected
* Correct types on getCustomerPaymentMethods
* Set status in data store alongside context status
* Comment out active gateway selection - remove later
* Set status in express payment methods in data store
* Directly check payment methods from the list in blocks-registry
* Add semicolon to import statement
* Fix payment method data state call
* Get paymentMethodData from store not context
* Add addPaymentMethodData action/reducer case
* Update payment method on payment success
* Add 'getCurrentStatus' selector
* Remove the temporary solution
For getting payment method data into the data store
* Prevent the 'success' context action from being dispatched
* Update the "setPaymentStatus" data store action
Accept status as an object instead of string
* Fix the "currentStatus" reducer state update value
* Get payment data into data store
* Set the correct payment status to data store
* Get the success status of payment from data store
* Use store data in the payment dispatchers
Replace the React useReducers action in the payment dispatchers file with
the payment method data store
* Get payment status from data store
* Use data store for the payment error status
* Use payment data store failed status
* Use payment data store for the isFinished status
* Update the setPaymentStatus argument
* Set up setRegisteredPaymentMethods in data store
* Use the data store version of the registeredPaymentMethods
* Fix the default state type of the registeredPaymentMethods
* Set up setRegisteredExpressPaymentMethod in data store
* Use the data version of the registred express payment methods
* Set the correct action type for removing payment methods
* Fix default state express payment methods type
* Use the store data version of activePaymentMethod
* Use setActivePaymentMethod in the dispatchers file
And refactor code
* Update payment status arguments for express payment methods
* Use paymentMethodData from the data store
* Use payment method's errorMessage from data store
* Update paymentMethods list in data store reducer
* Replace remaining payment context data with data store
* Clean up payment method context file
Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
* Get payment method data directly from the data store instead of the usePaymentMethodDataContext hook (https://github.com/woocommerce/woocommerce-blocks/pull/6589)
* Add checkout data store
* wip on checkout data store
* CheckoutContext now uses the checkout store
* Investigated and removed setting the redirectUrl on the default state
* update extension and address hooks to use checkout data store
* use checkout data store in checkout-processor and use-checkout-button
* trim useCheckoutContext from use-payment-method-interface && use-store-cart-item-quantity
* Remove useCheckoutContext from shipping provider
* Remove isCalculating from state
* Removed useCheckoutContext from lots of places
* Remove useCheckoutContext from checkout-payment-block
* Remove useCheckoutContext in checkout-shipping-methods-block and checkout-shipping-address-block
* add isCart selector and action and update the checkoutstate context
* Fixed redirectUrl bug by using thunks
* Remove dispatchActions from checkout-state
* Change SET_HAS_ERROR action to be neater
* Thomas' feedback
* Tidy up
* Oops, deleted things I shouldn't have
* Typescript
* Fix types
* Fix tests
* Remove isCart
* Update docs and remove unecessary getRedirectUrl() selector
* set correct type for preloadedCheckoutData
* Remove duplicate Address type
* Fix missing addresses from type-defs index
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Revert feedback changes
* REvert feedback formatting
* Update docs formatting
* Fix typographical error on LegacyRegisterExpressPaymentMethodFunction type
* Add default state for PaymentMethod data store
* Add preliminary action types
* Add preliminary action dispatchers
* Create payment method data store
* Add preliminary reducers for payment method data store
* Add preliminary selectors for payment method data store
* Add reducers/actions for registering payment methods
* Export payment method data store key
* Add test for payment method data reducers
* Add shouldSavePaymentMethod selector
* Add store key as constant
* Add more action types for registering and initializing payment methods
* Get active payment method from data store instead of from context
* Add registered methods to default state of payment method data store
* Dispatch name of registered payment method to payment method data store
* Remove setShouldSavePayment from payment method dispatcher and types
* Get payment methods from registry instead of payment context
* Add available payment methods to store
* Add function to check whether payment methods are allowed to be used
* Add selector to check if payments are initialised
* Remove resolvers and add controls to payment method data store
* Change type of payment requirements to string[]
* Turn addRegistered and addRegisteredExpress into generators
This is so we can check each payment method's validity before adding it to the list of available payment methods
* Add action type for setting express payments as initialized
* Only select from available methods in payment method options
* Remove argument from addRegisteredPaymentMethod in payment method registry
* Rename folder and store name to not contain the word data
* Add selectors for express payment methods and their initialisation
* Delete controls again in favour of thunks
* Rename payment-method-data to payment-methdods
* Create new setDefaultPaymentMethod function
This will set the payment method when the cart loads.
* Add CustomerPaymentMethodConfiguration type
* Make getAvailableExpressPaymentMethods return correct data
* Check express methods and normal methods when cart changes
* Add action for setting active express payment methods
* Handle express methods in checkPaymentMethodCanPay
* Hide express payments area if none are available
* Add selector for paymentMethodData
* Add customer data to default state and add selector for it
* Add setPaymentStatus action and reducer case
* Set the default payment method when one isn't selected
* Correct types on getCustomerPaymentMethods
* Set status in data store alongside context status
* Comment out active gateway selection - remove later
* Set status in express payment methods in data store
* Directly check payment methods from the list in blocks-registry
* Add semicolon to import statement
* Fix payment method data state call
* Get paymentMethodData from store not context
* Add addPaymentMethodData action/reducer case
* Update payment method on payment success
* Add 'getCurrentStatus' selector
* Remove the temporary solution
For getting payment method data into the data store
* Prevent the 'success' context action from being dispatched
* Update the "setPaymentStatus" data store action
Accept status as an object instead of string
* Fix the "currentStatus" reducer state update value
* Get payment data into data store
* Set the correct payment status to data store
* Get the success status of payment from data store
* Use store data in the payment dispatchers
Replace the React useReducers action in the payment dispatchers file with
the payment method data store
* Get payment status from data store
* Use data store for the payment error status
* Use payment data store failed status
* Use payment data store for the isFinished status
* Update the setPaymentStatus argument
* Set up setRegisteredPaymentMethods in data store
* Use the data store version of the registeredPaymentMethods
* Fix the default state type of the registeredPaymentMethods
* Set up setRegisteredExpressPaymentMethod in data store
* Use the data version of the registred express payment methods
* Set the correct action type for removing payment methods
* Fix default state express payment methods type
* Use the store data version of activePaymentMethod
* Use setActivePaymentMethod in the dispatchers file
And refactor code
* Update payment status arguments for express payment methods
* Use paymentMethodData from the data store
* Use payment method's errorMessage from data store
* Update paymentMethods list in data store reducer
* Replace remaining payment context data with data store
* Clean up payment method context file
* Get payment method state from data store in the checkout submit hook
* Copy types.ts file into the payment data store folder
* Fix isExpressPaymentMethodActive selector
* Move the entire currentStatus into the data store
* Replace the payment context state with the data store
* Fix getActiveSavedToken & clean up the context file
* Use the accutrate name of the "createErrorNotice"
* Update the payment method data store key import
* Diable unused state from the context
Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
* Refactor the payment method data store & context (https://github.com/woocommerce/woocommerce-blocks/pull/6607)
* Add checkout data store
* wip on checkout data store
* CheckoutContext now uses the checkout store
* Investigated and removed setting the redirectUrl on the default state
* update extension and address hooks to use checkout data store
* use checkout data store in checkout-processor and use-checkout-button
* trim useCheckoutContext from use-payment-method-interface && use-store-cart-item-quantity
* Remove useCheckoutContext from shipping provider
* Remove isCalculating from state
* Removed useCheckoutContext from lots of places
* Remove useCheckoutContext from checkout-payment-block
* Remove useCheckoutContext in checkout-shipping-methods-block and checkout-shipping-address-block
* add isCart selector and action and update the checkoutstate context
* Fixed redirectUrl bug by using thunks
* Remove dispatchActions from checkout-state
* Change SET_HAS_ERROR action to be neater
* Thomas' feedback
* Tidy up
* Oops, deleted things I shouldn't have
* Typescript
* Fix types
* Fix tests
* Remove isCart
* Update docs and remove unecessary getRedirectUrl() selector
* set correct type for preloadedCheckoutData
* Remove duplicate Address type
* Fix missing addresses from type-defs index
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Revert feedback changes
* REvert feedback formatting
* Update docs formatting
* Fix typographical error on LegacyRegisterExpressPaymentMethodFunction type
* Add default state for PaymentMethod data store
* Add preliminary action types
* Add preliminary action dispatchers
* Create payment method data store
* Add preliminary reducers for payment method data store
* Add preliminary selectors for payment method data store
* Add reducers/actions for registering payment methods
* Export payment method data store key
* Add test for payment method data reducers
* Add shouldSavePaymentMethod selector
* Add store key as constant
* Add more action types for registering and initializing payment methods
* Get active payment method from data store instead of from context
* Add registered methods to default state of payment method data store
* Dispatch name of registered payment method to payment method data store
* Remove setShouldSavePayment from payment method dispatcher and types
* Get payment methods from registry instead of payment context
* Add available payment methods to store
* Add function to check whether payment methods are allowed to be used
* Add selector to check if payments are initialised
* Remove resolvers and add controls to payment method data store
* Change type of payment requirements to string[]
* Turn addRegistered and addRegisteredExpress into generators
This is so we can check each payment method's validity before adding it to the list of available payment methods
* Add action type for setting express payments as initialized
* Only select from available methods in payment method options
* Remove argument from addRegisteredPaymentMethod in payment method registry
* Rename folder and store name to not contain the word data
* Add selectors for express payment methods and their initialisation
* Delete controls again in favour of thunks
* Rename payment-method-data to payment-methdods
* Create new setDefaultPaymentMethod function
This will set the payment method when the cart loads.
* Add CustomerPaymentMethodConfiguration type
* Make getAvailableExpressPaymentMethods return correct data
* Check express methods and normal methods when cart changes
* Add action for setting active express payment methods
* Handle express methods in checkPaymentMethodCanPay
* Hide express payments area if none are available
* Add selector for paymentMethodData
* Add customer data to default state and add selector for it
* Add setPaymentStatus action and reducer case
* Set the default payment method when one isn't selected
* Correct types on getCustomerPaymentMethods
* Set status in data store alongside context status
* Comment out active gateway selection - remove later
* Set status in express payment methods in data store
* Directly check payment methods from the list in blocks-registry
* Add semicolon to import statement
* Fix payment method data state call
* Get paymentMethodData from store not context
* Add addPaymentMethodData action/reducer case
* Update payment method on payment success
* Add 'getCurrentStatus' selector
* Remove the temporary solution
For getting payment method data into the data store
* Prevent the 'success' context action from being dispatched
* Update the "setPaymentStatus" data store action
Accept status as an object instead of string
* Fix the "currentStatus" reducer state update value
* Get payment data into data store
* Set the correct payment status to data store
* Get the success status of payment from data store
* Use store data in the payment dispatchers
Replace the React useReducers action in the payment dispatchers file with
the payment method data store
* Get payment status from data store
* Use data store for the payment error status
* Use payment data store failed status
* Use payment data store for the isFinished status
* Update the setPaymentStatus argument
* Set up setRegisteredPaymentMethods in data store
* Use the data store version of the registeredPaymentMethods
* Fix the default state type of the registeredPaymentMethods
* Set up setRegisteredExpressPaymentMethod in data store
* Use the data version of the registred express payment methods
* Set the correct action type for removing payment methods
* Fix default state express payment methods type
* Use the store data version of activePaymentMethod
* Use setActivePaymentMethod in the dispatchers file
And refactor code
* Update payment status arguments for express payment methods
* Use paymentMethodData from the data store
* Use payment method's errorMessage from data store
* Update paymentMethods list in data store reducer
* Replace remaining payment context data with data store
* Clean up payment method context file
* Get payment method state from data store in the checkout submit hook
* Copy types.ts file into the payment data store folder
* Fix isExpressPaymentMethodActive selector
* Move the entire currentStatus into the data store
* Replace the payment context state with the data store
* Fix getActiveSavedToken & clean up the context file
* Use the accutrate name of the "createErrorNotice"
* Update the payment method data store key import
* Diable unused state from the context
* Get enabled customer payment methods using data store selector
* Remove remaining useReducer action from the dispatchers file
* Update types and remove unused vars
* Remove the payment method dispatchers hook
* Refactor & clean up (remove unused files)
* Remove commented line from payment methods types
* Move event emitter into thunks
Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
* Remove checkout-state after merge conflicts
* Fix linting errors
* Move types to types.ts
* Move default states into respective store folders
* Fix types and add comment
* Move setExpressPaymentError to payment-methods store
* fix express payment methods not showing up
* Check if payment method is active from the state
* Add comments
* Remove commented out code in payment method data context
* Display an error in the check-payment-methods directly from data store
* Remove use-emit-response hook and move utils in event-emit/utils.ts
* Use correct action property to remove payment methods
* Fix formatting
* Only try to initialize payment methods when cart is done loading
* Add function to order payment methods from server
* Add payment methods in the correct order
* Prevent adding registered payment methods before cart is ready
* Ensure payment methods get removed from state when deregistered
* Reorder setting default payment methods to add customer methods first
* Get customer methods from store not context
* Remove error from payment-method state and associated selectors
* Remove use-payment-method-registration and update the payment method state to remove the duplicated registeredPaymentMethods
* Remove errorMessage from payment-methods store
* Rename customerPaymentMethods -> savedPaymentMethods
* Order payment methods when validating
* Refactor payment-methods.js
* Fix "Payment methods not set in editor" woocommerce/woocommerce-blocks#6655 bug
We never get to load the payment methods object in the editor mode
because there are no cart totals to load.
* Initialize payment methods when available payments are loaded
* Remove duplicate code
* Fix data store state mutation anti-pattern
A Redux rule is to never mutate the state in a reducer to avoid any unexpected results
* Set availablePaymentMethods to the paymentMethods object
Instead of its keys. We can get the keys using "Object.keys".
* Use the available ordered payment methods
The `getPaymentMethods` & `getExpressPaymentMethods` may include unordored
& unavailable payment methods.
* Get the correct value from the emit event response
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
* Add validation reducers, actions, and action types
* Add selector for getValidationErrors
* Export store key and register store
* Export validation store key
* Move TextInput files to checkout package
* Export ValidatedTextInput from blocks-checkout package
* Update imports of ValidatedTextInput to reflect new location
* Use the validation wp-data store for showing error messages
* Export getValidationError in checkout package
* Move validation store to checkout package
* Move ValidationInputError to blocks-checkout package
* Only export "exposedSelectors" from validation
* Convert validation context to data store
* Fixed linting error
* Fixed linting error
* Change the validation selectors to return a function
* Convert reducer and selectors to TS
* Remove superfluous comments and improve test titles
* Test to ensure visible errors remain visible
* Make test for hasValidationErrors more robust
* Augment the wp-data module to include our selectors and actions
* Removed unused `exposedSelectors` variable
* Remove TS error because of `instanceId` on props
* Remove unnecessary as const
* Use function returned by getValidationError
* Use correct selector/action names now context has been decoupled
* hide validation error when input value changes
* Add correct aria-describedBy now we can get error id from store
* Clear validation error from store when component unmounts
* Clear validation error if input is valid
* convert ValidationInputError to TS and get correct id/error from store
* Ensure checkout block doesn't break when there are no errors
* Get validation data from the store instead of context
* Update country input to remove validation context
* Move validation store out of checkout package
* Move TextInput and ValidationInputError back out of the checkout package
* Remove duplicate internal styles comment
* Remove exports that no longer exist
* Get validation store key from block-data
* Make attribute-select-control use validation data store
* Export FieldValidationStatus type
* Make combobox use validation store not context
* Make Address use validation store not context
* Make Address use validation store not context
* Use hasValidationErrors selector as a function in shipping calculator
* Remove validation context from coupon story
* Import VALIDATION_STORE_KEY from correct location
* Stop coupon story from erroring
* Update useStoreCartCoupons to use validation store not context
* Make TotalsCoupon use validation store instead of context
* Make AddToCartFormContext use validation store not context
* Remove ValidationContext
* Import FieldValidationStatus from correct location
* Import ValidatedTextInput and ValidatedTextInput from correct location
* Remove ValidationContextProvider
* Update components to use validation store not context
* Update useValidation to use the data store
* Replace the validation context in checkout-events file
* Use the re-mapped path for the store key import
* Use "register" instead of the deprecated "registerStore"
* Fix import error of the "FieldValidationStatus" type
* Use TS instead of React's "PropTypes"
* Fix the type of "ValidationInputError" in the "payment-method-interface"
* Fix error not showing on the first place order click bug
We were mutating the state in the reducer, which prevented re-rendering
on state change
* Fix state mutation issue in the Validation reducer
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
* Add checkout data store
* wip on checkout data store
* CheckoutContext now uses the checkout store
* Investigated and removed setting the redirectUrl on the default state
* update extension and address hooks to use checkout data store
* use checkout data store in checkout-processor and use-checkout-button
* trim useCheckoutContext from use-payment-method-interface && use-store-cart-item-quantity
* Remove useCheckoutContext from shipping provider
* Remove isCalculating from state
* Removed useCheckoutContext from lots of places
* Remove useCheckoutContext from checkout-payment-block
* Remove useCheckoutContext in checkout-shipping-methods-block and checkout-shipping-address-block
* add isCart selector and action and update the checkoutstate context
* Fixed redirectUrl bug by using thunks
* Remove dispatchActions from checkout-state
* Change SET_HAS_ERROR action to be neater
* Thomas' feedback
* Tidy up
* Oops, deleted things I shouldn't have
* Typescript
* Fix types
* Fix tests
* Remove isCart
* Update docs and remove unecessary getRedirectUrl() selector
* validate event emitter button
* Added thunks in a separate file
* Call thunks from checkout-state
* Checkout logic tested and working
* Remove dependency injection as much as poss, tidy up and fix some TS errors
* Fix types in thunks.ts
* Fixed some ts errors
* WIP
* Fixed bug
* Shift side effects from checkout-state to checkout-processor
* Revert "Shift side effects from checkout-state to checkout-processor"
This reverts commit 059533da4eb34f9982f66cd4adacc7b2c24f939f.
* Rename CheckoutState to CheckoutEvents
* Move status check outside the thunk
* remove duplicate EVENTS constant
* remove temp buttons
* Remove console logs
* Augment @wordpress/data package with our new store types
* Add correct type for CheckoutAction
* Remove createErrorNotice arg from runCheckoutAfterProcessingWithErrorObservers
* Remove createErrorNotice from emit event types
* Use type keyword when importing types
* Add correct types for dispatch and select in thunks
* Update wordpress/data types
* Replace store creation with new preferred method
* Set correct action type on reducer
* Remove unnecessary async from thunk
* add CHECKOUT_ prefix to checkout events again
* export EVENTS with eveything else in checkout0-events/event-emit
* Remove duplicate SelectFromMap and TailParameters
* Updated type for paymentStatus
* TODO remove wp/data experimental thunks
* Remove `setCustomerId` from events and `processCheckoutResponseHeaders` (https://github.com/woocommerce/woocommerce-blocks/pull/6586)
* Prevent passing dispatch, instead get actions direct from store
* Get setCustomerId from the store instead of passing it to processCheckoutResponseHeaders
* Revert "Prevent passing dispatch, instead get actions direct from store"
This reverts commit 4479a2ef5599d9c8d99c3629616b3d662210fc08.
* Auto stash before revert of "Prevent passing dispatch, instead get actions direct from store"
* Remove duplicate dispatch
* Fix unit tests
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Add checkout data store
* wip on checkout data store
* CheckoutContext now uses the checkout store
* Investigated and removed setting the redirectUrl on the default state
* update extension and address hooks to use checkout data store
* use checkout data store in checkout-processor and use-checkout-button
* trim useCheckoutContext from use-payment-method-interface && use-store-cart-item-quantity
* Remove useCheckoutContext from shipping provider
* Remove isCalculating from state
* Removed useCheckoutContext from lots of places
* Remove useCheckoutContext from checkout-payment-block
* Remove useCheckoutContext in checkout-shipping-methods-block and checkout-shipping-address-block
* add isCart selector and action and update the checkoutstate context
* Fixed redirectUrl bug by using thunks
* Remove dispatchActions from checkout-state
* Change SET_HAS_ERROR action to be neater
* Thomas' feedback
* Tidy up
* Oops, deleted things I shouldn't have
* Typescript
* Fix types
* Fix tests
* Remove isCart
* Update docs and remove unecessary getRedirectUrl() selector
* set correct type for preloadedCheckoutData
* Remove duplicate Address type
* Fix missing addresses from type-defs index
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Revert feedback changes
* REvert feedback formatting
* Update docs formatting
* Delete empty types.ts file
* remove merge conflict from docs
* Correct linting in docs
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Rename billingData to billingAddress
* Add unit test to ensure billingData remains accessible
* add integration tests for slots
* Keep billingData in usePaymentMethodRegistration for backwards compatibility
* Gate `billingData` in deprecation gate
* Replace deprecation call
Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
* Remove expected warnings from test suite
* Switch dispatch and select usage to `controls`, from `@wordpress/data`
* Wrap render with act
* resolveSelect to wait for resolution
* resolveSelect
* Add address-related items to wc/store/cart data store
* Add useUpdateCustomerData hook
This allows us to have a single hook responsible for updating the customer information on the server.
* Add useUpdateCustomerData hook in Checkout block
* Remove shippingAsBilling from previousCustomerData ref type
* Add useShippingAsBillingCheckbox hook
* Remove checkbox handling from useCheckoutAddress
* Merge with woocommerce/woocommerce-blocks#5810 changes
* Move shipping as billing to checkout state context provider
* Subscribe to changes
* Cache customerDataToUpdate
* Combine customerDataType and customerDataContextType
* Fix notice context
* Clean up inline docs for push changes
* Add useShippingData hook
* Add shipping related selectors to cart store
* Update useShippingDataContext to useCustomerData hook
* Update uses of useShippingDataContext to get data from hook instead
* Remove rogue linebreak
* Re-add linebreak
* Re-add linebreak, remove shippingAsBilling
* Re-add linebreak
* Use useShippingData and useCustomerData instead of context
* Fix fromEntriesPolyfill to use number or undefined as an index option
* Convert derive-selected-shipping-rates to TS
* Add SelectShippingRateType
* Get needsShipping from new hook and not context
* Get address data from useCustomerData instead of useShippingDataContext
* Move selectedRates, selectShippingRate and isSelectingRate
* Remove items from ShippingDatacontext that are available in data stores
* Get shipping data from stores, not context in payment method interface
* Consider shipping rates to be loading if customer data is updating
* Get rates from useShippingData hook instead of context
* Fix incorrect TypeScript types and incorrectly named destructure
* Move useShippingData into shipping folder
* Update tests to mock useShippingData instead of context
* Remove empty string fallback from shipping phone
* Get types from Cart declaration instead of Picking them
Co-authored-by: Mike Jolley <mike.jolley@me.com>