Skip to content

Latest commit

 

History

History
490 lines (386 loc) · 32.2 KB

File metadata and controls

490 lines (386 loc) · 32.2 KB

Profiles

Overview

Available Operations

Create

Create a profile to process payments on.

Profiles are required for payment processing. Normally they are created via the Mollie dashboard. Alternatively, you can use this endpoint to automate profile creation.

Example Usage: create-profile-201-1

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.Profiles.Create(ctx, components.ProfileRequest{
        Name: "My website name",
        Website: "https://example.com",
        Email: "test@mollie.com",
        Phone: "+31208202070",
        Description: client.Pointer("My website description"),
        CountriesOfActivity: []string{
            "NL",
            "GB",
        },
        BusinessCategory: client.Pointer("OTHER_MERCHANDISE"),
    }, client.Pointer("123e4567-e89b-12d3-a456-426"))
    if err != nil {
        log.Fatal(err)
    }
    if res.ProfileResponse != nil {
        // handle response
    }
}

Example Usage: create-profile-201-2

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.Profiles.Create(ctx, components.ProfileRequest{
        Name: "My website name",
        Website: "https://example.com",
        Email: "test@mollie.com",
        Phone: "+31208202070",
        Description: client.Pointer("My website description"),
        CountriesOfActivity: []string{
            "NL",
            "GB",
        },
        BusinessCategory: client.Pointer("OTHER_MERCHANDISE"),
    }, client.Pointer("123e4567-e89b-12d3-a456-426"))
    if err != nil {
        log.Fatal(err)
    }
    if res.ProfileResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description Example
ctx context.Context ✔️ The context to use for the request.
profileRequest components.ProfileRequest ✔️ N/A
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.CreateProfileResponse, error

Errors

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

List

Retrieve a list of all of your profiles.

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"
	"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.Profiles.List(ctx, client.Pointer("pfl_QkEhN94Ba"), client.Pointer[int64](50), 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 Example
ctx context.Context ✔️ The context to use for the request.
from *string Provide an ID to start the result set from the item with the given ID and onwards. This allows you to paginate the
result set.
limit *int64 The maximum number of items to return. Defaults to 50 items. 50
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.ListProfilesResponse, error

Errors

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

Get

Retrieve a single profile by its ID.

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

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

Parameters

Parameter Type Required Description Example
ctx context.Context ✔️ The context to use for the request.
profileID string ✔️ Provide the ID of the related profile. pfl_5B8cwPMGnU
testmode *bool You can enable test mode by setting the testmode query parameter to true.

Test entities cannot be retrieved when the endpoint is set to live mode, and vice versa.
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.GetProfileResponse, error

Errors

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

Update

Update an existing profile.

Profiles are required for payment processing. Normally they are created and updated via the Mollie dashboard. Alternatively, you can use this endpoint to automate profile management.

Example Usage: update-profile-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.Profiles.Update(ctx, "pfl_5B8cwPMGnU", operations.UpdateProfileRequestBody{
        Name: client.Pointer("My new website name"),
        Website: client.Pointer("https://example.com"),
        Email: client.Pointer("test@mollie.com"),
        Phone: client.Pointer("+31208202071"),
        Description: client.Pointer("My website description"),
        CountriesOfActivity: []string{
            "NL",
            "GB",
        },
        BusinessCategory: client.Pointer("OTHER_MERCHANDISE"),
    }, client.Pointer("123e4567-e89b-12d3-a456-426"))
    if err != nil {
        log.Fatal(err)
    }
    if res.ProfileResponse != nil {
        // handle response
    }
}

Example Usage: update-profile-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.Profiles.Update(ctx, "pfl_5B8cwPMGnU", operations.UpdateProfileRequestBody{
        Name: client.Pointer("My new website name"),
        Website: client.Pointer("https://example.com"),
        Email: client.Pointer("test@mollie.com"),
        Phone: client.Pointer("+31208202071"),
        Description: client.Pointer("My website description"),
        CountriesOfActivity: []string{
            "NL",
            "GB",
        },
        BusinessCategory: client.Pointer("OTHER_MERCHANDISE"),
    }, client.Pointer("123e4567-e89b-12d3-a456-426"))
    if err != nil {
        log.Fatal(err)
    }
    if res.ProfileResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description Example
ctx context.Context ✔️ The context to use for the request.
profileID string ✔️ Provide the ID of the related profile. pfl_5B8cwPMGnU
requestBody operations.UpdateProfileRequestBody ✔️ N/A
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.UpdateProfileResponse, error

Errors

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

Delete

Delete a profile. A deleted profile and its related credentials can no longer be used for accepting payments.

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.Profiles.Delete(ctx, "pfl_5B8cwPMGnU", client.Pointer("123e4567-e89b-12d3-a456-426"))
    if err != nil {
        log.Fatal(err)
    }
    if res != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description Example
ctx context.Context ✔️ The context to use for the request.
profileID string ✔️ Provide the ID of the related profile. pfl_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.DeleteProfileResponse, error

Errors

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

GetCurrent

Retrieve the currently authenticated profile. A convenient alias of the Get profile endpoint.

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

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

    res, err := s.Profiles.GetCurrent(ctx, client.Pointer("123e4567-e89b-12d3-a456-426"))
    if err != nil {
        log.Fatal(err)
    }
    if res.ProfileResponse != 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.GetCurrentProfileResponse, error

Errors

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