Vexor

vexor.connect()

Account Connection

The vexor.connect() method allows you to connect accounts to various payment platforms. It supports both a generic method and platform-specific shortcuts.

The vexor.connect() method and its platform-specific shortcuts (vexor.connect.mercadopago(), vexor.connect.stripe()) can be used after instantiating Vexor with the project ID and secret key. The secret key is mandatory for this method.

Also take into account that most of the methods in this section will only work if you are also using the vexor.webhook() method.

Methodvexor.connect(params)

vexor.connect()

Connect an account to a specified payment platform.

Parameters

Returns

Returns a Promise that resolves to a VexorConnectResponse object.

import { vexor } from '@lib/vexor'; // Adjust the import path as necessary
const response = await vexor.connect({
platform: 'stripe',
redirectUrl: 'https://example.com/redirect',
countryCode: 'US',
express: true
});

Usage Examples

Here are some examples of how to use the vexor.connect() method:

Generic Usage

  1. Generic usage:
import { vexor } from '@lib/vexor'; // Adjust the import path as necessary
const response = await vexor.connect({
platform: 'stripe',
redirectUrl: 'https://myapp.com/connect/callback',
countryCode: 'US',
express: true
});

vexor.connect.stripe()

  1. Platform-specific shortcut for Stripe:
import { vexor } from '@lib/vexor'; // Adjust the import path as necessary
const response = await vexor.connect.stripe({
redirectUrl: 'https://myapp.com/connect/callback',
countryCode: 'US',
express: true
});

vexor.connect.mercadopago()

  1. Platform-specific shortcut for MercadoPago:
import { vexor } from '@lib/vexor'; // Adjust the import path as necessary
const response = await vexor.connect.mercadopago({
redirectUrl: 'https://myapp.com/connect/callback',
countryCode: 'AR'
});

Choose the method that best fits your application's needs and the payment platform you're connecting to.

Additional Connect Methods

vexor.connect.auth() (MercadoPago only)

Authenticate and get credentials for a MercadoPago account.

const response = await vexor.connect.auth({url: 'url_obtained_from_connect_redirect'});

vexor.connect.pay()

Create a payment using a connected account.

const response = await vexor.connect.pay({
platform: 'mercadopago',
redirectUrl: 'https://myapp.com/payment/callback',
seller: {
access_token: 'seller_access_token',
fee: '10%'
},
items: [
{
title: 'Product Name',
description: 'Product Description',
quantity: 1,
unit_price: 10.99
}
]
});

vexor.connect.dashboard() (Stripe only)

Get a URL for accessing the Stripe Express dashboard.

const response = await vexor.connect.dashboard({
  connectedAccountId: 'acct_1234567890'
});

vexor.connect.auth.refresh() (MercadoPago only)

Refresh the credentials for a connected MercadoPago account.

const response = await vexor.connect.auth.refresh({
  identifier: 'previously_obtained_identifier'
});

vexor.connect.refund()

Refund a payment made with a connected account. This method supports both generic and platform-specific usage.

Generic Usage:

const response = await vexor.connect.refund({
  platform: 'mercadopago',
  identifier: 'payment_identifier',
  seller: {
    identifier: 'seller_identifier'
  }
});

Platform-specific Usage:

const response = await vexor.connect.refund.mercadopago({
  identifier: 'payment_identifier',
  seller: {
    identifier: 'seller_identifier'
  }
});

The method accepts the following parameters:

Returns

Returns a Promise that resolves to a VexorConnectResponse object:

interface VexorConnectResponse {
  message: string;
  identifier: string;
  raw: any;
}

All vexor.connect() methods and their platform-specific shortcuts return a Promise that resolves to a VexorConnectResponse object. This object contains the connection URL, a unique identifier, and the raw response from the payment platform.

On this page