Vexor

vexor.subscribe()

Subscription Creation

The vexor.subscribe() method allows you to create subscription checkouts for various platforms. It supports both a generic method and platform-specific shortcuts.

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

Methodvexor.subscribe(params)

vexor.subscribe()

Create a subscription checkout for a specified platform.

Parameters

Returns

Returns a Promise that resolves to a VexorSubscriptionResponse object.

const response : VexorSubscriptionResponse = await vexor.subscribe({
  platform: 'stripe',
  name: 'Premium Plan',
  description: 'Monthly subscription to Premium features',
  interval: 'month',
  price: 19.99,
  currency: 'USD',
  successRedirect: 'https://example.com/success',
  failureRedirect: 'https://example.com/failure',
  customer: {
    email: 'customer@example.com',
    name: 'John Doe'
  }
});

Usage Examples

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

Generic Usage

  1. Generic usage:
const response : VexorSubscriptionResponse = await vexor.subscribe({
  platform: 'stripe', // or 'mercadopago' or 'paypal'
  name: 'Pro Plan',
  description: 'Access to all premium features',
  interval: 'month',
  price: 29.99,
  currency: 'USD',
  successRedirect: 'https://myapp.com/subscription/success',
  failureRedirect: 'https://myapp.com/subscription/failure',
  customer: {
    email: 'user@example.com',
    name: 'Jane Smith'
  }
});

vexor.subscribe.stripe()

  1. Platform-specific shortcut for Stripe:
const response : VexorSubscriptionResponse = await vexor.subscribe.stripe({
  name: 'Pro Plan',
  interval: 'month',
  price: 29.99,
  currency: 'USD',
  successRedirect: 'https://myapp.com/subscription/success'
});

vexor.subscribe.mercadopago()

  1. Platform-specific shortcut for MercadoPago:
const response : VexorSubscriptionResponse = await vexor.subscribe.mercadopago({
  name: 'Pro Plan',
  interval: 'month',
  price: 29.99,
  currency: 'ARS',
  successRedirect: 'https://myapp.com/subscription/success'
});

vexor.subscribe.paypal()

  1. Platform-specific shortcut for PayPal:
const response : VexorSubscriptionResponse = await vexor.subscribe.paypal({
  name: 'Pro Plan',
  interval: 'month',
  price: 29.99,
  currency: 'USD',
  successRedirect: 'https://myapp.com/subscription/success'
});

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

The vexor.subscribe() method and its platform-specific shortcuts (vexor.subscribe.mercadopago(), vexor.subscribe.stripe(), vexor.subscribe.paypal()) all return a Promise that resolves to a VexorSubscriptionResponse object. This object contains the subscription URL, a unique identifier, and the raw response from the payment platform.

On this page