Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Add support for extensions to filter express payment methods #4774

Merged
merged 3 commits into from
Sep 23, 2021

Conversation

ralucaStan
Copy link
Contributor

This PR adds support for extensions to also filter express payment methods.

Fixes #4733

Testing

Automated Tests

  • Changes in this PR are covered by Automated Tests.
    • Unit tests
    • E2E tests

Manual Testing

How to test the changes in this Pull Request:

  1. Make sure you use the Checkout block and that you are on https
  2. In an extension register an express payment method
registerExpressPaymentMethod({
        name: "expressMethod",
        edit: null,
        content: <div>My express test method</div>,
        canMakePayment: () => true,
        paymentMethodId: "expressMethod",
        supports: {
          features: ["products"],
        },
 })
  1. Go to the Checkout block and see that the express payment method appears
  2. In the same extension register a callback to remove the above express method
 registerPaymentMethodExtensionCallbacks( 'woocommerce-marketplace-extension',
	{
		expressMethod: ( arg ) => { return false; },
	}
);
  1. Go to the Checkout block and see that the express payment method disappears

Changelog

Add support for extensions to filter express payment methods

@ralucaStan ralucaStan added type: enhancement The issue is a request for an enhancement. category: extensibility Work involving adding or updating extensibility. Useful to combine with other scopes impacted. labels Sep 17, 2021
@ralucaStan ralucaStan requested a review from opr September 17, 2021 14:35
@ralucaStan ralucaStan requested a review from a team as a code owner September 17, 2021 14:35
@github-actions
Copy link
Contributor

github-actions bot commented Sep 17, 2021

Size Change: -25 B (0%)

Total Size: 1.25 MB

