Skip to content
ZytePedevelopersDashboard
DocsAPI reference
API reference

Create Refund

Creates a full or partial refund against a paid hosted checkout payment.

POST/refunds/createPlugin signed
Use your enabled merchant account. Examples run on your server, never in this documentation.

Authentication

Use plugin-signed headers. The signature scheme differs from merchant HMAC. Local source clarifies Unix-second timestamps and hexadecimal output; confirm deployment compatibility.

See authentication.

Workflow notes

  • Do not refund more than the captured amount.
  • The reviewed refund handler requires an Idempotency-Key of at least 16 characters. Reuse the same key when retrying the same refund.

Before you send

Check the field labels and use your enabled merchant account. Examples illustrate the API contract; confirm deployment-specific limits and error handling before launch. This page never sends a request.

Request example

Choose Node.js, Python, PHP, Ruby, Java or cURL. Run signed requests on your backend. PHP, Ruby and Java include signing directly. Java requires JDK 17 or newer.

import { pluginSignedHeaders } from './plugin-signing.mjs';
const path = `/refunds/create`;
const query = '';
const payload = {
  "merchant_id": "MERCHANT_001",
  "payment_id": "pay_123",
  "amount": "100.00",
  "currency": "INR",
  "reason": "Customer requested partial refund",
  "merchant_refund_id": "refund_ORDER_123_1"
};
const body = JSON.stringify(payload);
const headers = pluginSignedHeaders({
  method: 'POST', path, body,
  keyId: process.env.ZYTEPE_API_KEY_ID,
  secret: process.env.ZYTEPE_API_SECRET,
});
// Save this key before sending; reuse it for the same payment retry.
const idempotencyKey = process.env.ZYTEPE_IDEMPOTENCY_KEY;
if (!idempotencyKey || idempotencyKey.length < 16) throw new Error('Set a saved idempotency key of at least 16 characters');
headers['Idempotency-Key'] = idempotencyKey;
headers['Content-Type'] = 'application/json';
const url = 'https://api.zytepe.com' + path + (query ? '?' + query : '');
const response = await fetch(url, { method: 'POST', headers, body });
if (!response.ok) throw new Error('Request failed: HTTP ' + response.status);
const result = await response.json();
// Store the returned identifiers securely. Do not log customer data.

Request fields

Optional fields can be omitted. Conditional fields depend on the payment method. Labels reflect the reviewed API schemas and handler checks.

merchant_idRequired

Your merchant identifier.

payment_idRequired

The payment identifier returned by checkout creation.

amountRequired

Payment amount in the documented currency.

currencyOptional

Defaults to INR.

reasonOptional

Reason for the refund.

merchant_refund_idOptional

Your refund reference. Retain it for tracking.

Path, query and headers

Idempotency-KeyRequiredheader

Required by the reviewed refund handler. At least 16 characters; reuse the saved key for the same refund retry.

Request body

JSON · request.json
{
  "merchant_id": "MERCHANT_001",
  "payment_id": "pay_123",
  "amount": "100.00",
  "currency": "INR",
  "reason": "Customer requested partial refund",
  "merchant_refund_id": "refund_ORDER_123_1"
}

Example response

JSON · response
{
  "refund_id": "refund_ORDER_123_1",
  "payment_id": "pay_123",
  "status": "completed",
  "amount": "100.0000",
  "currency": "INR",
  "provider_reference": "RFND123456",
  "merchant_refund_id": "refund_ORDER_123_1"
}