Commit Graph

23 Commits

Author SHA1 Message Date
Raluca Stan 27600b3309 Update canMakePayment to receive cart as argument and make it react to changes in billingData. (https://github.com/woocommerce/woocommerce-blocks/pull/4776)
* Add 	cartCoupons to canMakePayment argument

* Add cart to the paymentMethodArgument and improve the dependencies for the effect calling refreshCanMakePayments

* Debounce refreshCanMakePayments

The initial approach was to debounce billingData and use this value as a dependency for the useEffect that runs refreshCanMakePayments.
But because the depencies array can always change we decided to debounce the callback instead, ensuring this way that callback is not called multiple times: for example when typing a field in the billing address. Debounced was chosen instead of throttle because we want to call refreshCanMakePayments once the change event has stopped, with the final value.

* Update types and docs related to canMakePaymentArgument

* Mock the /cart call when testing payment methods

* Remove unused cartCoupons key in canMakePaymentArguments' interface
2021-09-23 16:27:02 +01:00
Mike Jolley 286d52befb Remove the need for the `canMakePayment` callback in the editor context (https://github.com/woocommerce/woocommerce-blocks/pull/4188)
* Force can pay true in editor context

* Update docs
2021-05-13 11:21:21 +01:00
Raluca Stan 8ee5e816a0 Rename onCheckoutBeforeProcessing to onCheckoutValidationBeforeProcessing (https://github.com/woocommerce/woocommerce-blocks/pull/4039) 2021-04-26 17:27:22 +02:00
Albert Juhé Lluveras 7ac2fb3ec7 Add emitResponse prop to the Payment Method Nodes props docs (https://github.com/woocommerce/woocommerce-blocks/pull/3999)
* Typo

* Add emitResponse prop in the Payment Method Nodes props docs
2021-04-06 18:07:55 +02:00
Darren Ethier c622dc653c Expose the shouldSavePayment method value to registered payment methods (https://github.com/woocommerce/woocommerce-blocks/pull/3990)
* Expose the shouldSavePayment method value to registered payment methods

* update docs for `shouldSavePayment`
2021-03-22 13:55:12 -04:00
Darren Ethier afc93035fd Add new config property for payment method registration that allows for additional saved customer token handling. (https://github.com/woocommerce/woocommerce-blocks/pull/3961)
* Add new config for saved token processing by payment methods.

* Implement new saved token handling config from registered payment methods.

* Implement new saved token handling config from registered payment met… … 2b42205 …hods.

* make sure saved token handler component is only loaded when a token payment method is selected
2021-03-15 04:50:49 -04:00
Albert Juhé Lluveras 56092fcdc4 Remove extra padding from payment methods with no description (https://github.com/woocommerce/woocommerce-blocks/pull/3952)
* Remove extra padding from payment methods with no description

* Fix typo in a code snippet in payment method docs

* Remove unnecessary div
2021-03-12 15:40:09 +01:00
Albert Juhé Lluveras 85d450a00c Hide payment methods that have missing dependencies and display an error in the admin (https://github.com/woocommerce/woocommerce-blocks/pull/3920)
* Hide payment methods that have missing dependencies and display an error in the admin

* Clarify docs

* Use wp_scripts() instead of the global

* Don't localize logs and always show the docs link

* Add wards to ensure keys exist

* Show a console error instead of a notice in the admin
2021-03-09 11:15:18 +00:00
Darren Ethier ebf6752f84 Update payment-method-integration.md
Fix indentation on code example.
2021-03-08 08:35:56 -05:00
Mike Jolley 08e8e4dd59 Added docs for canMakePayment props 2021-03-08 11:22:04 +00:00
Darren Ethier 53e4c40c56 Improvements to payment methods integration docs (https://github.com/woocommerce/woocommerce-blocks/pull/3890)
* Client side improvement to the payment method integration docs

* improvements to php docs

* Improvements to server side documentation of Payment Method Checkout blocks integration

* Update docs/extensibility/payment-method-integration.md

Co-authored-by: Allen Smith <loranallensmith@gmail.com>

* Update docs/extensibility/payment-method-integration.md

Co-authored-by: Allen Smith <loranallensmith@gmail.com>

* Update docs/extensibility/payment-method-integration.md

Co-authored-by: Allen Smith <loranallensmith@gmail.com>

* Update docs/extensibility/payment-method-integration.md

Co-authored-by: Allen Smith <loranallensmith@gmail.com>

* More edits addressing feedback.

* Update docs/extensibility/payment-method-integration.md

Co-authored-by: Allen Smith <loranallensmith@gmail.com>

Co-authored-by: Allen Smith <loranallensmith@gmail.com>
2021-03-01 12:52:35 -05:00
Bartosz Budzanowski 116ec41c6a Use default "features" values for payment methods. (https://github.com/woocommerce/woocommerce-blocks/pull/3796)
* Use deafault features values for payment methods.

* Fix config check.

* Fix config check.

* Update documentation.
2021-02-05 15:31:34 +00:00
Bartosz Budzanowski a0eb52d32b Introduce payment gateway feature check for cart content. (https://github.com/woocommerce/woocommerce-blocks/pull/3719)
* Add supports data to payment methods abstractions. Implement in Stripe.

* Add capabilities to the payment gateway.

* Payment requirements in cart schema.

* Supported features format update.

* Formatting.

* Check required payment features.

* Refactor capabilieties check.

* No need for the cart parameter.

* Allow external modifiacation of features capability.

* Use ExtendRestApi to inject payment requirements into cart endpoint.

* Simplify the code.

* Enable more integrations.

* Enable Stripe payment request.

* Move  the filter to a more correc location.

* Add features check.

* Update typedefs and documentation.

* Update tests with new functionality.

* Style fixes.
2021-01-29 07:28:44 +01:00
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
Rua Haszard 8395954c7a Support a plain js config argument to payment method registration APIs (https://github.com/woocommerce/woocommerce-blocks/pull/3404)
* handle plain options passed to registerPaymentMethod:
- no need for a callback dance
- support the previous API: if a function is passed, call it as before

* update Stripe for new registerPaymentMethod interface

* update docs & all built-in payment methods to simpler API

* handle plain options arg to registerExpressPaymentMethod:
- add legacy fallback if passed a function
- update stripe express payment method
- update docs
- remove unused `assertValidPaymentMethodCreator` util

* use correct case for `JavaScript`

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>

* typedefs for payment registration options + tidies for regular methods

* typedef express payment options arg & tidy stripe/payment-request:
- use camelCase for config instance (not a constructor/type)

* mention typedefs in payment method dev docs

* use @wordpress/deprecated to warn if callback passed to payment register

* update unit tests for new payment method API

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-11-19 11:06:33 +13:00
Darren Ethier bb2acf726a Change default branch name to trunk (https://github.com/woocommerce/woocommerce-blocks/pull/3199)
* replace references to main branch with references to trunk

* update travis config to point to trunk not main branch

* more branch name changes
2020-09-26 13:28:16 -04:00
Rua Haszard aee97ceb3f Support cash on delivery payment method in checkout block (https://github.com/woocommerce/woocommerce-blocks/pull/2831)
* stub out COD payment method for checkout block

* consistently use sentence case for (default) payment tab labels

* expose COD `enable_for_virtual` option to client

* correct docblock return value comment Stripe::get_inline_cc_form()

* allow merchant to disable COD payment for virtual/downloadable orders

* tweak canMakePayment dev docs - add cart-dependent example use case

* only allow (show) COD if initially-selected shipping method(s) allow

* tweak `canMakePayment` payment extension API docs

* use $VID:$ substitution for `@since` version in new payment methods

* use FILTER_VALIDATE_BOOLEAN for payment method boolean options

* use more semantic `some` when hunting for COD-unsupported shipping

* clarify `canMakePayment` API docs

* re-select payment method if selected method disappears (e.g. COD) +
+ factor out early return into separate if at top for clarity
2020-07-15 10:14:41 -04:00
Mike Jolley 582ba8797f Update references to use main 2020-06-16 10:38:19 +01:00
Darren Ethier 5dafeac1ab Audit payment method interface API (https://github.com/woocommerce/woocommerce-blocks/pull/2622)
* remove obsolete useStoreOrder hook and implementation.

This hook was actually never completed and was only implemented in the `usePaymentMethodInterface` hook/api. The original purpose was to expose order details to registered payment methods, but that is now exposed via checkout state event emitters so it’s no longer needed.

OrderId is exposed via the `CheckoutState` context provider.

* remove setBillingData from being exposed to payment methods directly

billingData is updated via event emitter callback responses (see payment method data context provider) and is not something that should be set directly via payment methods.

We want checkout to have control over how billing data is updated in the state.
2020-06-05 11:20:05 -04:00
Mike Jolley 3122447ae4 Update payment-method-integration.md 2020-04-30 10:55:57 +01:00
Mike Jolley 4c16280977 Add placeOrderButtonLabel docs 2020-04-30 10:55:26 +01:00
Darren Ethier ae3a2dc7ad improve tocs in recently merged docs (https://github.com/woocommerce/woocommerce-blocks/pull/2246) 2020-04-17 11:42:51 -04:00
Darren Ethier 0a98037606 Add documentation for checkout flow and payment method integrations (https://github.com/woocommerce/woocommerce-blocks/pull/2246)
* add documentation for checkotu flow and payment method integrations

* Update docs/block-client-apis/README.md

Co-Authored-By: Mike Jolley <mike.jolley@me.com>

* Update docs/block-client-apis/README.md

Co-Authored-By: Mike Jolley <mike.jolley@me.com>

* Update docs/block-client-apis/checkout/checkout-api.md

Co-Authored-By: Mike Jolley <mike.jolley@me.com>

* standardize around capitalized API

* Remove extra dash.

Co-Authored-By: Mike Jolley <mike.jolley@me.com>

* Update docs/block-client-apis/checkout/checkout-api.md

Co-Authored-By: Mike Jolley <mike.jolley@me.com>

* Update docs/block-client-apis/checkout/checkout-api.md

Co-Authored-By: Mike Jolley <mike.jolley@me.com>

* Update docs/block-client-apis/checkout/checkout-api.md

Co-Authored-By: Mike Jolley <mike.jolley@me.com>

* remove 1st person narrative

* various other grammar fixes

* add table of contents to docs

Co-authored-by: Mike Jolley <mike.jolley@me.com>
2020-04-17 11:37:09 -04:00