VoidhashDocs
DevelopersHelp centerGuidesAPI reference
Dashboard
Essentials
API overview
Authentication
Event capture
Push device API
Webhooks
Webhook delivery
Webhook events
Projects & keys
Projects
API keys
Audit log
Customers & access
Persons
Products
Perks
Sandbox
Paywalls
Paywalls
Paywall locations
Components
Component registry
Assets
Experiments & flags
Experiments
Feature flags
Analytics & events
Analytics
Analytics alerts
Events
Ingest policy
VoidQL
Tracking domains
Ads
Ads
Ad accounts
Meta measurement
Payments & stores
Payment providers
Payment provider products
Purchase history imports
Payment sources
Webhooks & notifications
Webhooks
Push notifications
Push configurations
Automations
Organization & team
Organizations
Members
Invitations
Billing
Your account
Profile
Session
Notices
Connected apps
Terms of Service
Developer tools
Schema
SDK
Record a transaction
Refund a transaction
Record a subscription
Cancel a subscription

Refund a transaction

Asks the source's endpoint to refund a recorded charge, for amount or all that is left of it, then records the refund it answers with and returns it, under the source's id for the refund.

Only a payment source records purchases.

Guide: Payment sources

POST
/api/v1/projects/{projectId}/payment-providers/{paymentProviderId}/transactions/{externalId}/refund

Authorization

AuthorizationBearer <token>

A project secret key: vh_sk_... for production, vh_sk_test_... for test. Keep it on your servers.

In: header

Path parameters

projectId*string

The project's id, proj_.... A secret key works only in the project it belongs to.

paymentProviderId*string

The id of the project's payment provider connection, pp_conf_....

externalId*string

The payment source's own id for the transaction or subscription; to request a refund, the charge's.

Request body

application/json

TypeScript definitions

Use the request body type in TypeScript.

What to refund of a payment source's charge.

amount?|

The amount to refund, in the charge's minor units; everything left of the charge when left out.

reason?|

Why the charge is refunded, passed to the source's endpoint.

Examples

curl -X POST "https://api.voidhash.com/api/v1/projects/proj_tz4a98xxat96iws9zmbrgj3a/payment-providers/pp_conf_m2c8v5n1x7z4q9w3e6r0t8y2/transactions/txn_20260314_0042/refund" \  -H "Authorization: Bearer vh_sk_..." \  -H "Content-Type: application/json" \  -d '{    "amount": 499,    "reason": "Charged twice"  }'
{  "id": "rfd_20260320_0007",  "paymentProviderId": "pp_conf_m2c8v5n1x7z4q9w3e6r0t8y2",  "type": "refund",  "status": "applied",  "pendingReason": null,  "purchaseId": null,  "bookedAmount": 499}

{  "error": {    "type": "invalid_request",    "code": "invalid_transaction",    "message": "Product pro_monthly is a subscription; its charges name the subscriptionId and period they pay for"  }}

{  "error": {    "type": "unauthenticated",    "code": "invalid_api_key",    "message": "This secret key is not valid."  }}
{  "error": {    "type": "permission_denied",    "code": "permission_denied",    "message": "Insufficient permissions."  }}

{  "error": {    "type": "not_found",    "code": "transaction_not_found",    "message": "This payment source has no recorded charge with this id.",    "param": "externalId"  }}

{  "error": {    "type": "conflict",    "code": "payment_source_disabled",    "message": "This payment source is disabled; enable it to record purchases."  }}

{  "error": {    "type": "internal",    "code": "internal_error",    "message": "Something went wrong on our side. Try again, and contact support with the Request-Id header if it keeps failing."  }}

{  "error": {    "type": "unavailable",    "code": "payment_source_endpoint_unavailable",    "message": "The endpoint answered 503"  }}

Response body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

Errors

StatustypecodeWhen
400invalid_requestinvalid_transactionWhen the refund answered cannot be recorded, which records nothing.
400invalid_requestpayment_source_requiredFor a store.
404not_foundtransaction_not_foundWhen the charge is not recorded.
404not_foundpayment_provider_not_foundFor an unknown provider.
409conflictpayment_source_disabledFor a disabled source.
409conflictpayment_source_endpoint_not_configuredWhen the source's endpoint is not configured, does not support the action or refuses it.
409conflictpayment_source_endpoint_unsupportedWhen the source's endpoint is not configured, does not support the action or refuses it.
409conflictpayment_source_endpoint_rejectedWhen the source's endpoint is not configured, does not support the action or refuses it.
503unavailablepayment_source_endpoint_unavailableWhen it does not answer or answers outside the protocol; the message says why.
503unavailablepayment_source_endpoint_invalid_responseWhen it does not answer or answers outside the protocol; the message says why.

It can also fail with the errors every operation shares, such as unauthenticated; see Errors.

More in Payment sources

  • Record a transaction PUT
  • Record a subscription PUT
  • Cancel a subscription POST

Something wrong or missing on this page? Tell us by email or on Discord.

PreviousRecord a transactionNextRecord a subscription

On this page

AuthorizationPath parametersRequest bodyExamplesResponse bodyErrorsMore in Payment sources