Skip to main content

Refunds

Process refunds for INR transactions -- full, partial, and bulk. Access via zenpays.refunds.

Methods

getTemplate

Ask which beneficiary fields this transaction's payment provider actually requires, before you build a refund form. Different providers need different fields, so hard-coding them breaks the moment a transaction is routed elsewhere.

const template = await zenpays.refunds.getTemplate('txn_xxx')

if (template.requiredFields.length > 0) {
// Render a form for exactly the fields this provider needs
}
else {
// Nothing extra needed — refund directly
await zenpays.refunds.create({ transactionId: 'txn_xxx' })
}

// Partial refund: pass the amount to preview fees and limits for that amount
const partial = await zenpays.refunds.getTemplate('txn_xxx', 500)
ParameterTypeRequiredDescription
transactionIdstringYesTransaction to be refunded
amountnumberNoRefund amount. Omit for a full refund

Returns a RefundPreview:

FieldTypeDescription
tspProviderstringProvider slug, e.g. sulifu_pay, stripe
tspDisplayNamestringHuman-readable provider name
requiredFieldsRefundFieldDefinition[]Fields that must be supplied to create
optionalFieldsRefundFieldDefinition[]Fields that may be supplied
oneOfGroupsstring[][]Groups where at least one complete group is required
prefilledobjectValues carried over from the original transaction

preview

Alias for getTemplate, taking the amount as an options object instead of a positional argument.

const preview = await zenpays.refunds.preview('txn_xxx', { amount: 500 })

create

Create a refund. Provide the customer's bank account details so they receive the funds via IMPS.

// Full refund
const refund = await zenpays.refunds.create({
transactionId: 'txn_xxx',
reason: 'Customer request',
beneficiaryEmail: 'customer@example.com',
beneficiaryAccount: '50100012345678',
beneficiaryIfsc: 'HDFC0001234',
})

// Partial refund
const partialRefund = await zenpays.refunds.create({
transactionId: 'txn_xxx',
amount: 500,
reason: 'Partial item return',
beneficiaryEmail: 'customer@example.com',
beneficiaryAccount: '91020034567890',
beneficiaryIfsc: 'SBIN0001234',
beneficiaryName: 'Priya Sharma',
})

Parameters:

FieldTypeRequiredDescription
transactionIdstringYesTransaction to refund
reasonstringYesRefund reason
amountnumberNoPartial refund amount (omit for full refund)
beneficiaryEmailstringYesCustomer email
beneficiaryAccountstringYesBank account number
beneficiaryIfscstringYesIFSC code (e.g. HDFC0001234)
beneficiaryNamestringNoBeneficiary name
beneficiaryMobilestringNoMobile number
beneficiaryCitystringNoCity
customerIdstringNoCustomer ID (auto-resolved if omitted)
Try it out

Test refund creation interactively using the API Simulator.


bulkUpload

Create multiple refunds in a single call.

const result = await zenpays.refunds.bulkUpload({
refunds: [
{
transactionId: 'txn_aaa',
reason: 'Customer request',
beneficiaryEmail: 'john@example.com',
beneficiaryAccount: '50100012345678',
beneficiaryIfsc: 'HDFC0001234',
},
{
transactionId: 'txn_bbb',
amount: 500,
reason: 'Partial refund',
beneficiaryEmail: 'jane@example.com',
beneficiaryAccount: '91020034567890',
beneficiaryIfsc: 'SBIN0001234',
},
],
})

get

const refund = await zenpays.refunds.get('refund_xxx')

list

const { data } = await zenpays.refunds.list({
status: 'completed',
currency: 'INR',
limit: 20,
})

cancel

Cancel a refund that is still in pending_approval status.

const cancelled = await zenpays.refunds.cancel('refund_xxx')

getStats

const stats = await zenpays.refunds.getStats('2026-01-01', '2026-12-31', 'INR')

getAnalytics

const analytics = await zenpays.refunds.getAnalytics({
startDate: '2026-01-01',
endDate: '2026-12-31',
granularity: 'day',
currency: 'INR',
})

export

const downloadUrl = await zenpays.refunds.export(
{ status: 'completed', currency: 'INR' },
'csv'
)