diff --git a/.php_cs.php b/.php_cs.php index efab35fe2..7515892c9 100644 --- a/.php_cs.php +++ b/.php_cs.php @@ -1,8 +1,19 @@ setUsingCache(false) - ->setRules([ +$finder = \PhpCsFixer\Finder::create()->in([ + __DIR__ . '/src', +]); + +$finder->exclude( + [ + 'Resources' + ] +); + +$config = new \PhpCsFixer\Config(); + +$config->setRules( + [ '@PSR2' => true, 'array_syntax' => ['syntax' => 'short'], 'ordered_imports' => true, @@ -14,9 +25,12 @@ 'phpdoc_order' => true, 'phpdoc_trim_consecutive_blank_line_separation' => true, 'phpdoc_types_order' => true, - 'yoda_style' => null, - ]) - ->setFinder( - PhpCsFixer\Finder::create() - ->exclude(['Resources']) - ->in(__DIR__ . '/src')); + 'yoda_style' => false, + ] +); + +$config->setFinder($finder); + +$config->setUsingCache(false); + +return $config; diff --git a/composer.json b/composer.json index c0e8162ed..355ca8162 100644 --- a/composer.json +++ b/composer.json @@ -43,7 +43,7 @@ "autoload": { "psr-4": { "Kiener\\MolliePayments\\": "src/", - "Mollie\\Api\\": "vendor/mollie/mollie-api-php/src/", + "Mollie\\Api\\": "vendor_manual/mollie/mollie-api-php/src/", "Shopware\\Core\\": "polyfill/Shopware/Core/" } }, diff --git a/makefile b/makefile index 900e016c9..e5d53fc5e 100644 --- a/makefile +++ b/makefile @@ -28,12 +28,12 @@ prod: ## Installs all production dependencies cd src/Resources/app/storefront && npm install --production dev: ## Installs all dev dependencies - curl -1sLf 'https://dl.cloudsmith.io/public/friendsofshopware/stable/setup.deb.sh' | sudo -E bash && sudo apt install shopware-cli php switch-composer.php dev @composer validate @composer install cd src/Resources/app/administration && npm install cd src/Resources/app/storefront && npm install + curl -1sLf 'https://dl.cloudsmith.io/public/friendsofshopware/stable/setup.deb.sh' | sudo -E bash && sudo apt install shopware-cli install: ## [deprecated] Installs all production dependencies. Please use "make prod" now. @make prod -B diff --git a/vendor_manual/makefile b/vendor_manual/makefile new file mode 100644 index 000000000..4e1d8209e --- /dev/null +++ b/vendor_manual/makefile @@ -0,0 +1,18 @@ + +MOLLIE_PHP_VERSION:=2.61.0 + + +help: + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + +# ------------------------------------------------------------------------------------------------------------ + +install: ## Installs all production dependencies + rm -rf mollie + git clone -b v$(MOLLIE_PHP_VERSION) https://github.com/mollie/mollie-api-php.git mollie/mollie-api-php + rm -rf mollie/mollie-api-php/.git + rm -rf mollie/mollie-api-php/.github + rm -rf mollie/mollie-api-php/.gitattributes + rm -rf mollie/mollie-api-php/.gitignore + rm -rf mollie/mollie-api-php/examples + rm -rf mollie/mollie-api-php/tests diff --git a/vendor_manual/mollie/mollie-api-php/.php-cs-fixer.dist.php b/vendor_manual/mollie/mollie-api-php/.php-cs-fixer.dist.php new file mode 100644 index 000000000..f79cca01d --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/.php-cs-fixer.dist.php @@ -0,0 +1,37 @@ +in([ + __DIR__ . '/src', + __DIR__ . '/examples', + __DIR__ . '/tests', + ]) + ->name('*.php') + ->notPath('bootstrap/*') + ->notPath('storage/*') + ->notPath('vendor') + ->ignoreDotFiles(true) + ->ignoreVCS(true); + +return (new PhpCsFixer\Config()) + ->setRules([ + '@PSR2' => true, + 'array_syntax' => ['syntax' => 'short'], + 'ordered_imports' => ['sort_algorithm' => 'alpha'], + 'no_unused_imports' => true, + 'not_operator_with_successor_space' => true, + 'trailing_comma_in_multiline' => true, + 'phpdoc_scalar' => true, + 'unary_operator_spaces' => true, + 'binary_operator_spaces' => true, + 'blank_line_before_statement' => [ + 'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'], + ], + 'phpdoc_single_line_var_spacing' => true, + 'phpdoc_var_without_name' => true, + 'method_argument_space' => [ + 'on_multiline' => 'ensure_fully_multiline', + 'keep_multiple_spaces_after_comma' => true, + ], + 'single_trait_insert_per_statement' => true, + ]) + ->setFinder($finder); diff --git a/vendor_manual/mollie/mollie-api-php/LICENSE b/vendor_manual/mollie/mollie-api-php/LICENSE new file mode 100644 index 000000000..12c9d8d14 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/LICENSE @@ -0,0 +1,8 @@ +Copyright (c) 2013-2016, Mollie B.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor_manual/mollie/mollie-api-php/README.md b/vendor_manual/mollie/mollie-api-php/README.md new file mode 100644 index 000000000..c29135950 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/README.md @@ -0,0 +1,231 @@ +

+ +

+

Mollie API client for PHP

