Vexor

vexor.refund()

Refund Processing

The vexor.refund() method allows you to process refunds for payments across various platforms. It supports both a generic method and platform-specific shortcuts.

The vexor.refund() method requires the Vexor instance to be initialized with a secret key for security reasons.

Methodvexor.refund(params)

vexor.refund()

Process a refund for a specified platform and payment.

Parameters

Returns

Returns a Promise that resolves to a VexorRefundResponse object.

const response : VexorRefundResponse = await vexor.refund({
  platform: 'stripe',
  identifier: 'payment_123'
});

Usage Examples

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

Generic Usage

  1. Using the generic method:
const response : VexorRefundResponse = await vexor.refund({
  platform: 'stripe',
  identifier: 'payment_123'
});

Platform-specific Methods

  1. Using platform-specific shortcuts:
// For Stripe
const stripeRefund : VexorRefundResponse = await vexor.refund.stripe({
  identifier: 'payment_123'
});
// For MercadoPago
const mpRefund : VexorRefundResponse = await vexor.refund.mercadopago({
  identifier: 'payment_123'
});
// For PayPal
const paypalRefund : VexorRefundResponse = await vexor.refund.paypal({
  identifier: 'payment_123'
});

Server-side Implementation Example

  • Using in a server action or API route:
'use server'
import { vexor } from "@/lib/vexor";
import { VexorRefundResponse } from "vexor";
 
export async function handleRefund(identifier: string) {
  try {
    const response : VexorRefundResponse = await vexor.refund({
      platform: 'stripe',
      identifier
    });
    return { success: true, result: response };
  } catch (error) {
    return { error: true, message: error.message };
  }
}

Always process refunds on the server side to protect your secret key. The refund method requires the secret key for authentication with the payment platforms.

On this page