POST
/
v1
/
refunds
package main

import(
	"context"
	"os"
	polargo "github.com/polarsource/polar-go"
	"github.com/polarsource/polar-go/models/components"
	"log"
)

func main() {
    ctx := context.Background()
    
    s := polargo.New(
        polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
    )

    res, err := s.Refunds.Create(ctx, components.RefundCreate{
        OrderID: "<value>",
        Reason: components.RefundReasonCustomerRequest,
        Amount: 638424,
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.Refund != nil {
        // handle response
    }
}
{
  "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
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
order_id
string
required
reason
enum<string>
required
Available options:
duplicate,
fraudulent,
customer_request,
service_disruption,
satisfaction_guarantee,
other
amount
integer
required
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 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

200
application/json
Successful Response
created_at
string
required

Creation timestamp of the object.

modified_at
string | null
required

Last modification timestamp of the object.

id
string
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,
other
amount
integer
required
tax_amount
integer
required
currency
string
required
organization_id
string
required
order_id
string
required
subscription_id
string | null
required
customer_id
string
required
revoke_benefits
boolean
required

Was this page helpful?