Closed aldeed closed 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
paymentMethodOptions
to use paymentMethods
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."change input[name=enabled]"
handler to call the enabledPaymentMethodForShop
mutation instead of both Meteor.call
that are currently there.For all of this, you'll need to use the simpleClient
because it's Blaze code. To do this:
/imports/plugins/core/graphql/lib
and then import all three into /imports/plugins/core/graphql/lib/helpers/simpleClient.js
, following the pattern there to add them to mutations
or queries
object.simpleGraphQLClient
from there and call simpleGraphQLClient.mutations.enabledPaymentMethodForShop(...).then(...)
for example. You can see this used in /imports/plugins/included/payments-example/client/checkout/containers/ExampleIOUPaymentForm.js
and a few other placesFor 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");
Work
Update client UI to use GraphQL for payment methods
paymentMethods
query to get the full list of payment methods and show them along with enable/disable toggle on the operator Payment pageavailablePaymentMethods
query to get the full list of available payment methods for a shop.enabledPaymentMethodForShop
mutation when the toggle for a payment method is changed.