Skip to content

Latest commit

 

History

History
226 lines (177 loc) · 15.8 KB

README.md

File metadata and controls

226 lines (177 loc) · 15.8 KB

Refunds

(Refunds)

Overview

Collection of APIs handle refunds.

Available Operations

Create

Use this API to initiate refunds.

Example Usage

package main

import(
	"github.com/speakeasy-sdks/cashfree-go/pkg/models/shared"
	cashfreego "github.com/speakeasy-sdks/cashfree-go"
	"context"
	"github.com/speakeasy-sdks/cashfree-go/pkg/models/operations"
	"log"
)

func main() {
    s := cashfreego.New(
        cashfreego.WithSecurity(shared.Security{
            Option1: &shared.SecurityOption1{
                XClientID: "<YOUR_API_KEY_HERE>",
                XClientSecret: "<YOUR_API_KEY_HERE>",
            },
        }),
    )

    ctx := context.Background()
    res, err := s.Refunds.Create(ctx, operations.CreateRefundRequest{
        CreateRefundRequest: &shared.CreateRefundRequest{
            RefundAmount: 1,
            RefundID: "refund_00912",
            RefundNote: cashfreego.String("refund note for reference"),
            RefundSpeed: shared.CreateRefundRequestRefundSpeedStandard.ToPointer(),
        },
        OrderID: "<value>",
        XAPIVersion: "2022-09-01",
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.RefundsEntity != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.CreateRefundResponse, error

Error Object Status Code Content Type
sdkerrors.BadRequestError 400 application/json
sdkerrors.AuthenticationError 401 application/json
sdkerrors.APIError404 404 application/json
sdkerrors.APIError409 409 application/json
sdkerrors.IdempotencyError 422 application/json
sdkerrors.RateLimitError 429 application/json
sdkerrors.APIError 500 application/json
sdkerrors.APIError502 502 application/json
sdkerrors.SDKError 4xx-5xx /

Get

Use this API to fetch a specific refund processed on your Cashfree Account.

Example Usage

package main

import(
	"github.com/speakeasy-sdks/cashfree-go/pkg/models/shared"
	cashfreego "github.com/speakeasy-sdks/cashfree-go"
	"context"
	"log"
)

func main() {
    s := cashfreego.New(
        cashfreego.WithSecurity(shared.Security{
            Option1: &shared.SecurityOption1{
                XClientID: "<YOUR_API_KEY_HERE>",
                XClientSecret: "<YOUR_API_KEY_HERE>",
            },
        }),
    )


    var orderID string = "<value>"

    var refundID string = "<value>"

    var xAPIVersion string = "2022-09-01"

    var xRequestID *string = cashfreego.String("<value>")

    ctx := context.Background()
    res, err := s.Refunds.Get(ctx, orderID, refundID, xAPIVersion, xRequestID)
    if err != nil {
        log.Fatal(err)
    }
    if res.RefundsEntity != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
orderID string ✔️ Order or the invoice ID for which you want to view the refund details.
refundID string ✔️ Refund Id of the refund you want to fetch.
xAPIVersion string ✔️ API version to be used. Format is in YYYY-MM-DD
xRequestID *string Request id for the API call. Can be used to resolve tech issues. Communicate this in your tech related queries to cashfree
opts []operations.Option The options for this request.

Response

*operations.GetRefundResponse, error

Error Object Status Code Content Type
sdkerrors.BadRequestError 400 application/json
sdkerrors.AuthenticationError 401 application/json
sdkerrors.APIError404 404 application/json
sdkerrors.APIError409 409 application/json
sdkerrors.IdempotencyError 422 application/json
sdkerrors.RateLimitError 429 application/json
sdkerrors.APIError 500 application/json
sdkerrors.APIError502 502 application/json
sdkerrors.SDKError 4xx-5xx /

GetAllforOrder

Use this API to fetch all refunds processed against an order.

Example Usage

package main

import(
	"github.com/speakeasy-sdks/cashfree-go/pkg/models/shared"
	cashfreego "github.com/speakeasy-sdks/cashfree-go"
	"context"
	"log"
)

func main() {
    s := cashfreego.New(
        cashfreego.WithSecurity(shared.Security{
            Option1: &shared.SecurityOption1{
                XClientID: "<YOUR_API_KEY_HERE>",
                XClientSecret: "<YOUR_API_KEY_HERE>",
            },
        }),
    )


    var orderID string = "<value>"

    var xAPIVersion string = "2022-09-01"

    var xRequestID *string = cashfreego.String("<value>")

    ctx := context.Background()
    res, err := s.Refunds.GetAllforOrder(ctx, orderID, xAPIVersion, xRequestID)
    if err != nil {
        log.Fatal(err)
    }
    if res.Classes != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
orderID string ✔️ Order or the invoice ID for which you want to view the refund details.
xAPIVersion string ✔️ API version to be used. Format is in YYYY-MM-DD
xRequestID *string Request id for the API call. Can be used to resolve tech issues. Communicate this in your tech related queries to cashfree
opts []operations.Option The options for this request.

Response

*operations.GetAllRefundsForOrderResponse, error

Error Object Status Code Content Type
sdkerrors.BadRequestError 400 application/json
sdkerrors.AuthenticationError 401 application/json
sdkerrors.APIError404 404 application/json
sdkerrors.APIError409 409 application/json
sdkerrors.IdempotencyError 422 application/json
sdkerrors.RateLimitError 429 application/json
sdkerrors.APIError 500 application/json
sdkerrors.APIError502 502 application/json
sdkerrors.SDKError 4xx-5xx /