Filename Size Change
build/blocks-checkout.js 21 kB -3 B (0%)
build/wc-blocks-registry.js 3.71 kB -23 B (-1%)
build/wc-blocks-shared-context.js 1.54 kB +1 B (0%)
ℹ️ View Unchanged
Filename Size
build/active-filters-frontend.js 8.34 kB
build/active-filters.js 8.01 kB
build/all-products-frontend.js 23.1 kB
build/all-products.js 37 kB
build/all-reviews.js 9.56 kB
build/atomic-block-components/add-to-cart--atomic-block-components/button--atomic-block-components/image---a7e2bb9b.js 2.66 kB
build/atomic-block-components/add-to-cart--atomic-block-components/button.js 1.81 kB
build/atomic-block-components/add-to-cart--atomic-block-components/image--atomic-block-components/title.js 332 B
build/atomic-block-components/add-to-cart-frontend.js 8.38 kB
build/atomic-block-components/add-to-cart.js 7.72 kB
build/atomic-block-components/button-frontend.js 1.74 kB
build/atomic-block-components/button.js 875 B
build/atomic-block-components/category-list-frontend.js 472 B
build/atomic-block-components/category-list.js 476 B
build/atomic-block-components/image-frontend.js 1.88 kB
build/atomic-block-components/image.js 1.35 kB
build/atomic-block-components/price-frontend.js 2.13 kB
build/atomic-block-components/price.js 2.11 kB
build/atomic-block-components/rating-frontend.js 563 B
build/atomic-block-components/rating.js 566 B
build/atomic-block-components/sale-badge-frontend.js 862 B
build/atomic-block-components/sale-badge.js 869 B
build/atomic-block-components/sku-frontend.js 391 B
build/atomic-block-components/sku.js 393 B
build/atomic-block-components/stock-indicator-frontend.js 613 B
build/atomic-block-components/stock-indicator.js 611 B
build/atomic-block-components/summary-frontend.js 906 B
build/atomic-block-components/summary.js 911 B
build/atomic-block-components/tag-list-frontend.js 468 B
build/atomic-block-components/tag-list.js 471 B
build/atomic-block-components/title-frontend.js 1.47 kB
build/atomic-block-components/title.js 1.29 kB
build/attribute-filter-frontend.js 18.7 kB
build/attribute-filter.js 12.2 kB
build/cart-frontend.js 91.3 kB
build/cart-i2-frontend.js 91.1 kB
build/cart-i2.js 46.9 kB
build/cart.js 46.5 kB
build/checkout-blocks/actions-frontend.js 1.47 kB
build/checkout-blocks/billing-address--checkout-blocks/shipping-address-frontend.js 5.09 kB
build/checkout-blocks/billing-address-frontend.js 1.14 kB
build/checkout-blocks/contact-information-frontend.js 3.88 kB
build/checkout-blocks/express-payment--checkout-blocks/payment-frontend.js 4.83 kB
build/checkout-blocks/express-payment-frontend.js 1.83 kB
build/checkout-blocks/fields-frontend.js 290 B
build/checkout-blocks/order-note-frontend.js 1.56 kB
build/checkout-blocks/order-summary-frontend.js 12.7 kB
build/checkout-blocks/payment-frontend.js 4.51 kB
build/checkout-blocks/sample-frontend.js 249 B
build/checkout-blocks/shipping-address-frontend.js 1.62 kB
build/checkout-blocks/shipping-methods-frontend.js 5.54 kB
build/checkout-blocks/terms-frontend.js 1.64 kB
build/checkout-blocks/totals-frontend.js 270 B
build/checkout-frontend.js 54.2 kB
build/checkout.js 52.5 kB
build/featured-category.js 7.73 kB
build/featured-product.js 9.42 kB
build/handpicked-products.js 6.26 kB
build/mini-cart-component-frontend.js 36.6 kB
build/mini-cart-frontend.js 2.35 kB
build/mini-cart.js 2.34 kB
build/price-filter-frontend.js 14.4 kB
build/price-filter.js 9.63 kB
build/price-format.js 1.37 kB
build/product-best-sellers.js 6.61 kB
build/product-categories.js 3.38 kB
build/product-category.js 7.49 kB
build/product-new.js 6.77 kB
build/product-on-sale.js 7.12 kB
build/product-search.js 2.66 kB
build/product-tag.js 6.58 kB
build/product-top-rated.js 6.73 kB
build/products-by-attribute.js 7.7 kB
build/reviews-by-category.js 11.5 kB
build/reviews-by-product.js 13 kB
build/reviews-frontend.js 8.97 kB
build/single-product-frontend.js 26.2 kB
build/single-product.js 9.76 kB
build/stock-filter-frontend.js 8.77 kB
build/stock-filter.js 7.81 kB
build/vendors--atomic-block-components/add-to-cart--checkout-blocks/billing-address--checkout-blocks/orde--63cde524-frontend.js 16.2 kB
build/vendors--atomic-block-components/add-to-cart-frontend.js 4.77 kB
build/vendors--atomic-block-components/price--checkout-blocks/order-summary--checkout-blocks/shipping-methods-frontend.js 5.71 kB
build/vendors--checkout-blocks/billing-address--checkout-blocks/order-summary--checkout-blocks/shipping-address-frontend.js 5.02 kB
build/vendors--checkout-blocks/order-summary-frontend.js 3.11 kB
build/wc-blocks-data.js 11.3 kB
build/wc-blocks-editor-style-rtl.css 15.6 kB
build/wc-blocks-editor-style.css 15.6 kB
build/wc-blocks-google-analytics.js 1.98 kB
build/wc-blocks-middleware.js 1.47 kB
build/wc-blocks-shared-hocs.js 1.75 kB
build/wc-blocks-style-rtl.css 20.1 kB
build/wc-blocks-style.css 20.1 kB
build/wc-blocks-vendors-style-rtl.css 1.37 kB
build/wc-blocks-vendors-style.css 1.37 kB
build/wc-blocks-vendors.js 254 kB
build/wc-blocks.js 3.5 kB
build/wc-payment-method-bacs.js 806 B
build/wc-payment-method-cheque.js 806 B
build/wc-payment-method-cod.js 898 B
build/wc-payment-method-paypal.js 839 B
build/wc-payment-method-stripe.js 12.2 kB
build/wc-settings.js 2.91 kB

compressed-size-action

@ralucaStan ralucaStan removed the request for review from a team September 20, 2021 14:23
Copy link
Contributor

@opr opr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works as advertised 👏🏼 Just a query about the tests. From simply reading the tests, it's not super clear what we're testing, or why we're expecting certain things... I would love it if you added inline comments with an explanation about why we're expecting the result.

args.features,
args.paymentMethodName
)( canMakePaymentArgument );
expect( canMakePayment ).toBe( falseCallback() );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't falseCallback() evaluate to simply false, so you're testing here expect( canMakePayment ).toBe( false ); or am I misunderstanding?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the test in 630a15e, hope this makes it more clear

@ralucaStan ralucaStan force-pushed the add/4733-express-payment-with-extensions branch from d5b7a4a to 832814d Compare September 22, 2021 13:46
@ralucaStan ralucaStan requested a review from opr September 22, 2021 14:23
@ralucaStan ralucaStan added the block: checkout Issues related to the checkout block. label Sep 22, 2021
Copy link
Contributor

@opr opr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making the changes and describing the tests better! 🙌🏼

@github-actions github-actions bot added this to the 6.0.0 milestone Sep 23, 2021
@ralucaStan ralucaStan merged commit e84577d into trunk Sep 23, 2021
@ralucaStan ralucaStan deleted the add/4733-express-payment-with-extensions branch September 23, 2021 09:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
block: checkout Issues related to the checkout block. category: extensibility Work involving adding or updating extensibility. Useful to combine with other scopes impacted. type: enhancement The issue is a request for an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow express payment methods to be filtered by extensions
2 participants