Skip to content
ZytePedevelopersDashboard
Refunds

Refund a hosted payment

Track a full or partial refund against an existing paid payment.

Identify the original payment

Use the payment_id saved during hosted checkout. Create refund uses plugin authentication and the documented amount, currency, reason and merchant_refund_id. Do not refund more than the captured amount.

Keep a stable refund reference

Save the original refund request before sending it. The reviewed refund handler requires an Idempotency-Key of at least 16 characters on the first request and on retries. Reuse that key for the same refund. merchant_refund_id is optional, but useful for your own tracking. Confirm retention and changed-body behavior before automating retries.

Record the response

Retain refund_id, payment_id, provider_reference and the returned status. The source sample uses completed; it does not prove every refund completes synchronously. Reconcile ambiguous results with support rather than issuing another refund blindly.

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"
}

Explore the business workflow: Payment gateway overview.