From a638ebc14c144224f65c7d5887a8283fa5441446 Mon Sep 17 00:00:00 2001 From: Ron Dekker Date: Wed, 3 Jul 2024 10:24:11 +0200 Subject: [PATCH 01/10] Correct migration link in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e05b773d1..faa1275e3 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ The easiest way to install the Mollie API client is by using [Composer](http://g composer require mollie/mollie-api-php ``` -To work with the most recent API version, ensure that you are using a version of this API client that is equal to or greater than 2.0.0. If you prefer to continue using the v1 API, make sure your client version is below 2.0.0. For guidance on transitioning from v1 to v2, please refer to the [migration notes](https://docs.mollie.com/migrating-v1-to-v2). +To work with the most recent API version, ensure that you are using a version of this API client that is equal to or greater than 2.0.0. If you prefer to continue using the v1 API, make sure your client version is below 2.0.0. For guidance on transitioning from v1 to v2, please refer to the [migration notes](https://docs.mollie.com/docs/migrating-from-v1-to-v2). ### Manual Installation ### If you're not familiar with using composer we've added a ZIP file to the releases containing the API client and all the packages normally installed by composer. From f51a875a87a3db70f3a9a7e3816b2609f0aa3230 Mon Sep 17 00:00:00 2001 From: Florian Bender Date: Wed, 3 Jul 2024 12:54:36 +0200 Subject: [PATCH 02/10] NTR: Add Trustly enum --- src/Types/PaymentMethod.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Types/PaymentMethod.php b/src/Types/PaymentMethod.php index fb0f430b1..479dd7cb1 100644 --- a/src/Types/PaymentMethod.php +++ b/src/Types/PaymentMethod.php @@ -70,6 +70,7 @@ class PaymentMethod public const GIFTCARD = "giftcard"; /** + * @deprecated * @link https://www.mollie.com/en/payments/giropay */ public const GIROPAY = "giropay"; @@ -157,6 +158,11 @@ class PaymentMethod */ public const RIVERTY = "riverty"; + /** + * @link https://www.mollie.com/en/payments/trustly + */ + public const TRUSTLY = "trustly"; + /** * @link https://www.mollie.com/en/payments/twint */ From 3400426bc3c97e1f23618e896d5bb454ac9803dd Mon Sep 17 00:00:00 2001 From: fjbender Date: Wed, 3 Jul 2024 10:55:03 +0000 Subject: [PATCH 03/10] Fix styling --- src/Types/PaymentMethod.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Types/PaymentMethod.php b/src/Types/PaymentMethod.php index 479dd7cb1..fa770953a 100644 --- a/src/Types/PaymentMethod.php +++ b/src/Types/PaymentMethod.php @@ -70,7 +70,7 @@ class PaymentMethod public const GIFTCARD = "giftcard"; /** - * @deprecated + * @deprecated * @link https://www.mollie.com/en/payments/giropay */ public const GIROPAY = "giropay"; From d52a1a2338eeced2f59b1f5a8d1742f6e979f451 Mon Sep 17 00:00:00 2001 From: Sander van Hooft Date: Wed, 3 Jul 2024 21:08:55 +0200 Subject: [PATCH 04/10] Added payconiq --- src/Types/PaymentMethod.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Types/PaymentMethod.php b/src/Types/PaymentMethod.php index fa770953a..a20652c86 100644 --- a/src/Types/PaymentMethod.php +++ b/src/Types/PaymentMethod.php @@ -122,6 +122,11 @@ class PaymentMethod */ public const MYBANK = "mybank"; + /** + * @link https://www.mollie.com/en/payments/payconiq + */ + public const PAYCONIQ = "payconiq"; + /** * @link https://www.mollie.com/en/payments/paypal */ From a825578aba98605db3f6b6bc5b86c196276dc3f9 Mon Sep 17 00:00:00 2001 From: Sander van Hooft Date: Wed, 3 Jul 2024 21:11:11 +0200 Subject: [PATCH 05/10] Updated version number --- src/MollieApiClient.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MollieApiClient.php b/src/MollieApiClient.php index 820d2fff4..68b9cecb9 100644 --- a/src/MollieApiClient.php +++ b/src/MollieApiClient.php @@ -50,7 +50,7 @@ class MollieApiClient /** * Version of our client. */ - public const CLIENT_VERSION = "2.69.0"; + public const CLIENT_VERSION = "2.70.0"; /** * Endpoint of the remote API. From 8119f1112f6fc4465656b5941ed756f2cb70ff45 Mon Sep 17 00:00:00 2001 From: RichardJong Date: Mon, 8 Jul 2024 16:16:25 +0200 Subject: [PATCH 06/10] Update MandateEndpoint.php Correctly specify parameter types --- src/Endpoints/MandateEndpoint.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Endpoints/MandateEndpoint.php b/src/Endpoints/MandateEndpoint.php index d6dee89f3..7e77c167a 100644 --- a/src/Endpoints/MandateEndpoint.php +++ b/src/Endpoints/MandateEndpoint.php @@ -122,8 +122,8 @@ public function iteratorFor(Customer $customer, ?string $from = null, ?int $limi /** * @param string $customerId - * @param null $from - * @param null $limit + * @param string|null $from + * @param int|null $limit * @param array $parameters * * @return \Mollie\Api\Resources\MandateCollection From 87e1ac2178d19912d2e67e09a6902b0a698dc4f4 Mon Sep 17 00:00:00 2001 From: Sander van Hooft Date: Wed, 10 Jul 2024 11:52:02 +0200 Subject: [PATCH 07/10] wip --- src/Endpoints/OnboardingEndpoint.php | 4 +- src/Endpoints/PaymentLinkPaymentEndpoint.php | 42 +++++++++ src/MollieApiClient.php | 91 ++++++++++--------- src/Resources/PaymentLink.php | 18 ++++ .../PaymentLinkPaymentEndpointTest.php | 90 ++++++++++++++++++ 5 files changed, 202 insertions(+), 43 deletions(-) create mode 100644 src/Endpoints/PaymentLinkPaymentEndpoint.php create mode 100644 tests/Mollie/API/Endpoints/PaymentLinkPaymentEndpointTest.php diff --git a/src/Endpoints/OnboardingEndpoint.php b/src/Endpoints/OnboardingEndpoint.php index 52ba56958..c8cb9a364 100644 --- a/src/Endpoints/OnboardingEndpoint.php +++ b/src/Endpoints/OnboardingEndpoint.php @@ -40,13 +40,13 @@ public function get() } /** + * @deprecated 2023-05-01 For an alternative, see https://docs.mollie.com/reference/create-client-link . * Submit data that will be prefilled in the merchant’s onboarding. * Please note that the data you submit will only be processed when the onboarding status is needs-data. * * Information that the merchant has entered in their dashboard will not be overwritten. * - * Will throw a ApiException if the resource cannot be found. - * + * Will throw an ApiException if the resource cannot be found. * @throws ApiException */ public function submit(array $parameters = []) diff --git a/src/Endpoints/PaymentLinkPaymentEndpoint.php b/src/Endpoints/PaymentLinkPaymentEndpoint.php new file mode 100644 index 000000000..d266fc27c --- /dev/null +++ b/src/Endpoints/PaymentLinkPaymentEndpoint.php @@ -0,0 +1,42 @@ +client, $count, $_links); + } + + /** + * @inheritDoc + */ + protected function getResourceObject() + { + return new Payment($this->client); + } + + public function pageForId(string $paymentLinkId, string $from = null, int $limit = null, array $filters = []) + { + $this->parentId = $paymentLinkId; + + return $this->rest_list($from, $limit, $filters); + } + + public function pageFor(PaymentLink $paymentLink, string $from = null, int $limit = null, array $filters = []) + { + return $this->pageForId($paymentLink->id, $from, $limit, $filters); + } +} \ No newline at end of file diff --git a/src/MollieApiClient.php b/src/MollieApiClient.php index 820d2fff4..0a9935780 100644 --- a/src/MollieApiClient.php +++ b/src/MollieApiClient.php @@ -24,6 +24,7 @@ use Mollie\Api\Endpoints\PaymentChargebackEndpoint; use Mollie\Api\Endpoints\PaymentEndpoint; use Mollie\Api\Endpoints\PaymentLinkEndpoint; +use Mollie\Api\Endpoints\PaymentLinkPaymentEndpoint; use Mollie\Api\Endpoints\PaymentRefundEndpoint; use Mollie\Api\Endpoints\PaymentRouteEndpoint; use Mollie\Api\Endpoints\PermissionEndpoint; @@ -291,6 +292,13 @@ class MollieApiClient */ public $orderRefunds; + /** + * RESTful Payment Link Payment resource. + * + * @var PaymentLinkPaymentEndpoint + */ + public $paymentLinkPayments; + /** * Manages Payment Links requests * @@ -319,6 +327,20 @@ class MollieApiClient */ public $wallets; + /** + * RESTful Client resource. + * + * @var ClientEndpoint + */ + public $clients; + + /** + * RESTful Client resource. + * + * @var ClientLinkEndpoint + */ + public $clientLinks; + /** * @var string */ @@ -349,20 +371,6 @@ class MollieApiClient */ protected $versionStrings = []; - /** - * RESTful Client resource. - * - * @var ClientEndpoint - */ - public $clients; - - /** - * RESTful Client resource. - * - * @var ClientLinkEndpoint - */ - public $clientLinks; - /** * @param \GuzzleHttp\ClientInterface|\Mollie\Api\HttpAdapter\MollieHttpAdapterInterface|null $httpClient * @param \Mollie\Api\HttpAdapter\MollieHttpAdapterPickerInterface|null $httpAdapterPicker, @@ -384,43 +392,44 @@ public function __construct($httpClient = null, $httpAdapterPicker = null, $idem public function initializeEndpoints() { - $this->payments = new PaymentEndpoint($this); - $this->methods = new MethodEndpoint($this); - $this->profileMethods = new ProfileMethodEndpoint($this); - $this->customers = new CustomerEndpoint($this); - $this->settlements = new SettlementsEndpoint($this); - $this->settlementCaptures = new SettlementCaptureEndpoint($this); - $this->settlementChargebacks = new SettlementChargebackEndpoint($this); - $this->settlementPayments = new SettlementPaymentEndpoint($this); - $this->settlementRefunds = new SettlementRefundEndpoint($this); - $this->subscriptions = new SubscriptionEndpoint($this); - $this->customerPayments = new CustomerPaymentsEndpoint($this); - $this->mandates = new MandateEndpoint($this); - $this->balances = new BalanceEndpoint($this); - $this->balanceTransactions = new BalanceTransactionEndpoint($this); $this->balanceReports = new BalanceReportEndpoint($this); + $this->balanceTransactions = new BalanceTransactionEndpoint($this); + $this->balances = new BalanceEndpoint($this); + $this->chargebacks = new ChargebackEndpoint($this); + $this->clientLinks = new ClientLinkEndpoint($this); + $this->clients = new ClientEndpoint($this); + $this->customerPayments = new CustomerPaymentsEndpoint($this); + $this->customers = new CustomerEndpoint($this); $this->invoices = new InvoiceEndpoint($this); - $this->permissions = new PermissionEndpoint($this); - $this->profiles = new ProfileEndpoint($this); + $this->mandates = new MandateEndpoint($this); + $this->methods = new MethodEndpoint($this); $this->onboarding = new OnboardingEndpoint($this); - $this->organizations = new OrganizationEndpoint($this); - $this->orders = new OrderEndpoint($this); $this->orderLines = new OrderLineEndpoint($this); $this->orderPayments = new OrderPaymentEndpoint($this); $this->orderRefunds = new OrderRefundEndpoint($this); - $this->shipments = new ShipmentEndpoint($this); - $this->refunds = new RefundEndpoint($this); - $this->paymentRefunds = new PaymentRefundEndpoint($this); + $this->orders = new OrderEndpoint($this); + $this->organizationPartners = new OrganizationPartnerEndpoint($this); + $this->organizations = new OrganizationEndpoint($this); $this->paymentCaptures = new PaymentCaptureEndpoint($this); - $this->paymentRoutes = new PaymentRouteEndpoint($this); - $this->chargebacks = new ChargebackEndpoint($this); $this->paymentChargebacks = new PaymentChargebackEndpoint($this); - $this->wallets = new WalletEndpoint($this); + $this->paymentLinkPayments = new PaymentLinkPaymentEndpoint($this); $this->paymentLinks = new PaymentLinkEndpoint($this); + $this->paymentRefunds = new PaymentRefundEndpoint($this); + $this->paymentRoutes = new PaymentRouteEndpoint($this); + $this->payments = new PaymentEndpoint($this); + $this->permissions = new PermissionEndpoint($this); + $this->profileMethods = new ProfileMethodEndpoint($this); + $this->profiles = new ProfileEndpoint($this); + $this->refunds = new RefundEndpoint($this); + $this->settlementCaptures = new SettlementCaptureEndpoint($this); + $this->settlementChargebacks = new SettlementChargebackEndpoint($this); + $this->settlementPayments = new SettlementPaymentEndpoint($this); + $this->settlementRefunds = new SettlementRefundEndpoint($this); + $this->settlements = new SettlementsEndpoint($this); + $this->shipments = new ShipmentEndpoint($this); + $this->subscriptions = new SubscriptionEndpoint($this); $this->terminals = new TerminalEndpoint($this); - $this->organizationPartners = new OrganizationPartnerEndpoint($this); - $this->clients = new ClientEndpoint($this); - $this->clientLinks = new ClientLinkEndpoint($this); + $this->wallets = new WalletEndpoint($this); } protected function initializeVersionStrings() diff --git a/src/Resources/PaymentLink.php b/src/Resources/PaymentLink.php index 2d65796ed..bef2c9e30 100644 --- a/src/Resources/PaymentLink.php +++ b/src/Resources/PaymentLink.php @@ -158,6 +158,24 @@ public function archive() return $this->client->paymentLinks->update($this->id, $data); } + /** + * Retrieve a paginated list of payments associated with this payment link. + * + * @param string|null $from + * @param int|null $limit + * @param array $filters + * @return mixed|\Mollie\Api\Resources\BaseCollection + */ + public function payments(string $from = null, int $limit = null, array $filters = []) + { + return $this->client->paymentLinkPayments->pageFor( + $this, + $from, + $limit, + $this->withPresetOptions($filters) + ); + } + /** * When accessed by oAuth we want to pass the testmode by default * diff --git a/tests/Mollie/API/Endpoints/PaymentLinkPaymentEndpointTest.php b/tests/Mollie/API/Endpoints/PaymentLinkPaymentEndpointTest.php new file mode 100644 index 000000000..20550f960 --- /dev/null +++ b/tests/Mollie/API/Endpoints/PaymentLinkPaymentEndpointTest.php @@ -0,0 +1,90 @@ +mockApiCall( + new Request( + "GET", + "/v2/payment-links/pl_4Y0eZitmBnQ6IDoMqZQKh/payments" + ), + new Response( + 200, + [], + '{ + "count": 1, + "_embedded": { + "payments": [ + { + "resource": "payment", + "id": "tr_7UhSN1zuXS", + "mode": "live", + "status": "open", + "isCancelable": false, + "amount": { + "value": "75.00", + "currency": "GBP" + }, + "description": "Order #12345", + "method": "ideal", + "metadata": null, + "details": null, + "profileId": "pfl_QkEhN94Ba", + "redirectUrl": "https://webshop.example.org/order/12345/", + "createdAt": "2024-02-12T11:58:35.0Z", + "expiresAt": "2024-02-12T12:13:35.0Z", + "_links": { + "self": { + "href": "...", + "type": "application/hal+json" + }, + "checkout": { + "href": "https://www.mollie.com/checkout/issuer/select/ideal/7UhSN1zuXS", + "type": "text/html" + }, + "dashboard": { + "href": "https://www.mollie.com/dashboard/org_12345678/payments/tr_7UhSN1zuXS", + "type": "text/html" + } + } + } + ] + }, + "_links": { + "self": { + "href": "...", + "type": "application/hal+json" + }, + "previous": null, + "next": { + "href": "https://api.mollie.com/v2/payment-links/pl_4Y0eZitmBnQ6IDoMqZQKh/payments?from=tr_SDkzMggpvx&limit=5", + "type": "application/hal+json" + }, + "documentation": { + "href": "...", + "type": "text/html" + } + } + }' + ) + ); + + $response = $this->apiClient->paymentLinkPayments->pageForId('pl_4Y0eZitmBnQ6IDoMqZQKh'); + + $this->assertInstanceOf(PaymentCollection::class, $response); + $this->assertInstanceOf(Payment::class, $response[0]); + $this->assertEquals($response[0]->id, 'tr_7UhSN1zuXS'); + // Not necessary to test all fields... + } +} \ No newline at end of file From cfee4675c7272b16904f9d460964990c1e29ad27 Mon Sep 17 00:00:00 2001 From: Sander van Hooft Date: Wed, 10 Jul 2024 11:56:07 +0200 Subject: [PATCH 08/10] wip --- tests/Mollie/API/Endpoints/PaymentLinkPaymentEndpointTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Mollie/API/Endpoints/PaymentLinkPaymentEndpointTest.php b/tests/Mollie/API/Endpoints/PaymentLinkPaymentEndpointTest.php index 20550f960..8d3bbfede 100644 --- a/tests/Mollie/API/Endpoints/PaymentLinkPaymentEndpointTest.php +++ b/tests/Mollie/API/Endpoints/PaymentLinkPaymentEndpointTest.php @@ -80,11 +80,11 @@ public function testGetPaymentsPageForPaymentLink() ) ); - $response = $this->apiClient->paymentLinkPayments->pageForId('pl_4Y0eZitmBnQ6IDoMqZQKh'); + $response = $this->apiClient->paymentLinkPayments->pageForId("pl_4Y0eZitmBnQ6IDoMqZQKh"); $this->assertInstanceOf(PaymentCollection::class, $response); $this->assertInstanceOf(Payment::class, $response[0]); - $this->assertEquals($response[0]->id, 'tr_7UhSN1zuXS'); + $this->assertEquals($response[0]->id, "tr_7UhSN1zuXS"); // Not necessary to test all fields... } } \ No newline at end of file From 4c43f573b9b9e5fae5e089d186679e502c45486c Mon Sep 17 00:00:00 2001 From: sandervanhooft Date: Wed, 10 Jul 2024 09:56:29 +0000 Subject: [PATCH 09/10] Fix styling --- src/Endpoints/PaymentLinkPaymentEndpoint.php | 2 +- tests/Mollie/API/Endpoints/PaymentLinkPaymentEndpointTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Endpoints/PaymentLinkPaymentEndpoint.php b/src/Endpoints/PaymentLinkPaymentEndpoint.php index d266fc27c..58e51f798 100644 --- a/src/Endpoints/PaymentLinkPaymentEndpoint.php +++ b/src/Endpoints/PaymentLinkPaymentEndpoint.php @@ -39,4 +39,4 @@ public function pageFor(PaymentLink $paymentLink, string $from = null, int $limi { return $this->pageForId($paymentLink->id, $from, $limit, $filters); } -} \ No newline at end of file +} diff --git a/tests/Mollie/API/Endpoints/PaymentLinkPaymentEndpointTest.php b/tests/Mollie/API/Endpoints/PaymentLinkPaymentEndpointTest.php index 8d3bbfede..722f642c6 100644 --- a/tests/Mollie/API/Endpoints/PaymentLinkPaymentEndpointTest.php +++ b/tests/Mollie/API/Endpoints/PaymentLinkPaymentEndpointTest.php @@ -87,4 +87,4 @@ public function testGetPaymentsPageForPaymentLink() $this->assertEquals($response[0]->id, "tr_7UhSN1zuXS"); // Not necessary to test all fields... } -} \ No newline at end of file +} From 705b456e6fd3b49fd2cda3d897f152ee0d74436f Mon Sep 17 00:00:00 2001 From: Sander van Hooft Date: Wed, 10 Jul 2024 12:04:16 +0200 Subject: [PATCH 10/10] iterators --- src/Endpoints/PaymentLinkPaymentEndpoint.php | 53 +++++++++++++++++++- src/Endpoints/PaymentRefundEndpoint.php | 8 +-- 2 files changed, 56 insertions(+), 5 deletions(-) diff --git a/src/Endpoints/PaymentLinkPaymentEndpoint.php b/src/Endpoints/PaymentLinkPaymentEndpoint.php index d266fc27c..d118b3666 100644 --- a/src/Endpoints/PaymentLinkPaymentEndpoint.php +++ b/src/Endpoints/PaymentLinkPaymentEndpoint.php @@ -4,6 +4,7 @@ namespace Mollie\Api\Endpoints; +use Mollie\Api\Resources\LazyCollection; use Mollie\Api\Resources\Payment; use Mollie\Api\Resources\PaymentCollection; use Mollie\Api\Resources\PaymentLink; @@ -39,4 +40,54 @@ public function pageFor(PaymentLink $paymentLink, string $from = null, int $limi { return $this->pageForId($paymentLink->id, $from, $limit, $filters); } -} \ No newline at end of file + + /** + * Create an iterator for iterating over payments associated with the provided Payment Link id, retrieved from Mollie. + * + * @param string $paymentLinkId + * @param string|null $from The first resource ID you want to include in your list. + * @param int|null $limit + * @param array $parameters + * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). + * + * @return LazyCollection + */ + public function iteratorForId( + string $paymentLinkId, + ?string $from = null, + ?int $limit = null, + array $parameters = [], + bool $iterateBackwards = false + ): LazyCollection { + $this->parentId = $paymentLinkId; + + return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards); + } + + /** + * Create an iterator for iterating over payments associated with the provided Payment Link object, retrieved from Mollie. + * + * @param PaymentLink $paymentLink + * @param string|null $from The first resource ID you want to include in your list. + * @param int|null $limit + * @param array $parameters + * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). + * + * @return LazyCollection + */ + public function iteratorFor( + PaymentLink $paymentLink, + ?string $from = null, + ?int $limit = null, + array $parameters = [], + bool $iterateBackwards = false + ): LazyCollection { + return $this->iteratorForId( + $paymentLink->id, + $from, + $limit, + $parameters, + $iterateBackwards + ); + } +} diff --git a/src/Endpoints/PaymentRefundEndpoint.php b/src/Endpoints/PaymentRefundEndpoint.php index 68524ec8c..6110cdb57 100644 --- a/src/Endpoints/PaymentRefundEndpoint.php +++ b/src/Endpoints/PaymentRefundEndpoint.php @@ -78,8 +78,8 @@ public function listFor(Payment $payment, array $parameters = []) * Create an iterator for iterating over refunds for the given payment, retrieved from Mollie. * * @param Payment $payment - * @param string $from The first resource ID you want to include in your list. - * @param int $limit + * @param string|null $from The first resource ID you want to include in your list. + * @param int|null $limit * @param array $parameters * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). * @@ -108,8 +108,8 @@ public function listForId($paymentId, array $parameters = []) * Create an iterator for iterating over refunds for the given payment id, retrieved from Mollie. * * @param string $paymentId - * @param string $from The first resource ID you want to include in your list. - * @param int $limit + * @param string|null $from The first resource ID you want to include in your list. + * @param int|null $limit * @param array $parameters * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). *