Skip to content

Latest commit

 

History

History
478 lines (388 loc) · 16.9 KB

File metadata and controls

478 lines (388 loc) · 16.9 KB

Chargebacks

Overview

Available Operations

  • List - List payment chargebacks
  • Get - Get payment chargeback
  • All - List all chargebacks

List

Retrieve the chargebacks initiated for a specific payment.

The results are paginated.

Example Usage: list-chargeback-200-1

package main

import(
	"context"
	"os"
	"github.com/mollie/mollie-api-golang/models/components"
	client "github.com/mollie/mollie-api-golang"
	"github.com/mollie/mollie-api-golang/models/operations"
	"log"
)

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

    s := client.New(
        client.WithTestmode(false),
        client.WithSecurity(components.Security{
            APIKey: client.Pointer(os.Getenv("CLIENT_API_KEY")),
        }),
    )

    res, err := s.Chargebacks.List(ctx, operations.ListChargebacksRequest{
        PaymentID: "tr_5B8cwPMGnU",
        From: client.Pointer("chb_xFzwUN4ci8HAmSGUACS4J"),
        Limit: client.Pointer[int64](50),
        Embed: client.Pointer("payment"),
        IdempotencyKey: client.Pointer("123e4567-e89b-12d3-a456-426"),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.Object != nil {
        for {
            // handle items

            res, err = res.Next()

            if err != nil {
                // handle error
            }

            if res == nil {
                break
            }
        }
    }
}

Example Usage: list-chargeback-200-2

package main

import(
	"context"
	"os"
	"github.com/mollie/mollie-api-golang/models/components"
	client "github.com/mollie/mollie-api-golang"
	"github.com/mollie/mollie-api-golang/models/operations"
	"log"
)

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

    s := client.New(
        client.WithTestmode(false),
        client.WithSecurity(components.Security{
            APIKey: client.Pointer(os.Getenv("CLIENT_API_KEY")),
        }),
    )

    res, err := s.Chargebacks.List(ctx, operations.ListChargebacksRequest{
        PaymentID: "tr_5B8cwPMGnU",
        From: client.Pointer("chb_xFzwUN4ci8HAmSGUACS4J"),
        Limit: client.Pointer[int64](50),
        Embed: client.Pointer("payment"),
        IdempotencyKey: client.Pointer("123e4567-e89b-12d3-a456-426"),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.Object != nil {
        for {
            // handle items

            res, err = res.Next()

            if err != nil {
                // handle error
            }

            if res == nil {
                break
            }
        }
    }
}

Example Usage: list-chargeback-200-3

package main

import(
	"context"
	"os"
	"github.com/mollie/mollie-api-golang/models/components"
	client "github.com/mollie/mollie-api-golang"
	"github.com/mollie/mollie-api-golang/models/operations"
	"log"
)

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

    s := client.New(
        client.WithTestmode(false),
        client.WithSecurity(components.Security{
            APIKey: client.Pointer(os.Getenv("CLIENT_API_KEY")),
        }),
    )

    res, err := s.Chargebacks.List(ctx, operations.ListChargebacksRequest{
        PaymentID: "tr_5B8cwPMGnU",
        From: client.Pointer("chb_xFzwUN4ci8HAmSGUACS4J"),
        Limit: client.Pointer[int64](50),
        Embed: client.Pointer("payment"),
        IdempotencyKey: client.Pointer("123e4567-e89b-12d3-a456-426"),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.Object != 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.ListChargebacksRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.ListChargebacksResponse, error

Errors

Error Type Status Code Content Type
apierrors.ErrorResponse 400, 404 application/hal+json
apierrors.APIError 4XX, 5XX */*

Get

Retrieve a single payment chargeback by its ID and the ID of its parent payment.

Example Usage: get-chargeback-200-1

package main

import(
	"context"
	"os"
	"github.com/mollie/mollie-api-golang/models/components"
	client "github.com/mollie/mollie-api-golang"
	"github.com/mollie/mollie-api-golang/models/operations"
	"log"
)

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

    s := client.New(
        client.WithTestmode(false),
        client.WithSecurity(components.Security{
            APIKey: client.Pointer(os.Getenv("CLIENT_API_KEY")),
        }),
    )

    res, err := s.Chargebacks.Get(ctx, operations.GetChargebackRequest{
        PaymentID: "tr_5B8cwPMGnU",
        ChargebackID: "chb_xFzwUN4ci8HAmSGUACS4J",
        Embed: client.Pointer("payment"),
        IdempotencyKey: client.Pointer("123e4567-e89b-12d3-a456-426"),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.EntityChargeback != nil {
        // handle response
    }
}

Example Usage: get-chargeback-200-2

package main

import(
	"context"
	"os"
	"github.com/mollie/mollie-api-golang/models/components"
	client "github.com/mollie/mollie-api-golang"
	"github.com/mollie/mollie-api-golang/models/operations"
	"log"
)

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

    s := client.New(
        client.WithTestmode(false),
        client.WithSecurity(components.Security{
            APIKey: client.Pointer(os.Getenv("CLIENT_API_KEY")),
        }),
    )

    res, err := s.Chargebacks.Get(ctx, operations.GetChargebackRequest{
        PaymentID: "tr_5B8cwPMGnU",
        ChargebackID: "chb_xFzwUN4ci8HAmSGUACS4J",
        Embed: client.Pointer("payment"),
        IdempotencyKey: client.Pointer("123e4567-e89b-12d3-a456-426"),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.EntityChargeback != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.GetChargebackResponse, error

Errors

Error Type Status Code Content Type
apierrors.ErrorResponse 404 application/hal+json
apierrors.APIError 4XX, 5XX */*

All

Retrieve all chargebacks initiated for all your payments.

The results are paginated.

Example Usage: list-all-chargebacks-200-1

package main

import(
	"context"
	"os"
	"github.com/mollie/mollie-api-golang/models/components"
	client "github.com/mollie/mollie-api-golang"
	"github.com/mollie/mollie-api-golang/models/operations"
	"log"
)

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

    s := client.New(
        client.WithProfileID("pfl_5B8cwPMGnU"),
        client.WithTestmode(false),
        client.WithSecurity(components.Security{
            APIKey: client.Pointer(os.Getenv("CLIENT_API_KEY")),
        }),
    )

    res, err := s.Chargebacks.All(ctx, operations.ListAllChargebacksRequest{
        From: client.Pointer("chb_xFzwUN4ci8HAmSGUACS4J"),
        Limit: client.Pointer[int64](50),
        Embed: client.Pointer("payment"),
        Sort: components.SortingDesc.ToPointer(),
        IdempotencyKey: client.Pointer("123e4567-e89b-12d3-a456-426"),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.Object != nil {
        for {
            // handle items

            res, err = res.Next()

            if err != nil {
                // handle error
            }

            if res == nil {
                break
            }
        }
    }
}

Example Usage: list-all-chargebacks-200-2

package main

import(
	"context"
	"os"
	"github.com/mollie/mollie-api-golang/models/components"
	client "github.com/mollie/mollie-api-golang"
	"github.com/mollie/mollie-api-golang/models/operations"
	"log"
)

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

    s := client.New(
        client.WithProfileID("pfl_5B8cwPMGnU"),
        client.WithTestmode(false),
        client.WithSecurity(components.Security{
            APIKey: client.Pointer(os.Getenv("CLIENT_API_KEY")),
        }),
    )

    res, err := s.Chargebacks.All(ctx, operations.ListAllChargebacksRequest{
        From: client.Pointer("chb_xFzwUN4ci8HAmSGUACS4J"),
        Limit: client.Pointer[int64](50),
        Embed: client.Pointer("payment"),
        Sort: components.SortingDesc.ToPointer(),
        IdempotencyKey: client.Pointer("123e4567-e89b-12d3-a456-426"),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.Object != nil {
        for {
            // handle items

            res, err = res.Next()

            if err != nil {
                // handle error
            }

            if res == nil {
                break
            }
        }
    }
}

Example Usage: list-all-chargebacks-200-3

package main

import(
	"context"
	"os"
	"github.com/mollie/mollie-api-golang/models/components"
	client "github.com/mollie/mollie-api-golang"
	"github.com/mollie/mollie-api-golang/models/operations"
	"log"
)

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

    s := client.New(
        client.WithProfileID("pfl_5B8cwPMGnU"),
        client.WithTestmode(false),
        client.WithSecurity(components.Security{
            APIKey: client.Pointer(os.Getenv("CLIENT_API_KEY")),
        }),
    )

    res, err := s.Chargebacks.All(ctx, operations.ListAllChargebacksRequest{
        From: client.Pointer("chb_xFzwUN4ci8HAmSGUACS4J"),
        Limit: client.Pointer[int64](50),
        Embed: client.Pointer("payment"),
        Sort: components.SortingDesc.ToPointer(),
        IdempotencyKey: client.Pointer("123e4567-e89b-12d3-a456-426"),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.Object != 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.ListAllChargebacksRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.ListAllChargebacksResponse, error

Errors

Error Type Status Code Content Type
apierrors.ErrorResponse 400, 404 application/hal+json
apierrors.APIError 4XX, 5XX */*