woocommerce/plugins/woocommerce-blocks/assets/js/base/context
Thomas Roberts 96e3ff9662 Change payment processing for subscriptions (https://github.com/woocommerce/woocommerce-blocks/pull/3686)
* Remove savePaymentInfo check when displaying payment methods

This is because the savePaymentInfo is derived from whether the save payment method checkbox shows. This check doesn't make sense to do because it's not a good indicator of whether the payment method is enabled. Subscriptions for example hides the checkbox because it is implied that the method will be saved. We should instead rely on the server-side to only send permitted saved payment methods.

* Add safely_get_request_payment_method

This will allow us to try to get the payment method if it was passed in the request, but will default to an empty string if not. This is different to get_request_payment_method because it doesn't throw any errors. We need it to be different because get_request_payment_method is used when the order definitely needs payment (so a normal checkout scenario, vs. a £0 subscription checkout)

* Add action to update order meta when checking out

This is needed because some extensions rely on this action to add their information to the metadata of order items.

* Remove safely_get_request_payment_method

This is no longer needed.

* Remove @since from experimental hook

* Add PHPDoc for new update_order_meta hook

* Document use of experimental hook

* Reinstate the check for allowing saved cards

* Add method to Stripe integration to determine if saved_cards is enabled

* Add new field to get_payment_method_data

This adds displaySavePaymentMethodCheckbox which will be used to determine if the checkbox to save payment methods should display.

* Add displaySavePaymentMethodCheckbox option to client

This will determine whether the "Save payment information" checkbox will be displayed.

* Add requiresSaving option to Stripe payment method data

This is informed by the saved_cards option and the result of the wc_stripe_display_save_payment_method_checkbox filter.

* Rename displaySavePaymentMethodCheckbox to requiresSaving & fix logic

* Revert negation on display_save_payment method_checkbox filter & rename

We are going to rename the properties we use to determine whether saved cards are shown, or whether the save payment method checkbox is shown, so that their names are more descriptive of what they are for.

* Rename allowSavedCards and requiresSaving in Stripe integration

* Rename savePaymentInfo&requiresSaving to showSavedCards & showSaveOption

This is so we can hide the checkbox independently of hiding the saved payment methods.

* Show deprecated message if payment methods use savePaymentInfo

This is because we are leaving it in to enable backward compatibility but payment methods registering using this should be informed of the change in case it gets removed.

* Update Stripe typedefs and keys of supports object

* Show customer payment methods if showSavedCards is true on the method

* Make PaymentMethodTab accept showSaveOption prop

This will allow us to show the save checkbox only if the payment method says it should be shown.

* Update tests to use new keys in supports when reg'ing payment methods

* Add optional chaining when validating payment method config

This makes the code a little tidier :)

* Update assets/js/blocks-registry/payment-methods/payment-method-config.js

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>

* Add more information to deprecated call in payment method config

* Fix lint error

* Fix prop types for PaymentMethodTab

* Add information about supports on payment methods to docs

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
2021-01-24 14:59:13 +01:00
..
add-to-cart-form Fix circular dependencies (https://github.com/woocommerce/woocommerce-blocks/pull/3704) 2021-01-19 10:55:44 -05:00
cart-checkout Change payment processing for subscriptions (https://github.com/woocommerce/woocommerce-blocks/pull/3686) 2021-01-24 14:59:13 +01:00
editor show preview "saved payment methods" in editor (https://github.com/woocommerce/woocommerce-blocks/pull/2151) 2020-04-15 12:05:01 +12:00
shared Add "you don't need lodash/underscore" eslint rule (https://github.com/woocommerce/woocommerce-blocks/pull/3634) 2021-01-05 08:58:18 -05:00
test Add @woocommerce/eslint-plugin dependency (https://github.com/woocommerce/woocommerce-blocks/pull/3115) 2020-09-07 13:31:10 -04:00
container-width-context.js Enable and fix all jsdoc rule violations (https://github.com/woocommerce/woocommerce-blocks/pull/3168) 2020-09-20 19:54:08 -04:00
index.js Add to cart context provider (https://github.com/woocommerce/woocommerce-blocks/pull/2903) 2020-07-30 11:57:22 +01:00
query-state-context.js Update NPM dependencies and script dependency handling (https://github.com/woocommerce/woocommerce-blocks/pull/1337) 2019-12-10 12:17:46 -05:00
store-notices-context.js Enable and fix all jsdoc rule violations (https://github.com/woocommerce/woocommerce-blocks/pull/3168) 2020-09-20 19:54:08 -04:00
utils.js Add context value validation for context apis that receive an object. (https://github.com/woocommerce/woocommerce-blocks/pull/1174) 2019-11-14 09:51:32 -05:00