Skip to content

Latest commit

 

History

History
195 lines (150 loc) · 23.1 KB

File metadata and controls

195 lines (150 loc) · 23.1 KB

DelayedRouting

Overview

Available Operations

  • Create - Create a delayed route
  • List - List payment routes
  • Get - Get a delayed route

Create

Create a route for a specific payment. The routed amount is credited to the account of your customer.

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.DelayedRouting.Create(ctx, "tr_5B8cwPMGnU", client.Pointer("123e4567-e89b-12d3-a456-426"), &components.RouteCreateRequest{
        Amount: components.Amount{
            Currency: "EUR",
            Value: "10.00",
        },
        Destination: components.RouteCreateRequestDestination{
            Type: components.RouteDestinationTypeOrganization,
            OrganizationID: "org_1234567",
        },
        Description: client.Pointer("Payment for Order #12345"),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.RouteCreateResponse != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.PaymentCreateRouteResponse, error

Errors

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

List

Retrieve a list of all routes created for a specific payment.

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

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

Parameters

Parameter Type Required Description Example
ctx context.Context ✔️ The context to use for the request.
paymentID string ✔️ Provide the ID of the related payment. tr_5B8cwPMGnU
testmode *bool Most API credentials are specifically created for either live mode or test mode. In those cases the testmode query
parameter must not be sent. For organization-level credentials such as OAuth access tokens, 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.PaymentListRoutesResponse, error

Errors

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

Get

Retrieve a single route created for a specific payment.

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

Parameters

Parameter Type Required Description Example
ctx context.Context ✔️ The context to use for the request.
paymentID string ✔️ Provide the ID of the related payment. tr_5B8cwPMGnU
routeID string ✔️ Provide the ID of the route. crt_dyARQ3JzCgtPDhU2Pbq3J
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.PaymentGetRouteResponse, error

Errors

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