Registering a new Payment Provider
Your payment provider acts as the middleware between your frontend components and the payment service provider (Stripe, Braintree, PayPal etc.).
Payment Providers are registered in your server side config (
They are registered against the api.
payments maps to the section within
Each provider has a package associated with it and a
config object. You can use this config to pass data such as API keys to your provider. As per any config it's worth looking at which config file should contain which configurations (to avoid sensitive data by committed to your repository).
Stripe and Cash on delivery providers are both shipped with our
How the provider works
There are a few keys things to understand about payment providers:
- Configurations added to the
configobject in your config json files are available as
initializefunction is run when the method is selected
validatefunction is run when the payment is triggered on the frontend.
initializehave access to the param
payload(more info below).
This is a good example of what your payment provider might look like:
This function is triggered when the method is selected, before the linked component (more on this later) is rendered.
payload is an object that will look like this:
It expects an object of type
PaymentMethodInstance to be returned, this will look like this:
config object returned can return any information you might need in your components. This is a great place to put keys and config you need to render the payment form.
This method is triggered by the
placeOrder function imported from
demo-v2 example project this is found in
payload is passed from the
pay() in your payment component.