reactioncommerce / reaction

Mailchimp Open Commerce is an API-first, headless commerce platform built using Node.js, React, GraphQL. Deployed via Docker and Kubernetes.
https://mailchimp.com/developer/open-commerce/
GNU General Public License v3.0
12.3k stars 2.17k forks source link

Available Payment options are hardcoded for v2.x #4841

Closed janus-reith closed 5 years ago

janus-reith commented 5 years ago

Issue Description

The array for available payment templates is hardcoded in v2.x. I noticed this while reimplementing my Paypal Express Integration.

In imports/plugins/core/payments/client/checkout/payment/methods.js there are template names defined for the included plugins, ignoring custom plugins that might be added.

Steps to Reproduce

  1. Simply take a look at the linked code above and notice why this won't work # Or
  2. Create your own payment plugin, or copy the example plugin and replace all instances of example/Example to avoid issues, including file names.
  3. Enable the new plugin in the dashboard
  4. Try to checkout and notice how the new plugin doesn't show up as availabe payment option, while there is no error thrown (and no hint of it in reacts virtual dom inspector.)
  5. Manually add paymentMethods.name as key + the name of the component you registered as value to the templates object in the file linked above.
  6. Verify that the payment option is displayed now.

Possible Solution

The availablePaymentMethods query already lists available payment options, including custom ones. It returns name and pluginName.

Option A: add an additional field to be returned from the query, e.g. templateName Option B: Enforce a naming convention like it is done for capture/authorize methods, and derive the component name from pluginName.

Versions

v2.0.0-rc.7

aldeed commented 5 years ago

See comment: https://github.com/reactioncommerce/reaction/issues/4893#issuecomment-452813044