Skip to content

Latest commit

 

History

History
1008 lines (800 loc) · 41.9 KB

File metadata and controls

1008 lines (800 loc) · 41.9 KB

Settlements

Overview

Available Operations

List

Retrieve a list of all your settlements.

The results are paginated.

Example Usage

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.WithSecurity(components.Security{
            OrganizationAccessToken: client.Pointer(os.Getenv("CLIENT_ORGANIZATION_ACCESS_TOKEN")),
        }),
    )

    res, err := s.Settlements.List(ctx, operations.ListSettlementsRequest{
        From: client.Pointer("stl_jDk30akdN"),
        Limit: client.Pointer[int64](50),
        BalanceID: client.Pointer("bal_gVMhHKqSSRYJyPsuoPNFH"),
        Year: client.Pointer("2025"),
        Month: client.Pointer("1"),
        Currencies: components.CurrenciesEur.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.ListSettlementsRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.ListSettlementsResponse, error

Errors

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

Get

Retrieve a single settlement by its ID.

To lookup settlements by their bank reference, replace the ID in the URL by a reference. For example: 1234567.2404.03.

A settlement represents a transfer of your balance funds to your external bank account.

Settlements will typically include a report that details what balance transactions have taken place between this settlement and the previous one.

For more accurate bookkeeping, refer to the balance report endpoint or the balance transactions endpoint.

Example Usage

package main

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

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

    s := client.New(
        client.WithSecurity(components.Security{
            OrganizationAccessToken: client.Pointer(os.Getenv("CLIENT_ORGANIZATION_ACCESS_TOKEN")),
        }),
    )

    res, err := s.Settlements.Get(ctx, "stl_5B8cwPMGnU", client.Pointer("123e4567-e89b-12d3-a456-426"))
    if err != nil {
        log.Fatal(err)
    }
    if res.EntitySettlement != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description Example
ctx context.Context ✔️ The context to use for the request.
settlementID string ✔️ Provide the ID of the related settlement. stl_5B8cwPMGnU
idempotencyKey *string A unique key to ensure idempotent requests. This key should be a UUID v4 string. 123e4567-e89b-12d3-a456-426
opts []operations.Option The options for this request.

Response

*operations.GetSettlementResponse, error

Errors

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

GetOpen

Retrieve the details of the open balance of the organization. This will return a settlement object representing your organization's balance.

For a complete reference of the settlement object, refer to the Get settlement endpoint documentation.

For more accurate bookkeeping, refer to the balance report endpoint or the balance transactions endpoint.

Example Usage

package main

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

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

    s := client.New(
        client.WithSecurity(components.Security{
            OrganizationAccessToken: client.Pointer(os.Getenv("CLIENT_ORGANIZATION_ACCESS_TOKEN")),
        }),
    )

    res, err := s.Settlements.GetOpen(ctx, client.Pointer("123e4567-e89b-12d3-a456-426"))
    if err != nil {
        log.Fatal(err)
    }
    if res.EntitySettlement != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description Example
ctx context.Context ✔️ The context to use for the request.
idempotencyKey *string A unique key to ensure idempotent requests. This key should be a UUID v4 string. 123e4567-e89b-12d3-a456-426
opts []operations.Option The options for this request.

Response

*operations.GetOpenSettlementResponse, error

Errors

Error Type Status Code Content Type
apierrors.APIError 4XX, 5XX */*

GetNext

Retrieve the details of the current settlement, that has not yet been paid out.

For a complete reference of the settlement object, refer to the Get settlement endpoint documentation.

For more accurate bookkeeping, refer to the balance report endpoint or the balance transactions endpoint.

Example Usage

package main

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

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

    s := client.New(
        client.WithSecurity(components.Security{
            OrganizationAccessToken: client.Pointer(os.Getenv("CLIENT_ORGANIZATION_ACCESS_TOKEN")),
        }),
    )

    res, err := s.Settlements.GetNext(ctx, client.Pointer("123e4567-e89b-12d3-a456-426"))
    if err != nil {
        log.Fatal(err)
    }
    if res.EntitySettlement != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description Example
ctx context.Context ✔️ The context to use for the request.
idempotencyKey *string A unique key to ensure idempotent requests. This key should be a UUID v4 string. 123e4567-e89b-12d3-a456-426
opts []operations.Option The options for this request.

Response

*operations.GetNextSettlementResponse, error

Errors

Error Type Status Code Content Type
apierrors.APIError 4XX, 5XX */*

ListPayments

Retrieve all payments included in the given settlement.

The response is in the same format as the response of the List payments endpoint.

For capture-based payment methods such as Klarna, the payments are not listed here. Refer to the List captures endpoint endpoint instead.

Example Usage: list-payments-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.WithSecurity(components.Security{
            OrganizationAccessToken: client.Pointer(os.Getenv("CLIENT_ORGANIZATION_ACCESS_TOKEN")),
        }),
    )

    res, err := s.Settlements.ListPayments(ctx, operations.ListSettlementPaymentsRequest{
        SettlementID: "stl_5B8cwPMGnU",
        From: client.Pointer("tr_5B8cwPMGnU"),
        Limit: client.Pointer[int64](50),
        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-payments-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.WithSecurity(components.Security{
            OrganizationAccessToken: client.Pointer(os.Getenv("CLIENT_ORGANIZATION_ACCESS_TOKEN")),
        }),
    )

    res, err := s.Settlements.ListPayments(ctx, operations.ListSettlementPaymentsRequest{
        SettlementID: "stl_5B8cwPMGnU",
        From: client.Pointer("tr_5B8cwPMGnU"),
        Limit: client.Pointer[int64](50),
        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-payments-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.WithSecurity(components.Security{
            OrganizationAccessToken: client.Pointer(os.Getenv("CLIENT_ORGANIZATION_ACCESS_TOKEN")),
        }),
    )

    res, err := s.Settlements.ListPayments(ctx, operations.ListSettlementPaymentsRequest{
        SettlementID: "stl_5B8cwPMGnU",
        From: client.Pointer("tr_5B8cwPMGnU"),
        Limit: client.Pointer[int64](50),
        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-settlement-payments-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.WithSecurity(components.Security{
            OrganizationAccessToken: client.Pointer(os.Getenv("CLIENT_ORGANIZATION_ACCESS_TOKEN")),
        }),
    )

    res, err := s.Settlements.ListPayments(ctx, operations.ListSettlementPaymentsRequest{
        SettlementID: "stl_5B8cwPMGnU",
        From: client.Pointer("tr_5B8cwPMGnU"),
        Limit: client.Pointer[int64](50),
        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.ListSettlementPaymentsRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.ListSettlementPaymentsResponse, error

Errors

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

ListCaptures

Retrieve all captures included in the given settlement.

The response is in the same format as the response of the List captures endpoint.

Example Usage: list-captures-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.WithSecurity(components.Security{
            OrganizationAccessToken: client.Pointer(os.Getenv("CLIENT_ORGANIZATION_ACCESS_TOKEN")),
        }),
    )

    res, err := s.Settlements.ListCaptures(ctx, operations.ListSettlementCapturesRequest{
        SettlementID: "stl_5B8cwPMGnU",
        From: client.Pointer("cpt_vytxeTZskVKR7C7WgdSP3d"),
        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-captures-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.WithSecurity(components.Security{
            OrganizationAccessToken: client.Pointer(os.Getenv("CLIENT_ORGANIZATION_ACCESS_TOKEN")),
        }),
    )

    res, err := s.Settlements.ListCaptures(ctx, operations.ListSettlementCapturesRequest{
        SettlementID: "stl_5B8cwPMGnU",
        From: client.Pointer("cpt_vytxeTZskVKR7C7WgdSP3d"),
        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-settlement-captures-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.WithSecurity(components.Security{
            OrganizationAccessToken: client.Pointer(os.Getenv("CLIENT_ORGANIZATION_ACCESS_TOKEN")),
        }),
    )

    res, err := s.Settlements.ListCaptures(ctx, operations.ListSettlementCapturesRequest{
        SettlementID: "stl_5B8cwPMGnU",
        From: client.Pointer("cpt_vytxeTZskVKR7C7WgdSP3d"),
        Limit: client.Pointer[int64](50),
        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.ListSettlementCapturesRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.ListSettlementCapturesResponse, error

Errors

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

ListRefunds

Retrieve all refunds 'deducted' from the given settlement.

The response is in the same format as the response of the List refunds endpoint.

Example Usage: list-refunds-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.WithSecurity(components.Security{
            OrganizationAccessToken: client.Pointer(os.Getenv("CLIENT_ORGANIZATION_ACCESS_TOKEN")),
        }),
    )

    res, err := s.Settlements.ListRefunds(ctx, operations.ListSettlementRefundsRequest{
        SettlementID: "stl_5B8cwPMGnU",
        From: client.Pointer("re_5B8cwPMGnU"),
        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-settlement-refunds-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.WithSecurity(components.Security{
            OrganizationAccessToken: client.Pointer(os.Getenv("CLIENT_ORGANIZATION_ACCESS_TOKEN")),
        }),
    )

    res, err := s.Settlements.ListRefunds(ctx, operations.ListSettlementRefundsRequest{
        SettlementID: "stl_5B8cwPMGnU",
        From: client.Pointer("re_5B8cwPMGnU"),
        Limit: client.Pointer[int64](50),
        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.ListSettlementRefundsRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.ListSettlementRefundsResponse, error

Errors

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

ListChargebacks

Retrieve all chargebacks 'deducted' from the given settlement.

The response is in the same format as the response of the List chargebacks endpoint.

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{
            OrganizationAccessToken: client.Pointer(os.Getenv("CLIENT_ORGANIZATION_ACCESS_TOKEN")),
        }),
    )

    res, err := s.Settlements.ListChargebacks(ctx, operations.ListSettlementChargebacksRequest{
        SettlementID: "stl_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{
            OrganizationAccessToken: client.Pointer(os.Getenv("CLIENT_ORGANIZATION_ACCESS_TOKEN")),
        }),
    )

    res, err := s.Settlements.ListChargebacks(ctx, operations.ListSettlementChargebacksRequest{
        SettlementID: "stl_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{
            OrganizationAccessToken: client.Pointer(os.Getenv("CLIENT_ORGANIZATION_ACCESS_TOKEN")),
        }),
    )

    res, err := s.Settlements.ListChargebacks(ctx, operations.ListSettlementChargebacksRequest{
        SettlementID: "stl_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.ListSettlementChargebacksRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.ListSettlementChargebacksResponse, error

Errors

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