From 0ad3445787445f710385f7b44f7559139f5cfaef Mon Sep 17 00:00:00 2001 From: Victor Hugo Avelar Ossorio Date: Mon, 6 Feb 2023 15:26:21 +0100 Subject: [PATCH 01/29] chore(housekeeping): Support go 1.20 --- .devcontainer/devcontainer.json | 9 ++++----- .github/ISSUE_TEMPLATE/bug_report.md | 4 ++-- .github/ISSUE_TEMPLATE/config.yml | 6 ++++++ .github/ISSUE_TEMPLATE/feature_request.md | 2 +- .github/workflows/golangci-lint.yml | 2 +- .github/workflows/main.yml | 2 +- .github/workflows/release.yml | 2 +- SECURITY.md | 1 + 8 files changed, 17 insertions(+), 11 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 3dd2ce1..cd5bbea 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -6,6 +6,9 @@ "GO_VERSION": "1-bullseye" } }, + "mounts": [ + "source=${localEnv:HOME}/.zshrc,target=/root/.zshrc,type=bind,consistency=cached" + ], "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", @@ -88,9 +91,5 @@ "modules": "go mod download" }, "remoteUser": "root", - "containerUser": "root", - "containerEnv": { - "MOLLIE_API_TOKEN": "${localEnv:MOLLIE_API_TOKEN}", - "MOLLIE_ORG_TOKEN": "${localEnv:MOLLIE_ORG_TOKEN}" - } + "containerUser": "root" } diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 3205926..a422cbd 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -2,8 +2,8 @@ name: Bug report about: Create a report to help us improve title: '' -labels: '' -assignees: '' +labels: ['bug', 'help-wanted'] +assignees: 'VictorAvelar' --- diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 81c433e..85cdd8d 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -3,3 +3,9 @@ contact_links: - name: Victor H. Avelar url: https://victoravelar.com about: Maintainer + - name: Mollie's API Documentation + url: https://docs.mollie.com/index + about: Official API Documentation + - name: Mollie's Changelog + url: https://docs.mollie.com/changelog/v2/changelog + about: Changes announced in the API diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index bbcbbe7..abd8476 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -2,7 +2,7 @@ name: Feature request about: Suggest an idea for this project title: '' -labels: '' +labels: ['enhancement'] assignees: '' --- diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 5bd4dcb..d96e5d8 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -37,7 +37,7 @@ jobs: name: golangci-lint - uses: actions/setup-go@v3 with: - go-version: 1.19.X + go-version: 1.20.X - uses: golangci/golangci-lint-action@v3.4.0 with: version: latest diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 80383d5..ba23c94 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -31,7 +31,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go: [1.17.x, 1.18.x, 1.19.X] + go: [1.17.x, 1.18.x, 1.19.X, 1.20.x] name: Go ${{ matrix.go }} check steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a89ea83..e08ec1c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,7 +16,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.19.x + go-version: 1.20.x - name: Run GoReleaser uses: goreleaser/goreleaser-action@v4 with: diff --git a/SECURITY.md b/SECURITY.md index a2755e6..066bdc2 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -14,6 +14,7 @@ declared inside the `.github/workflows/main.yml` file. | 1.17.x | :white_check_mark: | | 1.18.x | :white_check_mark: | | 1.19.x | :white_check_mark: | +| 1.20.x | :white_check_mark: | | master | :x: | ## Reporting a Vulnerability From df634abc25807cda347ed4b4919686f3160bcf67 Mon Sep 17 00:00:00 2001 From: Victor Hugo Avelar Ossorio Date: Wed, 8 Feb 2023 16:28:26 +0000 Subject: [PATCH 02/29] chore(ci): handle ci-lint bugs preset --- mollie/connect/oauth2.go | 2 +- mollie/gift_cards.go | 1 + mollie/mollie.go | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/mollie/connect/oauth2.go b/mollie/connect/oauth2.go index 6a99fbe..184a064 100644 --- a/mollie/connect/oauth2.go +++ b/mollie/connect/oauth2.go @@ -7,7 +7,7 @@ import ( // Mollie's Oauth2 server URLs. const ( authURL = "https://www.mollie.com/oauth2/authorize" - tokensURL = "https://api.mollie.com/oauth2/tokens" + tokensURL = "https://api.mollie.com/oauth2/tokens" //#nosec G101 -- This is the url used to retrieve oauth2 tokens. ) // OauthEndpoint is Mollies's OAuth 2.0 endpoint. diff --git a/mollie/gift_cards.go b/mollie/gift_cards.go index 00059ea..700999a 100644 --- a/mollie/gift_cards.go +++ b/mollie/gift_cards.go @@ -5,6 +5,7 @@ package mollie type GiftCardIssuer string // Supported gift card issuers. +// #nosec G101 -- This are the brands issuing gift cards. const ( BloemenCadeuKaart GiftCardIssuer = "bloemencadeaukaart" BloemPlantGiftCard GiftCardIssuer = "bloemplantgiftcard" diff --git a/mollie/mollie.go b/mollie/mollie.go index 4998bd2..8d1e461 100644 --- a/mollie/mollie.go +++ b/mollie/mollie.go @@ -162,6 +162,7 @@ func (c *Client) SetIdempotencyKeyGenerator(kg idempotency.KeyGenerator) { // NewAPIRequest is a wrapper around the http.NewRequest function. // // It will setup the authentication headers/parameters according to the client config. +// nolint: contextcheck func (c *Client) NewAPIRequest(ctx context.Context, method string, uri string, body interface{}) (req *http.Request, err error) { if !strings.HasSuffix(c.BaseURL.Path, "/") { return nil, errBadBaseURL From 5003a8a59910fb33e123c034a4a0bc258c544f71 Mon Sep 17 00:00:00 2001 From: Victor Hugo Avelar Ossorio Date: Wed, 8 Feb 2023 16:38:40 +0000 Subject: [PATCH 03/29] chore(ci): handle ci-lint complexity preset --- mollie/mollie.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mollie/mollie.go b/mollie/mollie.go index 8d1e461..14586a9 100644 --- a/mollie/mollie.go +++ b/mollie/mollie.go @@ -191,15 +191,17 @@ func (c *Client) NewAPIRequest(ctx context.Context, method string, uri string, b } } - if ctx == nil { - ctx = context.Background() - } - req, err = http.NewRequestWithContext(ctx, method, url.String(), buf) if err != nil { return } + c.addRequestHeaders(req) + + return +} + +func (c *Client) addRequestHeaders(req *http.Request) { req.Header.Add(AuthHeader, strings.Join([]string{TokenType, c.authentication}, " ")) req.Header.Set("Content-Type", RequestContentType) req.Header.Set("Accept", RequestContentType) @@ -208,8 +210,6 @@ func (c *Client) NewAPIRequest(ctx context.Context, method string, uri string, b if c.config.reqIdempotency && c.idempotencyKeyProvider != nil && req.Method == http.MethodPost { req.Header.Set(IdempotencyKeyHeader, c.idempotencyKeyProvider.Generate()) } - - return } // Do sends an API request and returns the API response or returned as an From 648362043f423ff2d5c097760c8fa47556ff98de Mon Sep 17 00:00:00 2001 From: Victor Hugo Avelar Ossorio Date: Wed, 8 Feb 2023 17:20:26 +0000 Subject: [PATCH 04/29] chore(ci): move linter settings to file --- .devcontainer/devcontainer.json | 6 ------ .golangci.yaml | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 .golangci.yaml diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index cd5bbea..53cf51c 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -55,16 +55,10 @@ "ui.semanticTokens": true }, "go.lintTool": "golangci-lint", - "go.lintFlags": [ - "--fast" - ], "go.lintOnSave": "package", "go.toolsEnvVars": { "CGO_ENABLED": 1 }, - "go.testEnvVars": { - "": "" - }, "go.testFlags": [ "-v", "-race" diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 0000000..981f566 --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,32 @@ +# golangci-lint configuration + +run: + concurrency: 4 + timeout: 20s + issues-exit-code: 2 + tests: false + skip-dirs-use-default: true + modules-download-mode: readonly + go: '1.17' + +output: + format: tab + sort-results: true + +linters: + disable: + - tagliatelle + presets: + - bugs + - comment + - complexity + - error + - format + - import + - metalinter + - module + - performance + - sql + - style + + fast: true From d3d4d63ac96f19d28d2e95f7b431db80df39cce6 Mon Sep 17 00:00:00 2001 From: Victor Hugo Avelar Ossorio Date: Wed, 8 Feb 2023 17:20:44 +0000 Subject: [PATCH 05/29] chore(ci): fix lll linter issues on balances.go --- mollie/balances.go | 55 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 9 deletions(-) diff --git a/mollie/balances.go b/mollie/balances.go index 3ca0abd..631accf 100644 --- a/mollie/balances.go +++ b/mollie/balances.go @@ -240,6 +240,7 @@ func (bs *BalancesService) Get(ctx context.Context, balance string) (res *Respon // See: https://docs.mollie.com/reference/v2/balances-api/get-primary-balance func (bs *BalancesService) Primary(ctx context.Context) (res *Response, b *Balance, err error) { const id = "primary" + return bs.get(ctx, id) } @@ -247,21 +248,33 @@ func (bs *BalancesService) Primary(ctx context.Context) (res *Response, b *Balan // balance, ordered from newest to oldest. // // See: https://docs.mollie.com/reference/v2/balances-api/list-balances -func (bs *BalancesService) List(ctx context.Context, options *BalanceListOptions) (res *Response, bl *BalancesList, err error) { +func (bs *BalancesService) List(ctx context.Context, options *BalanceListOptions) ( + res *Response, + bl *BalancesList, + err error, +) { return bs.list(ctx, "v2/balances", options) } // GetReport returns the balance report for the specified balance id. // // See: https://docs.mollie.com/reference/v2/balances-api/get-balance-report -func (bs *BalancesService) GetReport(ctx context.Context, balance string, options *BalanceReportOptions) (res *Response, br *BalanceReport, err error) { +func (bs *BalancesService) GetReport(ctx context.Context, balance string, options *BalanceReportOptions) ( + res *Response, + br *BalanceReport, + err error, +) { return bs.getReport(ctx, balance, options) } // GetPrimaryReport returns the report for the primary balance. // // See: https://docs.mollie.com/reference/v2/balances-api/get-primary-balance-report -func (bs *BalancesService) GetPrimaryReport(ctx context.Context, options *BalanceReportOptions) (res *Response, br *BalanceReport, err error) { +func (bs *BalancesService) GetPrimaryReport(ctx context.Context, options *BalanceReportOptions) ( + res *Response, + br *BalanceReport, + err error, +) { return bs.getReport(ctx, "primary", options) } @@ -269,15 +282,27 @@ func (bs *BalancesService) GetPrimaryReport(ctx context.Context, options *Balanc // specified balance. // // See: https://docs.mollie.com/reference/v2/balances-api/list-balance-transactions -func (bs *BalancesService) GetTransactionsList(ctx context.Context, balance string, options *BalanceTransactionsListOptions) (res *Response, btl *BalanceTransactionsList, err error) { +func (bs *BalancesService) GetTransactionsList( + ctx context.Context, + balance string, + options *BalanceTransactionsListOptions, +) ( + res *Response, + btl *BalanceTransactionsList, + err error, +) { return bs.listTransactions(ctx, balance, options) } -// GetPrimaryTransactionsList retieves the list of movements (transactions) for the +// GetPrimaryTransactionsList retrieves the list of movements (transactions) for the // primary balance of the account. // // See: https://docs.mollie.com/reference/v2/balances-api/list-primary-balance-transactions -func (bs *BalancesService) GetPrimaryTransactionsList(ctx context.Context, options *BalanceTransactionsListOptions) (res *Response, btl *BalanceTransactionsList, err error) { +func (bs *BalancesService) GetPrimaryTransactionsList(ctx context.Context, options *BalanceTransactionsListOptions) ( + res *Response, + btl *BalanceTransactionsList, + err error, +) { return bs.listTransactions(ctx, "primary", options) } @@ -296,7 +321,11 @@ func (bs *BalancesService) get(ctx context.Context, balance string) (res *Respon return } -func (bs *BalancesService) list(ctx context.Context, uri string, options interface{}) (res *Response, lb *BalancesList, err error) { +func (bs *BalancesService) list( + ctx context.Context, + uri string, + options interface{}, +) (res *Response, lb *BalancesList, err error) { res, err = bs.client.get(ctx, uri, options) if err != nil { return @@ -309,7 +338,11 @@ func (bs *BalancesService) list(ctx context.Context, uri string, options interfa return } -func (bs *BalancesService) getReport(ctx context.Context, balance string, options *BalanceReportOptions) (res *Response, br *BalanceReport, err error) { +func (bs *BalancesService) getReport( + ctx context.Context, + balance string, + options *BalanceReportOptions, +) (res *Response, br *BalanceReport, err error) { u := fmt.Sprintf("v2/balances/%s/report", balance) res, err = bs.client.get(ctx, u, options) @@ -324,7 +357,11 @@ func (bs *BalancesService) getReport(ctx context.Context, balance string, option return } -func (bs *BalancesService) listTransactions(ctx context.Context, balance string, options *BalanceTransactionsListOptions) (res *Response, btl *BalanceTransactionsList, err error) { +func (bs *BalancesService) listTransactions( + ctx context.Context, + balance string, + options *BalanceTransactionsListOptions, +) (res *Response, btl *BalanceTransactionsList, err error) { u := fmt.Sprintf("v2/balances/%s/transactions", balance) res, err = bs.client.get(ctx, u, options) From 69ce3ac1bf2fdec8c0f0f335ae701e623e384f95 Mon Sep 17 00:00:00 2001 From: Victor Hugo Avelar Ossorio Date: Wed, 8 Feb 2023 17:21:05 +0000 Subject: [PATCH 06/29] chore(ci): fix spelling issues on profiles.go --- mollie/profiles.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mollie/profiles.go b/mollie/profiles.go index eee7a1a..8ee8406 100644 --- a/mollie/profiles.go +++ b/mollie/profiles.go @@ -163,7 +163,7 @@ func (ps *ProfilesService) DisablePaymentMethod(ctx context.Context, id string, return } -// EnableGiftCardIssuer activates the requested giftcard issuer for the provided +// EnableGiftCardIssuer activates the requested gift card issuer for the provided // profile id. // // See: https://docs.mollie.com/reference/v2/profiles-api/enable-gift-card-issuer @@ -179,7 +179,7 @@ func (ps *ProfilesService) EnableGiftCardIssuer(ctx context.Context, profileID s return } -// DisableGiftCardIssuer deactivates the requested giftcard issuer for the provided +// DisableGiftCardIssuer deactivates the requested gift card issuer for the provided // profile id. // // See: https://docs.mollie.com/reference/v2/profiles-api/disable-gift-card-issuer @@ -222,9 +222,10 @@ func (ps *ProfilesService) DisableGiftCardIssuerForCurrent(ctx context.Context, func (ps *ProfilesService) toggleGiftCardIssuerStatus(ctx context.Context, profileID string, method string, issuer GiftCardIssuer) (r *Response, err error) { u := fmt.Sprintf("v2/profiles/%s/methods/giftcard/issuers/%s", profileID, issuer) - if method == http.MethodDelete { + switch method { + case http.MethodDelete: r, err = ps.client.delete(ctx, u, nil) - } else if method == http.MethodPost { + case http.MethodPost: r, err = ps.client.post(ctx, u, nil, nil) } From ec99b9ceccfb5c0a2f3a4b6708db4a6f5f8e3b09 Mon Sep 17 00:00:00 2001 From: Victor Hugo Avelar Ossorio Date: Wed, 8 Feb 2023 17:22:35 +0000 Subject: [PATCH 07/29] chore(ci): fix lll errors in chargebacks.go --- mollie/chargebacks.go | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/mollie/chargebacks.go b/mollie/chargebacks.go index 5b5087e..39c868e 100644 --- a/mollie/chargebacks.go +++ b/mollie/chargebacks.go @@ -59,7 +59,11 @@ type ChargebacksService service // Note the original payment’s ID is needed as well. // // See: https://docs.mollie.com/reference/v2/chargebacks-api/get-chargeback -func (cs *ChargebacksService) Get(ctx context.Context, payment, chargeback string, opts *ChargebackOptions) (res *Response, p *Chargeback, err error) { +func (cs *ChargebacksService) Get(ctx context.Context, payment, chargeback string, opts *ChargebackOptions) ( + res *Response, + p *Chargeback, + err error, +) { u := fmt.Sprintf("v2/payments/%s/chargebacks/%s", payment, chargeback) res, err = cs.client.get(ctx, u, opts) @@ -77,19 +81,31 @@ func (cs *ChargebacksService) Get(ctx context.Context, payment, chargeback strin // List retrieves a list of chargebacks associated with your account/organization. // // See: https://docs.mollie.com/reference/v2/chargebacks-api/list-chargebacks -func (cs *ChargebacksService) List(ctx context.Context, options *ChargebacksListOptions) (res *Response, cl *ChargebacksList, err error) { +func (cs *ChargebacksService) List(ctx context.Context, options *ChargebacksListOptions) ( + res *Response, + cl *ChargebacksList, + err error, +) { return cs.list(ctx, "v2/chargebacks", options) } // ListForPayment retrieves a list of chargebacks associated with a single payment. // // See: https://docs.mollie.com/reference/v2/chargebacks-api/list-chargebacks -func (cs *ChargebacksService) ListForPayment(ctx context.Context, payment string, options *ChargebacksListOptions) (res *Response, cl *ChargebacksList, err error) { +func (cs *ChargebacksService) ListForPayment(ctx context.Context, payment string, options *ChargebacksListOptions) ( + res *Response, + cl *ChargebacksList, + err error, +) { return cs.list(ctx, fmt.Sprintf("v2/payments/%s/chargebacks", payment), options) } // encapsulates the shared list methods logic. -func (cs *ChargebacksService) list(ctx context.Context, uri string, options interface{}) (res *Response, cl *ChargebacksList, err error) { +func (cs *ChargebacksService) list(ctx context.Context, uri string, options interface{}) ( + res *Response, + cl *ChargebacksList, + err error, +) { res, err = cs.client.get(ctx, uri, options) if err != nil { return From dd89b004b8b76dc49cdcdf7ff56ff918c77b4edc Mon Sep 17 00:00:00 2001 From: Victor Hugo Avelar Ossorio Date: Wed, 8 Feb 2023 18:52:59 +0000 Subject: [PATCH 08/29] chore(ci): fix lll errors in common_types.go --- mollie/common_types.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mollie/common_types.go b/mollie/common_types.go index 022ef40..9dc4c6e 100644 --- a/mollie/common_types.go +++ b/mollie/common_types.go @@ -49,9 +49,10 @@ func (d *ShortDate) MarshalJSON() ([]byte, error) { // for the Date struct, as we need links to be pointers to the time.Time struct. func (d *ShortDate) UnmarshalJSON(b []byte) error { s := string(b) + s = strings.Trim(s, "\"") - date, err := time.Parse("2006-01-02", s) + date, err := time.Parse("2006-01-02", s) if err != nil { return fmt.Errorf("time_parse_error: %w", err) } @@ -159,7 +160,7 @@ const ( EmbedPayment EmbedValue = "payments" EmbedRefund EmbedValue = "refunds" EmbedShipments EmbedValue = "shipments" - EmbedChangebacks EmbedValue = "chanrgebacks" + EmbedChargebacks EmbedValue = "chargebacks" ) // Rate describes service rates, further divided into fixed and percentage costs. From 913a49601910a87148899f9ba997763c3a3c7014 Mon Sep 17 00:00:00 2001 From: Victor Hugo Avelar Ossorio Date: Wed, 8 Feb 2023 18:53:19 +0000 Subject: [PATCH 09/29] chore(ci): fix lll errors in customers.go --- mollie/customers.go | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/mollie/customers.go b/mollie/customers.go index 120f409..72fae6c 100644 --- a/mollie/customers.go +++ b/mollie/customers.go @@ -90,7 +90,11 @@ func (cs *CustomersService) Create(ctx context.Context, c Customer) (res *Respon // Update an existing customer. // // See: https://docs.mollie.com/reference/v2/customers-api/update-customer -func (cs *CustomersService) Update(ctx context.Context, id string, c Customer) (res *Response, cc *Customer, err error) { +func (cs *CustomersService) Update(ctx context.Context, id string, c Customer) ( + res *Response, + cc *Customer, + err error, +) { u := fmt.Sprintf("v2/customers/%s", id) res, err = cs.client.patch(ctx, u, c, nil) @@ -124,7 +128,11 @@ func (cs *CustomersService) Delete(ctx context.Context, id string) (res *Respons // List retrieves all customers created. // // See: https://docs.mollie.com/reference/v2/customers-api/list-customers -func (cs *CustomersService) List(ctx context.Context, options *CustomersListOptions) (res *Response, cl *CustomersList, err error) { +func (cs *CustomersService) List(ctx context.Context, options *CustomersListOptions) ( + res *Response, + cl *CustomersList, + err error, +) { res, err = cs.list(ctx, "v2/customers", options) if err != nil { return @@ -140,7 +148,11 @@ func (cs *CustomersService) List(ctx context.Context, options *CustomersListOpti // GetPayments retrieves all payments linked to the customer. // // See: https://docs.mollie.com/reference/v2/customers-api/list-customer-payments -func (cs *CustomersService) GetPayments(ctx context.Context, id string, options *CustomersListOptions) (res *Response, pl *PaymentList, err error) { +func (cs *CustomersService) GetPayments(ctx context.Context, id string, options *CustomersListOptions) ( + res *Response, + pl *PaymentList, + err error, +) { u := fmt.Sprintf("v2/customers/%s/payments", id) res, err = cs.list(ctx, u, options) @@ -158,7 +170,11 @@ func (cs *CustomersService) GetPayments(ctx context.Context, id string, options // CreatePayment creates a payment for the customer. // // See: https://docs.mollie.com/reference/v2/customers-api/create-customer-payment -func (cs *CustomersService) CreatePayment(ctx context.Context, id string, p Payment) (res *Response, pp *Payment, err error) { +func (cs *CustomersService) CreatePayment(ctx context.Context, id string, p Payment) ( + res *Response, + pp *Payment, + err error, +) { u := fmt.Sprintf("v2/customers/%s/payments", id) res, err = cs.client.post(ctx, u, p, nil) From 651a731b65d792690c43aff2279972e3f82ab99b Mon Sep 17 00:00:00 2001 From: Victor Hugo Avelar Ossorio Date: Wed, 8 Feb 2023 18:53:45 +0000 Subject: [PATCH 10/29] chore(ci): fix lll errors in invoices.go --- mollie/invoices.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mollie/invoices.go b/mollie/invoices.go index c2af8eb..4bd18f1 100644 --- a/mollie/invoices.go +++ b/mollie/invoices.go @@ -87,7 +87,11 @@ func (is *InvoicesService) Get(ctx context.Context, id string) (res *Response, i } // List retrieves a list of invoices associated with your account/organization. -func (is *InvoicesService) List(ctx context.Context, options *InvoicesListOptions) (res *Response, il *InvoicesList, err error) { +func (is *InvoicesService) List(ctx context.Context, options *InvoicesListOptions) ( + res *Response, + il *InvoicesList, + err error, +) { res, err = is.client.get(ctx, "v2/invoices", options) if err != nil { return From 8da6cb624cd81071384049884dd6fa0f6d11a819 Mon Sep 17 00:00:00 2001 From: Victor Hugo Avelar Ossorio Date: Wed, 8 Feb 2023 18:54:13 +0000 Subject: [PATCH 11/29] chore(ci): fix lll errors in mandates.go --- mollie/mandates.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mollie/mandates.go b/mollie/mandates.go index afc2932..4627ffa 100644 --- a/mollie/mandates.go +++ b/mollie/mandates.go @@ -100,7 +100,11 @@ type MandatesList struct { // Mandates allow you to charge a customer’s credit card or bank account recurrently. // // See: https://docs.mollie.com/reference/v2/mandates-api/create-mandate -func (ms *MandatesService) Create(ctx context.Context, customer string, mandate Mandate) (res *Response, mr *Mandate, err error) { +func (ms *MandatesService) Create(ctx context.Context, customer string, mandate Mandate) ( + res *Response, + mr *Mandate, + err error, +) { u := fmt.Sprintf("v2/customers/%s/mandates", customer) res, err = ms.client.post(ctx, u, mandate, nil) @@ -156,7 +160,11 @@ func (ms *MandatesService) Revoke(ctx context.Context, customer, mandate string) // ordered from newest to oldest. // // See: https://docs.mollie.com/reference/v2/mandates-api/list-mandates -func (ms *MandatesService) List(ctx context.Context, customer string, options *MandatesListOptions) (res *Response, ml *MandatesList, err error) { +func (ms *MandatesService) List(ctx context.Context, customer string, options *MandatesListOptions) ( + res *Response, + ml *MandatesList, + err error, +) { u := fmt.Sprintf("v2/customers/%s/mandates", customer) res, err = ms.client.get(ctx, u, options) From 473325de3ae8fa151fc86ad8fd00b7bd77514ee2 Mon Sep 17 00:00:00 2001 From: Victor Hugo Avelar Ossorio Date: Wed, 8 Feb 2023 18:57:56 +0000 Subject: [PATCH 12/29] chore(ci): fix linter errors in miscellaneous.go --- mollie/miscellaneous.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mollie/miscellaneous.go b/mollie/miscellaneous.go index 97ffce3..f1921ba 100644 --- a/mollie/miscellaneous.go +++ b/mollie/miscellaneous.go @@ -31,7 +31,11 @@ type ApplePaymentSessionRequest struct { // ApplePaymentSession returns an Apple Payment Session object valid for one transaction. // // See: https://docs.mollie.com/reference/v2/wallets-api/request-apple-pay-payment-session -func (ms *MiscellaneousService) ApplePaymentSession(ctx context.Context, asr *ApplePaymentSessionRequest) (res *Response, aps *ApplePaymentSession, err error) { +func (ms *MiscellaneousService) ApplePaymentSession(ctx context.Context, asr *ApplePaymentSessionRequest) ( + res *Response, + aps *ApplePaymentSession, + err error, +) { u := "v2/wallets/applepay/sessions" res, err = ms.client.post(ctx, u, asr, nil) From c0c9ebe78337ce46533c8c27ab0cc716138c09bd Mon Sep 17 00:00:00 2001 From: Victor Hugo Avelar Ossorio Date: Wed, 8 Feb 2023 19:03:21 +0000 Subject: [PATCH 13/29] chore(ci): fix linter errors in mollie.go --- mollie/mollie.go | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/mollie/mollie.go b/mollie/mollie.go index 14586a9..38c96aa 100644 --- a/mollie/mollie.go +++ b/mollie/mollie.go @@ -86,7 +86,10 @@ func (c *Client) get(ctx context.Context, uri string, options interface{}) (res return c.Do(req) } -func (c *Client) post(ctx context.Context, uri string, body interface{}, options interface{}) (res *Response, err error) { +func (c *Client) post(ctx context.Context, uri string, body interface{}, options interface{}) ( + res *Response, + err error, +) { if options != nil { v, _ := query.Values(options) uri = fmt.Sprintf("%s?%s", uri, v.Encode()) @@ -100,7 +103,10 @@ func (c *Client) post(ctx context.Context, uri string, body interface{}, options return c.Do(req) } -func (c *Client) patch(ctx context.Context, uri string, body interface{}, options interface{}) (res *Response, err error) { +func (c *Client) patch(ctx context.Context, uri string, body interface{}, options interface{}) ( + res *Response, + err error, +) { if options != nil { v, _ := query.Values(options) uri = fmt.Sprintf("%s?%s", uri, v.Encode()) @@ -162,8 +168,11 @@ func (c *Client) SetIdempotencyKeyGenerator(kg idempotency.KeyGenerator) { // NewAPIRequest is a wrapper around the http.NewRequest function. // // It will setup the authentication headers/parameters according to the client config. -// nolint: contextcheck -func (c *Client) NewAPIRequest(ctx context.Context, method string, uri string, body interface{}) (req *http.Request, err error) { +func (c *Client) NewAPIRequest(ctx context.Context, method string, uri string, body interface{}) ( + req *http.Request, + err error, +) { + //nolint: contextcheck if !strings.HasSuffix(c.BaseURL.Path, "/") { return nil, errBadBaseURL } @@ -198,7 +207,7 @@ func (c *Client) NewAPIRequest(ctx context.Context, method string, uri string, b c.addRequestHeaders(req) - return + return req, nil } func (c *Client) addRequestHeaders(req *http.Request) { @@ -207,7 +216,9 @@ func (c *Client) addRequestHeaders(req *http.Request) { req.Header.Set("Accept", RequestContentType) req.Header.Set("User-Agent", c.userAgent) - if c.config.reqIdempotency && c.idempotencyKeyProvider != nil && req.Method == http.MethodPost { + if c.config.reqIdempotency && + c.idempotencyKeyProvider != nil && + req.Method == http.MethodPost { req.Header.Set(IdempotencyKeyHeader, c.idempotencyKeyProvider.Generate()) } } @@ -217,10 +228,10 @@ func (c *Client) addRequestHeaders(req *http.Request) { func (c *Client) Do(req *http.Request) (*Response, error) { resp, err := c.client.Do(req) if err != nil { - return nil, fmt.Errorf("httperror: %w", err) + return nil, fmt.Errorf("http_error: %w", err) } - defer resp.Body.Close() + response, err := newResponse(resp) if err != nil { return response, err @@ -298,27 +309,27 @@ func NewClient(baseClient *http.Client, conf *Config) (mollie *Client, err error mollie.authentication = tkn } - return + return mollie, nil } /* Constructor for Error. */ func newError(rsp *Response) error { - merr := &BaseError{} + baseErr := &BaseError{} if rsp.ContentLength > 0 { - err := json.Unmarshal(rsp.content, merr) + err := json.Unmarshal(rsp.content, baseErr) if err != nil { return err } } else { - merr.Status = rsp.StatusCode - merr.Title = rsp.Status - merr.Detail = string(rsp.content) + baseErr.Status = rsp.StatusCode + baseErr.Title = rsp.Status + baseErr.Detail = string(rsp.content) } - return merr + return baseErr } // Response is a Mollie API response. This wraps the standard http.Response From 1d421936fdea000128e5fcbce2cdac4827ef3d73 Mon Sep 17 00:00:00 2001 From: Victor Hugo Avelar Ossorio Date: Wed, 8 Feb 2023 19:06:15 +0000 Subject: [PATCH 14/29] chore(ci): fix linter errors in orders.go --- mollie/orders.go | 57 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 9 deletions(-) diff --git a/mollie/orders.go b/mollie/orders.go index 282582e..bd136f6 100644 --- a/mollie/orders.go +++ b/mollie/orders.go @@ -213,7 +213,11 @@ type OrdersService service // Get retrieve a single order by its ID. // // See https://docs.mollie.com/reference/v2/orders-api/get-order -func (ors *OrdersService) Get(ctx context.Context, orID string, opts *OrderOptions) (res *Response, order *Order, err error) { +func (ors *OrdersService) Get(ctx context.Context, orID string, opts *OrderOptions) ( + res *Response, + order *Order, + err error, +) { res, err = ors.client.get(ctx, fmt.Sprintf("v2/orders/%s", orID), opts) if err != nil { return @@ -229,7 +233,11 @@ func (ors *OrdersService) Get(ctx context.Context, orID string, opts *OrderOptio // Create an order will automatically create the required payment to allow your customer to pay for the order. // // See https://docs.mollie.com/reference/v2/orders-api/create-order -func (ors *OrdersService) Create(ctx context.Context, ord Order, opts *OrderOptions) (res *Response, order *Order, err error) { +func (ors *OrdersService) Create(ctx context.Context, ord Order, opts *OrderOptions) ( + res *Response, + order *Order, + err error, +) { if ors.client.HasAccessToken() && ors.client.config.testing { ord.TestMode = true } @@ -249,7 +257,11 @@ func (ors *OrdersService) Create(ctx context.Context, ord Order, opts *OrderOpti // Update is used to update the billing and/or shipping address of an order. // // See https://docs.mollie.com/reference/v2/orders-api/update-order -func (ors *OrdersService) Update(ctx context.Context, orderID string, ord Order) (res *Response, order *Order, err error) { +func (ors *OrdersService) Update(ctx context.Context, orderID string, ord Order) ( + res *Response, + order *Order, + err error, +) { res, err = ors.client.patch(ctx, fmt.Sprintf("v2/orders/%s", orderID), ord, nil) if err != nil { return @@ -281,7 +293,11 @@ func (ors *OrdersService) Cancel(ctx context.Context, orderID string) (res *Resp // List is to retrieve all orders. // // See https://docs.mollie.com/reference/v2/orders-api/list-orders -func (ors *OrdersService) List(ctx context.Context, opts *OrderListOptions) (res *Response, ordList *OrderList, err error) { +func (ors *OrdersService) List(ctx context.Context, opts *OrderListOptions) ( + res *Response, + ordList *OrderList, + err error, +) { res, err = ors.client.get(ctx, "v2/orders", opts) if err != nil { return @@ -297,7 +313,15 @@ func (ors *OrdersService) List(ctx context.Context, opts *OrderListOptions) (res // UpdateOrderLine can be used to update an order line. // // See https://docs.mollie.com/reference/v2/orders-api/update-orderline -func (ors *OrdersService) UpdateOrderLine(ctx context.Context, orderID string, orderLineID string, orderLine OrderLine) (res *Response, order *Order, err error) { +func (ors *OrdersService) UpdateOrderLine( + ctx context.Context, + orderID string, + orderLineID string, + orderLine OrderLine) ( + res *Response, + order *Order, + err error, +) { u := fmt.Sprintf("v2/orders/%s/lines/%s", orderID, orderLineID) res, err = ors.client.patch(ctx, u, orderLine, nil) @@ -317,7 +341,10 @@ func (ors *OrdersService) UpdateOrderLine(ctx context.Context, orderID string, o // Use the Cancel Order API if you want to cancel the entire order or the remainder of the order. // // See https://docs.mollie.com/reference/v2/orders-api/cancel-order-lines -func (ors *OrdersService) CancelOrderLines(ctx context.Context, orderID string, orderLines []OrderLine) (res *Response, err error) { +func (ors *OrdersService) CancelOrderLines(ctx context.Context, orderID string, orderLines []OrderLine) ( + res *Response, + err error, +) { u := fmt.Sprintf("v2/orders/%s/lines", orderID) res, err = ors.client.delete(ctx, u, nil) @@ -332,7 +359,11 @@ func (ors *OrdersService) CancelOrderLines(ctx context.Context, orderID string, // and when the status of the existing payment is either expired, canceled or failed. // // See https://docs.mollie.com/reference/v2/orders-api/create-order-payment -func (ors *OrdersService) CreateOrderPayment(ctx context.Context, orderID string, ordPay *OrderPayment) (res *Response, payment *Payment, err error) { +func (ors *OrdersService) CreateOrderPayment(ctx context.Context, orderID string, ordPay *OrderPayment) ( + res *Response, + payment *Payment, + err error, +) { u := fmt.Sprintf("v2/orders/%s/payments", orderID) res, err = ors.client.post(ctx, u, ordPay, nil) @@ -350,7 +381,11 @@ func (ors *OrdersService) CreateOrderPayment(ctx context.Context, orderID string // CreateOrderRefund using the Orders API, refunds should be made against the order. // // See https://docs.mollie.com/reference/v2/orders-api/create-order-refund -func (ors *OrdersService) CreateOrderRefund(ctx context.Context, orderID string, order *Order) (res *Response, refund *Refund, err error) { +func (ors *OrdersService) CreateOrderRefund(ctx context.Context, orderID string, order *Order) ( + res *Response, + refund *Refund, + err error, +) { u := fmt.Sprintf("v2/orders/%s/refunds", orderID) res, err = ors.client.post(ctx, u, order, nil) @@ -368,7 +403,11 @@ func (ors *OrdersService) CreateOrderRefund(ctx context.Context, orderID string, // ListOrderRefunds retrieve all order refunds. // // See https://docs.mollie.com/reference/v2/orders-api/list-order-refunds -func (ors *OrdersService) ListOrderRefunds(ctx context.Context, orderID string, opts *OrderListRefundOptions) (res *Response, orderListRefund *OrderListRefund, err error) { +func (ors *OrdersService) ListOrderRefunds(ctx context.Context, orderID string, opts *OrderListRefundOptions) ( + res *Response, + orderListRefund *OrderListRefund, + err error, +) { u := fmt.Sprintf("v2/orders/%s/refunds", orderID) res, err = ors.client.get(ctx, u, opts) From 261725ee4915a4528bcabb68eb2feba8c2102acd Mon Sep 17 00:00:00 2001 From: Victor Hugo Avelar Ossorio Date: Wed, 8 Feb 2023 19:08:21 +0000 Subject: [PATCH 15/29] chore(ci): fix linter errors in organizations.go --- mollie/organizations.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mollie/organizations.go b/mollie/organizations.go index 3316eb8..03e178b 100644 --- a/mollie/organizations.go +++ b/mollie/organizations.go @@ -89,7 +89,11 @@ func (os *OrganizationsService) GetCurrent(ctx context.Context) (res *Response, // of the currently authenticated organization. // // See: https://docs.mollie.com/reference/v2/organizations-api/get-partner -func (os *OrganizationsService) GetPartnerStatus(ctx context.Context) (res *Response, ops *OrganizationPartnerStatus, err error) { +func (os *OrganizationsService) GetPartnerStatus(ctx context.Context) ( + res *Response, + ops *OrganizationPartnerStatus, + err error, +) { res, err = os.client.get(ctx, "v2/organizations/me/partner", nil) if err != nil { return From b5436dbbaeef744798e3260d0211cde7c0260673 Mon Sep 17 00:00:00 2001 From: Victor Hugo Avelar Ossorio Date: Wed, 8 Feb 2023 19:09:08 +0000 Subject: [PATCH 16/29] chore(ci): fix linter errors in partners.go --- mollie/partners.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mollie/partners.go b/mollie/partners.go index 45f3003..3f3ca67 100644 --- a/mollie/partners.go +++ b/mollie/partners.go @@ -59,7 +59,11 @@ type PartnerService service // List retrieves all clients. // // See: https://docs.mollie.com/reference/v2/partners-api/list-clients -func (ps *PartnerService) List(ctx context.Context, opts *ListPartnerClientsOptions) (res *Response, pc *PartnerClientList, err error) { +func (ps *PartnerService) List(ctx context.Context, opts *ListPartnerClientsOptions) ( + res *Response, + pc *PartnerClientList, + err error, +) { res, err = ps.client.get(ctx, "v2/clients", opts) if err != nil { return @@ -75,7 +79,11 @@ func (ps *PartnerService) List(ctx context.Context, opts *ListPartnerClientsOpti // Get retrieves a single client, linked to your partner account, by its ID. // // See: https://docs.mollie.com/reference/v2/partners-api/get-client -func (ps *PartnerService) Get(ctx context.Context, id string, opts *GetPartnerClientOptions) (res *Response, pc *PartnerClient, err error) { +func (ps *PartnerService) Get(ctx context.Context, id string, opts *GetPartnerClientOptions) ( + res *Response, + pc *PartnerClient, + err error, +) { res, err = ps.client.get(ctx, fmt.Sprintf("v2/clients/%s", id), opts) if err != nil { return From 7ae6fe6282a759ccab880483e3345af9ab01a9b8 Mon Sep 17 00:00:00 2001 From: Victor Hugo Avelar Ossorio Date: Wed, 8 Feb 2023 19:09:57 +0000 Subject: [PATCH 17/29] chore(ci): fix linter errors in payment_links.go --- mollie/payment_links.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mollie/payment_links.go b/mollie/payment_links.go index 1e0ce83..c8f6102 100644 --- a/mollie/payment_links.go +++ b/mollie/payment_links.go @@ -80,7 +80,11 @@ func (pls *PaymentLinksService) Get(ctx context.Context, id string) (res *Respon // Create generates payment links that by default, unlike regular payments, do not expire. // // See: https://docs.mollie.com/reference/v2/payment-links-api/create-payment-link -func (pls *PaymentLinksService) Create(ctx context.Context, p PaymentLink, opts *PaymentLinkOptions) (res *Response, np *PaymentLink, err error) { +func (pls *PaymentLinksService) Create(ctx context.Context, p PaymentLink, opts *PaymentLinkOptions) ( + res *Response, + np *PaymentLink, + err error, +) { res, err = pls.client.post(ctx, "v2/payment-links", p, opts) if err != nil { return @@ -97,7 +101,11 @@ func (pls *PaymentLinksService) Create(ctx context.Context, p PaymentLink, opts // ordered from newest to oldest. // // See: https://docs.mollie.com/reference/v2/payment-links-api/list-payment-links -func (pls *PaymentLinksService) List(ctx context.Context, opts *PaymentLinkOptions) (res *Response, pl *PaymentLinksList, err error) { +func (pls *PaymentLinksService) List(ctx context.Context, opts *PaymentLinkOptions) ( + res *Response, + pl *PaymentLinksList, + err error, +) { res, err = pls.client.get(ctx, "v2/payment-links", opts) if err != nil { return From 1c7e20fd7692ea2a997d0fa643f35eb9b700b427 Mon Sep 17 00:00:00 2001 From: Victor Hugo Avelar Ossorio Date: Wed, 8 Feb 2023 19:12:00 +0000 Subject: [PATCH 18/29] chore(ci): fix linter errors in payment_methods.go --- mollie/payment_methods.go | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/mollie/payment_methods.go b/mollie/payment_methods.go index 1f58152..78414b1 100644 --- a/mollie/payment_methods.go +++ b/mollie/payment_methods.go @@ -98,7 +98,11 @@ type PaymentMethodsService service // query string parameters. // // See: https://docs.mollie.com/reference/v2/methods-api/get-method -func (ms *PaymentMethodsService) Get(ctx context.Context, id PaymentMethod, options *PaymentMethodOptions) (res *Response, pmd *PaymentMethodDetails, err error) { +func (ms *PaymentMethodsService) Get(ctx context.Context, id PaymentMethod, options *PaymentMethodOptions) ( + res *Response, + pmd *PaymentMethodDetails, + err error, +) { u := fmt.Sprintf("v2/methods/%s", id) res, err = ms.client.get(ctx, u, options) @@ -116,7 +120,11 @@ func (ms *PaymentMethodsService) Get(ctx context.Context, id PaymentMethod, opti // All retrieves all the payment methods enabled for your account/organization. // // See: https://docs.mollie.com/reference/v2/methods-api/list-all-methods -func (ms *PaymentMethodsService) All(ctx context.Context, options *PaymentMethodsListOptions) (res *Response, pm *PaymentMethodsList, err error) { +func (ms *PaymentMethodsService) All(ctx context.Context, options *PaymentMethodsListOptions) ( + res *Response, + pm *PaymentMethodsList, + err error, +) { return ms.list(ctx, "v2/methods/all", options) } @@ -125,11 +133,19 @@ func (ms *PaymentMethodsService) All(ctx context.Context, options *PaymentMethod // The results are not paginated. // // See: https://docs.mollie.com/reference/v2/methods-api/list-methods -func (ms *PaymentMethodsService) List(ctx context.Context, options *PaymentMethodsListOptions) (res *Response, pm *PaymentMethodsList, err error) { +func (ms *PaymentMethodsService) List(ctx context.Context, options *PaymentMethodsListOptions) ( + res *Response, + pm *PaymentMethodsList, + err error, +) { return ms.list(ctx, "v2/methods", options) } -func (ms *PaymentMethodsService) list(ctx context.Context, uri string, options interface{}) (res *Response, pm *PaymentMethodsList, err error) { +func (ms *PaymentMethodsService) list(ctx context.Context, uri string, options interface{}) ( + res *Response, + pm *PaymentMethodsList, + err error, +) { res, err = ms.client.get(ctx, uri, options) if err != nil { return From 4a147fe72098e5e772139ed0e7cab3e5563541a1 Mon Sep 17 00:00:00 2001 From: Victor Hugo Avelar Ossorio Date: Wed, 8 Feb 2023 19:17:12 +0000 Subject: [PATCH 19/29] chore(ci): fix linter errors in payments.go --- mollie/payments.go | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/mollie/payments.go b/mollie/payments.go index 431cccf..d2eff74 100644 --- a/mollie/payments.go +++ b/mollie/payments.go @@ -23,7 +23,7 @@ const ( IDeal PaymentMethod = "ideal" KBC PaymentMethod = "kbc" KlarnaPayLater PaymentMethod = "klarnapaylater" - KlarnaLiceit PaymentMethod = "klarnaliceit" + KlarnaSliceIt PaymentMethod = "klarnasliceit" MyBank PaymentMethod = "mybank" PayPal PaymentMethod = "paypal" PaySafeCard PaymentMethod = "paysafecard" @@ -137,7 +137,11 @@ type ListPaymentOptions struct { type PaymentsService service // Get retrieves a single payment object by its payment token. -func (ps *PaymentsService) Get(ctx context.Context, id string, opts *PaymentOptions) (res *Response, p *Payment, err error) { +func (ps *PaymentsService) Get(ctx context.Context, id string, opts *PaymentOptions) ( + res *Response, + p *Payment, + err error, +) { res, err = ps.client.get(ctx, fmt.Sprintf("v2/payments/%s", id), opts) if err != nil { return @@ -153,7 +157,11 @@ func (ps *PaymentsService) Get(ctx context.Context, id string, opts *PaymentOpti // Create stores a new payment object attached to your Mollie account. // // See: https://docs.mollie.com/reference/v2/payments-api/create-payment# -func (ps *PaymentsService) Create(ctx context.Context, p Payment, opts *PaymentOptions) (res *Response, np *Payment, err error) { +func (ps *PaymentsService) Create(ctx context.Context, p Payment, opts *PaymentOptions) ( + res *Response, + np *Payment, + err error, +) { if ps.client.HasAccessToken() && ps.client.config.testing { p.TestMode = true } @@ -198,6 +206,7 @@ func (ps *PaymentsService) Update(ctx context.Context, id string, up Payment) (r if err = json.Unmarshal(res.content, &p); err != nil { return } + return } @@ -213,7 +222,11 @@ type PaymentList struct { // List retrieves a list of payments associated with your account/organization. // // See: https://docs.mollie.com/reference/v2/payments-api/list-payments -func (ps *PaymentsService) List(ctx context.Context, opts *ListPaymentOptions) (res *Response, pl *PaymentList, err error) { +func (ps *PaymentsService) List(ctx context.Context, opts *ListPaymentOptions) ( + res *Response, + pl *PaymentList, + err error, +) { res, err = ps.client.get(ctx, "v2/payments", opts) if err != nil { return @@ -222,5 +235,6 @@ func (ps *PaymentsService) List(ctx context.Context, opts *ListPaymentOptions) ( if err = json.Unmarshal(res.content, &pl); err != nil { return } + return } From ca52d2c64f9efb722602b10c67607ed460c58751 Mon Sep 17 00:00:00 2001 From: Victor Hugo Avelar Ossorio Date: Wed, 8 Feb 2023 19:17:58 +0000 Subject: [PATCH 20/29] chore(ci): fix linter errors in permissions.go --- mollie/permissions.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mollie/permissions.go b/mollie/permissions.go index 745b5ce..8822d7c 100644 --- a/mollie/permissions.go +++ b/mollie/permissions.go @@ -76,6 +76,7 @@ func (ps *PermissionsService) Get(ctx context.Context, id PermissionGrant) (res if err = json.Unmarshal(res.content, &p); err != nil { return } + return } @@ -92,5 +93,6 @@ func (ps *PermissionsService) List(ctx context.Context) (res *Response, pl *Perm if err = json.Unmarshal(res.content, &pl); err != nil { return } + return } From a402dca9ad7a6d3587f57780c88137e7b340e831 Mon Sep 17 00:00:00 2001 From: Victor Hugo Avelar Ossorio Date: Wed, 8 Feb 2023 19:21:03 +0000 Subject: [PATCH 21/29] chore(ci): fix linter errors in profiles.go --- mollie/profiles.go | 61 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 9 deletions(-) diff --git a/mollie/profiles.go b/mollie/profiles.go index 8ee8406..801253f 100644 --- a/mollie/profiles.go +++ b/mollie/profiles.go @@ -68,7 +68,11 @@ type ProfileList struct { type ProfilesService service // List returns all the profiles for the authenticated account. -func (ps *ProfilesService) List(ctx context.Context, opts *ProfileListOptions) (res *Response, pl *ProfileList, err error) { +func (ps *ProfilesService) List(ctx context.Context, opts *ProfileListOptions) ( + res *Response, + pl *ProfileList, + err error, +) { res, err = ps.client.get(ctx, "v2/profiles", opts) if err != nil { return @@ -77,6 +81,7 @@ func (ps *ProfilesService) List(ctx context.Context, opts *ProfileListOptions) ( if err = json.Unmarshal(res.content, &pl); err != nil { return } + return } @@ -100,6 +105,7 @@ func (ps *ProfilesService) get(ctx context.Context, id string) (res *Response, p if err = json.Unmarshal(res.content, &p); err != nil { return } + return } @@ -113,6 +119,7 @@ func (ps *ProfilesService) Create(ctx context.Context, np *Profile) (res *Respon if err = json.Unmarshal(res.content, &p); err != nil { return } + return } @@ -126,6 +133,7 @@ func (ps *ProfilesService) Update(ctx context.Context, id string, up *Profile) ( if err = json.Unmarshal(res.content, &p); err != nil { return } + return } @@ -136,12 +144,17 @@ func (ps *ProfilesService) Delete(ctx context.Context, id string) (res *Response if err != nil { return } + return } // EnablePaymentMethod enables a payment method on a specific or authenticated profile. // If you're using API tokens for authentication, pass "me" as id. -func (ps *ProfilesService) EnablePaymentMethod(ctx context.Context, id string, pm PaymentMethod) (res *Response, pmi *PaymentMethodDetails, err error) { +func (ps *ProfilesService) EnablePaymentMethod(ctx context.Context, id string, pm PaymentMethod) ( + res *Response, + pmi *PaymentMethodDetails, + err error, +) { res, err = ps.client.post(ctx, fmt.Sprintf("v2/profiles/%s/methods/%s", id, pm), nil, nil) if err != nil { return @@ -150,16 +163,21 @@ func (ps *ProfilesService) EnablePaymentMethod(ctx context.Context, id string, p if err = json.Unmarshal(res.content, &pmi); err != nil { return } + return } // DisablePaymentMethod disables a payment method on a specific or authenticated profile. // If you're using API tokens for authentication, pass "me" as id. -func (ps *ProfilesService) DisablePaymentMethod(ctx context.Context, id string, pm PaymentMethod) (res *Response, err error) { +func (ps *ProfilesService) DisablePaymentMethod(ctx context.Context, id string, pm PaymentMethod) ( + res *Response, + err error, +) { res, err = ps.client.delete(ctx, fmt.Sprintf("v2/profiles/%s/methods/%s", id, pm), nil) if err != nil { return } + return } @@ -167,7 +185,11 @@ func (ps *ProfilesService) DisablePaymentMethod(ctx context.Context, id string, // profile id. // // See: https://docs.mollie.com/reference/v2/profiles-api/enable-gift-card-issuer -func (ps *ProfilesService) EnableGiftCardIssuer(ctx context.Context, profileID string, issuer GiftCardIssuer) (res *Response, gc *GiftCardEnabled, err error) { +func (ps *ProfilesService) EnableGiftCardIssuer(ctx context.Context, profileID string, issuer GiftCardIssuer) ( + res *Response, + gc *GiftCardEnabled, + err error, +) { res, err = ps.toggleGiftCardIssuerStatus(ctx, profileID, http.MethodPost, issuer) if err != nil { return @@ -176,6 +198,7 @@ func (ps *ProfilesService) EnableGiftCardIssuer(ctx context.Context, profileID s if err = json.Unmarshal(res.content, &gc); err != nil { return } + return } @@ -183,11 +206,15 @@ func (ps *ProfilesService) EnableGiftCardIssuer(ctx context.Context, profileID s // profile id. // // See: https://docs.mollie.com/reference/v2/profiles-api/disable-gift-card-issuer -func (ps *ProfilesService) DisableGiftCardIssuer(ctx context.Context, profileID string, issuer GiftCardIssuer) (res *Response, err error) { +func (ps *ProfilesService) DisableGiftCardIssuer(ctx context.Context, profileID string, issuer GiftCardIssuer) ( + res *Response, + err error, +) { res, err = ps.toggleGiftCardIssuerStatus(ctx, profileID, http.MethodDelete, issuer) if err != nil { return } + return } @@ -195,7 +222,11 @@ func (ps *ProfilesService) DisableGiftCardIssuer(ctx context.Context, profileID // current profile (token owner). // // See: https://docs.mollie.com/reference/v2/profiles-api/enable-gift-card-issuer -func (ps *ProfilesService) EnableGiftCardIssuerForCurrent(ctx context.Context, issuer GiftCardIssuer) (res *Response, gc *GiftCardEnabled, err error) { +func (ps *ProfilesService) EnableGiftCardIssuerForCurrent(ctx context.Context, issuer GiftCardIssuer) ( + res *Response, + gc *GiftCardEnabled, + err error, +) { res, err = ps.toggleGiftCardIssuerStatus(ctx, "me", http.MethodPost, issuer) if err != nil { return @@ -204,6 +235,7 @@ func (ps *ProfilesService) EnableGiftCardIssuerForCurrent(ctx context.Context, i if err = json.Unmarshal(res.content, &gc); err != nil { return } + return } @@ -211,16 +243,27 @@ func (ps *ProfilesService) EnableGiftCardIssuerForCurrent(ctx context.Context, i // current profile (token owner). // // See: https://docs.mollie.com/reference/v2/profiles-api/disable-gift-card-issuer -func (ps *ProfilesService) DisableGiftCardIssuerForCurrent(ctx context.Context, issuer GiftCardIssuer) (res *Response, err error) { +func (ps *ProfilesService) DisableGiftCardIssuerForCurrent(ctx context.Context, issuer GiftCardIssuer) ( + res *Response, + err error, +) { res, err = ps.toggleGiftCardIssuerStatus(ctx, "me", http.MethodDelete, issuer) if err != nil { return } + return } -func (ps *ProfilesService) toggleGiftCardIssuerStatus(ctx context.Context, profileID string, method string, issuer GiftCardIssuer) (r *Response, err error) { - u := fmt.Sprintf("v2/profiles/%s/methods/giftcard/issuers/%s", profileID, issuer) +func (ps *ProfilesService) toggleGiftCardIssuerStatus( + ctx context.Context, + profile string, + method string, + issuer GiftCardIssuer) ( + r *Response, + err error, +) { + u := fmt.Sprintf("v2/profiles/%s/methods/giftcard/issuers/%s", profile, issuer) switch method { case http.MethodDelete: From b8745d337ebda4d51b1400c0cfe0dded0035db06 Mon Sep 17 00:00:00 2001 From: Victor Hugo Avelar Ossorio Date: Wed, 8 Feb 2023 19:22:33 +0000 Subject: [PATCH 22/29] chore(ci): fix linter errors in refunds.go --- mollie/refunds.go | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/mollie/refunds.go b/mollie/refunds.go index 3df1c60..bbbec5c 100644 --- a/mollie/refunds.go +++ b/mollie/refunds.go @@ -79,7 +79,11 @@ type RefundsService service // Get retrieve a single refund by its ID. // // If you do not know the original payment’s ID, you can use the List payment refunds endpoint. -func (rs *RefundsService) Get(ctx context.Context, paymentID, refundID string, opts *RefundOptions) (res *Response, refund *Refund, err error) { +func (rs *RefundsService) Get(ctx context.Context, paymentID, refundID string, opts *RefundOptions) ( + res *Response, + refund *Refund, + err error, +) { u := fmt.Sprintf("v2/payments/%s/refunds/%s", paymentID, refundID) res, err = rs.client.get(ctx, u, opts) @@ -97,7 +101,11 @@ func (rs *RefundsService) Get(ctx context.Context, paymentID, refundID string, o // Create a refund payment request. // // See https://docs.mollie.com/reference/v2/refunds-api/create-refund. -func (rs *RefundsService) Create(ctx context.Context, paymentID string, re Refund, options *RefundOptions) (res *Response, rf *Refund, err error) { +func (rs *RefundsService) Create(ctx context.Context, paymentID string, re Refund, options *RefundOptions) ( + res *Response, + rf *Refund, + err error, +) { uri := fmt.Sprintf("v2/payments/%s/refunds", paymentID) if rs.client.HasAccessToken() && rs.client.config.testing { @@ -133,7 +141,11 @@ func (rs *RefundsService) Cancel(ctx context.Context, paymentID, refundID string // ListRefund calls the top level https://api.mollie.com/v2/refunds. // // See https://docs.mollie.com/reference/v2/refunds-api/list-refunds. -func (rs *RefundsService) ListRefund(ctx context.Context, opts *ListRefundOptions) (res *Response, rl *RefundList, err error) { +func (rs *RefundsService) ListRefund(ctx context.Context, opts *ListRefundOptions) ( + res *Response, + rl *RefundList, + err error, +) { u := "v2/refunds" return rs.list(ctx, u, opts) @@ -144,13 +156,21 @@ func (rs *RefundsService) ListRefund(ctx context.Context, opts *ListRefundOption // // Only refunds for that specific payment are returned. // See: https://docs.mollie.com/reference/v2/refunds-api/list-refunds -func (rs *RefundsService) ListRefundPayment(ctx context.Context, paymentID string, opts *ListRefundOptions) (res *Response, rl *RefundList, err error) { +func (rs *RefundsService) ListRefundPayment(ctx context.Context, paymentID string, opts *ListRefundOptions) ( + res *Response, + rl *RefundList, + err error, +) { u := fmt.Sprintf("v2/payments/%s/refunds", paymentID) return rs.list(ctx, u, opts) } -func (rs *RefundsService) list(ctx context.Context, uri string, opts interface{}) (res *Response, rl *RefundList, err error) { +func (rs *RefundsService) list(ctx context.Context, uri string, opts interface{}) ( + res *Response, + rl *RefundList, + err error, +) { res, err = rs.client.get(ctx, uri, opts) if err != nil { return @@ -159,5 +179,6 @@ func (rs *RefundsService) list(ctx context.Context, uri string, opts interface{} if err = json.Unmarshal(res.content, &rl); err != nil { return } + return } From 9a7fd4bdefdc89df23cc1ce670a9f9eb102f78f4 Mon Sep 17 00:00:00 2001 From: Victor Hugo Avelar Ossorio Date: Wed, 8 Feb 2023 19:24:39 +0000 Subject: [PATCH 23/29] chore(ci): fix linter errors in settlements.go --- mollie/settlements.go | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/mollie/settlements.go b/mollie/settlements.go index 87447f6..2a63292 100644 --- a/mollie/settlements.go +++ b/mollie/settlements.go @@ -118,7 +118,11 @@ func (ss *SettlementsService) Open(ctx context.Context) (res *Response, s *Settl // List retrieves all settlements, ordered from new to old // // See: https://docs.mollie.com/reference/v2/settlements-api/list-settlements -func (ss *SettlementsService) List(ctx context.Context, slo *SettlementsListOptions) (res *Response, sl *SettlementsList, err error) { +func (ss *SettlementsService) List(ctx context.Context, slo *SettlementsListOptions) ( + res *Response, + sl *SettlementsList, + err error, +) { res, err = ss.list(ctx, "", "", slo) if err != nil { return @@ -127,13 +131,18 @@ func (ss *SettlementsService) List(ctx context.Context, slo *SettlementsListOpti if err = json.Unmarshal(res.content, &sl); err != nil { return } + return } // GetPayments retrieves all payments included in a settlement. // // See: https://docs.mollie.com/reference/v2/settlements-api/list-settlement-payments -func (ss *SettlementsService) GetPayments(ctx context.Context, id string, slo *SettlementsListOptions) (res *Response, pl *PaymentList, err error) { +func (ss *SettlementsService) GetPayments(ctx context.Context, id string, slo *SettlementsListOptions) ( + res *Response, + pl *PaymentList, + err error, +) { res, err = ss.list(ctx, id, "payments", slo) if err != nil { return @@ -142,13 +151,18 @@ func (ss *SettlementsService) GetPayments(ctx context.Context, id string, slo *S if err = json.Unmarshal(res.content, &pl); err != nil { return } + return } // GetRefunds retrieves all refunds included in a settlement. // // See: https://docs.mollie.com/reference/v2/settlements-api/list-settlement-refunds -func (ss *SettlementsService) GetRefunds(ctx context.Context, id string, slo *SettlementsListOptions) (res *Response, rl *RefundList, err error) { +func (ss *SettlementsService) GetRefunds(ctx context.Context, id string, slo *SettlementsListOptions) ( + res *Response, + rl *RefundList, + err error, +) { res, err = ss.list(ctx, id, "refunds", slo) if err != nil { return @@ -157,13 +171,18 @@ func (ss *SettlementsService) GetRefunds(ctx context.Context, id string, slo *Se if err = json.Unmarshal(res.content, &rl); err != nil { return } + return } // GetChargebacks retrieves all chargebacks included in a settlement. // // See: https://docs.mollie.com/reference/v2/settlements-api/list-settlement-chargebacks -func (ss *SettlementsService) GetChargebacks(ctx context.Context, id string, slo *SettlementsListOptions) (res *Response, cl *ChargebacksList, err error) { +func (ss *SettlementsService) GetChargebacks(ctx context.Context, id string, slo *SettlementsListOptions) ( + res *Response, + cl *ChargebacksList, + err error, +) { res, err = ss.list(ctx, id, "chargebacks", slo) if err != nil { return @@ -172,13 +191,18 @@ func (ss *SettlementsService) GetChargebacks(ctx context.Context, id string, slo if err = json.Unmarshal(res.content, &cl); err != nil { return } + return } // GetCaptures retrieves all captures included in a settlement. // // See: https://docs.mollie.com/reference/v2/settlements-api/list-settlement-captures -func (ss *SettlementsService) GetCaptures(ctx context.Context, id string, slo *SettlementsListOptions) (res *Response, cl *CapturesList, err error) { +func (ss *SettlementsService) GetCaptures(ctx context.Context, id string, slo *SettlementsListOptions) ( + res *Response, + cl *CapturesList, + err error, +) { res, err = ss.list(ctx, id, "captures", slo) if err != nil { return @@ -187,6 +211,7 @@ func (ss *SettlementsService) GetCaptures(ctx context.Context, id string, slo *S if err = json.Unmarshal(res.content, &cl); err != nil { return } + return } @@ -199,10 +224,14 @@ func (ss *SettlementsService) get(ctx context.Context, element string) (res *Res if err = json.Unmarshal(res.content, &s); err != nil { return } + return } -func (ss *SettlementsService) list(ctx context.Context, id string, category string, opts *SettlementsListOptions) (res *Response, err error) { +func (ss *SettlementsService) list(ctx context.Context, id string, category string, opts *SettlementsListOptions) ( + res *Response, + err error, +) { uri := "v2/settlements" if id != "" { @@ -217,5 +246,6 @@ func (ss *SettlementsService) list(ctx context.Context, id string, category stri if err != nil { return } + return } From a419fcc39c4db6adc1fa55c75744ef6c148ff2d1 Mon Sep 17 00:00:00 2001 From: Victor Hugo Avelar Ossorio Date: Wed, 8 Feb 2023 19:25:48 +0000 Subject: [PATCH 24/29] chore(ci): fix linter errors in shipments.go --- mollie/shipments.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/mollie/shipments.go b/mollie/shipments.go index bab6508..eaee09f 100644 --- a/mollie/shipments.go +++ b/mollie/shipments.go @@ -53,6 +53,7 @@ func (ss *ShipmentsService) Get(ctx context.Context, oID string, sID string) (re if err = json.Unmarshal(res.content, &s); err != nil { return } + return } @@ -66,7 +67,11 @@ type CreateShipmentRequest struct { // Create can be used to ship order lines. // // See: https://docs.mollie.com/reference/v2/shipments-api/create-shipment -func (ss *ShipmentsService) Create(ctx context.Context, oID string, cs CreateShipmentRequest) (res *Response, s *Shipment, err error) { +func (ss *ShipmentsService) Create(ctx context.Context, oID string, cs CreateShipmentRequest) ( + res *Response, + s *Shipment, + err error, +) { uri := fmt.Sprintf("v2/orders/%s/shipments", oID) if ss.client.HasAccessToken() && ss.client.config.testing { @@ -81,6 +86,7 @@ func (ss *ShipmentsService) Create(ctx context.Context, oID string, cs CreateShi if err = json.Unmarshal(res.content, &s); err != nil { return } + return } @@ -107,13 +113,18 @@ func (ss *ShipmentsService) List(ctx context.Context, oID string) (res *Response if err = json.Unmarshal(res.content, &sl); err != nil { return } + return } // Update can be used to update the tracking information of a shipment // // See: https://docs.mollie.com/reference/v2/shipments-api/update-shipment -func (ss *ShipmentsService) Update(ctx context.Context, oID string, sID string, st ShipmentTracking) (res *Response, s *Shipment, err error) { +func (ss *ShipmentsService) Update(ctx context.Context, oID string, sID string, st ShipmentTracking) ( + res *Response, + s *Shipment, + err error, +) { u := fmt.Sprintf("v2/orders/%s/shipments/%s", oID, sID) res, err = ss.client.patch(ctx, u, st, nil) @@ -124,5 +135,6 @@ func (ss *ShipmentsService) Update(ctx context.Context, oID string, sID string, if err = json.Unmarshal(res.content, &s); err != nil { return } + return } From 73f04677de7f4b118ea5fb33f363f4e39146eccb Mon Sep 17 00:00:00 2001 From: Victor Hugo Avelar Ossorio Date: Wed, 8 Feb 2023 19:27:40 +0000 Subject: [PATCH 25/29] chore(ci): fix linter errors in subscriptions.go --- mollie/subscriptions.go | 43 +++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/mollie/subscriptions.go b/mollie/subscriptions.go index 6ae3865..bf7e0c8 100644 --- a/mollie/subscriptions.go +++ b/mollie/subscriptions.go @@ -84,13 +84,18 @@ func (ss *SubscriptionsService) Get(ctx context.Context, cID, sID string) (res * if err = json.Unmarshal(res.content, &s); err != nil { return } + return } // Create stores a new subscription for a given customer // // See: https://docs.mollie.com/reference/v2/subscriptions-api/create-subscription -func (ss *SubscriptionsService) Create(ctx context.Context, cID string, sc *Subscription) (res *Response, s *Subscription, err error) { +func (ss *SubscriptionsService) Create(ctx context.Context, cID string, sc *Subscription) ( + res *Response, + s *Subscription, + err error, +) { uri := fmt.Sprintf("v2/customers/%s/subscriptions", cID) if ss.client.HasAccessToken() && ss.client.config.testing { @@ -105,13 +110,18 @@ func (ss *SubscriptionsService) Create(ctx context.Context, cID string, sc *Subs if err = json.Unmarshal(res.content, &s); err != nil { return } + return } // Update changes fields on a subscription object // // See: https://docs.mollie.com/reference/v2/subscriptions-api/update-subscription -func (ss *SubscriptionsService) Update(ctx context.Context, cID, sID string, sc *Subscription) (res *Response, s *Subscription, err error) { +func (ss *SubscriptionsService) Update(ctx context.Context, cID, sID string, sc *Subscription) ( + res *Response, + s *Subscription, + err error, +) { u := fmt.Sprintf("v2/customers/%s/subscriptions/%s", cID, sID) res, err = ss.client.patch(ctx, u, sc, nil) @@ -122,13 +132,18 @@ func (ss *SubscriptionsService) Update(ctx context.Context, cID, sID string, sc if err = json.Unmarshal(res.content, &s); err != nil { return } + return } // Delete cancels a subscription // // See: https://docs.mollie.com/reference/v2/subscriptions-api/cancel-subscription -func (ss *SubscriptionsService) Delete(ctx context.Context, cID, sID string) (res *Response, s *Subscription, err error) { +func (ss *SubscriptionsService) Delete(ctx context.Context, cID, sID string) ( + res *Response, + s *Subscription, + err error, +) { u := fmt.Sprintf("v2/customers/%s/subscriptions/%s", cID, sID) res, err = ss.client.delete(ctx, u, nil) @@ -139,6 +154,7 @@ func (ss *SubscriptionsService) Delete(ctx context.Context, cID, sID string) (re if err = json.Unmarshal(res.content, &s); err != nil { return } + return } @@ -147,7 +163,11 @@ func (ss *SubscriptionsService) Delete(ctx context.Context, cID, sID string) (re // In the case of an OAuth Access Token relies the website profile on the profileId field // // See: https://docs.mollie.com/reference/v2/subscriptions-api/list-all-subscriptions -func (ss *SubscriptionsService) All(ctx context.Context, opts *SubscriptionListOptions) (res *Response, sl *SubscriptionList, err error) { +func (ss *SubscriptionsService) All(ctx context.Context, opts *SubscriptionListOptions) ( + res *Response, + sl *SubscriptionList, + err error, +) { u := "v2/subscriptions" res, err = ss.list(ctx, u, opts) @@ -158,13 +178,18 @@ func (ss *SubscriptionsService) All(ctx context.Context, opts *SubscriptionListO if err = json.Unmarshal(res.content, &sl); err != nil { return } + return } // List retrieves all subscriptions of a customer // // See: https://docs.mollie.com/reference/v2/subscriptions-api/list-subscriptions -func (ss *SubscriptionsService) List(ctx context.Context, cID string, opts *SubscriptionListOptions) (res *Response, sl *SubscriptionList, err error) { +func (ss *SubscriptionsService) List(ctx context.Context, cID string, opts *SubscriptionListOptions) ( + res *Response, + sl *SubscriptionList, + err error, +) { u := fmt.Sprintf("v2/customers/%s/subscriptions", cID) res, err = ss.list(ctx, u, opts) @@ -175,13 +200,18 @@ func (ss *SubscriptionsService) List(ctx context.Context, cID string, opts *Subs if err = json.Unmarshal(res.content, &sl); err != nil { return } + return } // GetPayments retrieves all payments of a specific subscriptions of a customer // // See: https://docs.mollie.com/reference/v2/subscriptions-api/list-subscriptions-payments -func (ss *SubscriptionsService) GetPayments(ctx context.Context, cID, sID string, opts *SubscriptionListOptions) (res *Response, sl *PaymentList, err error) { +func (ss *SubscriptionsService) GetPayments(ctx context.Context, cID, sID string, opts *SubscriptionListOptions) ( + res *Response, + sl *PaymentList, + err error, +) { u := fmt.Sprintf("v2/customers/%s/subscriptions/%s/payments", cID, sID) res, err = ss.list(ctx, u, opts) @@ -192,6 +222,7 @@ func (ss *SubscriptionsService) GetPayments(ctx context.Context, cID, sID string if err = json.Unmarshal(res.content, &sl); err != nil { return } + return } From a6f26cf65cec87d73b85b77551d6e648e6965386 Mon Sep 17 00:00:00 2001 From: Victor Hugo Avelar Ossorio Date: Wed, 8 Feb 2023 19:30:58 +0000 Subject: [PATCH 26/29] chore(test): fix broken tests --- mollie/mollie.go | 4 ++++ mollie/mollie_test.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/mollie/mollie.go b/mollie/mollie.go index 38c96aa..0523684 100644 --- a/mollie/mollie.go +++ b/mollie/mollie.go @@ -200,6 +200,10 @@ func (c *Client) NewAPIRequest(ctx context.Context, method string, uri string, b } } + if ctx == nil { + ctx = context.Background() + } + req, err = http.NewRequestWithContext(ctx, method, url.String(), buf) if err != nil { return diff --git a/mollie/mollie_test.go b/mollie/mollie_test.go index 104df86..625413c 100644 --- a/mollie/mollie_test.go +++ b/mollie/mollie_test.go @@ -422,7 +422,7 @@ func TestClient_Do(t *testing.T) { nil, }, true, - fmt.Errorf("httperror: Get \"\": http: nil Request.URL"), + fmt.Errorf("http_error: Get \"\": http: nil Request.URL"), http.StatusOK, func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") From 291ecff04b77211503e80565f6a3ec296dce12ec Mon Sep 17 00:00:00 2001 From: Victor Hugo Avelar Ossorio Date: Wed, 8 Feb 2023 21:04:18 +0100 Subject: [PATCH 27/29] chore(actions): update actions to commit sha over version --- .github/dependabot.yml | 6 ++++++ .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/golangci-lint.yml | 10 ++++++---- .github/workflows/labeler.yml | 4 ++-- .github/workflows/main.yml | 6 ++++-- .github/workflows/release.yml | 9 +++------ 6 files changed, 22 insertions(+), 15 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 93494e6..a781ad9 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -6,15 +6,21 @@ updates: interval: weekly time: "04:00" open-pull-requests-limit: 10 + reviewers: + - VictorAvelar - package-ecosystem: github-actions directory: '/' schedule: interval: daily target-branch: master + reviewers: + - VictorAvelar - package-ecosystem: docker directory: '/' schedule: interval: weekly target-branch: master + reviewers: + - VictorAvelar diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 6cc207e..e4bf308 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -63,7 +63,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index d96e5d8..40b39ed 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -32,13 +32,15 @@ jobs: golangci: name: Linter runs-on: ubuntu-latest + permissions: + content: read + pull-requests: read steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@39d8d7e78f59cf6b40ac3b9fbebef0c753d7c9e5 name: golangci-lint - - uses: actions/setup-go@v3 + - uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 with: go-version: 1.20.X - - uses: golangci/golangci-lint-action@v3.4.0 + - uses: golangci/golangci-lint-action@08e2f20817b15149a52b5b3ebe7de50aff2ba8c5 with: version: latest - args: --issues-exit-code=0 --new=true --sort-results --skip-dirs-use-default --tests=false diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 63f8c50..e80c1df 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -17,7 +17,7 @@ jobs: pull-requests: write runs-on: ubuntu-latest steps: - - uses: actions/labeler@v4 + - uses: actions/labeler@5c7539237e04b714afd8ad9b4aed733815b9fab4 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" - sync-labels: true \ No newline at end of file + sync-labels: true diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ba23c94..df3dbc2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,13 +29,15 @@ on: jobs: testing: runs-on: ubuntu-latest + permissions: + contents: read strategy: matrix: go: [1.17.x, 1.18.x, 1.19.X, 1.20.x] name: Go ${{ matrix.go }} check steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v3 + - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c + - uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 with: go-version: ${{ matrix.go }} - run: go test -v -failfast ./... diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e08ec1c..b68f844 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,16 +9,13 @@ jobs: goreleaser: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 + - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c with: fetch-depth: 0 - - name: Set up Go - uses: actions/setup-go@v3 + - uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 with: go-version: 1.20.x - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v4 + - uses: goreleaser/goreleaser-action@f82d6c1c344bcacabba2c841718984797f664a6b with: version: latest args: release --rm-dist From 56fda8eeed82ee81bc5cfe2a0c9f9014874d4a26 Mon Sep 17 00:00:00 2001 From: Victor Hugo Avelar Ossorio Date: Wed, 8 Feb 2023 20:25:57 +0000 Subject: [PATCH 28/29] chore(meta): add CII badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f9cc5c4..087c7fa 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ [![Go Reference](https://pkg.go.dev/badge/github.com/VictorAvelar/mollie-api-go/v3/mollie.svg)](https://pkg.go.dev/github.com/VictorAvelar/mollie-api-go/v3/mollie) [![Go Report Card](https://goreportcard.com/badge/github.com/VictorAvelar/mollie-api-go/v3)](https://goreportcard.com/report/github.com/VictorAvelar/mollie-api-go/v3) +[![OpenSSF Best Practices](https://bestpractices.coreinfrastructure.org/projects/3522/badge)](https://bestpractices.coreinfrastructure.org/projects/3522) Accepting [iDEAL](https://www.mollie.com/payments/ideal/), [Apple Pay](https://www.mollie.com/payments/apple-pay), [Bancontact](https://www.mollie.com/payments/bancontact/), [SOFORT Banking](https://www.mollie.com/payments/sofort/), [Creditcard](https://www.mollie.com/payments/credit-card/), [SEPA Bank transfer](https://www.mollie.com/payments/bank-transfer/), [SEPA Direct debit](https://www.mollie.com/payments/direct-debit/), [PayPal](https://www.mollie.com/payments/paypal/), [Belfius Direct Net](https://www.mollie.com/payments/belfius/), [KBC/CBC](https://www.mollie.com/payments/kbc-cbc/), [paysafecard](https://www.mollie.com/payments/paysafecard/), [Giftcards](https://www.mollie.com/payments/gift-cards/), [Giropay](https://www.mollie.com/payments/giropay/), [EPS](https://www.mollie.com/payments/eps/) and [Przelewy24](https://www.mollie.com/payments/przelewy24/) online payments without fixed monthly costs or any punishing registration procedures. Just use the Mollie API to receive payments directly on your website or easily refund transactions to your customers. From 71847e629155fb812878354d0d9ad5fa09715624 Mon Sep 17 00:00:00 2001 From: Victor Hugo Avelar Ossorio Date: Wed, 8 Feb 2023 20:35:06 +0000 Subject: [PATCH 29/29] chore(docs): update generated documentation --- docs/README.md | 800 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 733 insertions(+), 67 deletions(-) diff --git a/docs/README.md b/docs/README.md index 5957831..ba8e228 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,7 +1,7 @@ # mollie -- -import "github.com/VictorAvelar/mollie-api-golang/v3/mollie" + import "github.com/VictorAvelar/mollie-api-golang/v3/mollie" Package mollie is a wrapper around Mollie's REST API. @@ -119,6 +119,346 @@ type ApplicationFee struct { ApplicationFee allows you to split a payment between a platform and connected merchant accounts. +#### type Balance + +```go +type Balance struct { + ID string `json:"id,omitempty"` + Resource string `json:"resource,omitempty"` + Currency string `json:"currency,omitempty"` + TransferReference string `json:"transferReference,omitempty"` + Status BalanceStatus `json:"status,omitempty"` + TransferFrequency TransferFrequency `json:"transferFrequency,omitempty"` + TransferThreshold *Amount `json:"transferThreshold,omitempty"` + AvailableAmount *Amount `json:"availableAmount,omitempty"` + PendingAmount *Amount `json:"pendingAmount,omitempty"` + TransferDestination *TransferDestination `json:"transferDestination,omitempty"` + CreatedAt *time.Time `json:"createdAt,omitempty"` + Links BalanceLinks `json:"_links,omitempty"` +} +``` + +Balance holds the payments processed with Mollie once fees have been deducted. + +#### type BalanceAmount + +```go +type BalanceAmount struct { + Amount *Amount `json:"amount,omitempty"` +} +``` + +BalanceAmount wraps the std Amount type. + +#### type BalanceGroupingFormat + +```go +type BalanceGroupingFormat string +``` + +BalanceGroupingFormat defines a grouping mechanism for transactions included in +a balance report. + +```go +const ( + StatusBalancesGrouping BalanceGroupingFormat = "status-balances" + TransactionCategoriesGrouping BalanceGroupingFormat = "transaction-categories" +) +``` + +Supported transaction grouping. + +#### type BalanceLinks + +```go +type BalanceLinks struct { + Self *URL `json:"self,omitempty"` + Documentation *URL `json:"documentation,omitempty"` +} +``` + +BalanceLinks holds URL objects relevant to the balance. + +#### type BalanceListOptions + +```go +type BalanceListOptions struct { + Currency string `url:"currency,omitempty"` + From string `url:"from,omitempty"` + Limit int `url:"limit,omitempty"` +} +``` + +BalanceListOptions contains valid query parameters for the list balances +endpoint. + +#### type BalanceReport + +```go +type BalanceReport struct { + Resource string `json:"resource,omitempty"` + BalanceID string `json:"balanceId,omitempty"` + TimeZone string `json:"timeZone,omitempty"` + From *ShortDate `json:"from,omitempty"` + Until *ShortDate `json:"until,omitempty"` + Totals *BalanceReportTotalsGrouping `json:"totals,omitempty"` + Grouping BalanceGroupingFormat `json:"grouping,omitempty"` + Links BalanceReportLinks `json:"_links,omitempty"` +} +``` + +BalanceReport contains the common fields between different balance grouping +options. + +#### type BalanceReportDetail + +```go +type BalanceReportDetail struct { + Open *BalanceAmount `json:"open,omitempty"` + Pending *BalanceAmount `json:"pending,omitempty"` + MovedToAvailable *BalanceAmount `json:"movedToAvailable,omitempty"` + ImmediatelyAvailable *BalanceAmount `json:"immediatelyAvailable,omitempty"` + Close *BalanceAmount `json:"close,omitempty"` +} +``` + +BalanceReportDetail contains the breakdown categories when grouping balance +transactions. + +#### type BalanceReportLinks + +```go +type BalanceReportLinks struct { + Self *URL `json:"self,omitempty"` + Documentation *URL `json:"documentation,omitempty"` +} +``` + +BalanceReportLinks holds URL objects relevant to the balance report. + +#### type BalanceReportOptions + +```go +type BalanceReportOptions struct { + Grouping BalanceGroupingFormat `url:"grouping,omitempty"` + From *ShortDate `url:"from,omitempty"` + Until *ShortDate `url:"until,omitempty"` +} +``` + +BalanceReportOptions contains valid query parameters for the list balances +endpoint. + +#### type BalanceReportTotalsGrouping + +```go +type BalanceReportTotalsGrouping struct { + PendingBalance *BalanceReportDetail `json:"pendingBalance,omitempty"` + AvailableBalance *BalanceReportDetail `json:"availableBalance,omitempty"` + Open *BalanceReportDetail `json:"open,omitempty"` + Payments *BalanceReportDetail `json:"payments,omitempty"` + Refunds *BalanceReportDetail `json:"refunds,omitempty"` + Chargebacks *BalanceReportDetail `json:"chargebacks,omitempty"` + Capital *BalanceReportDetail `json:"capital,omitempty"` + Transfers *BalanceReportDetail `json:"transfers,omitempty"` + FeePrePayments *BalanceReportDetail `json:"fee-prepayments,omitempty"` + Corrections *BalanceReportDetail `json:"corrections,omitempty"` + Close *BalanceReportDetail `json:"close,omitempty"` +} +``` + +BalanceReportTotalsGrouping contains the per totals grouped balances for the +requested period. + +#### type BalanceStatus + +```go +type BalanceStatus string +``` + +BalanceStatus reflects whether a balance is operational or not. + +```go +const ( + BalanceActive BalanceStatus = "active" + BalanceInactive BalanceStatus = "inactive" +) +``` + +Possible values for type BalanceStatus. + +#### type BalanceTransaction + +```go +type BalanceTransaction struct { + Resource string `json:"resource,omitempty"` + ID string `json:"id,omitempty"` + TransactionType string `json:"transactionType,omitempty"` + ResultAmount *Amount `json:"resultAmount,omitempty"` + InitialAmount *Amount `json:"initialAmount,omitempty"` + Deductions *Amount `json:"deductions,omitempty"` + CreatedAt *time.Time `json:"createdAt,omitempty"` + Context ContextValues `json:"context,omitempty"` +} +``` + +BalanceTransaction represents a the movement on your balance. + +#### type BalanceTransactionsList + +```go +type BalanceTransactionsList struct { + Count int `json:"count,omitempty"` + Embedded struct { + BalanceTransactions []*BalanceTransaction `json:"balance_transactions,omitempty"` + } `json:"_embedded,omitempty"` + Links PaginationLinks `json:"_links,omitempty"` +} +``` + +BalanceTransactionsList contains an array of embedded transactions. + +#### type BalanceTransactionsListOptions + +```go +type BalanceTransactionsListOptions struct { + From string `url:"from,omitempty"` + Limit int `url:"limit,omitempty"` +} +``` + +BalanceTransactionsListOptions are valid query parameters for list balance +transactions requests. + +#### type BalancesList + +```go +type BalancesList struct { + Count int `json:"count,omitempty"` + Embedded struct { + Balances []*Balance `json:"balances,omitempty"` + } `json:"_embedded,omitempty"` + Links PaginationLinks `json:"_links,omitempty"` +} +``` + +BalancesList describes a list of captures. + +#### type BalancesService + +```go +type BalancesService service +``` + +BalancesService allows you to retrieve real-time as well as historical +information about your Mollie balance. + +Works with Organization access tokens and App access tokens. + +The API is in **BETA** so be careful and expect changes. + +See: + +#### func (*BalancesService) Get + +```go +func (bs *BalancesService) Get(ctx context.Context, balance string) (res *Response, b *Balance, err error) +``` + +GetBalance retrieves a balance by its id. + +See: + +#### func (*BalancesService) GetPrimaryReport + +```go +func (bs *BalancesService) GetPrimaryReport(ctx context.Context, options *BalanceReportOptions) ( + res *Response, + br *BalanceReport, + err error, +) +``` + +GetPrimaryReport returns the report for the primary balance. + +See: + + +#### func (*BalancesService) GetPrimaryTransactionsList + +```go +func (bs *BalancesService) GetPrimaryTransactionsList(ctx context.Context, options *BalanceTransactionsListOptions) ( + res *Response, + btl *BalanceTransactionsList, + err error, +) +``` + +GetPrimaryTransactionsList retrieves the list of movements (transactions) for +the primary balance of the account. + +See: + + +#### func (*BalancesService) GetReport + +```go +func (bs *BalancesService) GetReport(ctx context.Context, balance string, options *BalanceReportOptions) ( + res *Response, + br *BalanceReport, + err error, +) +``` + +GetReport returns the balance report for the specified balance id. + +See: + +#### func (*BalancesService) GetTransactionsList + +```go +func (bs *BalancesService) GetTransactionsList( + ctx context.Context, + balance string, + options *BalanceTransactionsListOptions, +) ( + res *Response, + btl *BalanceTransactionsList, + err error, +) +``` + +GetTransactionsList retrieves a list of movements (transactions) for the +specified balance. + +See: + +#### func (*BalancesService) List + +```go +func (bs *BalancesService) List(ctx context.Context, options *BalanceListOptions) ( + res *Response, + bl *BalancesList, + err error, +) +``` + +List retrieves all the organization’s balances, including the primary balance, +ordered from newest to oldest. + +See: + +#### func (*BalancesService) Primary + +```go +func (bs *BalancesService) Primary(ctx context.Context) (res *Response, b *Balance, err error) +``` + +Primary retrieves the primary balance. This is the balance of your account’s +primary currency, where all payments are settled to by default. + +See: + #### type BaseError ```go @@ -365,7 +705,11 @@ ChargebacksService instance operates over chargeback resources. #### func (*ChargebacksService) Get ```go -func (cs *ChargebacksService) Get(ctx context.Context, payment, chargeback string, opts *ChargebackOptions) (res *Response, p *Chargeback, err error) +func (cs *ChargebacksService) Get(ctx context.Context, payment, chargeback string, opts *ChargebackOptions) ( + res *Response, + p *Chargeback, + err error, +) ``` Get retrieves a single chargeback by its ID. Note the original payment’s ID is @@ -376,7 +720,11 @@ See: #### func (*ChargebacksService) List ```go -func (cs *ChargebacksService) List(ctx context.Context, options *ChargebacksListOptions) (res *Response, cl *ChargebacksList, err error) +func (cs *ChargebacksService) List(ctx context.Context, options *ChargebacksListOptions) ( + res *Response, + cl *ChargebacksList, + err error, +) ``` List retrieves a list of chargebacks associated with your account/organization. @@ -386,7 +734,11 @@ See: #### func (*ChargebacksService) ListForPayment ```go -func (cs *ChargebacksService) ListForPayment(ctx context.Context, payment string, options *ChargebacksListOptions) (res *Response, cl *ChargebacksList, err error) +func (cs *ChargebacksService) ListForPayment(ctx context.Context, payment string, options *ChargebacksListOptions) ( + res *Response, + cl *ChargebacksList, + err error, +) ``` ListForPayment retrieves a list of chargebacks associated with a single payment. @@ -419,6 +771,7 @@ type Client struct { Onboarding *OnboardingService PaymentLinks *PaymentLinksService Partners *PartnerService + Balances *BalancesService } ``` @@ -464,7 +817,10 @@ See: #### func (*Client) NewAPIRequest ```go -func (c *Client) NewAPIRequest(ctx context.Context, method string, uri string, body interface{}) (req *http.Request, err error) +func (c *Client) NewAPIRequest(ctx context.Context, method string, uri string, body interface{}) ( + req *http.Request, + err error, +) ``` NewAPIRequest is a wrapper around the http.NewRequest function. @@ -525,6 +881,23 @@ client is meant to create requests for testing, reqIdem to enable the request idempotency beta feature, and auth to indicate the authentication method we want to use. +#### type ContextValue + +```go +type ContextValue string +``` + +ContextValue represents a relevant value in the system associated with a +BalanceTransaction. + +#### type ContextValues + +```go +type ContextValues map[TransactionType]ContextValue +``` + +ContextValues is a map of TransactionType to ContextValue. + #### type CreateShipmentRequest ```go @@ -622,7 +995,11 @@ See: #### func (*CustomersService) CreatePayment ```go -func (cs *CustomersService) CreatePayment(ctx context.Context, id string, p Payment) (res *Response, pp *Payment, err error) +func (cs *CustomersService) CreatePayment(ctx context.Context, id string, p Payment) ( + res *Response, + pp *Payment, + err error, +) ``` CreatePayment creates a payment for the customer. @@ -655,7 +1032,11 @@ See: #### func (*CustomersService) GetPayments ```go -func (cs *CustomersService) GetPayments(ctx context.Context, id string, options *CustomersListOptions) (res *Response, pl *PaymentList, err error) +func (cs *CustomersService) GetPayments(ctx context.Context, id string, options *CustomersListOptions) ( + res *Response, + pl *PaymentList, + err error, +) ``` GetPayments retrieves all payments linked to the customer. @@ -665,7 +1046,11 @@ See: #### func (*CustomersService) List ```go -func (cs *CustomersService) List(ctx context.Context, options *CustomersListOptions) (res *Response, cl *CustomersList, err error) +func (cs *CustomersService) List(ctx context.Context, options *CustomersListOptions) ( + res *Response, + cl *CustomersList, + err error, +) ``` List retrieves all customers created. @@ -675,7 +1060,11 @@ See: #### func (*CustomersService) Update ```go -func (cs *CustomersService) Update(ctx context.Context, id string, c Customer) (res *Response, cc *Customer, err error) +func (cs *CustomersService) Update(ctx context.Context, id string, c Customer) ( + res *Response, + cc *Customer, + err error, +) ``` Update an existing customer. @@ -717,7 +1106,7 @@ const ( EmbedPayment EmbedValue = "payments" EmbedRefund EmbedValue = "refunds" EmbedShipments EmbedValue = "shipments" - EmbedChangebacks EmbedValue = "chanrgebacks" + EmbedChargebacks EmbedValue = "chargebacks" ) ``` @@ -851,7 +1240,8 @@ const ( ) ``` -Supported gift card issuers. +Supported gift card issuers. #nosec G101 -- This are the brands issuing gift +cards. #### type GiftCardIssuerStatus @@ -993,7 +1383,11 @@ Get retrieve details of an invoice, using the invoice’s identifier. #### func (*InvoicesService) List ```go -func (is *InvoicesService) List(ctx context.Context, options *InvoicesListOptions) (res *Response, il *InvoicesList, err error) +func (is *InvoicesService) List(ctx context.Context, options *InvoicesListOptions) ( + res *Response, + il *InvoicesList, + err error, +) ``` List retrieves a list of invoices associated with your account/organization. @@ -1203,7 +1597,11 @@ MandatesService operates over customer mandates endpoints. #### func (*MandatesService) Create ```go -func (ms *MandatesService) Create(ctx context.Context, customer string, mandate Mandate) (res *Response, mr *Mandate, err error) +func (ms *MandatesService) Create(ctx context.Context, customer string, mandate Mandate) ( + res *Response, + mr *Mandate, + err error, +) ``` Create a mandate for a specific customer. @@ -1227,7 +1625,11 @@ See: #### func (*MandatesService) List ```go -func (ms *MandatesService) List(ctx context.Context, customer string, options *MandatesListOptions) (res *Response, ml *MandatesList, err error) +func (ms *MandatesService) List(ctx context.Context, customer string, options *MandatesListOptions) ( + res *Response, + ml *MandatesList, + err error, +) ``` List retrieves all mandates for the given customerId, ordered from newest to @@ -1271,7 +1673,11 @@ miscellaneous API endpoints section. #### func (*MiscellaneousService) ApplePaymentSession ```go -func (ms *MiscellaneousService) ApplePaymentSession(ctx context.Context, asr *ApplePaymentSessionRequest) (res *Response, aps *ApplePaymentSession, err error) +func (ms *MiscellaneousService) ApplePaymentSession(ctx context.Context, asr *ApplePaymentSessionRequest) ( + res *Response, + aps *ApplePaymentSession, + err error, +) ``` ApplePaymentSession returns an Apple Payment Session object valid for one @@ -1685,7 +2091,10 @@ See #### func (*OrdersService) CancelOrderLines ```go -func (ors *OrdersService) CancelOrderLines(ctx context.Context, orderID string, orderLines []OrderLine) (res *Response, err error) +func (ors *OrdersService) CancelOrderLines(ctx context.Context, orderID string, orderLines []OrderLine) ( + res *Response, + err error, +) ``` CancelOrderLines can be used to cancel one or more order lines that were @@ -1697,7 +2106,11 @@ See #### func (*OrdersService) Create ```go -func (ors *OrdersService) Create(ctx context.Context, ord Order, opts *OrderOptions) (res *Response, order *Order, err error) +func (ors *OrdersService) Create(ctx context.Context, ord Order, opts *OrderOptions) ( + res *Response, + order *Order, + err error, +) ``` Create an order will automatically create the required payment to allow your @@ -1708,7 +2121,11 @@ See #### func (*OrdersService) CreateOrderPayment ```go -func (ors *OrdersService) CreateOrderPayment(ctx context.Context, orderID string, ordPay *OrderPayment) (res *Response, payment *Payment, err error) +func (ors *OrdersService) CreateOrderPayment(ctx context.Context, orderID string, ordPay *OrderPayment) ( + res *Response, + payment *Payment, + err error, +) ``` CreateOrderPayment can only be created while the status of the order is created, @@ -1720,7 +2137,11 @@ See #### func (*OrdersService) CreateOrderRefund ```go -func (ors *OrdersService) CreateOrderRefund(ctx context.Context, orderID string, order *Order) (res *Response, refund *Refund, err error) +func (ors *OrdersService) CreateOrderRefund(ctx context.Context, orderID string, order *Order) ( + res *Response, + refund *Refund, + err error, +) ``` CreateOrderRefund using the Orders API, refunds should be made against the @@ -1731,7 +2152,11 @@ See #### func (*OrdersService) Get ```go -func (ors *OrdersService) Get(ctx context.Context, orID string, opts *OrderOptions) (res *Response, order *Order, err error) +func (ors *OrdersService) Get(ctx context.Context, orID string, opts *OrderOptions) ( + res *Response, + order *Order, + err error, +) ``` Get retrieve a single order by its ID. @@ -1741,7 +2166,11 @@ See #### func (*OrdersService) List ```go -func (ors *OrdersService) List(ctx context.Context, opts *OrderListOptions) (res *Response, ordList *OrderList, err error) +func (ors *OrdersService) List(ctx context.Context, opts *OrderListOptions) ( + res *Response, + ordList *OrderList, + err error, +) ``` List is to retrieve all orders. @@ -1751,7 +2180,11 @@ See #### func (*OrdersService) ListOrderRefunds ```go -func (ors *OrdersService) ListOrderRefunds(ctx context.Context, orderID string, opts *OrderListRefundOptions) (res *Response, orderListRefund *OrderListRefund, err error) +func (ors *OrdersService) ListOrderRefunds(ctx context.Context, orderID string, opts *OrderListRefundOptions) ( + res *Response, + orderListRefund *OrderListRefund, + err error, +) ``` ListOrderRefunds retrieve all order refunds. @@ -1761,7 +2194,11 @@ See #### func (*OrdersService) Update ```go -func (ors *OrdersService) Update(ctx context.Context, orderID string, ord Order) (res *Response, order *Order, err error) +func (ors *OrdersService) Update(ctx context.Context, orderID string, ord Order) ( + res *Response, + order *Order, + err error, +) ``` Update is used to update the billing and/or shipping address of an order. @@ -1771,7 +2208,15 @@ See #### func (*OrdersService) UpdateOrderLine ```go -func (ors *OrdersService) UpdateOrderLine(ctx context.Context, orderID string, orderLineID string, orderLine OrderLine) (res *Response, order *Order, err error) +func (ors *OrdersService) UpdateOrderLine( + ctx context.Context, + orderID string, + orderLineID string, + orderLine OrderLine) ( + res *Response, + order *Order, + err error, +) ``` UpdateOrderLine can be used to update an order line. @@ -1873,7 +2318,11 @@ GetCurrent retrieve the currently authenticated organization. #### func (*OrganizationsService) GetPartnerStatus ```go -func (os *OrganizationsService) GetPartnerStatus(ctx context.Context) (res *Response, ops *OrganizationPartnerStatus, err error) +func (os *OrganizationsService) GetPartnerStatus(ctx context.Context) ( + res *Response, + ops *OrganizationPartnerStatus, + err error, +) ``` GetPartnerStatus retrieves details about the partner status of the currently @@ -1946,7 +2395,11 @@ PartnerService operates over the partners API. #### func (*PartnerService) Get ```go -func (ps *PartnerService) Get(ctx context.Context, id string, opts *GetPartnerClientOptions) (res *Response, pc *PartnerClient, err error) +func (ps *PartnerService) Get(ctx context.Context, id string, opts *GetPartnerClientOptions) ( + res *Response, + pc *PartnerClient, + err error, +) ``` Get retrieves a single client, linked to your partner account, by its ID. @@ -1956,7 +2409,11 @@ See: #### func (*PartnerService) List ```go -func (ps *PartnerService) List(ctx context.Context, opts *ListPartnerClientsOptions) (res *Response, pc *PartnerClientList, err error) +func (ps *PartnerService) List(ctx context.Context, opts *ListPartnerClientsOptions) ( + res *Response, + pc *PartnerClientList, + err error, +) ``` List retrieves all clients. @@ -2220,7 +2677,11 @@ PaymentLinksService operates over the payment link resource. #### func (*PaymentLinksService) Create ```go -func (pls *PaymentLinksService) Create(ctx context.Context, p PaymentLink, opts *PaymentLinkOptions) (res *Response, np *PaymentLink, err error) +func (pls *PaymentLinksService) Create(ctx context.Context, p PaymentLink, opts *PaymentLinkOptions) ( + res *Response, + np *PaymentLink, + err error, +) ``` Create generates payment links that by default, unlike regular payments, do not @@ -2241,7 +2702,11 @@ See: #### func (*PaymentLinksService) List ```go -func (pls *PaymentLinksService) List(ctx context.Context, opts *PaymentLinkOptions) (res *Response, pl *PaymentLinksList, err error) +func (pls *PaymentLinksService) List(ctx context.Context, opts *PaymentLinkOptions) ( + res *Response, + pl *PaymentLinksList, + err error, +) ``` List retrieves all payments links created with the current website profile, @@ -2284,7 +2749,7 @@ const ( IDeal PaymentMethod = "ideal" KBC PaymentMethod = "kbc" KlarnaPayLater PaymentMethod = "klarnapaylater" - KlarnaLiceit PaymentMethod = "klarnaliceit" + KlarnaSliceIt PaymentMethod = "klarnasliceit" MyBank PaymentMethod = "mybank" PayPal PaymentMethod = "paypal" PaySafeCard PaymentMethod = "paysafecard" @@ -2421,7 +2886,11 @@ PaymentMethodsService operates on methods endpoints. #### func (*PaymentMethodsService) All ```go -func (ms *PaymentMethodsService) All(ctx context.Context, options *PaymentMethodsListOptions) (res *Response, pm *PaymentMethodsList, err error) +func (ms *PaymentMethodsService) All(ctx context.Context, options *PaymentMethodsListOptions) ( + res *Response, + pm *PaymentMethodsList, + err error, +) ``` All retrieves all the payment methods enabled for your account/organization. @@ -2431,7 +2900,11 @@ See: #### func (*PaymentMethodsService) Get ```go -func (ms *PaymentMethodsService) Get(ctx context.Context, id PaymentMethod, options *PaymentMethodOptions) (res *Response, pmd *PaymentMethodDetails, err error) +func (ms *PaymentMethodsService) Get(ctx context.Context, id PaymentMethod, options *PaymentMethodOptions) ( + res *Response, + pmd *PaymentMethodDetails, + err error, +) ``` Get returns information about the payment method specified by id, it also @@ -2443,7 +2916,11 @@ See: #### func (*PaymentMethodsService) List ```go -func (ms *PaymentMethodsService) List(ctx context.Context, options *PaymentMethodsListOptions) (res *Response, pm *PaymentMethodsList, err error) +func (ms *PaymentMethodsService) List(ctx context.Context, options *PaymentMethodsListOptions) ( + res *Response, + pm *PaymentMethodsList, + err error, +) ``` List retrieves all enabled payment methods. @@ -2486,17 +2963,25 @@ See: #### func (*PaymentsService) Create ```go -func (ps *PaymentsService) Create(ctx context.Context, p Payment, opts *PaymentOptions) (res *Response, np *Payment, err error) +func (ps *PaymentsService) Create(ctx context.Context, p Payment, opts *PaymentOptions) ( + res *Response, + np *Payment, + err error, +) ``` Create stores a new payment object attached to your Mollie account. -See: # +See: #### func (*PaymentsService) Get ```go -func (ps *PaymentsService) Get(ctx context.Context, id string, opts *PaymentOptions) (res *Response, p *Payment, err error) +func (ps *PaymentsService) Get(ctx context.Context, id string, opts *PaymentOptions) ( + res *Response, + p *Payment, + err error, +) ``` Get retrieves a single payment object by its payment token. @@ -2504,7 +2989,11 @@ Get retrieves a single payment object by its payment token. #### func (*PaymentsService) List ```go -func (ps *PaymentsService) List(ctx context.Context, opts *ListPaymentOptions) (res *Response, pl *PaymentList, err error) +func (ps *PaymentsService) List(ctx context.Context, opts *ListPaymentOptions) ( + res *Response, + pl *PaymentList, + err error, +) ``` List retrieves a list of payments associated with your account/organization. @@ -2519,7 +3008,7 @@ func (ps *PaymentsService) Update(ctx context.Context, id string, up Payment) (r Update can be used to update some details of a created payment. -See: # +See: #### type Permission @@ -2778,18 +3267,24 @@ API calls and transactions. #### func (*ProfilesService) DisableGiftCardIssuer ```go -func (ps *ProfilesService) DisableGiftCardIssuer(ctx context.Context, profileID string, issuer GiftCardIssuer) (res *Response, err error) +func (ps *ProfilesService) DisableGiftCardIssuer(ctx context.Context, profileID string, issuer GiftCardIssuer) ( + res *Response, + err error, +) ``` -DisableGiftCardIssuer deactivates the requested giftcard issuer for the provided -profile id. +DisableGiftCardIssuer deactivates the requested gift card issuer for the +provided profile id. See: #### func (*ProfilesService) DisableGiftCardIssuerForCurrent ```go -func (ps *ProfilesService) DisableGiftCardIssuerForCurrent(ctx context.Context, issuer GiftCardIssuer) (res *Response, err error) +func (ps *ProfilesService) DisableGiftCardIssuerForCurrent(ctx context.Context, issuer GiftCardIssuer) ( + res *Response, + err error, +) ``` DisableGiftCardIssuerForCurrent deactivates the specified issuer for the current @@ -2800,7 +3295,10 @@ See: @@ -2820,7 +3322,11 @@ See: #### func (*ProfilesService) EnableGiftCardIssuerForCurrent ```go -func (ps *ProfilesService) EnableGiftCardIssuerForCurrent(ctx context.Context, issuer GiftCardIssuer) (res *Response, gc *GiftCardEnabled, err error) +func (ps *ProfilesService) EnableGiftCardIssuerForCurrent(ctx context.Context, issuer GiftCardIssuer) ( + res *Response, + gc *GiftCardEnabled, + err error, +) ``` EnableGiftCardIssuerForCurrent activates the specified issuer for the current @@ -2831,7 +3337,11 @@ See: #### func (*ProfilesService) EnablePaymentMethod ```go -func (ps *ProfilesService) EnablePaymentMethod(ctx context.Context, id string, pm PaymentMethod) (res *Response, pmi *PaymentMethodDetails, err error) +func (ps *ProfilesService) EnablePaymentMethod(ctx context.Context, id string, pm PaymentMethod) ( + res *Response, + pmi *PaymentMethodDetails, + err error, +) ``` EnablePaymentMethod enables a payment method on a specific or authenticated @@ -2848,7 +3358,11 @@ Get retrieves the a profile by ID. #### func (*ProfilesService) List ```go -func (ps *ProfilesService) List(ctx context.Context, opts *ProfileListOptions) (res *Response, pl *ProfileList, err error) +func (ps *ProfilesService) List(ctx context.Context, opts *ProfileListOptions) ( + res *Response, + pl *ProfileList, + err error, +) ``` List returns all the profiles for the authenticated account. @@ -2989,7 +3503,11 @@ the refund’s status is either queued or pending. See #### func (*RefundsService) Create ```go -func (rs *RefundsService) Create(ctx context.Context, paymentID string, re Refund, options *RefundOptions) (res *Response, rf *Refund, err error) +func (rs *RefundsService) Create(ctx context.Context, paymentID string, re Refund, options *RefundOptions) ( + res *Response, + rf *Refund, + err error, +) ``` Create a refund payment request. @@ -2999,7 +3517,11 @@ See . #### func (*RefundsService) Get ```go -func (rs *RefundsService) Get(ctx context.Context, paymentID, refundID string, opts *RefundOptions) (res *Response, refund *Refund, err error) +func (rs *RefundsService) Get(ctx context.Context, paymentID, refundID string, opts *RefundOptions) ( + res *Response, + refund *Refund, + err error, +) ``` Get retrieve a single refund by its ID. @@ -3010,7 +3532,11 @@ refunds endpoint. #### func (*RefundsService) ListRefund ```go -func (rs *RefundsService) ListRefund(ctx context.Context, opts *ListRefundOptions) (res *Response, rl *RefundList, err error) +func (rs *RefundsService) ListRefund(ctx context.Context, opts *ListRefundOptions) ( + res *Response, + rl *RefundList, + err error, +) ``` ListRefund calls the top level . @@ -3020,11 +3546,15 @@ See . #### func (*RefundsService) ListRefundPayment ```go -func (rs *RefundsService) ListRefundPayment(ctx context.Context, paymentID string, opts *ListRefundOptions) (res *Response, rl *RefundList, err error) +func (rs *RefundsService) ListRefundPayment(ctx context.Context, paymentID string, opts *ListRefundOptions) ( + res *Response, + rl *RefundList, + err error, +) ``` ListRefundPayment calls the payment-specific -*paymentId*/refunds. +. Only refunds for that specific payment are returned. See: @@ -3213,7 +3743,11 @@ See: #### func (*SettlementsService) GetCaptures ```go -func (ss *SettlementsService) GetCaptures(ctx context.Context, id string, slo *SettlementsListOptions) (res *Response, cl *CapturesList, err error) +func (ss *SettlementsService) GetCaptures(ctx context.Context, id string, slo *SettlementsListOptions) ( + res *Response, + cl *CapturesList, + err error, +) ``` GetCaptures retrieves all captures included in a settlement. @@ -3224,7 +3758,11 @@ See: #### func (*SettlementsService) GetChargebacks ```go -func (ss *SettlementsService) GetChargebacks(ctx context.Context, id string, slo *SettlementsListOptions) (res *Response, cl *ChargebacksList, err error) +func (ss *SettlementsService) GetChargebacks(ctx context.Context, id string, slo *SettlementsListOptions) ( + res *Response, + cl *ChargebacksList, + err error, +) ``` GetChargebacks retrieves all chargebacks included in a settlement. @@ -3235,7 +3773,11 @@ See: #### func (*SettlementsService) GetPayments ```go -func (ss *SettlementsService) GetPayments(ctx context.Context, id string, slo *SettlementsListOptions) (res *Response, pl *PaymentList, err error) +func (ss *SettlementsService) GetPayments(ctx context.Context, id string, slo *SettlementsListOptions) ( + res *Response, + pl *PaymentList, + err error, +) ``` GetPayments retrieves all payments included in a settlement. @@ -3246,7 +3788,11 @@ See: #### func (*SettlementsService) GetRefunds ```go -func (ss *SettlementsService) GetRefunds(ctx context.Context, id string, slo *SettlementsListOptions) (res *Response, rl *RefundList, err error) +func (ss *SettlementsService) GetRefunds(ctx context.Context, id string, slo *SettlementsListOptions) ( + res *Response, + rl *RefundList, + err error, +) ``` GetRefunds retrieves all refunds included in a settlement. @@ -3257,7 +3803,11 @@ See: #### func (*SettlementsService) List ```go -func (ss *SettlementsService) List(ctx context.Context, slo *SettlementsListOptions) (res *Response, sl *SettlementsList, err error) +func (ss *SettlementsService) List(ctx context.Context, slo *SettlementsListOptions) ( + res *Response, + sl *SettlementsList, + err error, +) ``` List retrieves all settlements, ordered from new to old @@ -3355,7 +3905,11 @@ ShipmentsService operates on shipments endpoints. #### func (*ShipmentsService) Create ```go -func (ss *ShipmentsService) Create(ctx context.Context, oID string, cs CreateShipmentRequest) (res *Response, s *Shipment, err error) +func (ss *ShipmentsService) Create(ctx context.Context, oID string, cs CreateShipmentRequest) ( + res *Response, + s *Shipment, + err error, +) ``` Create can be used to ship order lines. @@ -3370,7 +3924,7 @@ func (ss *ShipmentsService) Get(ctx context.Context, oID string, sID string) (re Get retrieves a single shipment and the order lines shipped by a shipment’s ID. -See: # +See: #### func (*ShipmentsService) List @@ -3385,7 +3939,11 @@ See: #### func (*ShipmentsService) Update ```go -func (ss *ShipmentsService) Update(ctx context.Context, oID string, sID string, st ShipmentTracking) (res *Response, s *Shipment, err error) +func (ss *ShipmentsService) Update(ctx context.Context, oID string, sID string, st ShipmentTracking) ( + res *Response, + s *Shipment, + err error, +) ``` Update can be used to update the tracking information of a shipment @@ -3520,7 +4078,11 @@ SubscriptionsService operates over subscriptions resource. #### func (*SubscriptionsService) All ```go -func (ss *SubscriptionsService) All(ctx context.Context, opts *SubscriptionListOptions) (res *Response, sl *SubscriptionList, err error) +func (ss *SubscriptionsService) All(ctx context.Context, opts *SubscriptionListOptions) ( + res *Response, + sl *SubscriptionList, + err error, +) ``` All retrieves all subscriptions, ordered from newest to oldest. By using an API @@ -3534,7 +4096,11 @@ See: #### func (*SubscriptionsService) Create ```go -func (ss *SubscriptionsService) Create(ctx context.Context, cID string, sc *Subscription) (res *Response, s *Subscription, err error) +func (ss *SubscriptionsService) Create(ctx context.Context, cID string, sc *Subscription) ( + res *Response, + s *Subscription, + err error, +) ``` Create stores a new subscription for a given customer @@ -3544,7 +4110,11 @@ See: #### func (*SubscriptionsService) GetPayments ```go -func (ss *SubscriptionsService) GetPayments(ctx context.Context, cID, sID string, opts *SubscriptionListOptions) (res *Response, sl *PaymentList, err error) +func (ss *SubscriptionsService) GetPayments(ctx context.Context, cID, sID string, opts *SubscriptionListOptions) ( + res *Response, + sl *PaymentList, + err error, +) ``` GetPayments retrieves all payments of a specific subscriptions of a customer @@ -3575,7 +4149,11 @@ See: #### func (*SubscriptionsService) List ```go -func (ss *SubscriptionsService) List(ctx context.Context, cID string, opts *SubscriptionListOptions) (res *Response, sl *SubscriptionList, err error) +func (ss *SubscriptionsService) List(ctx context.Context, cID string, opts *SubscriptionListOptions) ( + res *Response, + sl *SubscriptionList, + err error, +) ``` List retrieves all subscriptions of a customer @@ -3585,13 +4163,101 @@ See: #### func (*SubscriptionsService) Update ```go -func (ss *SubscriptionsService) Update(ctx context.Context, cID, sID string, sc *Subscription) (res *Response, s *Subscription, err error) +func (ss *SubscriptionsService) Update(ctx context.Context, cID, sID string, sc *Subscription) ( + res *Response, + s *Subscription, + err error, +) ``` Update changes fields on a subscription object See: +#### type Subtotal + +```go +type Subtotal struct { + TransactionType string `json:"transactionType,omitempty"` + Count int `json:"count,omitempty"` + Amount *Amount `json:"amount,omitempty"` + Subtotals []*Subtotal `json:"subtotals,omitempty"` +} +``` + +Subtotal balance descriptor. + +#### type TransactionType + +```go +type TransactionType string +``` + +TransactionType specifies the reason for the movement. + +```go +const ( + PaymentTransaction TransactionType = "payment" + CaptureTransaction TransactionType = "capture" + UnauthorizedDirectDebitTransaction TransactionType = "unauthorized-direct-debit" + FailedPaymentTransaction TransactionType = "failed-payment" + RefundTransaction TransactionType = "refund-transaction" + ReturnedRefundTransaction TransactionType = "returned-refund" + ChargebackTransaction TransactionType = "chargeback" + ChargebackReversalTransaction TransactionType = "chargeback-reversal" + OutgoingTransferTransaction TransactionType = "outgoing-transfer" + CanceledOutgoingTransfer TransactionType = "canceled-outgoing-transfer" + ReturnedTransferTransaction TransactionType = "returned-transfer" + InvoiceCompensationTransferTransaction TransactionType = "invoice-compensation" + BalanceCorrectionTransaction TransactionType = "balance-correction" + ApplicationFeeTransaction TransactionType = "application-fee" + SplitPaymentTransaction TransactionType = "split-payment" + PlatformPaymentRefundTransaction TransactionType = "platform-payment-refund" + PlatformPaymentChargeback TransactionType = "platform-payment-chargeback" +) +``` + +Known and supported transaction types. + +#### type TransferDestination + +```go +type TransferDestination struct { + Type string `json:"type,omitempty"` + BankAccount string `json:"bankAccount,omitempty"` + BeneficiaryName string `json:"beneficiaryName,omitempty"` +} +``` + +TransferDestination where the available amount will be automatically +transferred. + +#### type TransferFrequency + +```go +type TransferFrequency string +``` + +TransferFrequency reflects the frequency at which the available amount on the +balance will be settled to the configured transfer destination. + +```go +const ( + TransferDaily TransferFrequency = "daily" + TransferTwiceAWeek TransferFrequency = "twice-a-week" + TransferEveryMonday TransferFrequency = "every-monday" + TransferEveryTuesday TransferFrequency = "every-tuesday" + TransferEveryWednesday TransferFrequency = "every-wednesday" + TransferEveryThursday TransferFrequency = "every-thursday" + TransferEveryFriday TransferFrequency = "every-friday" + TransferTwiceAMonth TransferFrequency = "twice-a-month" + TransferMonthly TransferFrequency = "monthly" + TransferNever TransferFrequency = "never" +) +``` + +Possible values for type TransferFrequency. + #### type URL ```go