diff --git a/vendor_manual/mollie/mollie-api-php/README.md b/vendor_manual/mollie/mollie-api-php/README.md index c29135950..8f9cb7d71 100644 --- a/vendor_manual/mollie/mollie-api-php/README.md +++ b/vendor_manual/mollie/mollie-api-php/README.md @@ -1,9 +1,10 @@

- +

+

Mollie API client for PHP

- +![mollie-api-php-header](https://github.com/mollie/mollie-api-php/assets/7265703/e79b7770-fe00-4dfe-bb8b-3d5ed221e329) 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/), [ING Home'Pay](https://www.mollie.com/payments/ing-homepay/), [Giropay](https://www.mollie.com/payments/giropay/), [EPS](https://www.mollie.com/payments/eps/), [Przelewy24](https://www.mollie.com/payments/przelewy24/), [Postepay](https://www.mollie.com/en/payments/postepay), [In3](https://www.mollie.com/payments/in3/), [Klarna](https://www.mollie.com/payments/klarna-pay-later/) ([Pay now](https://www.mollie.com/payments/klarna-pay-now/), [Pay later](https://www.mollie.com/payments/klarna-pay-later/), [Slice it](https://www.mollie.com/payments/klarna-slice-it/), [Pay in 3](https://www.mollie.com/payments/klarna-pay-in-3/)), [Giftcard](https://www.mollie.com/payments/gift-cards/) and [Voucher](https://www.mollie.com/en/payments/meal-eco-gift-vouchers) 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. @@ -22,132 +23,287 @@ To use the Mollie API client, the following things are required: For leveraging [Mollie Connect](https://docs.mollie.com/oauth/overview) (advanced use cases only), we recommend also installing our [OAuth2 client](https://github.com/mollie/oauth2-mollie-php). -## Composer Installation ## - -By far the easiest way to install the Mollie API client is to require it with [Composer](http://getcomposer.org/doc/00-intro.md). +## Installation ## +### Using Composer ### - $ composer require mollie/mollie-api-php:^2.0 +The easiest way to install the Mollie API client is by using [Composer](http://getcomposer.org/doc/00-intro.md). You can require it with the following command: - { - "require": { - "mollie/mollie-api-php": "^2.0" - } - } - -The version of the API client corresponds to the version of the API it implements. Check the [notes on migration](https://docs.mollie.com/migrating-v1-to-v2) to see what changes you need to make if you want to start using a newer API version. +```bash +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). -## Manual Installation ## +### 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. Download the ``mollie-api-php.zip`` from the [releases page](https://github.com/mollie/mollie-api-php/releases). Include the ``vendor/autoload.php`` as shown in [Initialize example](https://github.com/mollie/mollie-api-php/blob/master/examples/initialize.php). -## How to receive payments ## - -To successfully receive a payment, these steps should be implemented: - -1. Use the Mollie API client to create a payment with the requested amount, currency, description and optionally, a payment method. It is important to specify a unique redirect URL where the customer is supposed to return to after the payment is completed. - -2. Immediately after the payment is completed, our platform will send an asynchronous request to the configured webhook to allow the payment details to be retrieved, so you know when exactly to start processing the customer's order. - -3. The customer returns, and should be satisfied to see that the order was paid and is now being processed. - -Find our full documentation online on [docs.mollie.com](https://docs.mollie.com). - -## Getting started ## +## Usage ## Initializing the Mollie API client, and setting your API key. ```php $mollie = new \Mollie\Api\MollieApiClient(); $mollie->setApiKey("test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"); -``` +``` + +With the `MollieApiClient` you can now access any of the following endpoints by selecting them as a property of the client: + +| API | Resource | Code | Link to Endpoint file | +| ----------------------- | ----------------------- | -------------------------- | -------------------------------------------------------------------------- | +| **[Balances API](https://docs.mollie.com/reference/v2/balances-api/overview)** | Balance | `$mollie->balances` | [BalanceEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/BalanceEndpoint.php) | +| | Balance Report | `$mollie->balanceReports` | [BalanceReportEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/BalanceReportEndpoint.php) | +| | Balance Transaction | `$mollie->balanceTransactions` | [BalanceTransactionEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/BalanceTransactionEndpoint.php) | +| **[Chargebacks API](https://docs.mollie.com/reference/v2/chargebacks-api/overview)** | Chargeback |`$mollie->chargebacks` | [ChargebackEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/ChargebackEndpoint.php) | +| | Payment Chargeback | `$mollie->paymentChargebacks` | [PaymentChargebackEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/PaymentChargebackEndpoint.php) | +| **[Clients API](https://docs.mollie.com/reference/v2/clients-api/overview)** | Client | `$mollie->clients` | [ClientEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/ClientEndpoint.php) | +| **[Client Links API](https://docs.mollie.com/reference/v2/client-links-api/overview)** | Client Link | `$mollie->clientLinks` | [ClientLinkEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/ClientLinkEndpoint.php) | +| **[Customers API](https://docs.mollie.com/reference/v2/customers-api/overview)** | Customer | `$mollie->customers` | [CustomerEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/CustomerEndpoint.php) | +| | Customer Payment | `$mollie->customerPayments` | [CustomerPaymentsEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/CustomerPaymentsEndpoint.php) | +| **[Invoices API](https://docs.mollie.com/reference/v2/invoices-api/overview)** | Invoice | `$mollie->invoices` | [InvoiceEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/InvoiceEndpoint.php) | +| **[Mandates API](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/MandateEndpoint.php)** | Mandate | `$mollie->mandates` | [MandateEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/MandateEndpoint.php) | +| **[Methods API](https://docs.mollie.com/reference/v2/methods-api/overview)** | Payment Method | `$mollie->methods` | [MethodEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/MethodEndpoint.php) | +| **[Onboarding API](https://docs.mollie.com/reference/v2/onboarding-api/overview)** | Onboarding |`$mollie->onboarding` | [OnboardingEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/OnboardingEndpoint.php) | +| **[Orders API](https://docs.mollie.com/reference/v2/orders-api/overview)** | Order | `$mollie->orders` | [OrderEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/OrderEndpoint.php) | +| | Order Line | `$mollie->orderLines` | [OrderLineEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/OrderLineEndpoint.php) | +| | Order Payment | `$mollie->orderPayments` | [OrderPaymentEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/OrderPaymentEndpoint.php) | +| **[Organizations API](https://docs.mollie.com/reference/v2/organizations-api/overview)** | Organization | `$mollie->organizations` | [OrganizationEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/OrganizationEndpoint.php) | +| | Organization Partner | `$mollie->organizationPartners` | [OrganizationPartnerEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/OrganizationPartnerEndpoint.php) | +| **[Captures API](https://docs.mollie.com/reference/v2/captures-api/overview)** | Payment Captures | `$mollie->organizations` | [PaymentCaptureEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/PaymentCaptureEndpoint.php) | +| **[Payments API](https://docs.mollie.com/reference/v2/payments-api/overview)** | Payment | `$mollie->payments` | [PaymentEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/PaymentEndpoint.php) | +| | Payment Route | `$mollie->paymentRoutes` | [PaymentRouteEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/PaymentRouteEndpoint.php) | +| **[Payment links API](https://docs.mollie.com/reference/v2/payment-links-api/overview)** | Payment Link | `$mollie->paymentLinks` | [PaymentLinkEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/PaymentLinkEndpoint.php) | +| **[Permissions API](https://docs.mollie.com/reference/v2/permissions-api/overview)** | Permission | `$mollie->permissions` | [PermissionEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/PermissionEndpoint.php) | +| **[Profile API](https://docs.mollie.com/reference/v2/profiles-api/overview)** | Profile | `$mollie->profiles` | [ProfileEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/ProfileEndpoint.php) | +| | Profile Method | `$mollie->profileMethods` | [ProfileMethodEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/ProfileMethodEndpoint.php) | +| **[Refund API](https://docs.mollie.com/reference/v2/refunds-api/overview)** | Refund | `$mollie->refunds` | [RefundEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/RefundEndpoint.php) | +| | Order Refund | `$mollie->orderRefunds` | [OrderRefundEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/OrderRefundEndpoint.php) | +| | Payment Refund | `$mollie->paymentRefunds` | [PaymentRefundEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/PaymentRefundEndpoint.php) | +| **[Settlements API](https://docs.mollie.com/reference/v2/settlements-api/overview)** | Settlement | `$mollie->settlements` | [SettlementsEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/SettlementsEndpoint.php) | +| | Settlement Capture | `$mollie->settlementCaptures` | [SettlementCaptureEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/SettlementCaptureEndpoint.php) | +| | Settlement Chargeback | `$mollie->settlementChargebacks` | [SettlementChargebackEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/SettlementChargebackEndpoint.php) | +| | Settlement Payment | `$mollie->settlementPayments` | [SettlementPaymentEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/SettlementPaymentEndpoint.php) | +| | Settlement Refund | `$mollie->settlementRefunds` | [SettlementRefundEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/SettlementRefundEndpoint.php) | +| **[Shipments API](https://docs.mollie.com/reference/v2/shipments-api/overview)** | Shipment | `$mollie->shipments` | [ShipmentEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/ShipmentEndpoint.php) | +| **[Subscriptions API](https://docs.mollie.com/reference/v2/subscriptions-api/overview)** | Subscription | `$mollie->subscriptions` | [SubscriptionEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/SubscriptionEndpoint.php) | +| **[Terminal API](https://docs.mollie.com/reference/v2/terminals-api/overview)** | Terminal | `$mollie->terminals` | [TerminalEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/TerminalEndpoint.php) | +| **[Wallets API](https://docs.mollie.com/reference/v2/wallets-api/overview)** | Wallet | `$mollie->wallets` | [WalletEndpoint](https://github.com/mollie/mollie-api-php/blob/master/src/Endpoints/WalletEndpoint.php) | -Creating a new payment. +Find our full documentation online on [docs.mollie.com](https://docs.mollie.com). + +### Orders ### +#### Creating Orders #### +**[Create Order reference](https://docs.mollie.com/reference/v2/orders-api/create-order)** ```php -$payment = $mollie->payments->create([ +$order = $mollie->orders->create([ "amount" => [ + "value" => "1027.99", "currency" => "EUR", - "value" => "10.00" ], - "description" => "My first API payment", - "redirectUrl" => "https://webshop.example.org/order/12345/", - "webhookUrl" => "https://webshop.example.org/mollie-webhook/", + "billingAddress" => [ + "streetAndNumber" => "Keizersgracht 313", + "postalCode" => "1016 EE", + "city" => "Amsterdam", + "country" => "nl", + "givenName" => "Luke", + "familyName" => "Skywalker", + "email" => "luke@skywalker.com", + ], + "shippingAddress" => [ + "streetAndNumber" => "Keizersgracht 313", + "postalCode" => "1016 EE", + "city" => "Amsterdam", + "country" => "nl", + "givenName" => "Luke", + "familyName" => "Skywalker", + "email" => "luke@skywalker.com", + ], + "metadata" => [ + "some" => "data", + ], + "consumerDateOfBirth" => "1958-01-31", + "locale" => "en_US", + "orderNumber" => "1234", + "redirectUrl" => "https://your_domain.com/return?some_other_info=foo", + "webhookUrl" => "https://your_domain.com/webhook", + "method" => "ideal", + "lines" => [ + [ + "sku" => "5702016116977", + "name" => "LEGO 42083 Bugatti Chiron", + "productUrl" => "https://shop.lego.com/nl-NL/Bugatti-Chiron-42083", + "imageUrl" => 'https://sh-s7-live-s.legocdn.com/is/image//LEGO/42083_alt1?$main$', + "quantity" => 2, + "vatRate" => "21.00", + "unitPrice" => [ + "currency" => "EUR", + "value" => "399.00", + ], + "totalAmount" => [ + "currency" => "EUR", + "value" => "698.00", + ], + "discountAmount" => [ + "currency" => "EUR", + "value" => "100.00", + ], + "vatAmount" => [ + "currency" => "EUR", + "value" => "121.14", + ], + ], + // more order line items + ], ]); ``` -_After creation, the payment id is available in the `$payment->id` property. You should store this id with your order._ -After storing the payment id you can send the customer to the checkout using the `$payment->getCheckoutUrl()`. +_After creation, the order id is available in the `$order->id` property. You should store this id with your order._ + +After storing the order id you can send the customer off to complete the order payment using `$order->getCheckoutUrl()`. ```php -header("Location: " . $payment->getCheckoutUrl(), true, 303); +header("Location: " . $order->getCheckoutUrl(), true, 303); ``` + _This header location should always be a GET, thus we enforce 303 http response code_ -For a payment create example, see [Example - New Payment](https://github.com/mollie/mollie-api-php/blob/master/examples/payments/create-payment.php). +For an order create example, see [Example - New Order](https://github.com/mollie/mollie-api-php/blob/master/examples/orders/create-order.php). -## Retrieving payments ## -We can use the `$payment->id` to retrieve a payment and check if the payment `isPaid`. +#### Updating Orders #### +**[Update Order Documentation](https://docs.mollie.com/reference/v2/orders-api/update-order)** ```php -$payment = $mollie->payments->get($payment->id); +$order = $mollie->orders->get("ord_kEn1PlbGa"); +$order->billingAddress->organizationName = "Mollie B.V."; +$order->billingAddress->streetAndNumber = "Keizersgracht 126"; +$order->billingAddress->city = "Amsterdam"; +$order->billingAddress->region = "Noord-Holland"; +$order->billingAddress->postalCode = "1234AB"; +$order->billingAddress->country = "NL"; +$order->billingAddress->title = "Dhr"; +$order->billingAddress->givenName = "Piet"; +$order->billingAddress->familyName = "Mondriaan"; +$order->billingAddress->email = "piet@mondriaan.com"; +$order->billingAddress->phone = "+31208202070"; +$order->update(); +``` -if ($payment->isPaid()) -{ - echo "Payment received."; -} +#### Refunding Orders #### +##### Complete ##### +```php +$order = $mollie->orders->get('ord_8wmqcHMN4U'); +$refund = $order->refundAll(); + +echo 'Refund ' . $refund->id . ' was created for order ' . $order->id; ``` -Or retrieve a collection of payments. +##### Partially ##### +When executing a partial refund you have to list all order line items that should be refunded. ```php -$payments = $mollie->payments->page(); +$order = $mollie->orders->get('ord_8wmqcHMN4U'); +$refund = $order->refund([ + 'lines' => [ + [ + 'id' => 'odl_dgtxyl', + 'quantity' => 1, + ], + ], + "description" => "Required quantity not in stock, refunding one photo book.", +]); ``` -For an extensive example of listing payments with the details and status, see [Example - List Payments](https://github.com/mollie/mollie-api-php/blob/master/examples/payments/list-payments.php). +#### Cancel Orders #### +**[Cancel Order Documentation](https://docs.mollie.com/reference/v2/orders-api/cancel-order)** + +_When canceling an order it is crucial to check if the order is cancelable before executing the cancel action. For more information see the [possible order statuses](https://docs.mollie.com/orders/status-changes#possible-statuses-for-orders)._ + +```php +$order = $mollie->orders->get("ord_pbjz8x"); -## Payment webhook ## +if ($order->isCancelable) { + $canceledOrder = $order->cancel(); + echo "Your order " . $order->id . " has been canceled."; +} else { + echo "Unable to cancel your order " . $order->id . "."; +} +``` -When the status of a payment changes the `webhookUrl` we specified in the creation of the payment will be called. -There we can use the `id` from our POST parameters to check te status and act upon that, see [Example - Webhook](https://github.com/mollie/mollie-api-php/blob/master/examples/payments/webhook.php). +#### Order webhook #### +When the order status changes, the `webhookUrl` you specified during order creation will be called. You can use the `id` from the POST parameters to check the status and take appropriate actions. For more details, refer to [Example - Webhook](https://github.com/mollie/mollie-api-php/blob/master/examples/orders/webhook.php). +### Payments ### +#### Payment Reception Process #### +**[Payment Reception Process documentation](https://docs.mollie.com/payments/accepting-payments#working-with-the-payments-api)** -## Multicurrency ## -Since 2.0 it is now possible to create non-EUR payments for your customers. -A full list of available currencies can be found [in our documentation](https://docs.mollie.com/guides/multicurrency). +To ensure a successful payment reception, you should follow these steps: + +1. Utilize the Mollie API client to initiate a payment. Specify the desired amount, currency, description, and optionally, a payment method. It's crucial to define a unique redirect URL where the customer should be directed after completing the payment. + +2. Immediately upon payment completion, our platform will initiate an asynchronous request to the configured webhook. This enables you to retrieve payment details, ensuring you know precisely when to commence processing the customer's order. + +3. The customer is redirected to the URL from step (1) and should be pleased to find that the order has been paid and is now in the processing stage. + + +#### Creating Payments #### +**[Create Payment Documentation](https://docs.mollie.com/reference/v2/payments-api/create-payment)** ```php $payment = $mollie->payments->create([ "amount" => [ - "currency" => "USD", + "currency" => "EUR", "value" => "10.00" ], - "description" => "Order #12345", + "description" => "My first API payment", "redirectUrl" => "https://webshop.example.org/order/12345/", "webhookUrl" => "https://webshop.example.org/mollie-webhook/", ]); ``` -_After creation, the `settlementAmount` will contain the EUR amount that will be settled on your account._ +_After creation, the payment id is available in the `$payment->id` property. You should store this id with your order._ +After storing the payment id you can send the customer to the checkout using `$payment->getCheckoutUrl()`. + +```php +header("Location: " . $payment->getCheckoutUrl(), true, 303); +``` + +_This header location should always be a GET, thus we enforce 303 http response code_ -### Fully integrated iDEAL payments ### +For a payment create example, see [Example - New Payment](https://github.com/mollie/mollie-api-php/blob/master/examples/payments/create-payment.php). + +##### Multicurrency ##### +Since API v2.0 it is now possible to create non-EUR payments for your customers. +A full list of available currencies can be found [in our documentation](https://docs.mollie.com/guides/multicurrency). + +```php +$payment = $mollie->payments->create([ + "amount" => [ + "currency" => "USD", + "value" => "10.00" + ], + //... +]); +``` +_After creation, the `settlementAmount` will contain the EUR amount that will be settled on your account._ -If you want to fully integrate iDEAL payments in your web site, some additional steps are required. First, you need to -retrieve the list of issuers (banks) that support iDEAL and have your customer pick the issuer he/she wants to use for -the payment. +##### Create fully integrated iDEAL payments ##### +To fully integrate iDEAL payments on your website, follow these additional steps: -Retrieve the iDEAL method and include the issuers +1. Retrieve the list of issuers (banks) that support iDEAL. ```php $method = $mollie->methods->get(\Mollie\Api\Types\PaymentMethod::IDEAL, ["include" => "issuers"]); ``` +Use the `$method->issuers` list to let the customer pick their preferred issuer. + _`$method->issuers` will be a list of objects. Use the property `$id` of this object in the - API call, and the property `$name` for displaying the issuer to your customer. For a more in-depth example, see [Example - iDEAL payment](https://github.com/mollie/mollie-api-php/blob/master/examples/payments/create-ideal-payment.php)._ + API call, and the property `$name` for displaying the issuer to your customer._ -Create a payment with the selected issuer: +2. Create a payment with the selected issuer: ```php $payment = $mollie->payments->create([ @@ -166,10 +322,34 @@ $payment = $mollie->payments->create([ _The `_links` property of the `$payment` object will contain an object `checkout` with a `href` property, which is a URL that points directly to the online banking environment of the selected issuer. A short way of retrieving this URL can be achieved by using the `$payment->getCheckoutUrl()`._ -### Refunding payments ### +For a more in-depth example, see [Example - iDEAL payment](https://github.com/mollie/mollie-api-php/blob/master/examples/payments/create-ideal-payment.php). -The API also supports refunding payments. Note that there is no confirmation and that all refunds are immediate and -definitive. refunds are supported for all methods except for paysafecard and gift cards. +#### Retrieving Payments #### +**[Retrieve Payment Documentation](https://docs.mollie.com/reference/v2/payments-api/get-payment)** + +We can use the `$payment->id` to retrieve a payment and check if the payment `isPaid`. + +```php +$payment = $mollie->payments->get($payment->id); + +if ($payment->isPaid()) +{ + echo "Payment received."; +} +``` + +Or retrieve a collection of payments. + +```php +$payments = $mollie->payments->page(); +``` + +For an extensive example of listing payments with the details and status, see [Example - List Payments](https://github.com/mollie/mollie-api-php/blob/master/examples/payments/list-payments.php). + +#### Refunding payments #### +**[Refund Payment Documentation](https://docs.mollie.com/reference/v2/refunds-api/create-payment-refund)** + +Our API provides support for refunding payments. It's important to note that there is no confirmation step, and all refunds are immediate and final. Refunds are available for all payment methods except for paysafecard and gift cards. ```php $payment = $mollie->payments->get($payment->id); @@ -183,15 +363,16 @@ $refund = $payment->refund([ ]); ``` -For a working example, see [Example - Refund payment](https://github.com/mollie/mollie-api-php/blob/master/examples/payments/refund-payment.php). +#### Payment webhook #### +When the payment status changes, the `webhookUrl` you specified during payment creation will be called. You can use the `id` from the POST parameters to check the status and take appropriate actions. For more details, refer to [Example - Webhook](https://github.com/mollie/mollie-api-php/blob/master/examples/payments/webhook.php). -## Enabling debug mode +For a working example, see [Example - Refund payment](https://github.com/mollie/mollie-api-php/blob/master/examples/payments/refund-payment.php). -When debugging it can be convenient to have the submitted request available on the `ApiException`. +### Enabling debug mode ### -In order to prevent leaking sensitive request data into your local application logs, debugging is disabled by default. +When troubleshooting, it can be highly beneficial to have access to the submitted request within the `ApiException`. To safeguard against inadvertently exposing sensitive request data in your local application logs, the debugging feature is initially turned off. -To enable debugging and inspect the request: +To enable debugging and inspect the request: ```php /** @var $mollie \Mollie\Api\MollieApiClient */ @@ -204,8 +385,7 @@ try { } ``` -If you're logging the `ApiException`, the request will also be logged. Make sure to not retain any sensitive data in -these logs and clean up after debugging. +If you are recording instances of `ApiException`, the request details will be included in the logs. It is vital to ensure that no sensitive information is retained within these logs and to perform cleanup after debugging is complete. To disable debugging again: @@ -214,14 +394,13 @@ To disable debugging again: $mollie->disableDebugging(); ``` -Note that debugging is only available when using the default Guzzle http adapter (`Guzzle6And7MollieHttpAdapter`). +Please note that debugging is only available when using the default Guzzle http adapter (`Guzzle6And7MollieHttpAdapter`). ## API documentation ## -If you wish to learn more about our API, please visit the [Mollie Developer Portal](https://www.mollie.com/developers). API Documentation is available in English. - -## Want to help us make our API client even better? ## +For an in-depth understanding of our API, please explore the [Mollie Developer Portal](https://www.mollie.com/developers). Our API documentation is available in English. -Want to help us make our API client even better? We take [pull requests](https://github.com/mollie/mollie-api-php/pulls?utf8=%E2%9C%93&q=is%3Apr), sure. But how would you like to contribute to a technology oriented organization? Mollie is hiring developers and system engineers. [Check out our vacancies](https://jobs.mollie.com/) or [get in touch](mailto:personeel@mollie.com). +## Contributing to Our API Client ## +Would you like to contribute to improving our API client? We welcome [pull requests](https://github.com/mollie/mollie-api-php/pulls?utf8=%E2%9C%93&q=is%3Apr). But, if you're interested in contributing to a technology-focused organization, Mollie is actively recruiting developers and system engineers. Discover our current [job openings](https://jobs.mollie.com/) or [reach out](mailto:personeel@mollie.com). ## License ## [BSD (Berkeley Software Distribution) License](https://opensource.org/licenses/bsd-license.php). diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/BalanceEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/BalanceEndpoint.php index b1a9d69aa..5f44e41af 100644 --- a/vendor_manual/mollie/mollie-api-php/src/Endpoints/BalanceEndpoint.php +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/BalanceEndpoint.php @@ -6,6 +6,7 @@ use Mollie\Api\Resources\Balance; use Mollie\Api\Resources\BalanceCollection; use Mollie\Api\Resources\BaseCollection; +use Mollie\Api\Resources\LazyCollection; class BalanceEndpoint extends CollectionEndpointAbstract { @@ -45,7 +46,7 @@ protected function getResourceObject() public function get(string $balanceId, array $parameters = []) { if (empty($balanceId) || strpos($balanceId, self::RESOURCE_ID_PREFIX) !== 0) { - throw new ApiException("Invalid balance ID: '{$balanceId}'. A balance ID should start with '".self::RESOURCE_ID_PREFIX."'."); + throw new ApiException("Invalid balance ID: '{$balanceId}'. A balance ID should start with '" . self::RESOURCE_ID_PREFIX . "'."); } return parent::rest_read($balanceId, $parameters); @@ -79,4 +80,19 @@ public function page(?string $from = null, ?int $limit = null, array $parameters { return $this->rest_list($from, $limit, $parameters); } + + /** + * Create an iterator for iterating over balances retrieved from Mollie. + * + * @param string $from The first Balance ID you want to include in your list. + * @param int $limit + * @param array $parameters + * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). + * + * @return LazyCollection + */ + public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection + { + return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards); + } } diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/BalanceTransactionEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/BalanceTransactionEndpoint.php index ed0cbb098..4f2447139 100644 --- a/vendor_manual/mollie/mollie-api-php/src/Endpoints/BalanceTransactionEndpoint.php +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/BalanceTransactionEndpoint.php @@ -7,6 +7,7 @@ use Mollie\Api\Resources\Balance; use Mollie\Api\Resources\BalanceTransaction; use Mollie\Api\Resources\BalanceTransactionCollection; +use Mollie\Api\Resources\LazyCollection; class BalanceTransactionEndpoint extends CollectionEndpointAbstract { @@ -50,6 +51,20 @@ public function listFor(Balance $balance, array $parameters = []) return $this->listForId($balance->id, $parameters); } + /** + * Create an iterator for iterating over balance transactions for the given balance retrieved from Mollie. + * + * @param Balance $balance + * @param array $parameters + * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). + * + * @return LazyCollection + */ + public function iteratorFor(Balance $balance, array $parameters = [], bool $iterateBackwards = false): LazyCollection + { + return $this->iteratorForId($balance->id, $parameters, $iterateBackwards); + } + /** * List the transactions for a specific Balance ID. * @@ -66,6 +81,22 @@ public function listForId(string $balanceId, array $parameters = []) return parent::rest_list(null, null, $parameters); } + /** + * Create an iterator for iterating over balance transactions for the given balance id retrieved from Mollie. + * + * @param string $balanceId + * @param array $parameters + * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). + * + * @return LazyCollection + */ + public function iteratorForId(string $balanceId, array $parameters = [], bool $iterateBackwards = false): LazyCollection + { + $this->parentId = $balanceId; + + return $this->rest_iterator(null, null, $parameters, $iterateBackwards); + } + /** * List the transactions for the primary Balance. * @@ -80,4 +111,19 @@ public function listForPrimary(array $parameters = []) return parent::rest_list(null, null, $parameters); } + + /** + * Create an iterator for iterating over transactions for the primary balance retrieved from Mollie. + * + * @param array $parameters + * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). + * + * @return LazyCollection + */ + public function iteratorForPrimary(array $parameters = [], bool $iterateBackwards = false): LazyCollection + { + $this->parentId = "primary"; + + return $this->rest_iterator(null, null, $parameters, $iterateBackwards); + } } diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/ChargebackEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/ChargebackEndpoint.php index dd5045ab5..c40c179c0 100644 --- a/vendor_manual/mollie/mollie-api-php/src/Endpoints/ChargebackEndpoint.php +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/ChargebackEndpoint.php @@ -5,6 +5,7 @@ use Mollie\Api\Exceptions\ApiException; use Mollie\Api\Resources\Chargeback; use Mollie\Api\Resources\ChargebackCollection; +use Mollie\Api\Resources\LazyCollection; class ChargebackEndpoint extends CollectionEndpointAbstract { @@ -43,8 +44,23 @@ protected function getResourceCollectionObject($count, $_links) * @return ChargebackCollection * @throws ApiException */ - public function page($from = null, $limit = null, array $parameters = []) + public function page(?string $from = null, ?int $limit = null, array $parameters = []) { return $this->rest_list($from, $limit, $parameters); } + + /** + * Create an iterator for iterating over chargeback retrieved from Mollie. + * + * @param string $from The first chargevback ID you want to include in your list. + * @param int $limit + * @param array $parameters + * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). + * + * @return LazyCollection + */ + public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection + { + return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards); + } } diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/ClientEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/ClientEndpoint.php index 86891785f..9d7ba66b1 100644 --- a/vendor_manual/mollie/mollie-api-php/src/Endpoints/ClientEndpoint.php +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/ClientEndpoint.php @@ -5,6 +5,7 @@ use Mollie\Api\Exceptions\ApiException; use Mollie\Api\Resources\Client; use Mollie\Api\Resources\ClientCollection; +use Mollie\Api\Resources\LazyCollection; class ClientEndpoint extends CollectionEndpointAbstract { @@ -62,8 +63,23 @@ public function get($clientId, array $parameters = []) * @return ClientCollection * @throws ApiException */ - public function page($from = null, $limit = null, array $parameters = []) + public function page(?string $from = null, ?int $limit = null, array $parameters = []) { return $this->rest_list($from, $limit, $parameters); } + + /** + * Create an iterator for iterating over clients retrieved from Mollie. + * + * @param string $from The first client ID you want to include in your list. + * @param int $limit + * @param array $parameters + * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). + * + * @return LazyCollection + */ + public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection + { + return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards); + } } diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/CollectionEndpointAbstract.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/CollectionEndpointAbstract.php index b11ee9853..06b1dec21 100644 --- a/vendor_manual/mollie/mollie-api-php/src/Endpoints/CollectionEndpointAbstract.php +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/CollectionEndpointAbstract.php @@ -4,6 +4,8 @@ use Mollie\Api\Exceptions\ApiException; use Mollie\Api\Resources\BaseCollection; +use Mollie\Api\Resources\CursorCollection; +use Mollie\Api\Resources\LazyCollection; use Mollie\Api\Resources\ResourceFactory; abstract class CollectionEndpointAbstract extends EndpointAbstract @@ -18,7 +20,7 @@ abstract class CollectionEndpointAbstract extends EndpointAbstract * @return mixed * @throws ApiException */ - protected function rest_list($from = null, $limit = null, array $filters = []) + protected function rest_list(?string $from = null, ?int $limit = null, array $filters = []) { $filters = array_merge(["from" => $from, "limit" => $limit], $filters); @@ -36,6 +38,27 @@ protected function rest_list($from = null, $limit = null, array $filters = []) return $collection; } + /** + * Create a generator for iterating over a resource's collection using REST API calls. + * + * This function fetches paginated data from a RESTful resource endpoint and returns a generator + * that allows you to iterate through the items in the collection one by one. It supports forward + * and backward iteration, pagination, and filtering. + * + * @param string $from The first resource ID you want to include in your list. + * @param int $limit + * @param array $filters + * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). + * @return LazyCollection + */ + protected function rest_iterator(?string $from = null, ?int $limit = null, array $filters = [], bool $iterateBackwards = false): LazyCollection + { + /** @var CursorCollection $page */ + $page = $this->rest_list($from, $limit, $filters); + + return $page->getAutoIterator($iterateBackwards); + } + /** * Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object. * diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/CustomerEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/CustomerEndpoint.php index ae04d8f4b..61c8e6895 100644 --- a/vendor_manual/mollie/mollie-api-php/src/Endpoints/CustomerEndpoint.php +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/CustomerEndpoint.php @@ -5,6 +5,7 @@ use Mollie\Api\Exceptions\ApiException; use Mollie\Api\Resources\Customer; use Mollie\Api\Resources\CustomerCollection; +use Mollie\Api\Resources\LazyCollection; class CustomerEndpoint extends CollectionEndpointAbstract { @@ -81,7 +82,7 @@ public function get($customerId, array $parameters = []) public function update($customerId, array $data = []) { if (empty($customerId) || strpos($customerId, self::RESOURCE_ID_PREFIX) !== 0) { - throw new ApiException("Invalid order ID: '{$customerId}'. An order ID should start with '".self::RESOURCE_ID_PREFIX."'."); + throw new ApiException("Invalid order ID: '{$customerId}'. An order ID should start with '" . self::RESOURCE_ID_PREFIX . "'."); } return parent::rest_update($customerId, $data); @@ -114,8 +115,23 @@ public function delete($customerId, array $data = []) * @return CustomerCollection * @throws ApiException */ - public function page($from = null, $limit = null, array $parameters = []) + public function page(?string $from = null, ?int $limit = null, array $parameters = []) { return $this->rest_list($from, $limit, $parameters); } + + /** + * Create an iterator for iterating over customers retrieved from Mollie. + * + * @param string $from The first customer ID you want to include in your list. + * @param int $limit + * @param array $parameters + * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). + * + * @return LazyCollection + */ + public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection + { + return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards); + } } diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/CustomerPaymentsEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/CustomerPaymentsEndpoint.php index 3961ea6f3..1730cb245 100644 --- a/vendor_manual/mollie/mollie-api-php/src/Endpoints/CustomerPaymentsEndpoint.php +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/CustomerPaymentsEndpoint.php @@ -3,6 +3,7 @@ namespace Mollie\Api\Endpoints; use Mollie\Api\Resources\Customer; +use Mollie\Api\Resources\LazyCollection; use Mollie\Api\Resources\Payment; use Mollie\Api\Resources\PaymentCollection; @@ -74,11 +75,27 @@ public function createForId($customerId, array $options = [], array $filters = [ * @return PaymentCollection * @throws \Mollie\Api\Exceptions\ApiException */ - public function listFor(Customer $customer, $from = null, $limit = null, array $parameters = []) + public function listFor(Customer $customer, ?string $from = null, ?int $limit = null, array $parameters = []) { return $this->listForId($customer->id, $from, $limit, $parameters); } + /** + * Create an iterator for iterating over payments for the given customer, retrieved from Mollie. + * + * @param Customer $customer + * @param string $from The first resource ID you want to include in your list. + * @param int $limit + * @param array $parameters + * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). + * + * @return LazyCollection + */ + public function iteratorFor(Customer $customer, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection + { + return $this->iteratorForId($customer->id, $from, $limit, $parameters, $iterateBackwards); + } + /** * @param string $customerId * @param string $from The first resource ID you want to include in your list. @@ -88,10 +105,28 @@ public function listFor(Customer $customer, $from = null, $limit = null, array $ * @return \Mollie\Api\Resources\PaymentCollection * @throws \Mollie\Api\Exceptions\ApiException */ - public function listForId($customerId, $from = null, $limit = null, array $parameters = []) + public function listForId($customerId, ?string $from = null, ?int $limit = null, array $parameters = []) { $this->parentId = $customerId; return parent::rest_list($from, $limit, $parameters); } + + /** + * Create an iterator for iterating over payments for the given customer id, retrieved from Mollie. + * + * @param string $customerId + * @param string $from The first resource ID you want to include in your list. + * @param int $limit + * @param array $parameters + * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). + * + * @return LazyCollection + */ + public function iteratorForId(string $customerId, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection + { + $this->parentId = $customerId; + + return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards); + } } diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/InvoiceEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/InvoiceEndpoint.php index a228fd283..e577abd93 100644 --- a/vendor_manual/mollie/mollie-api-php/src/Endpoints/InvoiceEndpoint.php +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/InvoiceEndpoint.php @@ -5,6 +5,7 @@ use Mollie\Api\Exceptions\ApiException; use Mollie\Api\Resources\Invoice; use Mollie\Api\Resources\InvoiceCollection; +use Mollie\Api\Resources\LazyCollection; class InvoiceEndpoint extends CollectionEndpointAbstract { @@ -76,4 +77,19 @@ public function all(array $parameters = []) { return $this->page(null, null, $parameters); } + + /** + * Create an iterator for iterating over invoices retrieved from Mollie. + * + * @param string $from The first resource ID you want to include in your list. + * @param int $limit + * @param array $parameters + * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). + * + * @return LazyCollection + */ + public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection + { + return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards); + } } diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/MandateEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/MandateEndpoint.php index 046eaf2e1..d6dee89f3 100644 --- a/vendor_manual/mollie/mollie-api-php/src/Endpoints/MandateEndpoint.php +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/MandateEndpoint.php @@ -3,6 +3,7 @@ namespace Mollie\Api\Endpoints; use Mollie\Api\Resources\Customer; +use Mollie\Api\Resources\LazyCollection; use Mollie\Api\Resources\Mandate; use Mollie\Api\Resources\MandateCollection; @@ -103,6 +104,22 @@ public function listFor(Customer $customer, $from = null, $limit = null, array $ return $this->listForId($customer->id, $from, $limit, $parameters); } + /** + * Create an iterator for iterating over mandates for the given customer, retrieved from Mollie. + * + * @param Customer $customer + * @param string $from The first resource ID you want to include in your list. + * @param int $limit + * @param array $parameters + * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). + * + * @return LazyCollection + */ + public function iteratorFor(Customer $customer, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection + { + return $this->iteratorForId($customer->id, $from, $limit, $parameters, $iterateBackwards); + } + /** * @param string $customerId * @param null $from @@ -119,6 +136,24 @@ public function listForId($customerId, $from = null, $limit = null, array $param return parent::rest_list($from, $limit, $parameters); } + /** + * Create an iterator for iterating over mandates for the given customer id, retrieved from Mollie. + * + * @param string $customerId + * @param string $from The first resource ID you want to include in your list. + * @param int $limit + * @param array $parameters + * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). + * + * @return LazyCollection + */ + public function iteratorForId(string $customerId, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection + { + $this->parentId = $customerId; + + return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards); + } + /** * @param Customer $customer * @param string $mandateId diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/OrderEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/OrderEndpoint.php index 605544a30..91f7bc347 100644 --- a/vendor_manual/mollie/mollie-api-php/src/Endpoints/OrderEndpoint.php +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/OrderEndpoint.php @@ -3,6 +3,7 @@ namespace Mollie\Api\Endpoints; use Mollie\Api\Exceptions\ApiException; +use Mollie\Api\Resources\LazyCollection; use Mollie\Api\Resources\Order; use Mollie\Api\Resources\OrderCollection; @@ -68,7 +69,7 @@ public function create(array $data = [], array $filters = []) public function update($orderId, array $data = []) { if (empty($orderId) || strpos($orderId, self::RESOURCE_ID_PREFIX) !== 0) { - throw new ApiException("Invalid order ID: '{$orderId}'. An order ID should start with '".self::RESOURCE_ID_PREFIX."'."); + throw new ApiException("Invalid order ID: '{$orderId}'. An order ID should start with '" . self::RESOURCE_ID_PREFIX . "'."); } return parent::rest_update($orderId, $data); @@ -87,7 +88,7 @@ public function update($orderId, array $data = []) public function get($orderId, array $parameters = []) { if (empty($orderId) || strpos($orderId, self::RESOURCE_ID_PREFIX) !== 0) { - throw new ApiException("Invalid order ID: '{$orderId}'. An order ID should start with '".self::RESOURCE_ID_PREFIX."'."); + throw new ApiException("Invalid order ID: '{$orderId}'. An order ID should start with '" . self::RESOURCE_ID_PREFIX . "'."); } return parent::rest_read($orderId, $parameters); @@ -123,8 +124,23 @@ public function cancel($orderId, $parameters = []) * @return OrderCollection * @throws ApiException */ - public function page($from = null, $limit = null, array $parameters = []) + public function page(?string $from = null, ?int $limit = null, array $parameters = []) { return $this->rest_list($from, $limit, $parameters); } + + /** + * Create an iterator for iterating over orders retrieved from Mollie. + * + * @param string $from The first order ID you want to include in your list. + * @param int $limit + * @param array $parameters + * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). + * + * @return LazyCollection + */ + public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection + { + return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards); + } } diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentCaptureEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentCaptureEndpoint.php index 6766235ab..61b2a6d24 100644 --- a/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentCaptureEndpoint.php +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentCaptureEndpoint.php @@ -4,6 +4,7 @@ use Mollie\Api\Resources\Capture; use Mollie\Api\Resources\CaptureCollection; +use Mollie\Api\Resources\LazyCollection; use Mollie\Api\Resources\Payment; class PaymentCaptureEndpoint extends CollectionEndpointAbstract @@ -105,6 +106,22 @@ public function listFor(Payment $payment, array $parameters = []) return $this->listForId($payment->id, $parameters); } + /** + * Create an iterator for iterating over captures 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 array $parameters + * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). + * + * @return LazyCollection + */ + public function iteratorFor(Payment $payment, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection + { + return $this->iteratorForId($payment->id, $from, $limit, $parameters, $iterateBackwards); + } + /** * @param string $paymentId * @param array $parameters @@ -118,4 +135,22 @@ public function listForId($paymentId, array $parameters = []) return parent::rest_list(null, null, $parameters); } + + /** + * Create an iterator for iterating over captures 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 array $parameters + * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). + * + * @return LazyCollection + */ + public function iteratorForId(string $paymentId, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection + { + $this->parentId = $paymentId; + + return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards); + } } diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentChargebackEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentChargebackEndpoint.php index e27ddeb5a..5a232f889 100644 --- a/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentChargebackEndpoint.php +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentChargebackEndpoint.php @@ -4,6 +4,7 @@ use Mollie\Api\Resources\Chargeback; use Mollie\Api\Resources\ChargebackCollection; +use Mollie\Api\Resources\LazyCollection; use Mollie\Api\Resources\Payment; class PaymentChargebackEndpoint extends CollectionEndpointAbstract @@ -73,6 +74,22 @@ public function listFor(Payment $payment, array $parameters = []) return $this->listForId($payment->id, $parameters); } + /** + * Create an iterator for iterating over chargebacks 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 array $parameters + * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). + * + * @return LazyCollection + */ + public function iteratorFor(Payment $payment, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection + { + return $this->iteratorForId($payment->id, $from, $limit, $parameters, $iterateBackwards); + } + /** * @param string $paymentId * @param array $parameters @@ -86,4 +103,22 @@ public function listForId($paymentId, array $parameters = []) return parent::rest_list(null, null, $parameters); } + + /** + * Create an iterator for iterating over chargebacks 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 array $parameters + * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). + * + * @return LazyCollection + */ + public function iteratorForId(string $paymentId, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection + { + $this->parentId = $paymentId; + + return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards); + } } diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentEndpoint.php index a840863e7..79b1c6b6e 100644 --- a/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentEndpoint.php +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentEndpoint.php @@ -3,6 +3,7 @@ namespace Mollie\Api\Endpoints; use Mollie\Api\Exceptions\ApiException; +use Mollie\Api\Resources\LazyCollection; use Mollie\Api\Resources\Payment; use Mollie\Api\Resources\PaymentCollection; use Mollie\Api\Resources\Refund; @@ -66,7 +67,7 @@ public function create(array $data = [], array $filters = []) public function update($paymentId, array $data = []) { if (empty($paymentId) || strpos($paymentId, self::RESOURCE_ID_PREFIX) !== 0) { - throw new ApiException("Invalid payment ID: '{$paymentId}'. A payment ID should start with '".self::RESOURCE_ID_PREFIX."'."); + throw new ApiException("Invalid payment ID: '{$paymentId}'. A payment ID should start with '" . self::RESOURCE_ID_PREFIX . "'."); } return parent::rest_update($paymentId, $data); @@ -85,7 +86,7 @@ public function update($paymentId, array $data = []) public function get($paymentId, array $parameters = []) { if (empty($paymentId) || strpos($paymentId, self::RESOURCE_ID_PREFIX) !== 0) { - throw new ApiException("Invalid payment ID: '{$paymentId}'. A payment ID should start with '".self::RESOURCE_ID_PREFIX."'."); + throw new ApiException("Invalid payment ID: '{$paymentId}'. A payment ID should start with '" . self::RESOURCE_ID_PREFIX . "'."); } return parent::rest_read($paymentId, $parameters); @@ -140,6 +141,21 @@ public function page($from = null, $limit = null, array $parameters = []) return $this->rest_list($from, $limit, $parameters); } + /** + * Create an iterator for iterating over payments retrieved from Mollie. + * + * @param string $from The first resource ID you want to include in your list. + * @param int $limit + * @param array $parameters + * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). + * + * @return LazyCollection + */ + public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection + { + return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards); + } + /** * Issue a refund for the given payment. * diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentLinkEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentLinkEndpoint.php index 8f3f3bef1..f27d09ddf 100644 --- a/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentLinkEndpoint.php +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentLinkEndpoint.php @@ -3,6 +3,7 @@ namespace Mollie\Api\Endpoints; use Mollie\Api\Exceptions\ApiException; +use Mollie\Api\Resources\LazyCollection; use Mollie\Api\Resources\Payment; use Mollie\Api\Resources\PaymentLink; use Mollie\Api\Resources\PaymentLinkCollection; @@ -64,7 +65,7 @@ public function create(array $data = [], array $filters = []) public function get($paymentLinkId, array $parameters = []) { if (empty($paymentLinkId) || strpos($paymentLinkId, self::RESOURCE_ID_PREFIX) !== 0) { - throw new ApiException("Invalid payment link ID: '{$paymentLinkId}'. A payment link ID should start with '".self::RESOURCE_ID_PREFIX."'."); + throw new ApiException("Invalid payment link ID: '{$paymentLinkId}'. A payment link ID should start with '" . self::RESOURCE_ID_PREFIX . "'."); } return parent::rest_read($paymentLinkId, $parameters); @@ -84,4 +85,19 @@ public function page($from = null, $limit = null, array $parameters = []) { return $this->rest_list($from, $limit, $parameters); } + + /** + * Create an iterator for iterating over payment links retrieved from Mollie. + * + * @param string $from The first resource ID you want to include in your list. + * @param int $limit + * @param array $parameters + * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). + * + * @return LazyCollection + */ + public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection + { + return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards); + } } diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentRefundEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentRefundEndpoint.php index 3dfa24696..68524ec8c 100644 --- a/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentRefundEndpoint.php +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentRefundEndpoint.php @@ -2,6 +2,7 @@ namespace Mollie\Api\Endpoints; +use Mollie\Api\Resources\LazyCollection; use Mollie\Api\Resources\Payment; use Mollie\Api\Resources\Refund; use Mollie\Api\Resources\RefundCollection; @@ -73,6 +74,22 @@ public function listFor(Payment $payment, array $parameters = []) return $this->listForId($payment->id, $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 array $parameters + * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). + * + * @return LazyCollection + */ + public function iteratorFor(Payment $payment, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection + { + return $this->iteratorForId($payment->id, $from, $limit, $parameters, $iterateBackwards); + } + /** * @param string $paymentId * @param array $parameters @@ -87,6 +104,24 @@ public function listForId($paymentId, array $parameters = []) return parent::rest_list(null, null, $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 array $parameters + * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). + * + * @return LazyCollection + */ + public function iteratorForId(string $paymentId, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection + { + $this->parentId = $paymentId; + + return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards); + } + /** * Creates a refund for a specific payment. diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/ProfileEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/ProfileEndpoint.php index 498d442ad..d430275c9 100644 --- a/vendor_manual/mollie/mollie-api-php/src/Endpoints/ProfileEndpoint.php +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/ProfileEndpoint.php @@ -4,6 +4,7 @@ use Mollie\Api\Exceptions\ApiException; use Mollie\Api\Resources\CurrentProfile; +use Mollie\Api\Resources\LazyCollection; use Mollie\Api\Resources\Profile; use Mollie\Api\Resources\ProfileCollection; @@ -88,7 +89,7 @@ public function get($profileId, array $parameters = []) public function update($profileId, array $data = []) { if (empty($profileId) || strpos($profileId, self::RESOURCE_ID_PREFIX) !== 0) { - throw new ApiException("Invalid profile id: '{$profileId}'. An profile id should start with '".self::RESOURCE_ID_PREFIX."'."); + throw new ApiException("Invalid profile id: '{$profileId}'. An profile id should start with '" . self::RESOURCE_ID_PREFIX . "'."); } return parent::rest_update($profileId, $data); @@ -140,4 +141,19 @@ public function page($from = null, $limit = null, array $parameters = []) { return $this->rest_list($from, $limit, $parameters); } + + /** + * Create an iterator for iterating over profiles retrieved from Mollie. + * + * @param string $from The first resource ID you want to include in your list. + * @param int $limit + * @param array $parameters + * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). + * + * @return LazyCollection + */ + public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection + { + return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards); + } } diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/RefundEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/RefundEndpoint.php index 385e21c0f..de03c477a 100644 --- a/vendor_manual/mollie/mollie-api-php/src/Endpoints/RefundEndpoint.php +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/RefundEndpoint.php @@ -3,6 +3,7 @@ namespace Mollie\Api\Endpoints; use Mollie\Api\Exceptions\ApiException; +use Mollie\Api\Resources\LazyCollection; use Mollie\Api\Resources\Refund; use Mollie\Api\Resources\RefundCollection; @@ -47,4 +48,19 @@ public function page($from = null, $limit = null, array $parameters = []) { return $this->rest_list($from, $limit, $parameters); } + + /** + * Create an iterator for iterating over refunds retrieved from Mollie. + * + * @param string $from The first resource ID you want to include in your list. + * @param int $limit + * @param array $parameters + * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). + * + * @return LazyCollection + */ + public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection + { + return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards); + } } diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/SettlementCaptureEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/SettlementCaptureEndpoint.php new file mode 100644 index 000000000..3e51443ef --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/SettlementCaptureEndpoint.php @@ -0,0 +1,63 @@ +client); + } + + protected function getResourceCollectionObject($count, $_links) + { + return new CaptureCollection($this->client, $count, $_links); + } + + /** + * Retrieves a collection of Settlement Captures from Mollie. + * + * @param string $settlementId + * @param string|null $from The first capture ID you want to include in your list. + * @param int|null $limit + * @param array $parameters + * + * @return mixed + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function pageForId(string $settlementId, string $from = null, int $limit = null, array $parameters = []) + { + $this->parentId = $settlementId; + + return $this->rest_list($from, $limit, $parameters); + } + + /** + * Create an iterator for iterating over captures for the given settlement id, retrieved from Mollie. + * + * @param string $settlementId + * @param string $from The first resource ID you want to include in your list. + * @param int $limit + * @param array $parameters + * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). + * + * @return LazyCollection + */ + public function iteratorForId(string $settlementId, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection + { + $this->parentId = $settlementId; + + return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/SettlementChargebackEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/SettlementChargebackEndpoint.php new file mode 100644 index 000000000..585ccf2c5 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/SettlementChargebackEndpoint.php @@ -0,0 +1,66 @@ +client); + } + + /** + * @inheritDoc + */ + protected function getResourceCollectionObject($count, $_links) + { + return new ChargebackCollection($this->client, $count, $_links); + } + + /** + * Retrieves a collection of Settlement Chargebacks from Mollie. + * + * @param string $settlementId + * @param string|null $from The first chargeback ID you want to include in your list. + * @param int|null $limit + * @param array $parameters + * + * @return mixed + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function pageForId(string $settlementId, string $from = null, int $limit = null, array $parameters = []) + { + $this->parentId = $settlementId; + + return $this->rest_list($from, $limit, $parameters); + } + + /** + * Create an iterator for iterating over chargeback for the given settlement id, retrieved from Mollie. + * + * @param string $settlementId + * @param string $from The first resource ID you want to include in your list. + * @param int $limit + * @param array $parameters + * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). + * + * @return LazyCollection + */ + public function iteratorForId(string $settlementId, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection + { + $this->parentId = $settlementId; + + return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/SettlementPaymentEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/SettlementPaymentEndpoint.php index 6ac8304e5..ed9b10b5f 100644 --- a/vendor_manual/mollie/mollie-api-php/src/Endpoints/SettlementPaymentEndpoint.php +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/SettlementPaymentEndpoint.php @@ -2,6 +2,7 @@ namespace Mollie\Api\Endpoints; +use Mollie\Api\Resources\LazyCollection; use Mollie\Api\Resources\Payment; use Mollie\Api\Resources\PaymentCollection; @@ -42,4 +43,22 @@ public function pageForId($settlementId, $from = null, $limit = null, array $par return $this->rest_list($from, $limit, $parameters); } + + /** + * Create an iterator for iterating over payments for the given settlement id, retrieved from Mollie. + * + * @param string $settlementId + * @param string $from The first resource ID you want to include in your list. + * @param int $limit + * @param array $parameters + * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). + * + * @return LazyCollection + */ + public function iteratorForId(string $settlementId, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection + { + $this->parentId = $settlementId; + + return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards); + } } diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/SettlementRefundEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/SettlementRefundEndpoint.php new file mode 100644 index 000000000..4f751da79 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/SettlementRefundEndpoint.php @@ -0,0 +1,66 @@ +client, $count, $_links); + } + + /** + * @inheritDoc + */ + protected function getResourceObject() + { + return new Refund($this->client); + } + + /** + * Retrieves a collection of Settlement Refunds from Mollie. + * + * @param string $settlementId + * @param string|null $from The first refund ID you want to include in your list. + * @param int|null $limit + * @param array $parameters + * + * @return mixed + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function pageForId(string $settlementId, string $from = null, int $limit = null, array $parameters = []) + { + $this->parentId = $settlementId; + + return $this->rest_list($from, $limit, $parameters); + } + + /** + * Create an iterator for iterating over refunds for the given settlement id, retrieved from Mollie. + * + * @param string $settlementId + * @param string $from The first resource ID you want to include in your list. + * @param int $limit + * @param array $parameters + * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). + * + * @return LazyCollection + */ + public function iteratorForId(string $settlementId, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection + { + $this->parentId = $settlementId; + + return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/SettlementsEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/SettlementsEndpoint.php index a4d49e85e..76c7cad84 100644 --- a/vendor_manual/mollie/mollie-api-php/src/Endpoints/SettlementsEndpoint.php +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/SettlementsEndpoint.php @@ -3,6 +3,7 @@ namespace Mollie\Api\Endpoints; use Mollie\Api\Exceptions\ApiException; +use Mollie\Api\Resources\LazyCollection; use Mollie\Api\Resources\Settlement; use Mollie\Api\Resources\SettlementCollection; @@ -84,4 +85,19 @@ public function page($from = null, $limit = null, array $parameters = []) { return $this->rest_list($from, $limit, $parameters); } + + /** + * Create an iterator for iterating over settlements retrieved from Mollie. + * + * @param string $from The first resource ID you want to include in your list. + * @param int $limit + * @param array $parameters + * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). + * + * @return LazyCollection + */ + public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection + { + return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards); + } } diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/ShipmentEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/ShipmentEndpoint.php index 6456ab7ca..c62bcb361 100644 --- a/vendor_manual/mollie/mollie-api-php/src/Endpoints/ShipmentEndpoint.php +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/ShipmentEndpoint.php @@ -121,7 +121,7 @@ public function getForId($orderId, $shipmentId, array $parameters = []) public function update($orderId, $shipmentId, array $data = []) { if (empty($shipmentId) || strpos($shipmentId, self::RESOURCE_ID_PREFIX) !== 0) { - throw new ApiException("Invalid subscription ID: '{$shipmentId}'. An subscription ID should start with '".self::RESOURCE_ID_PREFIX."'."); + throw new ApiException("Invalid subscription ID: '{$shipmentId}'. An subscription ID should start with '" . self::RESOURCE_ID_PREFIX . "'."); } $this->parentId = $orderId; diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/SubscriptionEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/SubscriptionEndpoint.php index d9b919af3..8e2d8122c 100644 --- a/vendor_manual/mollie/mollie-api-php/src/Endpoints/SubscriptionEndpoint.php +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/SubscriptionEndpoint.php @@ -4,6 +4,7 @@ use Mollie\Api\Exceptions\ApiException; use Mollie\Api\Resources\Customer; +use Mollie\Api\Resources\LazyCollection; use Mollie\Api\Resources\ResourceFactory; use Mollie\Api\Resources\Subscription; use Mollie\Api\Resources\SubscriptionCollection; @@ -88,7 +89,7 @@ public function createForId($customerId, array $options = [], array $filters = [ public function update($customerId, $subscriptionId, array $data = []) { if (empty($subscriptionId) || strpos($subscriptionId, self::RESOURCE_ID_PREFIX) !== 0) { - throw new ApiException("Invalid subscription ID: '{$subscriptionId}'. An subscription ID should start with '".self::RESOURCE_ID_PREFIX."'."); + throw new ApiException("Invalid subscription ID: '{$subscriptionId}'. An subscription ID should start with '" . self::RESOURCE_ID_PREFIX . "'."); } $this->parentId = $customerId; @@ -138,6 +139,22 @@ public function listFor(Customer $customer, $from = null, $limit = null, array $ return $this->listForId($customer->id, $from, $limit, $parameters); } + /** + * Create an iterator for iterating over subscriptions for the given customer, retrieved from Mollie. + * + * @param Customer $customer + * @param string $from The first resource ID you want to include in your list. + * @param int $limit + * @param array $parameters + * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). + * + * @return LazyCollection + */ + public function iteratorFor(Customer $customer, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection + { + return $this->iteratorForId($customer->id, $from, $limit, $parameters, $iterateBackwards); + } + /** * @param string $customerId * @param string $from The first resource ID you want to include in your list. @@ -154,6 +171,24 @@ public function listForId($customerId, $from = null, $limit = null, array $param return parent::rest_list($from, $limit, $parameters); } + /** + * Create an iterator for iterating over subscriptions for the given customer id, retrieved from Mollie. + * + * @param string $customerId + * @param string $from The first resource ID you want to include in your list. + * @param int $limit + * @param array $parameters + * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). + * + * @return LazyCollection + */ + public function iteratorForId(string $customerId, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection + { + $this->parentId = $customerId; + + return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards); + } + /** * @param Customer $customer * @param string $subscriptionId @@ -209,4 +244,21 @@ public function page($from = null, $limit = null, array $parameters = []) return $collection; } + + /** + * Create an iterator for iterating over subscriptions retrieved from Mollie. + * + * @param string $from The first resource ID you want to include in your list. + * @param int $limit + * @param array $parameters + * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). + * + * @return LazyCollection + */ + public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection + { + $page = $this->page($from, $limit, $parameters); + + return $page->getAutoIterator($iterateBackwards); + } } diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/TerminalEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/TerminalEndpoint.php index 4b100b566..4f7a65c62 100644 --- a/vendor_manual/mollie/mollie-api-php/src/Endpoints/TerminalEndpoint.php +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/TerminalEndpoint.php @@ -3,6 +3,7 @@ namespace Mollie\Api\Endpoints; use Mollie\Api\Exceptions\ApiException; +use Mollie\Api\Resources\LazyCollection; use Mollie\Api\Resources\Terminal; use Mollie\Api\Resources\TerminalCollection; @@ -69,4 +70,19 @@ public function page($from = null, $limit = null, array $parameters = []) { return $this->rest_list($from, $limit, $parameters); } + + /** + * Create an iterator for iterating over terminals retrieved from Mollie. + * + * @param string $from The first resource ID you want to include in your list. + * @param int $limit + * @param array $parameters + * @param bool $iterateBackwards Set to true for reverse order iteration (default is false). + * + * @return LazyCollection + */ + public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection + { + return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards); + } } diff --git a/vendor_manual/mollie/mollie-api-php/src/MollieApiClient.php b/vendor_manual/mollie/mollie-api-php/src/MollieApiClient.php index 86f5d5c7a..a7a1a35e7 100644 --- a/vendor_manual/mollie/mollie-api-php/src/MollieApiClient.php +++ b/vendor_manual/mollie/mollie-api-php/src/MollieApiClient.php @@ -30,7 +30,10 @@ use Mollie\Api\Endpoints\ProfileEndpoint; use Mollie\Api\Endpoints\ProfileMethodEndpoint; use Mollie\Api\Endpoints\RefundEndpoint; +use Mollie\Api\Endpoints\SettlementCaptureEndpoint; +use Mollie\Api\Endpoints\SettlementChargebackEndpoint; use Mollie\Api\Endpoints\SettlementPaymentEndpoint; +use Mollie\Api\Endpoints\SettlementRefundEndpoint; use Mollie\Api\Endpoints\SettlementsEndpoint; use Mollie\Api\Endpoints\ShipmentEndpoint; use Mollie\Api\Endpoints\SubscriptionEndpoint; @@ -47,7 +50,7 @@ class MollieApiClient /** * Version of our client. */ - public const CLIENT_VERSION = "2.61.0"; + public const CLIENT_VERSION = "2.65.0"; /** * Endpoint of the remote API. @@ -117,6 +120,20 @@ class MollieApiClient */ public $settlements; + /** + * RESTful Settlement capture resource. + * + * @var \Mollie\Api\Endpoints\SettlementCaptureEndpoint + */ + public $settlementCaptures; + + /** + * RESTful Settlement chargeback resource. + * + * @var \Mollie\Api\Endpoints\SettlementChargebackEndpoint + */ + public $settlementChargebacks; + /** * RESTful Settlement payment resource. * @@ -124,6 +141,13 @@ class MollieApiClient */ public $settlementPayments; + /** + * RESTful Settlement refund resource. + * + * @var \Mollie\Api\Endpoints\SettlementRefundEndpoint + */ + public $settlementRefunds; + /** * RESTful Subscription resource. * @@ -365,7 +389,10 @@ public function initializeEndpoints() $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); diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/CursorCollection.php b/vendor_manual/mollie/mollie-api-php/src/Resources/CursorCollection.php index e32653351..0f83c7e56 100644 --- a/vendor_manual/mollie/mollie-api-php/src/Resources/CursorCollection.php +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/CursorCollection.php @@ -2,6 +2,7 @@ namespace Mollie\Api\Resources; +use Generator; use Mollie\Api\MollieApiClient; abstract class CursorCollection extends BaseCollection @@ -93,4 +94,32 @@ public function hasPrevious() { return isset($this->_links->previous->href); } + + /** + * Iterate over a CursorCollection and yield its elements. + * + * @param bool $iterateBackwards + * + * @return LazyCollection + */ + public function getAutoIterator(bool $iterateBackwards = false): LazyCollection + { + $page = $this; + + return new LazyCollection(function () use ($page, $iterateBackwards): Generator { + while (true) { + foreach ($page as $item) { + yield $item; + } + + if (($iterateBackwards && ! $page->hasPrevious()) || ! $page->hasNext()) { + break; + } + + $page = $iterateBackwards + ? $page->previous() + : $page->next(); + } + }); + } } diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/LazyCollection.php b/vendor_manual/mollie/mollie-api-php/src/Resources/LazyCollection.php new file mode 100644 index 000000000..0fc90f081 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/LazyCollection.php @@ -0,0 +1,198 @@ + + */ +class LazyCollection implements IteratorAggregate +{ + /** + * @var callable + */ + private $source; + + /** + * @param callable $source + */ + public function __construct($source) + { + $this->source = $source; + } + + /** + * Get all items in the collection. + * + * @return array + */ + public function all(): array + { + return iterator_to_array($this->getIterator()); + } + + /** + * Get an item from the collection by key. + * + * @param TKey $key + * @return TValue|null + */ + public function get($key) + { + foreach ($this as $outerKey => $outerValue) { + if ($outerKey == $key) { + return $outerValue; + } + } + + return null; + } + + /** + * Run a filter over each of the items. + * + * @param (callable(TValue, TKey): bool) $callback + * @return self + */ + public function filter(callable $callback): self + { + return new self(function () use ($callback) { + foreach ($this as $key => $value) { + if ($callback($value, $key)) { + yield $key => $value; + } + } + }); + } + + /** + * Get the first item from the collection passing the given truth test. + * + * @param (callable(TValue, TKey): bool)|null $callback + * @return TValue|null + */ + public function first(callable $callback = null) + { + $iterator = $this->getIterator(); + + if (is_null($callback)) { + if (! $iterator->valid()) { + return null; + } + + return $iterator->current(); + } + + foreach ($iterator as $key => $value) { + if ($callback($value, $key)) { + return $value; + } + } + + return null; + } + + /** + * Run a map over each of the items. + * + * @template TMapValue + * + * @param callable(TValue, TKey): TMapValue $callback + * @return static + */ + public function map(callable $callback): self + { + return new self(function () use ($callback) { + foreach ($this as $key => $value) { + yield $key => $callback($value, $key); + } + }); + } + + /** + * Take the first {$limit} items. + * + * @param int $limit + * @return static + */ + public function take(int $limit): self + { + return new self(function () use ($limit) { + $iterator = $this->getIterator(); + + while ($limit--) { + if (! $iterator->valid()) { + break; + } + + yield $iterator->key() => $iterator->current(); + + if ($limit) { + $iterator->next(); + } + } + }); + } + + /** + * Determine if all items pass the given truth test. + * + * @param (callable(TValue, TKey): bool) $callback + * @return bool + */ + public function every(callable $callback): bool + { + $iterator = $this->getIterator(); + + foreach ($iterator as $key => $value) { + if (! $callback($value, $key)) { + return false; + } + } + + return true; + } + + /** + * Count the number of items in the collection. + * + * @return int + */ + public function count(): int + { + return iterator_count($this->getIterator()); + } + + /** + * Get an iterator for the items. + * + * @return Iterator + */ + public function getIterator(): Iterator + { + return $this->makeIterator($this->source); + } + + /** + * Get an iterator for the given value. + * + * @template TIteratorKey of array-key + * @template TIteratorValue + * + * @param IteratorAggregate|(callable(): \Generator) $source + * @return Iterator + */ + protected function makeIterator($source): Iterator + { + if ($source instanceof IteratorAggregate) { + return $source->getIterator(); + } + + return $source(); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/Settlement.php b/vendor_manual/mollie/mollie-api-php/src/Resources/Settlement.php index 8bdef55ac..54f71cd24 100644 --- a/vendor_manual/mollie/mollie-api-php/src/Resources/Settlement.php +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/Settlement.php @@ -3,7 +3,6 @@ namespace Mollie\Api\Resources; use Mollie\Api\Exceptions\ApiException; -use Mollie\Api\MollieApiClient; use Mollie\Api\Types\SettlementStatus; class Settlement extends BaseResource @@ -92,7 +91,7 @@ public function isPending() } /** - * Is this settlement paidout? + * Is this settlement paid out? * * @return bool */ @@ -102,7 +101,7 @@ public function isPaidout() } /** - * Is this settlement failed? + * Has this settlement failed? * * @return bool */ @@ -112,7 +111,7 @@ public function isFailed() } /** - * Retrieves all payments associated with this settlement + * Retrieve the first page of payments associated with this settlement. * * @param int|null $limit * @param array $parameters @@ -121,72 +120,65 @@ public function isFailed() */ public function payments(int $limit = null, array $parameters = []): PaymentCollection { - return $this->client->settlementPayments->pageForId($this->id, null, $limit, $parameters); + return $this->client->settlementPayments->pageForId( + $this->id, + null, + $limit, + $parameters + ); } /** - * Retrieves all refunds associated with this settlement + * Retrieve the first page of refunds associated with this settlement. * + * @param int|null $limit + * @param array $parameters * @return RefundCollection * @throws ApiException */ - public function refunds() + public function refunds(int $limit = null, array $parameters = []) { - if (! isset($this->_links->refunds->href)) { - return new RefundCollection($this->client, 0, null); - } - - $result = $this->client->performHttpCallToFullUrl(MollieApiClient::HTTP_GET, $this->_links->refunds->href); - - return ResourceFactory::createCursorResourceCollection( - $this->client, - $result->_embedded->refunds, - Refund::class, - $result->_links + return $this->client->settlementRefunds->pageForId( + $this->id, + null, + $limit, + $parameters ); } /** - * Retrieves all chargebacks associated with this settlement + * Retrieve the first page of chargebacks associated with this settlement. * + * @param int|null $limit + * @param array $parameters * @return ChargebackCollection * @throws ApiException */ - public function chargebacks() + public function chargebacks(int $limit = null, array $parameters = []) { - if (! isset($this->_links->chargebacks->href)) { - return new ChargebackCollection($this->client, 0, null); - } - - $result = $this->client->performHttpCallToFullUrl(MollieApiClient::HTTP_GET, $this->_links->chargebacks->href); - - return ResourceFactory::createCursorResourceCollection( - $this->client, - $result->_embedded->chargebacks, - Chargeback::class, - $result->_links + return $this->client->settlementChargebacks->pageForId( + $this->id, + null, + $limit, + $parameters ); } /** - * Retrieves all captures associated with this settlement + * Retrieve the first page of cap associated with this settlement. * + * @param int|null $limit + * @param array $parameters * @return CaptureCollection * @throws ApiException */ - public function captures() + public function captures(int $limit = null, array $parameters = []) { - if (! isset($this->_links->captures->href)) { - return new CaptureCollection($this->client, 0, null); - } - - $result = $this->client->performHttpCallToFullUrl(MollieApiClient::HTTP_GET, $this->_links->captures->href); - - return ResourceFactory::createCursorResourceCollection( - $this->client, - $result->_embedded->captures, - Capture::class, - $result->_links + return $this->client->settlementCaptures->pageForId( + $this->id, + null, + $limit, + $parameters ); } } diff --git a/vendor_manual/mollie/mollie-api-php/src/Types/PaymentMethod.php b/vendor_manual/mollie/mollie-api-php/src/Types/PaymentMethod.php index 7c7436565..512804288 100644 --- a/vendor_manual/mollie/mollie-api-php/src/Types/PaymentMethod.php +++ b/vendor_manual/mollie/mollie-api-php/src/Types/PaymentMethod.php @@ -4,11 +4,21 @@ class PaymentMethod { + /** + * @link https://www.mollie.com/en/payments/alma + */ + public const ALMA = "alma"; + /** * @link https://www.mollie.com/en/payments/applepay */ public const APPLEPAY = "applepay"; + /** + * @link https://www.mollie.com/en/payments/bancomatpay + */ + public const BANCOMATPAY = "bancomatpay"; + /** * @link https://www.mollie.com/en/payments/bancontact */ @@ -34,6 +44,11 @@ class PaymentMethod */ public const BITCOIN = "bitcoin"; + /** + * @link https://www.mollie.com/en/payments/blik + */ + public const BLIK = "blik"; + /** * @link https://www.mollie.com/en/payments/credit-card */ @@ -79,11 +94,13 @@ class PaymentMethod */ public const KBC = "kbc"; + public const KLARNA_ONE = "klarna"; + /** * @link https://www.mollie.com/en/payments/klarna-pay-later */ public const KLARNA_PAY_LATER = "klarnapaylater"; - + /** * @link https://www.mollie.com/en/payments/klarna-pay-now */ @@ -124,7 +141,7 @@ class PaymentMethod * @link https://www.mollie.com/en/payments/sofort */ public const SOFORT = "sofort"; - + /** * @link https://www.mollie.com/en/payments/in3 */ @@ -134,4 +151,9 @@ class PaymentMethod * @link https://docs.mollie.com/point-of-sale/overview */ public const POINT_OF_SALE = "pointofsale"; + + /** + * @link https://www.mollie.com/en/payments/twint + */ + public const TWINT = "twint"; }