Skip to main content
POST
/
v1
/
refunds
Python (SDK)
import polar_sdk
from polar_sdk import Polar


with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    res = polar.refunds.create(request={
        "order_id": "<value>",
        "reason": polar_sdk.RefundReason.SERVICE_DISRUPTION,
        "amount": 90,
    })

    assert res is not None

    # Handle response
    print(res)
{
  "created_at": "2023-11-07T05:31:56Z",
  "modified_at": "2023-11-07T05:31:56Z",
  "id": "<string>",
  "metadata": {},
  "status": "pending",
  "reason": "duplicate",
  "amount": 123,
  "tax_amount": 123,
  "currency": "<string>",
  "organization_id": "<string>",
  "order_id": "<string>",
  "subscription_id": "<string>",
  "customer_id": "<string>",
  "revoke_benefits": true,
  "dispute": {
    "created_at": "2023-11-07T05:31:56Z",
    "modified_at": "2023-11-07T05:31:56Z",
    "id": "<string>",
    "status": "prevented",
    "resolved": true,
    "closed": true,
    "amount": 123,
    "tax_amount": 123,
    "currency": "<string>",
    "order_id": "<string>",
    "payment_id": "<string>"
  }
}

Authorizations

Authorization
string
header
required

You can generate an Organization Access Token from your organization's settings.

Body

application/json
order_id
string<uuid4>
required
reason
enum<string>
required
Available options:
duplicate,
fraudulent,
customer_request,
service_disruption,
satisfaction_guarantee,
dispute_prevention,
other
amount
integer
required

Amount to refund in cents. Minimum is 1.

metadata
Metadata · object

Key-value object allowing you to store additional information.

The key must be a string with a maximum length of 40 characters. The value must be either:

  • A string with a maximum length of 500 characters
  • An integer
  • A floating-point number
  • A boolean

You can store up to 50 key-value pairs.

comment
string | null

An internal comment about the refund.

revoke_benefits
boolean
default:false

Should this refund trigger the associated customer benefits to be revoked?

Note: Only allowed in case the order is a one-time purchase. Subscriptions automatically revoke customer benefits once the subscription itself is revoked, i.e fully canceled.

Response

Successful Response

created_at
string<date-time>
required

Creation timestamp of the object.

modified_at
string<date-time> | null
required

Last modification timestamp of the object.

id
string<uuid4>
required

The ID of the object.

metadata
object
required
status
enum<string>
required
Available options:
pending,
succeeded,
failed,
canceled
reason
enum<string>
required
Available options:
duplicate,
fraudulent,
customer_request,
service_disruption,
satisfaction_guarantee,
dispute_prevention,
other
amount
integer
required
tax_amount
integer
required
currency
string
required
organization_id
string<uuid4>
required
order_id
string<uuid4>
required
subscription_id
string<uuid4> | null
required
customer_id
string<uuid4>
required
revoke_benefits
boolean
required
dispute
RefundDispute · object
required

Dispute associated with a refund, in case we prevented a dispute by issuing a refund.