* WIP
* convert to reakit
* rebase and fix styling issues
* add forget initialTabName
* delete button and force manual select
* fix git diff problem in package-lock
* directly render tabs
* fix regression
* gaurd against unset values
* update reakit and guard against empty tabs
* fix dependencies
* refactor stripe payment-request to extract things into smaller units
- adds/fixes typedefs
- fixes dependencies
- improves logic.
* implement memoizing for functions.
* if same shipping address is selected, just call updateWith immediately
* add separate handler for failed shipping rate retrieval
* improve logic around shipping rate fail/success status
* add notice suppression logic to store notices.
- this is implemented in checkout processor to suppress notices when express payment methods are active.
* add error detection for shipping address errors and update the shipping status accordingly
* update type-def
* set billingData before shippingData
This is needed because of the shipping data and billing data sync logic in use-checkout-address.
* have to tighten dependencies to prevent unnecessary firing
With us now adding error status setters for shippping, the potential for the shipping status changes to trigger the effect went up. So tightening the dependencies to only the stati we care about prevent unnecessary effect calls.
* refactor event handlers to be named and remove all listeners.
This is an undocumented api on the stripe `paymentRequest.on` return value, but I’m trusting it will be relatively stable for this api.
The need for this is caused by the fact that without it, the listeners are re-registered on the paymentRequest event everytime the paymentRequest modal is closed and reopened.
* fix typo in doc block
* expose a allowSavedCards option to JS on stripe settings data
* hide 'save my card' checkbox if merchant disables saved cards
* use stripe allowSavedCards option to control "Save my card" checkbox
* (linter) remove unnecessary useEffect dependency:
- stripePromise const is defined outside component, so hook doesn't
depend on it
* clarify comment about saved cards and supports( tokenization )
* correct comment about save card merchant option - doesn't affect paying with previously saved payment methods
* use true boolean value for stripe allow saved cards setting:
previously was using woo option `yes no` style, other JS settings all use true bool
Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
* fix client side check now `allowSavedCards` is true boolean
Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
* remove unnecessary shipping field and shipping fields setter
* remove a commented out block
* account for billingData having values but billingFields not when shipping address changes.
* Update wp.editor references to wp.blockEditor
* Bump min version requirment to 5.2
* Update packages
* Revert "Update packages"
This reverts commit 7565c83a14fe8efd2e7c52473eeeaa5f837fa9fb.
* Undo server side render import changes
* bump min wp version variable
* Refactor usePaymentMethodRegistration so initialisation happens at same point as dispatch
* Update NoPaymentMethods conditonal
* Suggested changes to payment init
* always default "save my card for next time" checkbox to unchecked:
This is based on the previous checkout behaviour.
I.e. the shopper has to actively opt-in to save their card.
* Implement "save payment method for next purchase" in checkout:
- send "save card" option using existing post key
- wc-stripe-new-payment-method
- comment out inappropriate use of "save" when using a saved card (tbc)
* don't hard code the payment gateway name in 'save payment method' key
* refactor "save payment info" checkbox so payment methods can opt-in:
- Add options.allowSavePaymentToken to payment method
registration / config.
- Opt-in in Stripe CC, it allows saved cards.
- Remove render of "save my card" checkbox from Stripe CC UI component.
- Render "save my card" checkbox automatically in payment method tab
(based on allowSavePaymentToken option).
+ todo/follow up comments
* rejig "save my payment method" behaviour so it's generic:
- Any payment method that supports "save" can opt-in:
- options.allowSavePaymentToken = true/false
- handle `wc-XXX-new-payment-method` key server side to persist
- Add support in payment context/state reducer for storing checkbox
state, expose value and action via context
- Convert state flag to appropriate API key/value in payment processor
- Remove previous stripe-specific implementation
+ bonus add comment to payment context about preserving state in
PRISTINE action
* rename payment method "allow save" option, more consistent with UI
* remove last vestiges of gateway-specific "save card" impl:
- No need to pass CheckboxControl to payment methods; checkbox is
now handled automatically by checkout.
- Remove shouldSavePayment prop passing through various layers of
stripe payment processing code. (Now handled in context/processor.)
* change new option property name and shape. Also adds validation.
* update type-defs
* use more reliable `activePaymentMethod` for saved payment method
Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
* If product is changed for featured product block, update the link in the button
* add handling to _only_ update the product url when the product is changed.
* fix arguments
* only set payment status to pristine if it isn’t already successful
* add server side handling for saved tokens
* ensure correct gateway is selected when using saved card:
- reset the active payment method when user selects saved payment method
(card); this ensures that the correct gateway is used when switching
from another gateway to a saved card
* enhance radiocontrol to receive option specific change events.
* implement specific option change events
This commit:
- ensures selecting a saved payment option updates active payment method for the selected option.
- Sets the saved token key for the selected option correctly.
* remove unnecessary php side code
* fix bug with default saved payment option not applying:
When the payment options are initialised, we now call the onChange
handler for the default (`is_default`) option. This triggers payment
success() so checkout succeeds with default payment method, even if user
doesn't touch payment options.
* fix effect dependencies
Co-authored-by: Rua Haszard <rua.haszard@automattic.com>
* add typedefs for store notice context
* improve useStoreNotices hook so returned interfaces are fairly constant
* fix dependencies, defaults, and add types
* fix dependencies
* fix dependencies
* improve functions exposed on validation context so they are more constant
* fixing dependencies
* normalize tokenId to string everywhere
Assuming the token is a number is a bad idea because it is feasible that source for some payment methods could be a string. Also when retrieved as an input value, the id will be a string anyways.
* refactor to move payment processing into it’s own effect
- this is the first step in trying to improve the createSource behaviour.
* memoize setValidationErrors so onPaymentProcessing event effect doesn’t re-run unnecessarily.
* Update assets/js/payment-method-extensions/payment-methods/stripe/credit-card/use-payment-processing.js
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
* fix docs alignment
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>