Skip to content

Latest commit

 

History

History
137 lines (101 loc) · 5.71 KB

README.md

File metadata and controls

137 lines (101 loc) · 5.71 KB

Refunds

(Refunds)

Overview

Available Operations

List

List products.

Scopes: refunds:read refunds:write

Example Usage

package main

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

func main() {
    ctx := context.Background()

    s := polargo.New(
        polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
    )

    res, err := s.Refunds.List(ctx, operations.RefundsListRequest{})
    if err != nil {
        log.Fatal(err)
    }
    if res.ListResourceRefund != nil {
        for {
            // handle items

            res, err = res.Next()

            if err != nil {
                // handle error
            }

            if res == nil {
                break
            }
        }
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.RefundsListRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.RefundsListResponse, error

Errors

Error Type Status Code Content Type
apierrors.HTTPValidationError 422 application/json
apierrors.APIError 4XX, 5XX */*

Create

Create a refund.

Scopes: refunds:write

Example Usage

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
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request components.RefundCreate ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.RefundsCreateResponse, error

Errors

Error Type Status Code Content Type
apierrors.RefundAmountTooHigh 400 application/json
apierrors.RefundedAlready 403 application/json
apierrors.HTTPValidationError 422 application/json
apierrors.APIError 4XX, 5XX */*