Payment Integrations

Payment Integrations

Vendure can support many kinds of payment workflows, such as authorizing and capturing payment in a single step upon checkout or authorizing on checkout and then capturing on fulfillment.

Creating an integration

Payment integrations are created by creating a new PaymentMethodHandler and passing that handler into the paymentOptions.paymentMethodHandlers array in the VendureConfig.

import { PaymentMethodHandler, VendureConfig } from '@vendure/core';

const myPaymentIntegration = new PaymentMethodHandler({
    code: 'my-payment-method',
    // ... 
    // configuration of the handler (see PaymentMethodConfigOptions docs)
});

export const config: VendureConfig = {
    // ...
    paymentOptions: {
        paymentMethodHandlers: [myPaymentIntegration],
    },
};

For a more complete example of a payment integration, see the PaymentMethodHandler documentation.

Using an integration

In your storefront application, this payment method can then be used when executing the addPaymentToOrder mutation, as the “method” field of the PaymentInput object.

mutation {
    addPaymentToOrder(input: { 
        method: "my-payment-method",
        metadata: { id: "<some id from the payment provider>" }) {
        ...Order
    }
}