From 9270bc906d4f0c765f39797b0ef3a78198872c20 Mon Sep 17 00:00:00 2001 From: Vitalij Mik Date: Mon, 18 Mar 2024 15:18:03 +0100 Subject: [PATCH 1/8] NTR: Squashed commit of the following: commit 70fe37e90ccacd1c97748110e21300c1cb16ccc5 Author: Vitalij Mik Date: Mon Mar 18 15:17:08 2024 +0100 NTR: update mollie lbirary (#723) Co-authored-by: Vitalij Mik --- vendor_manual/mollie/mollie-api-php/README.md | 337 ++++++++++++++---- .../src/Endpoints/BalanceEndpoint.php | 18 +- .../Endpoints/BalanceTransactionEndpoint.php | 46 +++ .../src/Endpoints/ChargebackEndpoint.php | 18 +- .../src/Endpoints/ClientEndpoint.php | 18 +- .../Endpoints/CollectionEndpointAbstract.php | 25 +- .../src/Endpoints/CustomerEndpoint.php | 20 +- .../Endpoints/CustomerPaymentsEndpoint.php | 39 +- .../src/Endpoints/InvoiceEndpoint.php | 16 + .../src/Endpoints/MandateEndpoint.php | 35 ++ .../src/Endpoints/OrderEndpoint.php | 22 +- .../src/Endpoints/PaymentCaptureEndpoint.php | 35 ++ .../Endpoints/PaymentChargebackEndpoint.php | 35 ++ .../src/Endpoints/PaymentEndpoint.php | 20 +- .../src/Endpoints/PaymentLinkEndpoint.php | 18 +- .../src/Endpoints/PaymentRefundEndpoint.php | 35 ++ .../src/Endpoints/ProfileEndpoint.php | 18 +- .../src/Endpoints/RefundEndpoint.php | 16 + .../Endpoints/SettlementCaptureEndpoint.php | 63 ++++ .../SettlementChargebackEndpoint.php | 66 ++++ .../Endpoints/SettlementPaymentEndpoint.php | 19 + .../Endpoints/SettlementRefundEndpoint.php | 66 ++++ .../src/Endpoints/SettlementsEndpoint.php | 16 + .../src/Endpoints/ShipmentEndpoint.php | 2 +- .../src/Endpoints/SubscriptionEndpoint.php | 54 ++- .../src/Endpoints/TerminalEndpoint.php | 16 + .../mollie-api-php/src/MollieApiClient.php | 29 +- .../src/Resources/CursorCollection.php | 29 ++ .../src/Resources/LazyCollection.php | 198 ++++++++++ .../src/Resources/Settlement.php | 80 ++--- .../src/Types/PaymentMethod.php | 26 +- 31 files changed, 1292 insertions(+), 143 deletions(-) create mode 100644 vendor_manual/mollie/mollie-api-php/src/Endpoints/SettlementCaptureEndpoint.php create mode 100644 vendor_manual/mollie/mollie-api-php/src/Endpoints/SettlementChargebackEndpoint.php create mode 100644 vendor_manual/mollie/mollie-api-php/src/Endpoints/SettlementRefundEndpoint.php create mode 100644 vendor_manual/mollie/mollie-api-php/src/Resources/LazyCollection.php 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"; } From c6f4d8321289ee89bafb7806fbeb2b9d9a4e4a2f Mon Sep 17 00:00:00 2001 From: Vitalij Mik Date: Mon, 18 Mar 2024 15:29:13 +0100 Subject: [PATCH 2/8] NTR: PISHPS-229: add bancomat pay --- .../ApplePayDirect/ApplePayDirect.php | 3 +- src/Facade/MolliePaymentDoPay.php | 16 +++- src/Handler/Method/BancomatPayment.php | 34 +++++++++ src/Handler/PaymentHandler.php | 3 +- .../plugins/bancomat-plugin.js | 37 +++++++++ src/Resources/app/storefront/src/register.js | 3 + src/Resources/config/services/handlers.xml | 7 ++ .../snippet/de_DE/mollie-payments.de-DE.json | 4 + .../snippet/en_GB/mollie-payments.en-GB.json | 4 + .../snippet/nl_NL/mollie-payments.nl-NL.json | 4 + src/Resources/views/storefront/base.html.twig | 10 +-- .../component/bancomat-fields.html.twig | 18 +++++ .../payment/payment-fields.html.twig | 2 + .../payment/payment-method.html.twig | 2 + src/Service/PaymentMethodService.php | 2 + src/Struct/Order/OrderAttributes.php | 27 +++++++ .../storefront/payment-methods/bancomat.cy.js | 43 +++++++++++ .../Payments/BancomatOrderBuilderTest.php | 76 +++++++++++++++++++ .../Service/PaymentMethodServiceTest.php | 2 + 19 files changed, 289 insertions(+), 8 deletions(-) create mode 100644 src/Handler/Method/BancomatPayment.php create mode 100644 src/Resources/app/storefront/src/mollie-payments/plugins/bancomat-plugin.js create mode 100644 src/Resources/views/storefront/component/payment/component/bancomat-fields.html.twig create mode 100644 tests/Cypress/cypress/e2e/storefront/payment-methods/bancomat.cy.js create mode 100644 tests/PHPUnit/Service/MollieApi/Builder/Payments/BancomatOrderBuilderTest.php diff --git a/src/Components/ApplePayDirect/ApplePayDirect.php b/src/Components/ApplePayDirect/ApplePayDirect.php index bcb490c93..9909a8728 100644 --- a/src/Components/ApplePayDirect/ApplePayDirect.php +++ b/src/Components/ApplePayDirect/ApplePayDirect.php @@ -31,6 +31,7 @@ use Shopware\Core\Checkout\Order\OrderEntity; use Shopware\Core\Checkout\Payment\Cart\AsyncPaymentTransactionStruct; use Shopware\Core\Framework\Validation\DataBag\DataBag; +use Shopware\Core\Framework\Validation\DataBag\RequestDataBag; use Shopware\Core\System\SalesChannel\SalesChannelContext; class ApplePayDirect @@ -458,7 +459,7 @@ public function createPayment(OrderEntity $order, string $shopwareReturnUrl, str # This is required for a smooth checkout with our already validated Apple Pay transaction. $this->paymentHandler->setToken($paymentToken); - $paymentData = $this->molliePayments->startMolliePayment(ApplePayPayment::PAYMENT_METHOD_NAME, $asyncPaymentTransition, $context, $this->paymentHandler); + $paymentData = $this->molliePayments->startMolliePayment(ApplePayPayment::PAYMENT_METHOD_NAME, $asyncPaymentTransition, $context, $this->paymentHandler, new RequestDataBag()); # now also update the custom fields of our order # we want to have the mollie metadata in the diff --git a/src/Facade/MolliePaymentDoPay.php b/src/Facade/MolliePaymentDoPay.php index 171d97b7d..3547ee2df 100644 --- a/src/Facade/MolliePaymentDoPay.php +++ b/src/Facade/MolliePaymentDoPay.php @@ -30,6 +30,7 @@ use Shopware\Core\Checkout\Order\Aggregate\OrderLineItem\OrderLineItemCollection; use Shopware\Core\Checkout\Order\OrderEntity; use Shopware\Core\Checkout\Payment\Cart\AsyncPaymentTransactionStruct; +use Shopware\Core\Framework\Validation\DataBag\RequestDataBag; use Shopware\Core\System\SalesChannel\SalesChannelContext; use Twig\Environment; use Twig\Extension\CoreExtension; @@ -135,10 +136,11 @@ public function __construct(OrderDataExtractor $extractor, MollieOrderBuilder $o * @param AsyncPaymentTransactionStruct $transactionStruct * @param SalesChannelContext $salesChannelContext * @param PaymentHandler $paymentHandler + * @param RequestDataBag $dataBag * @throws ApiException * @return MolliePaymentPrepareData */ - public function startMolliePayment(string $paymentMethod, AsyncPaymentTransactionStruct $transactionStruct, SalesChannelContext $salesChannelContext, PaymentHandler $paymentHandler): MolliePaymentPrepareData + public function startMolliePayment(string $paymentMethod, AsyncPaymentTransactionStruct $transactionStruct, SalesChannelContext $salesChannelContext, PaymentHandler $paymentHandler, RequestDataBag $dataBag): MolliePaymentPrepareData { $settings = $this->settingsService->getSettings($salesChannelContext->getSalesChannelId()); @@ -172,6 +174,16 @@ public function startMolliePayment(string $paymentMethod, AsyncPaymentTransactio $mollieOrderId = $orderCustomFields->getMollieOrderId(); + $bancomatPayPhoneNumber = $dataBag->get('mollieBancomatPayPhone'); + + if ($bancomatPayPhoneNumber !== null) { + ## we need to pass the custom fields now, so we can use them in create order and display the number on failed orders + $orderCustomFields->setBancomatPayPhoneNumber($bancomatPayPhoneNumber); + $order->setCustomFields($orderCustomFields->toArray()); + $this->updaterOrderCustomFields->updateOrder($order->getId(), $orderCustomFields, $salesChannelContext->getContext()); + } + + # now let's check if we have another payment attempt for an existing order. # this is the case, if we already have a Mollie Order ID in our custom fields. # in this case, we just add a new payment (transaction) to the existing order in Mollie. @@ -211,6 +223,7 @@ public function startMolliePayment(string $paymentMethod, AsyncPaymentTransactio # We just try to create the customer before we create the actual order. $this->createCustomerAtMollie($order, $salesChannelContext); + # let's create our real Mollie order # for this payment in Shopware. $molliePaymentData = $this->createMollieOrder($order, $paymentMethod, $transactionStruct, $salesChannelContext, $paymentHandler); @@ -232,6 +245,7 @@ public function startMolliePayment(string $paymentMethod, AsyncPaymentTransactio $orderCustomFields->setSubscriptionData($subscriptionId, ''); } + /** * @var OrderLineItemCollection $orderLineItems */ diff --git a/src/Handler/Method/BancomatPayment.php b/src/Handler/Method/BancomatPayment.php new file mode 100644 index 000000000..2514fa477 --- /dev/null +++ b/src/Handler/Method/BancomatPayment.php @@ -0,0 +1,34 @@ + $orderData + * @param OrderEntity $orderEntity + * @param SalesChannelContext $salesChannelContext + * @param CustomerEntity $customer + * @return array + */ + public function processPaymentMethodSpecificParameters(array $orderData, OrderEntity $orderEntity, SalesChannelContext $salesChannelContext, CustomerEntity $customer): array + { + $orderCustomFields = new OrderAttributes($orderEntity); + $orderData['billingAddress']['phone'] = $orderCustomFields->getBancomatPayPhoneNumber(); + return $orderData; + } +} diff --git a/src/Handler/PaymentHandler.php b/src/Handler/PaymentHandler.php index 664b5ddfb..c4bcfa301 100644 --- a/src/Handler/PaymentHandler.php +++ b/src/Handler/PaymentHandler.php @@ -117,7 +117,8 @@ public function pay(AsyncPaymentTransactionStruct $transaction, RequestDataBag $ $this->paymentMethod, $transaction, $salesChannelContext, - $this + $this, + $dataBag ); $paymentUrl = $paymentData->getCheckoutURL(); diff --git a/src/Resources/app/storefront/src/mollie-payments/plugins/bancomat-plugin.js b/src/Resources/app/storefront/src/mollie-payments/plugins/bancomat-plugin.js new file mode 100644 index 000000000..617536347 --- /dev/null +++ b/src/Resources/app/storefront/src/mollie-payments/plugins/bancomat-plugin.js @@ -0,0 +1,37 @@ +import Plugin from '@shopware-storefront-sdk/plugin-system/plugin.class'; + +export default class MollieBancomatPlugin extends Plugin { + + init() { + + const phoneField = document.getElementById('mollieBancomatPayPhone'); + if (phoneField === null) { + console.log("phone field not found"); + return; + } + + const inputFieldWrapper = document.querySelector('.mollie-bancomat-pay'); + console.log(inputFieldWrapper); + const errorMessageElement = document.querySelector('.mollie-bancomat-pay [data-form-validation-invalid-phone="true"]'); + console.log(errorMessageElement); + phoneField.addEventListener('focus',(e)=>{ + inputFieldWrapper.classList.add('was-validated'); + e.target.removeAttribute('invalid'); + errorMessageElement.classList.add('d-none'); + console.log("focus"); + }); + + + phoneField.addEventListener('blur', (e) => { + const form = e.target.form; + if(form.reportValidity() === false){ + e.target.setAttribute('invalid',true); + errorMessageElement.classList.remove('d-none'); + } + console.log("blur"); + return form.reportValidity(); + + }) + + } +} \ No newline at end of file diff --git a/src/Resources/app/storefront/src/register.js b/src/Resources/app/storefront/src/register.js index 9de86e174..685e4b364 100644 --- a/src/Resources/app/storefront/src/register.js +++ b/src/Resources/app/storefront/src/register.js @@ -5,6 +5,7 @@ import MollieApplePayDirect from './mollie-payments/plugins/apple-pay-direct.plu import MollieApplePayPaymentMethod from './mollie-payments/plugins/apple-pay-payment-method.plugin'; import MollieCreditCardMandateManage from './mollie-payments/plugins/creditcard-mandate-manage.plugin'; import MolliePosTerminalPlugin from './mollie-payments/plugins/pos-terminal.plugin'; +import MollieBancomatPlugin from "./mollie-payments/plugins/bancomat-plugin"; export default class MolliRegistration { @@ -42,6 +43,8 @@ export default class MolliRegistration { // POS Terminal // ----------------------------------------------------------------------------- pluginManager.register('MolliePosTerminal', MolliePosTerminalPlugin, '[data-mollie-template-pos-terminal]'); + + pluginManager.register('MollieBancomatPlugin',MollieBancomatPlugin); } } diff --git a/src/Resources/config/services/handlers.xml b/src/Resources/config/services/handlers.xml index 5ffa6d2d6..0da99bb80 100644 --- a/src/Resources/config/services/handlers.xml +++ b/src/Resources/config/services/handlers.xml @@ -190,6 +190,13 @@ + + + + + + + diff --git a/src/Resources/snippet/de_DE/mollie-payments.de-DE.json b/src/Resources/snippet/de_DE/mollie-payments.de-DE.json index bd1bd667e..4d6de8a76 100644 --- a/src/Resources/snippet/de_DE/mollie-payments.de-DE.json +++ b/src/Resources/snippet/de_DE/mollie-payments.de-DE.json @@ -43,6 +43,10 @@ "deleteButton": "Löschen", "deleteConfirmation": "Sind Sie sicher, dass Sie die Zahlart löschen möchten?", "title": "Bestätigung zum Löschen" + }, + "bancomatPay": { + "headLine": "Telefonnummer", + "phoneErrorMessage": "Die Telefonnummer ist im E.164-Format erforderlich. Zum Beispiel +31208202070" } }, "messages": { diff --git a/src/Resources/snippet/en_GB/mollie-payments.en-GB.json b/src/Resources/snippet/en_GB/mollie-payments.en-GB.json index d47fd4a9e..5ae2c1ebe 100644 --- a/src/Resources/snippet/en_GB/mollie-payments.en-GB.json +++ b/src/Resources/snippet/en_GB/mollie-payments.en-GB.json @@ -43,6 +43,10 @@ "deleteButton": "Delete", "deleteConfirmation": "Are you sure you want to delete?", "title": "Delete Confirmation" + }, + "bancomatPay": { + "headLine": "Phone number", + "phoneErrorMessage": "Phone Number is required in the E.164 format. For example +31208202070" } }, "messages": { diff --git a/src/Resources/snippet/nl_NL/mollie-payments.nl-NL.json b/src/Resources/snippet/nl_NL/mollie-payments.nl-NL.json index a8ca26978..5fb8644b5 100644 --- a/src/Resources/snippet/nl_NL/mollie-payments.nl-NL.json +++ b/src/Resources/snippet/nl_NL/mollie-payments.nl-NL.json @@ -43,6 +43,10 @@ "deleteButton": "Verwijderen", "deleteConfirmation": "Weet je zeker dat je dat wilt verwijderen?", "title": "Bevestiging verwijderen" + }, + "bancomatPay": { + "headLine": "Telefoonnummer", + "phoneErrorMessage": "Telefoonnummer is vereist in het E.164-formaat. Bijvoorbeeld +31208202070" } }, "messages": { diff --git a/src/Resources/views/storefront/base.html.twig b/src/Resources/views/storefront/base.html.twig index 7b2ce1a1d..c266d66d7 100644 --- a/src/Resources/views/storefront/base.html.twig +++ b/src/Resources/views/storefront/base.html.twig @@ -14,20 +14,20 @@ {% set currentRoute = app.request.attributes.get('_route') %} - {% set implementJS = false %} + {% set includeJsInHeader = false %} {# js always required on this pages #} {% if currentRoute == 'frontend.checkout.cart.page' or currentRoute == 'frontend.checkout.confirm.page' %} - {% set implementJS = true %} + {% set includeJsInHeader = true %} {% endif %} {# requirement check for apple pay direct #} {% if mollie_applepaydirect_enabled == true or mollie_applepay_enabled == true %} {% if currentRoute in onlyShowHere|keys and onlyShowHere[currentRoute] not in mollie_applepaydirect_restrictions %} - {% set implementJS = true %} + {% set includeJsInHeader = true %} {% endif %} {% if 'offcanvas' not in mollie_applepaydirect_restrictions %} - {% set implementJS = true %} + {% set includeJsInHeader = true %} {% endif %} {% endif %} @@ -35,7 +35,7 @@ window.mollie_javascript_use_shopware = '{{ mollie_javascript_use_shopware }}' - {% if mollie_javascript_use_shopware != '1' and implementJS == true %} + {% if mollie_javascript_use_shopware != '1' and includeJsInHeader == true %} {% endif %} diff --git a/src/Resources/views/storefront/component/payment/component/bancomat-fields.html.twig b/src/Resources/views/storefront/component/payment/component/bancomat-fields.html.twig new file mode 100644 index 000000000..cfeb79124 --- /dev/null +++ b/src/Resources/views/storefront/component/payment/component/bancomat-fields.html.twig @@ -0,0 +1,18 @@ +{% if context.paymentMethod.translated.customFields.mollie_payment_method_name == 'bancomatpay' %} +
+ + + + + + {{ "molliePayments.components.bancomatPay.phoneErrorMessage"|trans|striptags }} + + +
+{% endif %} \ No newline at end of file diff --git a/src/Resources/views/storefront/component/payment/payment-fields.html.twig b/src/Resources/views/storefront/component/payment/payment-fields.html.twig index a9b5d6eb7..48cd7d061 100644 --- a/src/Resources/views/storefront/component/payment/payment-fields.html.twig +++ b/src/Resources/views/storefront/component/payment/payment-fields.html.twig @@ -35,5 +35,7 @@ {% sw_include '@MolliePayments/storefront/component/payment/component/ideal-fields.html.twig' %} {% elseif payment.translated.customFields.mollie_payment_method_name == 'pointofsale' %} {% sw_include '@MolliePayments/storefront/component/payment/component/pos-fields.html.twig' %} + {% elseif payment.translated.customFields.mollie_payment_method_name == 'bancomatpay' %} + {% sw_include '@MolliePayments/storefront/component/payment/component/bancomat-fields.html.twig' %} {% endif %} {% endblock %} diff --git a/src/Resources/views/storefront/component/payment/payment-method.html.twig b/src/Resources/views/storefront/component/payment/payment-method.html.twig index af3746b8b..c519f4d0e 100644 --- a/src/Resources/views/storefront/component/payment/payment-method.html.twig +++ b/src/Resources/views/storefront/component/payment/payment-method.html.twig @@ -39,5 +39,7 @@ {% sw_include '@MolliePayments/storefront/component/payment/component/ideal-fields.html.twig' %} {% elseif payment.translated.customFields.mollie_payment_method_name == 'pointofsale' %} {% sw_include '@MolliePayments/storefront/component/payment/component/pos-fields.html.twig' %} + {% elseif payment.translated.customFields.mollie_payment_method_name == 'bancomatpay' %} + {% sw_include '@MolliePayments/storefront/component/payment/component/bancomat-fields.html.twig' %} {% endif %} {% endblock %} diff --git a/src/Service/PaymentMethodService.php b/src/Service/PaymentMethodService.php index 446d4d703..ae5a2a123 100644 --- a/src/Service/PaymentMethodService.php +++ b/src/Service/PaymentMethodService.php @@ -4,6 +4,7 @@ use Kiener\MolliePayments\Compatibility\VersionCompare; use Kiener\MolliePayments\Handler\Method\ApplePayPayment; +use Kiener\MolliePayments\Handler\Method\BancomatPayment; use Kiener\MolliePayments\Handler\Method\BanContactPayment; use Kiener\MolliePayments\Handler\Method\BankTransferPayment; use Kiener\MolliePayments\Handler\Method\BelfiusPayment; @@ -435,6 +436,7 @@ public function getPaymentHandlers(): array PosPayment::class, TwintPayment::class, BlikPayment::class, + BancomatPayment::class, // IngHomePayPayment::class, // not allowed anymore // DirectDebitPayment::class, // only allowed when updating subsriptions, aka => not allowed anymore ]; diff --git a/src/Struct/Order/OrderAttributes.php b/src/Struct/Order/OrderAttributes.php index a9f0375b1..eca8bad18 100644 --- a/src/Struct/Order/OrderAttributes.php +++ b/src/Struct/Order/OrderAttributes.php @@ -104,6 +104,11 @@ class OrderAttributes */ private $bankBic; + /** + * @var string + */ + private $bancomatPayPhoneNumber; + /** * @param OrderEntity $order */ @@ -128,6 +133,7 @@ public function __construct(OrderEntity $order) $this->bankAccount = $this->getCustomFieldValue($order, 'bankAccount'); $this->bankBic = $this->getCustomFieldValue($order, 'bankBic'); $this->timezone = $this->getCustomFieldValue($order, 'timezone'); + $this->bancomatPayPhoneNumber = $this->getCustomFieldValue($order, 'bancomatPayPhoneNumber'); } /** @@ -444,6 +450,24 @@ public function setBankTransferDetails(?stdClass $details) } } + /** + * @return string + */ + public function getBancomatPayPhoneNumber(): string + { + return $this->bancomatPayPhoneNumber; + } + + /** + * @param string $bancomatPayPhoneNumber + * @return void + */ + public function setBancomatPayPhoneNumber(string $bancomatPayPhoneNumber): void + { + $this->bancomatPayPhoneNumber = $bancomatPayPhoneNumber; + } + + /** * @return array */ @@ -528,6 +552,9 @@ public function toArray(): array $mollieData['bankBic'] = $this->bankBic; } + if ($this->bancomatPayPhoneNumber !== '') { + $mollieData['bancomatPayPhoneNumber'] = $this->bancomatPayPhoneNumber; + } return [ 'mollie_payments' => $mollieData, ]; diff --git a/tests/Cypress/cypress/e2e/storefront/payment-methods/bancomat.cy.js b/tests/Cypress/cypress/e2e/storefront/payment-methods/bancomat.cy.js new file mode 100644 index 000000000..068e7f101 --- /dev/null +++ b/tests/Cypress/cypress/e2e/storefront/payment-methods/bancomat.cy.js @@ -0,0 +1,43 @@ +import Devices from "Services/utils/Devices"; +import Session from "Services/utils/Session" +// ------------------------------------------------------ +import PaymentAction from "Actions/storefront/checkout/PaymentAction"; +import DummyBasketScenario from "Scenarios/DummyBasketScenario"; +// ------------------------------------------------------ + + +const devices = new Devices(); +const session = new Session(); + +const paymentAction = new PaymentAction(); +const scenarioDummyBasket = new DummyBasketScenario(1); + +const device = devices.getFirstDevice(); + + +describe('Bancomat Pay', () => { + + context(devices.getDescription(device), () => { + + before(function () { + devices.setDevice(device); + }) + + beforeEach(() => { + session.resetBrowserSession(); + devices.setDevice(device); + }); + + it('C2775016: Bancomat Pay is existing in checkout', () => { + + scenarioDummyBasket.execute(); + + paymentAction.switchPaymentMethod('Bancomat Pay'); + + // payment would only work using currency CHF which cannot be done at the moment + }) + + }) + +}) + diff --git a/tests/PHPUnit/Service/MollieApi/Builder/Payments/BancomatOrderBuilderTest.php b/tests/PHPUnit/Service/MollieApi/Builder/Payments/BancomatOrderBuilderTest.php new file mode 100644 index 000000000..bf7c1fffe --- /dev/null +++ b/tests/PHPUnit/Service/MollieApi/Builder/Payments/BancomatOrderBuilderTest.php @@ -0,0 +1,76 @@ +router->method('generate')->willReturn($redirectWebhookUrl); + + $this->paymentHandler = new BancomatPayment( + $this->loggerService, + new FakeContainer() + ); + + $transactionId = Uuid::randomHex(); + $amountTotal = 27.0; + $taxStatus = CartPrice::TAX_STATE_GROSS; + $currencyISO = 'EUR'; + + $currency = new CurrencyEntity(); + $currency->setId(Uuid::randomHex()); + $currency->setIsoCode($currencyISO); + + $orderNumber = 'foo number'; + $lineItems = $this->getDummyLineItems(); + + $order = $this->getOrderEntity($amountTotal, $taxStatus, $currencyISO, $lineItems, $orderNumber); + + $phoneNumber = '+1234567'; + $orderAttributes = new OrderAttributes($order); + $orderAttributes->setBancomatPayPhoneNumber($phoneNumber); + $order->setCustomFields($orderAttributes->toArray()); + + $actual = $this->builder->buildOrderPayload($order, $transactionId, $this->paymentHandler::PAYMENT_METHOD_NAME, $this->salesChannelContext, $this->paymentHandler, []); + + $expectedOrderLifeTime = (new DateTime())->setTimezone(new DateTimeZone('UTC')) + ->modify(sprintf('+%d day', $this->expiresAt)) + ->format('Y-m-d'); + + $expectedBillingAddress = $this->getExpectedTestAddress($this->address, $this->email); + $expectedBillingAddress['phone'] = $phoneNumber; + + $expected = [ + 'amount' => (new MollieOrderPriceBuilder())->build($amountTotal, $currencyISO), + 'locale' => $this->localeCode, + 'method' => $this->paymentHandler::PAYMENT_METHOD_NAME, + 'orderNumber' => $orderNumber, + 'payment' => ['webhookUrl' => $redirectWebhookUrl], + 'redirectUrl' => $redirectWebhookUrl, + 'webhookUrl' => $redirectWebhookUrl, + 'lines' => $this->getExpectedLineItems($taxStatus, $lineItems, $currency), + 'billingAddress' => $expectedBillingAddress, + 'shippingAddress' => $this->getExpectedTestAddress($this->address, $this->email), + 'expiresAt' => $expectedOrderLifeTime + ]; + + self::assertSame($expected, $actual); + } +} diff --git a/tests/PHPUnit/Service/PaymentMethodServiceTest.php b/tests/PHPUnit/Service/PaymentMethodServiceTest.php index 8c01d69a5..3581aeb8e 100644 --- a/tests/PHPUnit/Service/PaymentMethodServiceTest.php +++ b/tests/PHPUnit/Service/PaymentMethodServiceTest.php @@ -3,6 +3,7 @@ namespace Kiener\MolliePayments\Tests\Service; use Kiener\MolliePayments\Handler\Method\ApplePayPayment; +use Kiener\MolliePayments\Handler\Method\BancomatPayment; use Kiener\MolliePayments\Handler\Method\BanContactPayment; use Kiener\MolliePayments\Handler\Method\BankTransferPayment; use Kiener\MolliePayments\Handler\Method\BelfiusPayment; @@ -129,6 +130,7 @@ public function testSupportedMethods(): void PosPayment::class, TwintPayment::class, BlikPayment::class, + BancomatPayment::class, ]; $handlers = $this->paymentMethodService->getPaymentHandlers(); From 1699a4a643b78fb5096eef41f7831c2307948e9b Mon Sep 17 00:00:00 2001 From: Vitalij Mik Date: Mon, 18 Mar 2024 15:32:30 +0100 Subject: [PATCH 3/8] NTR: remove console.log --- .../src/mollie-payments/plugins/bancomat-plugin.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Resources/app/storefront/src/mollie-payments/plugins/bancomat-plugin.js b/src/Resources/app/storefront/src/mollie-payments/plugins/bancomat-plugin.js index 617536347..b08b04aed 100644 --- a/src/Resources/app/storefront/src/mollie-payments/plugins/bancomat-plugin.js +++ b/src/Resources/app/storefront/src/mollie-payments/plugins/bancomat-plugin.js @@ -6,19 +6,18 @@ export default class MollieBancomatPlugin extends Plugin { const phoneField = document.getElementById('mollieBancomatPayPhone'); if (phoneField === null) { - console.log("phone field not found"); + return; } const inputFieldWrapper = document.querySelector('.mollie-bancomat-pay'); - console.log(inputFieldWrapper); + const errorMessageElement = document.querySelector('.mollie-bancomat-pay [data-form-validation-invalid-phone="true"]'); - console.log(errorMessageElement); + phoneField.addEventListener('focus',(e)=>{ inputFieldWrapper.classList.add('was-validated'); e.target.removeAttribute('invalid'); errorMessageElement.classList.add('d-none'); - console.log("focus"); }); @@ -28,7 +27,6 @@ export default class MollieBancomatPlugin extends Plugin { e.target.setAttribute('invalid',true); errorMessageElement.classList.remove('d-none'); } - console.log("blur"); return form.reportValidity(); }) From 4c35118ee9f7f6922e6af726080ded98d9d7e0ba Mon Sep 17 00:00:00 2001 From: Vitalij Mik Date: Mon, 18 Mar 2024 15:44:35 +0100 Subject: [PATCH 4/8] NTR: eslint fix --- src/Resources/app/storefront/src/register.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Resources/app/storefront/src/register.js b/src/Resources/app/storefront/src/register.js index 685e4b364..61abbca7f 100644 --- a/src/Resources/app/storefront/src/register.js +++ b/src/Resources/app/storefront/src/register.js @@ -5,7 +5,7 @@ import MollieApplePayDirect from './mollie-payments/plugins/apple-pay-direct.plu import MollieApplePayPaymentMethod from './mollie-payments/plugins/apple-pay-payment-method.plugin'; import MollieCreditCardMandateManage from './mollie-payments/plugins/creditcard-mandate-manage.plugin'; import MolliePosTerminalPlugin from './mollie-payments/plugins/pos-terminal.plugin'; -import MollieBancomatPlugin from "./mollie-payments/plugins/bancomat-plugin"; +import MollieBancomatPlugin from './mollie-payments/plugins/bancomat-plugin'; export default class MolliRegistration { From 77e783b8275f87e786007628de3812cfe3be7a6e Mon Sep 17 00:00:00 2001 From: Vitalij Mik Date: Tue, 19 Mar 2024 08:36:09 +0100 Subject: [PATCH 5/8] NTR: Squashed commit of the following: commit 190312956939ae38704df683ac6cc23d4fd106d3 Author: Vitalij Mik Date: Tue Mar 19 08:33:14 2024 +0100 NTR: add the default system language (#726) Co-authored-by: Vitalij Mik commit 77be51e0e1e193b8fca00086831caea4700e25f9 Author: Vitalij Mik Date: Tue Mar 19 08:32:52 2024 +0100 NTR: PISHPS-256: rebranding ideal (#725) Co-authored-by: Vitalij Mik commit 70fe37e90ccacd1c97748110e21300c1cb16ccc5 Author: Vitalij Mik Date: Mon Mar 18 15:17:08 2024 +0100 NTR: update mollie lbirary (#723) Co-authored-by: Vitalij Mik --- src/Handler/Method/In3Payment.php | 2 +- src/Service/PaymentMethodService.php | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Handler/Method/In3Payment.php b/src/Handler/Method/In3Payment.php index 1aa4e42c9..c87f5c47f 100644 --- a/src/Handler/Method/In3Payment.php +++ b/src/Handler/Method/In3Payment.php @@ -15,7 +15,7 @@ class In3Payment extends PaymentHandler /** * */ - public const PAYMENT_METHOD_DESCRIPTION = 'in3'; + public const PAYMENT_METHOD_DESCRIPTION = 'iDeal IN3'; /** * @var string diff --git a/src/Service/PaymentMethodService.php b/src/Service/PaymentMethodService.php index ae5a2a123..421276a42 100644 --- a/src/Service/PaymentMethodService.php +++ b/src/Service/PaymentMethodService.php @@ -182,8 +182,12 @@ public function addPaymentMethods(array $paymentMethods, Context $context): void $translations = $existingPaymentMethod->getTranslations(); if ($translations !== null) { + $paymentMethodData['translations'][Defaults::LANGUAGE_SYSTEM] = [ + 'name' => $existingPaymentMethod->getName() + ]; + foreach ($translations as $translation) { - $paymentMethodData['translations'][$translation->getLanguageId()]=[ + $paymentMethodData['translations'][$translation->getLanguageId()] = [ 'name' => $translation->getName() ]; } From 3e289f292c222a36787a6a4faf5ac0f809e3896d Mon Sep 17 00:00:00 2001 From: Vitalij Mik Date: Tue, 19 Mar 2024 10:07:32 +0100 Subject: [PATCH 6/8] NTR: fix pr --- .../storefront/src/scss/checkout/payment-selection.scss | 8 ++++++++ src/Resources/snippet/de_DE/mollie-payments.de-DE.json | 2 +- src/Resources/snippet/en_GB/mollie-payments.en-GB.json | 2 +- src/Resources/snippet/nl_NL/mollie-payments.nl-NL.json | 2 +- src/Resources/views/storefront/base.html.twig | 2 +- .../component/payment/component/bancomat-fields.html.twig | 5 ++--- .../cypress/e2e/storefront/payment-methods/bancomat.cy.js | 2 -- 7 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/Resources/app/storefront/src/scss/checkout/payment-selection.scss b/src/Resources/app/storefront/src/scss/checkout/payment-selection.scss index 6536b54ca..e9000d92f 100644 --- a/src/Resources/app/storefront/src/scss/checkout/payment-selection.scss +++ b/src/Resources/app/storefront/src/scss/checkout/payment-selection.scss @@ -9,6 +9,10 @@ margin-top: 15px; } + .mollie-bancomat-pay{ + margin-top:15px; + } + .mollie-pos-terminals { margin-top: 15px; } @@ -27,6 +31,10 @@ } } + .mollie-bancomat-pay{ + margin-top:15px; + } + .mollie-pos-terminals { margin-top: 15px; diff --git a/src/Resources/snippet/de_DE/mollie-payments.de-DE.json b/src/Resources/snippet/de_DE/mollie-payments.de-DE.json index 4d6de8a76..a25f8be5d 100644 --- a/src/Resources/snippet/de_DE/mollie-payments.de-DE.json +++ b/src/Resources/snippet/de_DE/mollie-payments.de-DE.json @@ -46,7 +46,7 @@ }, "bancomatPay": { "headLine": "Telefonnummer", - "phoneErrorMessage": "Die Telefonnummer ist im E.164-Format erforderlich. Zum Beispiel +31208202070" + "phoneErrorMessage": "Die Telefonnummer ist erforderlich. Zum Beispiel +31208202070" } }, "messages": { diff --git a/src/Resources/snippet/en_GB/mollie-payments.en-GB.json b/src/Resources/snippet/en_GB/mollie-payments.en-GB.json index 5ae2c1ebe..c90c86622 100644 --- a/src/Resources/snippet/en_GB/mollie-payments.en-GB.json +++ b/src/Resources/snippet/en_GB/mollie-payments.en-GB.json @@ -46,7 +46,7 @@ }, "bancomatPay": { "headLine": "Phone number", - "phoneErrorMessage": "Phone Number is required in the E.164 format. For example +31208202070" + "phoneErrorMessage": "Phone Number is required. For example +31208202070" } }, "messages": { diff --git a/src/Resources/snippet/nl_NL/mollie-payments.nl-NL.json b/src/Resources/snippet/nl_NL/mollie-payments.nl-NL.json index 5fb8644b5..e73d3d682 100644 --- a/src/Resources/snippet/nl_NL/mollie-payments.nl-NL.json +++ b/src/Resources/snippet/nl_NL/mollie-payments.nl-NL.json @@ -46,7 +46,7 @@ }, "bancomatPay": { "headLine": "Telefoonnummer", - "phoneErrorMessage": "Telefoonnummer is vereist in het E.164-formaat. Bijvoorbeeld +31208202070" + "phoneErrorMessage": "Telefoonnummer is vereist. Bijvoorbeeld +31208202070" } }, "messages": { diff --git a/src/Resources/views/storefront/base.html.twig b/src/Resources/views/storefront/base.html.twig index c266d66d7..aee39e3d5 100644 --- a/src/Resources/views/storefront/base.html.twig +++ b/src/Resources/views/storefront/base.html.twig @@ -17,7 +17,7 @@ {% set includeJsInHeader = false %} {# js always required on this pages #} - {% if currentRoute == 'frontend.checkout.cart.page' or currentRoute == 'frontend.checkout.confirm.page' %} + {% if currentRoute == 'frontend.checkout.cart.page' or currentRoute == 'frontend.checkout.confirm.page' or currentRoute == 'frontend.account.edit-order.page' %} {% set includeJsInHeader = true %} {% endif %} diff --git a/src/Resources/views/storefront/component/payment/component/bancomat-fields.html.twig b/src/Resources/views/storefront/component/payment/component/bancomat-fields.html.twig index cfeb79124..634bdfcc6 100644 --- a/src/Resources/views/storefront/component/payment/component/bancomat-fields.html.twig +++ b/src/Resources/views/storefront/component/payment/component/bancomat-fields.html.twig @@ -2,13 +2,12 @@
- + value="{{ context.customer.activeBillingAddress.phoneNumber }}" + required="required" /> {{ "molliePayments.components.bancomatPay.phoneErrorMessage"|trans|striptags }} diff --git a/tests/Cypress/cypress/e2e/storefront/payment-methods/bancomat.cy.js b/tests/Cypress/cypress/e2e/storefront/payment-methods/bancomat.cy.js index 068e7f101..33f0b75d3 100644 --- a/tests/Cypress/cypress/e2e/storefront/payment-methods/bancomat.cy.js +++ b/tests/Cypress/cypress/e2e/storefront/payment-methods/bancomat.cy.js @@ -33,8 +33,6 @@ describe('Bancomat Pay', () => { scenarioDummyBasket.execute(); paymentAction.switchPaymentMethod('Bancomat Pay'); - - // payment would only work using currency CHF which cannot be done at the moment }) }) From 2de03f14ae3a93752f211fdd6616c500cfe0beb1 Mon Sep 17 00:00:00 2001 From: Vitalij Mik Date: Tue, 19 Mar 2024 11:54:17 +0100 Subject: [PATCH 7/8] NTR: hide bancomat in order edit --- src/Service/Payment/Remover/RegularPaymentRemover.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Service/Payment/Remover/RegularPaymentRemover.php b/src/Service/Payment/Remover/RegularPaymentRemover.php index 40ca6088a..f429e5359 100644 --- a/src/Service/Payment/Remover/RegularPaymentRemover.php +++ b/src/Service/Payment/Remover/RegularPaymentRemover.php @@ -51,6 +51,11 @@ public function removePaymentMethods(PaymentMethodRouteResponse $originalData, S if ($attributes->getMollieIdentifier() === PaymentMethod::INGHOMEPAY) { $originalData->getPaymentMethods()->remove($key); } + + # currently for bancomat, you cannot update the phone number, so customer might stuck in order edit. we remove the payment method for now and will enable it when the mollie api allows to change that + if ($this->isOrderRoute() && $attributes->getMollieIdentifier() === PaymentMethod::BANCOMATPAY) { + $originalData->getPaymentMethods()->remove($key); + } } return $originalData; From b637b0a6781bff1415f2f8e39a959c1b195fbec3 Mon Sep 17 00:00:00 2001 From: Vitalij Mik Date: Mon, 6 May 2024 11:05:17 +0200 Subject: [PATCH 8/8] NTR: bancomat pay numer ist noch required --- src/Handler/Method/BancomatPayment.php | 1 - .../component/payment/component/bancomat-fields.html.twig | 4 ++-- src/Service/Payment/Remover/RegularPaymentRemover.php | 5 ----- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/Handler/Method/BancomatPayment.php b/src/Handler/Method/BancomatPayment.php index 2514fa477..05f05ac12 100644 --- a/src/Handler/Method/BancomatPayment.php +++ b/src/Handler/Method/BancomatPayment.php @@ -7,7 +7,6 @@ use Mollie\Api\Types\PaymentMethod; use Shopware\Core\Checkout\Customer\CustomerEntity; use Shopware\Core\Checkout\Order\OrderEntity; -use Shopware\Core\System\Locale\LocaleEntity; use Shopware\Core\System\SalesChannel\SalesChannelContext; class BancomatPayment extends PaymentHandler diff --git a/src/Resources/views/storefront/component/payment/component/bancomat-fields.html.twig b/src/Resources/views/storefront/component/payment/component/bancomat-fields.html.twig index 634bdfcc6..070bfe636 100644 --- a/src/Resources/views/storefront/component/payment/component/bancomat-fields.html.twig +++ b/src/Resources/views/storefront/component/payment/component/bancomat-fields.html.twig @@ -1,13 +1,13 @@ {% if context.paymentMethod.translated.customFields.mollie_payment_method_name == 'bancomatpay' %}
- + + /> {{ "molliePayments.components.bancomatPay.phoneErrorMessage"|trans|striptags }} diff --git a/src/Service/Payment/Remover/RegularPaymentRemover.php b/src/Service/Payment/Remover/RegularPaymentRemover.php index f429e5359..40ca6088a 100644 --- a/src/Service/Payment/Remover/RegularPaymentRemover.php +++ b/src/Service/Payment/Remover/RegularPaymentRemover.php @@ -51,11 +51,6 @@ public function removePaymentMethods(PaymentMethodRouteResponse $originalData, S if ($attributes->getMollieIdentifier() === PaymentMethod::INGHOMEPAY) { $originalData->getPaymentMethods()->remove($key); } - - # currently for bancomat, you cannot update the phone number, so customer might stuck in order edit. we remove the payment method for now and will enable it when the mollie api allows to change that - if ($this->isOrderRoute() && $attributes->getMollieIdentifier() === PaymentMethod::BANCOMATPAY) { - $originalData->getPaymentMethods()->remove($key); - } } return $originalData;