(Refunds)
Collection of APIs handle refunds.
- Create - Create Refund
- Get - Get Refund
- GetAllforOrder - Get All Refunds for an Order
Use this API to initiate refunds.
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
}
}
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. |
*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 | / |
Use this API to fetch a specific refund processed on your Cashfree Account.
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
}
}
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. |
*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 | / |
Use this API to fetch all refunds processed against an order.
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
}
}
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. |
*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 | / |