RefundServiceoperates on a specific payment ID — pass the payment ID when callingcreate.
Methods
Create a refund
Full refund
Omitamount to refund the full payment:
Partial refund
Passamount to refund a specific amount:
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
import { createOakClient, createRefundService } from '@oaknetwork/payments-sdk';
const client = createOakClient({ ... });
const refunds = createRefundService(client);
RefundServiceoperates on a specific payment ID — pass the payment ID when callingcreate.
| Method | Description |
|---|---|
create(paymentId, refund) | Refund a payment |
amount to refund the full payment:
const result = await refunds.create('pay_abc123', {});
if (result.ok) {
console.log('Refund ID:', result.value.data.id);
console.log('Status:', result.value.data.status);
}
amount to refund a specific amount:
const result = await refunds.create('pay_abc123', {
amount: 2500,
metadata: {
reason: 'Customer requested partial refund',
},
});
if (result.ok) {
console.log('Refund ID:', result.value.data.id);
console.log('Amount:', result.value.data.amount);
}
| Field | Type | Required | Description |
|---|---|---|---|
amount | number | No | Amount to refund. Omit for a full refund. |
metadata | Record<string, any> | No | Custom metadata attached to the refund |
| Field | Type | Description |
|---|---|---|
id | string | Refund ID |
status | string | Refund status (e.g., "created") |
type | "refund" | Always "refund" |
amount | number | Refunded amount |
provider | string | Provider that processed the refund |