Palbase IAP · API
/iap/customers/{customer_id}/subscriptions/{subscription_id}/refundRefund a subscription
Refunds the subscription's latest payment — all of it (full) or what is left of its period (prorated) — and ends it now: the customer's access ends as the call answers. Google Play and the web; the App Store decides its own refunds (409 store_decides_refunds: the customer asks Apple, which asks the app what they used — Palbase answers it when they consented). On the web (Stripe) the newest payment for a period — the last renewal's, or the first payment when it never renewed; never seats charged within a period — is given back in full at Stripe, then the subscription is ended there at once; asked again, it finds the refund made and gives nothing back twice. A web subscription's payment is refunded in full only (409 refund_in_full_only for prorated); one nothing was charged for yet, a free trial, is refused (409 nothing_to_refund: cancel it); an iyzico channel's is given back at iyzico (409 refund_unavailable). Kept in the history (refund_issued).
Called by your server, with the project's secret key.
Path
customer_idstring · requiredThe customer: the user's id (a guest merged into an account names the account).subscription_idstring (uuid) · requiredThe subscription, by its id in the customer's record (subscriptions[].id).Headers
Idempotency-Keystring · optionalMakes the write safe to send again (at most 255 characters). A retry with the same key and the same request gets the first answer back, marked `Idempotent-Replayed: true`, and changes nothing; the same key with a different request is refused with 422, and while the first request still runs a retry gets 409 with Retry-After. Answers are kept for 24 hours.Request body
mode"full" | "prorated" · required`full`: the latest payment; `prorated`: what is left of its period.notestring · optionalWhat support writes of it (500 characters at most): the record.curl -X POST "https://<your-ref>.palbase.studio/iap/customers/<customer_id>/subscriptions/<subscription_id>/refund" \
-H "apikey: $PALBASE_SECRET_KEY" \
-H "content-type: application/json" \
-d '{"mode":"full"}'Responses
200Done, and the subscription after
400A field out of its bounds (`invalid_days`, `invalid_reason`, `invalid_mode`, `invalid_note`), or the body is not the request
401No key, not a key of this project, or a token that is not valid (the edge's answer)
403Not the project's secret key (`secret_key_required`)
404The customer has no such subscription (`subscription_not_found`, `customer_not_found`)
409The App Store decides its refunds (`store_decides_refunds`); nothing is left of the period (`nothing_left_to_refund`); a web subscription's refund is in full only (`refund_in_full_only`), its current period charged the card nothing — a free trial, a credit balance — (`nothing_to_refund`), its channel gives none back from here (`refund_unavailable`), its newest payment is no payment of the project's (`payment_not_found`) or not a paid one (`intent_not_refundable`), another refund of that payment is being made (`refund_in_progress`: ask again), one of its refunds is waiting to be settled (`refund_pending`: `POST /payments/intents/{intent_id}/pending-refund`), or Stripe did not make it (`refund_failed`); the store refused (`store_refused`, with what it said), the project's store connection cannot act on it (`store_not_connected`, `apple_not_connected`, `store_not_connected`), or a request with this Idempotency-Key is still running. A refusal of Stripe's own, of a web subscription's refund or end, is answered with Stripe's status and its code
410The user was deleted (`customer_erased`)
429Over the project's request limit; Retry-After says when to try again
502The store could not be reached (`store_unreachable`), nor the payments service (`payments_unreachable`), or Stripe did not answer a web subscription's refund (`provider_unavailable`: it may have been made). Retrying with the same Idempotency-Key is safe: it gives nothing back twice
defaultAn error: the envelope names it (`error`) and explains it (`error_description`).
Operation RefundSubscription of iap's contract.