Getting the available shipping methods in a component is simple.
We'll be using the PaymentMethodListQuery query from @deity/falcon-shop-data and SetPaymentMethod from @deity/falcon-front-kit.
First you'll need to ensure your shop API has a paymentMethodList method that returns methods. If you're using one of our existing integrations this will exist already.
In your client side component the code is as simple as:
The next thing you'll want to do is to get the selected payment method and load the payment UI.
We use loadable so only the selected method is loaded. As you can see from the code below we use the provider code and method (if available) to define which UI components to load.
You'll notice we have 2 additional components also loaded:
{
result && result.url&&<TestAdditionalPaymentStep{...result}/>;
}
{
result && result.id&&<Redirect to="/checkout/confirmation"/>;
}
TestAdditionalPaymentStep is used to handle payment methods that require an additional step, e.g. 3D secure.
Redirect simple redirects a user to your desired success page if result exists in useCheckout.
This example is taken from our Stripe credit card form. We wrap the entire form in StripePlugin, this loads the various scripts that are needed to load the Stripe card fields. You'll notice we pass prop to StripePlugin. These props are passed from Falcon Payment and depending on your method are likely to contain API keys needed to load the UI.
If you can't find what you're looking for, the answer might be on our community slack channel. Our team keep a close eye on this and will usually get back to you within a few hours, if not straight away. If you haven't created an account yet please sign up here slack.deity.io.
Stay up to date
Do you want to be informed when we release new features or fixes? Sign up to our newsletter to stay in the loop.