Refunds & Disputes
Palbase supports full and partial refunds either back to the original payment method or instantly to the customer's closed-loop wallet, plus double-entry wallet accounting for the disputes Stripe tells Palbase of.
Issuing refunds
Every call to POST /payments/refunds requires an Idempotency-Key header so network retries never double-refund a payment. Pass amount: 0 (or omit amount) to refund the full remaining refundable amount, or specify a smaller minor-unit amount for partial refunds. A payment taken at once gives back, with its price, the tax its provider added on top of it (a web subscription's first payment, a checkout whose tax is exclusive): the card's share and that tax, and a wallet's share to the wallet. Nothing else the card was charged above its share is the payment's — an installment's interest stays with the provider — and a payment captured by hand gives back what was captured.
Money a closed payment receives goes back by itself
A provider can still take money on a payment after it was closed: iyzico's payment form cannot be closed from its API, so a buyer who kept it open can pay a payment that was canceled or expired; two pages of one payment can be paid at the same moment. Money that does not match its payment (another currency, less than its card's share) is given back the same way, and the payment stays payable. Palbase does not make the payment paid by such money, nor count it as the payment's. It closes the attempt that took it, gives the money back (a hold is voided, a charge refunded in full; a subscription the money began is ended) and tells you with payments.payment.charge_returned (why: canceled, expired, paid_by_another, mismatch, balance_limit — a top-up its wallet refused for good — or customer_erased — a top-up paid after its person was erased; a top-up given back for either of these two fails). The attempt lists it under returned. It is no refund of the payment's: POST /payments/refunds still refunds what the payment itself was paid. A provider out of reach is asked again until it takes it. One that refuses the channel's keys is asked again until they are mended, and told once meanwhile (status: pending). One that refuses for good, or a channel deleted since, is told with status: failed, and the money is yours to give back.
Original card vs instant wallet credit
destination: "original"(default): Executes the provider refund (on iyzico, automatically picks same-daycancelvs post-settlementrefund; on Stripe, creates a Stripe Refund).destination: "wallet": Immediately credits the customer's closed-loop wallet (wallet_key) in a balanced double-entryrefund_to_walletledger transaction — zero settlement lag and zero card-network refund wait. The provider never hears of a wallet refund: don't refund the same payment again in the provider's own dashboard, which would give the card back what the wallet already received. Refund what is left through this API, which counts both.
import { createServer } from "palbase/server";
const palbase = createServer({
url: process.env.PALBASE_URL!,
secretKey: process.env.PALBASE_SECRET_KEY!,
});
export async function issueInstantWalletRefund(intentId: string, refundRef: string, amountMinor: number) {
const { data: refund } = await palbase.payments.createRefund({
headers: { "Idempotency-Key": `refund:${refundRef}` },
body: {
intent_id: intentId,
amount: amountMinor,
destination: "wallet",
wallet_key: "try",
reason: "instant_store_credit",
},
});
return refund;
}
Operators can issue both original-card and instant-wallet refunds directly from the transaction detail sheet in Studio (Payments › Transactions).
Settled refunds update intent.refunded_amount and emit payments.refund.succeeded. Inspect refund history at GET /payments/refunds.
A subscription's payment refunded at Stripe
A refund made at Stripe's dashboard of a subscription's payment — its first payment, a renewal, seats charged within a period (a subscription's charges are payments) — is read from Stripe when it tells of it (charge.refunded), written on the payment once, and emitted as payments.refund.succeeded with actor: "provider". One that Palbase itself asked Stripe for is not written twice: while its answer is not written yet, Stripe's word of it waits and is taken again. A refund made at the dashboard of any other payment is not read yet: refund those with POST /payments/refunds.
Disputes & wallet chargeback accounting
Palbase hears of a dispute from Stripe. When Stripe tells of one (charge.dispute.*), Palbase reads it again from Stripe, writes it under GET /payments/disputes (visible in Studio under Payments › Disputes) and emits payments.dispute.opened when it opens and payments.dispute.closed when it is won or lost. A dispute moved to review (under_review) emits nothing: read it from the list. A status told again is told once. A dispute's status is opened (any status of Stripe's other than these three), under_review, won or lost. A dispute of a subscription's renewal or of seats charged within a period is that charge's payment's, named by its invoice_id.
If the disputed payment was a wallet top-up, the wallet follows the dispute:
- Opened (
opened,under_review): the wallet is not touched. The top-up's money stays spendable while the dispute is open. - Lost (
lost): Palbase posts onechargeback_debitof the dispute's amount. Money in the wallet whose time has ended is let go first; the wallet's money is taken; what it cannot cover becomesdebt, the wallet is setfrozen: true(its spends, holds and transfers are refused, top-ups still land) andpayments.wallet.debt_createdis emitted. - Won after it was lost (
won): Palbase gives back exactly what the loss took, once, as achargeback_reversal. Like any money in, it pays the wallet'sdebtfirst; once the debt is zero the wallet is unfrozen. - Won with nothing taken (
won): a dispute won before it was ever lost moves nothing.
A status told twice, or by two deliveries at once, changes the wallet once: each effect is keyed by its dispute. While the wallet is busy, Stripe is answered 503 and tells it again. A dispute of a charge Palbase gave back as no money of its payment's (money a closed payment receives) is written and told with returned_charge: true, and takes nothing from the wallet.
Submit evidence in your Stripe dashboard before evidence_due_at.
iyzico chargebacks are not told to Palbase
iyzico tells Palbase of no chargeback: its webhooks carry none, and Palbase has no route that writes one, so GET /payments/disputes lists none of iyzico's. When a cardholder disputes an iyzico payment, iyzico contacts you itself and you answer it by iyzico's chargeback procedure. Palbase takes nothing from the wallet of an iyzico top-up so disputed: when iyzico tells you of one, stop that wallet yourself with PUT /payments/wallets/customers/{customer_id}/{wallet_key}/freeze and {"frozen": true} (its spends, holds and transfers are refused); {"frozen": false} lifts it. A wallet frozen by hand that also carries chargeback debt is unfrozen when money in pays that debt to zero.