From 2b2e5a2a93dbcd38329814e3fb5664a82f812c70 Mon Sep 17 00:00:00 2001 From: Jan Paepke Date: Wed, 11 Sep 2024 12:29:19 +0200 Subject: [PATCH 01/19] add missing payment include type --- src/createMollieClient.ts | 2 +- src/data/payments/data.ts | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/createMollieClient.ts b/src/createMollieClient.ts index d6cf0e68..376f2786 100644 --- a/src/createMollieClient.ts +++ b/src/createMollieClient.ts @@ -192,7 +192,7 @@ export { MandateMethod, MandateStatus } from './data/customers/mandates/data'; export { MethodImageSize, MethodInclude } from './data/methods/data'; export { OrderEmbed, OrderStatus } from './data/orders/data'; export { OrderLineType } from './data/orders/orderlines/OrderLine'; -export { PaymentEmbed, PaymentStatus } from './data/payments/data'; +export { PaymentEmbed, PaymentInclude, PaymentStatus } from './data/payments/data'; export { RefundEmbed, RefundStatus } from './data/refunds/data'; export { SubscriptionStatus } from './data/subscriptions/data'; export { ProfileStatus } from './data/profiles/data'; diff --git a/src/data/payments/data.ts b/src/data/payments/data.ts index 644896ec..ba224d48 100644 --- a/src/data/payments/data.ts +++ b/src/data/payments/data.ts @@ -860,7 +860,10 @@ export enum PaymentStatus { paid = 'paid', } -export type PaymentInclude = 'details.qrCode'; +export enum PaymentInclude { + qrCode = 'details.qrCode', + remainderDEtails = 'details.remainderDetails', +} export enum PaymentEmbed { refunds = 'refunds', From de1c64c37e7a4c05277a783eec8684904eb927a3 Mon Sep 17 00:00:00 2001 From: Jan Paepke Date: Wed, 11 Sep 2024 13:03:07 +0200 Subject: [PATCH 02/19] export missing mandate types from package --- src/createMollieClient.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/createMollieClient.ts b/src/createMollieClient.ts index d6cf0e68..462f20e3 100644 --- a/src/createMollieClient.ts +++ b/src/createMollieClient.ts @@ -188,7 +188,7 @@ export { createMollieClient }; export { ApiMode, Locale, PaymentMethod, HistoricPaymentMethod, SequenceType } from './data/global'; export { CaptureEmbed } from './data/payments/captures/data'; -export { MandateMethod, MandateStatus } from './data/customers/mandates/data'; +export { type MandateDetails, type MandateDetailsCreditCard, type MandateDetailsDirectDebit, MandateMethod, MandateStatus } from './data/customers/mandates/data'; export { MethodImageSize, MethodInclude } from './data/methods/data'; export { OrderEmbed, OrderStatus } from './data/orders/data'; export { OrderLineType } from './data/orders/orderlines/OrderLine'; From 3142b3637e0931fa468ec055792fd0c902336831 Mon Sep 17 00:00:00 2001 From: "Pimm \"de Chinchilla\" Hogeling" Date: Mon, 16 Sep 2024 07:22:29 +0200 Subject: [PATCH 03/19] =?UTF-8?q?Rename=20PaymentInclude.remainderDEtails?= =?UTF-8?q?=20=E2=86=92=20PaymentInclude.remainderDetails.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/data/payments/data.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/payments/data.ts b/src/data/payments/data.ts index ba224d48..4483ff67 100644 --- a/src/data/payments/data.ts +++ b/src/data/payments/data.ts @@ -862,7 +862,7 @@ export enum PaymentStatus { export enum PaymentInclude { qrCode = 'details.qrCode', - remainderDEtails = 'details.remainderDetails', + remainderDetails = 'details.remainderDetails', } export enum PaymentEmbed { From f413229bc82d69f94ec684901ffe32a48cbf7538 Mon Sep 17 00:00:00 2001 From: Jan Paepke Date: Wed, 11 Sep 2024 15:15:43 +0200 Subject: [PATCH 04/19] add dashboard urls --- src/data/orders/OrderHelper.ts | 10 ++++++++++ src/data/orders/data.ts | 6 ++++++ src/data/payments/PaymentHelper.ts | 13 +++++++++++-- src/data/payments/data.ts | 6 ++++++ tests/unit/resources/orders.test.ts | 12 ++++++++++++ tests/unit/resources/payments.test.ts | 8 ++++++++ 6 files changed, 53 insertions(+), 2 deletions(-) diff --git a/src/data/orders/OrderHelper.ts b/src/data/orders/OrderHelper.ts index 327e1847..11f401ec 100644 --- a/src/data/orders/OrderHelper.ts +++ b/src/data/orders/OrderHelper.ts @@ -98,6 +98,16 @@ export default class OrderHelper extends Helper { return this.links.checkout.href; } + /** + * Returns the direct link to the order in the Mollie Dashboard. + * + * @see https://docs.mollie.com/reference/v2/orders-api/get-order?path=_links/dashboard#response + * @since 4.0.0 + */ + public getDashboardUrl(): string { + return this.links.dashboard.href; + } + /** * Returns all payments created for the order. * diff --git a/src/data/orders/data.ts b/src/data/orders/data.ts index 43bd16d7..21101a7c 100644 --- a/src/data/orders/data.ts +++ b/src/data/orders/data.ts @@ -202,6 +202,12 @@ export interface OrderLinks extends Links { * @see https://docs.mollie.com/reference/v2/orders-api/get-order?path=_links/checkout#response */ checkout?: Url; + /** + * Direct link to the order in the Mollie Dashboard. + * + * @see https://docs.mollie.com/reference/v2/orders-api/get-order?path=_links/dashboard#response + */ + dashboard: Url; } export enum OrderStatus { diff --git a/src/data/payments/PaymentHelper.ts b/src/data/payments/PaymentHelper.ts index 3465105a..0e796a8c 100644 --- a/src/data/payments/PaymentHelper.ts +++ b/src/data/payments/PaymentHelper.ts @@ -12,7 +12,6 @@ import { type ThrottlingParameter } from '../../types/parameters'; import Helper from '../Helper'; import type Chargeback from '../chargebacks/Chargeback'; import { type ChargebackData } from '../chargebacks/Chargeback'; -import { SequenceType, type Amount } from '../global'; import type Order from '../orders/Order'; import { type OrderData } from '../orders/data'; import type Refund from '../refunds/Refund'; @@ -20,7 +19,7 @@ import { type RefundData } from '../refunds/data'; import type Payment from './Payment'; import type Capture from './captures/Capture'; import { type CaptureData } from './captures/data'; -import { PaymentStatus, type BankTransferLinks, type PaymentData } from './data'; +import { type BankTransferLinks, type PaymentData } from './data'; export default class PaymentHelper extends Helper { constructor(networkClient: TransformingNetworkClient, protected readonly links: PaymentData['_links'], protected readonly embedded: Payment['_embedded']) { @@ -59,6 +58,16 @@ export default class PaymentHelper extends Helper { return this.links.checkout?.href ?? null; } + /** + * Returns the direct link to the payment in the Mollie Dashboard. + * + * @see https://docs.mollie.com/reference/v2/payments-api/get-payment?path=_links/dashboard#response + * @since 4.0.0 + */ + public getDashboardUrl(): string { + return this.links.dashboard.href; + } + public canBeRefunded(this: PaymentData): boolean { return this.amountRemaining != undefined; } diff --git a/src/data/payments/data.ts b/src/data/payments/data.ts index 4483ff67..55615fe8 100644 --- a/src/data/payments/data.ts +++ b/src/data/payments/data.ts @@ -338,6 +338,12 @@ interface PaymentLinks extends Links { * @see https://docs.mollie.com/reference/v2/payments-api/get-payment?path=_links/order#response */ order?: Url; + /** + * Direct link to the payment in the Mollie Dashboard. + * + * @see https://docs.mollie.com/reference/v2/payments-api/get-payment?path=_links/dashboard#response + */ + dashboard: Url; } export interface BancontactDetails { diff --git a/tests/unit/resources/orders.test.ts b/tests/unit/resources/orders.test.ts index aee6ddf2..3bf97c13 100644 --- a/tests/unit/resources/orders.test.ts +++ b/tests/unit/resources/orders.test.ts @@ -121,6 +121,10 @@ function composeOrderResponse(orderId, orderStatus = 'created', orderNumber = '1 href: 'https://www.mollie.com/payscreen/select-method/7UhSN1zuXS', type: 'text/html', }, + dashboard: { + href: `https://www.mollie.com/dashboard/org_123456789/orders/${orderId}`, + type: 'text/html', + }, documentation: { href: 'https://docs.mollie.com/reference/v2/orders-api/get-order', type: 'text/html', @@ -198,6 +202,8 @@ function testOrder(order, orderId, orderStatus = 'created', orderNumber = '1337' href: 'https://docs.mollie.com/reference/v2/orders-api/get-order', type: 'text/html', }); + expect(order.getCheckoutUrl()).toBe('https://www.mollie.com/payscreen/select-method/7UhSN1zuXS'); + expect(order.getDashboardUrl()).toBe(`https://www.mollie.com/dashboard/org_123456789/orders/${orderId}`); expect(order.lines[0]).toEqual({ resource: 'orderline', @@ -545,6 +551,10 @@ test('getOrderIncludingPayments', () => { href: 'https://www.mollie.com/payscreen/order/checkout/pbjz8x', type: 'text/html', }, + dashboard: { + href: 'https://www.mollie.com/dashboard/org_123456789/orders/ord_pbjz8x', + type: 'text/html', + }, documentation: { href: 'https://docs.mollie.com/reference/v2/orders-api/get-order', type: 'text/html', @@ -585,6 +595,8 @@ test('getOrderIncludingPayments', () => { href: 'https://api.mollie.com/v2/orders/ord_kEn1PlbGa', type: 'application/hal+json', }); + expect(order.getCheckoutUrl()).toBe('https://www.mollie.com/payscreen/order/checkout/pbjz8x'); + expect(order.getDashboardUrl()).toBe('https://www.mollie.com/dashboard/org_123456789/orders/ord_pbjz8x'); }); }); diff --git a/tests/unit/resources/payments.test.ts b/tests/unit/resources/payments.test.ts index d1de63d4..52658711 100644 --- a/tests/unit/resources/payments.test.ts +++ b/tests/unit/resources/payments.test.ts @@ -34,6 +34,10 @@ test('createPayment', () => { href: 'https://www.mollie.com/payscreen/select-method/44aKxzEbr8', type: 'text/html', }, + dashboard: { + href: 'https://www.mollie.com/dashboard/org_12345678/payments/tr_44aKxzEbr8', + type: 'text/html', + }, documentation: { href: 'https://docs.mollie.com/reference/v2/payments-api/create-payment', type: 'text/html', @@ -79,6 +83,10 @@ test('createPayment', () => { expect(payment._links.checkout).toEqual({ href: 'https://www.mollie.com/payscreen/select-method/44aKxzEbr8', type: 'text/html' }); expect(payment._links.documentation).toEqual({ href: 'https://docs.mollie.com/reference/v2/payments-api/create-payment', type: 'text/html' }); + + expect(payment.getCheckoutUrl()).toBe('https://www.mollie.com/payscreen/select-method/44aKxzEbr8'); + + expect(payment.getDashboardUrl()).toBe('https://www.mollie.com/dashboard/org_12345678/payments/tr_44aKxzEbr8'); }); }); From 39829f5d7c95a2834941e845f4a525240ea84454 Mon Sep 17 00:00:00 2001 From: Tim Ohlsen Date: Sat, 10 Aug 2024 16:48:32 +0200 Subject: [PATCH 05/19] pricing type to array Following https://docs.mollie.com/reference/v2/methods-api/get-method?path=pricing#response the response is an array of MethodPricing --- src/data/methods/data.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/methods/data.ts b/src/data/methods/data.ts index eba4df75..6928f98d 100644 --- a/src/data/methods/data.ts +++ b/src/data/methods/data.ts @@ -32,7 +32,7 @@ export interface MethodData extends Model<'method', PaymentMethodEnum> { * * @see https://docs.mollie.com/reference/v2/methods-api/get-method?path=pricing#response */ - pricing: MethodPricing; + pricing: MethodPricing[]; /** * An object with several URL objects relevant to the payment method. Every URL object will contain an `href` and a `type` field. * From c5cc313bbfb0a33136481b0f6be3c1b8d9e2a1c3 Mon Sep 17 00:00:00 2001 From: Jan Paepke Date: Wed, 11 Sep 2024 15:42:08 +0200 Subject: [PATCH 06/19] complete optional method includes --- src/data/methods/data.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/data/methods/data.ts b/src/data/methods/data.ts index 6928f98d..36ba7e68 100644 --- a/src/data/methods/data.ts +++ b/src/data/methods/data.ts @@ -32,7 +32,13 @@ export interface MethodData extends Model<'method', PaymentMethodEnum> { * * @see https://docs.mollie.com/reference/v2/methods-api/get-method?path=pricing#response */ - pricing: MethodPricing[]; + pricing?: MethodPricing[]; + /** + * Pricing set of the payment method what will be include if you add the parameter. + * + * @see https://docs.mollie.com/reference/v2/methods-api/get-method?path=pricing#response + */ + issuers?: MethodIssuers[]; /** * An object with several URL objects relevant to the payment method. Every URL object will contain an `href` and a `type` field. * @@ -93,3 +99,10 @@ export interface MethodPricing { variable: string; feeRegion: FeeRegion; } + +export interface MethodIssuers { + resource: string; + id: string; + name: string; + image: Image; +} From 2862cf4207b0e308c0cbc423801386c0e16b6566 Mon Sep 17 00:00:00 2001 From: "Pimm \"de Chinchilla\" Hogeling" Date: Mon, 16 Sep 2024 23:50:43 +0200 Subject: [PATCH 07/19] Update documentation in MethodsData. --- src/data/methods/data.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/data/methods/data.ts b/src/data/methods/data.ts index 36ba7e68..5c358758 100644 --- a/src/data/methods/data.ts +++ b/src/data/methods/data.ts @@ -28,13 +28,14 @@ export interface MethodData extends Model<'method', PaymentMethodEnum> { */ image: Image; /** - * Pricing set of the payment method what will be include if you add the parameter. + * Array of objects describing the pricing configuration applicable for this payment method on your account. * * @see https://docs.mollie.com/reference/v2/methods-api/get-method?path=pricing#response */ pricing?: MethodPricing[]; /** - * Pricing set of the payment method what will be include if you add the parameter. + * Array of objects for each 'issuer' that is available for this payment method. Only relevant for iDEAL, KBC/CBC, + * gift cards, and vouchers. * * @see https://docs.mollie.com/reference/v2/methods-api/get-method?path=pricing#response */ From e7db5e5bb559f82687dd9ff606ca824de6dbd73b Mon Sep 17 00:00:00 2001 From: "Pimm \"de Chinchilla\" Hogeling" Date: Fri, 6 Sep 2024 16:19:47 +0200 Subject: [PATCH 08/19] Update changelog for v4.0.0. --- CHANGELOG.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c1b7d97..c8220e0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,23 @@ All notable changes to this project will be documented in this file. +### v4.0.0 - 2024-09-16 + - Replace Axios dependency in favour of [fetch](https://developer.mozilla.org/docs/Web/API/fetch) ([#358](https://github.com/mollie/mollie-api-node/pull/358)) + - Add `cancelUrl` and `getDashboardUrl` to payments and orders ([#327](https://github.com/mollie/mollie-api-node/pull/327)/[#373](https://github.com/mollie/mollie-api-node/pull/373)) + - Add `status` and `issuers` to methods and update `pricing` ([#335](https://github.com/mollie/mollie-api-node/pull/335)/[#374](https://github.com/mollie/mollie-api-node/pull/374)) + - Update and export `PaymentInclude` ([#370](https://github.com/mollie/mollie-api-node/pull/370)) + - Change type of `metadata` (from `any`) to `unknown` ([#367](https://github.com/mollie/mollie-api-node/pull/367)) + - Change return type of functions to plain arrays or iterators, depending on whether the represented list is paginated ([#322](https://github.com/mollie/mollie-api-node/pull/322)) + - Bump Node.js requirement to 14 + - Remove snake case properties, e.g. `customers_payments` ([#314](https://github.com/mollie/mollie-api-node/pull/314)/[#353](https://github.com/mollie/mollie-api-node/pull/353)) + - Remove endpoint aliases, e.g. `delete` intead of `cancel` ([#315](https://github.com/mollie/mollie-api-node/pull/315)/[#353](https://github.com/mollie/mollie-api-node/pull/353)) + - Remove predictable helper functions ([#364](https://github.com/mollie/mollie-api-node/pull/364)) + - Remove fields from `ApiError` ([#363](https://github.com/mollie/mollie-api-node/pull/363)) + - Remove `count` from pages ([#365](https://github.com/mollie/mollie-api-node/pull/365)) + - Remove `withParent` ([#323](https://github.com/mollie/mollie-api-node/pull/323)) + - Remove `toPlainObject` ([#362](https://github.com/mollie/mollie-api-node/pull/362)) + - Remove `Object.entries` polyfill ([#352](https://github.com/mollie/mollie-api-node/pull/352)) + ### v3.7.0 - 2023-03-08 - Update APIs ([#279](https://github.com/mollie/mollie-api-node/pull/279)/[#285](https://github.com/mollie/mollie-api-node/pull/285)/[#292](https://github.com/mollie/mollie-api-node/pull/292)/[#293](https://github.com/mollie/mollie-api-node/pull/293)) From 1c09488fe3dec7a1345fca51638b77dc9940576c Mon Sep 17 00:00:00 2001 From: "Pimm \"de Chinchilla\" Hogeling" Date: Tue, 17 Sep 2024 01:24:09 +0200 Subject: [PATCH 09/19] Add migration guide for v4.0.0. --- MIGRATION.md | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 110 insertions(+), 2 deletions(-) diff --git a/MIGRATION.md b/MIGRATION.md index 71704fc1..3a375bd3 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -1,4 +1,112 @@ -# Migrating from v2.3.2 to v3.0.0 +# Migrating from v3.×.× to v4.0.0 + +## Raised Node.js requirement + +Node.js 14+ is officially supported, although we believe Node.js 8+ should work. + +## Removed `withParent` + +`withParent` has been removed, eliminating state from the client: +```diff +- const payments = mollieClient.customerPayments.withParent(customer).iterate(); ++ const payments = mollieClient.customerPayments.iterate({ customerId: customer.id }); + for await (const payment of payments) { + … + } +``` + +## Removed snake case properties (e.g. `payments_refunds`) + +Snake case properties have been removed in favour of camel case ones. Please use `paymentRefunds` instead of `payments_refunds`, `orderShipments` instead of `orders_shipments`, et cetera: +```diff +- mollieClient.customers_subscriptions.get('sub_PCN3U3U27K', { customerId: 'cst_pzhEvnttJ2' }) ++ mollieClient.customerSubscriptions.get('sub_PCN3U3U27K', { customerId: 'cst_pzhEvnttJ2' }); +``` + +## Removed endpoint aliases (e.g. `payments.delete`) + +Endpoint aliases have been removed. Please use `mollieClient.payments.cancel` instead of `mollieClient.payments.delete`, `mollieClient.refunds.page` instead of `mollieClient.refunds.list`, et cetera: +```diff +- mollieClient.subscriptions.list({ limit: 10 }) ++ mollieClient.subscriptions.page({ limit: 10 }) +``` + +## Removed predictable helper functions + +Helper functions which do not provide a significantly simpler API have been removed: +```diff +- if (payment.isOpen()) { ++ if (payment.status == PaymentStatus.open) { +``` +```diff +- if (payment.hasSequenceTypeFirst()) { ++ if (payment.sequenceType == SequenceType.first) +``` + +## Removed functions from `ApiError` + +`getMessage`, `getField`, `getStatusCode` have been removed. Please use `message`, `field`, and `statusCode` instead: +```diff + try { + const payment = await mollieClient.payments.get(…); + } catch (error) { +- console.warn(error.getMessage()) ++ console.warn(error.message) + } +``` + +## Changed type of `metadata` (from `any`) to `unknown` + +The `metadata` property is now typed as `unknown`. Please check its type at runtime, or use `as any` to opt in to type issues. + +This is part of a larger movement in the TypeScript universe to reduce usage of the `any` type. See [microsoft/TypeScript#41016](https://github.com/microsoft/TypeScript/issues/41016). + +## Removed `count` + +The `count` property has been removed from pages, please use `length` instead: +```diff +- mollieClient.payments.page({ limit: 10 }).count ++ mollieClient.payments.page({ limit: 10 }).length +``` + +## List API changes + +The return type of list functions now reflects whether the underlying endpoint is paginated. The following functions now return (plain) arrays: + + * `mollieClient.methods.list` + * `mollieClient.orderShipments.list` + * `mollieClient.permissions.list` + +The following functions now return iterators: + + * `customer.getMandates()` + * `customer.getSubscriptions()` + * `customer.getPayments()` + * `order.getRefunds()` + * `payment.getRefunds()` + * `payment.getChargebacks()` + * `payment.getCaptures()` + * `profile.getChargebacks()` + * `profile.getPayments()` + * `profile.getRefunds()` + * `subscription.getPayments()` + +## Removed `toPlainObject` + +`toPlainObject` has been removed. The appropriate alternative depends on your motivation to use the now-removed function. + +## Removed Axios-specific options + +Previously, it was possible to provide options to Axios through `createMollieClient`. The client no longer uses Axios. The following options no longer have any effect: + + * `adapter` + * `proxy` + * `socketPath` + * `timeout` + +Please [create an issue](https://github.com/mollie/mollie-api-node/issues/new) if you rely on such an option. + +# Migrating from v2.×.× to v3.0.0 ## Initialization @@ -60,7 +168,7 @@ The alternative using JavaScript modules would be to replace the first line of t import createMollieClient, { PaymentMethod } from '@mollie/api-client'; ``` -# Migrating from v1.x to v2.0 +# Migrating from v1.×.× to v2.0.0 Version 2.x of the Node client uses the v2 Mollie API. Please refer to [Migrating from v1 to v2](https://docs.mollie.com/migrating-v1-to-v2) for a general overview of the changes introduced by the new Mollie API. From e2ee4bb5ff4a4177987fc5bfd8225179454b6783 Mon Sep 17 00:00:00 2001 From: "Pimm \"de Chinchilla\" Hogeling" Date: Tue, 17 Sep 2024 00:19:34 +0200 Subject: [PATCH 10/19] Update link in readme. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8d762e94..a48ac278 100644 --- a/README.md +++ b/README.md @@ -133,7 +133,7 @@ For a deep dive in how our systems function, we refer to [our excellent guides]( ## API reference -This library is a wrapper around our Mollie API. Some more specific details are better explained in [our API reference](https://docs.mollie.com/reference/v2/), and you can also get a better understanding of how the requests look under the hood. +This library is a wrapper around our Mollie API. Some more specific details are better explained in [our API reference](https://docs.mollie.com/reference/), and you can also get a better understanding of how the requests look under the hood. ## Migrating From c81b6f7be6197bf4a0caa0bd5b81366d3dbe8227 Mon Sep 17 00:00:00 2001 From: "Pimm \"de Chinchilla\" Hogeling" Date: Tue, 17 Sep 2024 01:32:56 +0200 Subject: [PATCH 11/19] Add clarification to migration guide. --- MIGRATION.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MIGRATION.md b/MIGRATION.md index 3a375bd3..1fdbf29e 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -45,7 +45,7 @@ Helper functions which do not provide a significantly simpler API have been remo ## Removed functions from `ApiError` -`getMessage`, `getField`, `getStatusCode` have been removed. Please use `message`, `field`, and `statusCode` instead: +`getMessage`, `getField`, `getStatusCode` have been removed from `ApiError`. Please use `message`, `field`, and `statusCode` instead: ```diff try { const payment = await mollieClient.payments.get(…); From fd35bfc3733809362647dc36d49b84a3ffc602a0 Mon Sep 17 00:00:00 2001 From: "Pimm \"de Chinchilla\" Hogeling" Date: Tue, 17 Sep 2024 01:36:09 +0200 Subject: [PATCH 12/19] Extend the migration guide. --- MIGRATION.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/MIGRATION.md b/MIGRATION.md index 1fdbf29e..e4d8c6d9 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -69,15 +69,15 @@ The `count` property has been removed from pages, please use `length` instead: + mollieClient.payments.page({ limit: 10 }).length ``` -## List API changes +## Changed return type of list functions -The return type of list functions now reflects whether the underlying endpoint is paginated. The following functions now return (plain) arrays: +The return type of list functions now reflects whether the underlying endpoint is paginated. The following functions return (plain) arrays: * `mollieClient.methods.list` * `mollieClient.orderShipments.list` * `mollieClient.permissions.list` -The following functions now return iterators: +The following functions return iterators: * `customer.getMandates()` * `customer.getSubscriptions()` @@ -106,6 +106,10 @@ Previously, it was possible to provide options to Axios through `createMollieCli Please [create an issue](https://github.com/mollie/mollie-api-node/issues/new) if you rely on such an option. +## Note: network errors may have changed + +It is possible that network issues produce different error messages compared to previous versions of the client. Please update your error handling code if necessary. + # Migrating from v2.×.× to v3.0.0 ## Initialization From 1010dc8dc9439887fc5bef1b7922c0b97d30faa9 Mon Sep 17 00:00:00 2001 From: "Pimm \"de Chinchilla\" Hogeling" Date: Tue, 17 Sep 2024 08:55:03 +0200 Subject: [PATCH 13/19] Tweaked changelog and migration guide. --- CHANGELOG.md | 2 +- MIGRATION.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8220e0a..5df75587 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ### Changelog -All notable changes to this project will be documented in this file. +Please see [the migration guide](MIGRATION.md) for guidance about updating to a newer major version. ### v4.0.0 - 2024-09-16 - Replace Axios dependency in favour of [fetch](https://developer.mozilla.org/docs/Web/API/fetch) ([#358](https://github.com/mollie/mollie-api-node/pull/358)) diff --git a/MIGRATION.md b/MIGRATION.md index e4d8c6d9..020904ae 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -106,9 +106,9 @@ Previously, it was possible to provide options to Axios through `createMollieCli Please [create an issue](https://github.com/mollie/mollie-api-node/issues/new) if you rely on such an option. -## Note: network errors may have changed +## Note: network error messages may have changed -It is possible that network issues produce different error messages compared to previous versions of the client. Please update your error handling code if necessary. +It is possible that network issues produce different values for the `message` property of the produced errors compared to previous versions of the client. If your integration relies on `message`, please update your error handling code accordingly. # Migrating from v2.×.× to v3.0.0 From b5ab239aa9d31284437a22edd996474e00b74352 Mon Sep 17 00:00:00 2001 From: "Pimm \"de Chinchilla\" Hogeling" Date: Tue, 17 Sep 2024 09:28:46 +0200 Subject: [PATCH 14/19] Bump version to 4.0.0. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9a5f6714..44f82447 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mollie/api-client", - "version": "3.7.0", + "version": "4.0.0", "license": "BSD-3-Clause", "description": "Official Mollie API client for Node", "repository": { From d79e4ee267d400bbe6601df2a0cd12397410119a Mon Sep 17 00:00:00 2001 From: Jan Paepke Date: Tue, 17 Sep 2024 10:01:00 +0200 Subject: [PATCH 15/19] update payment methods --- README.md | 30 ++++++++++++++++-------------- src/data/global.ts | 14 ++++++++++++-- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index a48ac278..cd6fa6ad 100644 --- a/README.md +++ b/README.md @@ -147,24 +147,26 @@ Want to help us make our API client even better? We take [pull requests](https:/ [New BSD (Berkeley Software Distribution) License](https://opensource.org/licenses/BSD-3-Clause). Copyright 2013-2021, Mollie B.V. -[credit-card]: https://www.mollie.com/payments/credit-card [apple-pay]: https://www.mollie.com/payments/apple-pay -[paypal]: https://www.mollie.com/payments/paypal -[klarna-pay-now]: https://www.mollie.com/payments/klarna-pay-now -[klarna-pay-later]: https://www.mollie.com/payments/klarna-pay-later -[klarna-slice-it]: https://www.mollie.com/payments/klarna-slice-it -[ideal]: https://www.mollie.com/payments/ideal -[meal-eco-gift-vouchers]: https://www.mollie.com/payments/meal-eco-gift-vouchers -[bank-transfer]: https://www.mollie.com/payments/bank-transfer -[direct-debit]: https://www.mollie.com/payments/direct-debit -[sofort]: https://www.mollie.com/payments/sofort [bancontact]: https://www.mollie.com/payments/bancontact +[bank-transfer]: https://www.mollie.com/payments/bank-transfer +[belfius]: https://www.mollie.com/payments/belfius [cartes-bancaires]: https://www.mollie.com/payments/cartes-bancaires +[credit-card]: https://www.mollie.com/payments/credit-card +[direct-debit]: https://www.mollie.com/payments/direct-debit [eps]: https://www.mollie.com/payments/eps -[postepay]: https://www.mollie.com/payments/postepay -[giropay]: https://www.mollie.com/payments/giropay +[gift-cards]: https://www.mollie.com/payments/gift-cards +[ideal]: https://www.mollie.com/payments/ideal [kbc-cbc]: https://www.mollie.com/payments/kbc-cbc -[belfius]: https://www.mollie.com/payments/belfius +[klarna-pay-later]: https://www.mollie.com/payments/klarna-pay-later +[klarna-pay-now]: https://www.mollie.com/payments/klarna-pay-now +[klarna-slice-it]: https://www.mollie.com/payments/klarna-slice-it +[meal-eco-gift-vouchers]: https://www.mollie.com/payments/meal-eco-gift-vouchers +[paypal]: https://www.mollie.com/payments/paypal [paysafecard]: https://www.mollie.com/payments/paysafecard -[gift-cards]: https://www.mollie.com/payments/gift-cards +[postepay]: https://www.mollie.com/payments/postepay [przelewy24]: https://www.mollie.com/payments/przelewy24 +[riverty]: https://www.mollie.com/payments/riverty +[satispay]: https://www.mollie.com/payments/satispay +[trustly]: https://www.mollie.com/payments/trustly +[twint]: https://www.mollie.com/payments/twint diff --git a/src/data/global.ts b/src/data/global.ts index 08f6fd6e..f26177ce 100644 --- a/src/data/global.ts +++ b/src/data/global.ts @@ -23,18 +23,23 @@ export enum Locale { } export enum PaymentMethod { + alma = 'alma', applepay = 'applepay', + bacs = 'bacs', + bancomatpay = 'bancomatpay', bancontact = 'bancontact', banktransfer = 'banktransfer', belfius = 'belfius', + billie = 'billie', + blik = 'blik', creditcard = 'creditcard', directdebit = 'directdebit', eps = 'eps', giftcard = 'giftcard', - giropay = 'giropay', ideal = 'ideal', in3 = 'in3', kbc = 'kbc', + klarna = 'klarna', klarnapaylater = 'klarnapaylater', klarnapaynow = 'klarnapaynow', klarnasliceit = 'klarnasliceit', @@ -42,13 +47,18 @@ export enum PaymentMethod { paypal = 'paypal', paysafecard = 'paysafecard', przelewy24 = 'przelewy24', - sofort = 'sofort', + riverty = 'riverty', + satispay = 'satispay', + trustly = 'trustly', + twint = 'twint', voucher = 'voucher', } export enum HistoricPaymentMethod { bitcoin = 'bitcoin', inghomepay = 'inghomepay', + giropay = 'giropay', + sofort = 'sofort', } export enum ApiMode { From 147d0aa551a9ff5a3aff7b6ec366e1372369c37c Mon Sep 17 00:00:00 2001 From: "Pimm \"de Chinchilla\" Hogeling" Date: Thu, 19 Sep 2024 23:22:05 +0200 Subject: [PATCH 16/19] Update list of payment methods in about section in readme. --- README.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index cd6fa6ad..7a669845 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ # About -[Mollie](https://www.mollie.com/) builds payment products, commerce solutions and APIs that let you accept online and mobile payments, for small online stores and Fortune 500s alike. Accepting [Credit Card][credit-card], [Apple Pay][apple-pay], [PayPal][paypal], [Klarna: Pay now][klarna-pay-now], [Klarna: Pay later][klarna-pay-later], [Klarna: Slice it][klarna-slice-it], [iDeal][ideal], [vouchers][meal-eco-gift-vouchers], [SEPA Bank Transfer][bank-transfer], [SEPA Direct Debit][direct-debit], [SOFORT banking][sofort], [Bancontact][bancontact], [Cartes Bancaires][cartes-bancaires], [EPS][eps], [PostePay][postepay], [Giropay][giropay], [KBC Payment Button][kbc-cbc], [Belfius Pay Button][belfius], [paysafecard][paysafecard], [gift cards][gift-cards], and [Przelewy24][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. +[Mollie](https://www.mollie.com/) builds payment products, commerce solutions and APIs that let you accept online and mobile payments, for small online stores and Fortune 500s alike. Accepting [credit and debit card][credit-card] ([Cartes Bancaires][cartes-bancaires], [PostePay][postepay]), [Alma][alma], [Apple Pay][apple-pay], [BACS Direct Debit][bacs], [BANCOMAT Pay][bancomat-pay], [Bancontact][bancontact], [SEPA Bank Transfer][bank-transfer], [Belfius Pay Button][belfius], [Billie][billie], [BLIK][blik], [SEPA Direct Debit][direct-debit], [EPS][eps], [iDEAL][ideal] ([in3][ideal-in3]), [KBC Payment Button][kbc-cbc], [Klarna][klarna] (Pay Later, Pay Now, Pay in 3, Financing), [PayPal][paypal], [paysafecard][paysafecard], [Przelewy24][przelewy24], [Riverty][riverty], [Satispay][satispay], [Trustly][trustly], [TWINT][twint], [eco- gift- and meal vouchers][meal-eco-gift-vouchers] and [gift cards][gift-cards] 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. ### A note on use outside of Node.js @@ -147,21 +147,26 @@ Want to help us make our API client even better? We take [pull requests](https:/ [New BSD (Berkeley Software Distribution) License](https://opensource.org/licenses/BSD-3-Clause). Copyright 2013-2021, Mollie B.V. +[alma]: https://www.mollie.com/payments/alma [apple-pay]: https://www.mollie.com/payments/apple-pay +[bacs]: https://www.mollie.com/payments/bacs +[bancomat-pay]: https://www.mollie.com/payments/bancomat-pay [bancontact]: https://www.mollie.com/payments/bancontact [bank-transfer]: https://www.mollie.com/payments/bank-transfer [belfius]: https://www.mollie.com/payments/belfius +[billie]: https://www.mollie.com/payments/billie +[blik]: https://www.mollie.com/payments/blik [cartes-bancaires]: https://www.mollie.com/payments/cartes-bancaires [credit-card]: https://www.mollie.com/payments/credit-card [direct-debit]: https://www.mollie.com/payments/direct-debit [eps]: https://www.mollie.com/payments/eps [gift-cards]: https://www.mollie.com/payments/gift-cards [ideal]: https://www.mollie.com/payments/ideal +[ideal-in3]: https://www.mollie.com/payments/ideal-in3 [kbc-cbc]: https://www.mollie.com/payments/kbc-cbc -[klarna-pay-later]: https://www.mollie.com/payments/klarna-pay-later -[klarna-pay-now]: https://www.mollie.com/payments/klarna-pay-now -[klarna-slice-it]: https://www.mollie.com/payments/klarna-slice-it +[klarna]: https://www.mollie.com/payments/klarna [meal-eco-gift-vouchers]: https://www.mollie.com/payments/meal-eco-gift-vouchers +[mybank]: https://www.mollie.com/payments/mybank [paypal]: https://www.mollie.com/payments/paypal [paysafecard]: https://www.mollie.com/payments/paysafecard [postepay]: https://www.mollie.com/payments/postepay @@ -169,4 +174,4 @@ Want to help us make our API client even better? We take [pull requests](https:/ [riverty]: https://www.mollie.com/payments/riverty [satispay]: https://www.mollie.com/payments/satispay [trustly]: https://www.mollie.com/payments/trustly -[twint]: https://www.mollie.com/payments/twint +[twint]: https://www.mollie.com/payments/twint \ No newline at end of file From 88ad95681297ecb4d124ded17f8ad2387a783a1a Mon Sep 17 00:00:00 2001 From: "Pimm \"de Chinchilla\" Hogeling" Date: Thu, 19 Sep 2024 23:30:04 +0200 Subject: [PATCH 17/19] Update changelog and migration guide. --- CHANGELOG.md | 3 ++- MIGRATION.md | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5df75587..a45a51a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,11 +5,12 @@ Please see [the migration guide](MIGRATION.md) for guidance about updating to a newer major version. -### v4.0.0 - 2024-09-16 +### v4.0.0 - 2024-09-19 - Replace Axios dependency in favour of [fetch](https://developer.mozilla.org/docs/Web/API/fetch) ([#358](https://github.com/mollie/mollie-api-node/pull/358)) - Add `cancelUrl` and `getDashboardUrl` to payments and orders ([#327](https://github.com/mollie/mollie-api-node/pull/327)/[#373](https://github.com/mollie/mollie-api-node/pull/373)) - Add `status` and `issuers` to methods and update `pricing` ([#335](https://github.com/mollie/mollie-api-node/pull/335)/[#374](https://github.com/mollie/mollie-api-node/pull/374)) - Update and export `PaymentInclude` ([#370](https://github.com/mollie/mollie-api-node/pull/370)) + - Update payment methods ([#376](https://github.com/mollie/mollie-api-node/pull/376)) - Change type of `metadata` (from `any`) to `unknown` ([#367](https://github.com/mollie/mollie-api-node/pull/367)) - Change return type of functions to plain arrays or iterators, depending on whether the represented list is paginated ([#322](https://github.com/mollie/mollie-api-node/pull/322)) - Bump Node.js requirement to 14 diff --git a/MIGRATION.md b/MIGRATION.md index 020904ae..6a0de3d8 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -55,6 +55,10 @@ Helper functions which do not provide a significantly simpler API have been remo } ``` +## Removed Giropay and SOFORT + +[Giropay](https://help.mollie.com/hc/en-us/articles/19745480480786-Giropay-Depreciation-FAQ) and [SOFORT](https://help.mollie.com/hc/en-us/articles/20904206772626-SOFORT-Deprecation-30-September-2024) have been deprecated, and removed from the client. Please update your code accordingly. + ## Changed type of `metadata` (from `any`) to `unknown` The `metadata` property is now typed as `unknown`. Please check its type at runtime, or use `as any` to opt in to type issues. From a3dceafe926d93c11cab07442bb22684b37e4385 Mon Sep 17 00:00:00 2001 From: "Pimm \"de Chinchilla\" Hogeling" Date: Fri, 20 Sep 2024 00:17:36 +0200 Subject: [PATCH 18/19] Change path of the types in package.json. It seems that the TypeScript compiler previously put the type definitions into dist/types/src, but now puts them in dist/types. This may have happened here: https://github.com/mollie/mollie-api-node/pull/360. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 44f82447..0accaf3c 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "main": "dist/mollie.cjs.js", "module": "dist/mollie.esm.js", "jsnext:main": "dist/mollie.esm.js", - "types": "dist/types/src/types.d.ts", + "types": "dist/types/types.d.ts", "engines": { "node": ">=8" }, From f3f1ece0a12ada5d452ca9b1042ef0cd91fd4592 Mon Sep 17 00:00:00 2001 From: "Pimm \"de Chinchilla\" Hogeling" Date: Fri, 20 Sep 2024 14:36:32 +0200 Subject: [PATCH 19/19] Made @types/node-fetch a regular dependency instead of a dev one. As we are using and re-exporting types from this package, users of this client should install them as well. This dependency is not required for users who don't use TypeScript and thus don't rely on the types, but I don't think anyone would mind the overhead. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0accaf3c..9f655ebf 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "lint": "yarn lint:eslint:fix && yarn lint:prettier" }, "dependencies": { + "@types/node-fetch": "^2.6.11", "node-fetch": "^2.7.0", "ruply": "^1.0.1" }, @@ -51,7 +52,6 @@ "@mollie/eslint-config-typescript": "^1.6.5", "@types/jest": "^29.5.12", "@types/node": "^22.5.4", - "@types/node-fetch": "^2.6.11", "babel-jest": "^29.7.0", "commitizen": "^4.3.0", "cz-conventional-changelog": "^3.3.0",