Vexor

Initialize the SDK

As regards the code, the only difference between the Open Source version and the commercial one is the way you initialize the SDK, you'll see that below.

If you need to know more about the differences as regards the product itself, you can read the differences page.

Installation

Vexor can be installed in any Node.js-based project. To install Vexor, simply run one of the following commands in your project directory:

npm install vexor

or

npm i vexor

This will install the core Vexor library, which can be used with any Node.js-based framework or library.

Static Initialization

There are 3 ways to instantiate a Vexor instance:

  1. Using the new Vexor() constructor with publishable key, project id and secret key.
  2. Using the Vexor.init() static method.
  3. Using the Vexor.fromEnv() only available in the commercial version.

StaticVexor.init(params) | new Vexor(params)

Returns

These methods return a new Vexor instance. Choose the method that best fits your application's architecture/conventions.

import { Vexor } from 'vexor';
 
export const vexor = Vexor.init({
  platforms: {
     mercadopago?: {
      public_key: string;
      access_token: string;
      client_id?: string;
      client_secret?: string;
      webhook_secret?: string;
      webhooks_url?: string;
      sandbox?: boolean;
    },
    stripe?: {
      public_key: string;
      secret_key: string;
      webhook_secrets?: string[];
      sandbox?: boolean;
    },
    paypal?: {
      client_id: string;
      secret_key: string;
      webhook_id?: string;
      sandbox?: boolean;
    },
    talo?: {
      user_id: string;
      client_id: string;
      client_secret: string;
      webhooks_url?: string;
      sandbox?: boolean;
    },
    square?: {
      access_token: string;
      application_id: string;
      webhooks_url?: string;
      webhook_signature_key?: string;
      sandbox?: boolean;
    }
  }
});

Recommendations

  1. Create a .env file in your project root and add your Vexor environment variables:
PUBLIC_VEXOR_KEY=pk_test_1234567890
PUBLIC_VEXOR_PROJECT=proj_0987654321
VEXOR_SECRET_KEY=sk_test_1234567890

WARNING: Do not store any secrets (such as VEXOR_SECRET_KEY) in your React app! These keys should be handled on the server side.

  1. Create a vexor.ts file in your lib or utils folder and export the Vexor instance:
import { Vexor } from 'vexor';
 
export const vexor = Vexor.init({
  publishableKey: process.env.PUBLIC_VEXOR_KEY,
  projectId: process.env.PUBLIC_VEXOR_PROJECT,
  secretKey: process.env.VEXOR_SECRET_KEY
});

Choose the method that best fits your application's architecture and security requirements.

The Vexor.init() method is functionally equivalent to using the new Vexor() constructor. It's provided as an alternative syntax that some developers may find more intuitive or easier to use in certain contexts.

Next Steps

Follow the guides to start integrating Vexor into your project.

On this page