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

Update client UI to use GraphQL for payment methods #4719

Closed aldeed closed 5 years ago

aldeed commented 5 years ago

Work

Update client UI to use GraphQL for payment methods

aldeed commented 5 years ago

Here are the places in the UI code that need updating:

/imports/plugins/core/payments/client/checkout/payment/methods.js Update enabledPayments function to use the availablePaymentMethods query. This will likely require using some reactive state since it's an async request. Might need to transform the response data a bit before returning it from that function.

/imports/plugins/core/payments/client/settings/settings.js

For all of this, you'll need to use the simpleClient because it's Blaze code. To do this:

aldeed commented 5 years ago

For the queries, when you need to reactively set the lists after getting them from the server, you can use the pattern found in /imports/plugins/included/payments-stripe/client/checkout/stripe.js for example.

In onCreated:

this.state = new ReactiveDict();

After the query results come:

this.state.set("paymentMethods", paymentMethods);

In the template helpers:

const paymentMethods = Template.instance().state.get("paymentMethods");