+ + + +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. + +[![Build Status](https://github.com/mollie/mollie-api-php/workflows/tests/badge.svg)](https://github.com/mollie/mollie-api-php/actions) +[![Latest Stable Version](https://poser.pugx.org/mollie/mollie-api-php/v/stable)](https://packagist.org/packages/mollie/mollie-api-php) +[![Total Downloads](https://poser.pugx.org/mollie/mollie-api-php/downloads)](https://packagist.org/packages/mollie/mollie-api-php) + +## Requirements ## +To use the Mollie API client, the following things are required: + ++ Get yourself a free [Mollie account](https://www.mollie.com/signup). No sign up costs. ++ Now you're ready to use the Mollie API client in test mode. ++ Follow [a few steps](https://www.mollie.com/dashboard/?modal=onboarding) to enable payment methods in live mode, and let us handle the rest. ++ PHP >= 7.0 ++ Up-to-date OpenSSL (or other SSL/TLS toolkit) + +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). + + $ composer require mollie/mollie-api-php:^2.0 + + { + "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. + + +## 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 ## + +Initializing the Mollie API client, and setting your API key. + +```php +$mollie = new \Mollie\Api\MollieApiClient(); +$mollie->setApiKey("test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"); +``` + +Creating a new payment. + +```php +$payment = $mollie->payments->create([ + "amount" => [ + "currency" => "EUR", + "value" => "10.00" + ], + "description" => "My first API payment", + "redirectUrl" => "https://webshop.example.org/order/12345/", + "webhookUrl" => "https://webshop.example.org/mollie-webhook/", +]); +``` +_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()`. + +```php +header("Location: " . $payment->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). + +## Retrieving payments ## +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). + +## Payment webhook ## + +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). + + +## 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). + +```php +$payment = $mollie->payments->create([ + "amount" => [ + "currency" => "USD", + "value" => "10.00" + ], + "description" => "Order #12345", + "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._ + + +### Fully integrated iDEAL payments ### + +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. + +Retrieve the iDEAL method and include the issuers + +```php +$method = $mollie->methods->get(\Mollie\Api\Types\PaymentMethod::IDEAL, ["include" => "issuers"]); +``` + +_`$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)._ + +Create a payment with the selected issuer: + +```php +$payment = $mollie->payments->create([ + "amount" => [ + "currency" => "EUR", + "value" => "10.00" + ], + "description" => "My first API payment", + "redirectUrl" => "https://webshop.example.org/order/12345/", + "webhookUrl" => "https://webshop.example.org/mollie-webhook/", + "method" => \Mollie\Api\Types\PaymentMethod::IDEAL, + "issuer" => $selectedIssuerId, // e.g. "ideal_INGBNL2A" +]); +``` + +_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 ### + +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. + +```php +$payment = $mollie->payments->get($payment->id); + +// Refund € 2 of this payment +$refund = $payment->refund([ + "amount" => [ + "currency" => "EUR", + "value" => "2.00" + ] +]); +``` + +For a working example, see [Example - Refund payment](https://github.com/mollie/mollie-api-php/blob/master/examples/payments/refund-payment.php). + +## Enabling debug mode + +When debugging it can be convenient to have the submitted request available on the `ApiException`. + +In order to prevent leaking sensitive request data into your local application logs, debugging is disabled by default. + +To enable debugging and inspect the request: + +```php +/** @var $mollie \Mollie\Api\MollieApiClient */ +$mollie->enableDebugging(); + +try { + $mollie->payments->get('tr_12345678'); +} catch (\Mollie\Api\Exceptions\ApiException $exception) { + $request = $exception->getRequest(); +} +``` + +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. + +To disable debugging again: + +```php +/** @var $mollie \Mollie\Api\MollieApiClient */ +$mollie->disableDebugging(); +``` + +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? ## + +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). + +## License ## +[BSD (Berkeley Software Distribution) License](https://opensource.org/licenses/bsd-license.php). +Copyright (c) 2013-2018, Mollie B.V. + +## Support ## +Contact: [www.mollie.com](https://www.mollie.com) — info@mollie.com — +31 20 820 20 70 diff --git a/vendor_manual/mollie/mollie-api-php/composer.json b/vendor_manual/mollie/mollie-api-php/composer.json new file mode 100644 index 000000000..47040d24b --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/composer.json @@ -0,0 +1,84 @@ +{ + "name": "mollie/mollie-api-php", + "description": "Mollie API client library for PHP. Mollie is a European Payment Service provider and offers international payment methods such as Mastercard, VISA, American Express and PayPal, and local payment methods such as iDEAL, Bancontact, SOFORT Banking, SEPA direct debit, Belfius Direct Net, KBC Payment Button and various gift cards such as Podiumcadeaukaart and fashioncheque.", + "keywords": [ + "mollie", + "payment", + "service", + "ideal", + "creditcard", + "apple pay", + "mistercash", + "bancontact", + "sofort", + "sofortbanking", + "sepa", + "paypal", + "paysafecard", + "podiumcadeaukaart", + "przelewy24", + "banktransfer", + "direct debit", + "belfius", + "belfius direct net", + "refunds", + "api", + "payments", + "gateway", + "subscriptions", + "recurring", + "charges", + "kbc", + "cbc", + "gift cards", + "intersolve", + "fashioncheque", + "inghomepay", + "klarna", + "paylater", + "sliceit" + ], + "homepage": "https://www.mollie.com/en/developers", + "license": "BSD-2-Clause", + "authors": [ + { + "name": "Mollie B.V.", + "email": "info@mollie.com" + } + ], + "require": { + "php": "^7.2|^8.0", + "ext-curl": "*", + "ext-json": "*", + "ext-openssl": "*", + "composer/ca-bundle": "^1.2" + }, + "require-dev": { + "eloquent/liberator": "^2.0||^3.0", + "friendsofphp/php-cs-fixer": "^3.0", + "guzzlehttp/guzzle": "^6.3 || ^7.0", + "phpstan/phpstan": "^1.4", + "phpunit/phpunit": "^8.5 || ^9.5" + }, + "suggest": { + "mollie/oauth2-mollie-php": "Use OAuth to authenticate with the Mollie API. This is needed for some endpoints. Visit https://docs.mollie.com/ for more information." + }, + "config": { + "sort-packages": true + }, + "autoload": { + "psr-4": { + "Mollie\\Api\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Tests\\": "tests/", + "Tests\\Mollie\\Api\\": "tests/Mollie/API/" + } + }, + "scripts": { + "test": "./vendor/bin/phpunit tests", + "format": "./vendor/bin/php-cs-fixer fix --allow-risky=yes" + } +} diff --git a/vendor_manual/mollie/mollie-api-php/phpstan-baseline.neon b/vendor_manual/mollie/mollie-api-php/phpstan-baseline.neon new file mode 100644 index 000000000..56cabd08a --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/phpstan-baseline.neon @@ -0,0 +1,5 @@ +parameters: + ignoreErrors: + - + message: "#^Variable \\$mollie might not be defined\\.$#" + path: examples/* diff --git a/vendor_manual/mollie/mollie-api-php/phpstan.neon b/vendor_manual/mollie/mollie-api-php/phpstan.neon new file mode 100644 index 000000000..ecd56da76 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/phpstan.neon @@ -0,0 +1,17 @@ +parameters: + level: 5 + paths: + - %currentWorkingDirectory%/src + - %currentWorkingDirectory%/tests + - %currentWorkingDirectory%/examples + excludePaths: + - %currentWorkingDirectory%/vendor + ignoreErrors: + - '#Access to an undefined property Eloquent\\Liberator\\LiberatorProxyInterface::\$request#' + - '#Access to protected property Mollie\\Api\\MollieApiClient::\$apiKey#' + - '#Access to protected property Mollie\\Api\\MollieApiClient::\$httpClient#' + - '#Call to an undefined method Mollie\\Api\\HttpAdapter\\MollieHttpAdapterInterface::enableDebugging\(\)#' + - '#Call to an undefined method Mollie\\Api\\HttpAdapter\\MollieHttpAdapterInterface::disableDebugging\(\)#' + treatPhpDocTypesAsCertain: false +includes: + - phpstan-baseline.neon diff --git a/vendor_manual/mollie/mollie-api-php/phpunit.xml b/vendor_manual/mollie/mollie-api-php/phpunit.xml new file mode 100644 index 000000000..eb7a8f95d --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/phpunit.xml @@ -0,0 +1,15 @@ + + + + + src/ + + + + + + + + tests/ + + diff --git a/vendor_manual/mollie/mollie-api-php/scoper.inc.php b/vendor_manual/mollie/mollie-api-php/scoper.inc.php new file mode 100644 index 000000000..88317a713 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/scoper.inc.php @@ -0,0 +1,13 @@ + [], // Finder[] + 'patchers' => [], // callable[] + 'whitelist' => [ + 'Mollie\\Api\\*', + ], +]; \ No newline at end of file diff --git a/vendor_manual/mollie/mollie-api-php/src/CompatibilityChecker.php b/vendor_manual/mollie/mollie-api-php/src/CompatibilityChecker.php new file mode 100644 index 000000000..b754b2116 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/CompatibilityChecker.php @@ -0,0 +1,59 @@ +satisfiesPhpVersion()) { + throw new IncompatiblePlatform( + "The client requires PHP version >= " . self::MIN_PHP_VERSION . ", you have " . PHP_VERSION . ".", + IncompatiblePlatform::INCOMPATIBLE_PHP_VERSION + ); + } + + if (! $this->satisfiesJsonExtension()) { + throw new IncompatiblePlatform( + "PHP extension json is not enabled. Please make sure to enable 'json' in your PHP configuration.", + IncompatiblePlatform::INCOMPATIBLE_JSON_EXTENSION + ); + } + } + + /** + * @return bool + * @codeCoverageIgnore + */ + public function satisfiesPhpVersion() + { + return (bool)version_compare(PHP_VERSION, self::MIN_PHP_VERSION, ">="); + } + + /** + * @return bool + * @codeCoverageIgnore + */ + public function satisfiesJsonExtension() + { + // Check by extension_loaded + if (function_exists('extension_loaded') && extension_loaded('json')) { + return true; + } elseif (function_exists('json_encode')) { + return true; + } + + return false; + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/BalanceEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/BalanceEndpoint.php new file mode 100644 index 000000000..b1a9d69aa --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/BalanceEndpoint.php @@ -0,0 +1,82 @@ +client, $count, $_links); + } + + /** + * @inheritDoc + */ + protected function getResourceObject() + { + return new Balance($this->client); + } + + /** + * Retrieve a single balance from Mollie. + * + * Will throw an ApiException if the balance id is invalid or the resource cannot be found. + * + * @param string $balanceId + * @param array $parameters + * @return \Mollie\Api\Resources\Balance|\Mollie\Api\Resources\BaseResource + * @throws ApiException + */ + 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."'."); + } + + return parent::rest_read($balanceId, $parameters); + } + + /** + * Retrieve the primary balance from Mollie. + * + * Will throw an ApiException if the balance id is invalid or the resource cannot be found. + * + * @param array $parameters + * @return \Mollie\Api\Resources\Balance|\Mollie\Api\Resources\BaseResource + * @throws ApiException + */ + public function primary(array $parameters = []) + { + return parent::rest_read("primary", $parameters); + } + + /** + * Retrieves a collection of Balances from Mollie. + * + * @param string|null $from The first Balance ID you want to include in your list. + * @param int|null $limit + * @param array $parameters + * + * @return BaseCollection|BalanceCollection + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function page(?string $from = null, ?int $limit = null, array $parameters = []) + { + return $this->rest_list($from, $limit, $parameters); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/BalanceReportEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/BalanceReportEndpoint.php new file mode 100644 index 000000000..86effa9cc --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/BalanceReportEndpoint.php @@ -0,0 +1,69 @@ +client); + } + + /** + * Retrieve a balance report for the provided balance id and parameters. + * + * @param string $balanceId + * @param array $parameters + * @return \Mollie\Api\Resources\BalanceReport|\Mollie\Api\Resources\BaseResource + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function getForId(string $balanceId, array $parameters = []) + { + $this->parentId = $balanceId; + + $result = $this->client->performHttpCall( + self::REST_READ, + $this->getResourcePath() . $this->buildQueryString($parameters) + ); + + return ResourceFactory::createFromApiResult($result, $this->getResourceObject()); + } + + /** + * Retrieve the primary balance. + * This is the balance of your account’s primary currency, where all payments are settled to by default. + * + * @param array $parameters + * @return \Mollie\Api\Resources\BalanceReport|\Mollie\Api\Resources\BaseResource + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function getForPrimary(array $parameters = []) + { + return $this->getForId("primary", $parameters); + } + + + /** + * Retrieve a balance report for the provided balance resource and parameters. + * + * @param \Mollie\Api\Resources\Balance $balance + * @param array $parameters + * @return \Mollie\Api\Resources\BalanceReport|\Mollie\Api\Resources\BaseResource + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function getFor(Balance $balance, array $parameters = []) + { + return $this->getForId($balance->id, $parameters); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/BalanceTransactionEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/BalanceTransactionEndpoint.php new file mode 100644 index 000000000..ed0cbb098 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/BalanceTransactionEndpoint.php @@ -0,0 +1,83 @@ +client, $count, $_links); + } + + /** + * @inheritDoc + */ + protected function getResourceObject() + { + return new BalanceTransaction($this->client); + } + + /** + * List the transactions for a specific Balance. + * + * @param Balance $balance + * @param array $parameters + * @return BalanceTransactionCollection|\Mollie\Api\Resources\BaseCollection + * + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function listFor(Balance $balance, array $parameters = []) + { + return $this->listForId($balance->id, $parameters); + } + + /** + * List the transactions for a specific Balance ID. + * + * @param string $balanceId + * @param array $parameters + * @return BalanceTransactionCollection|\Mollie\Api\Resources\BaseCollection + * + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function listForId(string $balanceId, array $parameters = []) + { + $this->parentId = $balanceId; + + return parent::rest_list(null, null, $parameters); + } + + /** + * List the transactions for the primary Balance. + * + * @param array $parameters + * @return BalanceTransactionCollection|\Mollie\Api\Resources\BaseCollection + * + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function listForPrimary(array $parameters = []) + { + $this->parentId = "primary"; + + return parent::rest_list(null, null, $parameters); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/ChargebackEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/ChargebackEndpoint.php new file mode 100644 index 000000000..dd5045ab5 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/ChargebackEndpoint.php @@ -0,0 +1,50 @@ +client); + } + + /** + * Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object. + * + * @param int $count + * @param \stdClass $_links + * + * @return ChargebackCollection + */ + protected function getResourceCollectionObject($count, $_links) + { + return new ChargebackCollection($this->client, $count, $_links); + } + + /** + * Retrieves a collection of Chargebacks from Mollie. + * + * @param string $from The first chargeback ID you want to include in your list. + * @param int $limit + * @param array $parameters + * + * @return ChargebackCollection + * @throws ApiException + */ + public function page($from = null, $limit = null, array $parameters = []) + { + return $this->rest_list($from, $limit, $parameters); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/ClientEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/ClientEndpoint.php new file mode 100644 index 000000000..86891785f --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/ClientEndpoint.php @@ -0,0 +1,69 @@ +client); + } + + /** + * Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object. + * + * @param int $count + * @param \stdClass $_links + * + * @return ClientCollection + */ + protected function getResourceCollectionObject($count, $_links) + { + return new ClientCollection($this->client, $count, $_links); + } + + /** + * Retrieve a client from Mollie. + * + * Will throw an ApiException if the client id is invalid or the resource cannot be found. + * The client id corresponds to the organization id, for example "org_1337". + * + * @param string $clientId + * @param array $parameters + * + * @return Client + * @throws ApiException + */ + public function get($clientId, array $parameters = []) + { + if (empty($clientId)) { + throw new ApiException("Client ID is empty."); + } + + return parent::rest_read($clientId, $parameters); + } + + /** + * Retrieves a page of clients from Mollie. + * + * @param string $from The first client ID you want to include in your list. + * @param int $limit + * @param array $parameters + * + * @return ClientCollection + * @throws ApiException + */ + public function page($from = null, $limit = null, array $parameters = []) + { + return $this->rest_list($from, $limit, $parameters); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/ClientLinkEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/ClientLinkEndpoint.php new file mode 100644 index 000000000..5641cc0d7 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/ClientLinkEndpoint.php @@ -0,0 +1,40 @@ +client); + } + + /** + * Creates a client link in Mollie. + * + * @param array $data An array containing details on the client link. + * + * @return ClientLink + * @throws ApiException + */ + public function create(array $data = []): ClientLink + { + return $this->rest_create($data, []); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/CollectionEndpointAbstract.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/CollectionEndpointAbstract.php new file mode 100644 index 000000000..b11ee9853 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/CollectionEndpointAbstract.php @@ -0,0 +1,48 @@ + $from, "limit" => $limit], $filters); + + $apiPath = $this->getResourcePath() . $this->buildQueryString($filters); + + $result = $this->client->performHttpCall(self::REST_LIST, $apiPath); + + /** @var BaseCollection $collection */ + $collection = $this->getResourceCollectionObject($result->count, $result->_links); + + foreach ($result->_embedded->{$collection->getCollectionResourceName()} as $dataResult) { + $collection[] = ResourceFactory::createFromApiResult($dataResult, $this->getResourceObject()); + } + + return $collection; + } + + /** + * Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object. + * + * @param int $count + * @param \stdClass $_links + * + * @return BaseCollection + */ + abstract protected function getResourceCollectionObject($count, $_links); +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/CustomerEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/CustomerEndpoint.php new file mode 100644 index 000000000..ae04d8f4b --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/CustomerEndpoint.php @@ -0,0 +1,121 @@ +client); + } + + /** + * Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object. + * + * @param int $count + * @param \stdClass $_links + * + * @return CustomerCollection + */ + protected function getResourceCollectionObject($count, $_links) + { + return new CustomerCollection($this->client, $count, $_links); + } + + /** + * Creates a customer in Mollie. + * + * @param array $data An array containing details on the customer. + * @param array $filters + * + * @return Customer + * @throws ApiException + */ + public function create(array $data = [], array $filters = []) + { + return $this->rest_create($data, $filters); + } + + /** + * Retrieve a single customer from Mollie. + * + * Will throw a ApiException if the customer id is invalid or the resource cannot be found. + * + * @param string $customerId + * @param array $parameters + * @return Customer + * @throws ApiException + */ + public function get($customerId, array $parameters = []) + { + return $this->rest_read($customerId, $parameters); + } + + /** + * Update a specific Customer resource. + * + * Will throw an ApiException if the customer id is invalid or the resource cannot be found. + * + * @param string $customerId + * + * @param array $data + * @return Customer + * @throws ApiException + */ + 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."'."); + } + + return parent::rest_update($customerId, $data); + } + + /** + * Deletes the given Customer. + * + * Will throw a ApiException if the customer id is invalid or the resource cannot be found. + * Returns with HTTP status No Content (204) if successful. + * + * @param string $customerId + * + * @param array $data + * @return null + * @throws ApiException + */ + public function delete($customerId, array $data = []) + { + return $this->rest_delete($customerId, $data); + } + + /** + * Retrieves a collection of Customers from Mollie. + * + * @param string $from The first customer ID you want to include in your list. + * @param int $limit + * @param array $parameters + * + * @return CustomerCollection + * @throws ApiException + */ + public function page($from = null, $limit = null, array $parameters = []) + { + return $this->rest_list($from, $limit, $parameters); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/CustomerPaymentsEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/CustomerPaymentsEndpoint.php new file mode 100644 index 000000000..3961ea6f3 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/CustomerPaymentsEndpoint.php @@ -0,0 +1,97 @@ +client); + } + + /** + * Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object. + * + * @param int $count + * @param \stdClass $_links + * + * @return PaymentCollection + */ + protected function getResourceCollectionObject($count, $_links) + { + return new PaymentCollection($this->client, $count, $_links); + } + + /** + * Create a subscription for a Customer + * + * @param Customer $customer + * @param array $options + * @param array $filters + * + * @return Payment + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function createFor(Customer $customer, array $options = [], array $filters = []) + { + return $this->createForId($customer->id, $options, $filters); + } + + /** + * Create a subscription for a Customer ID + * + * @param string $customerId + * @param array $options + * @param array $filters + * + * @return \Mollie\Api\Resources\Payment + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function createForId($customerId, array $options = [], array $filters = []) + { + $this->parentId = $customerId; + + return parent::rest_create($options, $filters); + } + + /** + * @param Customer $customer + * @param string $from The first resource ID you want to include in your list. + * @param int $limit + * @param array $parameters + * + * @return PaymentCollection + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function listFor(Customer $customer, $from = null, $limit = null, array $parameters = []) + { + return $this->listForId($customer->id, $from, $limit, $parameters); + } + + /** + * @param string $customerId + * @param string $from The first resource ID you want to include in your list. + * @param int $limit + * @param array $parameters + * + * @return \Mollie\Api\Resources\PaymentCollection + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function listForId($customerId, $from = null, $limit = null, array $parameters = []) + { + $this->parentId = $customerId; + + return parent::rest_list($from, $limit, $parameters); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/EndpointAbstract.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/EndpointAbstract.php new file mode 100644 index 000000000..fe87e9787 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/EndpointAbstract.php @@ -0,0 +1,210 @@ +client = $api; + } + + /** + * @param array $filters + * @return string + */ + protected function buildQueryString(array $filters) + { + if (empty($filters)) { + return ""; + } + + foreach ($filters as $key => $value) { + if ($value === true) { + $filters[$key] = "true"; + } + + if ($value === false) { + $filters[$key] = "false"; + } + } + + return "?" . http_build_query($filters, "", "&"); + } + + /** + * @param array $body + * @param array $filters + * @return mixed + * @throws ApiException + */ + protected function rest_create(array $body, array $filters) + { + $result = $this->client->performHttpCall( + self::REST_CREATE, + $this->getResourcePath() . $this->buildQueryString($filters), + $this->parseRequestBody($body) + ); + + return ResourceFactory::createFromApiResult($result, $this->getResourceObject()); + } + + /** + * Sends a PATCH request to a single Mollie API object. + * + * @param string $id + * @param array $body + * + * @return mixed + * @throws ApiException + */ + protected function rest_update($id, array $body = []) + { + if (empty($id)) { + throw new ApiException("Invalid resource id."); + } + + $id = urlencode($id); + $result = $this->client->performHttpCall( + self::REST_UPDATE, + "{$this->getResourcePath()}/{$id}", + $this->parseRequestBody($body) + ); + + if ($result == null) { + return null; + } + + return ResourceFactory::createFromApiResult($result, $this->getResourceObject()); + } + + /** + * Retrieves a single object from the REST API. + * + * @param string $id Id of the object to retrieve. + * @param array $filters + * @return mixed + * @throws ApiException + */ + protected function rest_read($id, array $filters) + { + if (empty($id)) { + throw new ApiException("Invalid resource id."); + } + + $id = urlencode($id); + $result = $this->client->performHttpCall( + self::REST_READ, + "{$this->getResourcePath()}/{$id}" . $this->buildQueryString($filters) + ); + + return ResourceFactory::createFromApiResult($result, $this->getResourceObject()); + } + + /** + * Sends a DELETE request to a single Molle API object. + * + * @param string $id + * @param array $body + * + * @return mixed + * @throws ApiException + */ + protected function rest_delete($id, array $body = []) + { + if (empty($id)) { + throw new ApiException("Invalid resource id."); + } + + $id = urlencode($id); + $result = $this->client->performHttpCall( + self::REST_DELETE, + "{$this->getResourcePath()}/{$id}", + $this->parseRequestBody($body) + ); + + if ($result == null) { + return null; + } + + return ResourceFactory::createFromApiResult($result, $this->getResourceObject()); + } + + + + /** + * Get the object that is used by this API endpoint. Every API endpoint uses one type of object. + * + * @return BaseResource + */ + abstract protected function getResourceObject(); + + /** + * @param string $resourcePath + */ + public function setResourcePath($resourcePath) + { + $this->resourcePath = strtolower($resourcePath); + } + + /** + * @return string + * @throws ApiException + */ + public function getResourcePath() + { + if (strpos($this->resourcePath, "_") !== false) { + [$parentResource, $childResource] = explode("_", $this->resourcePath, 2); + + if (empty($this->parentId)) { + throw new ApiException("Subresource '{$this->resourcePath}' used without parent '$parentResource' ID."); + } + + return "$parentResource/{$this->parentId}/$childResource"; + } + + return $this->resourcePath; + } + + /** + * @param array $body + * @return null|string + */ + protected function parseRequestBody(array $body) + { + if (empty($body)) { + return null; + } + + return @json_encode($body); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/InvoiceEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/InvoiceEndpoint.php new file mode 100644 index 000000000..a228fd283 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/InvoiceEndpoint.php @@ -0,0 +1,79 @@ +client); + } + + /** + * Get the collection object that is used by this API. Every API uses one type of collection object. + * + * @param int $count + * @param \stdClass $_links + * + * @return \Mollie\Api\Resources\BaseCollection + */ + protected function getResourceCollectionObject($count, $_links) + { + return new InvoiceCollection($this->client, $count, $_links); + } + + /** + * Retrieve an Invoice from Mollie. + * + * Will throw a ApiException if the invoice id is invalid or the resource cannot be found. + * + * @param string $invoiceId + * @param array $parameters + * + * @return Invoice + * @throws ApiException + */ + public function get($invoiceId, array $parameters = []) + { + return $this->rest_read($invoiceId, $parameters); + } + + /** + * Retrieves a collection of Invoices from Mollie. + * + * @param string $from The first invoice ID you want to include in your list. + * @param int $limit + * @param array $parameters + * + * @return InvoiceCollection + * @throws ApiException + */ + public function page($from = null, $limit = null, array $parameters = []) + { + return $this->rest_list($from, $limit, $parameters); + } + + /** + * This is a wrapper method for page + * + * @param array $parameters + * + * @return \Mollie\Api\Resources\BaseCollection + * @throws ApiException + */ + public function all(array $parameters = []) + { + return $this->page(null, null, $parameters); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/MandateEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/MandateEndpoint.php new file mode 100644 index 000000000..046eaf2e1 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/MandateEndpoint.php @@ -0,0 +1,149 @@ +client); + } + + /** + * Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object. + * + * @param int $count + * @param \stdClass $_links + * + * @return MandateCollection + */ + protected function getResourceCollectionObject($count, $_links) + { + return new MandateCollection($this->client, $count, $_links); + } + + /** + * @param Customer $customer + * @param array $options + * @param array $filters + * + * @return \Mollie\Api\Resources\Mandate + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function createFor(Customer $customer, array $options = [], array $filters = []) + { + return $this->createForId($customer->id, $options, $filters); + } + + /** + * @param string $customerId + * @param array $options + * @param array $filters + * + * @return \Mollie\Api\Resources\Mandate + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function createForId($customerId, array $options = [], array $filters = []) + { + $this->parentId = $customerId; + + return parent::rest_create($options, $filters); + } + + /** + * @param Customer $customer + * @param string $mandateId + * @param array $parameters + * + * @return \Mollie\Api\Resources\Mandate + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function getFor(Customer $customer, $mandateId, array $parameters = []) + { + return $this->getForId($customer->id, $mandateId, $parameters); + } + + /** + * @param string $customerId + * @param string $mandateId + * @param array $parameters + * + * @return \Mollie\Api\Resources\Mandate + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function getForId($customerId, $mandateId, array $parameters = []) + { + $this->parentId = $customerId; + + return parent::rest_read($mandateId, $parameters); + } + + /** + * @param Customer $customer + * @param string $from The first resource ID you want to include in your list. + * @param int $limit + * @param array $parameters + * + * @return \Mollie\Api\Resources\MandateCollection + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function listFor(Customer $customer, $from = null, $limit = null, array $parameters = []) + { + return $this->listForId($customer->id, $from, $limit, $parameters); + } + + /** + * @param string $customerId + * @param null $from + * @param null $limit + * @param array $parameters + * + * @return \Mollie\Api\Resources\MandateCollection + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function listForId($customerId, $from = null, $limit = null, array $parameters = []) + { + $this->parentId = $customerId; + + return parent::rest_list($from, $limit, $parameters); + } + + /** + * @param Customer $customer + * @param string $mandateId + * @param array $data + * + * @return null + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function revokeFor(Customer $customer, $mandateId, $data = []) + { + return $this->revokeForId($customer->id, $mandateId, $data); + } + + /** + * @param string $customerId + * @param string $mandateId + * @param array $data + * + * @return null + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function revokeForId($customerId, $mandateId, $data = []) + { + $this->parentId = $customerId; + + return parent::rest_delete($mandateId, $data); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/MethodEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/MethodEndpoint.php new file mode 100644 index 000000000..934a27a84 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/MethodEndpoint.php @@ -0,0 +1,103 @@ +client); + } + + /** + * Retrieve all active methods. In test mode, this includes pending methods. The results are not paginated. + * + * @deprecated Use allActive() instead + * @param array $parameters + * + * @return \Mollie\Api\Resources\BaseCollection|\Mollie\Api\Resources\MethodCollection + * @throws ApiException + */ + public function all(array $parameters = []) + { + return $this->allActive($parameters); + } + + /** + * Retrieve all active methods for the organization. In test mode, this includes pending methods. + * The results are not paginated. + * + * @param array $parameters + * + * @return \Mollie\Api\Resources\BaseCollection|\Mollie\Api\Resources\MethodCollection + * @throws ApiException + */ + public function allActive(array $parameters = []) + { + return parent::rest_list(null, null, $parameters); + } + + /** + * Retrieve all available methods for the organization, including activated and not yet activated methods. The + * results are not paginated. Make sure to include the profileId parameter if using an OAuth Access Token. + * + * @param array $parameters Query string parameters. + * @return \Mollie\Api\Resources\BaseCollection|\Mollie\Api\Resources\MethodCollection + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function allAvailable(array $parameters = []) + { + $url = 'methods/all' . $this->buildQueryString($parameters); + + $result = $this->client->performHttpCall('GET', $url); + + return ResourceFactory::createBaseResourceCollection( + $this->client, + Method::class, + $result->_embedded->methods, + $result->_links + ); + } + + /** + * Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object. + * + * @param int $count + * @param \stdClass $_links + * + * @return MethodCollection + */ + protected function getResourceCollectionObject($count, $_links) + { + return new MethodCollection($count, $_links); + } + + /** + * Retrieve a payment method from Mollie. + * + * Will throw a ApiException if the method id is invalid or the resource cannot be found. + * + * @param string $methodId + * @param array $parameters + * @return \Mollie\Api\Resources\Method + * @throws ApiException + */ + public function get($methodId, array $parameters = []) + { + if (empty($methodId)) { + throw new ApiException("Method ID is empty."); + } + + return parent::rest_read($methodId, $parameters); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/OnboardingEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/OnboardingEndpoint.php new file mode 100644 index 000000000..52ba56958 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/OnboardingEndpoint.php @@ -0,0 +1,89 @@ +client); + } + + /** + * Retrieve the organization's onboarding status from Mollie. + * + * Will throw a ApiException if the resource cannot be found. + * + * @return Onboarding + * @throws ApiException + */ + public function get() + { + return $this->rest_read('', []); + } + + /** + * Submit data that will be prefilled in the merchant’s onboarding. + * Please note that the data you submit will only be processed when the onboarding status is needs-data. + * + * Information that the merchant has entered in their dashboard will not be overwritten. + * + * Will throw a ApiException if the resource cannot be found. + * + * @throws ApiException + */ + public function submit(array $parameters = []) + { + return $this->rest_create($parameters, []); + } + + /** + * @param string $id + * @param array $filters + * + * @return mixed + * @throws \Mollie\Api\Exceptions\ApiException + */ + protected function rest_read($id, array $filters) + { + $result = $this->client->performHttpCall( + self::REST_READ, + $this->getResourcePath() . $this->buildQueryString($filters) + ); + + return ResourceFactory::createFromApiResult($result, $this->getResourceObject()); + } + + /** + * @param array $body + * @param array $filters + * + * @return mixed + * @throws \Mollie\Api\Exceptions\ApiException + */ + protected function rest_create(array $body, array $filters) + { + $this->client->performHttpCall( + self::REST_CREATE, + $this->getResourcePath() . $this->buildQueryString($filters), + $this->parseRequestBody($body) + ); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/OrderEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/OrderEndpoint.php new file mode 100644 index 000000000..605544a30 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/OrderEndpoint.php @@ -0,0 +1,130 @@ +client); + } + + /** + * Get the collection object that is used by this API endpoint. Every API + * endpoint uses one type of collection object. + * + * @param int $count + * @param \stdClass $_links + * + * @return OrderCollection + */ + protected function getResourceCollectionObject($count, $_links) + { + return new OrderCollection($this->client, $count, $_links); + } + + /** + * Creates a order in Mollie. + * + * @param array $data An array containing details on the order. + * @param array $filters + * + * @return Order + * @throws ApiException + */ + public function create(array $data = [], array $filters = []) + { + return $this->rest_create($data, $filters); + } + + /** + * Update a specific Order resource + * + * Will throw a ApiException if the order id is invalid or the resource cannot be found. + * + * @param string $orderId + * + * @param array $data + * @return Order + * @throws ApiException + */ + 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."'."); + } + + return parent::rest_update($orderId, $data); + } + + /** + * Retrieve a single order from Mollie. + * + * Will throw a ApiException if the order id is invalid or the resource cannot + * be found. + * + * @param array $parameters + * @return Order + * @throws ApiException + */ + 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."'."); + } + + return parent::rest_read($orderId, $parameters); + } + + /** + * Cancel the given Order. + * + * If the order was partially shipped, the status will be "completed" instead of + * "canceled". + * Will throw a ApiException if the order id is invalid or the resource cannot + * be found. + * Returns the canceled order with HTTP status 200. + * + * @param string $orderId + * + * @param array $parameters + * @return Order + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function cancel($orderId, $parameters = []) + { + return $this->rest_delete($orderId, $parameters); + } + + /** + * Retrieves a collection of Orders from Mollie. + * + * @param string $from The first order ID you want to include in your list. + * @param int $limit + * @param array $parameters + * + * @return OrderCollection + * @throws ApiException + */ + public function page($from = null, $limit = null, array $parameters = []) + { + return $this->rest_list($from, $limit, $parameters); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/OrderLineEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/OrderLineEndpoint.php new file mode 100644 index 000000000..2f16f0dad --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/OrderLineEndpoint.php @@ -0,0 +1,139 @@ +client); + } + + /** + * Get the collection object that is used by this API endpoint. Every API + * endpoint uses one type of collection object. + * + * @param int $count + * @param \stdClass $_links + * + * @return OrderLineCollection + */ + protected function getResourceCollectionObject($count, $_links) + { + return new OrderLineCollection($count, $_links); + } + + /** + * Update a specific OrderLine resource. + * + * Will throw an ApiException if the order line id is invalid or the resource cannot be found. + * + * @param string|null $orderId + * @param string $orderlineId + * + * @param array $data + * + * @return \Mollie\Api\Resources\BaseResource|null + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function update($orderId, $orderlineId, array $data = []) + { + $this->parentId = $orderId; + + if (empty($orderlineId) || strpos($orderlineId, self::RESOURCE_ID_PREFIX) !== 0) { + throw new ApiException("Invalid order line ID: '{$orderlineId}'. An order line ID should start with '".self::RESOURCE_ID_PREFIX."'."); + } + + return parent::rest_update($orderlineId, $data); + } + + /** + * @param string $orderId + * @param array $operations + * @param array $parameters + * @return Order|\Mollie\Api\Resources\BaseResource + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function updateMultiple(string $orderId, array $operations, array $parameters = []) + { + if (empty($orderId)) { + throw new ApiException("Invalid resource id."); + } + + $this->parentId = $orderId; + + $parameters['operations'] = $operations; + + $result = $this->client->performHttpCall( + self::REST_UPDATE, + "{$this->getResourcePath()}", + $this->parseRequestBody($parameters) + ); + + return ResourceFactory::createFromApiResult($result, new Order($this->client)); + } + + /** + * Cancel lines for the provided order. + * The data array must contain a lines array. + * You can pass an empty lines array if you want to cancel all eligible lines. + * Returns null if successful. + * + * @param Order $order + * @param array $data + * + * @return null + * @throws ApiException + */ + public function cancelFor(Order $order, array $data) + { + return $this->cancelForId($order->id, $data); + } + + /** + * Cancel lines for the provided order id. + * The data array must contain a lines array. + * You can pass an empty lines array if you want to cancel all eligible lines. + * Returns null if successful. + * + * @param string $orderId + * @param array $data + * + * @return null + * @throws ApiException + */ + public function cancelForId($orderId, array $data) + { + if (! isset($data['lines']) || ! is_array($data['lines'])) { + throw new ApiException("A lines array is required."); + } + $this->parentId = $orderId; + + $this->client->performHttpCall( + self::REST_DELETE, + "{$this->getResourcePath()}", + $this->parseRequestBody($data) + ); + + return null; + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/OrderPaymentEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/OrderPaymentEndpoint.php new file mode 100644 index 000000000..6bedacf3e --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/OrderPaymentEndpoint.php @@ -0,0 +1,74 @@ +client); + } + + /** + * Get the collection object that is used by this API endpoint. Every API + * endpoint uses one type of collection object. + * + * @param int $count + * @param \stdClass $_links + * + * @return \Mollie\Api\Resources\PaymentCollection + */ + protected function getResourceCollectionObject($count, $_links) + { + return new PaymentCollection($this->client, $count, $_links); + } + + /** + * Creates a payment in Mollie for a specific order. + * + * @param \Mollie\Api\Resources\Order $order + * @param array $data An array containing details on the order payment. + * @param array $filters + * + * @return \Mollie\Api\Resources\Payment + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function createFor(Order $order, array $data, array $filters = []) + { + return $this->createForId($order->id, $data, $filters); + } + + /** + * Creates a payment in Mollie for a specific order ID. + * + * @param string $orderId + * @param array $data An array containing details on the order payment. + * @param array $filters + * + * @return \Mollie\Api\Resources\Payment + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function createForId($orderId, array $data, array $filters = []) + { + $this->parentId = $orderId; + + return $this->rest_create($data, $filters); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/OrderRefundEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/OrderRefundEndpoint.php new file mode 100644 index 000000000..d50c9e3b4 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/OrderRefundEndpoint.php @@ -0,0 +1,69 @@ +client); + } + + /** + * Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object. + * + * @param int $count + * @param \stdClass $_links + * + * @return RefundCollection + */ + protected function getResourceCollectionObject($count, $_links) + { + return new RefundCollection($this->client, $count, $_links); + } + + /** + * Refund some order lines. You can provide an empty array for the + * "lines" data to refund all eligible lines for this order. + * + * @param Order $order + * @param array $data + * @param array $filters + * + * @return Refund + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function createFor(Order $order, array $data, array $filters = []) + { + return $this->createForId($order->id, $data, $filters); + } + + /** + * Refund some order lines. You can provide an empty array for the + * "lines" data to refund all eligible lines for this order. + * + * @param string $orderId + * @param array $data + * @param array $filters + * + * @return \Mollie\Api\Resources\Refund + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function createForId($orderId, array $data, array $filters = []) + { + $this->parentId = $orderId; + + return parent::rest_create($data, $filters); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/OrganizationEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/OrganizationEndpoint.php new file mode 100644 index 000000000..10a7d7b95 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/OrganizationEndpoint.php @@ -0,0 +1,64 @@ +client); + } + + /** + * Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object. + * + * @param int $count + * @param \stdClass $_links + * + * @return OrganizationCollection + */ + protected function getResourceCollectionObject($count, $_links) + { + return new OrganizationCollection($this->client, $count, $_links); + } + + /** + * Retrieve an organization from Mollie. + * + * Will throw a ApiException if the organization id is invalid or the resource cannot be found. + * + * @param string $organizationId + * @param array $parameters + * @return Organization + * @throws ApiException + */ + public function get($organizationId, array $parameters = []) + { + if (empty($organizationId)) { + throw new ApiException("Organization ID is empty."); + } + + return parent::rest_read($organizationId, $parameters); + } + + /** + * Retrieve the current organization from Mollie. + * + * @param array $parameters + * @return Organization + * @throws ApiException + */ + public function current(array $parameters = []) + { + return parent::rest_read('me', $parameters); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/OrganizationPartnerEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/OrganizationPartnerEndpoint.php new file mode 100644 index 000000000..06a677b04 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/OrganizationPartnerEndpoint.php @@ -0,0 +1,58 @@ +client); + } + + /** + * Retrieve details about the partner status of the currently authenticated organization. + * + * Will throw an ApiException if the resource cannot be found. + * + * @return Partner + * @throws ApiException + */ + public function get() + { + return $this->rest_read('', []); + } + + /** + * @param string $id + * @param array $filters + * + * @return mixed + * @throws \Mollie\Api\Exceptions\ApiException + */ + protected function rest_read($id, array $filters) + { + $result = $this->client->performHttpCall( + self::REST_READ, + $this->getResourcePath() . $this->buildQueryString($filters) + ); + + return ResourceFactory::createFromApiResult($result, $this->getResourceObject()); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentCaptureEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentCaptureEndpoint.php new file mode 100644 index 000000000..6766235ab --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentCaptureEndpoint.php @@ -0,0 +1,121 @@ +client); + } + + /** + * Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object. + * + * @param int $count + * @param \stdClass $_links + * + * @return \Mollie\Api\Resources\CaptureCollection + */ + protected function getResourceCollectionObject($count, $_links) + { + return new CaptureCollection($this->client, $count, $_links); + } + + /** + * Creates a payment capture in Mollie. + * + * @param Payment $payment. + * @param array $data An array containing details on the capture. + * @param array $filters + * + * @return Capture + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function createFor(Payment $payment, array $data = [], array $filters = []) + { + return $this->createForId($payment->id, $data, $filters); + } + + /** + * Creates a payment capture in Mollie. + * + * @param string $paymentId The payment's ID. + * @param array $data An array containing details on the capture. + * @param array $filters + * + * @return Capture + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function createForId($paymentId, array $data = [], array $filters = []) + { + $this->parentId = $paymentId; + + return $this->rest_create($data, $filters); + } + + /** + * @param Payment $payment + * @param string $captureId + * @param array $parameters + * + * @return Capture + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function getFor(Payment $payment, $captureId, array $parameters = []) + { + return $this->getForId($payment->id, $captureId, $parameters); + } + + /** + * @param string $paymentId + * @param string $captureId + * @param array $parameters + * + * @return \Mollie\Api\Resources\Capture + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function getForId($paymentId, $captureId, array $parameters = []) + { + $this->parentId = $paymentId; + + return parent::rest_read($captureId, $parameters); + } + + /** + * @param Payment $payment + * @param array $parameters + * + * @return Capture + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function listFor(Payment $payment, array $parameters = []) + { + return $this->listForId($payment->id, $parameters); + } + + /** + * @param string $paymentId + * @param array $parameters + * + * @return \Mollie\Api\Resources\BaseCollection|\Mollie\Api\Resources\Capture + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function listForId($paymentId, array $parameters = []) + { + $this->parentId = $paymentId; + + return parent::rest_list(null, null, $parameters); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentChargebackEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentChargebackEndpoint.php new file mode 100644 index 000000000..e27ddeb5a --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentChargebackEndpoint.php @@ -0,0 +1,89 @@ +client); + } + + /** + * Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object. + * + * @param int $count + * @param \stdClass $_links + * + * @return ChargebackCollection + */ + protected function getResourceCollectionObject($count, $_links) + { + return new ChargebackCollection($this->client, $count, $_links); + } + + /** + * @param Payment $payment + * @param string $chargebackId + * @param array $parameters + * + * @return Chargeback + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function getFor(Payment $payment, $chargebackId, array $parameters = []) + { + return $this->getForId($payment->id, $chargebackId, $parameters); + } + + /** + * @param string $paymentId + * @param string $chargebackId + * @param array $parameters + * + * @return Chargeback + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function getForId($paymentId, $chargebackId, array $parameters = []) + { + $this->parentId = $paymentId; + + return parent::rest_read($chargebackId, $parameters); + } + + /** + * @param Payment $payment + * @param array $parameters + * + * @return Chargeback + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function listFor(Payment $payment, array $parameters = []) + { + return $this->listForId($payment->id, $parameters); + } + + /** + * @param string $paymentId + * @param array $parameters + * + * @return \Mollie\Api\Resources\BaseCollection|\Mollie\Api\Resources\Chargeback + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function listForId($paymentId, array $parameters = []) + { + $this->parentId = $paymentId; + + return parent::rest_list(null, null, $parameters); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentEndpoint.php new file mode 100644 index 000000000..a840863e7 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentEndpoint.php @@ -0,0 +1,168 @@ +client); + } + + /** + * Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object. + * + * @param int $count + * @param \stdClass $_links + * + * @return PaymentCollection + */ + protected function getResourceCollectionObject($count, $_links) + { + return new PaymentCollection($this->client, $count, $_links); + } + + /** + * Creates a payment in Mollie. + * + * @param array $data An array containing details on the payment. + * @param array $filters + * + * @return Payment + * @throws ApiException + */ + public function create(array $data = [], array $filters = []) + { + return $this->rest_create($data, $filters); + } + + /** + * Update the given Payment. + * + * Will throw a ApiException if the payment id is invalid or the resource cannot be found. + * + * @param string $paymentId + * + * @param array $data + * @return Payment + * @throws ApiException + */ + 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."'."); + } + + return parent::rest_update($paymentId, $data); + } + + /** + * Retrieve a single payment from Mollie. + * + * Will throw a ApiException if the payment id is invalid or the resource cannot be found. + * + * @param string $paymentId + * @param array $parameters + * @return Payment + * @throws ApiException + */ + 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."'."); + } + + return parent::rest_read($paymentId, $parameters); + } + + /** + * Deletes the given Payment. + * + * Will throw a ApiException if the payment id is invalid or the resource cannot be found. + * Returns with HTTP status No Content (204) if successful. + * + * @param string $paymentId + * + * @param array $data + * @return Payment + * @throws ApiException + */ + public function delete($paymentId, array $data = []) + { + return $this->rest_delete($paymentId, $data); + } + + /** + * Cancel the given Payment. This is just an alias of the 'delete' method. + * + * Will throw a ApiException if the payment id is invalid or the resource cannot be found. + * Returns with HTTP status No Content (204) if successful. + * + * @param string $paymentId + * + * @param array $data + * @return Payment + * @throws ApiException + */ + public function cancel($paymentId, array $data = []) + { + return $this->rest_delete($paymentId, $data); + } + + /** + * Retrieves a collection of Payments from Mollie. + * + * @param string $from The first payment ID you want to include in your list. + * @param int $limit + * @param array $parameters + * + * @return PaymentCollection + * @throws ApiException + */ + public function page($from = null, $limit = null, array $parameters = []) + { + return $this->rest_list($from, $limit, $parameters); + } + + /** + * Issue a refund for the given payment. + * + * The $data parameter may either be an array of endpoint parameters, a float value to + * initiate a partial refund, or empty to do a full refund. + * + * @param Payment $payment + * @param array|float|null $data + * + * @return Refund + * @throws ApiException + */ + public function refund(Payment $payment, $data = []) + { + $resource = "{$this->getResourcePath()}/" . urlencode($payment->id) . "/refunds"; + + $body = null; + if (($data === null ? 0 : count($data)) > 0) { + $body = json_encode($data); + } + + $result = $this->client->performHttpCall(self::REST_CREATE, $resource, $body); + + return ResourceFactory::createFromApiResult($result, new Refund($this->client)); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentLinkEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentLinkEndpoint.php new file mode 100644 index 000000000..8f3f3bef1 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentLinkEndpoint.php @@ -0,0 +1,87 @@ +client); + } + + /** + * Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object. + * + * @param int $count + * @param \stdClass $_links + * + * @return PaymentLinkCollection + */ + protected function getResourceCollectionObject($count, $_links) + { + return new PaymentLinkCollection($this->client, $count, $_links); + } + + /** + * Creates a payment link in Mollie. + * + * @param array $data An array containing details on the payment link. + * @param array $filters + * + * @return PaymentLink + * @throws ApiException + */ + public function create(array $data = [], array $filters = []) + { + return $this->rest_create($data, $filters); + } + + /** + * Retrieve payment link from Mollie. + * + * Will throw a ApiException if the payment link id is invalid or the resource cannot be found. + * + * @param string $paymentLinkId + * @param array $parameters + * @return PaymentLink + * @throws ApiException + */ + 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."'."); + } + + return parent::rest_read($paymentLinkId, $parameters); + } + + /** + * Retrieves a collection of Payment Links from Mollie. + * + * @param string $from The first payment link ID you want to include in your list. + * @param int $limit + * @param array $parameters + * + * @return PaymentLinkCollection + * @throws ApiException + */ + public function page($from = null, $limit = null, array $parameters = []) + { + return $this->rest_list($from, $limit, $parameters); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentRefundEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentRefundEndpoint.php new file mode 100644 index 000000000..3dfa24696 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentRefundEndpoint.php @@ -0,0 +1,122 @@ +client); + } + + /** + * Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object. + * + * @param int $count + * @param \stdClass $_links + * + * @return RefundCollection + */ + protected function getResourceCollectionObject($count, $_links) + { + return new RefundCollection($this->client, $count, $_links); + } + + /** + * @param Payment $payment + * @param string $refundId + * @param array $parameters + * + * @return Refund + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function getFor(Payment $payment, $refundId, array $parameters = []) + { + return $this->getForId($payment->id, $refundId, $parameters); + } + + /** + * @param string $paymentId + * @param string $refundId + * @param array $parameters + * + * @return \Mollie\Api\Resources\Refund + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function getForId($paymentId, $refundId, array $parameters = []) + { + $this->parentId = $paymentId; + + return parent::rest_read($refundId, $parameters); + } + + /** + * @param Payment $payment + * @param array $parameters + * + * @return Refund + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function listFor(Payment $payment, array $parameters = []) + { + return $this->listForId($payment->id, $parameters); + } + + /** + * @param string $paymentId + * @param array $parameters + * + * @return \Mollie\Api\Resources\BaseCollection|\Mollie\Api\Resources\Refund + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function listForId($paymentId, array $parameters = []) + { + $this->parentId = $paymentId; + + return parent::rest_list(null, null, $parameters); + } + + + /** + * Creates a refund for a specific payment. + * + * @param Payment $payment + * @param array $data + * @param array $filters + * + * @return Refund + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function createFor(Payment $payment, array $data, array $filters = []) + { + return $this->createForId($payment->id, $data, $filters); + } + + /** + * Creates a refund for a specific payment. + * + * @param string $paymentId + * @param array $data + * @param array $filters + * + * @return \Mollie\Api\Resources\Refund + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function createForId(string $paymentId, array $data, array $filters = []) + { + $this->parentId = $paymentId; + + return parent::rest_create($data, $filters); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentRouteEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentRouteEndpoint.php new file mode 100644 index 000000000..fc5c654cb --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/PaymentRouteEndpoint.php @@ -0,0 +1,70 @@ +client); + } + + /** + * Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object. + * + * @param int $count + * @param \stdClass $_links + * + * @return \Mollie\Api\Resources\RouteCollection + */ + protected function getResourceCollectionObject($count, $_links) + { + return new RouteCollection($this->client, $count, $_links); + } + + /** + * @param Payment $payment + * @param string $routeId + * @param string $releaseDate - UTC datetime in ISO-8601 format when the funds for the following payment will become available on + * the balance of the connected account + * + * @return Route + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function updateReleaseDateFor(Payment $payment, $routeId, $releaseDate) + { + return $this->updateReleaseDateForPaymentId($payment->id, $routeId, $releaseDate); + } + + /** + * @param string $paymentId + * @param string $routeId + * @param string $releaseDate - UTC datetime in ISO-8601 format when the funds for the following payment will become available on + * the balance of the connected account + * + * @return \Mollie\Api\Resources\Route + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function updateReleaseDateForPaymentId($paymentId, $routeId, $releaseDate, $testmode = false) + { + $this->parentId = $paymentId; + + $params = [ + 'releaseDate' => $releaseDate, + 'testmode' => $testmode, + ]; + + return parent::rest_update($routeId, $params); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/PermissionEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/PermissionEndpoint.php new file mode 100644 index 000000000..fbe038204 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/PermissionEndpoint.php @@ -0,0 +1,65 @@ +client); + } + + /** + * Get the collection object that is used by this API endpoint. Every API + * endpoint uses one type of collection object. + * + * @param int $count + * @param \stdClass $_links + * + * @return PermissionCollection + */ + protected function getResourceCollectionObject($count, $_links) + { + return new PermissionCollection($count, $_links); + } + + /** + * Retrieve a single Permission from Mollie. + * + * Will throw an ApiException if the permission id is invalid. + * + * @param string $permissionId + * @param array $parameters + * @return Permission + * @throws ApiException + */ + public function get($permissionId, array $parameters = []) + { + return $this->rest_read($permissionId, $parameters); + } + + /** + * Retrieve all permissions. + * + * @param array $parameters + * + * @return PermissionCollection + * @throws ApiException + */ + public function all(array $parameters = []) + { + return parent::rest_list(null, null, $parameters); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/ProfileEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/ProfileEndpoint.php new file mode 100644 index 000000000..498d442ad --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/ProfileEndpoint.php @@ -0,0 +1,143 @@ +resourceClass($this->client); + } + + /** + * Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object. + * + * @param int $count + * @param \stdClass $_links + * + * @return ProfileCollection + */ + protected function getResourceCollectionObject($count, $_links) + { + return new ProfileCollection($this->client, $count, $_links); + } + + /** + * Creates a Profile in Mollie. + * + * @param array $data An array containing details on the profile. + * @param array $filters + * + * @return Profile + * @throws ApiException + */ + public function create(array $data = [], array $filters = []) + { + return $this->rest_create($data, $filters); + } + + /** + * Retrieve a Profile from Mollie. + * + * Will throw an ApiException if the profile id is invalid or the resource cannot be found. + * + * @param string $profileId + * @param array $parameters + * + * @return Profile + * @throws ApiException + */ + public function get($profileId, array $parameters = []) + { + if ($profileId === 'me') { + return $this->getCurrent($parameters); + } + + return $this->rest_read($profileId, $parameters); + } + + /** + * Update a specific Profile resource. + * + * Will throw an ApiException if the profile id is invalid or the resource cannot be found. + * + * @param string $profileId + * + * @param array $data + * @return Profile + * @throws ApiException + */ + 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."'."); + } + + return parent::rest_update($profileId, $data); + } + + /** + * Retrieve the current Profile from Mollie. + * + * @param array $parameters + * + * @return CurrentProfile + * @throws ApiException + */ + public function getCurrent(array $parameters = []) + { + $this->resourceClass = CurrentProfile::class; + + return $this->rest_read('me', $parameters); + } + + /** + * Delete a Profile from Mollie. + * + * Will throw a ApiException if the profile id is invalid or the resource cannot be found. + * Returns with HTTP status No Content (204) if successful. + * + * @param string $profileId + * + * @param array $data + * @return Profile + * @throws ApiException + */ + public function delete($profileId, array $data = []) + { + return $this->rest_delete($profileId, $data); + } + + /** + * Retrieves a collection of Profiles from Mollie. + * + * @param string $from The first profile ID you want to include in your list. + * @param int $limit + * @param array $parameters + * + * @return ProfileCollection + * @throws ApiException + */ + public function page($from = null, $limit = null, array $parameters = []) + { + return $this->rest_list($from, $limit, $parameters); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/ProfileMethodEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/ProfileMethodEndpoint.php new file mode 100644 index 000000000..606d6141c --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/ProfileMethodEndpoint.php @@ -0,0 +1,129 @@ +client); + } + + /** + * Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object. + * + * @param int $count + * @param \stdClass $_links + * + * @return MethodCollection() + */ + protected function getResourceCollectionObject($count, $_links) + { + return new MethodCollection($count, $_links); + } + + /** + * Enable a method for the provided Profile ID. + * + * @param string $profileId + * @param string $methodId + * @param array $data + * @return \Mollie\Api\Resources\Method + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function createForId($profileId, $methodId, array $data = []) + { + $this->parentId = $profileId; + $resource = $this->getResourcePath() . '/' . urlencode($methodId); + + $body = null; + if (count($data) > 0) { + $body = json_encode($data); + } + + $result = $this->client->performHttpCall(self::REST_CREATE, $resource, $body); + + return ResourceFactory::createFromApiResult($result, new Method($this->client)); + } + + /** + * Enable a method for the provided Profile object. + * + * @param Profile $profile + * @param string $methodId + * @param array $data + * @return Method + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function createFor($profile, $methodId, array $data = []) + { + return $this->createForId($profile->id, $methodId, $data); + } + + /** + * Enable a method for the current profile. + * + * @param string $methodId + * @param array $data + * @return \Mollie\Api\Resources\Method + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function createForCurrentProfile($methodId, array $data = []) + { + return $this->createForId('me', $methodId, $data); + } + + /** + * Disable a method for the provided Profile ID. + * + * @param string $profileId + * @param string $methodId + * @param array $data + * @return mixed + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function deleteForId($profileId, $methodId, array $data = []) + { + $this->parentId = $profileId; + + return $this->rest_delete($methodId, $data); + } + + /** + * Disable a method for the provided Profile object. + * + * @param Profile $profile + * @param string $methodId + * @param array $data + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function deleteFor($profile, $methodId, array $data = []) + { + return $this->deleteForId($profile->id, $methodId, $data); + } + + /** + * Disable a method for the current profile. + * + * @param string $methodId + * @param array $data + * @return \Mollie\Api\Resources\Method + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function deleteForCurrentProfile($methodId, array $data) + { + return $this->deleteForId('me', $methodId, $data); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/RefundEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/RefundEndpoint.php new file mode 100644 index 000000000..385e21c0f --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/RefundEndpoint.php @@ -0,0 +1,50 @@ +client); + } + + /** + * Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object. + * + * @param int $count + * @param \stdClass $_links + * + * @return RefundCollection + */ + protected function getResourceCollectionObject($count, $_links) + { + return new RefundCollection($this->client, $count, $_links); + } + + /** + * Retrieves a collection of Refunds from Mollie. + * + * @param string $from The first refund ID you want to include in your list. + * @param int $limit + * @param array $parameters + * + * @return RefundCollection + * @throws ApiException + */ + public function page($from = null, $limit = null, array $parameters = []) + { + return $this->rest_list($from, $limit, $parameters); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/SettlementPaymentEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/SettlementPaymentEndpoint.php new file mode 100644 index 000000000..6ac8304e5 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/SettlementPaymentEndpoint.php @@ -0,0 +1,45 @@ +client); + } + + /** + * @inheritDoc + */ + protected function getResourceCollectionObject($count, $_links) + { + return new PaymentCollection($this->client, $count, $_links); + } + + /** + * Retrieves a collection of Payments from Mollie. + * + * @param string $settlementId + * @param string $from The first payment ID you want to include in your list. + * @param int $limit + * @param array $parameters + * + * @return mixed + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function pageForId($settlementId, $from = null, $limit = null, array $parameters = []) + { + $this->parentId = $settlementId; + + return $this->rest_list($from, $limit, $parameters); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/SettlementsEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/SettlementsEndpoint.php new file mode 100644 index 000000000..a4d49e85e --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/SettlementsEndpoint.php @@ -0,0 +1,87 @@ +client); + } + + /** + * Get the collection object that is used by this API. Every API uses one type of collection object. + * + * @param int $count + * @param \stdClass $_links + * + * @return \Mollie\Api\Resources\BaseCollection + */ + protected function getResourceCollectionObject($count, $_links) + { + return new SettlementCollection($this->client, $count, $_links); + } + + /** + * Retrieve a single settlement from Mollie. + * + * Will throw a ApiException if the settlement id is invalid or the resource cannot be found. + * + * @param string $settlementId + * @param array $parameters + * @return Settlement + * @throws ApiException + */ + public function get($settlementId, array $parameters = []) + { + return parent::rest_read($settlementId, $parameters); + } + + /** + * Retrieve the details of the current settlement that has not yet been paid out. + * + * @return Settlement + * @throws ApiException + */ + public function next() + { + return parent::rest_read("next", []); + } + + /** + * Retrieve the details of the open balance of the organization. + * + * @return Settlement + * @throws ApiException + */ + public function open() + { + return parent::rest_read("open", []); + } + + /** + * Retrieves a collection of Settlements from Mollie. + * + * @param string $from The first settlement ID you want to include in your list. + * @param int $limit + * @param array $parameters + * + * @return SettlementCollection + * @throws ApiException + */ + public function page($from = null, $limit = null, array $parameters = []) + { + return $this->rest_list($from, $limit, $parameters); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/ShipmentEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/ShipmentEndpoint.php new file mode 100644 index 000000000..6456ab7ca --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/ShipmentEndpoint.php @@ -0,0 +1,161 @@ +client); + } + + /** + * Get the collection object that is used by this API endpoint. Every API + * endpoint uses one type of collection object. + * + * @param int $count + * @param \stdClass $_links + * + * @return ShipmentCollection + */ + protected function getResourceCollectionObject($count, $_links) + { + return new ShipmentCollection($count, $_links); + } + + /** + * Create a shipment for some order lines. You can provide an empty array for the + * "lines" option to include all unshipped lines for this order. + * + * @param Order $order + * @param array $options + * @param array $filters + * + * @return Shipment + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function createFor(Order $order, array $options = [], array $filters = []) + { + return $this->createForId($order->id, $options, $filters); + } + + /** + * Create a shipment for some order lines. You can provide an empty array for the + * "lines" option to include all unshipped lines for this order. + * + * @param string $orderId + * @param array $options + * @param array $filters + * + * @return Shipment + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function createForId($orderId, array $options = [], array $filters = []) + { + $this->parentId = $orderId; + + return parent::rest_create($options, $filters); + } + + /** + * Retrieve a single shipment and the order lines shipped by a shipment’s ID. + * + * @param Order $order + * @param string $shipmentId + * @param array $parameters + * + * @return Shipment + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function getFor(Order $order, $shipmentId, array $parameters = []) + { + return $this->getForId($order->id, $shipmentId, $parameters); + } + + /** + * Retrieve a single shipment and the order lines shipped by a shipment’s ID. + * + * @param string $orderId + * @param string $shipmentId + * @param array $parameters + * + * @return \Mollie\Api\Resources\Shipment + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function getForId($orderId, $shipmentId, array $parameters = []) + { + $this->parentId = $orderId; + + return parent::rest_read($shipmentId, $parameters); + } + + /** + * Update a specific Order Shipment resource. + * + * Will throw an ApiException if the shipment id is invalid or the resource cannot be found. + * + * @param string $shipmentId + * @param string $orderId + * + * @param array $data + * @return Shipment + * @throws ApiException + */ + 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."'."); + } + + $this->parentId = $orderId; + + return parent::rest_update($shipmentId, $data); + } + + /** + * Return all shipments for the Order provided. + * + * @param Order $order + * @param array $parameters + * + * @return ShipmentCollection + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function listFor(Order $order, array $parameters = []) + { + return $this->listForId($order->id, $parameters); + } + + /** + * Return all shipments for the provided Order id. + * + * @param string $orderId + * @param array $parameters + * + * @return \Mollie\Api\Resources\ShipmentCollection + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function listForId($orderId, array $parameters = []) + { + $this->parentId = $orderId; + + return parent::rest_list(null, null, $parameters); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/SubscriptionEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/SubscriptionEndpoint.php new file mode 100644 index 000000000..d9b919af3 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/SubscriptionEndpoint.php @@ -0,0 +1,212 @@ +client); + } + + /** + * Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object. + * + * @param int $count + * @param \stdClass $_links + * + * @return SubscriptionCollection + */ + protected function getResourceCollectionObject($count, $_links) + { + return new SubscriptionCollection($this->client, $count, $_links); + } + + /** + * Create a subscription for a Customer + * + * @param Customer $customer + * @param array $options + * @param array $filters + * + * @return Subscription + * @throws ApiException + */ + public function createFor(Customer $customer, array $options = [], array $filters = []) + { + return $this->createForId($customer->id, $options, $filters); + } + + /** + * Create a subscription for a Customer + * + * @param string $customerId + * @param array $options + * @param array $filters + * + * @return Subscription + * @throws ApiException + */ + public function createForId($customerId, array $options = [], array $filters = []) + { + $this->parentId = $customerId; + + return parent::rest_create($options, $filters); + } + + /** + * Update a specific Subscription resource. + * + * Will throw an ApiException if the subscription id is invalid or the resource cannot be found. + * + * @param string $subscriptionId + * @param string $customerId + * + * @param array $data + * + * @return Subscription + * @throws ApiException + */ + 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."'."); + } + + $this->parentId = $customerId; + + return parent::rest_update($subscriptionId, $data); + } + + /** + * @param Customer $customer + * @param string $subscriptionId + * @param array $parameters + * + * @return Subscription + * @throws ApiException + */ + public function getFor(Customer $customer, $subscriptionId, array $parameters = []) + { + return $this->getForId($customer->id, $subscriptionId, $parameters); + } + + /** + * @param string $customerId + * @param string $subscriptionId + * @param array $parameters + * + * @return Subscription + * @throws ApiException + */ + public function getForId($customerId, $subscriptionId, array $parameters = []) + { + $this->parentId = $customerId; + + return parent::rest_read($subscriptionId, $parameters); + } + + /** + * @param Customer $customer + * @param string $from The first resource ID you want to include in your list. + * @param int $limit + * @param array $parameters + * + * @return SubscriptionCollection + * @throws ApiException + */ + public function listFor(Customer $customer, $from = null, $limit = null, array $parameters = []) + { + return $this->listForId($customer->id, $from, $limit, $parameters); + } + + /** + * @param string $customerId + * @param string $from The first resource ID you want to include in your list. + * @param int $limit + * @param array $parameters + * + * @return SubscriptionCollection + * @throws ApiException + */ + public function listForId($customerId, $from = null, $limit = null, array $parameters = []) + { + $this->parentId = $customerId; + + return parent::rest_list($from, $limit, $parameters); + } + + /** + * @param Customer $customer + * @param string $subscriptionId + * @param array $data + * + * @return null + * @throws ApiException + */ + public function cancelFor(Customer $customer, $subscriptionId, array $data = []) + { + return $this->cancelForId($customer->id, $subscriptionId, $data); + } + + /** + * @param string $customerId + * @param string $subscriptionId + * @param array $data + * + * @return null + * @throws ApiException + */ + public function cancelForId($customerId, $subscriptionId, array $data = []) + { + $this->parentId = $customerId; + + return parent::rest_delete($subscriptionId, $data); + } + + /** + * Retrieves a collection of Subscriptions from Mollie. + * + * @param string $from The first payment ID you want to include in your list. + * @param int $limit + * @param array $parameters + * + * @return SubscriptionCollection + * @throws ApiException + */ + public function page($from = null, $limit = null, array $parameters = []) + { + $filters = array_merge(["from" => $from, "limit" => $limit], $parameters); + + $apiPath = 'subscriptions' . $this->buildQueryString($filters); + + $result = $this->client->performHttpCall(self::REST_LIST, $apiPath); + + /** @var SubscriptionCollection $collection */ + $collection = $this->getResourceCollectionObject($result->count, $result->_links); + + foreach ($result->_embedded->{$collection->getCollectionResourceName()} as $dataResult) { + $collection[] = ResourceFactory::createFromApiResult($dataResult, $this->getResourceObject()); + } + + return $collection; + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/TerminalEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/TerminalEndpoint.php new file mode 100644 index 000000000..4b100b566 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/TerminalEndpoint.php @@ -0,0 +1,72 @@ +client); + } + + /** + * Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object. + * + * @param int $count + * @param \stdClass $_links + * + * @return TerminalCollection + */ + protected function getResourceCollectionObject($count, $_links) + { + return new TerminalCollection($this->client, $count, $_links); + } + + /** + * Retrieve terminal from Mollie. + * + * Will throw a ApiException if the terminal id is invalid or the resource cannot be found. + * + * @param string $terminalId + * @param array $parameters + * @return Terminal + * @throws ApiException + */ + public function get($terminalId, array $parameters = []) + { + if (empty($terminalId) || strpos($terminalId, self::RESOURCE_ID_PREFIX) !== 0) { + throw new ApiException("Invalid terminal ID: '{$terminalId}'. A terminal ID should start with '" . self::RESOURCE_ID_PREFIX . "'."); + } + + return parent::rest_read($terminalId, $parameters); + } + + /** + * Retrieves a collection of Terminals from Mollie for the current organization / profile, ordered from newest to oldest. + * + * @param string $from The first terminal ID you want to include in your list. + * @param int $limit + * @param array $parameters + * + * @return TerminalCollection + * @throws ApiException + */ + public function page($from = null, $limit = null, array $parameters = []) + { + return $this->rest_list($from, $limit, $parameters); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Endpoints/WalletEndpoint.php b/vendor_manual/mollie/mollie-api-php/src/Endpoints/WalletEndpoint.php new file mode 100644 index 000000000..628aaebde --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Endpoints/WalletEndpoint.php @@ -0,0 +1,44 @@ +parseRequestBody(array_merge([ + 'domain' => $domain, + 'validationUrl' => $validationUrl, + ], $parameters)); + + $response = $this->client->performHttpCall( + self::REST_CREATE, + 'wallets/applepay/sessions', + $body + ); + + return json_encode($response); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Exceptions/ApiException.php b/vendor_manual/mollie/mollie-api-php/src/Exceptions/ApiException.php new file mode 100644 index 000000000..dc619db6e --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Exceptions/ApiException.php @@ -0,0 +1,244 @@ +plainMessage = $message; + + $this->raisedAt = new \DateTimeImmutable(); + + $formattedRaisedAt = $this->raisedAt->format(DateTime::ISO8601); + $message = "[{$formattedRaisedAt}] " . $message; + + if (! empty($field)) { + $this->field = (string)$field; + $message .= ". Field: {$this->field}"; + } + + if (! empty($response)) { + $this->response = $response; + + $object = static::parseResponseBody($this->response); + + if (isset($object->_links)) { + foreach ($object->_links as $key => $value) { + $this->links[$key] = $value; + } + } + } + + if ($this->hasLink('documentation')) { + $message .= ". Documentation: {$this->getDocumentationUrl()}"; + } + + $this->request = $request; + if ($request) { + $requestBody = $request->getBody()->__toString(); + + if ($requestBody) { + $message .= ". Request body: {$requestBody}"; + } + } + + parent::__construct($message, $code, $previous); + } + + /** + * @param \Psr\Http\Message\ResponseInterface $response + * @param \Psr\Http\Message\RequestInterface $request + * @param \Throwable|null $previous + * @return \Mollie\Api\Exceptions\ApiException + * @throws \Mollie\Api\Exceptions\ApiException + */ + public static function createFromResponse($response, $request = null, $previous = null) + { + $object = static::parseResponseBody($response); + + $field = null; + if (! empty($object->field)) { + $field = $object->field; + } + + return new self( + "Error executing API call ({$object->status}: {$object->title}): {$object->detail}", + $response->getStatusCode(), + $field, + $request, + $response, + $previous + ); + } + + /** + * @return string|null + */ + public function getField() + { + return $this->field; + } + + /** + * @return string|null + */ + public function getDocumentationUrl() + { + return $this->getUrl('documentation'); + } + + /** + * @return string|null + */ + public function getDashboardUrl() + { + return $this->getUrl('dashboard'); + } + + /** + * @return \Psr\Http\Message\ResponseInterface|null + */ + public function getResponse() + { + return $this->response; + } + + /** + * @return bool + */ + public function hasResponse() + { + return $this->response !== null; + } + + /** + * @param string $key + * @return bool + */ + public function hasLink($key) + { + return array_key_exists($key, $this->links); + } + + /** + * @param string $key + * @return mixed|null + */ + public function getLink($key) + { + if ($this->hasLink($key)) { + return $this->links[$key]; + } + + return null; + } + + /** + * @param string $key + * @return null + */ + public function getUrl($key) + { + if ($this->hasLink($key)) { + return $this->getLink($key)->href; + } + + return null; + } + + /** + * @return \Psr\Http\Message\RequestInterface + */ + public function getRequest() + { + return $this->request; + } + + /** + * Get the ISO8601 representation of the moment this exception was thrown + * + * @return \DateTimeImmutable + */ + public function getRaisedAt() + { + return $this->raisedAt; + } + + /** + * @param \Psr\Http\Message\ResponseInterface $response + * @return \stdClass + * @throws \Mollie\Api\Exceptions\ApiException + */ + protected static function parseResponseBody($response) + { + $body = (string) $response->getBody(); + + $object = @json_decode($body); + + if (json_last_error() !== JSON_ERROR_NONE) { + throw new self("Unable to decode Mollie response: '{$body}'."); + } + + return $object; + } + + /** + * Retrieve the plain exception message. + * + * @return string + */ + public function getPlainMessage() + { + return $this->plainMessage; + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Exceptions/CurlConnectTimeoutException.php b/vendor_manual/mollie/mollie-api-php/src/Exceptions/CurlConnectTimeoutException.php new file mode 100644 index 000000000..ab40ca1bc --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Exceptions/CurlConnectTimeoutException.php @@ -0,0 +1,7 @@ +attemptRequest($httpMethod, $url, $headers, $httpBody); + } catch (CurlConnectTimeoutException $e) { + // Nothing + } + } + + throw new CurlConnectTimeoutException( + "Unable to connect to Mollie. Maximum number of retries (". self::MAX_RETRIES .") reached." + ); + } + + /** + * @param string $httpMethod + * @param string $url + * @param array $headers + * @param string $httpBody + * @return \stdClass|void|null + * @throws \Mollie\Api\Exceptions\ApiException + */ + protected function attemptRequest($httpMethod, $url, $headers, $httpBody) + { + $curl = curl_init($url); + $headers["Content-Type"] = "application/json"; + + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_HTTPHEADER, $this->parseHeaders($headers)); + curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, self::DEFAULT_CONNECT_TIMEOUT); + curl_setopt($curl, CURLOPT_TIMEOUT, self::DEFAULT_TIMEOUT); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true); + curl_setopt($curl, CURLOPT_CAINFO, CaBundle::getBundledCaBundlePath()); + + switch ($httpMethod) { + case MollieApiClient::HTTP_POST: + curl_setopt($curl, CURLOPT_POST, true); + curl_setopt($curl, CURLOPT_POSTFIELDS, $httpBody); + + break; + case MollieApiClient::HTTP_GET: + break; + case MollieApiClient::HTTP_PATCH: + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PATCH'); + curl_setopt($curl, CURLOPT_POSTFIELDS, $httpBody); + + break; + case MollieApiClient::HTTP_DELETE: + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'DELETE'); + curl_setopt($curl, CURLOPT_POSTFIELDS, $httpBody); + + break; + default: + throw new \InvalidArgumentException("Invalid http method: ". $httpMethod); + } + + $startTime = microtime(true); + $response = curl_exec($curl); + $endTime = microtime(true); + + if ($response === false) { + $executionTime = $endTime - $startTime; + $curlErrorNumber = curl_errno($curl); + $curlErrorMessage = "Curl error: " . curl_error($curl); + + if ($this->isConnectTimeoutError($curlErrorNumber, $executionTime)) { + throw new CurlConnectTimeoutException("Unable to connect to Mollie. " . $curlErrorMessage); + } + + throw new ApiException($curlErrorMessage); + } + + $statusCode = curl_getinfo($curl, CURLINFO_RESPONSE_CODE); + curl_close($curl); + + return $this->parseResponseBody($response, $statusCode, $httpBody); + } + + /** + * The version number for the underlying http client, if available. + * @example Guzzle/6.3 + * + * @return string|null + */ + public function versionString() + { + return 'Curl/*'; + } + + /** + * Whether this http adapter provides a debugging mode. If debugging mode is enabled, the + * request will be included in the ApiException. + * + * @return false + */ + public function supportsDebugging() + { + return false; + } + + /** + * @param int $curlErrorNumber + * @param string|float $executionTime + * @return bool + */ + protected function isConnectTimeoutError($curlErrorNumber, $executionTime) + { + $connectErrors = [ + \CURLE_COULDNT_RESOLVE_HOST => true, + \CURLE_COULDNT_CONNECT => true, + \CURLE_SSL_CONNECT_ERROR => true, + \CURLE_GOT_NOTHING => true, + ]; + + if (isset($connectErrors[$curlErrorNumber])) { + return true; + }; + + if ($curlErrorNumber === \CURLE_OPERATION_TIMEOUTED) { + if ($executionTime > self::DEFAULT_TIMEOUT) { + return false; + } + + return true; + } + + return false; + } + + /** + * @param string $response + * @param int $statusCode + * @param string $httpBody + * @return \stdClass|null + * @throws \Mollie\Api\Exceptions\ApiException + */ + protected function parseResponseBody($response, $statusCode, $httpBody) + { + if (empty($response)) { + if ($statusCode === self::HTTP_NO_CONTENT) { + return null; + } + + throw new ApiException("No response body found."); + } + + $body = @json_decode($response); + + // GUARDS + if (json_last_error() !== JSON_ERROR_NONE) { + throw new ApiException("Unable to decode Mollie response: '{$response}'."); + } + + if (isset($body->error)) { + throw new ApiException($body->error->message); + } + + if ($statusCode >= 400) { + $message = "Error executing API call ({$body->status}: {$body->title}): {$body->detail}"; + + $field = null; + + if (! empty($body->field)) { + $field = $body->field; + } + + if (isset($body->_links, $body->_links->documentation)) { + $message .= ". Documentation: {$body->_links->documentation->href}"; + } + + if ($httpBody) { + $message .= ". Request body: {$httpBody}"; + } + + throw new ApiException($message, $statusCode, $field); + } + + return $body; + } + + protected function parseHeaders($headers) + { + $result = []; + + foreach ($headers as $key => $value) { + $result[] = $key .': ' . $value; + } + + return $result; + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/HttpAdapter/Guzzle6And7MollieHttpAdapter.php b/vendor_manual/mollie/mollie-api-php/src/HttpAdapter/Guzzle6And7MollieHttpAdapter.php new file mode 100644 index 000000000..a9e27cdb3 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/HttpAdapter/Guzzle6And7MollieHttpAdapter.php @@ -0,0 +1,198 @@ +httpClient = $httpClient; + } + + /** + * Instantiate a default adapter with sane configuration for Guzzle 6 or 7. + * + * @return static + */ + public static function createDefault() + { + $retryMiddlewareFactory = new Guzzle6And7RetryMiddlewareFactory; + $handlerStack = HandlerStack::create(); + $handlerStack->push($retryMiddlewareFactory->retry()); + + $client = new Client([ + GuzzleRequestOptions::VERIFY => CaBundle::getBundledCaBundlePath(), + GuzzleRequestOptions::TIMEOUT => self::DEFAULT_TIMEOUT, + GuzzleRequestOptions::CONNECT_TIMEOUT => self::DEFAULT_CONNECT_TIMEOUT, + 'handler' => $handlerStack, + ]); + + return new Guzzle6And7MollieHttpAdapter($client); + } + + /** + * Send a request to the specified Mollie api url. + * + * @param string $httpMethod + * @param string $url + * @param array $headers + * @param string $httpBody + * @return \stdClass|null + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function send($httpMethod, $url, $headers, $httpBody) + { + $request = new Request($httpMethod, $url, $headers, $httpBody); + + try { + $response = $this->httpClient->send($request, ['http_errors' => false]); + } catch (GuzzleException $e) { + // Prevent sensitive request data from ending up in exception logs unintended + if (! $this->debugging) { + $request = null; + } + + // Not all Guzzle Exceptions implement hasResponse() / getResponse() + if (method_exists($e, 'hasResponse') && method_exists($e, 'getResponse')) { + if ($e->hasResponse()) { + throw ApiException::createFromResponse($e->getResponse(), $request); + } + } + + throw new ApiException($e->getMessage(), $e->getCode(), null, $request, null); + } + + return $this->parseResponseBody($response); + } + + /** + * Whether this http adapter provides a debugging mode. If debugging mode is enabled, the + * request will be included in the ApiException. + * + * @return true + */ + public function supportsDebugging() + { + return true; + } + + /** + * Whether debugging is enabled. If debugging mode is enabled, the request will + * be included in the ApiException. By default, debugging is disabled to prevent + * sensitive request data from leaking into exception logs. + * + * @return bool + */ + public function debugging() + { + return $this->debugging; + } + + /** + * Enable debugging. If debugging mode is enabled, the request will + * be included in the ApiException. By default, debugging is disabled to prevent + * sensitive request data from leaking into exception logs. + */ + public function enableDebugging() + { + $this->debugging = true; + } + + /** + * Disable debugging. If debugging mode is enabled, the request will + * be included in the ApiException. By default, debugging is disabled to prevent + * sensitive request data from leaking into exception logs. + */ + public function disableDebugging() + { + $this->debugging = false; + } + + /** + * Parse the PSR-7 Response body + * + * @param ResponseInterface $response + * @return \stdClass|null + * @throws ApiException + */ + private function parseResponseBody(ResponseInterface $response) + { + $body = (string) $response->getBody(); + if (empty($body)) { + if ($response->getStatusCode() === self::HTTP_NO_CONTENT) { + return null; + } + + throw new ApiException("No response body found."); + } + + $object = @json_decode($body); + + if (json_last_error() !== JSON_ERROR_NONE) { + throw new ApiException("Unable to decode Mollie response: '{$body}'."); + } + + if ($response->getStatusCode() >= 400) { + throw ApiException::createFromResponse($response, null); + } + + return $object; + } + + /** + * The version number for the underlying http client, if available. This is used to report the UserAgent to Mollie, + * for convenient support. + * @example Guzzle/6.3 + * + * @return string|null + */ + public function versionString() + { + if (defined('\GuzzleHttp\ClientInterface::MAJOR_VERSION')) { // Guzzle 7 + return "Guzzle/" . ClientInterface::MAJOR_VERSION; + } elseif (defined('\GuzzleHttp\ClientInterface::VERSION')) { // Before Guzzle 7 + return "Guzzle/" . ClientInterface::VERSION; + } + + return null; + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/HttpAdapter/Guzzle6And7RetryMiddlewareFactory.php b/vendor_manual/mollie/mollie-api-php/src/HttpAdapter/Guzzle6And7RetryMiddlewareFactory.php new file mode 100644 index 000000000..b6d8cb73e --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/HttpAdapter/Guzzle6And7RetryMiddlewareFactory.php @@ -0,0 +1,83 @@ +newRetryDecider(), + $delay ? $this->getRetryDelay() : $this->getZeroRetryDelay() + ); + } + + /** + * Returns a method that takes the number of retries and returns the number of milliseconds + * to wait + * + * @return callable + */ + private function getRetryDelay() + { + return function ($numberOfRetries) { + return static::DELAY_INCREASE_MS * $numberOfRetries; + }; + } + + /** + * Returns a method that returns zero milliseconds to wait + * + * @return callable + */ + private function getZeroRetryDelay() + { + return function ($numberOfRetries) { + return 0; + }; + } + + /** + * @return callable + */ + private function newRetryDecider() + { + return function ( + $retries, + Request $request, + Response $response = null, + TransferException $exception = null + ) { + if ($retries >= static::MAX_RETRIES) { + return false; + } + + if ($exception instanceof ConnectException) { + return true; + } + + return false; + }; + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/HttpAdapter/MollieHttpAdapterInterface.php b/vendor_manual/mollie/mollie-api-php/src/HttpAdapter/MollieHttpAdapterInterface.php new file mode 100644 index 000000000..226bbef85 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/HttpAdapter/MollieHttpAdapterInterface.php @@ -0,0 +1,26 @@ +guzzleIsDetected()) { + $guzzleVersion = $this->guzzleMajorVersionNumber(); + + if ($guzzleVersion && in_array($guzzleVersion, [6, 7])) { + return Guzzle6And7MollieHttpAdapter::createDefault(); + } + } + + return new CurlMollieHttpAdapter; + } + + if ($httpClient instanceof MollieHttpAdapterInterface) { + return $httpClient; + } + + if ($httpClient instanceof \GuzzleHttp\ClientInterface) { + return new Guzzle6And7MollieHttpAdapter($httpClient); + } + + throw new UnrecognizedClientException('The provided http client or adapter was not recognized.'); + } + + /** + * @return bool + */ + private function guzzleIsDetected() + { + return interface_exists('\\' . \GuzzleHttp\ClientInterface::class); + } + + /** + * @return int|null + */ + private function guzzleMajorVersionNumber() + { + // Guzzle 7 + if (defined('\GuzzleHttp\ClientInterface::MAJOR_VERSION')) { + return (int) \GuzzleHttp\ClientInterface::MAJOR_VERSION; + } + + // Before Guzzle 7 + if (defined('\GuzzleHttp\ClientInterface::VERSION')) { + return (int) \GuzzleHttp\ClientInterface::VERSION[0]; + } + + return null; + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/HttpAdapter/MollieHttpAdapterPickerInterface.php b/vendor_manual/mollie/mollie-api-php/src/HttpAdapter/MollieHttpAdapterPickerInterface.php new file mode 100644 index 000000000..b91542d61 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/HttpAdapter/MollieHttpAdapterPickerInterface.php @@ -0,0 +1,13 @@ +length = $length; + } + + /** + * @throws \Mollie\Api\Exceptions\IncompatiblePlatform + * @return string + */ + public function generate() + { + $length = $this->length; + + $string = ''; + + while (($len = strlen($string)) < $length) { + $size = $length - $len; + + try { + $bytes = random_bytes($size); + } catch (\Exception $e) { + throw new IncompatiblePlatform( + 'PHP function random_bytes missing. Consider overriding the DefaultIdempotencyKeyGenerator with your own.', + IncompatiblePlatform::INCOMPATIBLE_RANDOM_BYTES_FUNCTION + ); + } + + $string .= substr(str_replace(['/', '+', '='], '', base64_encode($bytes)), 0, $size); + } + + return $string; + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Idempotency/FakeIdempotencyKeyGenerator.php b/vendor_manual/mollie/mollie-api-php/src/Idempotency/FakeIdempotencyKeyGenerator.php new file mode 100644 index 000000000..95871939f --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Idempotency/FakeIdempotencyKeyGenerator.php @@ -0,0 +1,21 @@ +fakeKey = $fakeKey; + } + + public function generate() + { + return $this->fakeKey; + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Idempotency/IdempotencyKeyGeneratorContract.php b/vendor_manual/mollie/mollie-api-php/src/Idempotency/IdempotencyKeyGeneratorContract.php new file mode 100644 index 000000000..6ffe80ca6 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Idempotency/IdempotencyKeyGeneratorContract.php @@ -0,0 +1,7 @@ +httpClient = $httpAdapterPicker->pickHttpAdapter($httpClient); + + $compatibilityChecker = new CompatibilityChecker; + $compatibilityChecker->checkCompatibility(); + + $this->initializeEndpoints(); + $this->initializeVersionStrings(); + $this->initializeIdempotencyKeyGenerator($idempotencyKeyGenerator); + } + + public function initializeEndpoints() + { + $this->payments = new PaymentEndpoint($this); + $this->methods = new MethodEndpoint($this); + $this->profileMethods = new ProfileMethodEndpoint($this); + $this->customers = new CustomerEndpoint($this); + $this->settlements = new SettlementsEndpoint($this); + $this->settlementPayments = new SettlementPaymentEndpoint($this); + $this->subscriptions = new SubscriptionEndpoint($this); + $this->customerPayments = new CustomerPaymentsEndpoint($this); + $this->mandates = new MandateEndpoint($this); + $this->balances = new BalanceEndpoint($this); + $this->balanceTransactions = new BalanceTransactionEndpoint($this); + $this->balanceReports = new BalanceReportEndpoint($this); + $this->invoices = new InvoiceEndpoint($this); + $this->permissions = new PermissionEndpoint($this); + $this->profiles = new ProfileEndpoint($this); + $this->onboarding = new OnboardingEndpoint($this); + $this->organizations = new OrganizationEndpoint($this); + $this->orders = new OrderEndpoint($this); + $this->orderLines = new OrderLineEndpoint($this); + $this->orderPayments = new OrderPaymentEndpoint($this); + $this->orderRefunds = new OrderRefundEndpoint($this); + $this->shipments = new ShipmentEndpoint($this); + $this->refunds = new RefundEndpoint($this); + $this->paymentRefunds = new PaymentRefundEndpoint($this); + $this->paymentCaptures = new PaymentCaptureEndpoint($this); + $this->paymentRoutes = new PaymentRouteEndpoint($this); + $this->chargebacks = new ChargebackEndpoint($this); + $this->paymentChargebacks = new PaymentChargebackEndpoint($this); + $this->wallets = new WalletEndpoint($this); + $this->paymentLinks = new PaymentLinkEndpoint($this); + $this->terminals = new TerminalEndpoint($this); + $this->organizationPartners = new OrganizationPartnerEndpoint($this); + $this->clients = new ClientEndpoint($this); + $this->clientLinks = new ClientLinkEndpoint($this); + } + + protected function initializeVersionStrings() + { + $this->addVersionString("Mollie/" . self::CLIENT_VERSION); + $this->addVersionString("PHP/" . phpversion()); + + $httpClientVersionString = $this->httpClient->versionString(); + if ($httpClientVersionString) { + $this->addVersionString($httpClientVersionString); + } + } + + /** + * @param \Mollie\Api\Idempotency\IdempotencyKeyGeneratorContract $generator + * @return void + */ + protected function initializeIdempotencyKeyGenerator($generator) + { + $this->idempotencyKeyGenerator = $generator ? $generator : new DefaultIdempotencyKeyGenerator; + } + + /** + * @param string $url + * + * @return MollieApiClient + */ + public function setApiEndpoint($url) + { + $this->apiEndpoint = rtrim(trim($url), '/'); + + return $this; + } + + /** + * @return string + */ + public function getApiEndpoint() + { + return $this->apiEndpoint; + } + + /** + * @return array + */ + public function getVersionStrings() + { + return $this->versionStrings; + } + + /** + * @param string $apiKey The Mollie API key, starting with 'test_' or 'live_' + * + * @return MollieApiClient + * @throws ApiException + */ + public function setApiKey($apiKey) + { + $apiKey = trim($apiKey); + + if (! preg_match('/^(live|test)_\w{30,}$/', $apiKey)) { + throw new ApiException("Invalid API key: '{$apiKey}'. An API key must start with 'test_' or 'live_' and must be at least 30 characters long."); + } + + $this->apiKey = $apiKey; + $this->oauthAccess = false; + + return $this; + } + + /** + * @param string $accessToken OAuth access token, starting with 'access_' + * + * @return MollieApiClient + * @throws ApiException + */ + public function setAccessToken($accessToken) + { + $accessToken = trim($accessToken); + + if (! preg_match('/^access_\w+$/', $accessToken)) { + throw new ApiException("Invalid OAuth access token: '{$accessToken}'. An access token must start with 'access_'."); + } + + $this->apiKey = $accessToken; + $this->oauthAccess = true; + + return $this; + } + + /** + * Returns null if no API key has been set yet. + * + * @return bool|null + */ + public function usesOAuth() + { + return $this->oauthAccess; + } + + /** + * @param string $versionString + * + * @return MollieApiClient + */ + public function addVersionString($versionString) + { + $this->versionStrings[] = str_replace([" ", "\t", "\n", "\r"], '-', $versionString); + + return $this; + } + + /** + * Enable debugging mode. If debugging mode is enabled, the attempted request will be included in the ApiException. + * By default, debugging is disabled to prevent leaking sensitive request data into exception logs. + * + * @throws \Mollie\Api\Exceptions\HttpAdapterDoesNotSupportDebuggingException + */ + public function enableDebugging() + { + if ( + ! method_exists($this->httpClient, 'supportsDebugging') + || ! $this->httpClient->supportsDebugging() + ) { + throw new HttpAdapterDoesNotSupportDebuggingException( + "Debugging is not supported by " . get_class($this->httpClient) . "." + ); + } + + $this->httpClient->enableDebugging(); + } + + /** + * Disable debugging mode. If debugging mode is enabled, the attempted request will be included in the ApiException. + * By default, debugging is disabled to prevent leaking sensitive request data into exception logs. + * + * @throws \Mollie\Api\Exceptions\HttpAdapterDoesNotSupportDebuggingException + */ + public function disableDebugging() + { + if ( + ! method_exists($this->httpClient, 'supportsDebugging') + || ! $this->httpClient->supportsDebugging() + ) { + throw new HttpAdapterDoesNotSupportDebuggingException( + "Debugging is not supported by " . get_class($this->httpClient) . "." + ); + } + + $this->httpClient->disableDebugging(); + } + + /** + * Set the idempotency key used on the next request. The idempotency key is a unique string ensuring a request to a + * mutating Mollie endpoint is processed only once. The idempotency key resets to null after each request. Using + * the setIdempotencyKey method supersedes the IdempotencyKeyGenerator. + * + * @param $key + * @return $this + */ + public function setIdempotencyKey($key) + { + $this->idempotencyKey = $key; + + return $this; + } + + /** + * Retrieve the idempotency key. The idempotency key is a unique string ensuring a request to a + * mutating Mollie endpoint is processed only once. Note that the idempotency key gets reset to null after each + * request. + * + * @return string|null + */ + public function getIdempotencyKey() + { + return $this->idempotencyKey; + } + + /** + * Reset the idempotency key. Note that the idempotency key automatically resets to null after each request. + * @return $this + */ + public function resetIdempotencyKey() + { + $this->idempotencyKey = null; + + return $this; + } + + /** + * @param \Mollie\Api\Idempotency\IdempotencyKeyGeneratorContract $generator + * @return \Mollie\Api\MollieApiClient + */ + public function setIdempotencyKeyGenerator($generator) + { + $this->idempotencyKeyGenerator = $generator; + + return $this; + } + + /** + * @return \Mollie\Api\MollieApiClient + */ + public function clearIdempotencyKeyGenerator() + { + $this->idempotencyKeyGenerator = null; + + return $this; + } + + /** + * Perform a http call. This method is used by the resource specific classes. Please use the $payments property to + * perform operations on payments. + * + * @param string $httpMethod + * @param string $apiMethod + * @param string|null $httpBody + * + * @return \stdClass + * @throws ApiException + * + * @codeCoverageIgnore + */ + public function performHttpCall($httpMethod, $apiMethod, $httpBody = null) + { + $url = $this->apiEndpoint . "/" . self::API_VERSION . "/" . $apiMethod; + + return $this->performHttpCallToFullUrl($httpMethod, $url, $httpBody); + } + + /** + * Perform a http call to a full url. This method is used by the resource specific classes. + * + * @see $payments + * @see $isuers + * + * @param string $httpMethod + * @param string $url + * @param string|null $httpBody + * + * @return \stdClass|null + * @throws ApiException + * + * @codeCoverageIgnore + */ + public function performHttpCallToFullUrl($httpMethod, $url, $httpBody = null) + { + if (empty($this->apiKey)) { + throw new ApiException("You have not set an API key or OAuth access token. Please use setApiKey() to set the API key."); + } + + $userAgent = implode(' ', $this->versionStrings); + + if ($this->usesOAuth()) { + $userAgent .= " OAuth/2.0"; + } + + $headers = [ + 'Accept' => "application/json", + 'Authorization' => "Bearer {$this->apiKey}", + 'User-Agent' => $userAgent, + ]; + + if ($httpBody !== null) { + $headers['Content-Type'] = "application/json"; + } + + if (function_exists("php_uname")) { + $headers['X-Mollie-Client-Info'] = php_uname(); + } + + $headers = $this->applyIdempotencyKey($headers, $httpMethod); + + $response = $this->httpClient->send($httpMethod, $url, $headers, $httpBody); + + $this->resetIdempotencyKey(); + + return $response; + } + + /** + * Conditionally apply the idempotency key to the request headers + * + * @param array $headers + * @param string $httpMethod + * @return array + */ + private function applyIdempotencyKey(array $headers, string $httpMethod) + { + if (! in_array($httpMethod, [self::HTTP_POST, self::HTTP_PATCH, self::HTTP_DELETE])) { + unset($headers['Idempotency-Key']); + + return $headers; + } + + if ($this->idempotencyKey) { + $headers['Idempotency-Key'] = $this->idempotencyKey; + + return $headers; + } + + if ($this->idempotencyKeyGenerator) { + $headers['Idempotency-Key'] = $this->idempotencyKeyGenerator->generate(); + + return $headers; + } + + unset($headers['Idempotency-Key']); + + return $headers; + } + + /** + * Serialization can be used for caching. Of course doing so can be dangerous but some like to live dangerously. + * + * \serialize() should be called on the collections or object you want to cache. + * + * We don't need any property that can be set by the constructor, only properties that are set by setters. + * + * Note that the API key is not serialized, so you need to set the key again after unserializing if you want to do + * more API calls. + * + * @deprecated + * @return string[] + */ + public function __sleep() + { + return ["apiEndpoint"]; + } + + /** + * When unserializing a collection or a resource, this class should restore itself. + * + * Note that if you have set an HttpAdapter, this adapter is lost on wakeup and reset to the default one. + * + * @throws IncompatiblePlatform If suddenly unserialized on an incompatible platform. + */ + public function __wakeup() + { + $this->__construct(); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/Balance.php b/vendor_manual/mollie/mollie-api-php/src/Resources/Balance.php new file mode 100644 index 000000000..c84ad5678 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/Balance.php @@ -0,0 +1,114 @@ +client); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/BalanceReport.php b/vendor_manual/mollie/mollie-api-php/src/Resources/BalanceReport.php new file mode 100644 index 000000000..96479f742 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/BalanceReport.php @@ -0,0 +1,80 @@ +client); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/BaseCollection.php b/vendor_manual/mollie/mollie-api-php/src/Resources/BaseCollection.php new file mode 100644 index 000000000..fd43b87a6 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/BaseCollection.php @@ -0,0 +1,34 @@ +count = $count; + $this->_links = $_links; + parent::__construct(); + } + + /** + * @return string|null + */ + abstract public function getCollectionResourceName(); +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/BaseResource.php b/vendor_manual/mollie/mollie-api-php/src/Resources/BaseResource.php new file mode 100644 index 000000000..d5762ccfd --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/BaseResource.php @@ -0,0 +1,31 @@ +client = $client; + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/Capture.php b/vendor_manual/mollie/mollie-api-php/src/Resources/Capture.php new file mode 100644 index 000000000..2fc7c4e5e --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/Capture.php @@ -0,0 +1,71 @@ +client); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/Chargeback.php b/vendor_manual/mollie/mollie-api-php/src/Resources/Chargeback.php new file mode 100644 index 000000000..d55b6da09 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/Chargeback.php @@ -0,0 +1,75 @@ +client); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/Client.php b/vendor_manual/mollie/mollie-api-php/src/Resources/Client.php new file mode 100644 index 000000000..ed226421b --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/Client.php @@ -0,0 +1,36 @@ +client); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/ClientLink.php b/vendor_manual/mollie/mollie-api-php/src/Resources/ClientLink.php new file mode 100644 index 000000000..36ac0b7a3 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/ClientLink.php @@ -0,0 +1,49 @@ + $client_id, + 'state' => $state, + 'approval_prompt' => $approval_prompt, + 'scope' => implode(' ', $scopes), + ], '', '&', PHP_QUERY_RFC3986); + + return "{$this->_links->clientLink->href}?{$query}"; + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/CurrentProfile.php b/vendor_manual/mollie/mollie-api-php/src/Resources/CurrentProfile.php new file mode 100644 index 000000000..b351fa92e --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/CurrentProfile.php @@ -0,0 +1,34 @@ +client->profileMethods->createForCurrentProfile($methodId, $data); + } + + /** + * Disable a payment method for this profile. + * + * @param string $methodId + * @param array $data + * @return Method + * @throws ApiException + */ + public function disableMethod($methodId, array $data = []) + { + return $this->client->profileMethods->deleteForCurrentProfile($methodId, $data); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/CursorCollection.php b/vendor_manual/mollie/mollie-api-php/src/Resources/CursorCollection.php new file mode 100644 index 000000000..e32653351 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/CursorCollection.php @@ -0,0 +1,96 @@ +client = $client; + } + + /** + * @return BaseResource + */ + abstract protected function createResourceObject(); + + /** + * Return the next set of resources when available + * + * @return CursorCollection|null + * @throws \Mollie\Api\Exceptions\ApiException + */ + final public function next() + { + if (! $this->hasNext()) { + return null; + } + + $result = $this->client->performHttpCallToFullUrl(MollieApiClient::HTTP_GET, $this->_links->next->href); + + $collection = new static($this->client, $result->count, $result->_links); + + foreach ($result->_embedded->{$collection->getCollectionResourceName()} as $dataResult) { + $collection[] = ResourceFactory::createFromApiResult($dataResult, $this->createResourceObject()); + } + + return $collection; + } + + /** + * Return the previous set of resources when available + * + * @return CursorCollection|null + * @throws \Mollie\Api\Exceptions\ApiException + */ + final public function previous() + { + if (! $this->hasPrevious()) { + return null; + } + + $result = $this->client->performHttpCallToFullUrl(MollieApiClient::HTTP_GET, $this->_links->previous->href); + + $collection = new static($this->client, $result->count, $result->_links); + + foreach ($result->_embedded->{$collection->getCollectionResourceName()} as $dataResult) { + $collection[] = ResourceFactory::createFromApiResult($dataResult, $this->createResourceObject()); + } + + return $collection; + } + + /** + * Determine whether the collection has a next page available. + * + * @return bool + */ + public function hasNext() + { + return isset($this->_links->next->href); + } + + /** + * Determine whether the collection has a previous page available. + * + * @return bool + */ + public function hasPrevious() + { + return isset($this->_links->previous->href); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/Customer.php b/vendor_manual/mollie/mollie-api-php/src/Resources/Customer.php new file mode 100644 index 000000000..98fc7443d --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/Customer.php @@ -0,0 +1,250 @@ + $this->name, + "email" => $this->email, + "locale" => $this->locale, + "metadata" => $this->metadata, + ]; + + $result = $this->client->customers->update($this->id, $body); + + return ResourceFactory::createFromApiResult($result, new Customer($this->client)); + } + + /** + * @param array $options + * @param array $filters + * + * @return Payment + * @throws ApiException + */ + public function createPayment(array $options = [], array $filters = []) + { + return $this->client->customerPayments->createFor($this, $this->withPresetOptions($options), $filters); + } + + /** + * Get all payments for this customer + * + * @return PaymentCollection + * @throws ApiException + */ + public function payments() + { + return $this->client->customerPayments->listFor($this, null, null, $this->getPresetOptions()); + } + + /** + * @param array $options + * @param array $filters + * + * @return Subscription + * @throws ApiException + */ + public function createSubscription(array $options = [], array $filters = []) + { + return $this->client->subscriptions->createFor($this, $this->withPresetOptions($options), $filters); + } + + /** + * @param string $subscriptionId + * @param array $parameters + * + * @return Subscription + * @throws ApiException + */ + public function getSubscription($subscriptionId, array $parameters = []) + { + return $this->client->subscriptions->getFor($this, $subscriptionId, $this->withPresetOptions($parameters)); + } + + /** + * @param string $subscriptionId + * + * @return null + * @throws ApiException + */ + public function cancelSubscription($subscriptionId) + { + return $this->client->subscriptions->cancelFor($this, $subscriptionId, $this->getPresetOptions()); + } + + /** + * Get all subscriptions for this customer + * + * @return SubscriptionCollection + * @throws ApiException + */ + public function subscriptions() + { + return $this->client->subscriptions->listFor($this, null, null, $this->getPresetOptions()); + } + + /** + * @param array $options + * @param array $filters + * + * @return Mandate + * @throws ApiException + */ + public function createMandate(array $options = [], array $filters = []) + { + return $this->client->mandates->createFor($this, $this->withPresetOptions($options), $filters); + } + + /** + * @param string $mandateId + * @param array $parameters + * + * @return Mandate + * @throws ApiException + */ + public function getMandate($mandateId, array $parameters = []) + { + return $this->client->mandates->getFor($this, $mandateId, $parameters); + } + + /** + * @param string $mandateId + * + * @return null + * @throws ApiException + */ + public function revokeMandate($mandateId) + { + return $this->client->mandates->revokeFor($this, $mandateId, $this->getPresetOptions()); + } + + /** + * Get all mandates for this customer + * + * @return MandateCollection + * @throws ApiException + */ + public function mandates() + { + return $this->client->mandates->listFor($this, null, null, $this->getPresetOptions()); + } + + /** + * Helper function to check for mandate with status valid + * + * @return bool + */ + public function hasValidMandate() + { + $mandates = $this->mandates(); + foreach ($mandates as $mandate) { + if ($mandate->isValid()) { + return true; + } + } + + return false; + } + + /** + * Helper function to check for specific payment method mandate with status valid + * + * @return bool + */ + public function hasValidMandateForMethod($method) + { + $mandates = $this->mandates(); + foreach ($mandates as $mandate) { + if ($mandate->method === $method && $mandate->isValid()) { + return true; + } + } + + return false; + } + + /** + * When accessed by oAuth we want to pass the testmode by default + * + * @return array + */ + private function getPresetOptions() + { + $options = []; + if ($this->client->usesOAuth()) { + $options["testmode"] = $this->mode === "test" ? true : false; + } + + return $options; + } + + /** + * Apply the preset options. + * + * @param array $options + * @return array + */ + private function withPresetOptions(array $options) + { + return array_merge($this->getPresetOptions(), $options); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/CustomerCollection.php b/vendor_manual/mollie/mollie-api-php/src/Resources/CustomerCollection.php new file mode 100644 index 000000000..deece5770 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/CustomerCollection.php @@ -0,0 +1,22 @@ +client); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/Invoice.php b/vendor_manual/mollie/mollie-api-php/src/Resources/Invoice.php new file mode 100644 index 000000000..70b86e775 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/Invoice.php @@ -0,0 +1,109 @@ +status == InvoiceStatus::STATUS_PAID; + } + + /** + * @return bool + */ + public function isOpen() + { + return $this->status == InvoiceStatus::STATUS_OPEN; + } + + /** + * @return bool + */ + public function isOverdue() + { + return $this->status == InvoiceStatus::STATUS_OVERDUE; + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/InvoiceCollection.php b/vendor_manual/mollie/mollie-api-php/src/Resources/InvoiceCollection.php new file mode 100644 index 000000000..3278dd082 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/InvoiceCollection.php @@ -0,0 +1,22 @@ +client); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/Issuer.php b/vendor_manual/mollie/mollie-api-php/src/Resources/Issuer.php new file mode 100644 index 000000000..357238c81 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/Issuer.php @@ -0,0 +1,35 @@ +status === MandateStatus::STATUS_VALID; + } + + /** + * @return bool + */ + public function isPending() + { + return $this->status === MandateStatus::STATUS_PENDING; + } + + /** + * @return bool + */ + public function isInvalid() + { + return $this->status === MandateStatus::STATUS_INVALID; + } + + /** + * Revoke the mandate + * + * @return null|\stdClass|\Mollie\Api\Resources\Mandate + */ + public function revoke() + { + if (! isset($this->_links->self->href)) { + return $this; + } + + $body = null; + if ($this->client->usesOAuth()) { + $body = json_encode([ + "testmode" => $this->mode === "test" ? true : false, + ]); + } + + $result = $this->client->performHttpCallToFullUrl( + MollieApiClient::HTTP_DELETE, + $this->_links->self->href, + $body + ); + + return $result; + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/MandateCollection.php b/vendor_manual/mollie/mollie-api-php/src/Resources/MandateCollection.php new file mode 100644 index 000000000..23d39d16c --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/MandateCollection.php @@ -0,0 +1,40 @@ +client); + } + + /** + * @param string $status + * @return array|\Mollie\Api\Resources\MandateCollection + */ + public function whereStatus($status) + { + $collection = new self($this->client, 0, $this->_links); + + foreach ($this as $item) { + if ($item->status === $status) { + $collection[] = $item; + $collection->count++; + } + } + + return $collection; + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/Method.php b/vendor_manual/mollie/mollie-api-php/src/Resources/Method.php new file mode 100644 index 000000000..fac587437 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/Method.php @@ -0,0 +1,100 @@ +size1x and $image->size2x to display the payment method logo. + * + * @var \stdClass + */ + public $image; + + /** + * The issuers available for this payment method. Only for the methods iDEAL, KBC/CBC and gift cards. + * Will only be filled when explicitly requested using the query string `include` parameter. + * + * @var array|object[] + */ + public $issuers; + + /** + * The pricing for this payment method. Will only be filled when explicitly requested using the query string + * `include` parameter. + * + * @var array|object[] + */ + public $pricing; + + /** + * The activation status the method is in. + * If the method has status "null", this value will be returned as a null value, not as a string. + * + * @var string | null + */ + public $status; + + /** + * @var \stdClass + */ + public $_links; + + /** + * Get the issuer value objects + * + * @return IssuerCollection + */ + public function issuers() + { + return ResourceFactory::createBaseResourceCollection( + $this->client, + Issuer::class, + $this->issuers + ); + } + + /** + * Get the method price value objects. + * + * @return MethodPriceCollection + */ + public function pricing() + { + return ResourceFactory::createBaseResourceCollection( + $this->client, + MethodPrice::class, + $this->pricing + ); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/MethodCollection.php b/vendor_manual/mollie/mollie-api-php/src/Resources/MethodCollection.php new file mode 100644 index 000000000..a1f204109 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/MethodCollection.php @@ -0,0 +1,14 @@ +status === OnboardingStatus::NEEDS_DATA; + } + + /** + * @return bool + */ + public function isInReview() + { + return $this->status === OnboardingStatus::IN_REVIEW; + } + + /** + * @return bool + */ + public function isCompleted() + { + return $this->status === OnboardingStatus::COMPLETED; + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/Order.php b/vendor_manual/mollie/mollie-api-php/src/Resources/Order.php new file mode 100644 index 000000000..349a2c3df --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/Order.php @@ -0,0 +1,570 @@ +status === OrderStatus::STATUS_CREATED; + } + + /** + * Is this order paid for? + * + * @return bool + */ + public function isPaid() + { + return $this->status === OrderStatus::STATUS_PAID; + } + + /** + * Is this order authorized? + * + * @return bool + */ + public function isAuthorized() + { + return $this->status === OrderStatus::STATUS_AUTHORIZED; + } + + /** + * Is this order canceled? + * + * @return bool + */ + public function isCanceled() + { + return $this->status === OrderStatus::STATUS_CANCELED; + } + + /** + * (Deprecated) Is this order refunded? + * @deprecated 2018-11-27 + * + * @return bool + */ + public function isRefunded() + { + return $this->status === OrderStatus::STATUS_REFUNDED; + } + + /** + * Is this order shipping? + * + * @return bool + */ + public function isShipping() + { + return $this->status === OrderStatus::STATUS_SHIPPING; + } + + /** + * Is this order completed? + * + * @return bool + */ + public function isCompleted() + { + return $this->status === OrderStatus::STATUS_COMPLETED; + } + + /** + * Is this order expired? + * + * @return bool + */ + public function isExpired() + { + return $this->status === OrderStatus::STATUS_EXPIRED; + } + + /** + * Is this order completed? + * + * @return bool + */ + public function isPending() + { + return $this->status === OrderStatus::STATUS_PENDING; + } + + /** + * Cancels this order. + * If the order was partially shipped, the status will be "completed" instead of + * "canceled". + * Will throw a ApiException if the order id is invalid or the resource cannot + * be found. + * + * @return Order + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function cancel() + { + return $this->client->orders->cancel($this->id, $this->getPresetOptions()); + } + + /** + * Cancel a line for this order. + * The data array must contain a lines array. + * You can pass an empty lines array if you want to cancel all eligible lines. + * Returns null if successful. + * + * @param array $data + * @return null + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function cancelLines(array $data) + { + return $this->client->orderLines->cancelFor($this, $data); + } + + /** + * Cancels all eligible lines for this order. + * Returns null if successful. + * + * @param array|null $data + * @return null + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function cancelAllLines($data = []) + { + $data['lines'] = []; + + return $this->client->orderLines->cancelFor($this, $data); + } + + /** + * Get the line value objects + * + * @return OrderLineCollection + */ + public function lines() + { + return ResourceFactory::createBaseResourceCollection( + $this->client, + OrderLine::class, + $this->lines + ); + } + + /** + * Create a shipment for some order lines. You can provide an empty array for the + * "lines" option to include all unshipped lines for this order. + * + * @param array $options + * + * @return Shipment + * @throws ApiException + */ + public function createShipment(array $options = []) + { + return $this->client->shipments->createFor($this, $this->withPresetOptions($options)); + } + + /** + * Create a shipment for all unshipped order lines. + * + * @param array $options + * + * @return Shipment + */ + public function shipAll(array $options = []) + { + $options['lines'] = []; + + return $this->createShipment($options); + } + + /** + * Retrieve a specific shipment for this order. + * + * @param string $shipmentId + * @param array $parameters + * + * @return Shipment + * @throws ApiException + */ + public function getShipment($shipmentId, array $parameters = []) + { + return $this->client->shipments->getFor($this, $shipmentId, $this->withPresetOptions($parameters)); + } + + /** + * Get all shipments for this order. + * + * @param array $parameters + * + * @return ShipmentCollection + * @throws ApiException + */ + public function shipments(array $parameters = []) + { + return $this->client->shipments->listFor($this, $this->withPresetOptions($parameters)); + } + + /** + * Get the checkout URL where the customer can complete the payment. + * + * @return string|null + */ + public function getCheckoutUrl() + { + if (empty($this->_links->checkout)) { + return null; + } + + return $this->_links->checkout->href; + } + + /** + * Refund specific order lines. + * + * @param array $data + * @return Refund + * @throws ApiException + */ + public function refund(array $data) + { + return $this->client->orderRefunds->createFor($this, $this->withPresetOptions($data)); + } + + /** + * Refund all eligible order lines. + * + * @param array $data + * @return Refund + */ + public function refundAll(array $data = []) + { + $data['lines'] = []; + + return $this->refund($data); + } + + /** + * Retrieves all refunds associated with this order + * + * @return RefundCollection + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function refunds() + { + 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 + ); + } + + /** + * Saves the order's updated billingAddress and/or shippingAddress. + * + * @return \Mollie\Api\Resources\Order + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function update() + { + $body = [ + "billingAddress" => $this->billingAddress, + "shippingAddress" => $this->shippingAddress, + "orderNumber" => $this->orderNumber, + "redirectUrl" => $this->redirectUrl, + "cancelUrl" => $this->cancelUrl, + "webhookUrl" => $this->webhookUrl, + ]; + + $result = $this->client->orders->update($this->id, $body); + + return ResourceFactory::createFromApiResult($result, new Order($this->client)); + } + + /** + * Create a new payment for this Order. + * + * @param array $data + * @param array $filters + * @return \Mollie\Api\Resources\Payment + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function createPayment($data, $filters = []) + { + return $this->client->orderPayments->createFor($this, $data, $filters); + } + + /** + * Retrieve the payments for this order. + * Requires the order to be retrieved using the embed payments parameter. + * + * @return null|\Mollie\Api\Resources\PaymentCollection + */ + public function payments() + { + if (! isset($this->_embedded, $this->_embedded->payments)) { + return null; + } + + return ResourceFactory::createCursorResourceCollection( + $this->client, + $this->_embedded->payments, + Payment::class + ); + } + + /** + * When accessed by oAuth we want to pass the testmode by default + * + * @return array + */ + private function getPresetOptions() + { + $options = []; + if ($this->client->usesOAuth()) { + $options["testmode"] = $this->mode === "test" ? true : false; + } + + return $options; + } + + /** + * Apply the preset options. + * + * @param array $options + * @return array + */ + private function withPresetOptions(array $options) + { + return array_merge($this->getPresetOptions(), $options); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/OrderCollection.php b/vendor_manual/mollie/mollie-api-php/src/Resources/OrderCollection.php new file mode 100644 index 000000000..ff5fad80c --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/OrderCollection.php @@ -0,0 +1,22 @@ +client); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/OrderLine.php b/vendor_manual/mollie/mollie-api-php/src/Resources/OrderLine.php new file mode 100644 index 000000000..aa700feb2 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/OrderLine.php @@ -0,0 +1,420 @@ +_links->productUrl)) { + return null; + } + + return $this->_links->productUrl; + } + + /** + * Get the image URL of the product sold. + * + * @return string|null + */ + public function getImageUrl() + { + if (empty($this->_links->imageUrl)) { + return null; + } + + return $this->_links->imageUrl; + } + + /** + * Is this order line created? + * + * @return bool + */ + public function isCreated() + { + return $this->status === OrderLineStatus::STATUS_CREATED; + } + + /** + * Is this order line paid for? + * + * @return bool + */ + public function isPaid() + { + return $this->status === OrderLineStatus::STATUS_PAID; + } + + /** + * Is this order line authorized? + * + * @return bool + */ + public function isAuthorized() + { + return $this->status === OrderLineStatus::STATUS_AUTHORIZED; + } + + /** + * Is this order line canceled? + * + * @return bool + */ + public function isCanceled() + { + return $this->status === OrderLineStatus::STATUS_CANCELED; + } + + /** + * (Deprecated) Is this order line refunded? + * @deprecated 2018-11-27 + * + * @return bool + */ + public function isRefunded() + { + return $this->status === OrderLineStatus::STATUS_REFUNDED; + } + + /** + * Is this order line shipping? + * + * @return bool + */ + public function isShipping() + { + return $this->status === OrderLineStatus::STATUS_SHIPPING; + } + + /** + * Is this order line completed? + * + * @return bool + */ + public function isCompleted() + { + return $this->status === OrderLineStatus::STATUS_COMPLETED; + } + + /** + * Is this order line for a physical product? + * + * @return bool + */ + public function isPhysical() + { + return $this->type === OrderLineType::TYPE_PHYSICAL; + } + + /** + * Is this order line for applying a discount? + * + * @return bool + */ + public function isDiscount() + { + return $this->type === OrderLineType::TYPE_DISCOUNT; + } + + /** + * Is this order line for a digital product? + * + * @return bool + */ + public function isDigital() + { + return $this->type === OrderLineType::TYPE_DIGITAL; + } + + /** + * Is this order line for applying a shipping fee? + * + * @return bool + */ + public function isShippingFee() + { + return $this->type === OrderLineType::TYPE_SHIPPING_FEE; + } + + /** + * Is this order line for store credit? + * + * @return bool + */ + public function isStoreCredit() + { + return $this->type === OrderLineType::TYPE_STORE_CREDIT; + } + + /** + * Is this order line for a gift card? + * + * @return bool + */ + public function isGiftCard() + { + return $this->type === OrderLineType::TYPE_GIFT_CARD; + } + + /** + * Is this order line for a surcharge? + * + * @return bool + */ + public function isSurcharge() + { + return $this->type === OrderLineType::TYPE_SURCHARGE; + } + + /** + * Update an orderline by supplying one or more parameters in the data array + * + * @return BaseResource + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function update() + { + $result = $this->client->orderLines->update($this->orderId, $this->id, $this->getUpdateData()); + + return ResourceFactory::createFromApiResult($result, new Order($this->client)); + } + + /** + * Get sanitized array of order line data + * + * @return array + */ + public function getUpdateData() + { + $data = [ + "name" => $this->name, + 'imageUrl' => $this->imageUrl, + 'productUrl' => $this->productUrl, + 'metadata' => $this->metadata, + 'sku' => $this->sku, + 'quantity' => $this->quantity, + 'unitPrice' => $this->unitPrice, + 'discountAmount' => $this->discountAmount, + 'totalAmount' => $this->totalAmount, + 'vatAmount' => $this->vatAmount, + 'vatRate' => $this->vatRate, + ]; + + // Explicitly filter only NULL values to keep "vatRate => 0" intact + return array_filter($data, function ($value) { + return $value !== null; + }); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/OrderLineCollection.php b/vendor_manual/mollie/mollie-api-php/src/Resources/OrderLineCollection.php new file mode 100644 index 000000000..d2f8bc285 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/OrderLineCollection.php @@ -0,0 +1,32 @@ +id === $lineId) { + return $line; + } + } + + return null; + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/Organization.php b/vendor_manual/mollie/mollie-api-php/src/Resources/Organization.php new file mode 100644 index 000000000..209f9e3af --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/Organization.php @@ -0,0 +1,70 @@ +client); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/Partner.php b/vendor_manual/mollie/mollie-api-php/src/Resources/Partner.php new file mode 100644 index 000000000..2c00ac1f1 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/Partner.php @@ -0,0 +1,50 @@ +consumerName and $details->consumerAccount. + * + * @var \stdClass|null + */ + public $details; + + /** + * Used to restrict the payment methods available to your customer to those from a single country. + * + * @var string|null; + */ + public $restrictPaymentMethodsToCountry; + + /** + * @var \stdClass + */ + public $_links; + + /** + * @var \stdClass[] + */ + public $_embedded; + + /** + * Whether or not this payment can be canceled. + * + * @var bool|null + */ + public $isCancelable; + + /** + * The total amount that is already captured for this payment. Only available + * when this payment supports captures. + * + * @var \stdClass|null + */ + public $amountCaptured; + + /** + * Indicates whether the capture will be scheduled automatically or not. Set + * to manual to capture the payment manually using the Create capture endpoint. + * + * Possible values: "automatic", "manual" + * + * @var string|null + */ + public $captureMode; + + /** + * Indicates the interval to wait before the payment is + * captured, for example `8 hours` or `2 days. The capture delay + * will be added to the date and time the payment became authorized. + * + * Possible values: ... hours ... days + * @example 8 hours + * @var string|null + */ + public $captureDelay; + + /** + * UTC datetime on which the merchant has to have captured the payment in + * ISO-8601 format. This parameter is omitted if the payment is not authorized (yet). + * + * @example "2013-12-25T10:30:54+00:00" + * @var string|null + */ + public $captureBefore; + + /** + * The application fee, if the payment was created with one. Contains amount + * (the value and currency) and description. + * + * @var \stdClass|null + */ + public $applicationFee; + + /** + * An optional routing configuration which enables you to route a successful payment, + * or part of the payment, to one or more connected accounts. Additionally, you can + * schedule (parts of) the payment to become available on the connected account on a + * future date. + * + * @var array|null + */ + public $routing; + + /** + * The date and time the payment became authorized, in ISO 8601 format. This + * parameter is omitted if the payment is not authorized (yet). + * + * @example "2013-12-25T10:30:54+00:00" + * @var string|null + */ + public $authorizedAt; + + /** + * The date and time the payment was expired, in ISO 8601 format. This + * parameter is omitted if the payment did not expire (yet). + * + * @example "2013-12-25T10:30:54+00:00" + * @var string|null + */ + public $expiredAt; + + /** + * If a customer was specified upon payment creation, the customer’s token will + * be available here as well. + * + * @example cst_XPn78q9CfT + * @var string|null + */ + public $customerId; + + /** + * This optional field contains your customer’s ISO 3166-1 alpha-2 country code, + * detected by us during checkout. For example: BE. This field is omitted if the + * country code was not detected. + * + * @var string|null + */ + public $countryCode; + + /** + * Is this payment canceled? + * + * @return bool + */ + public function isCanceled() + { + return $this->status === PaymentStatus::STATUS_CANCELED; + } + + /** + * Is this payment expired? + * + * @return bool + */ + public function isExpired() + { + return $this->status === PaymentStatus::STATUS_EXPIRED; + } + + /** + * Is this payment still open / ongoing? + * + * @return bool + */ + public function isOpen() + { + return $this->status === PaymentStatus::STATUS_OPEN; + } + + /** + * Is this payment pending? + * + * @return bool + */ + public function isPending() + { + return $this->status === PaymentStatus::STATUS_PENDING; + } + + /** + * Is this payment authorized? + * + * @return bool + */ + public function isAuthorized() + { + return $this->status === PaymentStatus::STATUS_AUTHORIZED; + } + + /** + * Is this payment paid for? + * + * @return bool + */ + public function isPaid() + { + return ! empty($this->paidAt); + } + + /** + * Does the payment have refunds + * + * @return bool + */ + public function hasRefunds() + { + return ! empty($this->_links->refunds); + } + + /** + * Does this payment has chargebacks + * + * @return bool + */ + public function hasChargebacks() + { + return ! empty($this->_links->chargebacks); + } + + /** + * Is this payment failing? + * + * @return bool + */ + public function isFailed() + { + return $this->status === PaymentStatus::STATUS_FAILED; + } + + /** + * Check whether 'sequenceType' is set to 'first'. If a 'first' payment has been + * completed successfully, the consumer's account may be charged automatically + * using recurring payments. + * + * @return bool + */ + public function hasSequenceTypeFirst() + { + return $this->sequenceType === SequenceType::SEQUENCETYPE_FIRST; + } + + /** + * Check whether 'sequenceType' is set to 'recurring'. This type of payment is + * processed without involving + * the consumer. + * + * @return bool + */ + public function hasSequenceTypeRecurring() + { + return $this->sequenceType === SequenceType::SEQUENCETYPE_RECURRING; + } + + /** + * Get the checkout URL where the customer can complete the payment. + * + * @return string|null + */ + public function getCheckoutUrl() + { + if (empty($this->_links->checkout)) { + return null; + } + + return $this->_links->checkout->href; + } + + /** + * Get the mobile checkout URL where the customer can complete the payment. + * + * @return string|null + */ + public function getMobileAppCheckoutUrl() + { + if (empty($this->_links->mobileAppCheckout)) { + return null; + } + + return $this->_links->mobileAppCheckout->href; + } + + /** + * @return bool + */ + public function canBeRefunded() + { + return $this->amountRemaining !== null; + } + + /** + * @return bool + */ + public function canBePartiallyRefunded() + { + return $this->canBeRefunded(); + } + + /** + * Get the amount that is already refunded + * + * @return float + */ + public function getAmountRefunded() + { + if ($this->amountRefunded) { + return (float)$this->amountRefunded->value; + } + + return 0.0; + } + + /** + * Get the remaining amount that can be refunded. For some payment methods this + * amount can be higher than the payment amount. This is possible to reimburse + * the costs for a return shipment to your customer for example. + * + * @return float + */ + public function getAmountRemaining() + { + if ($this->amountRemaining) { + return (float)$this->amountRemaining->value; + } + + return 0.0; + } + + /** + * Get the total amount that was charged back for this payment. Only available when the + * total charged back amount is not zero. + * + * @return float + */ + public function getAmountChargedBack() + { + if ($this->amountChargedBack) { + return (float)$this->amountChargedBack->value; + } + + return 0.0; + } + + /** + * Does the payment have split payments + * + * @return bool + */ + public function hasSplitPayments() + { + return ! empty($this->routing); + } + + /** + * Retrieves all refunds associated with this payment + * + * @return RefundCollection + * @throws ApiException + */ + public function refunds() + { + 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 + ); + } + + /** + * @param string $refundId + * @param array $parameters + * + * @return Refund + * @throws ApiException + */ + public function getRefund($refundId, array $parameters = []) + { + return $this->client->paymentRefunds->getFor($this, $refundId, $this->withPresetOptions($parameters)); + } + + /** + * @param array $parameters + * + * @return Refund + * @throws ApiException + */ + public function listRefunds(array $parameters = []) + { + return $this->client->paymentRefunds->listFor($this, $this->withPresetOptions($parameters)); + } + + /** + * Retrieves all captures associated with this payment + * + * @return CaptureCollection + * @throws ApiException + */ + public function captures() + { + 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 + ); + } + + /** + * @param string $captureId + * @param array $parameters + * + * @return Capture + * @throws ApiException + */ + public function getCapture($captureId, array $parameters = []) + { + return $this->client->paymentCaptures->getFor( + $this, + $captureId, + $this->withPresetOptions($parameters) + ); + } + + /** + * Retrieves all chargebacks associated with this payment + * + * @return ChargebackCollection + * @throws ApiException + */ + public function chargebacks() + { + 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 + ); + } + + /** + * Retrieves a specific chargeback for this payment. + * + * @param string $chargebackId + * @param array $parameters + * + * @return Chargeback + * @throws ApiException + */ + public function getChargeback($chargebackId, array $parameters = []) + { + return $this->client->paymentChargebacks->getFor( + $this, + $chargebackId, + $this->withPresetOptions($parameters) + ); + } + + /** + * Issue a refund for this payment. + * + * @param array $data + * + * @return \Mollie\Api\Resources\Refund + * @throws ApiException + */ + public function refund($data) + { + return $this->client->paymentRefunds->createFor($this, $data); + } + + /** + * @return \Mollie\Api\Resources\Payment + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function update() + { + $body = [ + "description" => $this->description, + "cancelUrl" => $this->cancelUrl, + "redirectUrl" => $this->redirectUrl, + "webhookUrl" => $this->webhookUrl, + "metadata" => $this->metadata, + "restrictPaymentMethodsToCountry" => $this->restrictPaymentMethodsToCountry, + "locale" => $this->locale, + "dueDate" => $this->dueDate, + ]; + + $result = $this->client->payments->update($this->id, $body); + + return ResourceFactory::createFromApiResult($result, new Payment($this->client)); + } + + /** + * When accessed by oAuth we want to pass the testmode by default + * + * @return array + */ + private function getPresetOptions() + { + $options = []; + if ($this->client->usesOAuth()) { + $options["testmode"] = $this->mode === "test" ? true : false; + } + + return $options; + } + + /** + * Apply the preset options. + * + * @param array $options + * @return array + */ + private function withPresetOptions(array $options) + { + return array_merge($this->getPresetOptions(), $options); + } + + /** + * The total amount that is already captured for this payment. Only available + * when this payment supports captures. + * + * @return float + */ + public function getAmountCaptured() + { + if ($this->amountCaptured) { + return (float)$this->amountCaptured->value; + } + + return 0.0; + } + + /** + * The amount that has been settled. + * + * @return float + */ + public function getSettlementAmount() + { + if ($this->settlementAmount) { + return (float)$this->settlementAmount->value; + } + + return 0.0; + } + + /** + * The total amount that is already captured for this payment. Only available + * when this payment supports captures. + * + * @return float + */ + public function getApplicationFeeAmount() + { + if ($this->applicationFee) { + return (float)$this->applicationFee->amount->value; + } + + return 0.0; + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/PaymentCollection.php b/vendor_manual/mollie/mollie-api-php/src/Resources/PaymentCollection.php new file mode 100644 index 000000000..892deb1be --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/PaymentCollection.php @@ -0,0 +1,22 @@ +client); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/PaymentLink.php b/vendor_manual/mollie/mollie-api-php/src/Resources/PaymentLink.php new file mode 100644 index 000000000..cd64ed7d9 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/PaymentLink.php @@ -0,0 +1,127 @@ +paidAt); + } + + /** + * Get the checkout URL where the customer can complete the payment. + * + * @return string|null + */ + public function getCheckoutUrl() + { + if (empty($this->_links->paymentLink)) { + return null; + } + + return $this->_links->paymentLink->href; + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/PaymentLinkCollection.php b/vendor_manual/mollie/mollie-api-php/src/Resources/PaymentLinkCollection.php new file mode 100644 index 000000000..061f1f665 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/PaymentLinkCollection.php @@ -0,0 +1,22 @@ +client); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/Permission.php b/vendor_manual/mollie/mollie-api-php/src/Resources/Permission.php new file mode 100644 index 000000000..fe0761d0a --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/Permission.php @@ -0,0 +1,27 @@ +status == ProfileStatus::STATUS_UNVERIFIED; + } + + /** + * @return bool + */ + public function isVerified() + { + return $this->status == ProfileStatus::STATUS_VERIFIED; + } + + /** + * @return bool + */ + public function isBlocked() + { + return $this->status == ProfileStatus::STATUS_BLOCKED; + } + + /** + * @return \Mollie\Api\Resources\Profile + * @throws ApiException + */ + public function update() + { + $body = [ + "name" => $this->name, + "website" => $this->website, + "email" => $this->email, + "phone" => $this->phone, + "businessCategory" => $this->businessCategory, + "mode" => $this->mode, + ]; + + $result = $this->client->profiles->update($this->id, $body); + + return ResourceFactory::createFromApiResult($result, new Profile($this->client)); + } + + /** + * Retrieves all chargebacks associated with this profile + * + * @return ChargebackCollection + * @throws ApiException + */ + public function chargebacks() + { + 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 + ); + } + + /** + * Retrieves all methods activated on this profile + * + * @return MethodCollection + * @throws ApiException + */ + public function methods() + { + if (! isset($this->_links->methods->href)) { + return new MethodCollection(0, null); + } + + $result = $this->client->performHttpCallToFullUrl(MollieApiClient::HTTP_GET, $this->_links->methods->href); + + return ResourceFactory::createCursorResourceCollection( + $this->client, + $result->_embedded->methods, + Method::class, + $result->_links + ); + } + + /** + * Enable a payment method for this profile. + * + * @param string $methodId + * @param array $data + * @return Method + * @throws ApiException + */ + public function enableMethod($methodId, array $data = []) + { + return $this->client->profileMethods->createFor($this, $methodId, $data); + } + + /** + * Disable a payment method for this profile. + * + * @param string $methodId + * @param array $data + * @return Method + * @throws ApiException + */ + public function disableMethod($methodId, array $data = []) + { + return $this->client->profileMethods->deleteFor($this, $methodId, $data); + } + + /** + * Retrieves all payments associated with this profile + * + * @return PaymentCollection + * @throws ApiException + */ + public function payments() + { + if (! isset($this->_links->payments->href)) { + return new PaymentCollection($this->client, 0, null); + } + + $result = $this->client->performHttpCallToFullUrl(MollieApiClient::HTTP_GET, $this->_links->payments->href); + + return ResourceFactory::createCursorResourceCollection( + $this->client, + $result->_embedded->methods, + Method::class, + $result->_links + ); + } + + /** + * Retrieves all refunds associated with this profile + * + * @return RefundCollection + * @throws ApiException + */ + public function refunds() + { + 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 + ); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/ProfileCollection.php b/vendor_manual/mollie/mollie-api-php/src/Resources/ProfileCollection.php new file mode 100644 index 000000000..536926b37 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/ProfileCollection.php @@ -0,0 +1,22 @@ +client); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/Refund.php b/vendor_manual/mollie/mollie-api-php/src/Resources/Refund.php new file mode 100644 index 000000000..651b13f13 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/Refund.php @@ -0,0 +1,177 @@ +isQueued() || $this->isPending(); + } + + /** + * Is this refund queued? + * + * @return bool + */ + public function isQueued() + { + return $this->status === RefundStatus::STATUS_QUEUED; + } + + /** + * Is this refund pending? + * + * @return bool + */ + public function isPending() + { + return $this->status === RefundStatus::STATUS_PENDING; + } + + /** + * Is this refund processing? + * + * @return bool + */ + public function isProcessing() + { + return $this->status === RefundStatus::STATUS_PROCESSING; + } + + /** + * Is this refund transferred to consumer? + * + * @return bool + */ + public function isTransferred() + { + return $this->status === RefundStatus::STATUS_REFUNDED; + } + + /** + * Is this refund failed? + * + * @return bool + */ + public function isFailed() + { + return $this->status === RefundStatus::STATUS_FAILED; + } + + /** + * Is this refund canceled? + * + * @return bool + */ + public function isCanceled() + { + return $this->status === RefundStatus::STATUS_CANCELED; + } + + /** + * Cancel the refund. + * Returns null if successful. + * + * @return null + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function cancel() + { + $this->client->performHttpCallToFullUrl( + MollieApiClient::HTTP_DELETE, + $this->_links->self->href + ); + + return null; + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/RefundCollection.php b/vendor_manual/mollie/mollie-api-php/src/Resources/RefundCollection.php new file mode 100644 index 000000000..01b55a3ce --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/RefundCollection.php @@ -0,0 +1,22 @@ +client); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/ResourceFactory.php b/vendor_manual/mollie/mollie-api-php/src/Resources/ResourceFactory.php new file mode 100644 index 000000000..bd418e6c2 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/ResourceFactory.php @@ -0,0 +1,79 @@ + $value) { + $resource->{$property} = $value; + } + + return $resource; + } + + /** + * @param MollieApiClient $client + * @param string $resourceClass + * @param array $data + * @param null $_links + * @param string $resourceCollectionClass + * @return mixed + */ + public static function createBaseResourceCollection( + MollieApiClient $client, + $resourceClass, + $data, + $_links = null, + $resourceCollectionClass = null + ) { + $resourceCollectionClass = $resourceCollectionClass ?: $resourceClass . 'Collection'; + $data = $data ?: []; + + $result = new $resourceCollectionClass(count($data), $_links); + foreach ($data as $item) { + $result[] = static::createFromApiResult($item, new $resourceClass($client)); + } + + return $result; + } + + /** + * @param MollieApiClient $client + * @param array $input + * @param string $resourceClass + * @param null $_links + * @param null $resourceCollectionClass + * @return mixed + */ + public static function createCursorResourceCollection( + $client, + array $input, + $resourceClass, + $_links = null, + $resourceCollectionClass = null + ) { + if (null === $resourceCollectionClass) { + $resourceCollectionClass = $resourceClass.'Collection'; + } + + $data = new $resourceCollectionClass($client, count($input), $_links); + foreach ($input as $item) { + $data[] = static::createFromApiResult($item, new $resourceClass($client)); + } + + return $data; + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/Route.php b/vendor_manual/mollie/mollie-api-php/src/Resources/Route.php new file mode 100644 index 000000000..20b119d34 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/Route.php @@ -0,0 +1,35 @@ +client); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/Settlement.php b/vendor_manual/mollie/mollie-api-php/src/Resources/Settlement.php new file mode 100644 index 000000000..8bdef55ac --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/Settlement.php @@ -0,0 +1,192 @@ +status === SettlementStatus::STATUS_OPEN; + } + + /** + * Is this settlement pending? + * + * @return bool + */ + public function isPending() + { + return $this->status === SettlementStatus::STATUS_PENDING; + } + + /** + * Is this settlement paidout? + * + * @return bool + */ + public function isPaidout() + { + return $this->status === SettlementStatus::STATUS_PAIDOUT; + } + + /** + * Is this settlement failed? + * + * @return bool + */ + public function isFailed() + { + return $this->status === SettlementStatus::STATUS_FAILED; + } + + /** + * Retrieves all payments associated with this settlement + * + * @param int|null $limit + * @param array $parameters + * @return PaymentCollection + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function payments(int $limit = null, array $parameters = []): PaymentCollection + { + return $this->client->settlementPayments->pageForId($this->id, null, $limit, $parameters); + } + + /** + * Retrieves all refunds associated with this settlement + * + * @return RefundCollection + * @throws ApiException + */ + public function refunds() + { + 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 + ); + } + + /** + * Retrieves all chargebacks associated with this settlement + * + * @return ChargebackCollection + * @throws ApiException + */ + public function chargebacks() + { + 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 + ); + } + + /** + * Retrieves all captures associated with this settlement + * + * @return CaptureCollection + * @throws ApiException + */ + public function captures() + { + 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 + ); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/SettlementCollection.php b/vendor_manual/mollie/mollie-api-php/src/Resources/SettlementCollection.php new file mode 100644 index 000000000..f8910b6f6 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/SettlementCollection.php @@ -0,0 +1,22 @@ +client); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/Shipment.php b/vendor_manual/mollie/mollie-api-php/src/Resources/Shipment.php new file mode 100644 index 000000000..01c1e9ae4 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/Shipment.php @@ -0,0 +1,124 @@ +tracking !== null; + } + + /** + * Does this shipment offer a track and trace code? + * + * @return bool + */ + public function hasTrackingUrl() + { + return $this->hasTracking() && ! empty($this->tracking->url); + } + + /** + * Retrieve the track and trace url. Returns null if there is no url available. + * + * @return string|null + */ + public function getTrackingUrl() + { + if (! $this->hasTrackingUrl()) { + return null; + } + + return $this->tracking->url; + } + + /** + * Get the line value objects + * + * @return OrderLineCollection + */ + public function lines() + { + return ResourceFactory::createBaseResourceCollection( + $this->client, + OrderLine::class, + $this->lines + ); + } + + /** + * Get the Order object for this shipment + * + * @return Order + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function order() + { + return $this->client->orders->get($this->orderId); + } + + /** + * Save changes made to this shipment. + * + * @return BaseResource|Shipment + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function update() + { + $body = [ + "tracking" => $this->tracking, + ]; + + $result = $this->client->shipments->update($this->orderId, $this->id, $body); + + return ResourceFactory::createFromApiResult($result, new Shipment($this->client)); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/ShipmentCollection.php b/vendor_manual/mollie/mollie-api-php/src/Resources/ShipmentCollection.php new file mode 100644 index 000000000..b87f3453e --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/ShipmentCollection.php @@ -0,0 +1,14 @@ + $this->amount, + "times" => $this->times, + "startDate" => $this->startDate, + "webhookUrl" => $this->webhookUrl, + "description" => $this->description, + "mandateId" => $this->mandateId, + "metadata" => $this->metadata, + "interval" => $this->interval, + ]; + + $result = $this->client->subscriptions->update($this->customerId, $this->id, $body); + + return ResourceFactory::createFromApiResult($result, new Subscription($this->client)); + } + + /** + * Returns whether the Subscription is active or not. + * + * @return bool + */ + public function isActive() + { + return $this->status === SubscriptionStatus::STATUS_ACTIVE; + } + + /** + * Returns whether the Subscription is pending or not. + * + * @return bool + */ + public function isPending() + { + return $this->status === SubscriptionStatus::STATUS_PENDING; + } + + /** + * Returns whether the Subscription is canceled or not. + * + * @return bool + */ + public function isCanceled() + { + return $this->status === SubscriptionStatus::STATUS_CANCELED; + } + + /** + * Returns whether the Subscription is suspended or not. + * + * @return bool + */ + public function isSuspended() + { + return $this->status === SubscriptionStatus::STATUS_SUSPENDED; + } + + /** + * Returns whether the Subscription is completed or not. + * + * @return bool + */ + public function isCompleted() + { + return $this->status === SubscriptionStatus::STATUS_COMPLETED; + } + + /** + * Cancels this subscription + * + * @return Subscription + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function cancel() + { + if (! isset($this->_links->self->href)) { + return $this; + } + + $body = null; + if ($this->client->usesOAuth()) { + $body = json_encode([ + "testmode" => $this->mode === "test" ? true : false, + ]); + } + + $result = $this->client->performHttpCallToFullUrl( + MollieApiClient::HTTP_DELETE, + $this->_links->self->href, + $body + ); + + return ResourceFactory::createFromApiResult($result, new Subscription($this->client)); + } + + /** + * Get subscription payments + * + * @return \Mollie\Api\Resources\PaymentCollection + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function payments() + { + if (! isset($this->_links->payments->href)) { + return new PaymentCollection($this->client, 0, null); + } + + $result = $this->client->performHttpCallToFullUrl( + MollieApiClient::HTTP_GET, + $this->_links->payments->href + ); + + return ResourceFactory::createCursorResourceCollection( + $this->client, + $result->_embedded->payments, + Payment::class, + $result->_links + ); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/SubscriptionCollection.php b/vendor_manual/mollie/mollie-api-php/src/Resources/SubscriptionCollection.php new file mode 100644 index 000000000..848130895 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/SubscriptionCollection.php @@ -0,0 +1,22 @@ +client); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/Terminal.php b/vendor_manual/mollie/mollie-api-php/src/Resources/Terminal.php new file mode 100644 index 000000000..a2fd3b436 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/Terminal.php @@ -0,0 +1,157 @@ +status === TerminalStatus::STATUS_PENDING; + } + + /** + * @return bool + */ + public function isActive() + { + return $this->status === TerminalStatus::STATUS_ACTIVE; + } + + /** + * @return bool + */ + public function isInactive() + { + return $this->status === TerminalStatus::STATUS_INACTIVE; + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Resources/TerminalCollection.php b/vendor_manual/mollie/mollie-api-php/src/Resources/TerminalCollection.php new file mode 100644 index 000000000..af785a6e2 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Resources/TerminalCollection.php @@ -0,0 +1,22 @@ +client); + } +} diff --git a/vendor_manual/mollie/mollie-api-php/src/Types/ApprovalPrompt.php b/vendor_manual/mollie/mollie-api-php/src/Types/ApprovalPrompt.php new file mode 100644 index 000000000..3aff39844 --- /dev/null +++ b/vendor_manual/mollie/mollie-api-php/src/Types/ApprovalPrompt.php @@ -0,0 +1,14 @@ +