Version Description
04-11-2019 =
Fix - Apple Pay payment method appear temporary in checkout page even if the device does not support Apple Pay
Fix - Refunding per line items is not possible when the refund amount field is disabled in WooCommerce order edit page
Fix - Compatibility with Php 7.4
Download this release
Release Info
| Developer | wido |
| Plugin | |
| Version | 5.3.1 |
| Comparing to | |
| See all releases | |
Code changes from version 5.3.0 to 5.3.1
- assets/js/applepay.js +8 -5
- includes/mollie-api-php/.gitattributes +0 -8
- includes/mollie-api-php/.github/ISSUE_TEMPLATE.md +0 -8
- includes/mollie-api-php/.gitignore +0 -8
- includes/mollie-api-php/.travis.yml +0 -46
- includes/mollie-api-php/Makefile +0 -31
- includes/mollie-api-php/composer.json +0 -80
- includes/mollie-api-php/examples/captures/get-capture.php +0 -27
- includes/mollie-api-php/examples/captures/list-captures.php +0 -27
- includes/mollie-api-php/examples/customers/create-customer-first-payment.php +0 -67
- includes/mollie-api-php/examples/customers/create-customer-payment.php +0 -61
- includes/mollie-api-php/examples/customers/create-customer-recurring-payment.php +0 -63
- includes/mollie-api-php/examples/customers/create-customer.php +0 -27
- includes/mollie-api-php/examples/customers/delete-customer.php +0 -17
- includes/mollie-api-php/examples/customers/list-customer-payments.php +0 -58
- includes/mollie-api-php/examples/customers/update-customer.php +0 -31
- includes/mollie-api-php/examples/database/.gitignore +0 -1
- includes/mollie-api-php/examples/functions.php +0 -23
- includes/mollie-api-php/examples/initialize.php +0 -18
- includes/mollie-api-php/examples/initialize_with_oauth.php +0 -19
- includes/mollie-api-php/examples/invoices/list-invoices.php +0 -37
- includes/mollie-api-php/examples/mandates/create-mandate.php +0 -30
- includes/mollie-api-php/examples/mandates/list-mandates.php +0 -28
- includes/mollie-api-php/examples/mandates/revoke-mandate.php +0 -31
- includes/mollie-api-php/examples/orders/cancel-order-lines.php +0 -44
- includes/mollie-api-php/examples/orders/cancel-order.php +0 -26
- includes/mollie-api-php/examples/orders/create-order.php +0 -118
- includes/mollie-api-php/examples/orders/list-methods.php +0 -28
- includes/mollie-api-php/examples/orders/list-orders.php +0 -49
- includes/mollie-api-php/examples/orders/refund-order-completely.php +0 -25
- includes/mollie-api-php/examples/orders/refund-order-partially.php +0 -33
- includes/mollie-api-php/examples/orders/webhook.php +0 -50
- includes/mollie-api-php/examples/payments/create-ideal-payment.php +0 -81
- includes/mollie-api-php/examples/payments/create-payment-oauth.php +0 -67
- includes/mollie-api-php/examples/payments/create-payment.php +0 -60
- includes/mollie-api-php/examples/payments/list-methods.php +0 -27
- includes/mollie-api-php/examples/payments/list-payments.php +0 -85
- includes/mollie-api-php/examples/payments/refund-payment.php +0 -71
- includes/mollie-api-php/examples/payments/return.php +0 -29
- includes/mollie-api-php/examples/payments/webhook.php +0 -65
- includes/mollie-api-php/examples/profiles/create-profile.php +0 -30
- includes/mollie-api-php/examples/profiles/delete-profile.php +0 -23
- includes/mollie-api-php/examples/profiles/list-profiles.php +0 -28
- includes/mollie-api-php/examples/profiles/update-profile.php +0 -33
- includes/mollie-api-php/examples/settlements/list-settlements.php +0 -53
- includes/mollie-api-php/examples/shipments/create-shipment-all.php +0 -27
- includes/mollie-api-php/examples/shipments/create-shipment-partial.php +0 -42
- includes/mollie-api-php/examples/shipments/get-shipment.php +0 -27
- includes/mollie-api-php/examples/shipments/list-shipments.php +0 -30
- includes/mollie-api-php/examples/shipments/update-shipment.php +0 -40
- includes/mollie-api-php/examples/subscriptions/cancel-subscription.php +0 -36
- includes/mollie-api-php/examples/subscriptions/create-subscription.php +0 -61
- includes/mollie-api-php/examples/subscriptions/update-subscription.php +0 -31
- includes/mollie-api-php/phpunit.xml +0 -15
- includes/mollie-api-php/tests/Mollie/API/CompatibilityCheckerTest.php +0 -57
- includes/mollie-api-php/tests/Mollie/API/Endpoints/BaseEndpointTest.php +0 -76
- includes/mollie-api-php/tests/Mollie/API/Endpoints/ChargebackEndpointTest.php +0 -156
- includes/mollie-api-php/tests/Mollie/API/Endpoints/CustomerEndpointTest.php +0 -234
- includes/mollie-api-php/tests/Mollie/API/Endpoints/CustomerPaymentEndpointTest.php +0 -314
- includes/mollie-api-php/tests/Mollie/API/Endpoints/InvoiceEndpointTest.php +0 -222
- includes/mollie-api-php/tests/Mollie/API/Endpoints/MandateEndpointTest.php +0 -428
- includes/mollie-api-php/tests/Mollie/API/Endpoints/MethodEndpointTest.php +0 -641
- includes/mollie-api-php/tests/Mollie/API/Endpoints/OnboardingEndpointTest.php +0 -82
- includes/mollie-api-php/tests/Mollie/API/Endpoints/OrderEndpointTest.php +0 -1085
- includes/mollie-api-php/tests/Mollie/API/Endpoints/OrderLineEndpointTest.php +0 -21
- includes/mollie-api-php/tests/Mollie/API/Endpoints/OrderPaymentEndpointTest.php +0 -289
- includes/mollie-api-php/tests/Mollie/API/Endpoints/OrderRefundEndpointTest.php +0 -427
- includes/mollie-api-php/tests/Mollie/API/Endpoints/OrganizationEndpointTest.php +0 -126
- includes/mollie-api-php/tests/Mollie/API/Endpoints/PaymentCaptureEndpointTest.php +0 -283
- includes/mollie-api-php/tests/Mollie/API/Endpoints/PaymentChargebackEndpointTest.php +0 -265
- includes/mollie-api-php/tests/Mollie/API/Endpoints/PaymentEndpointTest.php +0 -381
- includes/mollie-api-php/tests/Mollie/API/Endpoints/PaymentRefundEndpointTest.php +0 -388
- includes/mollie-api-php/tests/Mollie/API/Endpoints/PermissionEndpointTest.php +0 -169
- includes/mollie-api-php/tests/Mollie/API/Endpoints/ProfileEndpointTest.php +0 -501
- includes/mollie-api-php/tests/Mollie/API/Endpoints/ProfileMethodEndpointTest.php +0 -232
- includes/mollie-api-php/tests/Mollie/API/Endpoints/RefundEndpointTest.php +0 -161
- includes/mollie-api-php/tests/Mollie/API/Endpoints/SettlementEndpointTest.php +0 -450
- includes/mollie-api-php/tests/Mollie/API/Endpoints/ShipmentEndpointTest.php +0 -565
- includes/mollie-api-php/tests/Mollie/API/Endpoints/SubscriptionEndpointTest.php +0 -491
- includes/mollie-api-php/tests/Mollie/API/Exceptions/ApiExceptionTest.php +0 -89
- includes/mollie-api-php/tests/Mollie/API/MollieApiClientTest.php +0 -159
- includes/mollie-api-php/tests/Mollie/API/Resources/InvoiceTest.php +0 -42
- includes/mollie-api-php/tests/Mollie/API/Resources/OnboardingTest.php +0 -42
- includes/mollie-api-php/tests/Mollie/API/Resources/OrderLineCollectionTest.php +0 -36
- includes/mollie-api-php/tests/Mollie/API/Resources/OrderLineTest.php +0 -149
- includes/mollie-api-php/tests/Mollie/API/Resources/OrderTest.php +0 -295
- includes/mollie-api-php/tests/Mollie/API/Resources/PaymentTest.php +0 -212
- includes/mollie-api-php/tests/Mollie/API/Resources/ProfileTest.php +0 -42
- includes/mollie-api-php/tests/Mollie/API/Resources/RefundTest.php +0 -50
- includes/mollie-api-php/tests/Mollie/API/Resources/ResourceFactoryTest.php +0 -34
- includes/mollie-api-php/tests/Mollie/API/Resources/SettlementTest.php +0 -50
- includes/mollie-api-php/tests/Mollie/API/Resources/ShipmentTest.php +0 -84
- includes/mollie-api-php/tests/Mollie/API/Resources/SubscriptionTest.php +0 -60
- includes/mollie-api-php/tests/Mollie/API/Types/MandateMethodTest.php +0 -37
- includes/mollie-api-php/tests/Mollie/TestHelpers/AmountObjectTestHelpers.php +0 -22
- includes/mollie-api-php/tests/Mollie/TestHelpers/LinkObjectTestHelpers.php +0 -29
- includes/mollie-api-php/vendor/autoload.php +1 -1
- includes/mollie-api-php/vendor/composer/autoload_classmap.php +0 -162
- includes/mollie-api-php/vendor/composer/autoload_real.php +7 -7
- includes/mollie-api-php/vendor/composer/autoload_static.php +3 -169
- includes/mollie-api-php/vendor/composer/ca-bundle/res/cacert.pem +2 -33
- includes/mollie-api-php/vendor/composer/installed.json +19 -18
- includes/mollie-api-php/vendor/guzzlehttp/guzzle/.php_cs +21 -0
- includes/mollie-api-php/vendor/guzzlehttp/guzzle/CHANGELOG.md +17 -0
- includes/mollie-api-php/vendor/guzzlehttp/guzzle/Dockerfile +18 -0
- includes/mollie-api-php/vendor/guzzlehttp/guzzle/README.md +11 -12
- includes/mollie-api-php/vendor/guzzlehttp/guzzle/composer.json +28 -14
- includes/mollie-api-php/vendor/guzzlehttp/guzzle/phpstan.neon.dist +9 -0
- includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Client.php +1 -1
- includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/ClientInterface.php +1 -1
- includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php +1 -1
- includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php +2 -1
- includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php +1 -0
- includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php +2 -2
- includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Exception/ClientException.php +3 -1
- includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Exception/GuzzleException.php +20 -10
- includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Exception/InvalidArgumentException.php +7 -0
- includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php +1 -1
- includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Exception/ServerException.php +3 -1
- includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php +3 -1
- includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Exception/TransferException.php +3 -1
- includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php +22 -7
- includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php +11 -5
- includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php +2 -1
- includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php +17 -5
- includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/HandlerStack.php +4 -4
- includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Middleware.php +3 -4
- includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Pool.php +1 -1
- includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php +1 -1
- includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/RequestOptions.php +1 -1
- includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php +4 -1
- includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/TransferStats.php +1 -1
- includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/functions.php +18 -5
- includes/mollie/OrderLineStatus.php +20 -0
- includes/mollie/wc/gateway/abstract.php +32 -11
- includes/mollie/wc/gateway/abstractseparecurring.php +43 -35
- includes/mollie/wc/helper/api.php +10 -15
- includes/mollie/wc/helper/paymentfactory.php +33 -10
- includes/mollie/wc/payment/OrderItemsRefunder.php +227 -0
- includes/mollie/wc/payment/PartialRefundException.php +5 -0
- includes/mollie/wc/payment/RefundLineItemsBuilder.php +136 -0
- includes/mollie/wc/payment/object.php +9 -2
- includes/mollie/wc/payment/order.php +164 -131
- includes/mollie/wc/payment/payment.php +19 -2
- includes/mollie/wc/plugin.php +91 -10
- includes/woocommerce_functions.php +6 -1
- mollie-payments-for-woocommerce.php +8 -1
- readme.txt +7 -1
assets/js/applepay.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
| 1 |
(function (ApplePaySession) {
|
|
|
|
| 2 |
document.addEventListener('DOMContentLoaded', function () {
|
| 3 |
var applePayMethodElement = document.querySelector(
|
| 4 |
'.payment_method_mollie_wc_gateway_applepay',
|
| 5 |
)
|
|
|
|
| 6 |
var woocommerceCheckoutForm = document.querySelector(
|
| 7 |
'form.woocommerce-checkout',
|
| 8 |
)
|
|
@@ -14,11 +16,12 @@
|
|
| 14 |
if (!ApplePaySession || !ApplePaySession.canMakePayments()) {
|
| 15 |
applePayMethodElement &&
|
| 16 |
applePayMethodElement.parentNode.removeChild(applePayMethodElement)
|
| 17 |
-
|
| 18 |
-
woocommerceCheckoutForm.insertAdjacentHTML(
|
| 19 |
-
'beforeend',
|
| 20 |
-
'<input type="hidden" name="mollie_apple_pay_method_not_allowed" value="1" />',
|
| 21 |
-
)
|
| 22 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
})
|
| 24 |
})(window.ApplePaySession)
|
| 1 |
(function (ApplePaySession) {
|
| 2 |
+
|
| 3 |
document.addEventListener('DOMContentLoaded', function () {
|
| 4 |
var applePayMethodElement = document.querySelector(
|
| 5 |
'.payment_method_mollie_wc_gateway_applepay',
|
| 6 |
)
|
| 7 |
+
|
| 8 |
var woocommerceCheckoutForm = document.querySelector(
|
| 9 |
'form.woocommerce-checkout',
|
| 10 |
)
|
| 16 |
if (!ApplePaySession || !ApplePaySession.canMakePayments()) {
|
| 17 |
applePayMethodElement &&
|
| 18 |
applePayMethodElement.parentNode.removeChild(applePayMethodElement)
|
| 19 |
+
return
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
}
|
| 21 |
+
|
| 22 |
+
woocommerceCheckoutForm.insertAdjacentHTML(
|
| 23 |
+
'beforeend',
|
| 24 |
+
'<input type="hidden" name="mollie_apple_pay_method_allowed" value="1" />',
|
| 25 |
+
)
|
| 26 |
})
|
| 27 |
})(window.ApplePaySession)
|
includes/mollie-api-php/.gitattributes
DELETED
|
@@ -1,8 +0,0 @@
|
|
| 1 |
-
/.github export-ignore
|
| 2 |
-
/tests export-ignore
|
| 3 |
-
/.gitattributes export-ignore
|
| 4 |
-
/.gitignore export-ignore
|
| 5 |
-
/.travis.yml export-ignore
|
| 6 |
-
/Makefile export-ignore
|
| 7 |
-
/phpunit.xml export-ignore
|
| 8 |
-
/scoper.inc.php export-ignore
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/.github/ISSUE_TEMPLATE.md
DELETED
|
@@ -1,8 +0,0 @@
|
|
| 1 |
-
## Specifications
|
| 2 |
-
|
| 3 |
-
- API Version:
|
| 4 |
-
|
| 5 |
-
## Describe the issue
|
| 6 |
-
|
| 7 |
-
...
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/.gitignore
DELETED
|
@@ -1,8 +0,0 @@
|
|
| 1 |
-
/.idea
|
| 2 |
-
/build
|
| 3 |
-
/vendor
|
| 4 |
-
/composer.lock
|
| 5 |
-
.DS_Store
|
| 6 |
-
composer.phar
|
| 7 |
-
php-scoper.phar
|
| 8 |
-
php-scoper.phar.pubkey
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/.travis.yml
DELETED
|
@@ -1,46 +0,0 @@
|
|
| 1 |
-
language: php
|
| 2 |
-
|
| 3 |
-
dist: xenial
|
| 4 |
-
|
| 5 |
-
matrix:
|
| 6 |
-
fast_finish: true
|
| 7 |
-
allow_failures:
|
| 8 |
-
- php: nightly
|
| 9 |
-
include:
|
| 10 |
-
- php: 5.6
|
| 11 |
-
- php: 7.0
|
| 12 |
-
- php: 7.1
|
| 13 |
-
- php: 7.2
|
| 14 |
-
- php: 7.3
|
| 15 |
-
- php: nightly
|
| 16 |
-
|
| 17 |
-
sudo: false
|
| 18 |
-
|
| 19 |
-
cache:
|
| 20 |
-
directories:
|
| 21 |
-
- "$HOME/.composer/cache"
|
| 22 |
-
|
| 23 |
-
env:
|
| 24 |
-
- COMPOSER_NO_INTERACTION=1
|
| 25 |
-
|
| 26 |
-
install:
|
| 27 |
-
- travis_retry composer install --no-scripts --no-suggest
|
| 28 |
-
|
| 29 |
-
script:
|
| 30 |
-
- composer validate --strict
|
| 31 |
-
- find src examples tests -name '*.php' | xargs -n 1 -P4 php -l
|
| 32 |
-
- vendor/bin/phpunit
|
| 33 |
-
|
| 34 |
-
before_deploy:
|
| 35 |
-
- sed -i "/const CLIENT_VERSION/c\\ const CLIENT_VERSION = '${TRAVIS_TAG:1}';" src/MollieApiClient.php
|
| 36 |
-
- make mollie-api-php.zip
|
| 37 |
-
|
| 38 |
-
deploy:
|
| 39 |
-
provider: releases
|
| 40 |
-
api_key:
|
| 41 |
-
secure: oXVzXjLkVfr7+5leMbIHQnLDg1o9/ldG6qdJ/GtwumZJYiit9h7VBYpxRvQGgXUESzhDlBf2jCLKxqxW+P2/PwG738/rSJVjLvbtbyFRz+pvk4o8rm3U7IKRv87BFhIvhaO9HcgvmyHbPMzGKRdAsWYWGQf/dg9N77xeDZ9++80=
|
| 42 |
-
file: mollie-api-php.zip
|
| 43 |
-
skip_cleanup: true
|
| 44 |
-
on:
|
| 45 |
-
tags: true
|
| 46 |
-
php: 7.2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/Makefile
DELETED
|
@@ -1,31 +0,0 @@
|
|
| 1 |
-
#
|
| 2 |
-
# This automatically creates a fresh build for distribution with other modules or for getting started with Mollie
|
| 3 |
-
# without composer.
|
| 4 |
-
#
|
| 5 |
-
mollie-api-php.zip: php-scoper.phar
|
| 6 |
-
rm -rf build/*
|
| 7 |
-
|
| 8 |
-
#
|
| 9 |
-
# First, install all dependencies. Then prefix everything with humbug/php-scoper. Finally, we should dump the
|
| 10 |
-
# autoloader again to update the autoloader with the new classnames.
|
| 11 |
-
#
|
| 12 |
-
composer install --no-dev --no-scripts --no-suggest
|
| 13 |
-
php php-scoper.phar add-prefix --force
|
| 14 |
-
composer dump-autoload --working-dir build --classmap-authoritative
|
| 15 |
-
|
| 16 |
-
#
|
| 17 |
-
# Now move the autoload files. We have to use the scoper one to load the aliasses but we want to load the normal
|
| 18 |
-
# filename. Flip them around.
|
| 19 |
-
#
|
| 20 |
-
mv build/vendor/autoload.php build/vendor/composer-autoload.php
|
| 21 |
-
sed -i 's/autoload.php/composer-autoload.php/g' build/vendor/scoper-autoload.php
|
| 22 |
-
mv build/vendor/scoper-autoload.php build/vendor/autoload.php
|
| 23 |
-
|
| 24 |
-
#
|
| 25 |
-
# Finally, create a zip file with all built files.
|
| 26 |
-
#
|
| 27 |
-
cd build; zip -r ../mollie-api-php.zip examples src vendor composer.json LICENSE README.md
|
| 28 |
-
|
| 29 |
-
php-scoper.phar:
|
| 30 |
-
wget -q https://github.com/humbug/php-scoper/releases/download/0.9.2/php-scoper.phar
|
| 31 |
-
wget -q https://github.com/humbug/php-scoper/releases/download/0.9.2/php-scoper.phar.pubkey
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/composer.json
DELETED
|
@@ -1,80 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"name": "mollie/mollie-api-php",
|
| 3 |
-
"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.",
|
| 4 |
-
"keywords": [
|
| 5 |
-
"mollie",
|
| 6 |
-
"payment",
|
| 7 |
-
"service",
|
| 8 |
-
"ideal",
|
| 9 |
-
"creditcard",
|
| 10 |
-
"apple pay",
|
| 11 |
-
"mistercash",
|
| 12 |
-
"bancontact",
|
| 13 |
-
"sofort",
|
| 14 |
-
"sofortbanking",
|
| 15 |
-
"sepa",
|
| 16 |
-
"paypal",
|
| 17 |
-
"paysafecard",
|
| 18 |
-
"podiumcadeaukaart",
|
| 19 |
-
"przelewy24",
|
| 20 |
-
"banktransfer",
|
| 21 |
-
"direct debit",
|
| 22 |
-
"belfius",
|
| 23 |
-
"belfius direct net",
|
| 24 |
-
"refunds",
|
| 25 |
-
"api",
|
| 26 |
-
"payments",
|
| 27 |
-
"gateway",
|
| 28 |
-
"subscriptions",
|
| 29 |
-
"recurring",
|
| 30 |
-
"charges",
|
| 31 |
-
"kbc",
|
| 32 |
-
"cbc",
|
| 33 |
-
"gift cards",
|
| 34 |
-
"intersolve",
|
| 35 |
-
"fashioncheque",
|
| 36 |
-
"inghomepay",
|
| 37 |
-
"klarna",
|
| 38 |
-
"paylater",
|
| 39 |
-
"sliceit"
|
| 40 |
-
],
|
| 41 |
-
"homepage": "https://www.mollie.com/en/developers",
|
| 42 |
-
"license": "BSD-2-Clause",
|
| 43 |
-
"authors": [
|
| 44 |
-
{
|
| 45 |
-
"name": "Mollie B.V.",
|
| 46 |
-
"email": "info@mollie.com"
|
| 47 |
-
}
|
| 48 |
-
],
|
| 49 |
-
"require": {
|
| 50 |
-
"php": ">=5.6",
|
| 51 |
-
"ext-curl": "*",
|
| 52 |
-
"ext-json": "*",
|
| 53 |
-
"ext-openssl": "*",
|
| 54 |
-
"composer/ca-bundle": "^1.1",
|
| 55 |
-
"guzzlehttp/guzzle": "^6.3"
|
| 56 |
-
},
|
| 57 |
-
"require-dev": {
|
| 58 |
-
"eloquent/liberator": "^2.0",
|
| 59 |
-
"phpunit/phpunit": "^5.7 || ^6.5 || ^7.1"
|
| 60 |
-
},
|
| 61 |
-
"suggest": {
|
| 62 |
-
"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."
|
| 63 |
-
},
|
| 64 |
-
"config": {
|
| 65 |
-
"sort-packages": true
|
| 66 |
-
},
|
| 67 |
-
"autoload": {
|
| 68 |
-
"psr-4": {
|
| 69 |
-
"Mollie\\Api\\": "src/"
|
| 70 |
-
}
|
| 71 |
-
},
|
| 72 |
-
"autoload-dev": {
|
| 73 |
-
"psr-4": {
|
| 74 |
-
"Tests\\": "tests"
|
| 75 |
-
}
|
| 76 |
-
},
|
| 77 |
-
"scripts": {
|
| 78 |
-
"test": "./vendor/bin/phpunit tests"
|
| 79 |
-
}
|
| 80 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/captures/get-capture.php
DELETED
|
@@ -1,27 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* Retrieve a payment capture using the Mollie API.
|
| 4 |
-
*/
|
| 5 |
-
|
| 6 |
-
try {
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your API key or OAuth access token.
|
| 9 |
-
*/
|
| 10 |
-
require "../initialize.php";
|
| 11 |
-
|
| 12 |
-
/*
|
| 13 |
-
* Retrieve a capture with ID 'cpt_4qqhO89gsT' for payment with
|
| 14 |
-
* ID 'tr_WDqYK6vllg'.
|
| 15 |
-
*
|
| 16 |
-
* See: https://docs.mollie.com/reference/v2/captures-api/get-capture
|
| 17 |
-
*/
|
| 18 |
-
|
| 19 |
-
$payment = $mollie->payments->get('tr_WDqYK6vllg');
|
| 20 |
-
$capture = $payment->getCapture('cpt_4qqhO89gsT');
|
| 21 |
-
|
| 22 |
-
$amount = $capture->amount->currency . ' ' . $capture->amount->value;
|
| 23 |
-
|
| 24 |
-
echo 'Captured ' . $amount;
|
| 25 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 26 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 27 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/captures/list-captures.php
DELETED
|
@@ -1,27 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* List captures for a payment using the Mollie API.
|
| 4 |
-
*/
|
| 5 |
-
|
| 6 |
-
try {
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your API key or OAuth access token.
|
| 9 |
-
*/
|
| 10 |
-
require "../initialize.php";
|
| 11 |
-
|
| 12 |
-
/*
|
| 13 |
-
* List captures for payment with ID 'tr_WDqYK6vllg'.
|
| 14 |
-
*
|
| 15 |
-
* See: https://docs.mollie.com/reference/v2/captures-api/list-captures
|
| 16 |
-
*/
|
| 17 |
-
|
| 18 |
-
$payment = $mollie->payments->get('tr_WDqYK6vllg');
|
| 19 |
-
$captures = $payment->captures();
|
| 20 |
-
|
| 21 |
-
foreach ($captures as $capture) {
|
| 22 |
-
$amount = $capture->amount->currency . ' ' . $capture->amount->value;
|
| 23 |
-
echo 'Captured ' . $amount . ' for payment ' . $payment->id;
|
| 24 |
-
}
|
| 25 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 26 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 27 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/customers/create-customer-first-payment.php
DELETED
|
@@ -1,67 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* How to create a first payment to allow recurring payments later.
|
| 4 |
-
*/
|
| 5 |
-
|
| 6 |
-
try {
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your API key or OAuth access token.
|
| 9 |
-
*/
|
| 10 |
-
require "../initialize.php";
|
| 11 |
-
|
| 12 |
-
/*
|
| 13 |
-
* Retrieve the last created customer for this example.
|
| 14 |
-
* If no customers are created yet, run the create-customer example.
|
| 15 |
-
*/
|
| 16 |
-
$customer = $mollie->customers->page(null, 1)[0];
|
| 17 |
-
|
| 18 |
-
/*
|
| 19 |
-
* Generate a unique order id for this example. It is important to include this unique attribute
|
| 20 |
-
* in the redirectUrl (below) so a proper return page can be shown to the customer.
|
| 21 |
-
*/
|
| 22 |
-
$orderId = time();
|
| 23 |
-
|
| 24 |
-
/*
|
| 25 |
-
* Determine the url parts to these example files.
|
| 26 |
-
*/
|
| 27 |
-
$protocol = isset($_SERVER['HTTPS']) && strcasecmp('off', $_SERVER['HTTPS']) !== 0 ? "https" : "http";
|
| 28 |
-
$hostname = $_SERVER['HTTP_HOST'];
|
| 29 |
-
$path = dirname(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : $_SERVER['PHP_SELF']);
|
| 30 |
-
|
| 31 |
-
/**
|
| 32 |
-
* Customer Payment creation parameters.
|
| 33 |
-
*
|
| 34 |
-
* @See: https://docs.mollie.com/reference/v2/customers-api/create-customer-payment
|
| 35 |
-
*/
|
| 36 |
-
$payment = $customer->createPayment([
|
| 37 |
-
"amount" => [
|
| 38 |
-
"value" => "10.00", // You must send the correct number of decimals, thus we enforce the use of strings
|
| 39 |
-
"currency" => "EUR"
|
| 40 |
-
],
|
| 41 |
-
"description" => "First payment - Order #{$orderId}",
|
| 42 |
-
"redirectUrl" => "{$protocol}://{$hostname}{$path}/payments/return.php?order_id={$orderId}",
|
| 43 |
-
"webhookUrl" => "{$protocol}://{$hostname}{$path}/payments/webhook.php",
|
| 44 |
-
"metadata" => [
|
| 45 |
-
"order_id" => $orderId,
|
| 46 |
-
],
|
| 47 |
-
|
| 48 |
-
// Flag this payment as a first payment to allow recurring payments later.
|
| 49 |
-
"sequenceType" => \Mollie\Api\Types\SequenceType::SEQUENCETYPE_FIRST,
|
| 50 |
-
]);
|
| 51 |
-
|
| 52 |
-
/*
|
| 53 |
-
* In this example we store the order with its payment status in a database.
|
| 54 |
-
*/
|
| 55 |
-
database_write($orderId, $payment->status);
|
| 56 |
-
|
| 57 |
-
/*
|
| 58 |
-
* Send the customer off to complete the payment.
|
| 59 |
-
* This request should always be a GET, thus we enforce 303 http response code
|
| 60 |
-
*
|
| 61 |
-
* After completion, the customer will have a pending or valid mandate that can be
|
| 62 |
-
* used for recurring payments and subscriptions.
|
| 63 |
-
*/
|
| 64 |
-
header("Location: " . $payment->getCheckoutUrl(), true, 303);
|
| 65 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 66 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 67 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/customers/create-customer-payment.php
DELETED
|
@@ -1,61 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* How to create a new customer in the Mollie API.
|
| 4 |
-
*/
|
| 5 |
-
|
| 6 |
-
try {
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your API key or OAuth access token.
|
| 9 |
-
*/
|
| 10 |
-
require "../initialize.php";
|
| 11 |
-
|
| 12 |
-
/*
|
| 13 |
-
* Retrieve the last created customer for this example.
|
| 14 |
-
* If no customers are created yet, run create-customer example.
|
| 15 |
-
*/
|
| 16 |
-
$customer = $mollie->customers->page(null, 1)[0];
|
| 17 |
-
|
| 18 |
-
/*
|
| 19 |
-
* Generate a unique order id for this example. It is important to include this unique attribute
|
| 20 |
-
* in the redirectUrl (below) so a proper return page can be shown to the customer.
|
| 21 |
-
*/
|
| 22 |
-
$orderId = time();
|
| 23 |
-
|
| 24 |
-
/*
|
| 25 |
-
* Determine the url parts to these example files.
|
| 26 |
-
*/
|
| 27 |
-
$protocol = isset($_SERVER['HTTPS']) && strcasecmp('off', $_SERVER['HTTPS']) !== 0 ? "https" : "http";
|
| 28 |
-
$hostname = $_SERVER['HTTP_HOST'];
|
| 29 |
-
$path = dirname(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : $_SERVER['PHP_SELF']);
|
| 30 |
-
|
| 31 |
-
/**
|
| 32 |
-
* Linking customers to payments has a few benefits
|
| 33 |
-
*
|
| 34 |
-
* @see https://docs.mollie.com/reference/v2/customers-api/create-customer-payment
|
| 35 |
-
*/
|
| 36 |
-
$payment = $customer->createPayment([
|
| 37 |
-
"amount" => [
|
| 38 |
-
"value" => "10.00", // You must send the correct number of decimals, thus we enforce the use of strings
|
| 39 |
-
"currency" => "EUR"
|
| 40 |
-
],
|
| 41 |
-
"description" => "Order #{$orderId}",
|
| 42 |
-
"redirectUrl" => "{$protocol}://{$hostname}{$path}/payments/return.php?order_id={$orderId}",
|
| 43 |
-
"webhookUrl" => "{$protocol}://{$hostname}{$path}/payments/webhook.php",
|
| 44 |
-
"metadata" => [
|
| 45 |
-
"order_id" => $orderId,
|
| 46 |
-
]
|
| 47 |
-
]);
|
| 48 |
-
|
| 49 |
-
/*
|
| 50 |
-
* In this example we store the order with its payment status in a database.
|
| 51 |
-
*/
|
| 52 |
-
database_write($orderId, $payment->status);
|
| 53 |
-
|
| 54 |
-
/*
|
| 55 |
-
* Send the customer off to complete the payment.
|
| 56 |
-
* This request should always be a GET, thus we enforce 303 http response code
|
| 57 |
-
*/
|
| 58 |
-
header("Location: " . $payment->getCheckoutUrl(), true, 303);
|
| 59 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 60 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 61 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/customers/create-customer-recurring-payment.php
DELETED
|
@@ -1,63 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* How to create an on-demand recurring payment.
|
| 4 |
-
*/
|
| 5 |
-
|
| 6 |
-
try {
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your API key or OAuth access token.
|
| 9 |
-
*/
|
| 10 |
-
require "../initialize.php";
|
| 11 |
-
|
| 12 |
-
/*
|
| 13 |
-
* Retrieve the last created customer for this example.
|
| 14 |
-
* If no customers are created yet, run the create-customer example.
|
| 15 |
-
*/
|
| 16 |
-
$customer = $mollie->customers->page(null, 1)[0];
|
| 17 |
-
|
| 18 |
-
/*
|
| 19 |
-
* Generate a unique order id for this example.
|
| 20 |
-
*/
|
| 21 |
-
$orderId = time();
|
| 22 |
-
|
| 23 |
-
/*
|
| 24 |
-
* Determine the url parts to these example files.
|
| 25 |
-
*/
|
| 26 |
-
$protocol = isset($_SERVER['HTTPS']) && strcasecmp('off', $_SERVER['HTTPS']) !== 0 ? "https" : "http";
|
| 27 |
-
$hostname = $_SERVER['HTTP_HOST'];
|
| 28 |
-
$path = dirname(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : $_SERVER['PHP_SELF']);
|
| 29 |
-
|
| 30 |
-
/**
|
| 31 |
-
* Customer Payment creation parameters.
|
| 32 |
-
*
|
| 33 |
-
* @See: https://docs.mollie.com/reference/v2/customers-api/create-customer-payment
|
| 34 |
-
*/
|
| 35 |
-
$payment = $customer->createPayment([
|
| 36 |
-
"amount" => [
|
| 37 |
-
"value" => "10.00", // You must send the correct number of decimals, thus we enforce the use of strings
|
| 38 |
-
"currency" => "EUR"
|
| 39 |
-
],
|
| 40 |
-
"description" => "On-demand payment - Order #{$orderId}",
|
| 41 |
-
"webhookUrl" => "{$protocol}://{$hostname}{$path}/payments/webhook.php",
|
| 42 |
-
"metadata" => [
|
| 43 |
-
"order_id" => $orderId,
|
| 44 |
-
],
|
| 45 |
-
|
| 46 |
-
// Flag this payment as a recurring payment.
|
| 47 |
-
"sequenceType" => \Mollie\Api\Types\SequenceType::SEQUENCETYPE_RECURRING,
|
| 48 |
-
]);
|
| 49 |
-
|
| 50 |
-
/*
|
| 51 |
-
* In this example we store the order with its payment status in a database.
|
| 52 |
-
*/
|
| 53 |
-
database_write($orderId, $payment->status);
|
| 54 |
-
|
| 55 |
-
/*
|
| 56 |
-
* The payment will be either pending or paid immediately. The customer
|
| 57 |
-
* does not have to perform any payment steps.
|
| 58 |
-
*/
|
| 59 |
-
echo "<p>Selected mandate is '" . htmlspecialchars($payment->mandateId) . "' (" . htmlspecialchars($payment->method) . ").</p>\n";
|
| 60 |
-
echo "<p>The payment status is '" . htmlspecialchars($payment->status) . "'.</p>\n";
|
| 61 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 62 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 63 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/customers/create-customer.php
DELETED
|
@@ -1,27 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* How to create a new customer in the Mollie API.
|
| 4 |
-
*/
|
| 5 |
-
|
| 6 |
-
try {
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your API key or OAuth access token.
|
| 9 |
-
*/
|
| 10 |
-
require "../initialize.php";
|
| 11 |
-
|
| 12 |
-
/**
|
| 13 |
-
* Customer creation parameters.
|
| 14 |
-
*
|
| 15 |
-
* @See https://docs.mollie.com/reference/v2/customers-api/create-customer
|
| 16 |
-
*/
|
| 17 |
-
$customer = $mollie->customers->create([
|
| 18 |
-
"name" => "Luke Skywalker",
|
| 19 |
-
"email" => "luke@example.org",
|
| 20 |
-
"metadata" => [
|
| 21 |
-
"isJedi" => TRUE,
|
| 22 |
-
],
|
| 23 |
-
]);
|
| 24 |
-
echo "<p>New customer created " . htmlspecialchars($customer->id) . " (" . htmlspecialchars($customer->name) . ").</p>";
|
| 25 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 26 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 27 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/customers/delete-customer.php
DELETED
|
@@ -1,17 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* Delete a customer from the Mollie API.
|
| 4 |
-
*/
|
| 5 |
-
|
| 6 |
-
try {
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your API key or OAuth access token.
|
| 9 |
-
*/
|
| 10 |
-
require "../initialize.php";
|
| 11 |
-
|
| 12 |
-
$mollie->customers->delete("cst_fE3F6nvX");
|
| 13 |
-
echo "<p>Customer deleted!</p>";
|
| 14 |
-
|
| 15 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 16 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 17 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/customers/list-customer-payments.php
DELETED
|
@@ -1,58 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* How to retrieve your customers' payments history.
|
| 4 |
-
*/
|
| 5 |
-
|
| 6 |
-
try {
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your API key.
|
| 9 |
-
*
|
| 10 |
-
* See: https://www.mollie.com/dashboard/developers/api-keys
|
| 11 |
-
*/
|
| 12 |
-
require "../initialize.php";
|
| 13 |
-
|
| 14 |
-
/*
|
| 15 |
-
* Determine the url parts to these example files.
|
| 16 |
-
*/
|
| 17 |
-
$protocol = isset($_SERVER['HTTPS']) && strcasecmp('off', $_SERVER['HTTPS']) !== 0 ? "https" : "http";
|
| 18 |
-
$hostname = $_SERVER['HTTP_HOST'];
|
| 19 |
-
$path = dirname(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : $_SERVER['PHP_SELF']);
|
| 20 |
-
|
| 21 |
-
/*
|
| 22 |
-
* Retrieve the last created customer for this example.
|
| 23 |
-
* If no customers are created yet, run create-customer example.
|
| 24 |
-
*/
|
| 25 |
-
$customer = $mollie->customers->page(null, 1)[0];
|
| 26 |
-
|
| 27 |
-
/*
|
| 28 |
-
* Get the all payments for this API key ordered by newest.
|
| 29 |
-
*/
|
| 30 |
-
$payments = $customer->payments();
|
| 31 |
-
|
| 32 |
-
echo "<ul>";
|
| 33 |
-
foreach ($payments as $payment) {
|
| 34 |
-
echo "<li>";
|
| 35 |
-
echo "<strong style='font-family: monospace'>" . htmlspecialchars($payment->id) . "</strong><br />";
|
| 36 |
-
echo htmlspecialchars($payment->description) . "<br />";
|
| 37 |
-
echo htmlspecialchars($payment->amount->currency) . " " . htmlspecialchars($payment->amount->value) . "<br />";
|
| 38 |
-
|
| 39 |
-
echo "Status: " . htmlspecialchars($payment->status) . "<br />";
|
| 40 |
-
|
| 41 |
-
if ($payment->hasRefunds()) {
|
| 42 |
-
echo "Payment has been (partially) refunded.<br />";
|
| 43 |
-
}
|
| 44 |
-
|
| 45 |
-
if ($payment->hasChargebacks()) {
|
| 46 |
-
echo "Payment has been charged back.<br />";
|
| 47 |
-
}
|
| 48 |
-
|
| 49 |
-
if ($payment->canBeRefunded() && $payment->amountRemaining->currency === 'EUR' && $payment->amountRemaining->value >= '2.00') {
|
| 50 |
-
echo " (<a href=\"{$protocol}://{$hostname}{$path}/payments/refund-payment.php?payment_id=" . htmlspecialchars($payment->id) . "\">refund</a>)";
|
| 51 |
-
}
|
| 52 |
-
|
| 53 |
-
echo "</li>";
|
| 54 |
-
}
|
| 55 |
-
echo "</ul>";
|
| 56 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 57 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 58 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/customers/update-customer.php
DELETED
|
@@ -1,31 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* Updating an existing customer via the Mollie API.
|
| 4 |
-
*/
|
| 5 |
-
|
| 6 |
-
try {
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your API key or OAuth access token.
|
| 9 |
-
*/
|
| 10 |
-
require "../initialize.php";
|
| 11 |
-
|
| 12 |
-
/*
|
| 13 |
-
* Retrieve an existing customer by his customerId
|
| 14 |
-
*/
|
| 15 |
-
$customer = $mollie->customers->get("cst_cUe8HjeBuz");
|
| 16 |
-
|
| 17 |
-
/**
|
| 18 |
-
* Customer fields that can be updated.
|
| 19 |
-
*
|
| 20 |
-
* @See https://docs.mollie.com/reference/v2/customers-api/update-customer
|
| 21 |
-
*/
|
| 22 |
-
$customer->name = "Luke Sky";
|
| 23 |
-
$customer->email = "luke@example.org";
|
| 24 |
-
$customer->locale = "en_US";
|
| 25 |
-
$customer->metadata->isJedi = TRUE;
|
| 26 |
-
$customer->update();
|
| 27 |
-
|
| 28 |
-
echo "<p>Customer updated: " . htmlspecialchars($customer->name) . "</p>";
|
| 29 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 30 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/database/.gitignore
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
*.txt
|
|
|
includes/mollie-api-php/examples/functions.php
DELETED
|
@@ -1,23 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* NOTE: The examples are using a text file as a database.
|
| 4 |
-
* Please use a real database like MySQL in production code.
|
| 5 |
-
*/
|
| 6 |
-
|
| 7 |
-
function database_read($orderId)
|
| 8 |
-
{
|
| 9 |
-
$orderId = intval($orderId);
|
| 10 |
-
$database = dirname(__FILE__) . "/database/order-{$orderId}.txt";
|
| 11 |
-
|
| 12 |
-
$status = @file_get_contents($database);
|
| 13 |
-
|
| 14 |
-
return $status ? $status : "unknown order";
|
| 15 |
-
}
|
| 16 |
-
|
| 17 |
-
function database_write($orderId, $status)
|
| 18 |
-
{
|
| 19 |
-
$orderId = intval($orderId);
|
| 20 |
-
$database = dirname(__FILE__) . "/database/order-{$orderId}.txt";
|
| 21 |
-
|
| 22 |
-
file_put_contents($database, $status);
|
| 23 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/initialize.php
DELETED
|
@@ -1,18 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* Make sure to disable the display of errors in production code!
|
| 4 |
-
*/
|
| 5 |
-
ini_set('display_errors', 1);
|
| 6 |
-
ini_set('display_startup_errors', 1);
|
| 7 |
-
error_reporting(E_ALL);
|
| 8 |
-
|
| 9 |
-
require_once __DIR__ . "/../vendor/autoload.php";
|
| 10 |
-
require_once __DIR__ . "/functions.php";
|
| 11 |
-
|
| 12 |
-
/*
|
| 13 |
-
* Initialize the Mollie API library with your API key.
|
| 14 |
-
*
|
| 15 |
-
* See: https://www.mollie.com/dashboard/developers/api-keys
|
| 16 |
-
*/
|
| 17 |
-
$mollie = new \Mollie\Api\MollieApiClient();
|
| 18 |
-
$mollie->setApiKey("test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/initialize_with_oauth.php
DELETED
|
@@ -1,19 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
/*
|
| 4 |
-
* Make sure to disable the display of errors in production code!
|
| 5 |
-
*/
|
| 6 |
-
ini_set('display_errors', 1);
|
| 7 |
-
ini_set('display_startup_errors', 1);
|
| 8 |
-
error_reporting(E_ALL);
|
| 9 |
-
|
| 10 |
-
require_once __DIR__ . "/../vendor/autoload.php";
|
| 11 |
-
require_once __DIR__ . "/functions.php";
|
| 12 |
-
|
| 13 |
-
/*
|
| 14 |
-
* Initialize the Mollie API library with OAuth.
|
| 15 |
-
*
|
| 16 |
-
* See: https://docs.mollie.com/oauth/overview
|
| 17 |
-
*/
|
| 18 |
-
$mollie = new \Mollie\Api\MollieApiClient();
|
| 19 |
-
$mollie->setAccessToken("access_Wwvu7egPcJLLJ9Kb7J632x8wJ2zMeJ");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/invoices/list-invoices.php
DELETED
|
@@ -1,37 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* List the Mollie invoices.
|
| 4 |
-
*/
|
| 5 |
-
|
| 6 |
-
try {
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your API key or OAuth access token.
|
| 9 |
-
*/
|
| 10 |
-
require "../initialize_with_oauth.php";
|
| 11 |
-
|
| 12 |
-
/*
|
| 13 |
-
* Get all the activated methods for this API key.
|
| 14 |
-
*/
|
| 15 |
-
$invoices = $mollie->invoices->all();
|
| 16 |
-
foreach ($invoices as $invoice) {
|
| 17 |
-
echo '<li><b>Invoice ' . htmlspecialchars($invoice->reference) . ':</b> (' . htmlspecialchars($invoice->issuedAt) . ')';
|
| 18 |
-
echo '<br>Status: <b>' . $invoice->status;
|
| 19 |
-
echo '<table border="1"><tr><th>Period</th><th>Description</th><th>Count</th><th>VAT Percentage</th><th>Amount</th></tr>';
|
| 20 |
-
foreach ($invoice->lines as $line) {
|
| 21 |
-
echo '<tr>';
|
| 22 |
-
echo '<td>' . htmlspecialchars($line->period) . '</td>';
|
| 23 |
-
echo '<td>' . htmlspecialchars($line->description) . '</td>';
|
| 24 |
-
echo '<td align="right">' . htmlspecialchars($line->count) . '</td>';
|
| 25 |
-
echo '<td align="right">' . htmlspecialchars($line->vatPercentage) . '</td>';
|
| 26 |
-
echo '<td align="right">' . htmlspecialchars($line->amount->currency . " " . $line->amount->value) . '</td>';
|
| 27 |
-
echo '</tr>';
|
| 28 |
-
}
|
| 29 |
-
echo '<tr><th colspan="5" align="right">Gross Total</th><th align="right">' . htmlspecialchars($invoice->grossAmount->value . " " . $invoice->grossAmount->currency) . '</th></tr>';
|
| 30 |
-
echo '</table>';
|
| 31 |
-
echo '<a href="'. $invoice->_links->pdf->href .'" target="_blank">Click here to open PDF</a>';
|
| 32 |
-
echo '</li>';
|
| 33 |
-
}
|
| 34 |
-
|
| 35 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 36 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 37 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/mandates/create-mandate.php
DELETED
|
@@ -1,30 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* Create a customer mandate via the Mollie API.
|
| 4 |
-
*/
|
| 5 |
-
|
| 6 |
-
try {
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your API key or OAuth access token.
|
| 9 |
-
*/
|
| 10 |
-
require "../initialize.php";
|
| 11 |
-
|
| 12 |
-
/*
|
| 13 |
-
* Retrieve the last created customer for this example.
|
| 14 |
-
* If no customers are created yet, run create-customer example.
|
| 15 |
-
*/
|
| 16 |
-
$customer = $mollie->customers->page(null, 1)[0];
|
| 17 |
-
|
| 18 |
-
/*
|
| 19 |
-
* Create a SEPA Direct Debit mandate for the customer
|
| 20 |
-
*/
|
| 21 |
-
$mandate = $customer->createMandate([
|
| 22 |
-
"method" => \Mollie\Api\Types\MandateMethod::DIRECTDEBIT,
|
| 23 |
-
"consumerAccount" => 'NL34ABNA0243341423',
|
| 24 |
-
"consumerName" => 'B. A. Example',
|
| 25 |
-
]);
|
| 26 |
-
|
| 27 |
-
echo "<p>Mandate created with id " . $mandate->id . " for customer " . $customer->name . "</p>";
|
| 28 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 29 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 30 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/mandates/list-mandates.php
DELETED
|
@@ -1,28 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* List all customer mandates
|
| 4 |
-
*/
|
| 5 |
-
|
| 6 |
-
try {
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your API key or OAuth access token.
|
| 9 |
-
*/
|
| 10 |
-
require "../initialize.php";
|
| 11 |
-
|
| 12 |
-
/*
|
| 13 |
-
* Retrieve an existing customer by his customerId
|
| 14 |
-
*/
|
| 15 |
-
$customer = $mollie->customers->get("cst_cUa8HjKBus");
|
| 16 |
-
|
| 17 |
-
/*
|
| 18 |
-
* List the mandates of this customer
|
| 19 |
-
*/
|
| 20 |
-
echo "<ul>";
|
| 21 |
-
foreach ($customer->mandates() as $mandate) {
|
| 22 |
-
echo "<li>" . htmlspecialchars($mandate->id) . " - " . htmlspecialchars($mandate->method) . ": " . htmlspecialchars($mandate->status) . "</li>";
|
| 23 |
-
}
|
| 24 |
-
echo "</ul>";
|
| 25 |
-
|
| 26 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 27 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 28 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/mandates/revoke-mandate.php
DELETED
|
@@ -1,31 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* Revoke a customer mandate
|
| 4 |
-
*/
|
| 5 |
-
|
| 6 |
-
try {
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your API key or OAuth access token.
|
| 9 |
-
*/
|
| 10 |
-
require "../initialize.php";
|
| 11 |
-
|
| 12 |
-
/*
|
| 13 |
-
* Retrieve an existing customer by his customerId
|
| 14 |
-
*/
|
| 15 |
-
$customer = $mollie->customers->get("cst_cUa8HjKBus");
|
| 16 |
-
|
| 17 |
-
/*
|
| 18 |
-
* Retrieve an existing mandate by his mandateId
|
| 19 |
-
*/
|
| 20 |
-
$mandate = $customer->getMandate("mdt_pa3s7rGnrC");
|
| 21 |
-
|
| 22 |
-
/*
|
| 23 |
-
* Revoke the mandate
|
| 24 |
-
*/
|
| 25 |
-
$mandate->revoke();
|
| 26 |
-
|
| 27 |
-
echo "<p>Mandate has been successfully revoked.</p>";
|
| 28 |
-
|
| 29 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 30 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/orders/cancel-order-lines.php
DELETED
|
@@ -1,44 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* Cancel order lines using the Mollie API.
|
| 4 |
-
*/
|
| 5 |
-
|
| 6 |
-
try {
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your API key or OAuth access token.
|
| 9 |
-
*/
|
| 10 |
-
require "../initialize.php";
|
| 11 |
-
|
| 12 |
-
/*
|
| 13 |
-
* Cancel an order line with ID "odl_dgtxyl" for order ID "ord_8wmqcHMN4U"
|
| 14 |
-
*
|
| 15 |
-
* See: https://docs.mollie.com/reference/v2/orders-api/cancel-order-line
|
| 16 |
-
*/
|
| 17 |
-
|
| 18 |
-
$orderId = 'ord_8wmqcHMN4U';
|
| 19 |
-
$lineId = 'odl_dgtxyl';
|
| 20 |
-
|
| 21 |
-
$order = $mollie->orders->get($orderId);
|
| 22 |
-
$line = $order->lines()->get($lineId);
|
| 23 |
-
if ($line && $line->isCancelable) {
|
| 24 |
-
$order->cancelLines([
|
| 25 |
-
'lines' => [
|
| 26 |
-
[
|
| 27 |
-
'id' => $lineId,
|
| 28 |
-
'quantity' => 1, // optional parameter
|
| 29 |
-
]
|
| 30 |
-
],
|
| 31 |
-
]);
|
| 32 |
-
|
| 33 |
-
$updatedOrder = $mollie->orders->get($orderId);
|
| 34 |
-
|
| 35 |
-
echo 'Your order ' . $order->id . ' was updated:';
|
| 36 |
-
foreach ($order->lines as $line) {
|
| 37 |
-
echo $line->description . '. Status: <b>' . $line->status . '</b>.';
|
| 38 |
-
}
|
| 39 |
-
} else {
|
| 40 |
-
echo "Unable to cancel line " . $lineId . " for your order " . $orderId . ".";
|
| 41 |
-
}
|
| 42 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 43 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 44 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/orders/cancel-order.php
DELETED
|
@@ -1,26 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* Cancel an order using the Mollie API.
|
| 4 |
-
*/
|
| 5 |
-
|
| 6 |
-
try {
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your API key or OAuth access token.
|
| 9 |
-
*/
|
| 10 |
-
require "../initialize.php";
|
| 11 |
-
|
| 12 |
-
/*
|
| 13 |
-
* Cancel the order with ID "ord_pbjz8x"
|
| 14 |
-
*
|
| 15 |
-
* See: https://docs.mollie.com/reference/v2/orders-api/cancel-order
|
| 16 |
-
*/
|
| 17 |
-
$order = $mollie->orders->get("ord_pbjz8x");
|
| 18 |
-
if ($order->isCancelable) {
|
| 19 |
-
$canceledOrder = $order->cancel();
|
| 20 |
-
echo "Your order " . $order->id . " has been canceled.";
|
| 21 |
-
} else {
|
| 22 |
-
echo "Unable to cancel your order " . $order->id . ".";
|
| 23 |
-
}
|
| 24 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 25 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 26 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/orders/create-order.php
DELETED
|
@@ -1,118 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* How to create a new order in the Mollie API.
|
| 4 |
-
*/
|
| 5 |
-
|
| 6 |
-
try {
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your API key or OAuth access token.
|
| 9 |
-
*/
|
| 10 |
-
require "../initialize.php";
|
| 11 |
-
|
| 12 |
-
/*
|
| 13 |
-
* Generate a unique order id for this example. It is important to include this unique attribute
|
| 14 |
-
* in the redirectUrl (below) so a proper return page can be shown to the customer.
|
| 15 |
-
*/
|
| 16 |
-
$orderId = time();
|
| 17 |
-
|
| 18 |
-
/*
|
| 19 |
-
* Determine the url parts to these example files.
|
| 20 |
-
*/
|
| 21 |
-
$protocol = isset($_SERVER['HTTPS']) && strcasecmp('off', $_SERVER['HTTPS']) !== 0 ? "https" : "http";
|
| 22 |
-
$hostname = $_SERVER['HTTP_HOST'];
|
| 23 |
-
$path = dirname(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : $_SERVER['PHP_SELF']);
|
| 24 |
-
|
| 25 |
-
/*
|
| 26 |
-
* Order creation parameters.
|
| 27 |
-
*
|
| 28 |
-
* See: https://docs.mollie.com/reference/v2/orders-api/create-order
|
| 29 |
-
*/
|
| 30 |
-
$order = $mollie->orders->create([
|
| 31 |
-
"amount" => [
|
| 32 |
-
"value" => "1027.99",
|
| 33 |
-
"currency" => "EUR"
|
| 34 |
-
],
|
| 35 |
-
"billingAddress" => [
|
| 36 |
-
"streetAndNumber" => "Keizersgracht 313",
|
| 37 |
-
"postalCode" => "1016 EE",
|
| 38 |
-
"city" => "Amsterdam",
|
| 39 |
-
"country" => "nl",
|
| 40 |
-
"givenName" => "Luke",
|
| 41 |
-
"familyName" => "Skywalker",
|
| 42 |
-
"email" => "luke@skywalker.com",
|
| 43 |
-
],
|
| 44 |
-
"shippingAddress" => [
|
| 45 |
-
"streetAndNumber" => "Keizersgracht 313",
|
| 46 |
-
"postalCode" => "1016 EE",
|
| 47 |
-
"city" => "Amsterdam",
|
| 48 |
-
"country" => "nl",
|
| 49 |
-
"givenName" => "Luke",
|
| 50 |
-
"familyName" => "Skywalker",
|
| 51 |
-
"email" => "luke@skywalker.com",
|
| 52 |
-
],
|
| 53 |
-
"metadata" => [
|
| 54 |
-
"order_id" => $orderId
|
| 55 |
-
],
|
| 56 |
-
"consumerDateOfBirth" => "1958-01-31",
|
| 57 |
-
"locale" => "en_US",
|
| 58 |
-
"orderNumber" => strval($orderId),
|
| 59 |
-
"redirectUrl" => "{$protocol}://{$hostname}{$path}/orders/return.php?order_id={$orderId}",
|
| 60 |
-
"webhookUrl" => "{$protocol}://{$hostname}{$path}/orders/webhook.php",
|
| 61 |
-
"method" => "ideal",
|
| 62 |
-
"lines" => [
|
| 63 |
-
[
|
| 64 |
-
"sku" => "5702016116977",
|
| 65 |
-
"name" => "LEGO 42083 Bugatti Chiron",
|
| 66 |
-
"productUrl" => "https://shop.lego.com/nl-NL/Bugatti-Chiron-42083",
|
| 67 |
-
"imageUrl" => 'https://sh-s7-live-s.legocdn.com/is/image//LEGO/42083_alt1?$main$',
|
| 68 |
-
"quantity" => 2,
|
| 69 |
-
"vatRate" => "21.00",
|
| 70 |
-
"unitPrice" => [
|
| 71 |
-
"currency" => "EUR",
|
| 72 |
-
"value" => "399.00"
|
| 73 |
-
],
|
| 74 |
-
"totalAmount" => [
|
| 75 |
-
"currency" => "EUR",
|
| 76 |
-
"value" => "698.00"
|
| 77 |
-
],
|
| 78 |
-
"discountAmount" => [
|
| 79 |
-
"currency" => "EUR",
|
| 80 |
-
"value" => "100.00"
|
| 81 |
-
],
|
| 82 |
-
"vatAmount" => [
|
| 83 |
-
"currency" => "EUR",
|
| 84 |
-
"value" => "121.14"
|
| 85 |
-
]
|
| 86 |
-
],
|
| 87 |
-
[
|
| 88 |
-
"type" => "digital",
|
| 89 |
-
"sku" => "5702015594028",
|
| 90 |
-
"name" => "LEGO 42056 Porsche 911 GT3 RS",
|
| 91 |
-
"productUrl" => "https://shop.lego.com/nl-NL/Porsche-911-GT3-RS-42056",
|
| 92 |
-
"imageUrl" => 'https://sh-s7-live-s.legocdn.com/is/image/LEGO/42056?$PDPDefault$',
|
| 93 |
-
"quantity" => 1,
|
| 94 |
-
"vatRate" => "21.00",
|
| 95 |
-
"unitPrice" => [
|
| 96 |
-
"currency" => "EUR",
|
| 97 |
-
"value" => "329.99"
|
| 98 |
-
],
|
| 99 |
-
"totalAmount" => [
|
| 100 |
-
"currency" => "EUR",
|
| 101 |
-
"value" => "329.99"
|
| 102 |
-
],
|
| 103 |
-
"vatAmount" => [
|
| 104 |
-
"currency" => "EUR",
|
| 105 |
-
"value" => "57.27"
|
| 106 |
-
]
|
| 107 |
-
]
|
| 108 |
-
]
|
| 109 |
-
]);
|
| 110 |
-
|
| 111 |
-
/*
|
| 112 |
-
* Send the customer off to complete the order payment.
|
| 113 |
-
* This request should always be a GET, thus we enforce 303 http response code
|
| 114 |
-
*/
|
| 115 |
-
header("Location: " . $order->getCheckoutUrl(), true, 303);
|
| 116 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 117 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 118 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/orders/list-methods.php
DELETED
|
@@ -1,28 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* How to get the currently activated payment methods for the Orders API.
|
| 4 |
-
*/
|
| 5 |
-
|
| 6 |
-
try {
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your API key.
|
| 9 |
-
*
|
| 10 |
-
* See: https://www.mollie.com/dashboard/developers/api-keys
|
| 11 |
-
*/
|
| 12 |
-
require "../initialize.php";
|
| 13 |
-
|
| 14 |
-
/*
|
| 15 |
-
* Get all the activated methods for this API key.
|
| 16 |
-
* To get methods that are compatible with the Orders API
|
| 17 |
-
* we are passing the 'resource' parameter.
|
| 18 |
-
*/
|
| 19 |
-
$methods = $mollie->methods->all(['resource' => 'orders']);
|
| 20 |
-
foreach ($methods as $method) {
|
| 21 |
-
echo '<div style="line-height:40px; vertical-align:top">';
|
| 22 |
-
echo '<img src="' . htmlspecialchars($method->image->size1x) . '" srcset="' . htmlspecialchars($method->image->size2x) . ' 2x"> ';
|
| 23 |
-
echo htmlspecialchars($method->description) . ' (' . htmlspecialchars($method->id) . ')';
|
| 24 |
-
echo '</div>';
|
| 25 |
-
}
|
| 26 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 27 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 28 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/orders/list-orders.php
DELETED
|
@@ -1,49 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* List orders using the Mollie API.
|
| 4 |
-
*/
|
| 5 |
-
|
| 6 |
-
use Mollie\Api\Resources\OrderCollection;
|
| 7 |
-
|
| 8 |
-
try {
|
| 9 |
-
/*
|
| 10 |
-
* Initialize the Mollie API library with your API key or OAuth access token.
|
| 11 |
-
*/
|
| 12 |
-
require "../initialize.php";
|
| 13 |
-
|
| 14 |
-
/*
|
| 15 |
-
* List the most recent orders
|
| 16 |
-
*
|
| 17 |
-
* See: https://docs.mollie.com/reference/v2/orders-api/list-orders
|
| 18 |
-
*/
|
| 19 |
-
echo '<ul>';
|
| 20 |
-
$latestOrders = $mollie->orders->page();
|
| 21 |
-
printOrders($latestOrders);
|
| 22 |
-
|
| 23 |
-
$previousOrders = $latestOrders->next();
|
| 24 |
-
printOrders($previousOrders);
|
| 25 |
-
echo '</ul>';
|
| 26 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 27 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 28 |
-
}
|
| 29 |
-
|
| 30 |
-
function printOrders($orders)
|
| 31 |
-
{
|
| 32 |
-
if (empty($orders)) {
|
| 33 |
-
return ;
|
| 34 |
-
}
|
| 35 |
-
|
| 36 |
-
foreach ($orders as $order) {
|
| 37 |
-
echo '<li><b>Order ' . htmlspecialchars($order->id) . ':</b> (' . htmlspecialchars($order->createdAt) . ')';
|
| 38 |
-
echo '<br>Status: <b>' . htmlspecialchars($order->status);
|
| 39 |
-
echo '<table border="1"><tr><th>Billed to</th><th>Shipped to</th><th>Total amount</th></tr>';
|
| 40 |
-
echo '<tr>';
|
| 41 |
-
echo '<td>' . htmlspecialchars($order->shippingAddress->givenName) . ' ' . htmlspecialchars($order->shippingAddress->familyName) . '</td>';
|
| 42 |
-
echo '<td>' . htmlspecialchars($order->billingAddress->givenName) . ' ' . htmlspecialchars($order->billingAddress->familyName) . '</td>';
|
| 43 |
-
echo '<td>' . htmlspecialchars($order->amount->currency) . str_replace('.', ',', htmlspecialchars($order->amount->value)) . '</td>';
|
| 44 |
-
echo '</tr>';
|
| 45 |
-
echo '</table>';
|
| 46 |
-
echo '<a href="'. $order->getCheckoutUrl() .'" target="_blank">Click here to pay</a>';
|
| 47 |
-
echo '</li>';
|
| 48 |
-
}
|
| 49 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/orders/refund-order-completely.php
DELETED
|
@@ -1,25 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* Refund all eligible items for an order using the Mollie API.
|
| 4 |
-
*/
|
| 5 |
-
|
| 6 |
-
try {
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your API key or OAuth access token.
|
| 9 |
-
*/
|
| 10 |
-
require "../initialize.php";
|
| 11 |
-
|
| 12 |
-
/*
|
| 13 |
-
* Refund all eligible items for an order with ID "ord_8wmqcHMN4U".
|
| 14 |
-
*
|
| 15 |
-
* See: https://docs.mollie.com/reference/v2/orders-api/create-order-refund
|
| 16 |
-
*/
|
| 17 |
-
|
| 18 |
-
$order = $mollie->orders->get('ord_8wmqcHMN4U');
|
| 19 |
-
$refund = $order->refundAll();
|
| 20 |
-
|
| 21 |
-
echo 'Refund ' . $refund->id . ' was created for order ' . $order->id;
|
| 22 |
-
echo 'You will receive ' . $refund->amount->currency . $refund->amount->value;
|
| 23 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 24 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 25 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/orders/refund-order-partially.php
DELETED
|
@@ -1,33 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* Refund some items for an order using the Mollie API.
|
| 4 |
-
*/
|
| 5 |
-
|
| 6 |
-
try {
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your API key or OAuth access token.
|
| 9 |
-
*/
|
| 10 |
-
require "../initialize.php";
|
| 11 |
-
|
| 12 |
-
/*
|
| 13 |
-
* Refund 1 item of order line "odl_dgtxyl" for an order with ID "ord_8wmqcHMN4U".
|
| 14 |
-
*
|
| 15 |
-
* See: https://docs.mollie.com/reference/v2/orders-api/create-order-refund
|
| 16 |
-
*/
|
| 17 |
-
|
| 18 |
-
$order = $mollie->orders->get('ord_8wmqcHMN4U');
|
| 19 |
-
$refund = $order->refund([
|
| 20 |
-
'lines' => [
|
| 21 |
-
[
|
| 22 |
-
'id' => 'odl_dgtxyl',
|
| 23 |
-
'quantity' => 1,
|
| 24 |
-
]
|
| 25 |
-
],
|
| 26 |
-
"description" => "Required quantity not in stock, refunding one photo book.",
|
| 27 |
-
]);
|
| 28 |
-
|
| 29 |
-
echo 'Refund ' . $refund->id . ' was created for part of your order ' . $order->id;
|
| 30 |
-
echo 'You will receive ' . $refund->amount->currency . $refund->amount->value;
|
| 31 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 32 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 33 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/orders/webhook.php
DELETED
|
@@ -1,50 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* Handle an order status change using the Mollie API.
|
| 4 |
-
*/
|
| 5 |
-
|
| 6 |
-
try {
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your API key or OAuth access token.
|
| 9 |
-
*/
|
| 10 |
-
require "../initialize.php";
|
| 11 |
-
|
| 12 |
-
/*
|
| 13 |
-
* After your webhook has been called with the order ID in its body, you'd like
|
| 14 |
-
* to handle the order's status change. This is how you can do that.
|
| 15 |
-
*
|
| 16 |
-
* See: https://docs.mollie.com/reference/v2/orders-api/get-order
|
| 17 |
-
*/
|
| 18 |
-
$order = $mollie->orders->get($_POST["id"]);
|
| 19 |
-
$orderId = $order->metadata->order_id;
|
| 20 |
-
|
| 21 |
-
/*
|
| 22 |
-
* Update the order in the database.
|
| 23 |
-
*/
|
| 24 |
-
database_write($orderId, $order->status);
|
| 25 |
-
|
| 26 |
-
if ($order->isPaid() || $order->isAuthorized()) {
|
| 27 |
-
/*
|
| 28 |
-
* The order is paid or authorized
|
| 29 |
-
* At this point you'd probably want to start the process of delivering the product to the customer.
|
| 30 |
-
*/
|
| 31 |
-
} elseif ($order->isCanceled()) {
|
| 32 |
-
/*
|
| 33 |
-
* The order is canceled.
|
| 34 |
-
*/
|
| 35 |
-
} elseif ($order->isExpired()) {
|
| 36 |
-
/*
|
| 37 |
-
* The order is expired.
|
| 38 |
-
*/
|
| 39 |
-
} elseif ($order->isCompleted()) {
|
| 40 |
-
/*
|
| 41 |
-
* The order is completed.
|
| 42 |
-
*/
|
| 43 |
-
} elseif ($order->isPending()) {
|
| 44 |
-
/*
|
| 45 |
-
* The order is pending.
|
| 46 |
-
*/
|
| 47 |
-
}
|
| 48 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 49 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 50 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/payments/create-ideal-payment.php
DELETED
|
@@ -1,81 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* How to prepare an iDEAL payment with the Mollie API.
|
| 4 |
-
*/
|
| 5 |
-
|
| 6 |
-
try {
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your API key.
|
| 9 |
-
*
|
| 10 |
-
* See: https://www.mollie.com/dashboard/developers/api-keys
|
| 11 |
-
*/
|
| 12 |
-
require "../initialize.php";
|
| 13 |
-
|
| 14 |
-
/*
|
| 15 |
-
* First, let the customer pick the bank in a simple HTML form. This step is actually optional.
|
| 16 |
-
*/
|
| 17 |
-
if ($_SERVER["REQUEST_METHOD"] != "POST") {
|
| 18 |
-
$method = $mollie->methods->get(\Mollie\Api\Types\PaymentMethod::IDEAL, ["include" => "issuers"]);
|
| 19 |
-
|
| 20 |
-
echo '<form method="post">Select your bank: <select name="issuer">';
|
| 21 |
-
|
| 22 |
-
foreach ($method->issuers() as $issuer) {
|
| 23 |
-
echo '<option value=' . htmlspecialchars($issuer->id) . '>' . htmlspecialchars($issuer->name) . '</option>';
|
| 24 |
-
}
|
| 25 |
-
|
| 26 |
-
echo '<option value="">or select later</option>';
|
| 27 |
-
echo '</select><button>OK</button></form>';
|
| 28 |
-
exit;
|
| 29 |
-
}
|
| 30 |
-
|
| 31 |
-
/*
|
| 32 |
-
* Generate a unique order id for this example. It is important to include this unique attribute
|
| 33 |
-
* in the redirectUrl (below) so a proper return page can be shown to the customer.
|
| 34 |
-
*/
|
| 35 |
-
$orderId = time();
|
| 36 |
-
|
| 37 |
-
/*
|
| 38 |
-
* Determine the url parts to these example files.
|
| 39 |
-
*/
|
| 40 |
-
$protocol = isset($_SERVER['HTTPS']) && strcasecmp('off', $_SERVER['HTTPS']) !== 0 ? "https" : "http";
|
| 41 |
-
$hostname = $_SERVER['HTTP_HOST'];
|
| 42 |
-
$path = dirname(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : $_SERVER['PHP_SELF']);
|
| 43 |
-
|
| 44 |
-
/*
|
| 45 |
-
* Payment parameters:
|
| 46 |
-
* amount Amount in EUROs. This example creates a € 27.50 payment.
|
| 47 |
-
* method Payment method "ideal".
|
| 48 |
-
* description Description of the payment.
|
| 49 |
-
* redirectUrl Redirect location. The customer will be redirected there after the payment.
|
| 50 |
-
* webhookUrl Webhook location, used to report when the payment changes state.
|
| 51 |
-
* metadata Custom metadata that is stored with the payment.
|
| 52 |
-
* issuer The customer's bank. If empty the customer can select it later.
|
| 53 |
-
*/
|
| 54 |
-
$payment = $mollie->payments->create([
|
| 55 |
-
"amount" => [
|
| 56 |
-
"currency" => "EUR",
|
| 57 |
-
"value" => "27.50" // You must send the correct number of decimals, thus we enforce the use of strings
|
| 58 |
-
],
|
| 59 |
-
"method" => \Mollie\Api\Types\PaymentMethod::IDEAL,
|
| 60 |
-
"description" => "Order #{$orderId}",
|
| 61 |
-
"redirectUrl" => "{$protocol}://{$hostname}{$path}/payments/return.php?order_id={$orderId}",
|
| 62 |
-
"webhookUrl" => "{$protocol}://{$hostname}{$path}/payments/webhook.php",
|
| 63 |
-
"metadata" => [
|
| 64 |
-
"order_id" => $orderId,
|
| 65 |
-
],
|
| 66 |
-
"issuer" => !empty($_POST["issuer"]) ? $_POST["issuer"] : null
|
| 67 |
-
]);
|
| 68 |
-
|
| 69 |
-
/*
|
| 70 |
-
* In this example we store the order with its payment status in a database.
|
| 71 |
-
*/
|
| 72 |
-
database_write($orderId, $payment->status);
|
| 73 |
-
|
| 74 |
-
/*
|
| 75 |
-
* Send the customer off to complete the payment.
|
| 76 |
-
* This request should always be a GET, thus we enforce 303 http response code
|
| 77 |
-
*/
|
| 78 |
-
header("Location: " . $payment->getCheckoutUrl(), true, 303);
|
| 79 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 80 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 81 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/payments/create-payment-oauth.php
DELETED
|
@@ -1,67 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* Example 10 - Using OAuth access token to prepare a new payment.
|
| 4 |
-
*/
|
| 5 |
-
try
|
| 6 |
-
{
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your OAuth access token.
|
| 9 |
-
*/
|
| 10 |
-
require "../initialize_with_oauth.php";
|
| 11 |
-
/*
|
| 12 |
-
* Generate a unique order id for this example. It is important to include this unique attribute
|
| 13 |
-
* in the redirectUrl (below) so a proper return page can be shown to the customer.
|
| 14 |
-
*/
|
| 15 |
-
$orderId = time();
|
| 16 |
-
/*
|
| 17 |
-
* Determine the url parts to these example files.
|
| 18 |
-
*/
|
| 19 |
-
$protocol = isset($_SERVER['HTTPS']) && strcasecmp('off', $_SERVER['HTTPS']) !== 0 ? "https" : "http";
|
| 20 |
-
$hostname = $_SERVER['HTTP_HOST'] ? : "my.app";
|
| 21 |
-
$path = dirname(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : $_SERVER['PHP_SELF']);
|
| 22 |
-
/*
|
| 23 |
-
* Since unlike an API key the OAuth access token does NOT belong to a profile, we need to retrieve a profile
|
| 24 |
-
* so we can specify the profileId-parameter when creating a payment below.
|
| 25 |
-
*/
|
| 26 |
-
$profiles = $mollie->profiles->page();
|
| 27 |
-
$profile = reset($profiles);
|
| 28 |
-
|
| 29 |
-
/**
|
| 30 |
-
* Paramaters for creating a payment via oAuth
|
| 31 |
-
*
|
| 32 |
-
* @See https://docs.mollie.com/reference/v2/payments-api/create-payment
|
| 33 |
-
*/
|
| 34 |
-
$payment = $mollie->payments->create([
|
| 35 |
-
"amount" => [
|
| 36 |
-
"value" => "10.00",
|
| 37 |
-
"currency" => "EUR"
|
| 38 |
-
],
|
| 39 |
-
"description" => "My first API payment",
|
| 40 |
-
"redirectUrl" => "{$protocol}://{$hostname}{$path}/payments/return.php?order_id={$orderId}",
|
| 41 |
-
"webhookUrl" => "{$protocol}://{$hostname}{$path}/payments/webhook.php",
|
| 42 |
-
"metadata" => [
|
| 43 |
-
"order_id" => $orderId,
|
| 44 |
-
],
|
| 45 |
-
"profileId" => $profile->id // This is specifically necessary for payment resources via OAuth access.
|
| 46 |
-
]);
|
| 47 |
-
|
| 48 |
-
/*
|
| 49 |
-
* In this example we store the order with its payment status in a database.
|
| 50 |
-
*/
|
| 51 |
-
database_write($orderId, $payment->status);
|
| 52 |
-
|
| 53 |
-
/*
|
| 54 |
-
* Send the customer off to complete the payment.
|
| 55 |
-
* This request should always be a GET, thus we enforce 303 http response code
|
| 56 |
-
*/
|
| 57 |
-
if (PHP_SAPI === "cli")
|
| 58 |
-
{
|
| 59 |
-
echo "Redirect to: " . $payment->getCheckoutUrl() . PHP_EOL;
|
| 60 |
-
return;
|
| 61 |
-
}
|
| 62 |
-
header("Location: " . $payment->getCheckoutUrl(), true, 303);
|
| 63 |
-
}
|
| 64 |
-
catch (\Mollie\Api\Exceptions\ApiException $e)
|
| 65 |
-
{
|
| 66 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 67 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/payments/create-payment.php
DELETED
|
@@ -1,60 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* How to prepare a new payment with the Mollie API.
|
| 4 |
-
*/
|
| 5 |
-
|
| 6 |
-
try {
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your API key.
|
| 9 |
-
*
|
| 10 |
-
* See: https://www.mollie.com/dashboard/developers/api-keys
|
| 11 |
-
*/
|
| 12 |
-
require "../initialize.php";
|
| 13 |
-
|
| 14 |
-
/*
|
| 15 |
-
* Generate a unique order id for this example. It is important to include this unique attribute
|
| 16 |
-
* in the redirectUrl (below) so a proper return page can be shown to the customer.
|
| 17 |
-
*/
|
| 18 |
-
$orderId = time();
|
| 19 |
-
|
| 20 |
-
/*
|
| 21 |
-
* Determine the url parts to these example files.
|
| 22 |
-
*/
|
| 23 |
-
$protocol = isset($_SERVER['HTTPS']) && strcasecmp('off', $_SERVER['HTTPS']) !== 0 ? "https" : "http";
|
| 24 |
-
$hostname = $_SERVER['HTTP_HOST'];
|
| 25 |
-
$path = dirname(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : $_SERVER['PHP_SELF']);
|
| 26 |
-
|
| 27 |
-
/*
|
| 28 |
-
* Payment parameters:
|
| 29 |
-
* amount Amount in EUROs. This example creates a € 10,- payment.
|
| 30 |
-
* description Description of the payment.
|
| 31 |
-
* redirectUrl Redirect location. The customer will be redirected there after the payment.
|
| 32 |
-
* webhookUrl Webhook location, used to report when the payment changes state.
|
| 33 |
-
* metadata Custom metadata that is stored with the payment.
|
| 34 |
-
*/
|
| 35 |
-
$payment = $mollie->payments->create([
|
| 36 |
-
"amount" => [
|
| 37 |
-
"currency" => "EUR",
|
| 38 |
-
"value" => "10.00" // You must send the correct number of decimals, thus we enforce the use of strings
|
| 39 |
-
],
|
| 40 |
-
"description" => "Order #{$orderId}",
|
| 41 |
-
"redirectUrl" => "{$protocol}://{$hostname}{$path}/payments/return.php?order_id={$orderId}",
|
| 42 |
-
"webhookUrl" => "{$protocol}://{$hostname}{$path}/payments/webhook.php",
|
| 43 |
-
"metadata" => [
|
| 44 |
-
"order_id" => $orderId,
|
| 45 |
-
],
|
| 46 |
-
]);
|
| 47 |
-
|
| 48 |
-
/*
|
| 49 |
-
* In this example we store the order with its payment status in a database.
|
| 50 |
-
*/
|
| 51 |
-
database_write($orderId, $payment->status);
|
| 52 |
-
|
| 53 |
-
/*
|
| 54 |
-
* Send the customer off to complete the payment.
|
| 55 |
-
* This request should always be a GET, thus we enforce 303 http response code
|
| 56 |
-
*/
|
| 57 |
-
header("Location: " . $payment->getCheckoutUrl(), true, 303);
|
| 58 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 59 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 60 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/payments/list-methods.php
DELETED
|
@@ -1,27 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* How to get the currently activated payment methods for the Payments API.
|
| 4 |
-
*/
|
| 5 |
-
|
| 6 |
-
try {
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your API key.
|
| 9 |
-
*
|
| 10 |
-
* See: https://www.mollie.com/dashboard/developers/api-keys
|
| 11 |
-
*/
|
| 12 |
-
require "../initialize.php";
|
| 13 |
-
/*
|
| 14 |
-
* Get all the activated methods for this API key.
|
| 15 |
-
* By default we are using the resource "payments".
|
| 16 |
-
* See the orders folder for an example with the Orders API.
|
| 17 |
-
*/
|
| 18 |
-
$methods = $mollie->methods->all();
|
| 19 |
-
foreach ($methods as $method) {
|
| 20 |
-
echo '<div style="line-height:40px; vertical-align:top">';
|
| 21 |
-
echo '<img src="' . htmlspecialchars($method->image->size1x) . '" srcset="' . htmlspecialchars($method->image->size2x) . ' 2x"> ';
|
| 22 |
-
echo htmlspecialchars($method->description) . ' (' . htmlspecialchars($method->id) . ')';
|
| 23 |
-
echo '</div>';
|
| 24 |
-
}
|
| 25 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 26 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 27 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/payments/list-payments.php
DELETED
|
@@ -1,85 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* How to list your payments.
|
| 4 |
-
*/
|
| 5 |
-
|
| 6 |
-
try {
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your API key.
|
| 9 |
-
*
|
| 10 |
-
* See: https://www.mollie.com/dashboard/developers/api-keys
|
| 11 |
-
*/
|
| 12 |
-
require "../initialize.php";
|
| 13 |
-
|
| 14 |
-
/*
|
| 15 |
-
* Determine the url parts to these example files.
|
| 16 |
-
*/
|
| 17 |
-
$protocol = isset($_SERVER['HTTPS']) && strcasecmp('off', $_SERVER['HTTPS']) !== 0 ? "https" : "http";
|
| 18 |
-
$hostname = $_SERVER['HTTP_HOST'];
|
| 19 |
-
$path = dirname(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : $_SERVER['PHP_SELF']);
|
| 20 |
-
|
| 21 |
-
/*
|
| 22 |
-
* Get the all payments for this API key ordered by newest.
|
| 23 |
-
*/
|
| 24 |
-
$payments = $mollie->payments->page();
|
| 25 |
-
|
| 26 |
-
echo "<ul>";
|
| 27 |
-
foreach ($payments as $payment) {
|
| 28 |
-
echo "<li>";
|
| 29 |
-
echo "<strong style='font-family: monospace'>" . htmlspecialchars($payment->id) . "</strong><br />";
|
| 30 |
-
echo htmlspecialchars($payment->description) . "<br />";
|
| 31 |
-
echo htmlspecialchars($payment->amount->currency) . " " . htmlspecialchars($payment->amount->value) . "<br />";
|
| 32 |
-
|
| 33 |
-
echo "Status: " . htmlspecialchars($payment->status) . "<br />";
|
| 34 |
-
|
| 35 |
-
if ($payment->hasRefunds()) {
|
| 36 |
-
echo "Payment has been (partially) refunded.<br />";
|
| 37 |
-
}
|
| 38 |
-
|
| 39 |
-
if ($payment->hasChargebacks()) {
|
| 40 |
-
echo "Payment has been charged back.<br />";
|
| 41 |
-
}
|
| 42 |
-
|
| 43 |
-
if ($payment->canBeRefunded() && $payment->amountRemaining->currency === 'EUR' && $payment->amountRemaining->value >= '2.00') {
|
| 44 |
-
echo " (<a href=\"{$protocol}://{$hostname}{$path}/payments/refund-payment.php?payment_id=" . htmlspecialchars($payment->id) . "\">refund</a>)";
|
| 45 |
-
}
|
| 46 |
-
|
| 47 |
-
echo "</li>";
|
| 48 |
-
}
|
| 49 |
-
echo "</ul>";
|
| 50 |
-
|
| 51 |
-
/**
|
| 52 |
-
* Get the next set of Payments if applicable
|
| 53 |
-
*/
|
| 54 |
-
$nextPayments = $payments->next();
|
| 55 |
-
|
| 56 |
-
if (!empty($nextPayments)) {
|
| 57 |
-
echo "<ul>";
|
| 58 |
-
foreach ($nextPayments as $payment) {
|
| 59 |
-
echo "<li>";
|
| 60 |
-
echo "<strong style='font-family: monospace'>" . htmlspecialchars($payment->id) . "</strong><br />";
|
| 61 |
-
echo htmlspecialchars($payment->description) . "<br />";
|
| 62 |
-
echo htmlspecialchars($payment->amount->currency) . " " . htmlspecialchars($payment->amount->value) . "<br />";
|
| 63 |
-
|
| 64 |
-
echo "Status: " . htmlspecialchars($payment->status) . "<br />";
|
| 65 |
-
|
| 66 |
-
if ($payment->hasRefunds()) {
|
| 67 |
-
echo "Payment has been (partially) refunded.<br />";
|
| 68 |
-
}
|
| 69 |
-
|
| 70 |
-
if ($payment->hasChargebacks()) {
|
| 71 |
-
echo "Payment has been charged back.<br />";
|
| 72 |
-
}
|
| 73 |
-
|
| 74 |
-
if ($payment->canBeRefunded() && $payment->amountRemaining->currency === 'EUR' && $payment->amountRemaining->value >= '2.00') {
|
| 75 |
-
echo " (<a href=\"{$protocol}://{$hostname}{$path}/payments/refund-payment.php?payment_id=" . htmlspecialchars($payment->id) . "\">refund</a>)";
|
| 76 |
-
}
|
| 77 |
-
|
| 78 |
-
echo "</li>";
|
| 79 |
-
}
|
| 80 |
-
echo "</ul>";
|
| 81 |
-
}
|
| 82 |
-
|
| 83 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 84 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 85 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/payments/refund-payment.php
DELETED
|
@@ -1,71 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* How to refund a payment programmatically
|
| 4 |
-
*/
|
| 5 |
-
|
| 6 |
-
try {
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your API key.
|
| 9 |
-
*
|
| 10 |
-
* See: https://www.mollie.com/dashboard/developers/api-keys
|
| 11 |
-
*/
|
| 12 |
-
require "../initialize.php";
|
| 13 |
-
|
| 14 |
-
/*
|
| 15 |
-
* Determine the url parts to these example files.
|
| 16 |
-
*/
|
| 17 |
-
$protocol = isset($_SERVER['HTTPS']) && strcasecmp('off', $_SERVER['HTTPS']) !== 0 ? "https" : "http";
|
| 18 |
-
$hostname = $_SERVER['HTTP_HOST'];
|
| 19 |
-
$path = dirname(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : $_SERVER['PHP_SELF']);
|
| 20 |
-
|
| 21 |
-
if (isset($_GET['payment_id'])) {
|
| 22 |
-
/*
|
| 23 |
-
* Retrieve the payment you want to refund from the API.
|
| 24 |
-
*/
|
| 25 |
-
$paymentId = $_GET['payment_id'];
|
| 26 |
-
$payment = $mollie->payments->get($paymentId);
|
| 27 |
-
|
| 28 |
-
if ($payment->canBeRefunded() && $payment->amountRemaining->currency === 'EUR' && $payment->amountRemaining->value >= '2.00') {
|
| 29 |
-
/*
|
| 30 |
-
* Refund € 2,00 of the payment.
|
| 31 |
-
*
|
| 32 |
-
* https://docs.mollie.com/reference/v2/refunds-api/create-refund
|
| 33 |
-
*/
|
| 34 |
-
$refund = $payment->refund([
|
| 35 |
-
"amount" => [
|
| 36 |
-
"currency" => "EUR",
|
| 37 |
-
"value" => "2.00" // You must send the correct number of decimals, thus we enforce the use of strings
|
| 38 |
-
]
|
| 39 |
-
]);
|
| 40 |
-
|
| 41 |
-
echo "{$refund->amount->currency} {$refund->amount->value} of payment {$paymentId} refunded.", PHP_EOL;
|
| 42 |
-
} else {
|
| 43 |
-
echo "Payment {$paymentId} can not be refunded.", PHP_EOL;
|
| 44 |
-
}
|
| 45 |
-
|
| 46 |
-
/*
|
| 47 |
-
* Retrieve all refunds on a payment.
|
| 48 |
-
*/
|
| 49 |
-
echo "<ul>";
|
| 50 |
-
foreach ($payment->refunds() as $refund) {
|
| 51 |
-
echo "<li>";
|
| 52 |
-
echo "<strong style='font-family: monospace'>" . htmlspecialchars($refund->id) . "</strong><br />";
|
| 53 |
-
echo htmlspecialchars($refund->description) . "<br />";
|
| 54 |
-
echo htmlspecialchars($refund->amount->currency) . " " . htmlspecialchars($refund->amount->value) . "<br />";
|
| 55 |
-
echo "Status: " . htmlspecialchars($refund->status);
|
| 56 |
-
echo "</li>";
|
| 57 |
-
}
|
| 58 |
-
echo "</ul>";
|
| 59 |
-
}
|
| 60 |
-
|
| 61 |
-
echo "Refund payment: ";
|
| 62 |
-
echo "<form method='get'><input name='payment_id' value='tr_xxx'/><input type='submit' /></form>";
|
| 63 |
-
|
| 64 |
-
echo "<p>";
|
| 65 |
-
echo '<a href="' . $protocol . '://' . $hostname . $path . '/payments/create-payment.php">Create a payment</a><br>';
|
| 66 |
-
echo '<a href="' . $protocol . '://' . $hostname . $path . '/payments/create-ideal-payment.php">Create an iDEAL payment</a><br>';
|
| 67 |
-
echo '<a href="' . $protocol . '://' . $hostname . $path . '/payments/list-payments.php">List payments</a><br>';
|
| 68 |
-
echo "</p>";
|
| 69 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 70 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 71 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/payments/return.php
DELETED
|
@@ -1,29 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* How to show a return page to the customer.
|
| 4 |
-
*
|
| 5 |
-
* In this example we retrieve the order stored in the database.
|
| 6 |
-
* Here, it's unnecessary to use the Mollie API Client.
|
| 7 |
-
*/
|
| 8 |
-
|
| 9 |
-
/*
|
| 10 |
-
* NOTE: The examples are using a text file as a database.
|
| 11 |
-
* Please use a real database like MySQL in production code.
|
| 12 |
-
*/
|
| 13 |
-
require_once "../functions.php";
|
| 14 |
-
|
| 15 |
-
$status = database_read($_GET["order_id"]);
|
| 16 |
-
|
| 17 |
-
/*
|
| 18 |
-
* Determine the url parts to these example files.
|
| 19 |
-
*/
|
| 20 |
-
$protocol = isset($_SERVER['HTTPS']) && strcasecmp('off', $_SERVER['HTTPS']) !== 0 ? "https" : "http";
|
| 21 |
-
$hostname = $_SERVER['HTTP_HOST'];
|
| 22 |
-
$path = dirname(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : $_SERVER['PHP_SELF']);
|
| 23 |
-
|
| 24 |
-
echo "<p>Your payment status is '" . htmlspecialchars($status) . "'.</p>";
|
| 25 |
-
echo "<p>";
|
| 26 |
-
echo '<a href="' . $protocol . '://' . $hostname . $path . '/payments/create-payment.php">Create a payment</a><br>';
|
| 27 |
-
echo '<a href="' . $protocol . '://' . $hostname . $path . '/payments/create-ideal-payment.php">Create an iDEAL payment</a><br>';
|
| 28 |
-
echo '<a href="' . $protocol . '://' . $hostname . $path . '/payments/list-payments.php">List payments</a><br>';
|
| 29 |
-
echo "</p>";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/payments/webhook.php
DELETED
|
@@ -1,65 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* How to verify Mollie API Payments in a webhook.
|
| 4 |
-
*
|
| 5 |
-
* See: https://docs.mollie.com/guides/webhooks
|
| 6 |
-
*/
|
| 7 |
-
|
| 8 |
-
try {
|
| 9 |
-
/*
|
| 10 |
-
* Initialize the Mollie API library with your API key.
|
| 11 |
-
*
|
| 12 |
-
* See: https://www.mollie.com/dashboard/developers/api-keys
|
| 13 |
-
*/
|
| 14 |
-
require "../initialize.php";
|
| 15 |
-
|
| 16 |
-
/*
|
| 17 |
-
* Retrieve the payment's current state.
|
| 18 |
-
*/
|
| 19 |
-
$payment = $mollie->payments->get($_POST["id"]);
|
| 20 |
-
$orderId = $payment->metadata->order_id;
|
| 21 |
-
|
| 22 |
-
/*
|
| 23 |
-
* Update the order in the database.
|
| 24 |
-
*/
|
| 25 |
-
database_write($orderId, $payment->status);
|
| 26 |
-
|
| 27 |
-
if ($payment->isPaid() && !$payment->hasRefunds() && !$payment->hasChargebacks()) {
|
| 28 |
-
/*
|
| 29 |
-
* The payment is paid and isn't refunded or charged back.
|
| 30 |
-
* At this point you'd probably want to start the process of delivering the product to the customer.
|
| 31 |
-
*/
|
| 32 |
-
} elseif ($payment->isOpen()) {
|
| 33 |
-
/*
|
| 34 |
-
* The payment is open.
|
| 35 |
-
*/
|
| 36 |
-
} elseif ($payment->isPending()) {
|
| 37 |
-
/*
|
| 38 |
-
* The payment is pending.
|
| 39 |
-
*/
|
| 40 |
-
} elseif ($payment->isFailed()) {
|
| 41 |
-
/*
|
| 42 |
-
* The payment has failed.
|
| 43 |
-
*/
|
| 44 |
-
} elseif ($payment->isExpired()) {
|
| 45 |
-
/*
|
| 46 |
-
* The payment is expired.
|
| 47 |
-
*/
|
| 48 |
-
} elseif ($payment->isCanceled()) {
|
| 49 |
-
/*
|
| 50 |
-
* The payment has been canceled.
|
| 51 |
-
*/
|
| 52 |
-
} elseif ($payment->hasRefunds()) {
|
| 53 |
-
/*
|
| 54 |
-
* The payment has been (partially) refunded.
|
| 55 |
-
* The status of the payment is still "paid"
|
| 56 |
-
*/
|
| 57 |
-
} elseif ($payment->hasChargebacks()) {
|
| 58 |
-
/*
|
| 59 |
-
* The payment has been (partially) charged back.
|
| 60 |
-
* The status of the payment is still "paid"
|
| 61 |
-
*/
|
| 62 |
-
}
|
| 63 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 64 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 65 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/profiles/create-profile.php
DELETED
|
@@ -1,30 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* Create a profile via the Mollie API.
|
| 4 |
-
*/
|
| 5 |
-
try
|
| 6 |
-
{
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your API key or OAuth access token.
|
| 9 |
-
*/
|
| 10 |
-
require "../initialize_with_oauth.php";
|
| 11 |
-
|
| 12 |
-
/**
|
| 13 |
-
* Create the profile
|
| 14 |
-
*
|
| 15 |
-
* @See https://docs.mollie.com/reference/v2/profiles-api/create-profile
|
| 16 |
-
*/
|
| 17 |
-
$profile = $mollie->profiles->create([
|
| 18 |
-
"name" => "My website name",
|
| 19 |
-
"website" => "https://www.mywebsite.com",
|
| 20 |
-
"email" => "info@mywebsite.com",
|
| 21 |
-
"phone" => "+31208202070",
|
| 22 |
-
"categoryCode" => 5399,
|
| 23 |
-
"mode" => "live",
|
| 24 |
-
]);
|
| 25 |
-
echo "<p>Profile created: " . htmlspecialchars($profile->name) . "</p>";
|
| 26 |
-
}
|
| 27 |
-
catch (\Mollie\Api\Exceptions\ApiException $e)
|
| 28 |
-
{
|
| 29 |
-
echo "<p>API call failed: " . htmlspecialchars($e->getMessage()) . "</p>";
|
| 30 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/profiles/delete-profile.php
DELETED
|
@@ -1,23 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* Delete a profile via the Mollie API.
|
| 4 |
-
*/
|
| 5 |
-
try
|
| 6 |
-
{
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your API key or OAuth access token.
|
| 9 |
-
*/
|
| 10 |
-
require "../initialize_with_oauth.php";
|
| 11 |
-
|
| 12 |
-
/**
|
| 13 |
-
* Delete a profile via the profileId
|
| 14 |
-
*
|
| 15 |
-
* @See https://docs.mollie.com/reference/v2/profiles-api/delete-profile
|
| 16 |
-
*/
|
| 17 |
-
$profile = $mollie->profiles->delete("pfl_v9hTwCvYqw");
|
| 18 |
-
echo "<p>Profile deleted</p>";
|
| 19 |
-
}
|
| 20 |
-
catch (\Mollie\Api\Exceptions\ApiException $e)
|
| 21 |
-
{
|
| 22 |
-
echo "<p>API call failed: " . htmlspecialchars($e->getMessage()) . "</p>";
|
| 23 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/profiles/list-profiles.php
DELETED
|
@@ -1,28 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* Using OAuth access token to list profiles of an account.
|
| 4 |
-
*/
|
| 5 |
-
try
|
| 6 |
-
{
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your OAuth access token.
|
| 9 |
-
*/
|
| 10 |
-
require "../initialize_with_oauth.php";
|
| 11 |
-
|
| 12 |
-
/*
|
| 13 |
-
* Get the all the profiles for this account.
|
| 14 |
-
*/
|
| 15 |
-
$profiles = $mollie->profiles->page();
|
| 16 |
-
foreach ($profiles as $profile)
|
| 17 |
-
{
|
| 18 |
-
echo '<div style="line-height:40px; vertical-align:top">';
|
| 19 |
-
echo htmlspecialchars($profile->name) .
|
| 20 |
-
' - ' . htmlspecialchars($profile->website) .
|
| 21 |
-
' (' . htmlspecialchars($profile->id) . ')';
|
| 22 |
-
echo '</div>';
|
| 23 |
-
}
|
| 24 |
-
}
|
| 25 |
-
catch (\Mollie\Api\Exceptions\ApiException $e)
|
| 26 |
-
{
|
| 27 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 28 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/profiles/update-profile.php
DELETED
|
@@ -1,33 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* Updating an existing profile via the Mollie API.
|
| 4 |
-
*/
|
| 5 |
-
try
|
| 6 |
-
{
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your API key or OAuth access token.
|
| 9 |
-
*/
|
| 10 |
-
require "../initialize_with_oauth.php";
|
| 11 |
-
|
| 12 |
-
/*
|
| 13 |
-
* Retrieve an existing profile by his profileId
|
| 14 |
-
*/
|
| 15 |
-
$profile = $mollie->profiles->get("pfl_eA4MSz7Bvy");
|
| 16 |
-
|
| 17 |
-
/**
|
| 18 |
-
* Profile fields that can be updated.
|
| 19 |
-
*
|
| 20 |
-
* @See https://docs.mollie.com/reference/v2/profiles-api/update-profile
|
| 21 |
-
*/
|
| 22 |
-
$profile->name = "Mollie B.V.";
|
| 23 |
-
$profile->website = 'www.mollie.com';
|
| 24 |
-
$profile->email = 'info@mollie.com';
|
| 25 |
-
$profile->phone = '0612345670';
|
| 26 |
-
$profile->categoryCode = 5399;
|
| 27 |
-
$profile->update();
|
| 28 |
-
echo "<p>Profile updated: " . htmlspecialchars($profile->name) . "</p>";
|
| 29 |
-
}
|
| 30 |
-
catch (\Mollie\Api\Exceptions\ApiException $e)
|
| 31 |
-
{
|
| 32 |
-
echo "<p>API call failed: " . htmlspecialchars($e->getMessage()) . "</p>";
|
| 33 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/settlements/list-settlements.php
DELETED
|
@@ -1,53 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* Using OAuth access token to list settlements of an account.
|
| 4 |
-
*/
|
| 5 |
-
|
| 6 |
-
try {
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your OAuth access token.
|
| 9 |
-
*/
|
| 10 |
-
require "../initialize_with_oauth.php";
|
| 11 |
-
|
| 12 |
-
/*
|
| 13 |
-
* Get the all the settlements for this account.
|
| 14 |
-
*/
|
| 15 |
-
$settlements = $mollie->settlements->page();
|
| 16 |
-
echo '<ul>';
|
| 17 |
-
foreach ($settlements as $settlement) {
|
| 18 |
-
echo '<li><b>Settlement ' . htmlspecialchars($settlement->reference) . ':</b> (' . htmlspecialchars($settlement->createdAt) . ')';
|
| 19 |
-
echo '<table border="1"><tr><th>Month</th><th>Description</th><th>Count</th><th>Net</th><th>VAT</th><th>Gross</th></tr>';
|
| 20 |
-
// Convert from stdClass to array
|
| 21 |
-
$settlement_periods = json_decode(json_encode($settlement->periods), TRUE);
|
| 22 |
-
foreach ($settlement_periods as $year => $months) {
|
| 23 |
-
foreach ($months as $month => $monthly_settlement) {
|
| 24 |
-
foreach ($monthly_settlement['revenue'] as $revenue) {
|
| 25 |
-
echo '<tr>';
|
| 26 |
-
echo '<td>' . htmlspecialchars($year . '-' . $month) . '</td>';
|
| 27 |
-
echo '<td>' . htmlspecialchars($revenue['description']) . '</td>';
|
| 28 |
-
echo '<td align="right">' . htmlspecialchars($revenue['count']) . ' x</td>';
|
| 29 |
-
echo '<td align="right">' . htmlspecialchars($revenue['amountNet']['value'] ? $revenue['amountNet']['value'] . " " . $revenue['amountNet']['currency'] : '-') . '</td>';
|
| 30 |
-
echo '<td align="right">' . htmlspecialchars($revenue['amountVat']['value'] ? $revenue['amountVat']['value'] . " " . $revenue['amountVat']['currency'] : '-') . '</td>';
|
| 31 |
-
echo '<td align="right">' . htmlspecialchars($revenue['amountGross']['value'] ? $revenue['amountGross']['value'] . " " . $revenue['amountGross']['currency'] : '-') . '</td>';
|
| 32 |
-
echo '</tr>';
|
| 33 |
-
}
|
| 34 |
-
foreach ($monthly_settlement['costs'] as $revenue) {
|
| 35 |
-
echo '<tr>';
|
| 36 |
-
echo '<td>' . htmlspecialchars($year . '-' . $month) . '</td>';
|
| 37 |
-
echo '<td>' . htmlspecialchars($revenue['description']) . '</td>';
|
| 38 |
-
echo '<td align="right">' . htmlspecialchars($revenue['count']) . ' x</td>';
|
| 39 |
-
echo '<td align="right">' . htmlspecialchars($revenue['amountNet']['value'] ? $revenue['amountNet']['value'] . " " . $revenue['amountNet']['currency'] : '-') . '</td>';
|
| 40 |
-
echo '<td align="right">' . htmlspecialchars($revenue['amountVat']['value'] ? $revenue['amountVat']['value'] . " " . $revenue['amountVat']['currency'] : '-') . '</td>';
|
| 41 |
-
echo '<td align="right">' . htmlspecialchars($revenue['amountGross']['value'] ? $revenue['amountGross']['value'] . " " . $revenue['amountGross']['currency'] : '-') . '</td>';
|
| 42 |
-
echo '</tr>';
|
| 43 |
-
}
|
| 44 |
-
}
|
| 45 |
-
}
|
| 46 |
-
echo '<tr><th colspan="5" align="right">TOTAL</th><th align="right">' . htmlspecialchars($settlement->amount->value . " " . $settlement->amount->currency) . '</th></tr>';
|
| 47 |
-
echo '</table>';
|
| 48 |
-
echo '</li>';
|
| 49 |
-
}
|
| 50 |
-
echo '</ul>';
|
| 51 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 52 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 53 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/shipments/create-shipment-all.php
DELETED
|
@@ -1,27 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* Create a shipment for an entire order using the Mollie API.
|
| 4 |
-
*/
|
| 5 |
-
|
| 6 |
-
try {
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your API key or OAuth access token.
|
| 9 |
-
*/
|
| 10 |
-
require "../initialize.php";
|
| 11 |
-
|
| 12 |
-
/*
|
| 13 |
-
* Create a shipment for the entire order with ID "ord_8wmqcHMN4U"
|
| 14 |
-
*
|
| 15 |
-
* See: https://docs.mollie.com/reference/v2/shipments-api/create-shipment
|
| 16 |
-
*/
|
| 17 |
-
|
| 18 |
-
$order = $mollie->orders->get('ord_8wmqcHMN4U');
|
| 19 |
-
$shipment = $order->shipAll();
|
| 20 |
-
|
| 21 |
-
echo 'A shipment with ID ' . $shipment->id. ' has been created for your order with ID ' . $order->id . '.';
|
| 22 |
-
foreach ($shipment->lines as $line) {
|
| 23 |
-
echo $line->name . ' - status: <b>' . $line->status . '</b>.';
|
| 24 |
-
}
|
| 25 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 26 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 27 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/shipments/create-shipment-partial.php
DELETED
|
@@ -1,42 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* Example 32 - Create a shipment for part of an order using the Mollie API.
|
| 4 |
-
*/
|
| 5 |
-
|
| 6 |
-
try {
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your API key or OAuth access token.
|
| 9 |
-
*/
|
| 10 |
-
require "./initialize.php";
|
| 11 |
-
|
| 12 |
-
/*
|
| 13 |
-
* Create a shipment for only two lines of the order with ID "ord_8wmqcHMN4U".
|
| 14 |
-
*
|
| 15 |
-
* See: https://docs.mollie.com/reference/v2/shipments-api/create-shipment
|
| 16 |
-
*/
|
| 17 |
-
|
| 18 |
-
$order = $this->getOrder('ord_8wmqcHMN4U');
|
| 19 |
-
$lineId1 = $order->lines()[0]->id;
|
| 20 |
-
$lineId2 = $order->lines()[1]->id;
|
| 21 |
-
$shipment = $order->createShipment(
|
| 22 |
-
[
|
| 23 |
-
'lines' => [
|
| 24 |
-
[
|
| 25 |
-
'id' => $lineId1,
|
| 26 |
-
// assume all is shipped if no quantity is specified
|
| 27 |
-
],
|
| 28 |
-
[
|
| 29 |
-
'id' => $lineId2,
|
| 30 |
-
'quantity' => 1, // you can set the quantity if not all is shipped at once
|
| 31 |
-
],
|
| 32 |
-
],
|
| 33 |
-
]
|
| 34 |
-
);
|
| 35 |
-
|
| 36 |
-
echo 'A shipment with ID ' . $shipment->id. ' has been created for your order with ID ' . $order->id . '.';
|
| 37 |
-
foreach ($shipment->lines as $line) {
|
| 38 |
-
echo $line->name . '- status: <b>' . $line->status . '</b>.';
|
| 39 |
-
}
|
| 40 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 41 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 42 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/shipments/get-shipment.php
DELETED
|
@@ -1,27 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* Retrieve a shipment using the Mollie API.
|
| 4 |
-
*/
|
| 5 |
-
|
| 6 |
-
try {
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your API key or OAuth access token.
|
| 9 |
-
*/
|
| 10 |
-
require "../initialize.php";
|
| 11 |
-
|
| 12 |
-
/*
|
| 13 |
-
* Retrieve a shipment with ID "shp_3wmsgCJN4U" for the order with ID "ord_8wmqcHMN4U".
|
| 14 |
-
*
|
| 15 |
-
* See: https://docs.mollie.com/reference/v2/shipments-api/get-shipment
|
| 16 |
-
*/
|
| 17 |
-
|
| 18 |
-
$order = $mollie->orders->get('ord_8wmqcHMN4U');
|
| 19 |
-
$shipment = $order->getShipment("shp_3wmsgCJN4U");
|
| 20 |
-
|
| 21 |
-
echo 'Shipment with ID ' . $shipment->id. ' for order with ID ' . $order->id . '.';
|
| 22 |
-
foreach ($shipment->lines as $line) {
|
| 23 |
-
echo $line->name . ' - status: <b>' . $line->status . '</b>.';
|
| 24 |
-
}
|
| 25 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 26 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 27 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/shipments/list-shipments.php
DELETED
|
@@ -1,30 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* List shipment for an order using the Mollie API.
|
| 4 |
-
*/
|
| 5 |
-
|
| 6 |
-
try {
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your API key or OAuth access token.
|
| 9 |
-
*/
|
| 10 |
-
require "../initialize.php";
|
| 11 |
-
|
| 12 |
-
/*
|
| 13 |
-
* Listing shipments for the order with ID "ord_8wmqcHMN4U".
|
| 14 |
-
*
|
| 15 |
-
* See: https://docs.mollie.com/reference/v2/shipments-api/get-shipment
|
| 16 |
-
*/
|
| 17 |
-
|
| 18 |
-
$order = $mollie->orders->get('ord_8wmqcHMN4U');
|
| 19 |
-
$shipments = $order->shipments();
|
| 20 |
-
|
| 21 |
-
echo 'Shipments for order with ID ' . $order->id . ':';
|
| 22 |
-
foreach ($shipments as $shipment) {
|
| 23 |
-
echo 'Shipment ' . $shipment->id . '. Items:';
|
| 24 |
-
foreach ($shipment->lines as $line) {
|
| 25 |
-
echo $line->name . ' - status: <b>' . $line->status . '</b>.';
|
| 26 |
-
}
|
| 27 |
-
}
|
| 28 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 29 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 30 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/shipments/update-shipment.php
DELETED
|
@@ -1,40 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* Update shipment tracking information using the Mollie API.
|
| 4 |
-
*/
|
| 5 |
-
|
| 6 |
-
try {
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your API key or OAuth access token.
|
| 9 |
-
*/
|
| 10 |
-
require "../initialize.php";
|
| 11 |
-
|
| 12 |
-
/*
|
| 13 |
-
* Update the tracking information for a shipment with ID "shp_3wmsgCJN4U" and
|
| 14 |
-
* order ID "ord_8wmqcHMN4U"
|
| 15 |
-
*
|
| 16 |
-
* See: https://docs.mollie.com/reference/v2/shipments-api/update-shipment
|
| 17 |
-
*/
|
| 18 |
-
|
| 19 |
-
$order = $mollie->orders->get('ord_8wmqcHMN4U');
|
| 20 |
-
$shipment = $order->getShipment("shp_3wmsgCJN4U");
|
| 21 |
-
|
| 22 |
-
$shipment->tracking = [
|
| 23 |
-
'carrier' => 'PostNL',
|
| 24 |
-
'code' => '3SKABA000000000',
|
| 25 |
-
'url' => 'http://postnl.nl/tracktrace/?B=3SKABA000000000&P=1016EE&D=NL&T=C',
|
| 26 |
-
];
|
| 27 |
-
$shipment = $shipment->update();
|
| 28 |
-
|
| 29 |
-
echo 'Shipment with ID ' . $shipment->id. ' for order with ID ' . $order->id . '.';
|
| 30 |
-
echo 'Tracking information updated:';
|
| 31 |
-
echo 'Carrier: ' . $shipment->tracking->carrier;
|
| 32 |
-
echo 'Code: ' . $shipment->tracking->code;
|
| 33 |
-
echo 'Url: ' . $shipment->tracking->url;
|
| 34 |
-
|
| 35 |
-
foreach ($shipment->lines as $line) {
|
| 36 |
-
echo $line->name . ' - status: <b>' . $line->status . '</b>.';
|
| 37 |
-
}
|
| 38 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 39 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 40 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/subscriptions/cancel-subscription.php
DELETED
|
@@ -1,36 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* How to cancel a subscription.
|
| 4 |
-
*/
|
| 5 |
-
|
| 6 |
-
try {
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your API key or OAuth access token.
|
| 9 |
-
*/
|
| 10 |
-
require "../initialize.php";
|
| 11 |
-
|
| 12 |
-
/*
|
| 13 |
-
* Retrieve the last created customer for this example.
|
| 14 |
-
* If no customers are created yet, run the create-customer example.
|
| 15 |
-
*/
|
| 16 |
-
$customer = $mollie->customers->page(null, 1)[0];
|
| 17 |
-
|
| 18 |
-
/*
|
| 19 |
-
* The subscription ID, starting with sub_
|
| 20 |
-
*/
|
| 21 |
-
$subscriptionId = isset($_GET['subscription_id']) ? $_GET['subscription_id'] : '';
|
| 22 |
-
|
| 23 |
-
/*
|
| 24 |
-
* Customer Subscription deletion parameters.
|
| 25 |
-
*
|
| 26 |
-
* See: https://www.mollie.com/nl/docs/reference/subscriptions/delete
|
| 27 |
-
*/
|
| 28 |
-
$canceledSubscription = $customer->cancelSubscription($subscriptionId);
|
| 29 |
-
|
| 30 |
-
/*
|
| 31 |
-
* The subscription status should now be canceled
|
| 32 |
-
*/
|
| 33 |
-
echo "<p>The subscription status is now: '" . htmlspecialchars($canceledSubscription->status) . "'.</p>\n";
|
| 34 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 35 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 36 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/subscriptions/create-subscription.php
DELETED
|
@@ -1,61 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* How to create a regular subscription.
|
| 4 |
-
*/
|
| 5 |
-
|
| 6 |
-
try {
|
| 7 |
-
/*
|
| 8 |
-
* Initialize the Mollie API library with your API key or OAuth access token.
|
| 9 |
-
*/
|
| 10 |
-
require "../initialize.php";
|
| 11 |
-
|
| 12 |
-
/*
|
| 13 |
-
* Determine the url parts to these example files.
|
| 14 |
-
*/
|
| 15 |
-
$protocol = isset($_SERVER['HTTPS']) && strcasecmp('off', $_SERVER['HTTPS']) !== 0 ? "https" : "http";
|
| 16 |
-
$hostname = $_SERVER['HTTP_HOST'];
|
| 17 |
-
$path = dirname(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : $_SERVER['PHP_SELF']);
|
| 18 |
-
|
| 19 |
-
/*
|
| 20 |
-
* Retrieve the last created customer for this example.
|
| 21 |
-
* If no customers are created yet, run create-customer example.
|
| 22 |
-
*/
|
| 23 |
-
$customer = $mollie->customers->page(null, 1)[0];
|
| 24 |
-
|
| 25 |
-
/*
|
| 26 |
-
* Generate a unique subscription id for this example. It is important to include this unique attribute
|
| 27 |
-
* in the webhookUrl (below) so new payments can be associated with this subscription.
|
| 28 |
-
*/
|
| 29 |
-
$subscriptionId = time();
|
| 30 |
-
|
| 31 |
-
/**
|
| 32 |
-
* Customer Subscription creation parameters.
|
| 33 |
-
*
|
| 34 |
-
* @See: https://docs.mollie.com/reference/v2/subscriptions-api/create-subscription
|
| 35 |
-
*/
|
| 36 |
-
$subscription = $customer->createSubscription([
|
| 37 |
-
"amount" => [
|
| 38 |
-
"value" => "10.00", // You must send the correct number of decimals, thus we enforce the use of strings
|
| 39 |
-
"currency" => "EUR"
|
| 40 |
-
],
|
| 41 |
-
"times" => 12,
|
| 42 |
-
"interval" => "1 month",
|
| 43 |
-
"description" => "Subscription #{$subscriptionId}",
|
| 44 |
-
"webhookUrl" => "{$protocol}://{$hostname}{$path}/subscriptions/webhook.php",
|
| 45 |
-
"metadata" => [
|
| 46 |
-
"subscription_id" => $subscriptionId
|
| 47 |
-
],
|
| 48 |
-
]);
|
| 49 |
-
|
| 50 |
-
/*
|
| 51 |
-
* The subscription will be either pending or active depending on whether the customer has
|
| 52 |
-
* a pending or valid mandate. If the customer has no mandates an error is returned. You
|
| 53 |
-
* should then set up a "first payment" for the customer.
|
| 54 |
-
*/
|
| 55 |
-
echo "<p>The subscription status is '" . htmlspecialchars($subscription->status) . "'.</p>\n";
|
| 56 |
-
echo "<p>";
|
| 57 |
-
echo '<a href="' . $protocol . '://' . $hostname . $path . '/17-cancel-subscription.php?subscription_id=' . $subscription->id . '">18-cancel-subscription</a><br>';
|
| 58 |
-
echo "</p>";
|
| 59 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 60 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 61 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/examples/subscriptions/update-subscription.php
DELETED
|
@@ -1,31 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
* Updating an existing subscription via the Mollie API.
|
| 4 |
-
*/
|
| 5 |
-
try {
|
| 6 |
-
/*
|
| 7 |
-
* Initialize the Mollie API library with your API key or OAuth access token.
|
| 8 |
-
*/
|
| 9 |
-
require "../initialize.php";
|
| 10 |
-
|
| 11 |
-
/*
|
| 12 |
-
* Retrieve an existing subscription
|
| 13 |
-
*/
|
| 14 |
-
$customer = $mollie->customers->get("cst_cUe8HjeBuz");
|
| 15 |
-
$subscription = $customer->getSubscription("sub_DRjwaT5qHx");
|
| 16 |
-
|
| 17 |
-
/**
|
| 18 |
-
* Subscription fields that can be updated are described by the link:
|
| 19 |
-
* See https://docs.mollie.com/reference/v2/subscriptions-api/update-subscription
|
| 20 |
-
*/
|
| 21 |
-
$subscription->times = 10;
|
| 22 |
-
$subscription->startDate = '2018-12-02'; // Year-month-day
|
| 23 |
-
$subscription->amount = (object)['value' => '12.12', 'currency' => 'EUR'];
|
| 24 |
-
$subscription->webhookUrl = 'https://some-webhook-url.com/with/path';
|
| 25 |
-
$subscription->description = 'Monthly subscription';
|
| 26 |
-
$subscription->update();
|
| 27 |
-
|
| 28 |
-
echo "<p>Subscription updated: " . $subscription->id . "</p>";
|
| 29 |
-
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
| 30 |
-
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
| 31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/phpunit.xml
DELETED
|
@@ -1,15 +0,0 @@
|
|
| 1 |
-
<?xml version="1.0" encoding="UTF-8" ?>
|
| 2 |
-
<phpunit colors="true" bootstrap="./vendor/autoload.php">
|
| 3 |
-
<php>
|
| 4 |
-
<ini name="display_errors" value="stderr"/>
|
| 5 |
-
<ini name="error_log" value="/dev/null"/>
|
| 6 |
-
</php>
|
| 7 |
-
<testsuite name="Unit tests">
|
| 8 |
-
<directory>tests/</directory>
|
| 9 |
-
</testsuite>
|
| 10 |
-
<filter>
|
| 11 |
-
<whitelist processUncoveredFilesFromWhitelist="true">
|
| 12 |
-
<directory suffix=".php">src/</directory>
|
| 13 |
-
</whitelist>
|
| 14 |
-
</filter>
|
| 15 |
-
</phpunit>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/CompatibilityCheckerTest.php
DELETED
|
@@ -1,57 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
namespace Tests\Mollie\Api;
|
| 3 |
-
|
| 4 |
-
use Mollie\Api\CompatibilityChecker;
|
| 5 |
-
|
| 6 |
-
class CompatibilityCheckerTest extends \PHPUnit\Framework\TestCase
|
| 7 |
-
{
|
| 8 |
-
/**
|
| 9 |
-
* @var CompatibilityChecker|\PHPUnit_Framework_MockObject_MockObject
|
| 10 |
-
*/
|
| 11 |
-
protected $checker;
|
| 12 |
-
|
| 13 |
-
protected function setUp()
|
| 14 |
-
{
|
| 15 |
-
parent::setUp();
|
| 16 |
-
|
| 17 |
-
$this->checker = $this->getMockBuilder(CompatibilityChecker::class)
|
| 18 |
-
->setMethods([
|
| 19 |
-
"satisfiesPhpVersion",
|
| 20 |
-
"satisfiesJsonExtension",
|
| 21 |
-
])
|
| 22 |
-
->getMock();
|
| 23 |
-
}
|
| 24 |
-
|
| 25 |
-
/**
|
| 26 |
-
* @expectedException \Mollie\Api\Exceptions\IncompatiblePlatform
|
| 27 |
-
* @expectedExceptionCode Mollie\Api\Exceptions\IncompatiblePlatform::INCOMPATIBLE_PHP_VERSION
|
| 28 |
-
*/
|
| 29 |
-
public function testCheckCompatibilityThrowsExceptionOnPhpVersion()
|
| 30 |
-
{
|
| 31 |
-
$this->checker->expects($this->once())
|
| 32 |
-
->method("satisfiesPhpVersion")
|
| 33 |
-
->will($this->returnValue(false)); // Fail
|
| 34 |
-
|
| 35 |
-
$this->checker->expects($this->never())
|
| 36 |
-
->method("satisfiesJsonExtension");
|
| 37 |
-
|
| 38 |
-
$this->checker->checkCompatibility();
|
| 39 |
-
}
|
| 40 |
-
|
| 41 |
-
/**
|
| 42 |
-
* @expectedException \Mollie\Api\Exceptions\IncompatiblePlatform
|
| 43 |
-
* @expectedExceptionCode Mollie\Api\Exceptions\IncompatiblePlatform::INCOMPATIBLE_JSON_EXTENSION
|
| 44 |
-
*/
|
| 45 |
-
public function testCheckCompatibilityThrowsExceptionOnJsonExtension()
|
| 46 |
-
{
|
| 47 |
-
$this->checker->expects($this->once())
|
| 48 |
-
->method("satisfiesPhpVersion")
|
| 49 |
-
->will($this->returnValue(true));
|
| 50 |
-
|
| 51 |
-
$this->checker->expects($this->once())
|
| 52 |
-
->method("satisfiesJsonExtension")
|
| 53 |
-
->will($this->returnValue(false)); // Fail
|
| 54 |
-
|
| 55 |
-
$this->checker->checkCompatibility();
|
| 56 |
-
}
|
| 57 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Endpoints/BaseEndpointTest.php
DELETED
|
@@ -1,76 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\Api\Endpoints;
|
| 4 |
-
|
| 5 |
-
use GuzzleHttp\Client;
|
| 6 |
-
use GuzzleHttp\Psr7\Request;
|
| 7 |
-
use GuzzleHttp\Psr7\Response;
|
| 8 |
-
use Mollie\Api\MollieApiClient;
|
| 9 |
-
|
| 10 |
-
abstract class BaseEndpointTest extends \PHPUnit\Framework\TestCase
|
| 11 |
-
{
|
| 12 |
-
/**
|
| 13 |
-
* @var Client|\PHPUnit_Framework_MockObject_MockObject
|
| 14 |
-
*/
|
| 15 |
-
protected $guzzleClient;
|
| 16 |
-
|
| 17 |
-
/**
|
| 18 |
-
* @var MollieApiClient
|
| 19 |
-
*/
|
| 20 |
-
protected $apiClient;
|
| 21 |
-
|
| 22 |
-
protected function mockApiCall(Request $expectedRequest, Response $response, $oAuthClient = false)
|
| 23 |
-
{
|
| 24 |
-
$this->guzzleClient = $this->createMock(Client::class);
|
| 25 |
-
|
| 26 |
-
$this->apiClient = new MollieApiClient($this->guzzleClient);
|
| 27 |
-
|
| 28 |
-
if (!$oAuthClient) {
|
| 29 |
-
$this->apiClient->setApiKey("test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM");
|
| 30 |
-
} else {
|
| 31 |
-
$this->apiClient->setAccessToken("access_Wwvu7egPcJLLJ9Kb7J632x8wJ2zMeJ");
|
| 32 |
-
}
|
| 33 |
-
|
| 34 |
-
$this->guzzleClient
|
| 35 |
-
->expects($this->once())
|
| 36 |
-
->method('send')
|
| 37 |
-
->with($this->isInstanceOf(Request::class))
|
| 38 |
-
->willReturnCallback(function (Request $request) use ($expectedRequest, $response) {
|
| 39 |
-
$this->assertEquals($expectedRequest->getMethod(), $request->getMethod(), "HTTP method must be identical");
|
| 40 |
-
|
| 41 |
-
$this->assertEquals(
|
| 42 |
-
$expectedRequest->getUri()->getPath(),
|
| 43 |
-
$request->getUri()->getPath(),
|
| 44 |
-
"URI path must be identical"
|
| 45 |
-
);
|
| 46 |
-
|
| 47 |
-
$this->assertEquals(
|
| 48 |
-
$expectedRequest->getUri()->getQuery(),
|
| 49 |
-
$request->getUri()->getQuery(),
|
| 50 |
-
'Query string parameters must be identical'
|
| 51 |
-
);
|
| 52 |
-
|
| 53 |
-
$requestBody = $request->getBody()->getContents();
|
| 54 |
-
$expectedBody = $expectedRequest->getBody()->getContents();
|
| 55 |
-
|
| 56 |
-
if (strlen($expectedBody) > 0 && strlen($requestBody) > 0) {
|
| 57 |
-
$this->assertJsonStringEqualsJsonString(
|
| 58 |
-
$expectedBody,
|
| 59 |
-
$requestBody,
|
| 60 |
-
"HTTP body must be identical"
|
| 61 |
-
);
|
| 62 |
-
}
|
| 63 |
-
|
| 64 |
-
return $response;
|
| 65 |
-
});
|
| 66 |
-
}
|
| 67 |
-
|
| 68 |
-
protected function copy($array, $object)
|
| 69 |
-
{
|
| 70 |
-
foreach ($array as $property => $value) {
|
| 71 |
-
$object->$property = $value;
|
| 72 |
-
}
|
| 73 |
-
|
| 74 |
-
return $object;
|
| 75 |
-
}
|
| 76 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Endpoints/ChargebackEndpointTest.php
DELETED
|
@@ -1,156 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\Api\Endpoints;
|
| 4 |
-
|
| 5 |
-
use GuzzleHttp\Psr7\Request;
|
| 6 |
-
use GuzzleHttp\Psr7\Response;
|
| 7 |
-
use Mollie\Api\Resources\Chargeback;
|
| 8 |
-
use Mollie\Api\Resources\ChargebackCollection;
|
| 9 |
-
use Mollie\Api\Resources\Payment;
|
| 10 |
-
use Tests\Mollie\TestHelpers\AmountObjectTestHelpers;
|
| 11 |
-
use Tests\Mollie\TestHelpers\LinkObjectTestHelpers;
|
| 12 |
-
|
| 13 |
-
class ChargebackEndpointTest extends BaseEndpointTest
|
| 14 |
-
{
|
| 15 |
-
use LinkObjectTestHelpers;
|
| 16 |
-
use AmountObjectTestHelpers;
|
| 17 |
-
|
| 18 |
-
public function testListChargebacks()
|
| 19 |
-
{
|
| 20 |
-
$this->mockApiCall(
|
| 21 |
-
new Request(
|
| 22 |
-
"GET",
|
| 23 |
-
"/v2/chargebacks"
|
| 24 |
-
),
|
| 25 |
-
new Response(
|
| 26 |
-
200,
|
| 27 |
-
[],
|
| 28 |
-
'{
|
| 29 |
-
"_embedded":{
|
| 30 |
-
"chargebacks":[
|
| 31 |
-
{
|
| 32 |
-
"resource":"chargeback",
|
| 33 |
-
"id":"chb_n9z0tp",
|
| 34 |
-
"amount":{
|
| 35 |
-
"value":"-13.00",
|
| 36 |
-
"currency":"EUR"
|
| 37 |
-
},
|
| 38 |
-
"createdAt":"2018-03-28T11:44:32+00:00",
|
| 39 |
-
"paymentId":"tr_44aKxzEbr8",
|
| 40 |
-
"settlementAmount":{
|
| 41 |
-
"value":"-13.00",
|
| 42 |
-
"currency":"EUR"
|
| 43 |
-
},
|
| 44 |
-
"_links":{
|
| 45 |
-
"self":{
|
| 46 |
-
"href":"https://api.mollie.com/v2/payments/tr_44aKxzEbr8/chargebacks/chb_n9z0tp",
|
| 47 |
-
"type":"application/hal+json"
|
| 48 |
-
},
|
| 49 |
-
"payment":{
|
| 50 |
-
"href":"https://api.mollie.com/v2/payments/tr_44aKxzEbr8",
|
| 51 |
-
"type":"application/hal+json"
|
| 52 |
-
},
|
| 53 |
-
"documentation": {
|
| 54 |
-
"href": "https://docs.mollie.com/reference/v2/chargebacks-api/get-chargeback",
|
| 55 |
-
"type": "text/html"
|
| 56 |
-
}
|
| 57 |
-
}
|
| 58 |
-
},
|
| 59 |
-
{
|
| 60 |
-
"resource":"chargeback",
|
| 61 |
-
"id":"chb_6cqlwf",
|
| 62 |
-
"amount":{
|
| 63 |
-
"value":"-0.37",
|
| 64 |
-
"currency":"EUR"
|
| 65 |
-
},
|
| 66 |
-
"createdAt":"2018-03-28T11:44:32+00:00",
|
| 67 |
-
"paymentId":"tr_nQKWJbDj7j",
|
| 68 |
-
"settlementAmount":{
|
| 69 |
-
"value":"-0.37",
|
| 70 |
-
"currency":"EUR"
|
| 71 |
-
},
|
| 72 |
-
"_links":{
|
| 73 |
-
"self":{
|
| 74 |
-
"href":"https://api.mollie.com/v2/payments/tr_nQKWJbDj7j/chargebacks/chb_6cqlwf",
|
| 75 |
-
"type":"application/hal+json"
|
| 76 |
-
},
|
| 77 |
-
"payment":{
|
| 78 |
-
"href":"https://api.mollie.com/v2/payments/tr_nQKWJbDj7j",
|
| 79 |
-
"type":"application/hal+json"
|
| 80 |
-
},
|
| 81 |
-
"documentation": {
|
| 82 |
-
"href": "https://docs.mollie.com/reference/v2/chargebacks-api/get-chargeback",
|
| 83 |
-
"type": "text/html"
|
| 84 |
-
}
|
| 85 |
-
}
|
| 86 |
-
}
|
| 87 |
-
]
|
| 88 |
-
},
|
| 89 |
-
"_links":{
|
| 90 |
-
"documentation":{
|
| 91 |
-
"href":"https://docs.mollie.com/reference/v2/chargebacks-api/list-chargebacks",
|
| 92 |
-
"type":"text/html"
|
| 93 |
-
},
|
| 94 |
-
"self":{
|
| 95 |
-
"href":"https://api.mollie.com/v2/chargebacks",
|
| 96 |
-
"type":"application/hal+json"
|
| 97 |
-
}
|
| 98 |
-
},
|
| 99 |
-
"count": 2
|
| 100 |
-
}'
|
| 101 |
-
)
|
| 102 |
-
);
|
| 103 |
-
|
| 104 |
-
$chargebacks = $this->apiClient->chargebacks->page();
|
| 105 |
-
|
| 106 |
-
$this->assertInstanceOf(ChargebackCollection::class, $chargebacks);
|
| 107 |
-
$this->assertEquals(2, $chargebacks->count);
|
| 108 |
-
$this->assertCount(2, $chargebacks);
|
| 109 |
-
|
| 110 |
-
$this->assertLinkObject(
|
| 111 |
-
"https://docs.mollie.com/reference/v2/chargebacks-api/list-chargebacks",
|
| 112 |
-
"text/html",
|
| 113 |
-
$chargebacks->_links->documentation
|
| 114 |
-
);
|
| 115 |
-
|
| 116 |
-
$this->assertLinkObject(
|
| 117 |
-
"https://api.mollie.com/v2/chargebacks",
|
| 118 |
-
"application/hal+json",
|
| 119 |
-
$chargebacks->_links->self
|
| 120 |
-
);
|
| 121 |
-
|
| 122 |
-
$this->assertChargeback($chargebacks[0], 'tr_44aKxzEbr8', 'chb_n9z0tp', "-13.00");
|
| 123 |
-
$this->assertChargeback($chargebacks[1], 'tr_nQKWJbDj7j', 'chb_6cqlwf', "-0.37");
|
| 124 |
-
}
|
| 125 |
-
|
| 126 |
-
protected function assertChargeback($chargeback, $paymentId, $chargebackId, $amount)
|
| 127 |
-
{
|
| 128 |
-
$this->assertInstanceOf(Chargeback::class, $chargeback);
|
| 129 |
-
$this->assertEquals("chargeback", $chargeback->resource);
|
| 130 |
-
$this->assertEquals($chargebackId, $chargeback->id);
|
| 131 |
-
|
| 132 |
-
$this->assertAmountObject($amount, "EUR", $chargeback->amount);
|
| 133 |
-
$this->assertAmountObject($amount, "EUR", $chargeback->settlementAmount);
|
| 134 |
-
|
| 135 |
-
$this->assertEquals("2018-03-28T11:44:32+00:00", $chargeback->createdAt);
|
| 136 |
-
$this->assertEquals($paymentId, $chargeback->paymentId);
|
| 137 |
-
|
| 138 |
-
$this->assertLinkObject(
|
| 139 |
-
"https://api.mollie.com/v2/payments/{$paymentId}/chargebacks/{$chargebackId}",
|
| 140 |
-
"application/hal+json",
|
| 141 |
-
$chargeback->_links->self
|
| 142 |
-
);
|
| 143 |
-
|
| 144 |
-
$this->assertLinkObject(
|
| 145 |
-
"https://api.mollie.com/v2/payments/{$paymentId}",
|
| 146 |
-
"application/hal+json",
|
| 147 |
-
$chargeback->_links->payment
|
| 148 |
-
);
|
| 149 |
-
|
| 150 |
-
$this->assertLinkObject(
|
| 151 |
-
"https://docs.mollie.com/reference/v2/chargebacks-api/get-chargeback",
|
| 152 |
-
"text/html",
|
| 153 |
-
$chargeback->_links->documentation
|
| 154 |
-
);
|
| 155 |
-
}
|
| 156 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Endpoints/CustomerEndpointTest.php
DELETED
|
@@ -1,234 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\Api\Endpoints;
|
| 4 |
-
|
| 5 |
-
use GuzzleHttp\Psr7\Request;
|
| 6 |
-
use GuzzleHttp\Psr7\Response;
|
| 7 |
-
use Mollie\Api\Resources\Customer;
|
| 8 |
-
use Mollie\Api\Resources\CustomerCollection;
|
| 9 |
-
|
| 10 |
-
class CustomerEndpointTest extends BaseEndpointTest
|
| 11 |
-
{
|
| 12 |
-
public function testCreateWorks()
|
| 13 |
-
{
|
| 14 |
-
$this->mockApiCall(
|
| 15 |
-
new Request('POST', '/v2/customers'),
|
| 16 |
-
new Response(
|
| 17 |
-
200,
|
| 18 |
-
[],
|
| 19 |
-
'{
|
| 20 |
-
"resource": "customer",
|
| 21 |
-
"id": "cst_FhQJRw4s2n",
|
| 22 |
-
"mode": "test",
|
| 23 |
-
"name": "John Doe",
|
| 24 |
-
"email": "johndoe@example.org",
|
| 25 |
-
"locale": null,
|
| 26 |
-
"metadata": null,
|
| 27 |
-
"recentlyUsedMethods": [],
|
| 28 |
-
"createdAt": "2018-04-19T08:49:01+00:00",
|
| 29 |
-
"_links": {
|
| 30 |
-
"documentation": {
|
| 31 |
-
"href": "https://docs.mollie.com/reference/v2/customers-api/create-customer",
|
| 32 |
-
"type": "text/html"
|
| 33 |
-
}
|
| 34 |
-
}
|
| 35 |
-
}'
|
| 36 |
-
)
|
| 37 |
-
);
|
| 38 |
-
|
| 39 |
-
/** @var Customer $customer */
|
| 40 |
-
$customer = $this->apiClient->customers->create([
|
| 41 |
-
"name" => "John Doe",
|
| 42 |
-
"email" => "johndoe@example.org"
|
| 43 |
-
]);
|
| 44 |
-
|
| 45 |
-
$this->assertInstanceOf(Customer::class, $customer);
|
| 46 |
-
$this->assertEquals("customer", $customer->resource);
|
| 47 |
-
$this->assertEquals("cst_FhQJRw4s2n", $customer->id);
|
| 48 |
-
$this->assertEquals("John Doe", $customer->name);
|
| 49 |
-
$this->assertEquals("johndoe@example.org", $customer->email);
|
| 50 |
-
$this->assertNull($customer->locale);
|
| 51 |
-
$this->assertNull($customer->metadata);
|
| 52 |
-
$this->assertEquals([], $customer->recentlyUsedMethods);
|
| 53 |
-
$this->assertEquals("2018-04-19T08:49:01+00:00", $customer->createdAt);
|
| 54 |
-
|
| 55 |
-
$documentationLink = (object)["href" => "https://docs.mollie.com/reference/v2/customers-api/create-customer", "type" => "text/html"];
|
| 56 |
-
$this->assertEquals($documentationLink, $customer->_links->documentation);
|
| 57 |
-
|
| 58 |
-
}
|
| 59 |
-
|
| 60 |
-
public function testGetWorks()
|
| 61 |
-
{
|
| 62 |
-
$this->mockApiCall(
|
| 63 |
-
new Request('GET', '/v2/customers/cst_FhQJRw4s2n'),
|
| 64 |
-
new Response(
|
| 65 |
-
200,
|
| 66 |
-
[],
|
| 67 |
-
'{
|
| 68 |
-
"resource": "customer",
|
| 69 |
-
"id": "cst_FhQJRw4s2n",
|
| 70 |
-
"mode": "test",
|
| 71 |
-
"name": "John Doe",
|
| 72 |
-
"email": "johndoe@example.org",
|
| 73 |
-
"locale": null,
|
| 74 |
-
"metadata": null,
|
| 75 |
-
"recentlyUsedMethods": [],
|
| 76 |
-
"createdAt": "2018-04-19T08:49:01+00:00",
|
| 77 |
-
"_links": {
|
| 78 |
-
"documentation": {
|
| 79 |
-
"href": "https://docs.mollie.com/reference/v2/customers-api/get-customer",
|
| 80 |
-
"type": "text/html"
|
| 81 |
-
}
|
| 82 |
-
}
|
| 83 |
-
}'
|
| 84 |
-
)
|
| 85 |
-
);
|
| 86 |
-
|
| 87 |
-
/** @var Customer $customer */
|
| 88 |
-
$customer = $this->apiClient->customers->get("cst_FhQJRw4s2n");
|
| 89 |
-
|
| 90 |
-
$this->assertInstanceOf(Customer::class, $customer);
|
| 91 |
-
$this->assertEquals("customer", $customer->resource);
|
| 92 |
-
$this->assertEquals("cst_FhQJRw4s2n", $customer->id);
|
| 93 |
-
$this->assertEquals("John Doe", $customer->name);
|
| 94 |
-
$this->assertEquals("johndoe@example.org", $customer->email);
|
| 95 |
-
$this->assertNull($customer->locale);
|
| 96 |
-
$this->assertNull($customer->metadata);
|
| 97 |
-
$this->assertEquals([], $customer->recentlyUsedMethods);
|
| 98 |
-
$this->assertEquals("2018-04-19T08:49:01+00:00", $customer->createdAt);
|
| 99 |
-
|
| 100 |
-
$documentationLink = (object)["href" => "https://docs.mollie.com/reference/v2/customers-api/get-customer", "type" => "text/html"];
|
| 101 |
-
$this->assertEquals($documentationLink, $customer->_links->documentation);
|
| 102 |
-
|
| 103 |
-
}
|
| 104 |
-
|
| 105 |
-
public function testListWorks()
|
| 106 |
-
{
|
| 107 |
-
$this->mockApiCall(
|
| 108 |
-
new Request('GET', '/v2/customers'),
|
| 109 |
-
new Response(
|
| 110 |
-
200,
|
| 111 |
-
[],
|
| 112 |
-
'{
|
| 113 |
-
"_embedded": {
|
| 114 |
-
"customers": [
|
| 115 |
-
{
|
| 116 |
-
"resource": "customer",
|
| 117 |
-
"id": "cst_FhQJRw4s2n",
|
| 118 |
-
"mode": "test",
|
| 119 |
-
"name": "John Doe",
|
| 120 |
-
"email": "johndoe@example.org",
|
| 121 |
-
"locale": null,
|
| 122 |
-
"metadata": null,
|
| 123 |
-
"recentlyUsedMethods": [],
|
| 124 |
-
"createdAt": "2018-04-19T08:49:01+00:00"
|
| 125 |
-
}
|
| 126 |
-
]
|
| 127 |
-
},
|
| 128 |
-
"count": 1,
|
| 129 |
-
"_links": {
|
| 130 |
-
"documentation": {
|
| 131 |
-
"href": "https://docs.mollie.com/reference/v2/customers-api/list-customers",
|
| 132 |
-
"type": "text/html"
|
| 133 |
-
},
|
| 134 |
-
"self": {
|
| 135 |
-
"href": "https://api.mollie.com/v2/customers?limit=50",
|
| 136 |
-
"type": "application/hal+json"
|
| 137 |
-
},
|
| 138 |
-
"previous": null,
|
| 139 |
-
"next": null
|
| 140 |
-
}
|
| 141 |
-
}'
|
| 142 |
-
)
|
| 143 |
-
);
|
| 144 |
-
|
| 145 |
-
/** @var Customer $customer */
|
| 146 |
-
$customers = $this->apiClient->customers->page();
|
| 147 |
-
|
| 148 |
-
$this->assertInstanceOf(CustomerCollection::class, $customers);
|
| 149 |
-
|
| 150 |
-
$documentationLink = (object)["href" => "https://docs.mollie.com/reference/v2/customers-api/list-customers", "type" => "text/html"];
|
| 151 |
-
$this->assertEquals($documentationLink, $customers->_links->documentation);
|
| 152 |
-
|
| 153 |
-
$selfLink = (object)["href" => "https://api.mollie.com/v2/customers?limit=50", "type" => "application/hal+json"];
|
| 154 |
-
$this->assertEquals($selfLink, $customers->_links->self);
|
| 155 |
-
|
| 156 |
-
foreach ($customers as $customer) {
|
| 157 |
-
$this->assertInstanceOf(Customer::class, $customer);
|
| 158 |
-
$this->assertEquals("customer", $customer->resource);
|
| 159 |
-
$this->assertNotEmpty($customer->createdAt);
|
| 160 |
-
}
|
| 161 |
-
|
| 162 |
-
}
|
| 163 |
-
|
| 164 |
-
public function testUpdateWorks()
|
| 165 |
-
{
|
| 166 |
-
$expectedName = 'Kaas Broodje';
|
| 167 |
-
$expectedEmail = 'kaas.broodje@gmail.com';
|
| 168 |
-
|
| 169 |
-
$this->mockApiCall(
|
| 170 |
-
new Request('PATCH', '/v2/customers/cst_FhQJRw4s2n'),
|
| 171 |
-
new Response(
|
| 172 |
-
200,
|
| 173 |
-
[],
|
| 174 |
-
'{
|
| 175 |
-
"resource": "customer",
|
| 176 |
-
"id": "cst_FhQJRw4s2n",
|
| 177 |
-
"mode": "test",
|
| 178 |
-
"name": "' . $expectedName . '",
|
| 179 |
-
"email": "' . $expectedEmail . '",
|
| 180 |
-
"locale": null,
|
| 181 |
-
"metadata": null,
|
| 182 |
-
"recentlyUsedMethods": [],
|
| 183 |
-
"createdAt": "2018-04-19T08:49:01+00:00",
|
| 184 |
-
"_links": {
|
| 185 |
-
"documentation": {
|
| 186 |
-
"href": "https://docs.mollie.com/reference/v2/customers-api/get-customer",
|
| 187 |
-
"type": "text/html"
|
| 188 |
-
}
|
| 189 |
-
}
|
| 190 |
-
}'
|
| 191 |
-
)
|
| 192 |
-
);
|
| 193 |
-
|
| 194 |
-
$customer = $this->getCustomer();
|
| 195 |
-
$customer->name = $expectedName;
|
| 196 |
-
$customer->email = $expectedEmail;
|
| 197 |
-
|
| 198 |
-
$updatedCustomer = $customer->update();
|
| 199 |
-
|
| 200 |
-
$this->assertEquals($expectedName, $updatedCustomer->name);
|
| 201 |
-
$this->assertEquals($expectedEmail, $updatedCustomer->email);
|
| 202 |
-
}
|
| 203 |
-
|
| 204 |
-
/**
|
| 205 |
-
* @return Customer
|
| 206 |
-
*/
|
| 207 |
-
private function getCustomer()
|
| 208 |
-
{
|
| 209 |
-
$customerJson = '{
|
| 210 |
-
"resource": "customer",
|
| 211 |
-
"id": "cst_FhQJRw4s2n",
|
| 212 |
-
"mode": "test",
|
| 213 |
-
"name": "John Doe",
|
| 214 |
-
"email": "johndoe@example.org",
|
| 215 |
-
"locale": null,
|
| 216 |
-
"metadata": null,
|
| 217 |
-
"recentlyUsedMethods": [],
|
| 218 |
-
"createdAt": "2018-04-19T08:49:01+00:00",
|
| 219 |
-
"_links": {
|
| 220 |
-
"self": {
|
| 221 |
-
"href": "http://api.mollie.test/v2/customers/cst_FhQJRw4s2n",
|
| 222 |
-
"type": "application/hal+json"
|
| 223 |
-
},
|
| 224 |
-
"documentation": {
|
| 225 |
-
"href": "https://docs.mollie.com/reference/v2/customers-api/get-customer",
|
| 226 |
-
"type": "text/html"
|
| 227 |
-
}
|
| 228 |
-
}
|
| 229 |
-
}';
|
| 230 |
-
|
| 231 |
-
return $this->copy(json_decode($customerJson), new Customer($this->apiClient));
|
| 232 |
-
}
|
| 233 |
-
|
| 234 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Endpoints/CustomerPaymentEndpointTest.php
DELETED
|
@@ -1,314 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\Api\Endpoints;
|
| 4 |
-
|
| 5 |
-
use GuzzleHttp\Psr7\Request;
|
| 6 |
-
use GuzzleHttp\Psr7\Response;
|
| 7 |
-
use Mollie\Api\Resources\Customer;
|
| 8 |
-
use Mollie\Api\Resources\Payment;
|
| 9 |
-
use Mollie\Api\Resources\PaymentCollection;
|
| 10 |
-
use Mollie\Api\Types\PaymentStatus;
|
| 11 |
-
use Mollie\Api\Types\SequenceType;
|
| 12 |
-
use stdClass;
|
| 13 |
-
|
| 14 |
-
class CustomerPaymentEndpointTest extends BaseEndpointTest
|
| 15 |
-
{
|
| 16 |
-
public function testCreateCustomerPayment()
|
| 17 |
-
{
|
| 18 |
-
$this->mockApiCall(
|
| 19 |
-
new Request(
|
| 20 |
-
"POST",
|
| 21 |
-
"/v2/customers/cst_FhQJRw4s2n/payments",
|
| 22 |
-
[],
|
| 23 |
-
'{
|
| 24 |
-
"amount":{
|
| 25 |
-
"value":"20.00",
|
| 26 |
-
"currency":"EUR"
|
| 27 |
-
},
|
| 28 |
-
"description": "My first API payment",
|
| 29 |
-
"redirectUrl": "https://example.org/redirect",
|
| 30 |
-
"webhookUrl": "https://example.org/webhook",
|
| 31 |
-
"metadata": {
|
| 32 |
-
"order_id": "1234"
|
| 33 |
-
}
|
| 34 |
-
}'
|
| 35 |
-
),
|
| 36 |
-
new Response(
|
| 37 |
-
201,
|
| 38 |
-
[],
|
| 39 |
-
'{
|
| 40 |
-
"resource":"payment",
|
| 41 |
-
"id":"tr_44aKxzEbr8",
|
| 42 |
-
"mode":"test",
|
| 43 |
-
"createdAt":"2018-03-13T14:02:29+00:00",
|
| 44 |
-
"amount":{
|
| 45 |
-
"value":"20.00",
|
| 46 |
-
"currency":"EUR"
|
| 47 |
-
},
|
| 48 |
-
"description":"My first API payment",
|
| 49 |
-
"method":null,
|
| 50 |
-
"metadata":{
|
| 51 |
-
"order_id":1234
|
| 52 |
-
},
|
| 53 |
-
"status":"open",
|
| 54 |
-
"isCancelable":false,
|
| 55 |
-
"expiresAt":"2018-03-13T14:17:29+00:00",
|
| 56 |
-
"details":null,
|
| 57 |
-
"profileId":"pfl_2A1gacu42V",
|
| 58 |
-
"sequenceType":"oneoff",
|
| 59 |
-
"redirectUrl":"http://example.org/examples/payment/03-return-page.php?order_id=1234",
|
| 60 |
-
"webhookUrl":"http://example.org/examples/payment/02-webhook-verification.php",
|
| 61 |
-
"_links":{
|
| 62 |
-
"self":{
|
| 63 |
-
"href":"https://api.mollie.com/v2/payments/tr_44aKxzEbr8",
|
| 64 |
-
"type":"application/hal+json"
|
| 65 |
-
},
|
| 66 |
-
"checkout":{
|
| 67 |
-
"href":"https://www.mollie.com/payscreen/select-method/44aKxzEbr8",
|
| 68 |
-
"type":"text/html"
|
| 69 |
-
},
|
| 70 |
-
"customer": {
|
| 71 |
-
"href": "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n",
|
| 72 |
-
"type": "application/hal+json"
|
| 73 |
-
},
|
| 74 |
-
"documentation":{
|
| 75 |
-
"href":"https://docs.mollie.com/reference/v2/customers-api/create-payment",
|
| 76 |
-
"type":"text/html"
|
| 77 |
-
}
|
| 78 |
-
}
|
| 79 |
-
}'
|
| 80 |
-
)
|
| 81 |
-
);
|
| 82 |
-
|
| 83 |
-
$customer = $this->getCustomer();
|
| 84 |
-
|
| 85 |
-
$payment = $customer->createPayment([
|
| 86 |
-
"amount" => [
|
| 87 |
-
"currency" => "EUR",
|
| 88 |
-
"value" => "20.00"
|
| 89 |
-
],
|
| 90 |
-
"description" => "My first API payment",
|
| 91 |
-
"redirectUrl" => "https://example.org/redirect",
|
| 92 |
-
"webhookUrl" => "https://example.org/webhook",
|
| 93 |
-
"metadata" => [
|
| 94 |
-
"order_id" => "1234",
|
| 95 |
-
],
|
| 96 |
-
]);
|
| 97 |
-
|
| 98 |
-
$this->assertInstanceOf(Payment::class, $payment);
|
| 99 |
-
$this->assertEquals('tr_44aKxzEbr8', $payment->id);
|
| 100 |
-
$this->assertEquals('test', $payment->mode);
|
| 101 |
-
$this->assertEquals("2018-03-13T14:02:29+00:00", $payment->createdAt);
|
| 102 |
-
|
| 103 |
-
$amount = new Stdclass();
|
| 104 |
-
$amount->value = '20.00';
|
| 105 |
-
$amount->currency = "EUR";
|
| 106 |
-
$this->assertEquals($amount, $payment->amount);
|
| 107 |
-
|
| 108 |
-
$this->assertEquals('My first API payment', $payment->description);
|
| 109 |
-
$this->assertNull($payment->method);
|
| 110 |
-
$this->assertEquals((object)["order_id" => "1234"], $payment->metadata);
|
| 111 |
-
$this->assertEquals(PaymentStatus::STATUS_OPEN, $payment->status);
|
| 112 |
-
$this->assertFalse($payment->isCancelable);
|
| 113 |
-
$this->assertEquals("2018-03-13T14:17:29+00:00", $payment->expiresAt);
|
| 114 |
-
$this->assertNull($payment->details);
|
| 115 |
-
$this->assertEquals("pfl_2A1gacu42V", $payment->profileId);
|
| 116 |
-
$this->assertEquals(SequenceType::SEQUENCETYPE_ONEOFF, $payment->sequenceType);
|
| 117 |
-
$this->assertEquals("http://example.org/examples/payment/03-return-page.php?order_id=1234", $payment->redirectUrl);
|
| 118 |
-
$this->assertEquals("http://example.org/examples/payment/02-webhook-verification.php", $payment->webhookUrl);
|
| 119 |
-
|
| 120 |
-
$selfLink = (object)["href" => "https://api.mollie.com/v2/payments/tr_44aKxzEbr8", "type" => "application/hal+json"];
|
| 121 |
-
$this->assertEquals($selfLink, $payment->_links->self);
|
| 122 |
-
|
| 123 |
-
$checkoutLink = (object)["href" => "https://www.mollie.com/payscreen/select-method/44aKxzEbr8", "type" => "text/html"];
|
| 124 |
-
$this->assertEquals($checkoutLink, $payment->_links->checkout);
|
| 125 |
-
|
| 126 |
-
$customerLink = (object)["href" => "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n", "type" => "application/hal+json"];
|
| 127 |
-
$this->assertEquals($customerLink, $payment->_links->customer);
|
| 128 |
-
|
| 129 |
-
$documentationLink = (object)["href" => "https://docs.mollie.com/reference/v2/customers-api/create-payment", "type" => "text/html"];
|
| 130 |
-
$this->assertEquals($documentationLink, $payment->_links->documentation);
|
| 131 |
-
}
|
| 132 |
-
|
| 133 |
-
public function testListCustomerPayments()
|
| 134 |
-
{
|
| 135 |
-
$this->mockApiCall(
|
| 136 |
-
new Request(
|
| 137 |
-
"GET",
|
| 138 |
-
"/v2/customers/cst_FhQJRw4s2n/payments?testmode=true",
|
| 139 |
-
[],
|
| 140 |
-
''
|
| 141 |
-
),
|
| 142 |
-
new Response(
|
| 143 |
-
200,
|
| 144 |
-
[],
|
| 145 |
-
'{
|
| 146 |
-
"_embedded": {
|
| 147 |
-
"payments": [
|
| 148 |
-
{
|
| 149 |
-
"resource": "payment",
|
| 150 |
-
"id": "tr_admNa2tFfa",
|
| 151 |
-
"mode": "test",
|
| 152 |
-
"createdAt": "2018-03-19T15:00:50+00:00",
|
| 153 |
-
"amount": {
|
| 154 |
-
"value": "100.00",
|
| 155 |
-
"currency": "EUR"
|
| 156 |
-
},
|
| 157 |
-
"description": "Payment no 1",
|
| 158 |
-
"method": null,
|
| 159 |
-
"metadata": null,
|
| 160 |
-
"status": "open",
|
| 161 |
-
"isCancelable": false,
|
| 162 |
-
"expiresAt": "2018-03-19T15:15:50+00:00",
|
| 163 |
-
"details": null,
|
| 164 |
-
"locale": "nl_NL",
|
| 165 |
-
"profileId": "pfl_7N5qjbu42V",
|
| 166 |
-
"sequenceType": "oneoff",
|
| 167 |
-
"redirectUrl": "https://www.example.org/",
|
| 168 |
-
"_links": {
|
| 169 |
-
"self": {
|
| 170 |
-
"href": "https://api.mollie.com/v2/payments/tr_admNa2tFfa",
|
| 171 |
-
"type": "application/hal+json"
|
| 172 |
-
},
|
| 173 |
-
"checkout": {
|
| 174 |
-
"href": "https://www.mollie.com/payscreen/select-method/admNa2tFfa",
|
| 175 |
-
"type": "text/html"
|
| 176 |
-
},
|
| 177 |
-
"customer": {
|
| 178 |
-
"href": "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n",
|
| 179 |
-
"type": "application/hal+json"
|
| 180 |
-
}
|
| 181 |
-
}
|
| 182 |
-
},
|
| 183 |
-
{
|
| 184 |
-
"resource": "payment",
|
| 185 |
-
"id": "tr_bcaLc7hFfa",
|
| 186 |
-
"mode": "test",
|
| 187 |
-
"createdAt": "2018-03-19T15:00:50+00:00",
|
| 188 |
-
"amount": {
|
| 189 |
-
"value": "100.00",
|
| 190 |
-
"currency": "EUR"
|
| 191 |
-
},
|
| 192 |
-
"description": "Payment no 2",
|
| 193 |
-
"method": null,
|
| 194 |
-
"metadata": null,
|
| 195 |
-
"status": "open",
|
| 196 |
-
"isCancelable": false,
|
| 197 |
-
"expiresAt": "2018-03-19T15:15:50+00:00",
|
| 198 |
-
"details": null,
|
| 199 |
-
"locale": "nl_NL",
|
| 200 |
-
"profileId": "pfl_7N5qjbu42V",
|
| 201 |
-
"sequenceType": "oneoff",
|
| 202 |
-
"redirectUrl": "https://www.example.org/",
|
| 203 |
-
"_links": {
|
| 204 |
-
"self": {
|
| 205 |
-
"href": "https://api.mollie.com/v2/payments/tr_bcaLc7hFfa",
|
| 206 |
-
"type": "application/hal+json"
|
| 207 |
-
},
|
| 208 |
-
"checkout": {
|
| 209 |
-
"href": "https://www.mollie.com/payscreen/select-method/bcaLc7hFfa",
|
| 210 |
-
"type": "text/html"
|
| 211 |
-
},
|
| 212 |
-
"customer": {
|
| 213 |
-
"href": "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n",
|
| 214 |
-
"type": "application/hal+json"
|
| 215 |
-
}
|
| 216 |
-
}
|
| 217 |
-
},
|
| 218 |
-
{
|
| 219 |
-
"resource": "payment",
|
| 220 |
-
"id": "tr_pslHy1tFfa",
|
| 221 |
-
"mode": "test",
|
| 222 |
-
"createdAt": "2018-03-19T15:00:50+00:00",
|
| 223 |
-
"amount": {
|
| 224 |
-
"value": "100.00",
|
| 225 |
-
"currency": "EUR"
|
| 226 |
-
},
|
| 227 |
-
"description": "Payment no 3",
|
| 228 |
-
"method": null,
|
| 229 |
-
"metadata": null,
|
| 230 |
-
"status": "open",
|
| 231 |
-
"isCancelable": false,
|
| 232 |
-
"expiresAt": "2018-03-19T15:15:50+00:00",
|
| 233 |
-
"details": null,
|
| 234 |
-
"locale": "nl_NL",
|
| 235 |
-
"profileId": "pfl_7N5qjbu42V",
|
| 236 |
-
"sequenceType": "oneoff",
|
| 237 |
-
"redirectUrl": "https://www.example.org/",
|
| 238 |
-
"_links": {
|
| 239 |
-
"self": {
|
| 240 |
-
"href": "https://api.mollie.com/v2/payments/tr_pslHy1tFfa",
|
| 241 |
-
"type": "application/hal+json"
|
| 242 |
-
},
|
| 243 |
-
"checkout": {
|
| 244 |
-
"href": "https://www.mollie.com/payscreen/select-method/pslHy1tFfa",
|
| 245 |
-
"type": "text/html"
|
| 246 |
-
},
|
| 247 |
-
"customer": {
|
| 248 |
-
"href": "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n",
|
| 249 |
-
"type": "application/hal+json"
|
| 250 |
-
}
|
| 251 |
-
}
|
| 252 |
-
}
|
| 253 |
-
]
|
| 254 |
-
},
|
| 255 |
-
"_links": {
|
| 256 |
-
"documentation": {
|
| 257 |
-
"href": "https://docs.mollie.com/reference/v2/customers-api/list-customer-payments",
|
| 258 |
-
"type": "text/html"
|
| 259 |
-
},
|
| 260 |
-
"self": {
|
| 261 |
-
"href": "https://api.mollie.com/v2/customers/cst_TkNdP8yPrH/payments?limit=50",
|
| 262 |
-
"type": "application/hal+json"
|
| 263 |
-
},
|
| 264 |
-
"previous": null,
|
| 265 |
-
"next": null
|
| 266 |
-
},
|
| 267 |
-
"count": 3
|
| 268 |
-
}'
|
| 269 |
-
),
|
| 270 |
-
true
|
| 271 |
-
);
|
| 272 |
-
|
| 273 |
-
/** @var Customer $customer */
|
| 274 |
-
$customer = $this->getCustomer();
|
| 275 |
-
|
| 276 |
-
$payments = $customer->payments();
|
| 277 |
-
|
| 278 |
-
$this->assertInstanceOf(PaymentCollection::class, $payments);
|
| 279 |
-
$this->assertEquals(3, $payments->count);
|
| 280 |
-
$this->assertEquals(3, count($payments));
|
| 281 |
-
|
| 282 |
-
$documentationLink = (object)["href" => "https://docs.mollie.com/reference/v2/customers-api/list-customer-payments", "type" => "text/html"];
|
| 283 |
-
$this->assertEquals($documentationLink, $payments->_links->documentation);
|
| 284 |
-
|
| 285 |
-
$selfLink = (object)["href" => "https://api.mollie.com/v2/customers/cst_TkNdP8yPrH/payments?limit=50", "type" => "application/hal+json"];
|
| 286 |
-
$this->assertEquals($selfLink, $payments->_links->self);
|
| 287 |
-
}
|
| 288 |
-
|
| 289 |
-
/**
|
| 290 |
-
* @return CustomerPaymentEndpointTest
|
| 291 |
-
*/
|
| 292 |
-
private function getCustomer()
|
| 293 |
-
{
|
| 294 |
-
$customerJson = '{
|
| 295 |
-
"resource": "customer",
|
| 296 |
-
"id": "cst_FhQJRw4s2n",
|
| 297 |
-
"mode": "test",
|
| 298 |
-
"name": "John Doe",
|
| 299 |
-
"email": "johndoe@example.org",
|
| 300 |
-
"locale": null,
|
| 301 |
-
"metadata": null,
|
| 302 |
-
"recentlyUsedMethods": [],
|
| 303 |
-
"createdAt": "2018-04-19T08:49:01+00:00",
|
| 304 |
-
"_links": {
|
| 305 |
-
"documentation": {
|
| 306 |
-
"href": "https://docs.mollie.com/reference/v2/customers-api/get-customer",
|
| 307 |
-
"type": "text/html"
|
| 308 |
-
}
|
| 309 |
-
}
|
| 310 |
-
}';
|
| 311 |
-
|
| 312 |
-
return $this->copy(json_decode($customerJson), new Customer($this->apiClient));
|
| 313 |
-
}
|
| 314 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Endpoints/InvoiceEndpointTest.php
DELETED
|
@@ -1,222 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\Api\Endpoints;
|
| 4 |
-
|
| 5 |
-
use GuzzleHttp\Psr7\Request;
|
| 6 |
-
use GuzzleHttp\Psr7\Response;
|
| 7 |
-
use Mollie\Api\Resources\Invoice;
|
| 8 |
-
use Mollie\Api\Resources\InvoiceCollection;
|
| 9 |
-
use Mollie\Api\Types\InvoiceStatus;
|
| 10 |
-
|
| 11 |
-
class InvoiceEndpointTest extends BaseEndpointTest
|
| 12 |
-
{
|
| 13 |
-
public function testGetInvoice()
|
| 14 |
-
{
|
| 15 |
-
$this->mockApiCall(
|
| 16 |
-
new Request(
|
| 17 |
-
"GET",
|
| 18 |
-
"/v2/invoices/inv_bsa6PvAwaK",
|
| 19 |
-
[],
|
| 20 |
-
''
|
| 21 |
-
),
|
| 22 |
-
new Response(
|
| 23 |
-
200,
|
| 24 |
-
[],
|
| 25 |
-
'{
|
| 26 |
-
"resource": "invoice",
|
| 27 |
-
"id": "inv_bsa6PvAwaK",
|
| 28 |
-
"reference": "2018.190241",
|
| 29 |
-
"vatNumber": "123456789B01",
|
| 30 |
-
"status": "paid",
|
| 31 |
-
"issuedAt": "2018-05-02",
|
| 32 |
-
"paidAt": "2018-05-02",
|
| 33 |
-
"netAmount": {
|
| 34 |
-
"value": "100.00",
|
| 35 |
-
"currency": "EUR"
|
| 36 |
-
},
|
| 37 |
-
"vatAmount": {
|
| 38 |
-
"value": "0.00",
|
| 39 |
-
"currency": "EUR"
|
| 40 |
-
},
|
| 41 |
-
"grossAmount": {
|
| 42 |
-
"value": "100.00",
|
| 43 |
-
"currency": "EUR"
|
| 44 |
-
},
|
| 45 |
-
"lines": [
|
| 46 |
-
{
|
| 47 |
-
"period": "2018-04",
|
| 48 |
-
"description": "iDEAL transaction costs: april 2018",
|
| 49 |
-
"count": 1337,
|
| 50 |
-
"vatPercentage": 0,
|
| 51 |
-
"amount": {
|
| 52 |
-
"value": "50.00",
|
| 53 |
-
"currency": "EUR"
|
| 54 |
-
}
|
| 55 |
-
},
|
| 56 |
-
{
|
| 57 |
-
"period": "2018-04",
|
| 58 |
-
"description": "Refunds iDEAL: april 2018",
|
| 59 |
-
"count": 1337,
|
| 60 |
-
"vatPercentage": 0,
|
| 61 |
-
"amount": {
|
| 62 |
-
"value": "50.00",
|
| 63 |
-
"currency": "EUR"
|
| 64 |
-
}
|
| 65 |
-
}
|
| 66 |
-
],
|
| 67 |
-
"_links": {
|
| 68 |
-
"self": {
|
| 69 |
-
"href": "https://api.mollie.com/v2/invoices/inv_bsa6PvAwaK",
|
| 70 |
-
"type": "application/hal+json"
|
| 71 |
-
},
|
| 72 |
-
"pdf": {
|
| 73 |
-
"href": "https://www.mollie.com/merchant/download/invoice/bsa6PvAwaK/79aa10f49132b7844c0243648ade6985",
|
| 74 |
-
"type": "application/pdf"
|
| 75 |
-
},
|
| 76 |
-
"documentation": {
|
| 77 |
-
"href": "https://docs.mollie.com/reference/v2/invoices-api/get-invoice",
|
| 78 |
-
"type": "text/html"
|
| 79 |
-
}
|
| 80 |
-
}
|
| 81 |
-
}'
|
| 82 |
-
)
|
| 83 |
-
);
|
| 84 |
-
|
| 85 |
-
$invoice = $this->apiClient->invoices->get("inv_bsa6PvAwaK");
|
| 86 |
-
|
| 87 |
-
$this->assertInstanceOf(Invoice::class, $invoice);
|
| 88 |
-
$this->assertEquals("invoice", $invoice->resource);
|
| 89 |
-
$this->assertEquals("inv_bsa6PvAwaK", $invoice->id);
|
| 90 |
-
$this->assertEquals("2018.190241", $invoice->reference);
|
| 91 |
-
$this->assertEquals("123456789B01", $invoice->vatNumber);
|
| 92 |
-
$this->assertEquals(InvoiceStatus::STATUS_PAID, $invoice->status);
|
| 93 |
-
$this->assertEquals("2018-05-02", $invoice->issuedAt);
|
| 94 |
-
$this->assertEquals("2018-05-02", $invoice->paidAt);
|
| 95 |
-
|
| 96 |
-
$this->assertEquals((object) ["value" => "100.00", "currency" => "EUR"], $invoice->netAmount);
|
| 97 |
-
$this->assertEquals((object) ["value" => "0.00", "currency" => "EUR"], $invoice->vatAmount);
|
| 98 |
-
$this->assertEquals((object) ["value" => "100.00", "currency" => "EUR"], $invoice->grossAmount);
|
| 99 |
-
|
| 100 |
-
$this->assertCount(2, $invoice->lines);
|
| 101 |
-
|
| 102 |
-
$selfLink = (object)['href' => 'https://api.mollie.com/v2/invoices/inv_bsa6PvAwaK', 'type' => 'application/hal+json'];
|
| 103 |
-
$this->assertEquals($selfLink, $invoice->_links->self);
|
| 104 |
-
|
| 105 |
-
$pdfLink = (object)['href' => 'https://www.mollie.com/merchant/download/invoice/bsa6PvAwaK/79aa10f49132b7844c0243648ade6985', 'type' => 'application/pdf'];
|
| 106 |
-
$this->assertEquals($pdfLink, $invoice->_links->pdf);
|
| 107 |
-
|
| 108 |
-
$documentationLink = (object)['href' => 'https://docs.mollie.com/reference/v2/invoices-api/get-invoice', 'type' => 'text/html'];
|
| 109 |
-
$this->assertEquals($documentationLink, $invoice->_links->documentation);
|
| 110 |
-
}
|
| 111 |
-
|
| 112 |
-
public function testListInvoices()
|
| 113 |
-
{
|
| 114 |
-
$this->mockApiCall(
|
| 115 |
-
new Request(
|
| 116 |
-
"GET",
|
| 117 |
-
"/v2/invoices",
|
| 118 |
-
[],
|
| 119 |
-
''
|
| 120 |
-
),
|
| 121 |
-
new Response(
|
| 122 |
-
200,
|
| 123 |
-
[],
|
| 124 |
-
'{
|
| 125 |
-
"_embedded": {
|
| 126 |
-
"invoices": [
|
| 127 |
-
{
|
| 128 |
-
"resource": "invoice",
|
| 129 |
-
"id": "inv_bsa6PvAwaK",
|
| 130 |
-
"reference": "2018.190241",
|
| 131 |
-
"vatNumber": "123456789B01",
|
| 132 |
-
"status": "paid",
|
| 133 |
-
"issuedAt": "2018-05-02",
|
| 134 |
-
"paidAt": "2018-05-02",
|
| 135 |
-
"netAmount": {
|
| 136 |
-
"value": "100.00",
|
| 137 |
-
"currency": "EUR"
|
| 138 |
-
},
|
| 139 |
-
"vatAmount": {
|
| 140 |
-
"value": "0.00",
|
| 141 |
-
"currency": "EUR"
|
| 142 |
-
},
|
| 143 |
-
"grossAmount": {
|
| 144 |
-
"value": "100.00",
|
| 145 |
-
"currency": "EUR"
|
| 146 |
-
},
|
| 147 |
-
"lines": [
|
| 148 |
-
{
|
| 149 |
-
"period": "2018-04",
|
| 150 |
-
"description": "iDEAL transaction costs: april 2018",
|
| 151 |
-
"count": 1337,
|
| 152 |
-
"vatPercentage": 0,
|
| 153 |
-
"amount": {
|
| 154 |
-
"value": "50.00",
|
| 155 |
-
"currency": "EUR"
|
| 156 |
-
}
|
| 157 |
-
},
|
| 158 |
-
{
|
| 159 |
-
"period": "2018-04",
|
| 160 |
-
"description": "Refunds iDEAL: april 2018",
|
| 161 |
-
"count": 1337,
|
| 162 |
-
"vatPercentage": 0,
|
| 163 |
-
"amount": {
|
| 164 |
-
"value": "50.00",
|
| 165 |
-
"currency": "EUR"
|
| 166 |
-
}
|
| 167 |
-
}
|
| 168 |
-
],
|
| 169 |
-
"_links": {
|
| 170 |
-
"self": {
|
| 171 |
-
"href": "https://api.mollie.com/v2/invoices/inv_bsa6PvAwaK",
|
| 172 |
-
"type": "application/hal+json"
|
| 173 |
-
},
|
| 174 |
-
"pdf": {
|
| 175 |
-
"href": "https://www.mollie.com/merchant/download/invoice/bsa6PvAwaK/79aa10f49132b7844c0243648ade6985",
|
| 176 |
-
"type": "application/pdf"
|
| 177 |
-
},
|
| 178 |
-
"documentation": {
|
| 179 |
-
"href": "https://docs.mollie.com/reference/v2/invoices-api/get-invoice",
|
| 180 |
-
"type": "text/html"
|
| 181 |
-
}
|
| 182 |
-
}
|
| 183 |
-
}
|
| 184 |
-
]
|
| 185 |
-
},
|
| 186 |
-
"count": 1,
|
| 187 |
-
"_links": {
|
| 188 |
-
"documentation": {
|
| 189 |
-
"href": "https://docs.mollie.com/reference/v2/invoices-api/list-invoices",
|
| 190 |
-
"type": "text/html"
|
| 191 |
-
},
|
| 192 |
-
"self": {
|
| 193 |
-
"href": "https://api.mollie.nl/v2/invoices?limit=50",
|
| 194 |
-
"type": "application/hal+json"
|
| 195 |
-
},
|
| 196 |
-
"previous": null,
|
| 197 |
-
"next": null
|
| 198 |
-
}
|
| 199 |
-
}'
|
| 200 |
-
)
|
| 201 |
-
);
|
| 202 |
-
|
| 203 |
-
$invoices = $this->apiClient->invoices->page();
|
| 204 |
-
$this->assertInstanceOf(InvoiceCollection::class, $invoices);
|
| 205 |
-
|
| 206 |
-
$documentationLink = (object)['href' => 'https://docs.mollie.com/reference/v2/invoices-api/list-invoices', 'type' => 'text/html'];
|
| 207 |
-
$this->assertEquals($documentationLink, $invoices->_links->documentation);
|
| 208 |
-
|
| 209 |
-
$selfLink = (object)['href' => 'https://api.mollie.nl/v2/invoices?limit=50', 'type' => 'application/hal+json'];
|
| 210 |
-
$this->assertEquals($selfLink, $invoices->_links->self);
|
| 211 |
-
|
| 212 |
-
$this->assertEmpty($invoices->_links->previous);
|
| 213 |
-
$this->assertEmpty($invoices->_links->next);
|
| 214 |
-
|
| 215 |
-
foreach($invoices as $invoice) {
|
| 216 |
-
$this->assertInstanceOf(Invoice::class, $invoice);
|
| 217 |
-
$this->assertEquals("invoice", $invoice->resource);
|
| 218 |
-
$this->assertNotEmpty($invoice->lines);
|
| 219 |
-
}
|
| 220 |
-
}
|
| 221 |
-
|
| 222 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Endpoints/MandateEndpointTest.php
DELETED
|
@@ -1,428 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\Api\Endpoints;
|
| 4 |
-
|
| 5 |
-
use GuzzleHttp\Psr7\Request;
|
| 6 |
-
use GuzzleHttp\Psr7\Response;
|
| 7 |
-
use Mollie\Api\Resources\Customer;
|
| 8 |
-
use Mollie\Api\Resources\Mandate;
|
| 9 |
-
use Mollie\Api\Resources\MandateCollection;
|
| 10 |
-
use Mollie\Api\Types\MandateMethod;
|
| 11 |
-
use Mollie\Api\Types\MandateStatus;
|
| 12 |
-
|
| 13 |
-
class MandateEndpointTest extends BaseEndpointTest
|
| 14 |
-
{
|
| 15 |
-
|
| 16 |
-
public function testCreateWorks()
|
| 17 |
-
{
|
| 18 |
-
$this->mockApiCall(
|
| 19 |
-
new Request('POST', '/v2/customers/cst_FhQJRw4s2n/mandates'),
|
| 20 |
-
new Response(
|
| 21 |
-
200,
|
| 22 |
-
[],
|
| 23 |
-
'{
|
| 24 |
-
"resource": "mandate",
|
| 25 |
-
"id": "mdt_AcQl5fdL4h",
|
| 26 |
-
"status": "valid",
|
| 27 |
-
"method": "directdebit",
|
| 28 |
-
"details": {
|
| 29 |
-
"consumerName": "John Doe",
|
| 30 |
-
"consumerAccount": "NL55INGB0000000000",
|
| 31 |
-
"consumerBic": "INGBNL2A"
|
| 32 |
-
},
|
| 33 |
-
"mandateReference": null,
|
| 34 |
-
"signatureDate": "2018-05-07",
|
| 35 |
-
"createdAt": "2018-05-07T10:49:08+00:00",
|
| 36 |
-
"_links": {
|
| 37 |
-
"self": {
|
| 38 |
-
"href": "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n/mandates/mdt_AcQl5fdL4h",
|
| 39 |
-
"type": "application/hal+json"
|
| 40 |
-
},
|
| 41 |
-
"customer": {
|
| 42 |
-
"href": "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n",
|
| 43 |
-
"type": "application/hal+json"
|
| 44 |
-
},
|
| 45 |
-
"documentation": {
|
| 46 |
-
"href": "https://mollie.com/en/docs/reference/customers/create-mandate",
|
| 47 |
-
"type": "text/html"
|
| 48 |
-
}
|
| 49 |
-
}
|
| 50 |
-
}'
|
| 51 |
-
)
|
| 52 |
-
);
|
| 53 |
-
|
| 54 |
-
$customer = $this->getCustomer();
|
| 55 |
-
|
| 56 |
-
/** @var Mandate $mandate */
|
| 57 |
-
$mandate = $customer->createMandate([
|
| 58 |
-
"consumerName" => "John Doe",
|
| 59 |
-
"method" => "directdebit",
|
| 60 |
-
"consumerBic" => "INGBNL2A",
|
| 61 |
-
"consumerAccount" => "NL55INGB0000000000"
|
| 62 |
-
]);
|
| 63 |
-
|
| 64 |
-
$this->assertInstanceOf(Mandate::class, $mandate);
|
| 65 |
-
$this->assertEquals("mandate", $mandate->resource);
|
| 66 |
-
$this->assertEquals(MandateStatus::STATUS_VALID, $mandate->status);
|
| 67 |
-
$this->assertEquals("directdebit", $mandate->method);
|
| 68 |
-
$this->assertEquals((object) ["consumerName" => "John Doe", "consumerAccount" => "NL55INGB0000000000", "consumerBic" => "INGBNL2A"], $mandate->details);
|
| 69 |
-
$this->assertNull($mandate->mandateReference);
|
| 70 |
-
$this->assertEquals("2018-05-07", $mandate->signatureDate);
|
| 71 |
-
$this->assertEquals("2018-05-07T10:49:08+00:00", $mandate->createdAt);
|
| 72 |
-
|
| 73 |
-
$selfLink = (object)["href" => "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n/mandates/mdt_AcQl5fdL4h", "type" => "application/hal+json"];
|
| 74 |
-
$this->assertEquals($selfLink, $mandate->_links->self);
|
| 75 |
-
|
| 76 |
-
$customerLink = (object)["href" => "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n", "type" => "application/hal+json"];
|
| 77 |
-
$this->assertEquals($customerLink, $mandate->_links->customer);
|
| 78 |
-
|
| 79 |
-
$documentationLink = (object)["href" => "https://mollie.com/en/docs/reference/customers/create-mandate", "type" => "text/html"];
|
| 80 |
-
$this->assertEquals($documentationLink, $mandate->_links->documentation);
|
| 81 |
-
}
|
| 82 |
-
|
| 83 |
-
public function testGetWorks()
|
| 84 |
-
{
|
| 85 |
-
$this->mockApiCall(
|
| 86 |
-
new Request('GET', '/v2/customers/cst_FhQJRw4s2n/mandates/mdt_AcQl5fdL4h'),
|
| 87 |
-
new Response(
|
| 88 |
-
200,
|
| 89 |
-
[],
|
| 90 |
-
'{
|
| 91 |
-
"resource": "mandate",
|
| 92 |
-
"id": "mdt_AcQl5fdL4h",
|
| 93 |
-
"status": "valid",
|
| 94 |
-
"method": "directdebit",
|
| 95 |
-
"details": {
|
| 96 |
-
"consumerName": "John Doe",
|
| 97 |
-
"consumerAccount": "NL55INGB0000000000",
|
| 98 |
-
"consumerBic": "INGBNL2A"
|
| 99 |
-
},
|
| 100 |
-
"mandateReference": null,
|
| 101 |
-
"signatureDate": "2018-05-07",
|
| 102 |
-
"createdAt": "2018-05-07T10:49:08+00:00",
|
| 103 |
-
"_links": {
|
| 104 |
-
"self": {
|
| 105 |
-
"href": "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n/mandates/mdt_AcQl5fdL4h",
|
| 106 |
-
"type": "application/hal+json"
|
| 107 |
-
},
|
| 108 |
-
"customer": {
|
| 109 |
-
"href": "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n",
|
| 110 |
-
"type": "application/hal+json"
|
| 111 |
-
},
|
| 112 |
-
"documentation": {
|
| 113 |
-
"href": "https://mollie.com/en/docs/reference/customers/create-mandate",
|
| 114 |
-
"type": "text/html"
|
| 115 |
-
}
|
| 116 |
-
}
|
| 117 |
-
}'
|
| 118 |
-
)
|
| 119 |
-
);
|
| 120 |
-
|
| 121 |
-
$customer = $this->getCustomer();
|
| 122 |
-
|
| 123 |
-
/** @var Mandate $mandate */
|
| 124 |
-
$mandate = $customer->getMandate("mdt_AcQl5fdL4h");
|
| 125 |
-
|
| 126 |
-
$this->assertInstanceOf(Mandate::class, $mandate);
|
| 127 |
-
$this->assertEquals("mandate", $mandate->resource);
|
| 128 |
-
$this->assertEquals(MandateStatus::STATUS_VALID, $mandate->status);
|
| 129 |
-
$this->assertEquals(MandateMethod::DIRECTDEBIT, $mandate->method);
|
| 130 |
-
$this->assertEquals((object) ["consumerName" => "John Doe", "consumerAccount" => "NL55INGB0000000000", "consumerBic" => "INGBNL2A"], $mandate->details);
|
| 131 |
-
$this->assertNull($mandate->mandateReference);
|
| 132 |
-
$this->assertEquals("2018-05-07", $mandate->signatureDate);
|
| 133 |
-
$this->assertEquals("2018-05-07T10:49:08+00:00", $mandate->createdAt);
|
| 134 |
-
|
| 135 |
-
$selfLink = (object)["href" => "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n/mandates/mdt_AcQl5fdL4h", "type" => "application/hal+json"];
|
| 136 |
-
$this->assertEquals($selfLink, $mandate->_links->self);
|
| 137 |
-
|
| 138 |
-
$customerLink = (object)["href" => "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n", "type" => "application/hal+json"];
|
| 139 |
-
$this->assertEquals($customerLink, $mandate->_links->customer);
|
| 140 |
-
|
| 141 |
-
$documentationLink = (object)["href" => "https://mollie.com/en/docs/reference/customers/create-mandate", "type" => "text/html"];
|
| 142 |
-
$this->assertEquals($documentationLink, $mandate->_links->documentation);
|
| 143 |
-
}
|
| 144 |
-
|
| 145 |
-
public function testListWorks()
|
| 146 |
-
{
|
| 147 |
-
$this->mockApiCall(
|
| 148 |
-
new Request('GET', '/v2/customers/cst_FhQJRw4s2n/mandates'),
|
| 149 |
-
new Response(
|
| 150 |
-
200,
|
| 151 |
-
[],
|
| 152 |
-
'{
|
| 153 |
-
"_embedded": {
|
| 154 |
-
"mandates": [
|
| 155 |
-
{
|
| 156 |
-
"resource": "mandate",
|
| 157 |
-
"id": "mdt_AcQl5fdL4h",
|
| 158 |
-
"status": "valid",
|
| 159 |
-
"method": "directdebit",
|
| 160 |
-
"details": {
|
| 161 |
-
"consumerName": "John Doe",
|
| 162 |
-
"consumerAccount": "NL55INGB0000000000",
|
| 163 |
-
"consumerBic": "INGBNL2A"
|
| 164 |
-
},
|
| 165 |
-
"mandateReference": null,
|
| 166 |
-
"signatureDate": "2018-05-07",
|
| 167 |
-
"createdAt": "2018-05-07T10:49:08+00:00",
|
| 168 |
-
"_links": {
|
| 169 |
-
"self": {
|
| 170 |
-
"href": "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n/mandates/mdt_AcQl5fdL4h",
|
| 171 |
-
"type": "application/hal+json"
|
| 172 |
-
},
|
| 173 |
-
"customer": {
|
| 174 |
-
"href": "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n",
|
| 175 |
-
"type": "application/hal+json"
|
| 176 |
-
}
|
| 177 |
-
}
|
| 178 |
-
}
|
| 179 |
-
]
|
| 180 |
-
},
|
| 181 |
-
"count": 1,
|
| 182 |
-
"_links": {
|
| 183 |
-
"documentation": {
|
| 184 |
-
"href": "https://mollie.com/en/docs/reference/customers/list-mandates",
|
| 185 |
-
"type": "text/html"
|
| 186 |
-
},
|
| 187 |
-
"self": {
|
| 188 |
-
"href": "https://api.mollie.com/v2/customers/cst_vzEExMcxj7/mandates?limit=50",
|
| 189 |
-
"type": "application/hal+json"
|
| 190 |
-
},
|
| 191 |
-
"previous": null,
|
| 192 |
-
"next": null
|
| 193 |
-
}
|
| 194 |
-
}'
|
| 195 |
-
)
|
| 196 |
-
);
|
| 197 |
-
|
| 198 |
-
$customer = $this->getCustomer();
|
| 199 |
-
|
| 200 |
-
/** @var Mandate $mandate */
|
| 201 |
-
$mandates = $customer->mandates();
|
| 202 |
-
$this->assertInstanceOf(MandateCollection::class, $mandates);
|
| 203 |
-
|
| 204 |
-
foreach ($mandates as $mandate) {
|
| 205 |
-
$this->assertInstanceOf(Mandate::class, $mandate);
|
| 206 |
-
$this->assertEquals("mandate", $mandate->resource);
|
| 207 |
-
$this->assertEquals(MandateStatus::STATUS_VALID, $mandate->status);
|
| 208 |
-
|
| 209 |
-
$customerLink = (object)["href" => "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n", "type" => "application/hal+json"];
|
| 210 |
-
$this->assertEquals($customerLink, $mandate->_links->customer);
|
| 211 |
-
}
|
| 212 |
-
|
| 213 |
-
$selfLink = (object)["href" => "https://api.mollie.com/v2/customers/cst_vzEExMcxj7/mandates?limit=50", "type" => "application/hal+json"];
|
| 214 |
-
$this->assertEquals($selfLink, $mandates->_links->self);
|
| 215 |
-
|
| 216 |
-
$documentationLink = (object)["href" => "https://mollie.com/en/docs/reference/customers/list-mandates", "type" => "text/html"];
|
| 217 |
-
$this->assertEquals($documentationLink, $mandates->_links->documentation);
|
| 218 |
-
}
|
| 219 |
-
|
| 220 |
-
public function testCustomerHasValidMandateWhenTrue()
|
| 221 |
-
{
|
| 222 |
-
$this->mockApiCall(
|
| 223 |
-
new Request('GET', '/v2/customers/cst_FhQJRw4s2n/mandates'),
|
| 224 |
-
new Response(
|
| 225 |
-
200,
|
| 226 |
-
[],
|
| 227 |
-
'{
|
| 228 |
-
"_embedded": {
|
| 229 |
-
"mandates": [
|
| 230 |
-
{
|
| 231 |
-
"resource": "mandate",
|
| 232 |
-
"id": "mdt_AcQl5fdL4h",
|
| 233 |
-
"status": "valid",
|
| 234 |
-
"method": "directdebit",
|
| 235 |
-
"details": {
|
| 236 |
-
"consumerName": "John Doe",
|
| 237 |
-
"consumerAccount": "NL55INGB0000000000",
|
| 238 |
-
"consumerBic": "INGBNL2A"
|
| 239 |
-
},
|
| 240 |
-
"mandateReference": null,
|
| 241 |
-
"signatureDate": "2018-05-07",
|
| 242 |
-
"createdAt": "2018-05-07T10:49:08+00:00",
|
| 243 |
-
"_links": {
|
| 244 |
-
"self": {
|
| 245 |
-
"href": "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n/mandates/mdt_AcQl5fdL4h",
|
| 246 |
-
"type": "application/hal+json"
|
| 247 |
-
},
|
| 248 |
-
"customer": {
|
| 249 |
-
"href": "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n",
|
| 250 |
-
"type": "application/hal+json"
|
| 251 |
-
}
|
| 252 |
-
}
|
| 253 |
-
}
|
| 254 |
-
]
|
| 255 |
-
},
|
| 256 |
-
"count": 1,
|
| 257 |
-
"_links": {
|
| 258 |
-
"documentation": {
|
| 259 |
-
"href": "https://mollie.com/en/docs/reference/customers/list-mandates",
|
| 260 |
-
"type": "text/html"
|
| 261 |
-
},
|
| 262 |
-
"self": {
|
| 263 |
-
"href": "https://api.mollie.com/v2/customers/cst_vzEExMcxj7/mandates?limit=50",
|
| 264 |
-
"type": "application/hal+json"
|
| 265 |
-
},
|
| 266 |
-
"previous": null,
|
| 267 |
-
"next": null
|
| 268 |
-
}
|
| 269 |
-
}'
|
| 270 |
-
)
|
| 271 |
-
);
|
| 272 |
-
|
| 273 |
-
$customer = $this->getCustomer();
|
| 274 |
-
|
| 275 |
-
$this->assertTrue($customer->hasValidMandate());
|
| 276 |
-
}
|
| 277 |
-
|
| 278 |
-
public function testCustomerHasValidMandateWhenFalse()
|
| 279 |
-
{
|
| 280 |
-
$this->mockApiCall(
|
| 281 |
-
new Request('GET', '/v2/customers/cst_FhQJRw4s2n/mandates'),
|
| 282 |
-
new Response(
|
| 283 |
-
200,
|
| 284 |
-
[],
|
| 285 |
-
'{
|
| 286 |
-
"_embedded": {
|
| 287 |
-
"mandates": []
|
| 288 |
-
},
|
| 289 |
-
"count": 0,
|
| 290 |
-
"_links": {
|
| 291 |
-
"documentation": {
|
| 292 |
-
"href": "https://mollie.com/en/docs/reference/customers/list-mandates",
|
| 293 |
-
"type": "text/html"
|
| 294 |
-
},
|
| 295 |
-
"self": {
|
| 296 |
-
"href": "https://api.mollie.com/v2/customers/cst_vzEExMcxj7/mandates?limit=50",
|
| 297 |
-
"type": "application/hal+json"
|
| 298 |
-
},
|
| 299 |
-
"previous": null,
|
| 300 |
-
"next": null
|
| 301 |
-
}
|
| 302 |
-
}'
|
| 303 |
-
)
|
| 304 |
-
);
|
| 305 |
-
|
| 306 |
-
$customer = $this->getCustomer();
|
| 307 |
-
|
| 308 |
-
$this->assertFalse($customer->hasValidMandate());
|
| 309 |
-
}
|
| 310 |
-
|
| 311 |
-
public function testCustomerHasValidMandateForMethodWhenFalse()
|
| 312 |
-
{
|
| 313 |
-
$this->mockApiCall(
|
| 314 |
-
new Request('GET', '/v2/customers/cst_FhQJRw4s2n/mandates'),
|
| 315 |
-
new Response(
|
| 316 |
-
200,
|
| 317 |
-
[],
|
| 318 |
-
'{
|
| 319 |
-
"_embedded": {
|
| 320 |
-
"mandates": []
|
| 321 |
-
},
|
| 322 |
-
"count": 0,
|
| 323 |
-
"_links": {
|
| 324 |
-
"documentation": {
|
| 325 |
-
"href": "https://mollie.com/en/docs/reference/customers/list-mandates",
|
| 326 |
-
"type": "text/html"
|
| 327 |
-
},
|
| 328 |
-
"self": {
|
| 329 |
-
"href": "https://api.mollie.com/v2/customers/cst_vzEExMcxj7/mandates?limit=50",
|
| 330 |
-
"type": "application/hal+json"
|
| 331 |
-
},
|
| 332 |
-
"previous": null,
|
| 333 |
-
"next": null
|
| 334 |
-
}
|
| 335 |
-
}'
|
| 336 |
-
)
|
| 337 |
-
);
|
| 338 |
-
|
| 339 |
-
$customer = $this->getCustomer();
|
| 340 |
-
|
| 341 |
-
$this->assertFalse($customer->hasValidMandateForMethod('directdebit'));
|
| 342 |
-
}
|
| 343 |
-
|
| 344 |
-
public function testCustomerHasValidMandateForMethodWhenTrue()
|
| 345 |
-
{
|
| 346 |
-
$this->mockApiCall(
|
| 347 |
-
new Request('GET', '/v2/customers/cst_FhQJRw4s2n/mandates'),
|
| 348 |
-
new Response(
|
| 349 |
-
200,
|
| 350 |
-
[],
|
| 351 |
-
'{
|
| 352 |
-
"_embedded": {
|
| 353 |
-
"mandates": [
|
| 354 |
-
{
|
| 355 |
-
"resource": "mandate",
|
| 356 |
-
"id": "mdt_AcQl5fdL4h",
|
| 357 |
-
"status": "valid",
|
| 358 |
-
"method": "directdebit",
|
| 359 |
-
"details": {
|
| 360 |
-
"consumerName": "John Doe",
|
| 361 |
-
"consumerAccount": "NL55INGB0000000000",
|
| 362 |
-
"consumerBic": "INGBNL2A"
|
| 363 |
-
},
|
| 364 |
-
"mandateReference": null,
|
| 365 |
-
"signatureDate": "2018-05-07",
|
| 366 |
-
"createdAt": "2018-05-07T10:49:08+00:00",
|
| 367 |
-
"_links": {
|
| 368 |
-
"self": {
|
| 369 |
-
"href": "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n/mandates/mdt_AcQl5fdL4h",
|
| 370 |
-
"type": "application/hal+json"
|
| 371 |
-
},
|
| 372 |
-
"customer": {
|
| 373 |
-
"href": "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n",
|
| 374 |
-
"type": "application/hal+json"
|
| 375 |
-
}
|
| 376 |
-
}
|
| 377 |
-
}
|
| 378 |
-
]
|
| 379 |
-
},
|
| 380 |
-
"count": 1,
|
| 381 |
-
"_links": {
|
| 382 |
-
"documentation": {
|
| 383 |
-
"href": "https://mollie.com/en/docs/reference/customers/list-mandates",
|
| 384 |
-
"type": "text/html"
|
| 385 |
-
},
|
| 386 |
-
"self": {
|
| 387 |
-
"href": "https://api.mollie.com/v2/customers/cst_vzEExMcxj7/mandates?limit=50",
|
| 388 |
-
"type": "application/hal+json"
|
| 389 |
-
},
|
| 390 |
-
"previous": null,
|
| 391 |
-
"next": null
|
| 392 |
-
}
|
| 393 |
-
}'
|
| 394 |
-
)
|
| 395 |
-
);
|
| 396 |
-
|
| 397 |
-
$customer = $this->getCustomer();
|
| 398 |
-
|
| 399 |
-
$this->assertTrue($customer->hasValidMandateForMethod('directdebit'));
|
| 400 |
-
}
|
| 401 |
-
|
| 402 |
-
/**
|
| 403 |
-
* @return Customer
|
| 404 |
-
*/
|
| 405 |
-
private function getCustomer()
|
| 406 |
-
{
|
| 407 |
-
$customerJson = '{
|
| 408 |
-
"resource": "customer",
|
| 409 |
-
"id": "cst_FhQJRw4s2n",
|
| 410 |
-
"mode": "test",
|
| 411 |
-
"name": "John Doe",
|
| 412 |
-
"email": "johndoe@example.org",
|
| 413 |
-
"locale": null,
|
| 414 |
-
"metadata": null,
|
| 415 |
-
"recentlyUsedMethods": [],
|
| 416 |
-
"createdAt": "2018-04-19T08:49:01+00:00",
|
| 417 |
-
"_links": {
|
| 418 |
-
"documentation": {
|
| 419 |
-
"href": "https://docs.mollie.com/reference/v2/customers-api/get-customer",
|
| 420 |
-
"type": "text/html"
|
| 421 |
-
}
|
| 422 |
-
}
|
| 423 |
-
}';
|
| 424 |
-
|
| 425 |
-
return $this->copy(json_decode($customerJson), new Customer($this->apiClient));
|
| 426 |
-
}
|
| 427 |
-
|
| 428 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Endpoints/MethodEndpointTest.php
DELETED
|
@@ -1,641 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\Api\Endpoints;
|
| 4 |
-
|
| 5 |
-
use GuzzleHttp\Psr7\Request;
|
| 6 |
-
use GuzzleHttp\Psr7\Response;
|
| 7 |
-
use Mollie\Api\Resources\Issuer;
|
| 8 |
-
use Mollie\Api\Resources\IssuerCollection;
|
| 9 |
-
use Mollie\Api\Resources\Method;
|
| 10 |
-
use Mollie\Api\Resources\MethodCollection;
|
| 11 |
-
use Mollie\Api\Resources\MethodPrice;
|
| 12 |
-
use Mollie\Api\Resources\MethodPriceCollection;
|
| 13 |
-
use stdClass;
|
| 14 |
-
use Tests\Mollie\TestHelpers\AmountObjectTestHelpers;
|
| 15 |
-
use Tests\Mollie\TestHelpers\LinkObjectTestHelpers;
|
| 16 |
-
|
| 17 |
-
class MethodEndpointTest extends BaseEndpointTest
|
| 18 |
-
{
|
| 19 |
-
use LinkObjectTestHelpers;
|
| 20 |
-
use AmountObjectTestHelpers;
|
| 21 |
-
|
| 22 |
-
public function testGetMethod()
|
| 23 |
-
{
|
| 24 |
-
$this->mockApiCall(
|
| 25 |
-
new Request('GET', '/v2/methods/ideal'),
|
| 26 |
-
new Response(
|
| 27 |
-
200,
|
| 28 |
-
[],
|
| 29 |
-
'{
|
| 30 |
-
"resource": "method",
|
| 31 |
-
"id": "ideal",
|
| 32 |
-
"description": "iDEAL",
|
| 33 |
-
"minimumAmount": {
|
| 34 |
-
"value": "0.01",
|
| 35 |
-
"currency": "EUR"
|
| 36 |
-
},
|
| 37 |
-
"maximumAmount": {
|
| 38 |
-
"value": "50000.00",
|
| 39 |
-
"currency": "EUR"
|
| 40 |
-
},
|
| 41 |
-
"image": {
|
| 42 |
-
"size1x": "https://www.mollie.com/images/payscreen/methods/ideal.png",
|
| 43 |
-
"size2x": "https://www.mollie.com/images/payscreen/methods/ideal%402x.png"
|
| 44 |
-
},
|
| 45 |
-
"_links": {
|
| 46 |
-
"self": {
|
| 47 |
-
"href": "https://api.mollie.com/v2/methods/ideal",
|
| 48 |
-
"type": "application/hal+json"
|
| 49 |
-
},
|
| 50 |
-
"documentation": {
|
| 51 |
-
"href": "https://docs.mollie.com/reference/v2/methods-api/get-method",
|
| 52 |
-
"type": "text/html"
|
| 53 |
-
}
|
| 54 |
-
}
|
| 55 |
-
}'
|
| 56 |
-
)
|
| 57 |
-
);
|
| 58 |
-
|
| 59 |
-
$idealMethod = $this->apiClient->methods->get('ideal');
|
| 60 |
-
|
| 61 |
-
$this->assertInstanceOf(Method::class, $idealMethod);
|
| 62 |
-
$this->assertEquals('ideal', $idealMethod->id);
|
| 63 |
-
$this->assertEquals('iDEAL', $idealMethod->description);
|
| 64 |
-
$this->assertAmountObject(0.01, 'EUR', $idealMethod->minimumAmount);
|
| 65 |
-
$this->assertAmountObject(50000, 'EUR', $idealMethod->maximumAmount);
|
| 66 |
-
$this->assertEquals('https://www.mollie.com/images/payscreen/methods/ideal.png', $idealMethod->image->size1x);
|
| 67 |
-
$this->assertEquals('https://www.mollie.com/images/payscreen/methods/ideal%402x.png', $idealMethod->image->size2x);
|
| 68 |
-
|
| 69 |
-
$this->assertLinkObject(
|
| 70 |
-
'https://api.mollie.com/v2/methods/ideal',
|
| 71 |
-
'application/hal+json',
|
| 72 |
-
$idealMethod->_links->self
|
| 73 |
-
);
|
| 74 |
-
|
| 75 |
-
$this->assertLinkObject(
|
| 76 |
-
'https://docs.mollie.com/reference/v2/methods-api/get-method',
|
| 77 |
-
'text/html',
|
| 78 |
-
$idealMethod->_links->documentation
|
| 79 |
-
);
|
| 80 |
-
}
|
| 81 |
-
|
| 82 |
-
public function testGetMethodWithIncludeIssuers()
|
| 83 |
-
{
|
| 84 |
-
$this->mockApiCall(
|
| 85 |
-
new Request('GET', '/v2/methods/ideal?include=issuers'),
|
| 86 |
-
new Response(
|
| 87 |
-
200,
|
| 88 |
-
[],
|
| 89 |
-
'{
|
| 90 |
-
"resource": "method",
|
| 91 |
-
"id": "ideal",
|
| 92 |
-
"description": "iDEAL",
|
| 93 |
-
"minimumAmount": {
|
| 94 |
-
"value": "0.01",
|
| 95 |
-
"currency": "EUR"
|
| 96 |
-
},
|
| 97 |
-
"maximumAmount": {
|
| 98 |
-
"value": "50000.00",
|
| 99 |
-
"currency": "EUR"
|
| 100 |
-
},
|
| 101 |
-
"image": {
|
| 102 |
-
"size1x": "https://www.mollie.com/images/payscreen/methods/ideal.png",
|
| 103 |
-
"size2x": "https://www.mollie.com/images/payscreen/methods/ideal%402x.png"
|
| 104 |
-
},
|
| 105 |
-
"issuers": [
|
| 106 |
-
{
|
| 107 |
-
"resource": "issuer",
|
| 108 |
-
"id": "ideal_TESTNL99",
|
| 109 |
-
"name": "TBM Bank",
|
| 110 |
-
"method": "ideal",
|
| 111 |
-
"image": {
|
| 112 |
-
"size1x": "https://www.mollie.com/images/checkout/v2/ideal-issuer-icons/TESTNL99.png",
|
| 113 |
-
"size2x": "https://www.mollie.com/images/checkout/v2/ideal-issuer-icons/TESTNL99.png"
|
| 114 |
-
}
|
| 115 |
-
}
|
| 116 |
-
],
|
| 117 |
-
|
| 118 |
-
"_links": {
|
| 119 |
-
"self": {
|
| 120 |
-
"href": "https://api.mollie.com/v2/methods/ideal",
|
| 121 |
-
"type": "application/hal+json"
|
| 122 |
-
},
|
| 123 |
-
"documentation": {
|
| 124 |
-
"href": "https://docs.mollie.com/reference/v2/methods-api/get-method",
|
| 125 |
-
"type": "text/html"
|
| 126 |
-
}
|
| 127 |
-
}
|
| 128 |
-
}'
|
| 129 |
-
)
|
| 130 |
-
);
|
| 131 |
-
|
| 132 |
-
$idealMethod = $this->apiClient->methods->get('ideal', ['include' => 'issuers']);
|
| 133 |
-
|
| 134 |
-
$this->assertInstanceOf(Method::class, $idealMethod);
|
| 135 |
-
$this->assertEquals('ideal', $idealMethod->id);
|
| 136 |
-
$this->assertEquals('iDEAL', $idealMethod->description);
|
| 137 |
-
$this->assertAmountObject(0.01, 'EUR', $idealMethod->minimumAmount);
|
| 138 |
-
$this->assertAmountObject(50000, 'EUR', $idealMethod->maximumAmount);
|
| 139 |
-
$this->assertEquals('https://www.mollie.com/images/payscreen/methods/ideal.png', $idealMethod->image->size1x);
|
| 140 |
-
$this->assertEquals('https://www.mollie.com/images/payscreen/methods/ideal%402x.png', $idealMethod->image->size2x);
|
| 141 |
-
|
| 142 |
-
$issuers = $idealMethod->issuers();
|
| 143 |
-
$this->assertInstanceOf(IssuerCollection::class, $issuers);
|
| 144 |
-
$this->assertCount(1, $issuers);
|
| 145 |
-
|
| 146 |
-
$testIssuer = $issuers[0];
|
| 147 |
-
|
| 148 |
-
$this->assertInstanceOf(Issuer::class, $testIssuer);
|
| 149 |
-
$this->assertEquals('ideal_TESTNL99', $testIssuer->id);
|
| 150 |
-
$this->assertEquals('TBM Bank', $testIssuer->name);
|
| 151 |
-
$this->assertEquals('ideal', $testIssuer->method);
|
| 152 |
-
|
| 153 |
-
$expectedSize1xImageLink = 'https://www.mollie.com/images/checkout/v2/ideal-issuer-icons/TESTNL99.png';
|
| 154 |
-
$this->assertEquals($expectedSize1xImageLink, $testIssuer->image->size1x);
|
| 155 |
-
|
| 156 |
-
$expectedSize2xImageLink = 'https://www.mollie.com/images/checkout/v2/ideal-issuer-icons/TESTNL99.png';
|
| 157 |
-
$this->assertEquals($expectedSize2xImageLink, $testIssuer->image->size2x);
|
| 158 |
-
|
| 159 |
-
$this->assertLinkObject(
|
| 160 |
-
'https://api.mollie.com/v2/methods/ideal',
|
| 161 |
-
'application/hal+json',
|
| 162 |
-
$idealMethod->_links->self
|
| 163 |
-
);
|
| 164 |
-
|
| 165 |
-
$this->assertLinkObject(
|
| 166 |
-
'https://docs.mollie.com/reference/v2/methods-api/get-method',
|
| 167 |
-
'text/html',
|
| 168 |
-
$idealMethod->_links->documentation
|
| 169 |
-
);
|
| 170 |
-
}
|
| 171 |
-
|
| 172 |
-
public function testGetMethodWithIncludePricing()
|
| 173 |
-
{
|
| 174 |
-
$this->mockApiCall(
|
| 175 |
-
new Request('GET', '/v2/methods/ideal?include=pricing'),
|
| 176 |
-
new Response(
|
| 177 |
-
200,
|
| 178 |
-
[],
|
| 179 |
-
'{
|
| 180 |
-
"resource": "method",
|
| 181 |
-
"id": "ideal",
|
| 182 |
-
"description": "iDEAL",
|
| 183 |
-
"minimumAmount": {
|
| 184 |
-
"value": "0.01",
|
| 185 |
-
"currency": "EUR"
|
| 186 |
-
},
|
| 187 |
-
"maximumAmount": {
|
| 188 |
-
"value": "50000.00",
|
| 189 |
-
"currency": "EUR"
|
| 190 |
-
},
|
| 191 |
-
"image": {
|
| 192 |
-
"size1x": "https://www.mollie.com/external/icons/payment-methods/ideal.png",
|
| 193 |
-
"size2x": "https://www.mollie.com/external/icons/payment-methods/ideal%402x.png",
|
| 194 |
-
"svg": "https://www.mollie.com/external/icons/payment-methods/ideal.svg"
|
| 195 |
-
},
|
| 196 |
-
"pricing": [
|
| 197 |
-
{
|
| 198 |
-
"description": "The Netherlands",
|
| 199 |
-
"fixed": {
|
| 200 |
-
"value": "0.29",
|
| 201 |
-
"currency": "EUR"
|
| 202 |
-
},
|
| 203 |
-
"variable": "0"
|
| 204 |
-
}
|
| 205 |
-
],
|
| 206 |
-
"_links": {
|
| 207 |
-
"self": {
|
| 208 |
-
"href": "https://api.mollie.com/v2/methods/ideal",
|
| 209 |
-
"type": "application/hal+json"
|
| 210 |
-
},
|
| 211 |
-
"documentation": {
|
| 212 |
-
"href": "https://docs.mollie.com/reference/v2/methods-api/get-method",
|
| 213 |
-
"type": "text/html"
|
| 214 |
-
}
|
| 215 |
-
}
|
| 216 |
-
}'
|
| 217 |
-
)
|
| 218 |
-
);
|
| 219 |
-
|
| 220 |
-
$method = $this->apiClient->methods->get('ideal', ['include' => 'pricing']);
|
| 221 |
-
|
| 222 |
-
$this->assertInstanceOf(Method::class, $method);
|
| 223 |
-
$this->assertEquals('method', $method->resource);
|
| 224 |
-
$this->assertEquals('ideal', $method->id);
|
| 225 |
-
$this->assertEquals('iDEAL', $method->description);
|
| 226 |
-
$this->assertAmountObject(0.01, 'EUR', $method->minimumAmount);
|
| 227 |
-
$this->assertAmountObject(50000, 'EUR', $method->maximumAmount);
|
| 228 |
-
$this->assertEquals(
|
| 229 |
-
'https://www.mollie.com/external/icons/payment-methods/ideal.png',
|
| 230 |
-
$method->image->size1x);
|
| 231 |
-
$this->assertEquals(
|
| 232 |
-
'https://www.mollie.com/external/icons/payment-methods/ideal%402x.png',
|
| 233 |
-
$method->image->size2x);
|
| 234 |
-
|
| 235 |
-
$this->assertEquals(
|
| 236 |
-
'https://www.mollie.com/external/icons/payment-methods/ideal.svg',
|
| 237 |
-
$method->image->svg);
|
| 238 |
-
|
| 239 |
-
$this->assertLinkObject(
|
| 240 |
-
'https://api.mollie.com/v2/methods/ideal',
|
| 241 |
-
'application/hal+json',
|
| 242 |
-
$method->_links->self
|
| 243 |
-
);
|
| 244 |
-
|
| 245 |
-
$this->assertLinkObject(
|
| 246 |
-
'https://docs.mollie.com/reference/v2/methods-api/get-method',
|
| 247 |
-
'text/html',
|
| 248 |
-
$method->_links->documentation
|
| 249 |
-
);
|
| 250 |
-
|
| 251 |
-
$price = $method->pricing[0];
|
| 252 |
-
|
| 253 |
-
$this->assertEquals('The Netherlands', $price->description);
|
| 254 |
-
$this->assertAmountObject(0.29, 'EUR', $price->fixed);
|
| 255 |
-
$this->assertEquals('0', $price->variable);
|
| 256 |
-
|
| 257 |
-
$method_prices = $method->pricing();
|
| 258 |
-
|
| 259 |
-
$this->assertInstanceOf(MethodPriceCollection::class, $method_prices);
|
| 260 |
-
|
| 261 |
-
$method_price = $method_prices[0];
|
| 262 |
-
$this->assertInstanceOf(MethodPrice::class, $method_price);
|
| 263 |
-
$this->assertAmountObject(0.29, 'EUR', $method_price->fixed);
|
| 264 |
-
$this->assertEquals('0', $method_price->variable);
|
| 265 |
-
}
|
| 266 |
-
|
| 267 |
-
public function testGetTranslatedMethod()
|
| 268 |
-
{
|
| 269 |
-
$this->mockApiCall(
|
| 270 |
-
new Request('GET', '/v2/methods/sofort?locale=de_DE'),
|
| 271 |
-
new Response(
|
| 272 |
-
200,
|
| 273 |
-
[],
|
| 274 |
-
'{
|
| 275 |
-
"resource": "method",
|
| 276 |
-
"id": "sofort",
|
| 277 |
-
"description": "SOFORT \u00dcberweisung",
|
| 278 |
-
"minimumAmount": {
|
| 279 |
-
"value": "0.01",
|
| 280 |
-
"currency": "EUR"
|
| 281 |
-
},
|
| 282 |
-
"maximumAmount": {
|
| 283 |
-
"value": "50000.00",
|
| 284 |
-
"currency": "EUR"
|
| 285 |
-
},
|
| 286 |
-
"image": {
|
| 287 |
-
"size1x": "https://www.mollie.com/images/payscreen/methods/sofort.png",
|
| 288 |
-
"size2x": "https://www.mollie.com/images/payscreen/methods/sofort%402x.png"
|
| 289 |
-
},
|
| 290 |
-
"_links": {
|
| 291 |
-
"self": {
|
| 292 |
-
"href": "https://api.mollie.com/v2/methods/sofort",
|
| 293 |
-
"type": "application/hal+json"
|
| 294 |
-
},
|
| 295 |
-
"documentation": {
|
| 296 |
-
"href": "https://docs.mollie.com/reference/v2/methods-api/get-method",
|
| 297 |
-
"type": "text/html"
|
| 298 |
-
}
|
| 299 |
-
}
|
| 300 |
-
}'
|
| 301 |
-
)
|
| 302 |
-
);
|
| 303 |
-
|
| 304 |
-
$method = $this->apiClient->methods->get('sofort', ['locale' => 'de_DE']);
|
| 305 |
-
|
| 306 |
-
$this->assertInstanceOf(Method::class, $method);
|
| 307 |
-
$this->assertEquals('sofort', $method->id);
|
| 308 |
-
$this->assertEquals('SOFORT Überweisung', $method->description);
|
| 309 |
-
$this->assertAmountObject(0.01, 'EUR', $method->minimumAmount);
|
| 310 |
-
$this->assertAmountObject(50000, 'EUR', $method->maximumAmount);
|
| 311 |
-
|
| 312 |
-
$amount = new Stdclass();
|
| 313 |
-
$amount->size1x = 'https://www.mollie.com/images/payscreen/methods/sofort.png';
|
| 314 |
-
$amount->size2x = 'https://www.mollie.com/images/payscreen/methods/sofort%402x.png';
|
| 315 |
-
|
| 316 |
-
$selfLink = (object)[
|
| 317 |
-
'href' => 'https://api.mollie.com/v2/methods/sofort',
|
| 318 |
-
'type' => 'application/hal+json'
|
| 319 |
-
];
|
| 320 |
-
$this->assertEquals($selfLink, $method->_links->self);
|
| 321 |
-
|
| 322 |
-
$documentationLink = (object)[
|
| 323 |
-
'href' => 'https://docs.mollie.com/reference/v2/methods-api/get-method',
|
| 324 |
-
'type' => 'text/html'
|
| 325 |
-
];
|
| 326 |
-
|
| 327 |
-
$this->assertEquals($documentationLink, $method->_links->documentation);
|
| 328 |
-
}
|
| 329 |
-
|
| 330 |
-
public function testListAllActiveMethods()
|
| 331 |
-
{
|
| 332 |
-
$this->mockApiCall(
|
| 333 |
-
new Request('GET', '/v2/methods'),
|
| 334 |
-
new Response(
|
| 335 |
-
200,
|
| 336 |
-
[],
|
| 337 |
-
'{
|
| 338 |
-
"_embedded": {
|
| 339 |
-
"methods": [
|
| 340 |
-
{
|
| 341 |
-
"resource": "method",
|
| 342 |
-
"id": "ideal",
|
| 343 |
-
"description": "iDEAL",
|
| 344 |
-
"minimumAmount": {
|
| 345 |
-
"value": "0.01",
|
| 346 |
-
"currency": "EUR"
|
| 347 |
-
},
|
| 348 |
-
"maximumAmount": {
|
| 349 |
-
"value": "50000.00",
|
| 350 |
-
"currency": "EUR"
|
| 351 |
-
},
|
| 352 |
-
"image": {
|
| 353 |
-
"size1x": "https://www.mollie.com/images/payscreen/methods/ideal.png",
|
| 354 |
-
"size2x": "https://www.mollie.com/images/payscreen/methods/ideal%402x.png"
|
| 355 |
-
},
|
| 356 |
-
"_links": {
|
| 357 |
-
"self": {
|
| 358 |
-
"href": "https://api.mollie.com/v2/methods/ideal",
|
| 359 |
-
"type": "application/hal+json"
|
| 360 |
-
}
|
| 361 |
-
}
|
| 362 |
-
},
|
| 363 |
-
{
|
| 364 |
-
"resource": "method",
|
| 365 |
-
"id": "creditcard",
|
| 366 |
-
"description": "Credit card",
|
| 367 |
-
"minimumAmount": {
|
| 368 |
-
"value": "0.01",
|
| 369 |
-
"currency": "EUR"
|
| 370 |
-
},
|
| 371 |
-
"maximumAmount": {
|
| 372 |
-
"value": "2000.00",
|
| 373 |
-
"currency": "EUR"
|
| 374 |
-
},
|
| 375 |
-
"image": {
|
| 376 |
-
"size1x": "https://www.mollie.com/images/payscreen/methods/creditcard.png",
|
| 377 |
-
"size2x": "https://www.mollie.com/images/payscreen/methods/creditcard%402x.png"
|
| 378 |
-
},
|
| 379 |
-
"_links": {
|
| 380 |
-
"self": {
|
| 381 |
-
"href": "https://api.mollie.com/v2/methods/creditcard",
|
| 382 |
-
"type": "application/hal+json"
|
| 383 |
-
}
|
| 384 |
-
}
|
| 385 |
-
},
|
| 386 |
-
{
|
| 387 |
-
"resource": "method",
|
| 388 |
-
"id": "mistercash",
|
| 389 |
-
"description": "Bancontact",
|
| 390 |
-
"minimumAmount": {
|
| 391 |
-
"value": "0.02",
|
| 392 |
-
"currency": "EUR"
|
| 393 |
-
},
|
| 394 |
-
"maximumAmount": {
|
| 395 |
-
"value": "50000.00",
|
| 396 |
-
"currency": "EUR"
|
| 397 |
-
},
|
| 398 |
-
"image": {
|
| 399 |
-
"size1x": "https://www.mollie.com/images/payscreen/methods/mistercash.png",
|
| 400 |
-
"size2x": "https://www.mollie.com/images/payscreen/methods/mistercash%402x.png"
|
| 401 |
-
},
|
| 402 |
-
"_links": {
|
| 403 |
-
"self": {
|
| 404 |
-
"href": "https://api.mollie.com/v2/methods/mistercash",
|
| 405 |
-
"type": "application/hal+json"
|
| 406 |
-
}
|
| 407 |
-
}
|
| 408 |
-
},
|
| 409 |
-
{
|
| 410 |
-
"resource": "method",
|
| 411 |
-
"id": "giftcard",
|
| 412 |
-
"description": "Gift cards",
|
| 413 |
-
"minimumAmount": {
|
| 414 |
-
"value": "0.01",
|
| 415 |
-
"currency": "EUR"
|
| 416 |
-
},
|
| 417 |
-
"maximumAmount": null,
|
| 418 |
-
"image": {
|
| 419 |
-
"size1x": "https://www.mollie.com/images/payscreen/methods/giftcard.png",
|
| 420 |
-
"size2x": "https://www.mollie.com/images/payscreen/methods/giftcard%402x.png"
|
| 421 |
-
},
|
| 422 |
-
"_links": {
|
| 423 |
-
"self": {
|
| 424 |
-
"href": "https://api.mollie.com/v2/methods/giftcard",
|
| 425 |
-
"type": "application/hal+json"
|
| 426 |
-
}
|
| 427 |
-
}
|
| 428 |
-
}
|
| 429 |
-
]
|
| 430 |
-
},
|
| 431 |
-
"count": 4,
|
| 432 |
-
"_links": {
|
| 433 |
-
"documentation": {
|
| 434 |
-
"href": "https://docs.mollie.com/reference/v2/methods-api/list-methods",
|
| 435 |
-
"type": "text/html"
|
| 436 |
-
},
|
| 437 |
-
"self": {
|
| 438 |
-
"href": "http://api.mollie.com/v2/methods",
|
| 439 |
-
"type": "application/hal+json"
|
| 440 |
-
}
|
| 441 |
-
}
|
| 442 |
-
}'
|
| 443 |
-
)
|
| 444 |
-
);
|
| 445 |
-
|
| 446 |
-
$methods = $this->apiClient->methods->allActive();
|
| 447 |
-
|
| 448 |
-
$this->assertInstanceOf(MethodCollection::class, $methods);
|
| 449 |
-
$this->assertEquals(4, $methods->count);
|
| 450 |
-
$this->assertCount(4, $methods);
|
| 451 |
-
|
| 452 |
-
$documentationLink = (object)[
|
| 453 |
-
'href' => 'https://docs.mollie.com/reference/v2/methods-api/list-methods',
|
| 454 |
-
'type' => 'text/html'
|
| 455 |
-
];
|
| 456 |
-
$this->assertEquals($documentationLink, $methods->_links->documentation);
|
| 457 |
-
|
| 458 |
-
$selfLink = (object)[
|
| 459 |
-
'href' => 'http://api.mollie.com/v2/methods',
|
| 460 |
-
'type' => 'application/hal+json'
|
| 461 |
-
];
|
| 462 |
-
$this->assertEquals($selfLink, $methods->_links->self);
|
| 463 |
-
|
| 464 |
-
$creditcardMethod = $methods[1];
|
| 465 |
-
|
| 466 |
-
$this->assertInstanceOf(Method::class, $creditcardMethod);
|
| 467 |
-
$this->assertEquals('creditcard', $creditcardMethod->id);
|
| 468 |
-
$this->assertEquals('Credit card', $creditcardMethod->description);
|
| 469 |
-
$this->assertAmountObject(0.01, 'EUR', $creditcardMethod->minimumAmount);
|
| 470 |
-
$this->assertAmountObject(2000, 'EUR', $creditcardMethod->maximumAmount);
|
| 471 |
-
$this->assertEquals('https://www.mollie.com/images/payscreen/methods/creditcard.png', $creditcardMethod->image->size1x);
|
| 472 |
-
$this->assertEquals('https://www.mollie.com/images/payscreen/methods/creditcard%402x.png', $creditcardMethod->image->size2x);
|
| 473 |
-
|
| 474 |
-
$selfLink = (object)[
|
| 475 |
-
'href' => 'https://api.mollie.com/v2/methods/creditcard',
|
| 476 |
-
'type' => 'application/hal+json'
|
| 477 |
-
];
|
| 478 |
-
$this->assertEquals($selfLink, $creditcardMethod->_links->self);
|
| 479 |
-
}
|
| 480 |
-
|
| 481 |
-
public function testListAllAvailableMethods()
|
| 482 |
-
{
|
| 483 |
-
$this->mockApiCall(
|
| 484 |
-
new Request('GET', '/v2/methods/all?include=pricing'),
|
| 485 |
-
new Response(
|
| 486 |
-
200,
|
| 487 |
-
[],
|
| 488 |
-
'{
|
| 489 |
-
"_embedded": {
|
| 490 |
-
"methods": [
|
| 491 |
-
{
|
| 492 |
-
"resource": "method",
|
| 493 |
-
"id": "ideal",
|
| 494 |
-
"description": "iDEAL",
|
| 495 |
-
"minimumAmount": {
|
| 496 |
-
"value": "0.01",
|
| 497 |
-
"currency": "EUR"
|
| 498 |
-
},
|
| 499 |
-
"maximumAmount": {
|
| 500 |
-
"value": "50000.00",
|
| 501 |
-
"currency": "EUR"
|
| 502 |
-
},
|
| 503 |
-
"image": {
|
| 504 |
-
"size1x": "https://www.mollie.com/images/payscreen/methods/ideal.png",
|
| 505 |
-
"size2x": "https://www.mollie.com/images/payscreen/methods/ideal%402x.png"
|
| 506 |
-
},
|
| 507 |
-
"pricing": [
|
| 508 |
-
{
|
| 509 |
-
"description": "Netherlands",
|
| 510 |
-
"fixed": {
|
| 511 |
-
"value": "0.29",
|
| 512 |
-
"currency": "EUR"
|
| 513 |
-
},
|
| 514 |
-
"variable": "0"
|
| 515 |
-
}
|
| 516 |
-
],
|
| 517 |
-
"_links": {
|
| 518 |
-
"self": {
|
| 519 |
-
"href": "https://api.mollie.com/v2/methods/ideal",
|
| 520 |
-
"type": "application/hal+json"
|
| 521 |
-
}
|
| 522 |
-
}
|
| 523 |
-
},
|
| 524 |
-
{
|
| 525 |
-
"resource": "method",
|
| 526 |
-
"id": "creditcard",
|
| 527 |
-
"description": "Credit card",
|
| 528 |
-
"minimumAmount": {
|
| 529 |
-
"value": "0.01",
|
| 530 |
-
"currency": "EUR"
|
| 531 |
-
},
|
| 532 |
-
"maximumAmount": {
|
| 533 |
-
"value": "2000.00",
|
| 534 |
-
"currency": "EUR"
|
| 535 |
-
},
|
| 536 |
-
"image": {
|
| 537 |
-
"size1x": "https://www.mollie.com/images/payscreen/methods/creditcard.png",
|
| 538 |
-
"size2x": "https://www.mollie.com/images/payscreen/methods/creditcard%402x.png"
|
| 539 |
-
},
|
| 540 |
-
"_links": {
|
| 541 |
-
"self": {
|
| 542 |
-
"href": "https://api.mollie.com/v2/methods/creditcard",
|
| 543 |
-
"type": "application/hal+json"
|
| 544 |
-
}
|
| 545 |
-
}
|
| 546 |
-
},
|
| 547 |
-
{
|
| 548 |
-
"resource": "method",
|
| 549 |
-
"id": "mistercash",
|
| 550 |
-
"description": "Bancontact",
|
| 551 |
-
"minimumAmount": {
|
| 552 |
-
"value": "0.02",
|
| 553 |
-
"currency": "EUR"
|
| 554 |
-
},
|
| 555 |
-
"maximumAmount": {
|
| 556 |
-
"value": "50000.00",
|
| 557 |
-
"currency": "EUR"
|
| 558 |
-
},
|
| 559 |
-
"image": {
|
| 560 |
-
"size1x": "https://www.mollie.com/images/payscreen/methods/mistercash.png",
|
| 561 |
-
"size2x": "https://www.mollie.com/images/payscreen/methods/mistercash%402x.png"
|
| 562 |
-
},
|
| 563 |
-
"_links": {
|
| 564 |
-
"self": {
|
| 565 |
-
"href": "https://api.mollie.com/v2/methods/mistercash",
|
| 566 |
-
"type": "application/hal+json"
|
| 567 |
-
}
|
| 568 |
-
}
|
| 569 |
-
},
|
| 570 |
-
{
|
| 571 |
-
"resource": "method",
|
| 572 |
-
"id": "giftcard",
|
| 573 |
-
"description": "Gift cards",
|
| 574 |
-
"minimumAmount": {
|
| 575 |
-
"value": "0.01",
|
| 576 |
-
"currency": "EUR"
|
| 577 |
-
},
|
| 578 |
-
"maximumAmount": null,
|
| 579 |
-
"image": {
|
| 580 |
-
"size1x": "https://www.mollie.com/images/payscreen/methods/giftcard.png",
|
| 581 |
-
"size2x": "https://www.mollie.com/images/payscreen/methods/giftcard%402x.png"
|
| 582 |
-
},
|
| 583 |
-
"_links": {
|
| 584 |
-
"self": {
|
| 585 |
-
"href": "https://api.mollie.com/v2/methods/giftcard",
|
| 586 |
-
"type": "application/hal+json"
|
| 587 |
-
}
|
| 588 |
-
}
|
| 589 |
-
}
|
| 590 |
-
]
|
| 591 |
-
},
|
| 592 |
-
"count": 4,
|
| 593 |
-
"_links": {
|
| 594 |
-
"documentation": {
|
| 595 |
-
"href": "https://docs.mollie.com/reference/v2/methods-api/list-methods",
|
| 596 |
-
"type": "text/html"
|
| 597 |
-
},
|
| 598 |
-
"self": {
|
| 599 |
-
"href": "http://api.mollie.com/v2/methods",
|
| 600 |
-
"type": "application/hal+json"
|
| 601 |
-
}
|
| 602 |
-
}
|
| 603 |
-
}'
|
| 604 |
-
)
|
| 605 |
-
);
|
| 606 |
-
|
| 607 |
-
$methods = $this->apiClient->methods->allAvailable(['include' => 'pricing']);
|
| 608 |
-
|
| 609 |
-
$this->assertInstanceOf(MethodCollection::class, $methods);
|
| 610 |
-
$this->assertEquals(4, $methods->count);
|
| 611 |
-
$this->assertCount(4, $methods);
|
| 612 |
-
|
| 613 |
-
$this->assertLinkObject(
|
| 614 |
-
'https://docs.mollie.com/reference/v2/methods-api/list-methods',
|
| 615 |
-
'text/html',
|
| 616 |
-
$methods->_links->documentation
|
| 617 |
-
);
|
| 618 |
-
|
| 619 |
-
$this->assertLinkObject(
|
| 620 |
-
'http://api.mollie.com/v2/methods',
|
| 621 |
-
'application/hal+json',
|
| 622 |
-
$methods->_links->self
|
| 623 |
-
);
|
| 624 |
-
|
| 625 |
-
$creditcardMethod = $methods[1];
|
| 626 |
-
|
| 627 |
-
$this->assertInstanceOf(Method::class, $creditcardMethod);
|
| 628 |
-
$this->assertEquals('creditcard', $creditcardMethod->id);
|
| 629 |
-
$this->assertEquals('Credit card', $creditcardMethod->description);
|
| 630 |
-
$this->assertAmountObject(0.01, 'EUR', $creditcardMethod->minimumAmount);
|
| 631 |
-
$this->assertAmountObject(2000, 'EUR', $creditcardMethod->maximumAmount);
|
| 632 |
-
$this->assertEquals('https://www.mollie.com/images/payscreen/methods/creditcard.png', $creditcardMethod->image->size1x);
|
| 633 |
-
$this->assertEquals('https://www.mollie.com/images/payscreen/methods/creditcard%402x.png', $creditcardMethod->image->size2x);
|
| 634 |
-
|
| 635 |
-
$this->assertLinkObject(
|
| 636 |
-
'https://api.mollie.com/v2/methods/creditcard',
|
| 637 |
-
'application/hal+json',
|
| 638 |
-
$creditcardMethod->_links->self
|
| 639 |
-
);
|
| 640 |
-
}
|
| 641 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Endpoints/OnboardingEndpointTest.php
DELETED
|
@@ -1,82 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
declare(strict_types=1);
|
| 4 |
-
|
| 5 |
-
namespace Tests\Mollie\API\Endpoints;
|
| 6 |
-
|
| 7 |
-
use GuzzleHttp\Psr7\Request;
|
| 8 |
-
use GuzzleHttp\Psr7\Response;
|
| 9 |
-
use Mollie\Api\Resources\Onboarding;
|
| 10 |
-
use Mollie\Api\Types\OnboardingStatus;
|
| 11 |
-
|
| 12 |
-
final class OnboardingEndpointTest extends BaseEndpointTest
|
| 13 |
-
{
|
| 14 |
-
public function testGetWorks()
|
| 15 |
-
{
|
| 16 |
-
$this->mockApiCall(
|
| 17 |
-
new Request('GET', '/v2/onboarding/me'),
|
| 18 |
-
new Response(
|
| 19 |
-
200,
|
| 20 |
-
[],
|
| 21 |
-
'{
|
| 22 |
-
"resource": "onboarding",
|
| 23 |
-
"name": "Mollie B.V.",
|
| 24 |
-
"signedUpAt": "2018-12-20T10:49:08+00:00",
|
| 25 |
-
"status": "completed",
|
| 26 |
-
"canReceivePayments": true,
|
| 27 |
-
"canReceiveSettlements": true,
|
| 28 |
-
"_links": {
|
| 29 |
-
"self": {
|
| 30 |
-
"href": "https://api.mollie.com/v2/onboarding/me",
|
| 31 |
-
"type": "application/hal+json"
|
| 32 |
-
},
|
| 33 |
-
"onboarding": {
|
| 34 |
-
"href": "https://www.mollie.com/dashboard/onboarding",
|
| 35 |
-
"type": "text/html"
|
| 36 |
-
},
|
| 37 |
-
"organization": {
|
| 38 |
-
"href": "https://api.mollie.com/v2/organization/org_12345",
|
| 39 |
-
"type": "application/hal+json"
|
| 40 |
-
},
|
| 41 |
-
"documentation": {
|
| 42 |
-
"href": "https://docs.mollie.com/reference/v2/onboarding-api/get-onboarding-status",
|
| 43 |
-
"type": "text/html"
|
| 44 |
-
}
|
| 45 |
-
}
|
| 46 |
-
}'
|
| 47 |
-
)
|
| 48 |
-
);
|
| 49 |
-
|
| 50 |
-
$onboarding = $this->apiClient->onboarding->get();
|
| 51 |
-
|
| 52 |
-
$this->assertInstanceOf(Onboarding::class, $onboarding);
|
| 53 |
-
$this->assertEquals("onboarding", $onboarding->resource);
|
| 54 |
-
$this->assertEquals("Mollie B.V.", $onboarding->name);
|
| 55 |
-
$this->assertEquals(OnboardingStatus::COMPLETED, $onboarding->status);
|
| 56 |
-
$this->assertEquals("2018-12-20T10:49:08+00:00", $onboarding->signedUpAt);
|
| 57 |
-
$this->assertEquals(true, $onboarding->canReceivePayments);
|
| 58 |
-
$this->assertEquals(true, $onboarding->canReceiveSettlements);
|
| 59 |
-
|
| 60 |
-
$selfLink = (object)['href' => 'https://api.mollie.com/v2/onboarding/me', 'type' => 'application/hal+json'];
|
| 61 |
-
$this->assertEquals($selfLink, $onboarding->_links->self);
|
| 62 |
-
|
| 63 |
-
$onboardingLink = (object)['href' => 'https://www.mollie.com/dashboard/onboarding', 'type' => 'text/html'];
|
| 64 |
-
$this->assertEquals($onboardingLink, $onboarding->_links->onboarding);
|
| 65 |
-
|
| 66 |
-
$organizationLink = (object)['href' => 'https://api.mollie.com/v2/organization/org_12345', 'type' => 'application/hal+json'];
|
| 67 |
-
$this->assertEquals($organizationLink, $onboarding->_links->organization);
|
| 68 |
-
|
| 69 |
-
$documentationLink = (object)['href' => 'https://docs.mollie.com/reference/v2/onboarding-api/get-onboarding-status', 'type' => 'text/html'];
|
| 70 |
-
$this->assertEquals($documentationLink, $onboarding->_links->documentation);
|
| 71 |
-
}
|
| 72 |
-
|
| 73 |
-
public function testSubmitWorks()
|
| 74 |
-
{
|
| 75 |
-
$this->mockApiCall(
|
| 76 |
-
new Request('POST', '/v2/onboarding/me'),
|
| 77 |
-
new Response(204)
|
| 78 |
-
);
|
| 79 |
-
|
| 80 |
-
$this->apiClient->onboarding->submit();
|
| 81 |
-
}
|
| 82 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Endpoints/OrderEndpointTest.php
DELETED
|
@@ -1,1085 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\Api\Endpoints;
|
| 4 |
-
|
| 5 |
-
use GuzzleHttp\Psr7\Request;
|
| 6 |
-
use GuzzleHttp\Psr7\Response;
|
| 7 |
-
use Mollie\Api\Resources\Order;
|
| 8 |
-
use Mollie\Api\Resources\OrderCollection;
|
| 9 |
-
use Mollie\Api\Resources\Payment;
|
| 10 |
-
use Mollie\Api\Resources\PaymentCollection;
|
| 11 |
-
use Mollie\Api\Resources\Shipment;
|
| 12 |
-
use Mollie\Api\Types\OrderLineStatus;
|
| 13 |
-
use Mollie\Api\Types\OrderLineType;
|
| 14 |
-
use Mollie\Api\Types\OrderStatus;
|
| 15 |
-
use Tests\Mollie\TestHelpers\AmountObjectTestHelpers;
|
| 16 |
-
use Tests\Mollie\TestHelpers\LinkObjectTestHelpers;
|
| 17 |
-
use stdClass;
|
| 18 |
-
|
| 19 |
-
class OrderEndpointTest extends BaseEndpointTest
|
| 20 |
-
{
|
| 21 |
-
use LinkObjectTestHelpers;
|
| 22 |
-
use AmountObjectTestHelpers;
|
| 23 |
-
|
| 24 |
-
public function testCreateOrder()
|
| 25 |
-
{
|
| 26 |
-
$this->mockApiCall(
|
| 27 |
-
new Request(
|
| 28 |
-
"POST",
|
| 29 |
-
"/v2/orders",
|
| 30 |
-
[],
|
| 31 |
-
'{
|
| 32 |
-
"amount": {
|
| 33 |
-
"value": "1027.99",
|
| 34 |
-
"currency": "EUR"
|
| 35 |
-
},
|
| 36 |
-
"billingAddress": {
|
| 37 |
-
"organizationName": "Organization Name LTD.",
|
| 38 |
-
"streetAndNumber": "Keizersgracht 313",
|
| 39 |
-
"postalCode": "1016 EE",
|
| 40 |
-
"city": "Amsterdam",
|
| 41 |
-
"country": "nl",
|
| 42 |
-
"givenName": "Luke",
|
| 43 |
-
"familyName": "Skywalker",
|
| 44 |
-
"email": "luke@skywalker.com"
|
| 45 |
-
},
|
| 46 |
-
"shippingAddress": {
|
| 47 |
-
"organizationName": "Organization Name LTD.",
|
| 48 |
-
"streetAndNumber": "Keizersgracht 313",
|
| 49 |
-
"postalCode": "1016 EE",
|
| 50 |
-
"city": "Amsterdam",
|
| 51 |
-
"country": "nl",
|
| 52 |
-
"givenName": "Luke",
|
| 53 |
-
"familyName": "Skywalker",
|
| 54 |
-
"email": "luke@skywalker.com"
|
| 55 |
-
},
|
| 56 |
-
"metadata": {
|
| 57 |
-
"order_id": "1337",
|
| 58 |
-
"description": "Lego cars"
|
| 59 |
-
},
|
| 60 |
-
"consumerDateOfBirth": "1958-01-31",
|
| 61 |
-
"orderNumber": "1337",
|
| 62 |
-
"locale": "nl_NL",
|
| 63 |
-
"method" : "klarnapaylater",
|
| 64 |
-
"redirectUrl": "https://example.org/redirect",
|
| 65 |
-
"webhookUrl": "https://example.org/webhook",
|
| 66 |
-
"lines": [
|
| 67 |
-
{
|
| 68 |
-
"sku": "5702016116977",
|
| 69 |
-
"name": "LEGO 42083 Bugatti Chiron",
|
| 70 |
-
"productUrl": "https://shop.lego.com/nl-NL/Bugatti-Chiron-42083",
|
| 71 |
-
"imageUrl": "https://sh-s7-live-s.legocdn.com/is/image//LEGO/42083_alt1?$main$",
|
| 72 |
-
"quantity": 2,
|
| 73 |
-
"unitPrice": {
|
| 74 |
-
"currency": "EUR",
|
| 75 |
-
"value": "399.00"
|
| 76 |
-
},
|
| 77 |
-
"vatRate": "21.00",
|
| 78 |
-
"vatAmount": {
|
| 79 |
-
"currency": "EUR",
|
| 80 |
-
"value": "121.14"
|
| 81 |
-
},
|
| 82 |
-
"discountAmount": {
|
| 83 |
-
"currency": "EUR",
|
| 84 |
-
"value": "100.00"
|
| 85 |
-
},
|
| 86 |
-
"totalAmount": {
|
| 87 |
-
"currency": "EUR",
|
| 88 |
-
"value": "698.00"
|
| 89 |
-
}
|
| 90 |
-
},
|
| 91 |
-
{
|
| 92 |
-
"type": "digital",
|
| 93 |
-
"sku": "5702015594028",
|
| 94 |
-
"name": "LEGO 42056 Porsche 911 GT3 RS",
|
| 95 |
-
"productUrl": "https://shop.lego.com/nl-NL/Porsche-911-GT3-RS-42056",
|
| 96 |
-
"imageUrl": "https://sh-s7-live-s.legocdn.com/is/image/LEGO/42056?$PDPDefault$",
|
| 97 |
-
"quantity": 1,
|
| 98 |
-
"unitPrice": {
|
| 99 |
-
"currency": "EUR",
|
| 100 |
-
"value": "329.99"
|
| 101 |
-
},
|
| 102 |
-
"vatRate": "21.00",
|
| 103 |
-
"vatAmount": {
|
| 104 |
-
"currency": "EUR",
|
| 105 |
-
"value": "57.27"
|
| 106 |
-
},
|
| 107 |
-
"totalAmount": {
|
| 108 |
-
"currency": "EUR",
|
| 109 |
-
"value": "329.99"
|
| 110 |
-
}
|
| 111 |
-
}
|
| 112 |
-
]
|
| 113 |
-
}'
|
| 114 |
-
),
|
| 115 |
-
new Response(
|
| 116 |
-
201,
|
| 117 |
-
[],
|
| 118 |
-
$this->getOrderResponseFixture("ord_pbjz8x")
|
| 119 |
-
)
|
| 120 |
-
);
|
| 121 |
-
|
| 122 |
-
$order = $this->apiClient->orders->create([
|
| 123 |
-
"amount" => [
|
| 124 |
-
"value" => "1027.99",
|
| 125 |
-
"currency" => "EUR"
|
| 126 |
-
],
|
| 127 |
-
"billingAddress" => [
|
| 128 |
-
"organizationName" => "Organization Name LTD.",
|
| 129 |
-
"streetAndNumber" => "Keizersgracht 313",
|
| 130 |
-
"postalCode" => "1016 EE",
|
| 131 |
-
"city" => "Amsterdam",
|
| 132 |
-
"country" => "nl",
|
| 133 |
-
"givenName" => "Luke",
|
| 134 |
-
"familyName" => "Skywalker",
|
| 135 |
-
"email" => "luke@skywalker.com",
|
| 136 |
-
],
|
| 137 |
-
"shippingAddress" => [
|
| 138 |
-
"organizationName" => "Organization Name LTD.",
|
| 139 |
-
"streetAndNumber" => "Keizersgracht 313",
|
| 140 |
-
"postalCode" => "1016 EE",
|
| 141 |
-
"city" => "Amsterdam",
|
| 142 |
-
"country" => "nl",
|
| 143 |
-
"givenName" => "Luke",
|
| 144 |
-
"familyName" => "Skywalker",
|
| 145 |
-
"email" => "luke@skywalker.com",
|
| 146 |
-
],
|
| 147 |
-
"metadata" => [
|
| 148 |
-
"order_id" => "1337",
|
| 149 |
-
"description" => "Lego cars"
|
| 150 |
-
],
|
| 151 |
-
"consumerDateOfBirth" => "1958-01-31",
|
| 152 |
-
"locale" => "nl_NL",
|
| 153 |
-
"orderNumber" => "1337",
|
| 154 |
-
"redirectUrl" => "https://example.org/redirect",
|
| 155 |
-
"webhookUrl" => "https://example.org/webhook",
|
| 156 |
-
"method" => "klarnapaylater",
|
| 157 |
-
"lines" => [
|
| 158 |
-
[
|
| 159 |
-
"sku" => "5702016116977",
|
| 160 |
-
"name" => "LEGO 42083 Bugatti Chiron",
|
| 161 |
-
"productUrl" => "https://shop.lego.com/nl-NL/Bugatti-Chiron-42083",
|
| 162 |
-
"imageUrl" => 'https://sh-s7-live-s.legocdn.com/is/image//LEGO/42083_alt1?$main$',
|
| 163 |
-
"quantity" => 2,
|
| 164 |
-
"vatRate" => "21.00",
|
| 165 |
-
"unitPrice" => [
|
| 166 |
-
"currency" => "EUR",
|
| 167 |
-
"value" => "399.00"
|
| 168 |
-
],
|
| 169 |
-
"totalAmount" => [
|
| 170 |
-
"currency" => "EUR",
|
| 171 |
-
"value" => "698.00"
|
| 172 |
-
],
|
| 173 |
-
"discountAmount" => [
|
| 174 |
-
"currency" => "EUR",
|
| 175 |
-
"value" => "100.00"
|
| 176 |
-
],
|
| 177 |
-
"vatAmount" => [
|
| 178 |
-
"currency" => "EUR",
|
| 179 |
-
"value" => "121.14"
|
| 180 |
-
]
|
| 181 |
-
],
|
| 182 |
-
[
|
| 183 |
-
"type" => "digital",
|
| 184 |
-
"sku" => "5702015594028",
|
| 185 |
-
"name" => "LEGO 42056 Porsche 911 GT3 RS",
|
| 186 |
-
"productUrl" => "https://shop.lego.com/nl-NL/Porsche-911-GT3-RS-42056",
|
| 187 |
-
"imageUrl" => 'https://sh-s7-live-s.legocdn.com/is/image/LEGO/42056?$PDPDefault$',
|
| 188 |
-
"quantity" => 1,
|
| 189 |
-
"vatRate" => "21.00",
|
| 190 |
-
"unitPrice" => [
|
| 191 |
-
"currency" => "EUR",
|
| 192 |
-
"value" => "329.99"
|
| 193 |
-
],
|
| 194 |
-
"totalAmount" => [
|
| 195 |
-
"currency" => "EUR",
|
| 196 |
-
"value" => "329.99"
|
| 197 |
-
],
|
| 198 |
-
"vatAmount" => [
|
| 199 |
-
"currency" => "EUR",
|
| 200 |
-
"value" => "57.27"
|
| 201 |
-
]
|
| 202 |
-
]
|
| 203 |
-
]
|
| 204 |
-
]);
|
| 205 |
-
|
| 206 |
-
$this->assertOrder($order, 'ord_pbjz8x');
|
| 207 |
-
}
|
| 208 |
-
|
| 209 |
-
public function testGetOrderDirectly()
|
| 210 |
-
{
|
| 211 |
-
$this->mockApiCall(
|
| 212 |
-
new Request(
|
| 213 |
-
"GET",
|
| 214 |
-
"/v2/orders/ord_pbjz8x"
|
| 215 |
-
),
|
| 216 |
-
new Response(
|
| 217 |
-
200,
|
| 218 |
-
[],
|
| 219 |
-
$this->getOrderResponseFixture("ord_pbjz8x")
|
| 220 |
-
)
|
| 221 |
-
);
|
| 222 |
-
|
| 223 |
-
$order = $this->apiClient->orders->get('ord_pbjz8x');
|
| 224 |
-
|
| 225 |
-
$this->assertOrder($order, 'ord_pbjz8x');
|
| 226 |
-
}
|
| 227 |
-
|
| 228 |
-
public function testGetOrderDirectlyIncludingPayments()
|
| 229 |
-
{
|
| 230 |
-
$this->mockApiCall(
|
| 231 |
-
new Request(
|
| 232 |
-
"GET",
|
| 233 |
-
"/v2/orders/ord_kEn1PlbGa?embed=payments"
|
| 234 |
-
),
|
| 235 |
-
new Response(
|
| 236 |
-
200,
|
| 237 |
-
[],
|
| 238 |
-
'{
|
| 239 |
-
"resource": "order",
|
| 240 |
-
"id": "ord_kEn1PlbGa",
|
| 241 |
-
"profileId": "pfl_URR55HPMGx",
|
| 242 |
-
"method": "klarnapaylater",
|
| 243 |
-
"amount": {
|
| 244 |
-
"value": "1027.99",
|
| 245 |
-
"currency": "EUR"
|
| 246 |
-
},
|
| 247 |
-
"status": "created",
|
| 248 |
-
"isCancelable": true,
|
| 249 |
-
"metadata": null,
|
| 250 |
-
"createdAt": "2018-08-02T09:29:56+00:00",
|
| 251 |
-
"expiresAt": "2018-08-30T09:29:56+00:00",
|
| 252 |
-
"mode": "live",
|
| 253 |
-
"locale": "nl_NL",
|
| 254 |
-
"billingAddress": {
|
| 255 |
-
"organizationName": "Mollie B.V.",
|
| 256 |
-
"streetAndNumber": "Keizersgracht 313",
|
| 257 |
-
"postalCode": "1016 EE",
|
| 258 |
-
"city": "Amsterdam",
|
| 259 |
-
"country": "nl",
|
| 260 |
-
"givenName": "Luke",
|
| 261 |
-
"familyName": "Skywalker",
|
| 262 |
-
"email": "luke@skywalker.com"
|
| 263 |
-
},
|
| 264 |
-
"orderNumber": "18475",
|
| 265 |
-
"shippingAddress": {
|
| 266 |
-
"organizationName": "Mollie B.V.",
|
| 267 |
-
"streetAndNumber": "Keizersgracht 313",
|
| 268 |
-
"postalCode": "1016 EE",
|
| 269 |
-
"city": "Amsterdam",
|
| 270 |
-
"country": "nl",
|
| 271 |
-
"givenName": "Luke",
|
| 272 |
-
"familyName": "Skywalker",
|
| 273 |
-
"email": "luke@skywalker.com"
|
| 274 |
-
},
|
| 275 |
-
"redirectUrl": "https://example.org/redirect",
|
| 276 |
-
"lines": [
|
| 277 |
-
{
|
| 278 |
-
"resource": "orderline",
|
| 279 |
-
"id": "odl_dgtxyl",
|
| 280 |
-
"orderId": "ord_pbjz8x",
|
| 281 |
-
"name": "LEGO 42083 Bugatti Chiron",
|
| 282 |
-
"sku": "5702016116977",
|
| 283 |
-
"type": "physical",
|
| 284 |
-
"status": "created",
|
| 285 |
-
"metadata": null,
|
| 286 |
-
"isCancelable": false,
|
| 287 |
-
"quantity": 2,
|
| 288 |
-
"quantityShipped": 0,
|
| 289 |
-
"amountShipped": {
|
| 290 |
-
"value": "0.00",
|
| 291 |
-
"currency": "EUR"
|
| 292 |
-
},
|
| 293 |
-
"quantityRefunded": 0,
|
| 294 |
-
"amountRefunded": {
|
| 295 |
-
"value": "0.00",
|
| 296 |
-
"currency": "EUR"
|
| 297 |
-
},
|
| 298 |
-
"quantityCanceled": 0,
|
| 299 |
-
"amountCanceled": {
|
| 300 |
-
"value": "0.00",
|
| 301 |
-
"currency": "EUR"
|
| 302 |
-
},
|
| 303 |
-
"shippableQuantity": 0,
|
| 304 |
-
"refundableQuantity": 0,
|
| 305 |
-
"cancelableQuantity": 0,
|
| 306 |
-
"unitPrice": {
|
| 307 |
-
"value": "399.00",
|
| 308 |
-
"currency": "EUR"
|
| 309 |
-
},
|
| 310 |
-
"vatRate": "21.00",
|
| 311 |
-
"vatAmount": {
|
| 312 |
-
"value": "121.14",
|
| 313 |
-
"currency": "EUR"
|
| 314 |
-
},
|
| 315 |
-
"discountAmount": {
|
| 316 |
-
"value": "100.00",
|
| 317 |
-
"currency": "EUR"
|
| 318 |
-
},
|
| 319 |
-
"totalAmount": {
|
| 320 |
-
"value": "698.00",
|
| 321 |
-
"currency": "EUR"
|
| 322 |
-
},
|
| 323 |
-
"createdAt": "2018-08-02T09:29:56+00:00",
|
| 324 |
-
"_links": {
|
| 325 |
-
"productUrl": {
|
| 326 |
-
"href": "https://shop.lego.com/nl-NL/Bugatti-Chiron-42083",
|
| 327 |
-
"type": "text/html"
|
| 328 |
-
},
|
| 329 |
-
"imageUrl": {
|
| 330 |
-
"href": "https://sh-s7-live-s.legocdn.com/is/image//LEGO/42083_alt1?$main$",
|
| 331 |
-
"type": "text/html"
|
| 332 |
-
}
|
| 333 |
-
}
|
| 334 |
-
},
|
| 335 |
-
{
|
| 336 |
-
"resource": "orderline",
|
| 337 |
-
"id": "odl_jp31jz",
|
| 338 |
-
"orderId": "ord_pbjz8x",
|
| 339 |
-
"name": "LEGO 42056 Porsche 911 GT3 RS",
|
| 340 |
-
"sku": "5702015594028",
|
| 341 |
-
"type": "physical",
|
| 342 |
-
"status": "created",
|
| 343 |
-
"metadata": null,
|
| 344 |
-
"isCancelable": false,
|
| 345 |
-
"quantity": 1,
|
| 346 |
-
"quantityShipped": 0,
|
| 347 |
-
"amountShipped": {
|
| 348 |
-
"value": "0.00",
|
| 349 |
-
"currency": "EUR"
|
| 350 |
-
},
|
| 351 |
-
"quantityRefunded": 0,
|
| 352 |
-
"amountRefunded": {
|
| 353 |
-
"value": "0.00",
|
| 354 |
-
"currency": "EUR"
|
| 355 |
-
},
|
| 356 |
-
"quantityCanceled": 0,
|
| 357 |
-
"amountCanceled": {
|
| 358 |
-
"value": "0.00",
|
| 359 |
-
"currency": "EUR"
|
| 360 |
-
},
|
| 361 |
-
"shippableQuantity": 0,
|
| 362 |
-
"refundableQuantity": 0,
|
| 363 |
-
"cancelableQuantity": 0,
|
| 364 |
-
"unitPrice": {
|
| 365 |
-
"value": "329.99",
|
| 366 |
-
"currency": "EUR"
|
| 367 |
-
},
|
| 368 |
-
"vatRate": "21.00",
|
| 369 |
-
"vatAmount": {
|
| 370 |
-
"value": "57.27",
|
| 371 |
-
"currency": "EUR"
|
| 372 |
-
},
|
| 373 |
-
"totalAmount": {
|
| 374 |
-
"value": "329.99",
|
| 375 |
-
"currency": "EUR"
|
| 376 |
-
},
|
| 377 |
-
"createdAt": "2018-08-02T09:29:56+00:00",
|
| 378 |
-
"_links": {
|
| 379 |
-
"productUrl": {
|
| 380 |
-
"href": "https://shop.lego.com/nl-NL/Porsche-911-GT3-RS-42056",
|
| 381 |
-
"type": "text/html"
|
| 382 |
-
},
|
| 383 |
-
"imageUrl": {
|
| 384 |
-
"href": "https://sh-s7-live-s.legocdn.com/is/image/LEGO/42056?$PDPDefault$",
|
| 385 |
-
"type": "text/html"
|
| 386 |
-
}
|
| 387 |
-
}
|
| 388 |
-
}
|
| 389 |
-
],
|
| 390 |
-
"_embedded": {
|
| 391 |
-
"payments": [
|
| 392 |
-
{
|
| 393 |
-
"resource": "payment",
|
| 394 |
-
"id": "tr_ncaPcAhuUV",
|
| 395 |
-
"mode": "live",
|
| 396 |
-
"createdAt": "2018-09-07T12:00:05+00:00",
|
| 397 |
-
"amount": {
|
| 398 |
-
"value": "1027.99",
|
| 399 |
-
"currency": "EUR"
|
| 400 |
-
},
|
| 401 |
-
"description": "Order #1337 (Lego cars)",
|
| 402 |
-
"method": null,
|
| 403 |
-
"metadata": null,
|
| 404 |
-
"status": "open",
|
| 405 |
-
"isCancelable": false,
|
| 406 |
-
"locale": "nl_NL",
|
| 407 |
-
"profileId": "pfl_URR55HPMGx",
|
| 408 |
-
"orderId": "ord_kEn1PlbGa",
|
| 409 |
-
"sequenceType": "oneoff",
|
| 410 |
-
"redirectUrl": "https://example.org/redirect",
|
| 411 |
-
"_links": {
|
| 412 |
-
"self": {
|
| 413 |
-
"href": "https://api.mollie.com/v2/payments/tr_ncaPcAhuUV",
|
| 414 |
-
"type": "application/hal+json"
|
| 415 |
-
},
|
| 416 |
-
"checkout": {
|
| 417 |
-
"href": "https://www.mollie.com/payscreen/select-method/ncaPcAhuUV",
|
| 418 |
-
"type": "text/html"
|
| 419 |
-
},
|
| 420 |
-
"order": {
|
| 421 |
-
"href": "https://api.mollie.com/v2/orders/ord_kEn1PlbGa",
|
| 422 |
-
"type": "application/hal+json"
|
| 423 |
-
}
|
| 424 |
-
}
|
| 425 |
-
}
|
| 426 |
-
]
|
| 427 |
-
},
|
| 428 |
-
"_links": {
|
| 429 |
-
"self": {
|
| 430 |
-
"href": "https://api.mollie.com/v2/orders/ord_pbjz8x",
|
| 431 |
-
"type": "application/hal+json"
|
| 432 |
-
},
|
| 433 |
-
"checkout": {
|
| 434 |
-
"href": "https://www.mollie.com/payscreen/order/checkout/pbjz8x",
|
| 435 |
-
"type": "text/html"
|
| 436 |
-
},
|
| 437 |
-
"documentation": {
|
| 438 |
-
"href": "https://docs.mollie.com/reference/v2/orders-api/get-order",
|
| 439 |
-
"type": "text/html"
|
| 440 |
-
}
|
| 441 |
-
}
|
| 442 |
-
}'
|
| 443 |
-
)
|
| 444 |
-
);
|
| 445 |
-
|
| 446 |
-
$order = $this->apiClient->orders->get('ord_kEn1PlbGa', ['embed' => 'payments']);
|
| 447 |
-
|
| 448 |
-
$this->assertInstanceOf(Order::class, $order);
|
| 449 |
-
$this->assertEquals('ord_kEn1PlbGa', $order->id);
|
| 450 |
-
|
| 451 |
-
$payments = $order->payments();
|
| 452 |
-
$this->assertInstanceOf(PaymentCollection::class, $payments);
|
| 453 |
-
|
| 454 |
-
$payment = $payments[0];
|
| 455 |
-
$this->assertInstanceOf(Payment::class, $payment);
|
| 456 |
-
$this->assertEquals('tr_ncaPcAhuUV', $payment->id);
|
| 457 |
-
$this->assertEquals('2018-09-07T12:00:05+00:00', $payment->createdAt);
|
| 458 |
-
$this->assertAmountObject('1027.99', 'EUR', $payment->amount);
|
| 459 |
-
$this->assertEquals('Order #1337 (Lego cars)', $payment->description);
|
| 460 |
-
$this->assertNull($payment->method);
|
| 461 |
-
$this->assertNull($payment->metadata);
|
| 462 |
-
$this->assertEquals('open', $payment->status);
|
| 463 |
-
$this->assertFalse($payment->isCancelable);
|
| 464 |
-
$this->assertEquals('nl_NL', $payment->locale);
|
| 465 |
-
$this->assertEquals('pfl_URR55HPMGx', $payment->profileId);
|
| 466 |
-
$this->assertEquals('ord_kEn1PlbGa', $payment->orderId);
|
| 467 |
-
$this->assertEquals('oneoff', $payment->sequenceType);
|
| 468 |
-
$this->assertEquals('https://example.org/redirect', $payment->redirectUrl);
|
| 469 |
-
$this->assertLinkObject(
|
| 470 |
-
'https://api.mollie.com/v2/payments/tr_ncaPcAhuUV',
|
| 471 |
-
'application/hal+json',
|
| 472 |
-
$payment->_links->self
|
| 473 |
-
);
|
| 474 |
-
$this->assertLinkObject(
|
| 475 |
-
'https://www.mollie.com/payscreen/select-method/ncaPcAhuUV',
|
| 476 |
-
'text/html',
|
| 477 |
-
$payment->_links->checkout
|
| 478 |
-
);
|
| 479 |
-
$this->assertLinkObject(
|
| 480 |
-
'https://api.mollie.com/v2/orders/ord_kEn1PlbGa',
|
| 481 |
-
'application/hal+json',
|
| 482 |
-
$payment->_links->order
|
| 483 |
-
);
|
| 484 |
-
}
|
| 485 |
-
|
| 486 |
-
public function testGetOrderOnShipmentResource()
|
| 487 |
-
{
|
| 488 |
-
$this->mockApiCall(
|
| 489 |
-
new Request(
|
| 490 |
-
"GET",
|
| 491 |
-
"/v2/orders/ord_pbjz8x"
|
| 492 |
-
),
|
| 493 |
-
new Response(
|
| 494 |
-
200,
|
| 495 |
-
[],
|
| 496 |
-
$this->getOrderResponseFixture("ord_pbjz8x")
|
| 497 |
-
)
|
| 498 |
-
);
|
| 499 |
-
|
| 500 |
-
$shipment = $this->getShipment("shp_3wmsgCJN4U", "ord_pbjz8x");
|
| 501 |
-
$order = $shipment->order();
|
| 502 |
-
|
| 503 |
-
$this->assertOrder($order, 'ord_pbjz8x');
|
| 504 |
-
}
|
| 505 |
-
|
| 506 |
-
public function testListOrders()
|
| 507 |
-
{
|
| 508 |
-
$this->mockApiCall(
|
| 509 |
-
new Request("GET", "/v2/orders"),
|
| 510 |
-
new Response(
|
| 511 |
-
200,
|
| 512 |
-
[],
|
| 513 |
-
'{
|
| 514 |
-
"count": 3,
|
| 515 |
-
"_embedded": {
|
| 516 |
-
"orders": [
|
| 517 |
-
' . $this->getOrderResponseFixture("ord_pbjz1x") . ',
|
| 518 |
-
' . $this->getOrderResponseFixture("ord_pbjz2y") . ',
|
| 519 |
-
' . $this->getOrderResponseFixture("ord_pbjz3z") . '
|
| 520 |
-
]
|
| 521 |
-
},
|
| 522 |
-
"_links": {
|
| 523 |
-
"self": {
|
| 524 |
-
"href": "https://api.mollie.com/v2/orders",
|
| 525 |
-
"type": "application/hal+json"
|
| 526 |
-
},
|
| 527 |
-
"previous": null,
|
| 528 |
-
"next": {
|
| 529 |
-
"href": "https://api.mollie.com/v2/orders?from=ord_stTC2WHAuS",
|
| 530 |
-
"type": "application/hal+json"
|
| 531 |
-
},
|
| 532 |
-
"documentation": {
|
| 533 |
-
"href": "https://docs.mollie.com/reference/v2/orders-api/list-orders",
|
| 534 |
-
"type": "text/html"
|
| 535 |
-
}
|
| 536 |
-
}
|
| 537 |
-
}'
|
| 538 |
-
)
|
| 539 |
-
);
|
| 540 |
-
|
| 541 |
-
$orders = $this->apiClient->orders->page();
|
| 542 |
-
|
| 543 |
-
$this->assertInstanceOf(OrderCollection::class, $orders);
|
| 544 |
-
$this->assertEquals(3, $orders->count);
|
| 545 |
-
$this->assertEquals(3, count($orders));
|
| 546 |
-
|
| 547 |
-
$this->assertNull($orders->_links->previous);
|
| 548 |
-
$selfLink = $this->createLinkObject(
|
| 549 |
-
"https://api.mollie.com/v2/orders",
|
| 550 |
-
"application/hal+json"
|
| 551 |
-
);
|
| 552 |
-
$this->assertEquals($selfLink, $orders->_links->self);
|
| 553 |
-
|
| 554 |
-
$nextLink = $this->createLinkObject(
|
| 555 |
-
"https://api.mollie.com/v2/orders?from=ord_stTC2WHAuS",
|
| 556 |
-
"application/hal+json"
|
| 557 |
-
);
|
| 558 |
-
$this->assertEquals($nextLink, $orders->_links->next);
|
| 559 |
-
|
| 560 |
-
$documentationLink = $this->createLinkObject(
|
| 561 |
-
"https://docs.mollie.com/reference/v2/orders-api/list-orders",
|
| 562 |
-
"text/html"
|
| 563 |
-
);
|
| 564 |
-
$this->assertEquals($documentationLink, $orders->_links->documentation);
|
| 565 |
-
|
| 566 |
-
$this->assertOrder($orders[0], 'ord_pbjz1x');
|
| 567 |
-
$this->assertOrder($orders[1], 'ord_pbjz2y');
|
| 568 |
-
$this->assertOrder($orders[2], 'ord_pbjz3z');
|
| 569 |
-
}
|
| 570 |
-
|
| 571 |
-
public function testCancelOrderDirectly()
|
| 572 |
-
{
|
| 573 |
-
$this->mockApiCall(
|
| 574 |
-
new Request("DELETE", "/v2/orders/ord_pbjz1x"),
|
| 575 |
-
new Response(
|
| 576 |
-
200,
|
| 577 |
-
[],
|
| 578 |
-
$this->getOrderResponseFixture(
|
| 579 |
-
'ord_pbjz1x',
|
| 580 |
-
OrderStatus::STATUS_CANCELED
|
| 581 |
-
)
|
| 582 |
-
)
|
| 583 |
-
);
|
| 584 |
-
$order = $this->apiClient->orders->cancel('ord_pbjz1x');
|
| 585 |
-
$this->assertOrder($order, 'ord_pbjz1x', OrderStatus::STATUS_CANCELED);
|
| 586 |
-
}
|
| 587 |
-
|
| 588 |
-
public function testCancelOrderOnResource()
|
| 589 |
-
{
|
| 590 |
-
$this->mockApiCall(
|
| 591 |
-
new Request("DELETE", "/v2/orders/ord_pbjz1x"),
|
| 592 |
-
new Response(
|
| 593 |
-
200,
|
| 594 |
-
[],
|
| 595 |
-
$this->getOrderResponseFixture(
|
| 596 |
-
'ord_pbjz1x',
|
| 597 |
-
OrderStatus::STATUS_CANCELED
|
| 598 |
-
)
|
| 599 |
-
)
|
| 600 |
-
);
|
| 601 |
-
$order = $this->getOrder('ord_pbjz1x');
|
| 602 |
-
$canceledOrder = $order->cancel();
|
| 603 |
-
$this->assertOrder($canceledOrder, 'ord_pbjz1x', OrderStatus::STATUS_CANCELED);
|
| 604 |
-
}
|
| 605 |
-
|
| 606 |
-
public function testCancelOrderLines()
|
| 607 |
-
{
|
| 608 |
-
$this->mockApiCall(
|
| 609 |
-
new Request(
|
| 610 |
-
"DELETE",
|
| 611 |
-
"/v2/orders/ord_8wmqcHMN4U/lines",
|
| 612 |
-
[],
|
| 613 |
-
'{
|
| 614 |
-
"lines": [
|
| 615 |
-
{
|
| 616 |
-
"id": "odl_dgtxyl",
|
| 617 |
-
"quantity": 1
|
| 618 |
-
}
|
| 619 |
-
]
|
| 620 |
-
}'
|
| 621 |
-
),
|
| 622 |
-
new Response(204)
|
| 623 |
-
);
|
| 624 |
-
|
| 625 |
-
$order = $this->getOrder('ord_8wmqcHMN4U');
|
| 626 |
-
|
| 627 |
-
$result = $order->cancelLines([
|
| 628 |
-
'lines' => [
|
| 629 |
-
[
|
| 630 |
-
'id' => 'odl_dgtxyl',
|
| 631 |
-
'quantity' => 1,
|
| 632 |
-
],
|
| 633 |
-
],
|
| 634 |
-
]);
|
| 635 |
-
|
| 636 |
-
$this->assertNull($result);
|
| 637 |
-
}
|
| 638 |
-
|
| 639 |
-
public function testCancelAllOrderLines()
|
| 640 |
-
{
|
| 641 |
-
$this->mockApiCall(
|
| 642 |
-
new Request(
|
| 643 |
-
"DELETE",
|
| 644 |
-
"/v2/orders/ord_8wmqcHMN4U/lines",
|
| 645 |
-
[],
|
| 646 |
-
'{
|
| 647 |
-
"lines": [],
|
| 648 |
-
"foo": "bar"
|
| 649 |
-
}'
|
| 650 |
-
),
|
| 651 |
-
new Response(204)
|
| 652 |
-
);
|
| 653 |
-
|
| 654 |
-
$order = $this->getOrder('ord_8wmqcHMN4U');
|
| 655 |
-
|
| 656 |
-
$result = $order->cancelAllLines([
|
| 657 |
-
'foo' => 'bar',
|
| 658 |
-
]);
|
| 659 |
-
|
| 660 |
-
$this->assertNull($result);
|
| 661 |
-
}
|
| 662 |
-
|
| 663 |
-
/** @test */
|
| 664 |
-
public function testUpdateOrder()
|
| 665 |
-
{
|
| 666 |
-
$this->mockApiCall(
|
| 667 |
-
new Request(
|
| 668 |
-
"PATCH",
|
| 669 |
-
"/v2/orders/ord_pbjz8x",
|
| 670 |
-
[],
|
| 671 |
-
'{
|
| 672 |
-
"billingAddress": {
|
| 673 |
-
"organizationName": "Organization Name LTD.",
|
| 674 |
-
"streetAndNumber": "Keizersgracht 313",
|
| 675 |
-
"postalCode": "1234AB",
|
| 676 |
-
"city": "Amsterdam",
|
| 677 |
-
"country": "NL",
|
| 678 |
-
"givenName": "Piet",
|
| 679 |
-
"familyName": "Mondriaan",
|
| 680 |
-
"email": "piet@mondriaan.com",
|
| 681 |
-
"region": "Noord-Holland",
|
| 682 |
-
"title": "Dhr",
|
| 683 |
-
"phone": "+31208202070"
|
| 684 |
-
},
|
| 685 |
-
"shippingAddress": {
|
| 686 |
-
"organizationName": "Organization Name LTD.",
|
| 687 |
-
"streetAndNumber": "Keizersgracht 313",
|
| 688 |
-
"postalCode": "1016 EE",
|
| 689 |
-
"city": "Amsterdam",
|
| 690 |
-
"country": "nl",
|
| 691 |
-
"givenName": "Luke",
|
| 692 |
-
"familyName": "Skywalker",
|
| 693 |
-
"email": "luke@skywalker.com"
|
| 694 |
-
},
|
| 695 |
-
"orderNumber": "16738"
|
| 696 |
-
}'
|
| 697 |
-
),
|
| 698 |
-
new Response(
|
| 699 |
-
200,
|
| 700 |
-
[],
|
| 701 |
-
$this->getOrderResponseFixture(
|
| 702 |
-
"ord_pbjz8x",
|
| 703 |
-
OrderStatus::STATUS_CREATED,
|
| 704 |
-
"16738"
|
| 705 |
-
)
|
| 706 |
-
)
|
| 707 |
-
);
|
| 708 |
-
|
| 709 |
-
/** @var Order $order */
|
| 710 |
-
$order = $this->getOrder("ord_pbjz8x");
|
| 711 |
-
|
| 712 |
-
$order->billingAddress->organizationName = "Organization Name LTD.";
|
| 713 |
-
$order->billingAddress->streetAndNumber = "Keizersgracht 313";
|
| 714 |
-
$order->billingAddress->city = "Amsterdam";
|
| 715 |
-
$order->billingAddress->region = "Noord-Holland";
|
| 716 |
-
$order->billingAddress->postalCode = "1234AB";
|
| 717 |
-
$order->billingAddress->country = "NL";
|
| 718 |
-
$order->billingAddress->title = "Dhr";
|
| 719 |
-
$order->billingAddress->givenName = "Piet";
|
| 720 |
-
$order->billingAddress->familyName = "Mondriaan";
|
| 721 |
-
$order->billingAddress->email = "piet@mondriaan.com";
|
| 722 |
-
$order->billingAddress->phone = "+31208202070";
|
| 723 |
-
$order->orderNumber = "16738";
|
| 724 |
-
$order = $order->update();
|
| 725 |
-
|
| 726 |
-
$this->assertOrder($order, "ord_pbjz8x", OrderStatus::STATUS_CREATED, "16738");
|
| 727 |
-
}
|
| 728 |
-
|
| 729 |
-
protected function assertOrder($order, $order_id, $order_status = OrderStatus::STATUS_CREATED, $orderNumber = "1337")
|
| 730 |
-
{
|
| 731 |
-
$this->assertInstanceOf(Order::class, $order);
|
| 732 |
-
$this->assertEquals('order', $order->resource);
|
| 733 |
-
$this->assertEquals($order_id, $order->id);
|
| 734 |
-
$this->assertEquals('pfl_URR55HPMGx', $order->profileId);
|
| 735 |
-
$this->assertEquals('live', $order->mode);
|
| 736 |
-
$this->assertEquals('klarnapaylater', $order->method);
|
| 737 |
-
$this->assertEquals('2018-08-02T09:29:56+00:00', $order->createdAt);
|
| 738 |
-
|
| 739 |
-
$this->assertAmountObject('1027.99', 'EUR', $order->amount);
|
| 740 |
-
$this->assertAmountObject('0.00', 'EUR', $order->amountCaptured);
|
| 741 |
-
$this->assertAmountObject('0.00', 'EUR', $order->amountRefunded);
|
| 742 |
-
|
| 743 |
-
$this->assertEquals((object) [
|
| 744 |
-
'order_id' => '1337',
|
| 745 |
-
'description' => 'Lego cars',
|
| 746 |
-
], $order->metadata);
|
| 747 |
-
|
| 748 |
-
$this->assertEquals($order_status, $order->status);
|
| 749 |
-
|
| 750 |
-
$billingAddress = new stdClass();
|
| 751 |
-
$billingAddress->organizationName = "Organization Name LTD.";
|
| 752 |
-
$billingAddress->streetAndNumber = "Keizersgracht 313";
|
| 753 |
-
$billingAddress->postalCode = "1016 EE";
|
| 754 |
-
$billingAddress->city = "Amsterdam";
|
| 755 |
-
$billingAddress->country = "nl";
|
| 756 |
-
$billingAddress->givenName = "Luke";
|
| 757 |
-
$billingAddress->familyName = "Skywalker";
|
| 758 |
-
$billingAddress->email = "luke@skywalker.com";
|
| 759 |
-
$this->assertEquals($billingAddress, $order->billingAddress);
|
| 760 |
-
|
| 761 |
-
$shippingAddress = new stdClass();
|
| 762 |
-
$shippingAddress->organizationName = "Organization Name LTD.";
|
| 763 |
-
$shippingAddress->streetAndNumber = "Keizersgracht 313";
|
| 764 |
-
$shippingAddress->postalCode = "1016 EE";
|
| 765 |
-
$shippingAddress->city = "Amsterdam";
|
| 766 |
-
$shippingAddress->country = "nl";
|
| 767 |
-
$shippingAddress->givenName = "Luke";
|
| 768 |
-
$shippingAddress->familyName = "Skywalker";
|
| 769 |
-
$shippingAddress->email = "luke@skywalker.com";
|
| 770 |
-
$this->assertEquals($shippingAddress, $order->shippingAddress);
|
| 771 |
-
|
| 772 |
-
$this->assertEquals($orderNumber, $order->orderNumber);
|
| 773 |
-
$this->assertEquals('nl_NL', $order->locale);
|
| 774 |
-
|
| 775 |
-
$this->assertEquals("https://example.org/redirect", $order->redirectUrl);
|
| 776 |
-
$this->assertEquals("https://example.org/webhook", $order->webhookUrl);
|
| 777 |
-
|
| 778 |
-
$links = (object )[
|
| 779 |
-
'self' => $this->createLinkObject(
|
| 780 |
-
'https://api.mollie.com/v2/orders/' . $order_id,
|
| 781 |
-
'application/hal+json'
|
| 782 |
-
),
|
| 783 |
-
'checkout' => $this->createLinkObject(
|
| 784 |
-
'https://www.mollie.com/payscreen/select-method/7UhSN1zuXS',
|
| 785 |
-
'text/html'
|
| 786 |
-
),
|
| 787 |
-
'documentation' => $this->createLinkObject(
|
| 788 |
-
'https://docs.mollie.com/reference/v2/orders-api/get-order',
|
| 789 |
-
'text/html'
|
| 790 |
-
),
|
| 791 |
-
];
|
| 792 |
-
$this->assertEquals($links, $order->_links);
|
| 793 |
-
|
| 794 |
-
$line1 = new stdClass();
|
| 795 |
-
$line1->resource = "orderline";
|
| 796 |
-
$line1->id = "odl_dgtxyl";
|
| 797 |
-
$line1->orderId = $order_id;
|
| 798 |
-
$line1->name = "LEGO 42083 Bugatti Chiron";
|
| 799 |
-
$line1->productUrl = "https://shop.lego.com/nl-NL/Bugatti-Chiron-42083";
|
| 800 |
-
$line1->imageUrl = 'https://sh-s7-live-s.legocdn.com/is/image//LEGO/42083_alt1?$main$';
|
| 801 |
-
$line1->sku = "5702016116977";
|
| 802 |
-
$line1->type = OrderLineType::TYPE_PHYSICAL;
|
| 803 |
-
$line1->status = OrderLineStatus::STATUS_CREATED;
|
| 804 |
-
$line1->isCancelable = true;
|
| 805 |
-
$line1->quantity = 2;
|
| 806 |
-
$line1->unitPrice = $this->createAmountObject("399.00", "EUR");
|
| 807 |
-
$line1->vatRate = "21.00";
|
| 808 |
-
$line1->vatAmount = $this->createAmountObject("121.14", "EUR");
|
| 809 |
-
$line1->discountAmount = $this->createAmountObject("100.00", "EUR");
|
| 810 |
-
$line1->totalAmount = $this->createAmountObject("698.00", "EUR");
|
| 811 |
-
$line1->createdAt = "2018-08-02T09:29:56+00:00";
|
| 812 |
-
$this->assertEquals($line1, $order->lines[0]);
|
| 813 |
-
|
| 814 |
-
$line2 = new stdClass();
|
| 815 |
-
$line2->resource = "orderline";
|
| 816 |
-
$line2->id = "odl_jp31jz";
|
| 817 |
-
$line2->orderId = $order_id;
|
| 818 |
-
$line2->name = "LEGO 42056 Porsche 911 GT3 RS";
|
| 819 |
-
$line2->productUrl = "https://shop.lego.com/nl-NL/Porsche-911-GT3-RS-42056";
|
| 820 |
-
$line2->imageUrl = 'https://sh-s7-live-s.legocdn.com/is/image/LEGO/42056?$PDPDefault$';
|
| 821 |
-
$line2->sku = "5702015594028";
|
| 822 |
-
$line2->type = OrderLineType::TYPE_DIGITAL;
|
| 823 |
-
$line2->status = OrderLineStatus::STATUS_CREATED;
|
| 824 |
-
$line2->isCancelable = true;
|
| 825 |
-
$line2->quantity = 1;
|
| 826 |
-
$line2->unitPrice = $this->createAmountObject("329.99", "EUR");
|
| 827 |
-
$line2->vatRate = "21.00";
|
| 828 |
-
$line2->vatAmount = $this->createAmountObject("57.27", "EUR");
|
| 829 |
-
$line2->totalAmount = $this->createAmountObject("329.99", "EUR");
|
| 830 |
-
$line2->createdAt = "2018-08-02T09:29:56+00:00";
|
| 831 |
-
$this->assertEquals($line2, $order->lines[1]);
|
| 832 |
-
|
| 833 |
-
$this->assertNull($order->payments());
|
| 834 |
-
}
|
| 835 |
-
|
| 836 |
-
protected function getOrder($id)
|
| 837 |
-
{
|
| 838 |
-
$orderJson = $this->getOrderResponseFixture($id);
|
| 839 |
-
return $this->copy(json_decode($orderJson), new Order($this->apiClient));
|
| 840 |
-
}
|
| 841 |
-
|
| 842 |
-
protected function getOrderResponseFixture($order_id, $order_status = OrderStatus::STATUS_CREATED, $orderNumber = '1337')
|
| 843 |
-
{
|
| 844 |
-
return str_replace(
|
| 845 |
-
[
|
| 846 |
-
"<<order_id>>",
|
| 847 |
-
"<<order_number>>"
|
| 848 |
-
],
|
| 849 |
-
[
|
| 850 |
-
$order_id,
|
| 851 |
-
$orderNumber,
|
| 852 |
-
],
|
| 853 |
-
'{
|
| 854 |
-
"resource": "order",
|
| 855 |
-
"id": "<<order_id>>",
|
| 856 |
-
"profileId": "pfl_URR55HPMGx",
|
| 857 |
-
"amount": {
|
| 858 |
-
"value": "1027.99",
|
| 859 |
-
"currency": "EUR"
|
| 860 |
-
},
|
| 861 |
-
"amountCaptured": {
|
| 862 |
-
"value": "0.00",
|
| 863 |
-
"currency": "EUR"
|
| 864 |
-
},
|
| 865 |
-
"amountRefunded": {
|
| 866 |
-
"value": "0.00",
|
| 867 |
-
"currency": "EUR"
|
| 868 |
-
},
|
| 869 |
-
"status": "' . $order_status . '",
|
| 870 |
-
"metadata": {
|
| 871 |
-
"order_id": "1337",
|
| 872 |
-
"description": "Lego cars"
|
| 873 |
-
},
|
| 874 |
-
"consumerDateOfBirth": "1958-01-31",
|
| 875 |
-
"createdAt": "2018-08-02T09:29:56+00:00",
|
| 876 |
-
"mode": "live",
|
| 877 |
-
"billingAddress": {
|
| 878 |
-
"organizationName": "Organization Name LTD.",
|
| 879 |
-
"streetAndNumber": "Keizersgracht 313",
|
| 880 |
-
"postalCode": "1016 EE",
|
| 881 |
-
"city": "Amsterdam",
|
| 882 |
-
"country": "nl",
|
| 883 |
-
"givenName": "Luke",
|
| 884 |
-
"familyName": "Skywalker",
|
| 885 |
-
"email": "luke@skywalker.com"
|
| 886 |
-
},
|
| 887 |
-
"shippingAddress": {
|
| 888 |
-
"organizationName": "Organization Name LTD.",
|
| 889 |
-
"streetAndNumber": "Keizersgracht 313",
|
| 890 |
-
"postalCode": "1016 EE",
|
| 891 |
-
"city": "Amsterdam",
|
| 892 |
-
"country": "nl",
|
| 893 |
-
"givenName": "Luke",
|
| 894 |
-
"familyName": "Skywalker",
|
| 895 |
-
"email": "luke@skywalker.com"
|
| 896 |
-
},
|
| 897 |
-
"orderNumber": <<order_number>>,
|
| 898 |
-
"locale": "nl_NL",
|
| 899 |
-
"method" : "klarnapaylater",
|
| 900 |
-
"isCancelable": true,
|
| 901 |
-
"redirectUrl": "https://example.org/redirect",
|
| 902 |
-
"webhookUrl": "https://example.org/webhook",
|
| 903 |
-
"lines": [
|
| 904 |
-
{
|
| 905 |
-
"resource": "orderline",
|
| 906 |
-
"id": "odl_dgtxyl",
|
| 907 |
-
"orderId": "<<order_id>>",
|
| 908 |
-
"name": "LEGO 42083 Bugatti Chiron",
|
| 909 |
-
"productUrl": "https://shop.lego.com/nl-NL/Bugatti-Chiron-42083",
|
| 910 |
-
"imageUrl": "https://sh-s7-live-s.legocdn.com/is/image//LEGO/42083_alt1?$main$",
|
| 911 |
-
"sku": "5702016116977",
|
| 912 |
-
"type": "physical",
|
| 913 |
-
"status": "created",
|
| 914 |
-
"isCancelable": true,
|
| 915 |
-
"quantity": 2,
|
| 916 |
-
"unitPrice": {
|
| 917 |
-
"value": "399.00",
|
| 918 |
-
"currency": "EUR"
|
| 919 |
-
},
|
| 920 |
-
"vatRate": "21.00",
|
| 921 |
-
"vatAmount": {
|
| 922 |
-
"value": "121.14",
|
| 923 |
-
"currency": "EUR"
|
| 924 |
-
},
|
| 925 |
-
"discountAmount": {
|
| 926 |
-
"value": "100.00",
|
| 927 |
-
"currency": "EUR"
|
| 928 |
-
},
|
| 929 |
-
"totalAmount": {
|
| 930 |
-
"value": "698.00",
|
| 931 |
-
"currency": "EUR"
|
| 932 |
-
},
|
| 933 |
-
"createdAt": "2018-08-02T09:29:56+00:00"
|
| 934 |
-
},
|
| 935 |
-
{
|
| 936 |
-
"resource": "orderline",
|
| 937 |
-
"id": "odl_jp31jz",
|
| 938 |
-
"orderId": "<<order_id>>",
|
| 939 |
-
"name": "LEGO 42056 Porsche 911 GT3 RS",
|
| 940 |
-
"productUrl": "https://shop.lego.com/nl-NL/Porsche-911-GT3-RS-42056",
|
| 941 |
-
"imageUrl": "https://sh-s7-live-s.legocdn.com/is/image/LEGO/42056?$PDPDefault$",
|
| 942 |
-
"sku": "5702015594028",
|
| 943 |
-
"type": "digital",
|
| 944 |
-
"status": "created",
|
| 945 |
-
"isCancelable": true,
|
| 946 |
-
"quantity": 1,
|
| 947 |
-
"unitPrice": {
|
| 948 |
-
"value": "329.99",
|
| 949 |
-
"currency": "EUR"
|
| 950 |
-
},
|
| 951 |
-
"vatRate": "21.00",
|
| 952 |
-
"vatAmount": {
|
| 953 |
-
"value": "57.27",
|
| 954 |
-
"currency": "EUR"
|
| 955 |
-
},
|
| 956 |
-
"totalAmount": {
|
| 957 |
-
"value": "329.99",
|
| 958 |
-
"currency": "EUR"
|
| 959 |
-
},
|
| 960 |
-
"createdAt": "2018-08-02T09:29:56+00:00"
|
| 961 |
-
}
|
| 962 |
-
],
|
| 963 |
-
"_links": {
|
| 964 |
-
"self": {
|
| 965 |
-
"href": "https://api.mollie.com/v2/orders/<<order_id>>",
|
| 966 |
-
"type": "application/hal+json"
|
| 967 |
-
},
|
| 968 |
-
"checkout": {
|
| 969 |
-
"href": "https://www.mollie.com/payscreen/select-method/7UhSN1zuXS",
|
| 970 |
-
"type": "text/html"
|
| 971 |
-
},
|
| 972 |
-
"documentation": {
|
| 973 |
-
"href": "https://docs.mollie.com/reference/v2/orders-api/get-order",
|
| 974 |
-
"type": "text/html"
|
| 975 |
-
}
|
| 976 |
-
}
|
| 977 |
-
}'
|
| 978 |
-
);
|
| 979 |
-
}
|
| 980 |
-
|
| 981 |
-
protected function getShipment($shipmentId, $orderId, $orderlineStatus = OrderLineStatus::STATUS_SHIPPING)
|
| 982 |
-
{
|
| 983 |
-
$shipmentJson = $this->getShipmentResponseFixture(
|
| 984 |
-
$shipmentId,
|
| 985 |
-
$orderId,
|
| 986 |
-
$orderlineStatus
|
| 987 |
-
);
|
| 988 |
-
return $this->copy(json_decode($shipmentJson), new Shipment($this->apiClient));
|
| 989 |
-
}
|
| 990 |
-
|
| 991 |
-
protected function getShipmentResponseFixture($shipmentId, $orderId, $orderlineStatus = OrderLineStatus::STATUS_SHIPPING)
|
| 992 |
-
{
|
| 993 |
-
return str_replace(
|
| 994 |
-
[
|
| 995 |
-
"<<order_id>>",
|
| 996 |
-
"<<shipment_id>>",
|
| 997 |
-
"<<orderline_status>>",
|
| 998 |
-
],
|
| 999 |
-
[
|
| 1000 |
-
$orderId,
|
| 1001 |
-
$shipmentId,
|
| 1002 |
-
$orderlineStatus
|
| 1003 |
-
],
|
| 1004 |
-
'{
|
| 1005 |
-
"resource": "shipment",
|
| 1006 |
-
"id": "<<shipment_id>>",
|
| 1007 |
-
"orderId": "<<order_id>>",
|
| 1008 |
-
"createdAt": "2018-08-02T09:29:56+00:00",
|
| 1009 |
-
"profileId": "pfl_URR55HPMGx",
|
| 1010 |
-
"lines": [
|
| 1011 |
-
{
|
| 1012 |
-
"resource": "orderline",
|
| 1013 |
-
"id": "odl_dgtxyl",
|
| 1014 |
-
"orderId": "<<order_id>>",
|
| 1015 |
-
"name": "LEGO 42083 Bugatti Chiron",
|
| 1016 |
-
"productUrl": "https://shop.lego.com/nl-NL/Bugatti-Chiron-42083",
|
| 1017 |
-
"imageUrl": "https://sh-s7-live-s.legocdn.com/is/image//LEGO/42083_alt1?$main$",
|
| 1018 |
-
"sku": "5702016116977",
|
| 1019 |
-
"type": "physical",
|
| 1020 |
-
"status": "<<orderline_status>>",
|
| 1021 |
-
"quantity": 1,
|
| 1022 |
-
"unitPrice": {
|
| 1023 |
-
"value": "399.00",
|
| 1024 |
-
"currency": "EUR"
|
| 1025 |
-
},
|
| 1026 |
-
"vatRate": "21.00",
|
| 1027 |
-
"vatAmount": {
|
| 1028 |
-
"value": "121.14",
|
| 1029 |
-
"currency": "EUR"
|
| 1030 |
-
},
|
| 1031 |
-
"discountAmount": {
|
| 1032 |
-
"value": "100.00",
|
| 1033 |
-
"currency": "EUR"
|
| 1034 |
-
},
|
| 1035 |
-
"totalAmount": {
|
| 1036 |
-
"value": "698.00",
|
| 1037 |
-
"currency": "EUR"
|
| 1038 |
-
},
|
| 1039 |
-
"createdAt": "2018-08-02T09:29:56+00:00"
|
| 1040 |
-
},
|
| 1041 |
-
{
|
| 1042 |
-
"resource": "orderline",
|
| 1043 |
-
"id": "odl_jp31jz",
|
| 1044 |
-
"orderId": "<<order_id>>",
|
| 1045 |
-
"name": "LEGO 42056 Porsche 911 GT3 RS",
|
| 1046 |
-
"productUrl": "https://shop.lego.com/nl-NL/Porsche-911-GT3-RS-42056",
|
| 1047 |
-
"imageUrl": "https://sh-s7-live-s.legocdn.com/is/image/LEGO/42056?$PDPDefault$",
|
| 1048 |
-
"sku": "5702015594028",
|
| 1049 |
-
"type": "digital",
|
| 1050 |
-
"status": "<<orderline_status>>",
|
| 1051 |
-
"quantity": 1,
|
| 1052 |
-
"unitPrice": {
|
| 1053 |
-
"value": "329.99",
|
| 1054 |
-
"currency": "EUR"
|
| 1055 |
-
},
|
| 1056 |
-
"vatRate": "21.00",
|
| 1057 |
-
"vatAmount": {
|
| 1058 |
-
"value": "57.27",
|
| 1059 |
-
"currency": "EUR"
|
| 1060 |
-
},
|
| 1061 |
-
"totalAmount": {
|
| 1062 |
-
"value": "329.99",
|
| 1063 |
-
"currency": "EUR"
|
| 1064 |
-
},
|
| 1065 |
-
"createdAt": "2018-08-02T09:29:56+00:00"
|
| 1066 |
-
}
|
| 1067 |
-
],
|
| 1068 |
-
"_links": {
|
| 1069 |
-
"self": {
|
| 1070 |
-
"href": "https://api.mollie.com/v2/orders/<<order_id>>/shipments/<<shipment_id>>",
|
| 1071 |
-
"type": "application/hal+json"
|
| 1072 |
-
},
|
| 1073 |
-
"order": {
|
| 1074 |
-
"href": "https://api.mollie.com/v2/orders/<<order_id>>",
|
| 1075 |
-
"type": "application/hal+json"
|
| 1076 |
-
},
|
| 1077 |
-
"documentation": {
|
| 1078 |
-
"href": "https://docs.mollie.com/reference/v2/shipments-api/get-shipment",
|
| 1079 |
-
"type": "text/html"
|
| 1080 |
-
}
|
| 1081 |
-
}
|
| 1082 |
-
}'
|
| 1083 |
-
);
|
| 1084 |
-
}
|
| 1085 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Endpoints/OrderLineEndpointTest.php
DELETED
|
@@ -1,21 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\Api\Endpoints;
|
| 4 |
-
|
| 5 |
-
use GuzzleHttp\Client;
|
| 6 |
-
use Mollie\Api\Exceptions\ApiException;
|
| 7 |
-
use Mollie\Api\MollieApiClient;
|
| 8 |
-
use Mollie\Api\Resources\Order;
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
class OrderLineEndpointTest extends BaseEndpointTest
|
| 12 |
-
{
|
| 13 |
-
public function testCancelLinesRequiresLinesArray() {
|
| 14 |
-
$this->expectException(ApiException::class);
|
| 15 |
-
|
| 16 |
-
$this->guzzleClient = $this->createMock(Client::class);
|
| 17 |
-
$this->apiClient = new MollieApiClient($this->guzzleClient);
|
| 18 |
-
|
| 19 |
-
$this->apiClient->orderLines->cancelFor(new Order($this->apiClient), []);
|
| 20 |
-
}
|
| 21 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Endpoints/OrderPaymentEndpointTest.php
DELETED
|
@@ -1,289 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\Api\Endpoints;
|
| 4 |
-
|
| 5 |
-
use GuzzleHttp\Psr7\Request;
|
| 6 |
-
use GuzzleHttp\Psr7\Response;
|
| 7 |
-
use Mollie\Api\Resources\Order;
|
| 8 |
-
use Mollie\Api\Resources\OrderCollection;
|
| 9 |
-
use Mollie\Api\Resources\Payment;
|
| 10 |
-
use Mollie\Api\Resources\Shipment;
|
| 11 |
-
use Mollie\Api\Types\OrderLineStatus;
|
| 12 |
-
use Mollie\Api\Types\OrderLineType;
|
| 13 |
-
use Mollie\Api\Types\OrderStatus;
|
| 14 |
-
use Mollie\Api\Types\PaymentMethod;
|
| 15 |
-
use Mollie\Api\Types\PaymentStatus;
|
| 16 |
-
use Mollie\Api\Types\SequenceType;
|
| 17 |
-
use Tests\Mollie\TestHelpers\AmountObjectTestHelpers;
|
| 18 |
-
use Tests\Mollie\TestHelpers\LinkObjectTestHelpers;
|
| 19 |
-
use stdClass;
|
| 20 |
-
|
| 21 |
-
class OrderPaymentEndpointTest extends BaseEndpointTest
|
| 22 |
-
{
|
| 23 |
-
use LinkObjectTestHelpers;
|
| 24 |
-
use AmountObjectTestHelpers;
|
| 25 |
-
|
| 26 |
-
public function testCreateOrderPayment()
|
| 27 |
-
{
|
| 28 |
-
$this->mockApiCall(
|
| 29 |
-
new Request(
|
| 30 |
-
"POST",
|
| 31 |
-
"/v2/orders/ord_stTC2WHAuS/payments",
|
| 32 |
-
[],
|
| 33 |
-
'{
|
| 34 |
-
"method": "banktransfer",
|
| 35 |
-
"dueDate": "2018-12-21"
|
| 36 |
-
}'
|
| 37 |
-
),
|
| 38 |
-
new Response(
|
| 39 |
-
201,
|
| 40 |
-
[],
|
| 41 |
-
'{
|
| 42 |
-
"resource": "payment",
|
| 43 |
-
"id": "tr_WDqYK6vllg",
|
| 44 |
-
"mode": "test",
|
| 45 |
-
"amount": {
|
| 46 |
-
"currency": "EUR",
|
| 47 |
-
"value": "698.00"
|
| 48 |
-
},
|
| 49 |
-
"status": "open",
|
| 50 |
-
"description": "Order #1337 (Lego cars)",
|
| 51 |
-
"createdAt": "2018-12-01T17:09:02+00:00",
|
| 52 |
-
"method": "banktransfer",
|
| 53 |
-
"metadata": null,
|
| 54 |
-
"orderId": "ord_stTC2WHAuS",
|
| 55 |
-
"isCancelable": true,
|
| 56 |
-
"locale": "nl_NL",
|
| 57 |
-
"profileId": "pfl_URR55HPMGx",
|
| 58 |
-
"sequenceType": "oneoff",
|
| 59 |
-
"settlementAmount": {
|
| 60 |
-
"value": "698.00",
|
| 61 |
-
"currency": "EUR"
|
| 62 |
-
},
|
| 63 |
-
"_links": {
|
| 64 |
-
"self": {
|
| 65 |
-
"href": "https://api.mollie.com/v2/payments/tr_WDqYK6vllg",
|
| 66 |
-
"type": "application/hal+json"
|
| 67 |
-
},
|
| 68 |
-
"order": {
|
| 69 |
-
"href": "https://api.mollie.com/v2/orders/ord_stTC2WHAuS",
|
| 70 |
-
"type": "application/hal+json"
|
| 71 |
-
},
|
| 72 |
-
"checkout": {
|
| 73 |
-
"href": "https://www.mollie.com/paymentscreen/testmode/?method=banktransfer&token=fgnwdh",
|
| 74 |
-
"type": "text/html"
|
| 75 |
-
},
|
| 76 |
-
"status": {
|
| 77 |
-
"href": "https://www.mollie.com/paymentscreen/banktransfer/status/fgnwdh",
|
| 78 |
-
"type": "text/html"
|
| 79 |
-
},
|
| 80 |
-
"payOnline": {
|
| 81 |
-
"href": "https://www.mollie.com/paymentscreen/banktransfer/pay-online/fgnwdh",
|
| 82 |
-
"type": "text/html"
|
| 83 |
-
},
|
| 84 |
-
"documentation": {
|
| 85 |
-
"href": "https://docs.mollie.com/reference/v2/orders-api/create-order-payment",
|
| 86 |
-
"type": "text/html"
|
| 87 |
-
}
|
| 88 |
-
}
|
| 89 |
-
}'
|
| 90 |
-
)
|
| 91 |
-
);
|
| 92 |
-
|
| 93 |
-
$order = $this->getOrder('ord_stTC2WHAuS');
|
| 94 |
-
|
| 95 |
-
$payment = $order->createPayment([
|
| 96 |
-
'method' => 'banktransfer',
|
| 97 |
-
'dueDate' => '2018-12-21',
|
| 98 |
-
]);
|
| 99 |
-
|
| 100 |
-
$this->assertNotNull($payment);
|
| 101 |
-
$this->assertInstanceOf(Payment::class, $payment);
|
| 102 |
-
$this->assertEquals('payment', $payment->resource);
|
| 103 |
-
$this->assertEquals('tr_WDqYK6vllg', $payment->id);
|
| 104 |
-
$this->assertEquals('test', $payment->mode);
|
| 105 |
-
$this->assertAmountObject(698, 'EUR', $payment->amount);
|
| 106 |
-
$this->assertEquals('open', $payment->status);
|
| 107 |
-
$this->assertEquals(PaymentStatus::STATUS_OPEN, $payment->status);
|
| 108 |
-
$this->assertEquals('Order #1337 (Lego cars)', $payment->description);
|
| 109 |
-
$this->assertEquals('2018-12-01T17:09:02+00:00', $payment->createdAt);
|
| 110 |
-
$this->assertEquals(PaymentMethod::BANKTRANSFER, $payment->method);
|
| 111 |
-
$this->assertNull($payment->metadata);
|
| 112 |
-
$this->assertEquals('ord_stTC2WHAuS', $payment->orderId);
|
| 113 |
-
$this->assertTrue($payment->isCancelable);
|
| 114 |
-
$this->assertEquals('nl_NL', $payment->locale);
|
| 115 |
-
$this->assertEquals('pfl_URR55HPMGx', $payment->profileId);
|
| 116 |
-
$this->assertEquals(SequenceType::SEQUENCETYPE_ONEOFF, $payment->sequenceType);
|
| 117 |
-
$this->assertAmountObject(698, 'EUR', $payment->settlementAmount);
|
| 118 |
-
|
| 119 |
-
$this->assertLinkObject(
|
| 120 |
-
'https://api.mollie.com/v2/payments/tr_WDqYK6vllg',
|
| 121 |
-
'application/hal+json',
|
| 122 |
-
$payment->_links->self
|
| 123 |
-
);
|
| 124 |
-
$this->assertLinkObject(
|
| 125 |
-
'https://api.mollie.com/v2/orders/ord_stTC2WHAuS',
|
| 126 |
-
'application/hal+json',
|
| 127 |
-
$payment->_links->order
|
| 128 |
-
);
|
| 129 |
-
$this->assertLinkObject(
|
| 130 |
-
'https://www.mollie.com/paymentscreen/testmode/?method=banktransfer&token=fgnwdh',
|
| 131 |
-
'text/html',
|
| 132 |
-
$payment->_links->checkout
|
| 133 |
-
);
|
| 134 |
-
$this->assertLinkObject(
|
| 135 |
-
'https://www.mollie.com/paymentscreen/banktransfer/status/fgnwdh',
|
| 136 |
-
'text/html',
|
| 137 |
-
$payment->_links->status
|
| 138 |
-
);
|
| 139 |
-
$this->assertLinkObject(
|
| 140 |
-
'https://www.mollie.com/paymentscreen/banktransfer/pay-online/fgnwdh',
|
| 141 |
-
'text/html',
|
| 142 |
-
$payment->_links->payOnline
|
| 143 |
-
);
|
| 144 |
-
$this->assertLinkObject(
|
| 145 |
-
'https://docs.mollie.com/reference/v2/orders-api/create-order-payment',
|
| 146 |
-
'text/html',
|
| 147 |
-
$payment->_links->documentation
|
| 148 |
-
);
|
| 149 |
-
}
|
| 150 |
-
|
| 151 |
-
protected function getOrder($id)
|
| 152 |
-
{
|
| 153 |
-
$orderJson = $this->getOrderResponseFixture($id);
|
| 154 |
-
return $this->copy(json_decode($orderJson), new Order($this->apiClient));
|
| 155 |
-
}
|
| 156 |
-
|
| 157 |
-
protected function getOrderResponseFixture($order_id, $order_status = OrderStatus::STATUS_CREATED)
|
| 158 |
-
{
|
| 159 |
-
return str_replace(
|
| 160 |
-
"<<order_id>>",
|
| 161 |
-
$order_id,
|
| 162 |
-
'{
|
| 163 |
-
"resource": "order",
|
| 164 |
-
"id": "<<order_id>>",
|
| 165 |
-
"profileId": "pfl_URR55HPMGx",
|
| 166 |
-
"amount": {
|
| 167 |
-
"value": "1027.99",
|
| 168 |
-
"currency": "EUR"
|
| 169 |
-
},
|
| 170 |
-
"amountCaptured": {
|
| 171 |
-
"value": "0.00",
|
| 172 |
-
"currency": "EUR"
|
| 173 |
-
},
|
| 174 |
-
"amountRefunded": {
|
| 175 |
-
"value": "0.00",
|
| 176 |
-
"currency": "EUR"
|
| 177 |
-
},
|
| 178 |
-
"status": "' . $order_status . '",
|
| 179 |
-
"metadata": {
|
| 180 |
-
"order_id": "1337",
|
| 181 |
-
"description": "Lego cars"
|
| 182 |
-
},
|
| 183 |
-
"consumerDateOfBirth": "1958-01-31",
|
| 184 |
-
"createdAt": "2018-08-02T09:29:56+00:00",
|
| 185 |
-
"mode": "live",
|
| 186 |
-
"billingAddress": {
|
| 187 |
-
"organizationName": "Organization Name LTD.",
|
| 188 |
-
"streetAndNumber": "Keizersgracht 313",
|
| 189 |
-
"postalCode": "1016 EE",
|
| 190 |
-
"city": "Amsterdam",
|
| 191 |
-
"country": "nl",
|
| 192 |
-
"givenName": "Luke",
|
| 193 |
-
"familyName": "Skywalker",
|
| 194 |
-
"email": "luke@skywalker.com"
|
| 195 |
-
},
|
| 196 |
-
"shippingAddress": {
|
| 197 |
-
"organizationName": "Organization Name LTD.",
|
| 198 |
-
"streetAndNumber": "Keizersgracht 313",
|
| 199 |
-
"postalCode": "1016 EE",
|
| 200 |
-
"city": "Amsterdam",
|
| 201 |
-
"country": "nl",
|
| 202 |
-
"givenName": "Luke",
|
| 203 |
-
"familyName": "Skywalker",
|
| 204 |
-
"email": "luke@skywalker.com"
|
| 205 |
-
},
|
| 206 |
-
"orderNumber": "1337",
|
| 207 |
-
"locale": "nl_NL",
|
| 208 |
-
"method" : "klarnapaylater",
|
| 209 |
-
"isCancelable": true,
|
| 210 |
-
"redirectUrl": "https://example.org/redirect",
|
| 211 |
-
"webhookUrl": "https://example.org/webhook",
|
| 212 |
-
"lines": [
|
| 213 |
-
{
|
| 214 |
-
"resource": "orderline",
|
| 215 |
-
"id": "odl_dgtxyl",
|
| 216 |
-
"orderId": "<<order_id>>",
|
| 217 |
-
"name": "LEGO 42083 Bugatti Chiron",
|
| 218 |
-
"productUrl": "https://shop.lego.com/nl-NL/Bugatti-Chiron-42083",
|
| 219 |
-
"imageUrl": "https://sh-s7-live-s.legocdn.com/is/image//LEGO/42083_alt1?$main$",
|
| 220 |
-
"sku": "5702016116977",
|
| 221 |
-
"type": "physical",
|
| 222 |
-
"status": "created",
|
| 223 |
-
"isCancelable": true,
|
| 224 |
-
"quantity": 2,
|
| 225 |
-
"unitPrice": {
|
| 226 |
-
"value": "399.00",
|
| 227 |
-
"currency": "EUR"
|
| 228 |
-
},
|
| 229 |
-
"vatRate": "21.00",
|
| 230 |
-
"vatAmount": {
|
| 231 |
-
"value": "121.14",
|
| 232 |
-
"currency": "EUR"
|
| 233 |
-
},
|
| 234 |
-
"discountAmount": {
|
| 235 |
-
"value": "100.00",
|
| 236 |
-
"currency": "EUR"
|
| 237 |
-
},
|
| 238 |
-
"totalAmount": {
|
| 239 |
-
"value": "698.00",
|
| 240 |
-
"currency": "EUR"
|
| 241 |
-
},
|
| 242 |
-
"createdAt": "2018-08-02T09:29:56+00:00"
|
| 243 |
-
},
|
| 244 |
-
{
|
| 245 |
-
"resource": "orderline",
|
| 246 |
-
"id": "odl_jp31jz",
|
| 247 |
-
"orderId": "<<order_id>>",
|
| 248 |
-
"name": "LEGO 42056 Porsche 911 GT3 RS",
|
| 249 |
-
"productUrl": "https://shop.lego.com/nl-NL/Porsche-911-GT3-RS-42056",
|
| 250 |
-
"imageUrl": "https://sh-s7-live-s.legocdn.com/is/image/LEGO/42056?$PDPDefault$",
|
| 251 |
-
"sku": "5702015594028",
|
| 252 |
-
"type": "digital",
|
| 253 |
-
"status": "created",
|
| 254 |
-
"isCancelable": true,
|
| 255 |
-
"quantity": 1,
|
| 256 |
-
"unitPrice": {
|
| 257 |
-
"value": "329.99",
|
| 258 |
-
"currency": "EUR"
|
| 259 |
-
},
|
| 260 |
-
"vatRate": "21.00",
|
| 261 |
-
"vatAmount": {
|
| 262 |
-
"value": "57.27",
|
| 263 |
-
"currency": "EUR"
|
| 264 |
-
},
|
| 265 |
-
"totalAmount": {
|
| 266 |
-
"value": "329.99",
|
| 267 |
-
"currency": "EUR"
|
| 268 |
-
},
|
| 269 |
-
"createdAt": "2018-08-02T09:29:56+00:00"
|
| 270 |
-
}
|
| 271 |
-
],
|
| 272 |
-
"_links": {
|
| 273 |
-
"self": {
|
| 274 |
-
"href": "https://api.mollie.com/v2/orders/<<order_id>>",
|
| 275 |
-
"type": "application/hal+json"
|
| 276 |
-
},
|
| 277 |
-
"checkout": {
|
| 278 |
-
"href": "https://www.mollie.com/payscreen/select-method/7UhSN1zuXS",
|
| 279 |
-
"type": "text/html"
|
| 280 |
-
},
|
| 281 |
-
"documentation": {
|
| 282 |
-
"href": "https://docs.mollie.com/reference/v2/orders-api/get-order",
|
| 283 |
-
"type": "text/html"
|
| 284 |
-
}
|
| 285 |
-
}
|
| 286 |
-
}'
|
| 287 |
-
);
|
| 288 |
-
}
|
| 289 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Endpoints/OrderRefundEndpointTest.php
DELETED
|
@@ -1,427 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\Api\Endpoints;
|
| 4 |
-
|
| 5 |
-
use GuzzleHttp\Psr7\Request;
|
| 6 |
-
use GuzzleHttp\Psr7\Response;
|
| 7 |
-
use Mollie\Api\Resources\Order;
|
| 8 |
-
use Mollie\Api\Resources\OrderLine;
|
| 9 |
-
use Mollie\Api\Resources\Refund;
|
| 10 |
-
use Mollie\Api\Resources\RefundCollection;
|
| 11 |
-
use Mollie\Api\Types\OrderStatus;
|
| 12 |
-
use Mollie\Api\Types\RefundStatus;
|
| 13 |
-
use Tests\Mollie\TestHelpers\AmountObjectTestHelpers;
|
| 14 |
-
use Tests\Mollie\TestHelpers\LinkObjectTestHelpers;
|
| 15 |
-
|
| 16 |
-
class OrderRefundEndpointTest extends BaseEndpointTest
|
| 17 |
-
{
|
| 18 |
-
use LinkObjectTestHelpers;
|
| 19 |
-
use AmountObjectTestHelpers;
|
| 20 |
-
|
| 21 |
-
public function testCreatePartialOrderRefund()
|
| 22 |
-
{
|
| 23 |
-
$this->mockApiCall(
|
| 24 |
-
new Request(
|
| 25 |
-
"POST",
|
| 26 |
-
"/v2/orders/ord_stTC2WHAuS/refunds",
|
| 27 |
-
[],
|
| 28 |
-
'{
|
| 29 |
-
"lines": [
|
| 30 |
-
{
|
| 31 |
-
"id": "odl_dgtxyl",
|
| 32 |
-
"quantity": 1
|
| 33 |
-
}
|
| 34 |
-
]
|
| 35 |
-
}'
|
| 36 |
-
),
|
| 37 |
-
new Response(
|
| 38 |
-
201,
|
| 39 |
-
[],
|
| 40 |
-
$this->getOrderRefundResponseFixture('re_4qqhO89gsT', 'ord_stTC2WHAuS')
|
| 41 |
-
)
|
| 42 |
-
);
|
| 43 |
-
|
| 44 |
-
$order = $this->getOrder('ord_stTC2WHAuS');
|
| 45 |
-
|
| 46 |
-
$refund = $order->refund([
|
| 47 |
-
'lines' => [
|
| 48 |
-
[
|
| 49 |
-
'id' => 'odl_dgtxyl',
|
| 50 |
-
'quantity' => 1,
|
| 51 |
-
]
|
| 52 |
-
],
|
| 53 |
-
]);
|
| 54 |
-
|
| 55 |
-
$this->assertOrderRefund($refund, 're_4qqhO89gsT');
|
| 56 |
-
}
|
| 57 |
-
|
| 58 |
-
public function testCreateCompleteOrderRefund()
|
| 59 |
-
{
|
| 60 |
-
$this->mockApiCall(
|
| 61 |
-
new Request(
|
| 62 |
-
"POST",
|
| 63 |
-
"/v2/orders/ord_stTC2WHAuS/refunds",
|
| 64 |
-
[],
|
| 65 |
-
'{
|
| 66 |
-
"lines": []
|
| 67 |
-
}'
|
| 68 |
-
),
|
| 69 |
-
new Response(
|
| 70 |
-
201,
|
| 71 |
-
[],
|
| 72 |
-
$this->getOrderRefundResponseFixture('re_4qqhO89gsT', 'ord_stTC2WHAuS')
|
| 73 |
-
)
|
| 74 |
-
);
|
| 75 |
-
|
| 76 |
-
$order = $this->getOrder('ord_stTC2WHAuS');
|
| 77 |
-
|
| 78 |
-
$refund = $order->refundAll();
|
| 79 |
-
|
| 80 |
-
$this->assertOrderRefund($refund, 're_4qqhO89gsT');
|
| 81 |
-
}
|
| 82 |
-
|
| 83 |
-
public function testListOrderRefunds()
|
| 84 |
-
{
|
| 85 |
-
$this->mockApiCall(
|
| 86 |
-
new Request(
|
| 87 |
-
"GET",
|
| 88 |
-
"/v2/orders/ord_stTC2WHAuS/refunds"
|
| 89 |
-
),
|
| 90 |
-
new Response(
|
| 91 |
-
200,
|
| 92 |
-
[],
|
| 93 |
-
'{
|
| 94 |
-
"count": 1,
|
| 95 |
-
"_embedded": {
|
| 96 |
-
"refunds": [
|
| 97 |
-
{
|
| 98 |
-
"resource": "refund",
|
| 99 |
-
"id": "re_4qqhO89gsT",
|
| 100 |
-
"amount": {
|
| 101 |
-
"currency": "EUR",
|
| 102 |
-
"value": "698.00"
|
| 103 |
-
},
|
| 104 |
-
"status": "pending",
|
| 105 |
-
"createdAt": "2018-03-19T12:33:37+00:00",
|
| 106 |
-
"description": "Item not in stock, refunding",
|
| 107 |
-
"paymentId": "tr_WDqYK6vllg",
|
| 108 |
-
"orderId": "ord_pbjz8x",
|
| 109 |
-
"lines": [
|
| 110 |
-
{
|
| 111 |
-
"resource": "orderline",
|
| 112 |
-
"id": "odl_dgtxyl",
|
| 113 |
-
"orderId": "ord_pbjz8x",
|
| 114 |
-
"name": "LEGO 42083 Bugatti Chiron",
|
| 115 |
-
"productUrl": "https://shop.lego.com/nl-NL/Bugatti-Chiron-42083",
|
| 116 |
-
"imageUrl": "https://sh-s7-live-s.legocdn.com/is/image//LEGO/42083_alt1?$main$",
|
| 117 |
-
"sku": "5702016116977",
|
| 118 |
-
"type": "physical",
|
| 119 |
-
"status": "refunded",
|
| 120 |
-
"quantity": 2,
|
| 121 |
-
"unitPrice": {
|
| 122 |
-
"value": "399.00",
|
| 123 |
-
"currency": "EUR"
|
| 124 |
-
},
|
| 125 |
-
"vatRate": "21.00",
|
| 126 |
-
"vatAmount": {
|
| 127 |
-
"value": "121.14",
|
| 128 |
-
"currency": "EUR"
|
| 129 |
-
},
|
| 130 |
-
"discountAmount": {
|
| 131 |
-
"value": "100.00",
|
| 132 |
-
"currency": "EUR"
|
| 133 |
-
},
|
| 134 |
-
"totalAmount": {
|
| 135 |
-
"value": "698.00",
|
| 136 |
-
"currency": "EUR"
|
| 137 |
-
},
|
| 138 |
-
"createdAt": "2018-08-02T09:29:56+00:00"
|
| 139 |
-
}
|
| 140 |
-
],
|
| 141 |
-
"_links": {
|
| 142 |
-
"self": {
|
| 143 |
-
"href": "https://api.mollie.com/v2/payments/tr_WDqYK6vllg/refunds/re_4qqhO89gsT",
|
| 144 |
-
"type": "application/hal+json"
|
| 145 |
-
},
|
| 146 |
-
"payment": {
|
| 147 |
-
"href": "https://api.mollie.com/v2/payments/tr_WDqYK6vllg",
|
| 148 |
-
"type": "application/hal+json"
|
| 149 |
-
},
|
| 150 |
-
"order": {
|
| 151 |
-
"href": "https://api.mollie.com/v2/orders/ord_pbjz8x",
|
| 152 |
-
"type": "application/hal+json"
|
| 153 |
-
},
|
| 154 |
-
"documentation": {
|
| 155 |
-
"href": "https://docs.mollie.com/reference/v2/refunds-api/get-refund",
|
| 156 |
-
"type": "text/html"
|
| 157 |
-
}
|
| 158 |
-
}
|
| 159 |
-
}
|
| 160 |
-
]
|
| 161 |
-
},
|
| 162 |
-
"_links": {
|
| 163 |
-
"self": {
|
| 164 |
-
"href": "https://api.mollie.com/v2/payments/tr_7UhSN1zuXS/refunds?limit=5",
|
| 165 |
-
"type": "application/hal+json"
|
| 166 |
-
},
|
| 167 |
-
"previous": null,
|
| 168 |
-
"next": {
|
| 169 |
-
"href": "https://api.mollie.com/v2/payments/tr_7UhSN1zuXS/refunds?from=re_APBiGPH2vV&limit=5",
|
| 170 |
-
"type": "application/hal+json"
|
| 171 |
-
},
|
| 172 |
-
"documentation": {
|
| 173 |
-
"href": "https://docs.mollie.com/reference/v2/orders-api/list-order-refunds",
|
| 174 |
-
"type": "text/html"
|
| 175 |
-
}
|
| 176 |
-
}
|
| 177 |
-
}'
|
| 178 |
-
)
|
| 179 |
-
);
|
| 180 |
-
|
| 181 |
-
$order = $this->getOrder('ord_stTC2WHAuS');
|
| 182 |
-
|
| 183 |
-
$refunds = $order->refunds();
|
| 184 |
-
|
| 185 |
-
$this->assertInstanceOf(RefundCollection::class, $refunds);
|
| 186 |
-
$this->assertEquals(1, $refunds->count);
|
| 187 |
-
$this->assertCount(1, $refunds);
|
| 188 |
-
|
| 189 |
-
$this->assertOrderRefund($refunds[0], 're_4qqhO89gsT');
|
| 190 |
-
}
|
| 191 |
-
|
| 192 |
-
protected function assertOrderRefund($refund, $refund_id, $refund_status = RefundStatus::STATUS_PENDING)
|
| 193 |
-
{
|
| 194 |
-
$this->assertInstanceOf(Refund::class, $refund);
|
| 195 |
-
$this->assertEquals($refund_id, $refund->id);
|
| 196 |
-
$this->assertAmountObject('698.00', 'EUR', $refund->amount);
|
| 197 |
-
|
| 198 |
-
$this->assertEquals($refund_status, $refund->status);
|
| 199 |
-
$this->assertEquals("2018-03-19T12:33:37+00:00", $refund->createdAt);
|
| 200 |
-
$this->assertEquals("Item not in stock, refunding", $refund->description);
|
| 201 |
-
$this->assertEquals("tr_WDqYK6vllg", $refund->paymentId);
|
| 202 |
-
|
| 203 |
-
$this->assertLinkObject(
|
| 204 |
-
"https://api.mollie.com/v2/payments/tr_WDqYK6vllg/refunds/{$refund_id}",
|
| 205 |
-
'application/hal+json',
|
| 206 |
-
$refund->_links->self
|
| 207 |
-
);
|
| 208 |
-
|
| 209 |
-
$this->assertLinkObject(
|
| 210 |
-
'https://docs.mollie.com/reference/v2/refunds-api/get-refund',
|
| 211 |
-
'text/html',
|
| 212 |
-
$refund->_links->documentation
|
| 213 |
-
);
|
| 214 |
-
}
|
| 215 |
-
|
| 216 |
-
protected function getOrderRefundResponseFixture($refund_id, $order_id)
|
| 217 |
-
{
|
| 218 |
-
return str_replace(
|
| 219 |
-
["<<refund_id>>", "<<order_id>>"],
|
| 220 |
-
[$refund_id, $order_id],
|
| 221 |
-
'{
|
| 222 |
-
"resource": "refund",
|
| 223 |
-
"id": "<<refund_id>>",
|
| 224 |
-
"amount": {
|
| 225 |
-
"currency": "EUR",
|
| 226 |
-
"value": "698.00"
|
| 227 |
-
},
|
| 228 |
-
"status": "pending",
|
| 229 |
-
"createdAt": "2018-03-19T12:33:37+00:00",
|
| 230 |
-
"description": "Item not in stock, refunding",
|
| 231 |
-
"paymentId": "tr_WDqYK6vllg",
|
| 232 |
-
"orderId": "<<order_id>>",
|
| 233 |
-
"lines": [
|
| 234 |
-
{
|
| 235 |
-
"resource": "orderline",
|
| 236 |
-
"id": "odl_dgtxyl",
|
| 237 |
-
"orderId": "<<order_id>>",
|
| 238 |
-
"name": "LEGO 42083 Bugatti Chiron",
|
| 239 |
-
"productUrl": "https://shop.lego.com/nl-NL/Bugatti-Chiron-42083",
|
| 240 |
-
"imageUrl": "https://sh-s7-live-s.legocdn.com/is/image//LEGO/42083_alt1?$main$",
|
| 241 |
-
"sku": "5702016116977",
|
| 242 |
-
"type": "physical",
|
| 243 |
-
"status": "refunded",
|
| 244 |
-
"quantity": 2,
|
| 245 |
-
"unitPrice": {
|
| 246 |
-
"value": "399.00",
|
| 247 |
-
"currency": "EUR"
|
| 248 |
-
},
|
| 249 |
-
"vatRate": "21.00",
|
| 250 |
-
"vatAmount": {
|
| 251 |
-
"value": "121.14",
|
| 252 |
-
"currency": "EUR"
|
| 253 |
-
},
|
| 254 |
-
"discountAmount": {
|
| 255 |
-
"value": "100.00",
|
| 256 |
-
"currency": "EUR"
|
| 257 |
-
},
|
| 258 |
-
"totalAmount": {
|
| 259 |
-
"value": "698.00",
|
| 260 |
-
"currency": "EUR"
|
| 261 |
-
},
|
| 262 |
-
"createdAt": "2018-08-02T09:29:56+00:00"
|
| 263 |
-
}
|
| 264 |
-
],
|
| 265 |
-
"_links": {
|
| 266 |
-
"self": {
|
| 267 |
-
"href": "https://api.mollie.com/v2/payments/tr_WDqYK6vllg/refunds/<<refund_id>>",
|
| 268 |
-
"type": "application/hal+json"
|
| 269 |
-
},
|
| 270 |
-
"payment": {
|
| 271 |
-
"href": "https://api.mollie.com/v2/payments/tr_WDqYK6vllg",
|
| 272 |
-
"type": "application/hal+json"
|
| 273 |
-
},
|
| 274 |
-
"order": {
|
| 275 |
-
"href": "https://api.mollie.com/v2/orders/<<order_id>>",
|
| 276 |
-
"type": "application/hal+json"
|
| 277 |
-
},
|
| 278 |
-
"documentation": {
|
| 279 |
-
"href": "https://docs.mollie.com/reference/v2/refunds-api/get-refund",
|
| 280 |
-
"type": "text/html"
|
| 281 |
-
}
|
| 282 |
-
}
|
| 283 |
-
}'
|
| 284 |
-
);
|
| 285 |
-
}
|
| 286 |
-
|
| 287 |
-
protected function getOrder($id)
|
| 288 |
-
{
|
| 289 |
-
$orderJson = $this->getOrderResponseFixture($id);
|
| 290 |
-
return $this->copy(json_decode($orderJson), new Order($this->apiClient));
|
| 291 |
-
}
|
| 292 |
-
|
| 293 |
-
protected function getOrderResponseFixture($order_id, $order_status = OrderStatus::STATUS_CREATED)
|
| 294 |
-
{
|
| 295 |
-
return str_replace(
|
| 296 |
-
"<<order_id>>",
|
| 297 |
-
$order_id,
|
| 298 |
-
'{
|
| 299 |
-
"resource": "order",
|
| 300 |
-
"id": "<<order_id>>",
|
| 301 |
-
"profileId": "pfl_URR55HPMGx",
|
| 302 |
-
"amount": {
|
| 303 |
-
"value": "1027.99",
|
| 304 |
-
"currency": "EUR"
|
| 305 |
-
},
|
| 306 |
-
"amountCaptured": {
|
| 307 |
-
"value": "0.00",
|
| 308 |
-
"currency": "EUR"
|
| 309 |
-
},
|
| 310 |
-
"amountRefunded": {
|
| 311 |
-
"value": "0.00",
|
| 312 |
-
"currency": "EUR"
|
| 313 |
-
},
|
| 314 |
-
"status": "' . $order_status . '",
|
| 315 |
-
"metadata": {
|
| 316 |
-
"order_id": "1337",
|
| 317 |
-
"description": "Lego cars"
|
| 318 |
-
},
|
| 319 |
-
"consumerDateOfBirth": "1958-01-31",
|
| 320 |
-
"createdAt": "2018-08-02T09:29:56+00:00",
|
| 321 |
-
"mode": "live",
|
| 322 |
-
"billingAddress": {
|
| 323 |
-
"streetAndNumber": "Keizersgracht 313",
|
| 324 |
-
"postalCode": "1016 EE",
|
| 325 |
-
"city": "Amsterdam",
|
| 326 |
-
"country": "nl",
|
| 327 |
-
"givenName": "Luke",
|
| 328 |
-
"familyName": "Skywalker",
|
| 329 |
-
"email": "luke@skywalker.com"
|
| 330 |
-
},
|
| 331 |
-
"shippingAddress": {
|
| 332 |
-
"streetAndNumber": "Keizersgracht 313",
|
| 333 |
-
"postalCode": "1016 EE",
|
| 334 |
-
"city": "Amsterdam",
|
| 335 |
-
"country": "nl",
|
| 336 |
-
"givenName": "Luke",
|
| 337 |
-
"familyName": "Skywalker",
|
| 338 |
-
"email": "luke@skywalker.com"
|
| 339 |
-
},
|
| 340 |
-
"orderNumber": "1337",
|
| 341 |
-
"locale": "nl_NL",
|
| 342 |
-
"method" : "klarnapaylater",
|
| 343 |
-
"isCancelable": true,
|
| 344 |
-
"redirectUrl": "https://example.org/redirect",
|
| 345 |
-
"webhookUrl": "https://example.org/webhook",
|
| 346 |
-
"lines": [
|
| 347 |
-
{
|
| 348 |
-
"resource": "orderline",
|
| 349 |
-
"id": "odl_dgtxyl",
|
| 350 |
-
"orderId": "<<order_id>>",
|
| 351 |
-
"name": "LEGO 42083 Bugatti Chiron",
|
| 352 |
-
"productUrl": "https://shop.lego.com/nl-NL/Bugatti-Chiron-42083",
|
| 353 |
-
"imageUrl": "https://sh-s7-live-s.legocdn.com/is/image//LEGO/42083_alt1?$main$",
|
| 354 |
-
"sku": "5702016116977",
|
| 355 |
-
"type": "physical",
|
| 356 |
-
"status": "created",
|
| 357 |
-
"isCancelable": true,
|
| 358 |
-
"quantity": 2,
|
| 359 |
-
"unitPrice": {
|
| 360 |
-
"value": "399.00",
|
| 361 |
-
"currency": "EUR"
|
| 362 |
-
},
|
| 363 |
-
"vatRate": "21.00",
|
| 364 |
-
"vatAmount": {
|
| 365 |
-
"value": "121.14",
|
| 366 |
-
"currency": "EUR"
|
| 367 |
-
},
|
| 368 |
-
"discountAmount": {
|
| 369 |
-
"value": "100.00",
|
| 370 |
-
"currency": "EUR"
|
| 371 |
-
},
|
| 372 |
-
"totalAmount": {
|
| 373 |
-
"value": "698.00",
|
| 374 |
-
"currency": "EUR"
|
| 375 |
-
},
|
| 376 |
-
"createdAt": "2018-08-02T09:29:56+00:00"
|
| 377 |
-
},
|
| 378 |
-
{
|
| 379 |
-
"resource": "orderline",
|
| 380 |
-
"id": "odl_jp31jz",
|
| 381 |
-
"orderId": "<<order_id>>",
|
| 382 |
-
"name": "LEGO 42056 Porsche 911 GT3 RS",
|
| 383 |
-
"productUrl": "https://shop.lego.com/nl-NL/Porsche-911-GT3-RS-42056",
|
| 384 |
-
"imageUrl": "https://sh-s7-live-s.legocdn.com/is/image/LEGO/42056?$PDPDefault$",
|
| 385 |
-
"sku": "5702015594028",
|
| 386 |
-
"type": "digital",
|
| 387 |
-
"status": "created",
|
| 388 |
-
"isCancelable": true,
|
| 389 |
-
"quantity": 1,
|
| 390 |
-
"unitPrice": {
|
| 391 |
-
"value": "329.99",
|
| 392 |
-
"currency": "EUR"
|
| 393 |
-
},
|
| 394 |
-
"vatRate": "21.00",
|
| 395 |
-
"vatAmount": {
|
| 396 |
-
"value": "57.27",
|
| 397 |
-
"currency": "EUR"
|
| 398 |
-
},
|
| 399 |
-
"totalAmount": {
|
| 400 |
-
"value": "329.99",
|
| 401 |
-
"currency": "EUR"
|
| 402 |
-
},
|
| 403 |
-
"createdAt": "2018-08-02T09:29:56+00:00"
|
| 404 |
-
}
|
| 405 |
-
],
|
| 406 |
-
"_links": {
|
| 407 |
-
"refunds": {
|
| 408 |
-
"href": "https://api.mollie.com/v2/orders/<<order_id>>/refunds",
|
| 409 |
-
"type": "application/hal+json"
|
| 410 |
-
},
|
| 411 |
-
"self": {
|
| 412 |
-
"href": "https://api.mollie.com/v2/orders/<<order_id>>",
|
| 413 |
-
"type": "application/hal+json"
|
| 414 |
-
},
|
| 415 |
-
"checkout": {
|
| 416 |
-
"href": "https://www.mollie.com/payscreen/select-method/7UhSN1zuXS",
|
| 417 |
-
"type": "text/html"
|
| 418 |
-
},
|
| 419 |
-
"documentation": {
|
| 420 |
-
"href": "https://docs.mollie.com/reference/v2/orders-api/get-order",
|
| 421 |
-
"type": "text/html"
|
| 422 |
-
}
|
| 423 |
-
}
|
| 424 |
-
}'
|
| 425 |
-
);
|
| 426 |
-
}
|
| 427 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Endpoints/OrganizationEndpointTest.php
DELETED
|
@@ -1,126 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\Api\Endpoints;
|
| 4 |
-
|
| 5 |
-
use GuzzleHttp\Psr7\Request;
|
| 6 |
-
use GuzzleHttp\Psr7\Response;
|
| 7 |
-
use Mollie\Api\Resources\Organization;
|
| 8 |
-
use Mollie\Api\Resources\OrganizationCollection;
|
| 9 |
-
use Tests\Mollie\TestHelpers\LinkObjectTestHelpers;
|
| 10 |
-
|
| 11 |
-
class OrganizationEndpointTest extends BaseEndpointTest
|
| 12 |
-
{
|
| 13 |
-
use LinkObjectTestHelpers;
|
| 14 |
-
|
| 15 |
-
public function testGetOrganization()
|
| 16 |
-
{
|
| 17 |
-
$this->mockApiCall(
|
| 18 |
-
new Request("GET", "/v2/organizations/org_12345678"),
|
| 19 |
-
new Response(
|
| 20 |
-
200,
|
| 21 |
-
[],
|
| 22 |
-
'{
|
| 23 |
-
"resource": "organization",
|
| 24 |
-
"id": "org_12345678",
|
| 25 |
-
"name": "Mollie B.V.",
|
| 26 |
-
"email": "info@mollie.com",
|
| 27 |
-
"locale": "nl_NL",
|
| 28 |
-
"address": {
|
| 29 |
-
"streetAndNumber": "Keizersgracht 313",
|
| 30 |
-
"postalCode": "1016 EE",
|
| 31 |
-
"city": "Amsterdam",
|
| 32 |
-
"country": "NL"
|
| 33 |
-
},
|
| 34 |
-
"registrationNumber": "30204462",
|
| 35 |
-
"vatNumber": "NL815839091B01",
|
| 36 |
-
"_links": {
|
| 37 |
-
"self": {
|
| 38 |
-
"href": "https://api.mollie.com/v2/organizations/org_12345678",
|
| 39 |
-
"type": "application/hal+json"
|
| 40 |
-
},
|
| 41 |
-
"documentation": {
|
| 42 |
-
"href": "https://docs.mollie.com/reference/v2/organizations-api/get-organization",
|
| 43 |
-
"type": "text/html"
|
| 44 |
-
}
|
| 45 |
-
}
|
| 46 |
-
}'
|
| 47 |
-
)
|
| 48 |
-
);
|
| 49 |
-
|
| 50 |
-
$organization = $this->apiClient->organizations->get('org_12345678');
|
| 51 |
-
|
| 52 |
-
$this->assertOrganization($organization);
|
| 53 |
-
}
|
| 54 |
-
|
| 55 |
-
public function testGetCurrentOrganization()
|
| 56 |
-
{
|
| 57 |
-
$this->mockApiCall(
|
| 58 |
-
new Request("GET", "/v2/organizations/me"),
|
| 59 |
-
new Response(
|
| 60 |
-
200,
|
| 61 |
-
[],
|
| 62 |
-
'{
|
| 63 |
-
"resource": "organization",
|
| 64 |
-
"id": "org_12345678",
|
| 65 |
-
"name": "Mollie B.V.",
|
| 66 |
-
"email": "info@mollie.com",
|
| 67 |
-
"locale": "nl_NL",
|
| 68 |
-
"address": {
|
| 69 |
-
"streetAndNumber": "Keizersgracht 313",
|
| 70 |
-
"postalCode": "1016 EE",
|
| 71 |
-
"city": "Amsterdam",
|
| 72 |
-
"country": "NL"
|
| 73 |
-
},
|
| 74 |
-
"registrationNumber": "30204462",
|
| 75 |
-
"vatNumber": "NL815839091B01",
|
| 76 |
-
"_links": {
|
| 77 |
-
"self": {
|
| 78 |
-
"href": "https://api.mollie.com/v2/organizations/org_12345678",
|
| 79 |
-
"type": "application/hal+json"
|
| 80 |
-
},
|
| 81 |
-
"documentation": {
|
| 82 |
-
"href": "https://docs.mollie.com/reference/v2/organizations-api/get-organization",
|
| 83 |
-
"type": "text/html"
|
| 84 |
-
}
|
| 85 |
-
}
|
| 86 |
-
}'
|
| 87 |
-
)
|
| 88 |
-
);
|
| 89 |
-
|
| 90 |
-
$organization = $this->apiClient->organizations->current();
|
| 91 |
-
|
| 92 |
-
$this->assertOrganization($organization);
|
| 93 |
-
}
|
| 94 |
-
|
| 95 |
-
protected function assertOrganization($organization)
|
| 96 |
-
{
|
| 97 |
-
$this->assertInstanceOf(Organization::class, $organization);
|
| 98 |
-
|
| 99 |
-
$this->assertEquals('org_12345678', $organization->id);
|
| 100 |
-
$this->assertEquals('Mollie B.V.', $organization->name);
|
| 101 |
-
$this->assertEquals('info@mollie.com', $organization->email);
|
| 102 |
-
$this->assertEquals('nl_NL', $organization->locale);
|
| 103 |
-
|
| 104 |
-
$this->assertEquals((object) [
|
| 105 |
-
'streetAndNumber' => 'Keizersgracht 313',
|
| 106 |
-
'postalCode' => '1016 EE',
|
| 107 |
-
'city' => 'Amsterdam',
|
| 108 |
-
'country' => 'NL',
|
| 109 |
-
], $organization->address);
|
| 110 |
-
|
| 111 |
-
$this->assertEquals('30204462', $organization->registrationNumber);
|
| 112 |
-
$this->assertEquals('NL815839091B01', $organization->vatNumber);
|
| 113 |
-
|
| 114 |
-
$this->assertLinkObject(
|
| 115 |
-
'https://api.mollie.com/v2/organizations/org_12345678',
|
| 116 |
-
'application/hal+json',
|
| 117 |
-
$organization->_links->self
|
| 118 |
-
);
|
| 119 |
-
|
| 120 |
-
$this->assertLinkObject(
|
| 121 |
-
'https://docs.mollie.com/reference/v2/organizations-api/get-organization',
|
| 122 |
-
'text/html',
|
| 123 |
-
$organization->_links->documentation
|
| 124 |
-
);
|
| 125 |
-
}
|
| 126 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Endpoints/PaymentCaptureEndpointTest.php
DELETED
|
@@ -1,283 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\Api\Endpoints;
|
| 4 |
-
|
| 5 |
-
use GuzzleHttp\Psr7\Request;
|
| 6 |
-
use GuzzleHttp\Psr7\Response;
|
| 7 |
-
use Mollie\Api\Resources\Capture;
|
| 8 |
-
use Mollie\Api\Resources\Payment;
|
| 9 |
-
use Tests\Mollie\TestHelpers\AmountObjectTestHelpers;
|
| 10 |
-
use Tests\Mollie\TestHelpers\LinkObjectTestHelpers;
|
| 11 |
-
|
| 12 |
-
class PaymentCaptureEndpointTest extends BaseEndpointTest
|
| 13 |
-
{
|
| 14 |
-
use AmountObjectTestHelpers;
|
| 15 |
-
use LinkObjectTestHelpers;
|
| 16 |
-
|
| 17 |
-
public function testGetCaptureForPaymentResource()
|
| 18 |
-
{
|
| 19 |
-
$this->mockApiCall(
|
| 20 |
-
new Request(
|
| 21 |
-
'GET',
|
| 22 |
-
'/v2/payments/tr_WDqYK6vllg/captures/cpt_4qqhO89gsT'
|
| 23 |
-
),
|
| 24 |
-
new Response(
|
| 25 |
-
200,
|
| 26 |
-
[],
|
| 27 |
-
$this->getCaptureFixture('tr_WDqYK6vllg', 'cpt_4qqhO89gsT')
|
| 28 |
-
)
|
| 29 |
-
);
|
| 30 |
-
|
| 31 |
-
$capture = $this->apiClient->paymentCaptures->getFor(
|
| 32 |
-
$this->getPayment('tr_WDqYK6vllg'),
|
| 33 |
-
'cpt_4qqhO89gsT'
|
| 34 |
-
);
|
| 35 |
-
|
| 36 |
-
$this->assertCapture($capture);
|
| 37 |
-
}
|
| 38 |
-
|
| 39 |
-
public function testGetCaptureOnPaymentResource()
|
| 40 |
-
{
|
| 41 |
-
$this->mockApiCall(
|
| 42 |
-
new Request(
|
| 43 |
-
'GET',
|
| 44 |
-
'/v2/payments/tr_WDqYK6vllg/captures/cpt_4qqhO89gsT'
|
| 45 |
-
),
|
| 46 |
-
new Response(
|
| 47 |
-
200,
|
| 48 |
-
[],
|
| 49 |
-
$this->getCaptureFixture('tr_WDqYK6vllg', 'cpt_4qqhO89gsT')
|
| 50 |
-
)
|
| 51 |
-
);
|
| 52 |
-
|
| 53 |
-
$capture = $this->getPayment('tr_WDqYK6vllg')->getCapture('cpt_4qqhO89gsT');
|
| 54 |
-
|
| 55 |
-
$this->assertCapture($capture);
|
| 56 |
-
}
|
| 57 |
-
|
| 58 |
-
public function testListCapturesOnPaymentResource()
|
| 59 |
-
{
|
| 60 |
-
$this->mockApiCall(
|
| 61 |
-
new Request(
|
| 62 |
-
'GET',
|
| 63 |
-
'/v2/payments/tr_WDqYK6vllg/captures'
|
| 64 |
-
),
|
| 65 |
-
new Response(
|
| 66 |
-
200,
|
| 67 |
-
[],
|
| 68 |
-
'{
|
| 69 |
-
"_embedded": {
|
| 70 |
-
"captures": [
|
| 71 |
-
' . $this->getCaptureFixture('tr_WDqYK6vllg', 'cpt_4qqhO89gsT') . '
|
| 72 |
-
]
|
| 73 |
-
},
|
| 74 |
-
"count": 1,
|
| 75 |
-
"_links": {
|
| 76 |
-
"documentation": {
|
| 77 |
-
"href": "https://docs.mollie.com/reference/v2/captures-api/list-captures",
|
| 78 |
-
"type": "text/html"
|
| 79 |
-
},
|
| 80 |
-
"self": {
|
| 81 |
-
"href": "https://api.mollie.dev/v2/payments/tr_WDqYK6vllg/captures?limit=50",
|
| 82 |
-
"type": "application/hal+json"
|
| 83 |
-
},
|
| 84 |
-
"previous": null,
|
| 85 |
-
"next": null
|
| 86 |
-
}
|
| 87 |
-
}'
|
| 88 |
-
)
|
| 89 |
-
);
|
| 90 |
-
|
| 91 |
-
$captures = $this->getPayment('tr_WDqYK6vllg')->captures();
|
| 92 |
-
|
| 93 |
-
$this->assertEquals(1, $captures->count);
|
| 94 |
-
|
| 95 |
-
$this->assertLinkObject(
|
| 96 |
-
'https://docs.mollie.com/reference/v2/captures-api/list-captures',
|
| 97 |
-
'text/html',
|
| 98 |
-
$captures->_links->documentation
|
| 99 |
-
);
|
| 100 |
-
|
| 101 |
-
$this->assertLinkObject(
|
| 102 |
-
'https://api.mollie.dev/v2/payments/tr_WDqYK6vllg/captures?limit=50',
|
| 103 |
-
'application/hal+json',
|
| 104 |
-
$captures->_links->self
|
| 105 |
-
);
|
| 106 |
-
|
| 107 |
-
$this->assertNull($captures->_links->previous);
|
| 108 |
-
$this->assertNull($captures->_links->next);
|
| 109 |
-
|
| 110 |
-
$this->assertCapture($captures[0]);
|
| 111 |
-
}
|
| 112 |
-
|
| 113 |
-
protected function assertCapture($capture)
|
| 114 |
-
{
|
| 115 |
-
$this->assertInstanceOf(Capture::class, $capture);
|
| 116 |
-
|
| 117 |
-
$this->assertEquals('capture', $capture->resource);
|
| 118 |
-
$this->assertEquals('cpt_4qqhO89gsT', $capture->id);
|
| 119 |
-
$this->assertEquals('live', $capture->mode);
|
| 120 |
-
$this->assertEquals('tr_WDqYK6vllg', $capture->paymentId);
|
| 121 |
-
$this->assertEquals('shp_3wmsgCJN4U', $capture->shipmentId);
|
| 122 |
-
$this->assertEquals('stl_jDk30akdN', $capture->settlementId);
|
| 123 |
-
|
| 124 |
-
$this->assertAmountObject('1027.99', 'EUR', $capture->amount);
|
| 125 |
-
$this->assertAmountObject('399.00', 'EUR', $capture->settlementAmount);
|
| 126 |
-
|
| 127 |
-
$this->assertEquals('2018-08-02T09:29:56+00:00', $capture->createdAt);
|
| 128 |
-
|
| 129 |
-
$this->assertLinkObject(
|
| 130 |
-
'https://api.mollie.com/v2/payments/tr_WDqYK6vllg/captures/cpt_4qqhO89gsT',
|
| 131 |
-
'application/hal+json',
|
| 132 |
-
$capture->_links->self
|
| 133 |
-
);
|
| 134 |
-
|
| 135 |
-
$this->assertLinkObject(
|
| 136 |
-
'https://api.mollie.com/v2/payments/tr_WDqYK6vllg',
|
| 137 |
-
'application/hal+json',
|
| 138 |
-
$capture->_links->payment
|
| 139 |
-
);
|
| 140 |
-
|
| 141 |
-
$this->assertLinkObject(
|
| 142 |
-
'https://api.mollie.com/v2/orders/ord_8wmqcHMN4U/shipments/shp_3wmsgCJN4U',
|
| 143 |
-
'application/hal+json',
|
| 144 |
-
$capture->_links->shipment
|
| 145 |
-
);
|
| 146 |
-
|
| 147 |
-
$this->assertLinkObject(
|
| 148 |
-
'https://api.mollie.com/v2/settlements/stl_jDk30akdN',
|
| 149 |
-
'application/hal+json',
|
| 150 |
-
$capture->_links->settlement
|
| 151 |
-
);
|
| 152 |
-
|
| 153 |
-
$this->assertLinkObject(
|
| 154 |
-
'https://docs.mollie.com/reference/v2/captures-api/get-capture',
|
| 155 |
-
'text/html',
|
| 156 |
-
$capture->_links->documentation
|
| 157 |
-
);
|
| 158 |
-
}
|
| 159 |
-
|
| 160 |
-
protected function getCaptureFixture(
|
| 161 |
-
$payment_id = 'tr_WDqYK6vllg',
|
| 162 |
-
$capture_id = 'cpt_4qqhO89gsT'
|
| 163 |
-
) {
|
| 164 |
-
return str_replace(
|
| 165 |
-
[
|
| 166 |
-
'<<payment_id>>',
|
| 167 |
-
'<<capture_id>>',
|
| 168 |
-
],
|
| 169 |
-
[
|
| 170 |
-
$payment_id,
|
| 171 |
-
$capture_id,
|
| 172 |
-
],
|
| 173 |
-
'{
|
| 174 |
-
"resource": "capture",
|
| 175 |
-
"id": "<<capture_id>>",
|
| 176 |
-
"mode": "live",
|
| 177 |
-
"amount": {
|
| 178 |
-
"value": "1027.99",
|
| 179 |
-
"currency": "EUR"
|
| 180 |
-
},
|
| 181 |
-
"settlementAmount": {
|
| 182 |
-
"value": "399.00",
|
| 183 |
-
"currency": "EUR"
|
| 184 |
-
},
|
| 185 |
-
"paymentId": "<<payment_id>>",
|
| 186 |
-
"shipmentId": "shp_3wmsgCJN4U",
|
| 187 |
-
"settlementId": "stl_jDk30akdN",
|
| 188 |
-
"createdAt": "2018-08-02T09:29:56+00:00",
|
| 189 |
-
"_links": {
|
| 190 |
-
"self": {
|
| 191 |
-
"href": "https://api.mollie.com/v2/payments/<<payment_id>>/captures/<<capture_id>>",
|
| 192 |
-
"type": "application/hal+json"
|
| 193 |
-
},
|
| 194 |
-
"payment": {
|
| 195 |
-
"href": "https://api.mollie.com/v2/payments/<<payment_id>>",
|
| 196 |
-
"type": "application/hal+json"
|
| 197 |
-
},
|
| 198 |
-
"shipment": {
|
| 199 |
-
"href": "https://api.mollie.com/v2/orders/ord_8wmqcHMN4U/shipments/shp_3wmsgCJN4U",
|
| 200 |
-
"type": "application/hal+json"
|
| 201 |
-
},
|
| 202 |
-
"settlement": {
|
| 203 |
-
"href": "https://api.mollie.com/v2/settlements/stl_jDk30akdN",
|
| 204 |
-
"type": "application/hal+json"
|
| 205 |
-
},
|
| 206 |
-
"documentation": {
|
| 207 |
-
"href": "https://docs.mollie.com/reference/v2/captures-api/get-capture",
|
| 208 |
-
"type": "text/html"
|
| 209 |
-
}
|
| 210 |
-
}
|
| 211 |
-
}'
|
| 212 |
-
);
|
| 213 |
-
}
|
| 214 |
-
|
| 215 |
-
/**
|
| 216 |
-
* @return Payment
|
| 217 |
-
*/
|
| 218 |
-
protected function getPayment($payment_id = 'tr_44aKxzEbr8')
|
| 219 |
-
{
|
| 220 |
-
$paymentJson = '{
|
| 221 |
-
"resource":"payment",
|
| 222 |
-
"id":"<<payment_id>>",
|
| 223 |
-
"mode":"test",
|
| 224 |
-
"createdAt":"2018-03-19T12:17:57+00:00",
|
| 225 |
-
"amount":{
|
| 226 |
-
"value":"20.00",
|
| 227 |
-
"currency":"EUR"
|
| 228 |
-
},
|
| 229 |
-
"description":"My first API payment",
|
| 230 |
-
"method":"ideal",
|
| 231 |
-
"metadata":{
|
| 232 |
-
"order_id":1234
|
| 233 |
-
},
|
| 234 |
-
"status":"paid",
|
| 235 |
-
"paidAt":"2018-03-19T12:18:35+00:00",
|
| 236 |
-
"amountRefunded":{
|
| 237 |
-
"value":"0.00",
|
| 238 |
-
"currency":"EUR"
|
| 239 |
-
},
|
| 240 |
-
"amountRemaining":{
|
| 241 |
-
"value":"20.00",
|
| 242 |
-
"currency":"EUR"
|
| 243 |
-
},
|
| 244 |
-
"details":{
|
| 245 |
-
"consumerName":"T. TEST",
|
| 246 |
-
"consumerAccount":"NL17RABO0213698412",
|
| 247 |
-
"consumerBic":"TESTNL99"
|
| 248 |
-
},
|
| 249 |
-
"locale":"nl_NL",
|
| 250 |
-
"countryCode":"NL",
|
| 251 |
-
"profileId":"pfl_2A1gacu42V",
|
| 252 |
-
"sequenceType":"oneoff",
|
| 253 |
-
"redirectUrl":"http://example.org/examples/03-return-page.php?order_id=1234",
|
| 254 |
-
"webhookUrl":"http://example.org/examples/02-webhook-verification.php",
|
| 255 |
-
"settlementAmount":{
|
| 256 |
-
"value":"20.00",
|
| 257 |
-
"currency":"EUR"
|
| 258 |
-
},
|
| 259 |
-
"_links":{
|
| 260 |
-
"self":{
|
| 261 |
-
"href":"https://api.mollie.com/v2/payments/<<payment_id>>",
|
| 262 |
-
"type":"application/hal+json"
|
| 263 |
-
},
|
| 264 |
-
"documentation":{
|
| 265 |
-
"href":"https://docs.mollie.com/reference/v2/payments-api/get-payment",
|
| 266 |
-
"type":"text/html"
|
| 267 |
-
},
|
| 268 |
-
"refunds":{
|
| 269 |
-
"href":"https://api.mollie.com/v2/payments/<<payment_id>>/refunds",
|
| 270 |
-
"type":"application/hal+json"
|
| 271 |
-
},
|
| 272 |
-
"captures":{
|
| 273 |
-
"href":"https://api.mollie.com/v2/payments/<<payment_id>>/captures",
|
| 274 |
-
"type":"application/hal+json"
|
| 275 |
-
}
|
| 276 |
-
}
|
| 277 |
-
}';
|
| 278 |
-
|
| 279 |
-
$paymentJson = str_replace('<<payment_id>>', $payment_id, $paymentJson);
|
| 280 |
-
|
| 281 |
-
return $this->copy(json_decode($paymentJson), new Payment($this->apiClient));
|
| 282 |
-
}
|
| 283 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Endpoints/PaymentChargebackEndpointTest.php
DELETED
|
@@ -1,265 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\Api\Endpoints;
|
| 4 |
-
|
| 5 |
-
use GuzzleHttp\Psr7\Request;
|
| 6 |
-
use GuzzleHttp\Psr7\Response;
|
| 7 |
-
use Mollie\Api\Resources\Chargeback;
|
| 8 |
-
use Mollie\Api\Resources\ChargebackCollection;
|
| 9 |
-
use Mollie\Api\Resources\Payment;
|
| 10 |
-
use Tests\Mollie\TestHelpers\AmountObjectTestHelpers;
|
| 11 |
-
use Tests\Mollie\TestHelpers\LinkObjectTestHelpers;
|
| 12 |
-
|
| 13 |
-
class PaymentChargebackEndpointTest extends BaseEndpointTest
|
| 14 |
-
{
|
| 15 |
-
use LinkObjectTestHelpers;
|
| 16 |
-
use AmountObjectTestHelpers;
|
| 17 |
-
|
| 18 |
-
public function testListChargebacksOnPaymentResource()
|
| 19 |
-
{
|
| 20 |
-
$this->mockApiCall(
|
| 21 |
-
new Request(
|
| 22 |
-
"GET",
|
| 23 |
-
"/v2/payments/tr_44aKxzEbr8/chargebacks"
|
| 24 |
-
),
|
| 25 |
-
new Response(
|
| 26 |
-
200,
|
| 27 |
-
[],
|
| 28 |
-
'{
|
| 29 |
-
"_embedded":{
|
| 30 |
-
"chargebacks":[
|
| 31 |
-
{
|
| 32 |
-
"resource":"chargeback",
|
| 33 |
-
"id":"chb_n9z0tp",
|
| 34 |
-
"amount":{
|
| 35 |
-
"value":"-13.00",
|
| 36 |
-
"currency":"EUR"
|
| 37 |
-
},
|
| 38 |
-
"createdAt":"2018-03-28T11:44:32+00:00",
|
| 39 |
-
"paymentId":"tr_44aKxzEbr8",
|
| 40 |
-
"settlementAmount":{
|
| 41 |
-
"value":"-13.00",
|
| 42 |
-
"currency":"EUR"
|
| 43 |
-
},
|
| 44 |
-
"_links":{
|
| 45 |
-
"self":{
|
| 46 |
-
"href":"https://api.mollie.com/v2/payments/tr_44aKxzEbr8/chargebacks/chb_n9z0tp",
|
| 47 |
-
"type":"application/hal+json"
|
| 48 |
-
},
|
| 49 |
-
"payment":{
|
| 50 |
-
"href":"https://api.mollie.com/v2/payments/tr_44aKxzEbr8",
|
| 51 |
-
"type":"application/hal+json"
|
| 52 |
-
},
|
| 53 |
-
"documentation": {
|
| 54 |
-
"href": "https://docs.mollie.com/reference/v2/chargebacks-api/get-chargeback",
|
| 55 |
-
"type": "text/html"
|
| 56 |
-
}
|
| 57 |
-
}
|
| 58 |
-
},
|
| 59 |
-
{
|
| 60 |
-
"resource":"chargeback",
|
| 61 |
-
"id":"chb_6cqlwf",
|
| 62 |
-
"amount":{
|
| 63 |
-
"value":"-0.37",
|
| 64 |
-
"currency":"EUR"
|
| 65 |
-
},
|
| 66 |
-
"createdAt":"2018-03-28T11:44:32+00:00",
|
| 67 |
-
"paymentId":"tr_44aKxzEbr8",
|
| 68 |
-
"settlementAmount":{
|
| 69 |
-
"value":"-0.37",
|
| 70 |
-
"currency":"EUR"
|
| 71 |
-
},
|
| 72 |
-
"_links":{
|
| 73 |
-
"self":{
|
| 74 |
-
"href":"https://api.mollie.com/v2/payments/tr_44aKxzEbr8/chargebacks/chb_6cqlwf",
|
| 75 |
-
"type":"application/hal+json"
|
| 76 |
-
},
|
| 77 |
-
"payment":{
|
| 78 |
-
"href":"https://api.mollie.com/v2/payments/tr_44aKxzEbr8",
|
| 79 |
-
"type":"application/hal+json"
|
| 80 |
-
},
|
| 81 |
-
"documentation": {
|
| 82 |
-
"href": "https://docs.mollie.com/reference/v2/chargebacks-api/get-chargeback",
|
| 83 |
-
"type": "text/html"
|
| 84 |
-
}
|
| 85 |
-
}
|
| 86 |
-
}
|
| 87 |
-
]
|
| 88 |
-
},
|
| 89 |
-
"_links":{
|
| 90 |
-
"documentation":{
|
| 91 |
-
"href":"https://docs.mollie.com/reference/v2/chargebacks-api/list-chargebacks",
|
| 92 |
-
"type":"text/html"
|
| 93 |
-
},
|
| 94 |
-
"self":{
|
| 95 |
-
"href":"https://api.mollie.com/v2/payments/tr_44aKxzEbr8/chargebacks",
|
| 96 |
-
"type":"application/hal+json"
|
| 97 |
-
}
|
| 98 |
-
},
|
| 99 |
-
"count": 2
|
| 100 |
-
}'
|
| 101 |
-
)
|
| 102 |
-
);
|
| 103 |
-
|
| 104 |
-
$chargebacks = $this->getPayment()->chargebacks();
|
| 105 |
-
|
| 106 |
-
$this->assertInstanceOf(ChargebackCollection::class, $chargebacks);
|
| 107 |
-
$this->assertEquals(2, $chargebacks->count);
|
| 108 |
-
$this->assertCount(2, $chargebacks);
|
| 109 |
-
|
| 110 |
-
$this->assertLinkObject(
|
| 111 |
-
"https://docs.mollie.com/reference/v2/chargebacks-api/list-chargebacks",
|
| 112 |
-
"text/html",
|
| 113 |
-
$chargebacks->_links->documentation
|
| 114 |
-
);
|
| 115 |
-
|
| 116 |
-
$this->assertLinkObject(
|
| 117 |
-
"https://api.mollie.com/v2/payments/tr_44aKxzEbr8/chargebacks",
|
| 118 |
-
"application/hal+json",
|
| 119 |
-
$chargebacks->_links->self
|
| 120 |
-
);
|
| 121 |
-
|
| 122 |
-
$this->assertChargeback($chargebacks[0], 'tr_44aKxzEbr8', 'chb_n9z0tp', "-13.00");
|
| 123 |
-
$this->assertChargeback($chargebacks[1], 'tr_44aKxzEbr8', 'chb_6cqlwf', "-0.37");
|
| 124 |
-
}
|
| 125 |
-
|
| 126 |
-
public function testGetChargebackOnPaymentResource()
|
| 127 |
-
{
|
| 128 |
-
$this->mockApiCall(
|
| 129 |
-
new Request(
|
| 130 |
-
"GET",
|
| 131 |
-
"/v2/payments/tr_44aKxzEbr8/chargebacks/chb_n9z0tp"
|
| 132 |
-
),
|
| 133 |
-
new Response(
|
| 134 |
-
200,
|
| 135 |
-
[],
|
| 136 |
-
'{
|
| 137 |
-
"resource":"chargeback",
|
| 138 |
-
"id":"chb_n9z0tp",
|
| 139 |
-
"amount":{
|
| 140 |
-
"value":"-13.00",
|
| 141 |
-
"currency":"EUR"
|
| 142 |
-
},
|
| 143 |
-
"createdAt":"2018-03-28T11:44:32+00:00",
|
| 144 |
-
"paymentId":"tr_44aKxzEbr8",
|
| 145 |
-
"settlementAmount":{
|
| 146 |
-
"value":"-13.00",
|
| 147 |
-
"currency":"EUR"
|
| 148 |
-
},
|
| 149 |
-
"_links":{
|
| 150 |
-
"self":{
|
| 151 |
-
"href":"https://api.mollie.com/v2/payments/tr_44aKxzEbr8/chargebacks/chb_n9z0tp",
|
| 152 |
-
"type":"application/hal+json"
|
| 153 |
-
},
|
| 154 |
-
"payment":{
|
| 155 |
-
"href":"https://api.mollie.com/v2/payments/tr_44aKxzEbr8",
|
| 156 |
-
"type":"application/hal+json"
|
| 157 |
-
},
|
| 158 |
-
"documentation": {
|
| 159 |
-
"href": "https://docs.mollie.com/reference/v2/chargebacks-api/get-chargeback",
|
| 160 |
-
"type": "text/html"
|
| 161 |
-
}
|
| 162 |
-
}
|
| 163 |
-
}'
|
| 164 |
-
)
|
| 165 |
-
);
|
| 166 |
-
|
| 167 |
-
$chargeback = $this->getPayment()->getChargeback("chb_n9z0tp");
|
| 168 |
-
|
| 169 |
-
$this->assertChargeback($chargeback, 'tr_44aKxzEbr8', 'chb_n9z0tp', "-13.00");
|
| 170 |
-
}
|
| 171 |
-
|
| 172 |
-
protected function assertChargeback($chargeback, $paymentId, $chargebackId, $amount)
|
| 173 |
-
{
|
| 174 |
-
$this->assertInstanceOf(Chargeback::class, $chargeback);
|
| 175 |
-
$this->assertEquals("chargeback", $chargeback->resource);
|
| 176 |
-
$this->assertEquals($chargebackId, $chargeback->id);
|
| 177 |
-
|
| 178 |
-
$this->assertAmountObject($amount, "EUR", $chargeback->amount);
|
| 179 |
-
$this->assertAmountObject($amount, "EUR", $chargeback->settlementAmount);
|
| 180 |
-
|
| 181 |
-
$this->assertEquals("2018-03-28T11:44:32+00:00", $chargeback->createdAt);
|
| 182 |
-
$this->assertEquals($paymentId, $chargeback->paymentId);
|
| 183 |
-
|
| 184 |
-
$this->assertLinkObject(
|
| 185 |
-
"https://api.mollie.com/v2/payments/{$paymentId}/chargebacks/{$chargebackId}",
|
| 186 |
-
"application/hal+json",
|
| 187 |
-
$chargeback->_links->self
|
| 188 |
-
);
|
| 189 |
-
|
| 190 |
-
$this->assertLinkObject(
|
| 191 |
-
"https://api.mollie.com/v2/payments/{$paymentId}",
|
| 192 |
-
"application/hal+json",
|
| 193 |
-
$chargeback->_links->payment
|
| 194 |
-
);
|
| 195 |
-
|
| 196 |
-
$this->assertLinkObject(
|
| 197 |
-
"https://docs.mollie.com/reference/v2/chargebacks-api/get-chargeback",
|
| 198 |
-
"text/html",
|
| 199 |
-
$chargeback->_links->documentation
|
| 200 |
-
);
|
| 201 |
-
}
|
| 202 |
-
|
| 203 |
-
/**
|
| 204 |
-
* @return Payment
|
| 205 |
-
*/
|
| 206 |
-
protected function getPayment()
|
| 207 |
-
{
|
| 208 |
-
$paymentJson = '{
|
| 209 |
-
"resource":"payment",
|
| 210 |
-
"id":"tr_44aKxzEbr8",
|
| 211 |
-
"mode":"test",
|
| 212 |
-
"createdAt":"2018-03-19T12:17:57+00:00",
|
| 213 |
-
"amount":{
|
| 214 |
-
"value":"20.00",
|
| 215 |
-
"currency":"EUR"
|
| 216 |
-
},
|
| 217 |
-
"description":"My first API payment",
|
| 218 |
-
"method":"ideal",
|
| 219 |
-
"metadata":{
|
| 220 |
-
"order_id":1234
|
| 221 |
-
},
|
| 222 |
-
"status":"paid",
|
| 223 |
-
"paidAt":"2018-03-19T12:18:35+00:00",
|
| 224 |
-
"amountRefunded":{
|
| 225 |
-
"value":"0.00",
|
| 226 |
-
"currency":"EUR"
|
| 227 |
-
},
|
| 228 |
-
"amountRemaining":{
|
| 229 |
-
"value":"20.00",
|
| 230 |
-
"currency":"EUR"
|
| 231 |
-
},
|
| 232 |
-
"details":{
|
| 233 |
-
"consumerName":"T. TEST",
|
| 234 |
-
"consumerAccount":"NL17RABO0213698412",
|
| 235 |
-
"consumerBic":"TESTNL99"
|
| 236 |
-
},
|
| 237 |
-
"locale":"nl_NL",
|
| 238 |
-
"countryCode":"NL",
|
| 239 |
-
"profileId":"pfl_2A1gacu42V",
|
| 240 |
-
"sequenceType":"oneoff",
|
| 241 |
-
"redirectUrl":"http://example.org/examples/03-return-page.php?order_id=1234",
|
| 242 |
-
"webhookUrl":"http://example.org/examples/02-webhook-verification.php",
|
| 243 |
-
"settlementAmount":{
|
| 244 |
-
"value":"20.00",
|
| 245 |
-
"currency":"EUR"
|
| 246 |
-
},
|
| 247 |
-
"_links":{
|
| 248 |
-
"self":{
|
| 249 |
-
"href":"https://api.mollie.com/v2/payments/tr_44aKxzEbr8",
|
| 250 |
-
"type":"application/hal+json"
|
| 251 |
-
},
|
| 252 |
-
"documentation":{
|
| 253 |
-
"href":"https://docs.mollie.com/reference/v2/payments-api/get-payment",
|
| 254 |
-
"type":"text/html"
|
| 255 |
-
},
|
| 256 |
-
"chargebacks":{
|
| 257 |
-
"href":"https://api.mollie.com/v2/payments/tr_44aKxzEbr8/chargebacks",
|
| 258 |
-
"type":"application/hal+json"
|
| 259 |
-
}
|
| 260 |
-
}
|
| 261 |
-
}';
|
| 262 |
-
|
| 263 |
-
return $this->copy(json_decode($paymentJson), new Payment($this->apiClient));
|
| 264 |
-
}
|
| 265 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Endpoints/PaymentEndpointTest.php
DELETED
|
@@ -1,381 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\Api\Endpoints;
|
| 4 |
-
|
| 5 |
-
use GuzzleHttp\Psr7\Request;
|
| 6 |
-
use GuzzleHttp\Psr7\Response;
|
| 7 |
-
use Mollie\Api\Resources\Payment;
|
| 8 |
-
use Mollie\Api\Resources\PaymentCollection;
|
| 9 |
-
use Mollie\Api\Types\PaymentStatus;
|
| 10 |
-
use Mollie\Api\Types\SequenceType;
|
| 11 |
-
use stdClass;
|
| 12 |
-
|
| 13 |
-
class PaymentEndpointTest extends BaseEndpointTest
|
| 14 |
-
{
|
| 15 |
-
public function testCreatePayment()
|
| 16 |
-
{
|
| 17 |
-
$this->mockApiCall(
|
| 18 |
-
new Request(
|
| 19 |
-
"POST",
|
| 20 |
-
"/v2/payments",
|
| 21 |
-
[],
|
| 22 |
-
'{
|
| 23 |
-
"amount":{
|
| 24 |
-
"value":"20.00",
|
| 25 |
-
"currency":"EUR"
|
| 26 |
-
},
|
| 27 |
-
"description": "My first API payment",
|
| 28 |
-
"redirectUrl": "https://example.org/redirect",
|
| 29 |
-
"webhookUrl": "https://example.org/webhook",
|
| 30 |
-
"metadata": {
|
| 31 |
-
"order_id": "1234"
|
| 32 |
-
}
|
| 33 |
-
}'
|
| 34 |
-
),
|
| 35 |
-
new Response(
|
| 36 |
-
201,
|
| 37 |
-
[],
|
| 38 |
-
'{
|
| 39 |
-
"resource":"payment",
|
| 40 |
-
"id":"tr_44aKxzEbr8",
|
| 41 |
-
"mode":"test",
|
| 42 |
-
"createdAt":"2018-03-13T14:02:29+00:00",
|
| 43 |
-
"amount":{
|
| 44 |
-
"value":"20.00",
|
| 45 |
-
"currency":"EUR"
|
| 46 |
-
},
|
| 47 |
-
"description":"My first API payment",
|
| 48 |
-
"method":null,
|
| 49 |
-
"metadata":{
|
| 50 |
-
"order_id":1234
|
| 51 |
-
},
|
| 52 |
-
"status":"open",
|
| 53 |
-
"isCancelable":false,
|
| 54 |
-
"expiresAt":"2018-03-13T14:17:29+00:00",
|
| 55 |
-
"details":null,
|
| 56 |
-
"profileId":"pfl_2A1gacu42V",
|
| 57 |
-
"sequenceType":"oneoff",
|
| 58 |
-
"redirectUrl":"http://example.org/examples/payment/03-return-page.php?order_id=1234",
|
| 59 |
-
"webhookUrl":"http://example.org/examples/payment/02-webhook-verification.php",
|
| 60 |
-
"_links":{
|
| 61 |
-
"self":{
|
| 62 |
-
"href":"https://api.mollie.com/v2/payments/tr_44aKxzEbr8",
|
| 63 |
-
"type":"application/hal+json"
|
| 64 |
-
},
|
| 65 |
-
"checkout":{
|
| 66 |
-
"href":"https://www.mollie.com/payscreen/select-method/44aKxzEbr8",
|
| 67 |
-
"type":"text/html"
|
| 68 |
-
},
|
| 69 |
-
"documentation":{
|
| 70 |
-
"href":"https://docs.mollie.com/reference/v2/payments-api/create-payment",
|
| 71 |
-
"type":"text/html"
|
| 72 |
-
}
|
| 73 |
-
}
|
| 74 |
-
}'
|
| 75 |
-
)
|
| 76 |
-
);
|
| 77 |
-
|
| 78 |
-
$payment = $this->apiClient->payments->create([
|
| 79 |
-
"amount" => [
|
| 80 |
-
"currency" => "EUR",
|
| 81 |
-
"value" => "20.00"
|
| 82 |
-
],
|
| 83 |
-
"description" => "My first API payment",
|
| 84 |
-
"redirectUrl" => "https://example.org/redirect",
|
| 85 |
-
"webhookUrl" => "https://example.org/webhook",
|
| 86 |
-
"metadata" => [
|
| 87 |
-
"order_id" => "1234",
|
| 88 |
-
],
|
| 89 |
-
]);
|
| 90 |
-
|
| 91 |
-
$this->assertInstanceOf(Payment::class, $payment);
|
| 92 |
-
$this->assertEquals('tr_44aKxzEbr8', $payment->id);
|
| 93 |
-
$this->assertEquals('test', $payment->mode);
|
| 94 |
-
$this->assertEquals("2018-03-13T14:02:29+00:00", $payment->createdAt);
|
| 95 |
-
|
| 96 |
-
$amount = new Stdclass();
|
| 97 |
-
$amount->value = '20.00';
|
| 98 |
-
$amount->currency = "EUR";
|
| 99 |
-
$this->assertEquals($amount, $payment->amount);
|
| 100 |
-
|
| 101 |
-
$this->assertEquals('My first API payment', $payment->description);
|
| 102 |
-
$this->assertNull($payment->method);
|
| 103 |
-
$this->assertEquals((object)["order_id" => "1234"], $payment->metadata);
|
| 104 |
-
$this->assertEquals(PaymentStatus::STATUS_OPEN, $payment->status);
|
| 105 |
-
$this->assertFalse($payment->isCancelable);
|
| 106 |
-
$this->assertEquals("2018-03-13T14:17:29+00:00", $payment->expiresAt);
|
| 107 |
-
$this->assertNull($payment->details);
|
| 108 |
-
$this->assertEquals("pfl_2A1gacu42V", $payment->profileId);
|
| 109 |
-
$this->assertEquals(SequenceType::SEQUENCETYPE_ONEOFF, $payment->sequenceType);
|
| 110 |
-
$this->assertEquals("http://example.org/examples/payment/03-return-page.php?order_id=1234", $payment->redirectUrl);
|
| 111 |
-
$this->assertEquals("http://example.org/examples/payment/02-webhook-verification.php", $payment->webhookUrl);
|
| 112 |
-
|
| 113 |
-
$selfLink = (object)["href" => "https://api.mollie.com/v2/payments/tr_44aKxzEbr8", "type" => "application/hal+json"];
|
| 114 |
-
$this->assertEquals($selfLink, $payment->_links->self);
|
| 115 |
-
|
| 116 |
-
$checkoutLink = (object)["href" => "https://www.mollie.com/payscreen/select-method/44aKxzEbr8", "type" => "text/html"];
|
| 117 |
-
$this->assertEquals($checkoutLink, $payment->_links->checkout);
|
| 118 |
-
|
| 119 |
-
$documentationLink = (object)["href" => "https://docs.mollie.com/reference/v2/payments-api/create-payment", "type" => "text/html"];
|
| 120 |
-
$this->assertEquals($documentationLink, $payment->_links->documentation);
|
| 121 |
-
}
|
| 122 |
-
|
| 123 |
-
public function testGetPayment()
|
| 124 |
-
{
|
| 125 |
-
$this->mockApiCall(
|
| 126 |
-
new Request(
|
| 127 |
-
"GET",
|
| 128 |
-
"/v2/payments/tr_44aKxzEbr8?testmode=true",
|
| 129 |
-
[],
|
| 130 |
-
''
|
| 131 |
-
),
|
| 132 |
-
new Response(
|
| 133 |
-
200,
|
| 134 |
-
[],
|
| 135 |
-
'{
|
| 136 |
-
"resource":"payment",
|
| 137 |
-
"id":"tr_44aKxzEbr8",
|
| 138 |
-
"mode":"test",
|
| 139 |
-
"createdAt":"2018-03-13T14:02:29+00:00",
|
| 140 |
-
"amount":{
|
| 141 |
-
"value":"20.00",
|
| 142 |
-
"currency":"EUR"
|
| 143 |
-
},
|
| 144 |
-
"description":"My first API payment",
|
| 145 |
-
"method":"ideal",
|
| 146 |
-
"metadata":{
|
| 147 |
-
"order_id":1234
|
| 148 |
-
},
|
| 149 |
-
"status":"paid",
|
| 150 |
-
"paidAt":"2018-03-19T12:18:35+00:00",
|
| 151 |
-
"amountRefunded":{
|
| 152 |
-
"value":"0.00",
|
| 153 |
-
"currency":"EUR"
|
| 154 |
-
},
|
| 155 |
-
"amountRemaining":{
|
| 156 |
-
"value":"20.00",
|
| 157 |
-
"currency":"EUR"
|
| 158 |
-
},
|
| 159 |
-
"details":{
|
| 160 |
-
"consumerName":"T. TEST",
|
| 161 |
-
"consumerAccount":"NL17RABO0213698412",
|
| 162 |
-
"consumerBic":"TESTNL99"
|
| 163 |
-
},
|
| 164 |
-
"locale":"nl_NL",
|
| 165 |
-
"countryCode":"NL",
|
| 166 |
-
"profileId":"pfl_2A1gacu42V",
|
| 167 |
-
"sequenceType":"oneoff",
|
| 168 |
-
"redirectUrl":"http://example.org/examples/03-return-page.php?order_id=1234",
|
| 169 |
-
"webhookUrl":"http://example.org/examples/02-webhook-verification.php",
|
| 170 |
-
"settlementAmount":{
|
| 171 |
-
"value":"20.00",
|
| 172 |
-
"currency":"EUR"
|
| 173 |
-
},
|
| 174 |
-
"_links":{
|
| 175 |
-
"self":{
|
| 176 |
-
"href":"https://api.mollie.com/v2/payments/tr_44aKxzEbr8",
|
| 177 |
-
"type":"application/hal+json"
|
| 178 |
-
},
|
| 179 |
-
"documentation":{
|
| 180 |
-
"href":"https://docs.mollie.com/reference/v2/payments-api/get-payment",
|
| 181 |
-
"type":"text/html"
|
| 182 |
-
}
|
| 183 |
-
}
|
| 184 |
-
}'
|
| 185 |
-
)
|
| 186 |
-
);
|
| 187 |
-
|
| 188 |
-
$payment = $this->apiClient->payments->get("tr_44aKxzEbr8", ["testmode" => true]);
|
| 189 |
-
|
| 190 |
-
$this->assertInstanceOf(Payment::class, $payment);
|
| 191 |
-
$this->assertEquals('tr_44aKxzEbr8', $payment->id);
|
| 192 |
-
$this->assertEquals('test', $payment->mode);
|
| 193 |
-
$this->assertEquals("2018-03-13T14:02:29+00:00", $payment->createdAt);
|
| 194 |
-
|
| 195 |
-
$amount = new Stdclass();
|
| 196 |
-
$amount->value = '20.00';
|
| 197 |
-
$amount->currency = "EUR";
|
| 198 |
-
$this->assertEquals($amount, $payment->amount);
|
| 199 |
-
|
| 200 |
-
$this->assertEquals('My first API payment', $payment->description);
|
| 201 |
-
$this->assertEquals("ideal", $payment->method);
|
| 202 |
-
$this->assertEquals((object)["order_id" => "1234"], $payment->metadata);
|
| 203 |
-
$this->assertEquals(PaymentStatus::STATUS_PAID, $payment->status);
|
| 204 |
-
|
| 205 |
-
$amountRefunded = new Stdclass();
|
| 206 |
-
$amountRefunded->value = '0.00';
|
| 207 |
-
$amountRefunded->currency = "EUR";
|
| 208 |
-
$this->assertEquals($amountRefunded, $payment->amountRefunded);
|
| 209 |
-
|
| 210 |
-
$amountRemaining = new Stdclass();
|
| 211 |
-
$amountRemaining->value = '20.00';
|
| 212 |
-
$amountRemaining->currency = "EUR";
|
| 213 |
-
$this->assertEquals($amountRemaining, $payment->amountRemaining);
|
| 214 |
-
|
| 215 |
-
$details = (object)[
|
| 216 |
-
'consumerName' => 'T. TEST',
|
| 217 |
-
'consumerAccount' => 'NL17RABO0213698412',
|
| 218 |
-
'consumerBic' => 'TESTNL99'
|
| 219 |
-
];
|
| 220 |
-
|
| 221 |
-
$this->assertEquals($details, $payment->details);
|
| 222 |
-
$this->assertEquals("pfl_2A1gacu42V", $payment->profileId);
|
| 223 |
-
$this->assertEquals(SequenceType::SEQUENCETYPE_ONEOFF, $payment->sequenceType);
|
| 224 |
-
$this->assertEquals("http://example.org/examples/03-return-page.php?order_id=1234", $payment->redirectUrl);
|
| 225 |
-
$this->assertEquals("http://example.org/examples/02-webhook-verification.php", $payment->webhookUrl);
|
| 226 |
-
|
| 227 |
-
$selfLink = (object)["href" => "https://api.mollie.com/v2/payments/tr_44aKxzEbr8", "type" => "application/hal+json"];
|
| 228 |
-
$this->assertEquals($selfLink, $payment->_links->self);
|
| 229 |
-
|
| 230 |
-
$documentationLink = (object)["href" => "https://docs.mollie.com/reference/v2/payments-api/get-payment", "type" => "text/html"];
|
| 231 |
-
$this->assertEquals($documentationLink, $payment->_links->documentation);
|
| 232 |
-
}
|
| 233 |
-
|
| 234 |
-
public function testListPayment()
|
| 235 |
-
{
|
| 236 |
-
$this->mockApiCall(
|
| 237 |
-
new Request(
|
| 238 |
-
"GET",
|
| 239 |
-
"/v2/payments?limit=3",
|
| 240 |
-
[],
|
| 241 |
-
''
|
| 242 |
-
),
|
| 243 |
-
new Response(
|
| 244 |
-
200,
|
| 245 |
-
[],
|
| 246 |
-
'{
|
| 247 |
-
"_embedded": {
|
| 248 |
-
"payments": [
|
| 249 |
-
{
|
| 250 |
-
"resource": "payment",
|
| 251 |
-
"id": "tr_admNa2tFfa",
|
| 252 |
-
"mode": "test",
|
| 253 |
-
"createdAt": "2018-03-19T15:00:50+00:00",
|
| 254 |
-
"amount": {
|
| 255 |
-
"value": "100.00",
|
| 256 |
-
"currency": "EUR"
|
| 257 |
-
},
|
| 258 |
-
"description": "Payment no 1",
|
| 259 |
-
"method": null,
|
| 260 |
-
"metadata": null,
|
| 261 |
-
"status": "open",
|
| 262 |
-
"isCancelable": false,
|
| 263 |
-
"expiresAt": "2018-03-19T15:15:50+00:00",
|
| 264 |
-
"details": null,
|
| 265 |
-
"locale": "nl_NL",
|
| 266 |
-
"profileId": "pfl_7N5qjbu42V",
|
| 267 |
-
"sequenceType": "oneoff",
|
| 268 |
-
"redirectUrl": "https://www.example.org/",
|
| 269 |
-
"_links": {
|
| 270 |
-
"self": {
|
| 271 |
-
"href": "https://api.mollie.com/v2/payments/tr_admNa2tFfa",
|
| 272 |
-
"type": "application/hal+json"
|
| 273 |
-
},
|
| 274 |
-
"checkout": {
|
| 275 |
-
"href": "https://www.mollie.com/payscreen/select-method/admNa2tFfa",
|
| 276 |
-
"type": "text/html"
|
| 277 |
-
}
|
| 278 |
-
}
|
| 279 |
-
},
|
| 280 |
-
{
|
| 281 |
-
"resource": "payment",
|
| 282 |
-
"id": "tr_bcaLc7hFfa",
|
| 283 |
-
"mode": "test",
|
| 284 |
-
"createdAt": "2018-03-19T15:00:50+00:00",
|
| 285 |
-
"amount": {
|
| 286 |
-
"value": "100.00",
|
| 287 |
-
"currency": "EUR"
|
| 288 |
-
},
|
| 289 |
-
"description": "Payment no 2",
|
| 290 |
-
"method": null,
|
| 291 |
-
"metadata": null,
|
| 292 |
-
"status": "open",
|
| 293 |
-
"isCancelable": false,
|
| 294 |
-
"expiresAt": "2018-03-19T15:15:50+00:00",
|
| 295 |
-
"details": null,
|
| 296 |
-
"locale": "nl_NL",
|
| 297 |
-
"profileId": "pfl_7N5qjbu42V",
|
| 298 |
-
"sequenceType": "oneoff",
|
| 299 |
-
"redirectUrl": "https://www.example.org/",
|
| 300 |
-
"_links": {
|
| 301 |
-
"self": {
|
| 302 |
-
"href": "https://api.mollie.com/v2/payments/tr_bcaLc7hFfa",
|
| 303 |
-
"type": "application/hal+json"
|
| 304 |
-
},
|
| 305 |
-
"checkout": {
|
| 306 |
-
"href": "https://www.mollie.com/payscreen/select-method/bcaLc7hFfa",
|
| 307 |
-
"type": "text/html"
|
| 308 |
-
}
|
| 309 |
-
}
|
| 310 |
-
},
|
| 311 |
-
{
|
| 312 |
-
"resource": "payment",
|
| 313 |
-
"id": "tr_pslHy1tFfa",
|
| 314 |
-
"mode": "test",
|
| 315 |
-
"createdAt": "2018-03-19T15:00:50+00:00",
|
| 316 |
-
"amount": {
|
| 317 |
-
"value": "100.00",
|
| 318 |
-
"currency": "EUR"
|
| 319 |
-
},
|
| 320 |
-
"description": "Payment no 3",
|
| 321 |
-
"method": null,
|
| 322 |
-
"metadata": null,
|
| 323 |
-
"status": "open",
|
| 324 |
-
"isCancelable": false,
|
| 325 |
-
"expiresAt": "2018-03-19T15:15:50+00:00",
|
| 326 |
-
"details": null,
|
| 327 |
-
"locale": "nl_NL",
|
| 328 |
-
"profileId": "pfl_7N5qjbu42V",
|
| 329 |
-
"sequenceType": "oneoff",
|
| 330 |
-
"redirectUrl": "https://www.example.org/",
|
| 331 |
-
"_links": {
|
| 332 |
-
"self": {
|
| 333 |
-
"href": "https://api.mollie.com/v2/payments/tr_pslHy1tFfa",
|
| 334 |
-
"type": "application/hal+json"
|
| 335 |
-
},
|
| 336 |
-
"checkout": {
|
| 337 |
-
"href": "https://www.mollie.com/payscreen/select-method/pslHy1tFfa",
|
| 338 |
-
"type": "text/html"
|
| 339 |
-
}
|
| 340 |
-
}
|
| 341 |
-
}
|
| 342 |
-
]
|
| 343 |
-
},
|
| 344 |
-
"_links": {
|
| 345 |
-
"documentation": {
|
| 346 |
-
"href": "https://docs.mollie.com/reference/v2/payments-api/list-payments",
|
| 347 |
-
"type": "text/html"
|
| 348 |
-
},
|
| 349 |
-
"self": {
|
| 350 |
-
"href": "http://api.mollie.com/v2/payments?limit=3",
|
| 351 |
-
"type": "application/hal+json"
|
| 352 |
-
},
|
| 353 |
-
"previous": null,
|
| 354 |
-
"next": {
|
| 355 |
-
"href": "http://api.mollie.com/v2/payments?from=tr_eW8f5kzUkF&limit=3",
|
| 356 |
-
"type": "application/hal+json"
|
| 357 |
-
}
|
| 358 |
-
},
|
| 359 |
-
"count": 3
|
| 360 |
-
}'
|
| 361 |
-
)
|
| 362 |
-
);
|
| 363 |
-
|
| 364 |
-
$payments = $this->apiClient->payments->page(null, 3);
|
| 365 |
-
|
| 366 |
-
$this->assertInstanceOf(PaymentCollection::class, $payments);
|
| 367 |
-
$this->assertEquals(3, $payments->count);
|
| 368 |
-
$this->assertEquals(3, count($payments));
|
| 369 |
-
|
| 370 |
-
$documentationLink = (object)["href" => "https://docs.mollie.com/reference/v2/payments-api/list-payments", "type" => "text/html"];
|
| 371 |
-
$this->assertEquals($documentationLink, $payments->_links->documentation);
|
| 372 |
-
|
| 373 |
-
$selfLink = (object)["href" => "http://api.mollie.com/v2/payments?limit=3", "type" => "application/hal+json"];
|
| 374 |
-
$this->assertEquals($selfLink, $payments->_links->self);
|
| 375 |
-
|
| 376 |
-
$this->assertNull($payments->_links->previous);
|
| 377 |
-
|
| 378 |
-
$nextLink = (object)["href" => "http://api.mollie.com/v2/payments?from=tr_eW8f5kzUkF&limit=3", "type" => "application/hal+json"];
|
| 379 |
-
$this->assertEquals($nextLink, $payments->_links->next);
|
| 380 |
-
}
|
| 381 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Endpoints/PaymentRefundEndpointTest.php
DELETED
|
@@ -1,388 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\Api\Endpoints;
|
| 4 |
-
|
| 5 |
-
use GuzzleHttp\Psr7\Request;
|
| 6 |
-
use GuzzleHttp\Psr7\Response;
|
| 7 |
-
use Mollie\Api\Resources\Payment;
|
| 8 |
-
use Mollie\Api\Resources\Refund;
|
| 9 |
-
use Mollie\Api\Resources\RefundCollection;
|
| 10 |
-
use stdClass;
|
| 11 |
-
|
| 12 |
-
class PaymentRefundEndpointTest extends BaseEndpointTest
|
| 13 |
-
{
|
| 14 |
-
public function testGetRefundForPaymentResource()
|
| 15 |
-
{
|
| 16 |
-
$this->mockApiCall(
|
| 17 |
-
new Request(
|
| 18 |
-
"GET",
|
| 19 |
-
"/v2/payments/tr_44aKxzEbr8/refunds/re_PsAvxvLsnm"
|
| 20 |
-
),
|
| 21 |
-
new Response(
|
| 22 |
-
201,
|
| 23 |
-
[],
|
| 24 |
-
'{
|
| 25 |
-
"resource":"refund",
|
| 26 |
-
"id":"re_PsAvxvLsnm",
|
| 27 |
-
"amount":{
|
| 28 |
-
"value":"20.00",
|
| 29 |
-
"currency":"EUR"
|
| 30 |
-
},
|
| 31 |
-
"status":"pending",
|
| 32 |
-
"createdAt":"2018-03-19T12:33:37+00:00",
|
| 33 |
-
"description":"My first API payment",
|
| 34 |
-
"paymentId":"tr_44aKxzEbr8",
|
| 35 |
-
"settlementAmount":{
|
| 36 |
-
"value":"-20.00",
|
| 37 |
-
"currency":"EUR"
|
| 38 |
-
},
|
| 39 |
-
"_links":{
|
| 40 |
-
"self":{
|
| 41 |
-
"href":"https://api.mollie.com/v2/payments/tr_Tgxm3amJBT/refunds/re_PmEtpvSsnm",
|
| 42 |
-
"type":"application/hal+json"
|
| 43 |
-
},
|
| 44 |
-
"payment":{
|
| 45 |
-
"href":"https://api.mollie.com/v2/payments/tr_44aKxzEbr8",
|
| 46 |
-
"type":"application/hal+json"
|
| 47 |
-
},
|
| 48 |
-
"documentation":{
|
| 49 |
-
"href":"https://docs.mollie.com/reference/v2/refunds-api/create-refund",
|
| 50 |
-
"type":"text/html"
|
| 51 |
-
}
|
| 52 |
-
}
|
| 53 |
-
}'
|
| 54 |
-
)
|
| 55 |
-
);
|
| 56 |
-
|
| 57 |
-
$refund = $this->apiClient->paymentRefunds->getFor($this->getPayment(), "re_PsAvxvLsnm");
|
| 58 |
-
|
| 59 |
-
$this->assertInstanceOf(Refund::class, $refund);
|
| 60 |
-
$this->assertEquals("re_PsAvxvLsnm", $refund->id);
|
| 61 |
-
|
| 62 |
-
$amount = new Stdclass();
|
| 63 |
-
$amount->value = '20.00';
|
| 64 |
-
$amount->currency = "EUR";
|
| 65 |
-
$this->assertEquals($amount, $refund->amount);
|
| 66 |
-
|
| 67 |
-
$this->assertEquals("pending", $refund->status);
|
| 68 |
-
$this->assertEquals("2018-03-19T12:33:37+00:00", $refund->createdAt);
|
| 69 |
-
$this->assertEquals("My first API payment", $refund->description);
|
| 70 |
-
$this->assertEquals("tr_44aKxzEbr8", $refund->paymentId);
|
| 71 |
-
|
| 72 |
-
$amount = new Stdclass();
|
| 73 |
-
$amount->value = '-20.00';
|
| 74 |
-
$amount->currency = "EUR";
|
| 75 |
-
$this->assertEquals($amount, $refund->settlementAmount);
|
| 76 |
-
|
| 77 |
-
$selfLink = (object)["href" => "https://api.mollie.com/v2/payments/tr_Tgxm3amJBT/refunds/re_PmEtpvSsnm", "type" => "application/hal+json"];
|
| 78 |
-
$this->assertEquals($selfLink, $refund->_links->self);
|
| 79 |
-
|
| 80 |
-
$paymentLink = (object)["href" => "https://api.mollie.com/v2/payments/tr_44aKxzEbr8", "type" => "application/hal+json"];
|
| 81 |
-
$this->assertEquals($paymentLink, $refund->_links->payment);
|
| 82 |
-
|
| 83 |
-
$documentationLink = (object)["href" => "https://docs.mollie.com/reference/v2/refunds-api/create-refund", "type" => "text/html"];
|
| 84 |
-
$this->assertEquals($documentationLink, $refund->_links->documentation);
|
| 85 |
-
}
|
| 86 |
-
|
| 87 |
-
public function testGetRefundOnPaymentResource()
|
| 88 |
-
{
|
| 89 |
-
$this->mockApiCall(
|
| 90 |
-
new Request(
|
| 91 |
-
"GET",
|
| 92 |
-
"/v2/payments/tr_44aKxzEbr8/refunds/re_PsAvxvLsnm"
|
| 93 |
-
),
|
| 94 |
-
new Response(
|
| 95 |
-
201,
|
| 96 |
-
[],
|
| 97 |
-
'{
|
| 98 |
-
"resource":"refund",
|
| 99 |
-
"id":"re_PsAvxvLsnm",
|
| 100 |
-
"amount":{
|
| 101 |
-
"value":"20.00",
|
| 102 |
-
"currency":"EUR"
|
| 103 |
-
},
|
| 104 |
-
"status":"pending",
|
| 105 |
-
"createdAt":"2018-03-19T12:33:37+00:00",
|
| 106 |
-
"description":"My first API payment",
|
| 107 |
-
"paymentId":"tr_44aKxzEbr8",
|
| 108 |
-
"settlementAmount":{
|
| 109 |
-
"value":"-20.00",
|
| 110 |
-
"currency":"EUR"
|
| 111 |
-
},
|
| 112 |
-
"_links":{
|
| 113 |
-
"self":{
|
| 114 |
-
"href":"https://api.mollie.com/v2/payments/tr_Tgxm3amJBT/refunds/re_PmEtpvSsnm",
|
| 115 |
-
"type":"application/hal+json"
|
| 116 |
-
},
|
| 117 |
-
"payment":{
|
| 118 |
-
"href":"https://api.mollie.com/v2/payments/tr_44aKxzEbr8",
|
| 119 |
-
"type":"application/hal+json"
|
| 120 |
-
},
|
| 121 |
-
"documentation":{
|
| 122 |
-
"href":"https://docs.mollie.com/reference/v2/refunds-api/create-refund",
|
| 123 |
-
"type":"text/html"
|
| 124 |
-
}
|
| 125 |
-
}
|
| 126 |
-
}'
|
| 127 |
-
)
|
| 128 |
-
);
|
| 129 |
-
|
| 130 |
-
$refund = $this->getPayment("tr_44aKxzEbr8")->getRefund("re_PsAvxvLsnm");
|
| 131 |
-
|
| 132 |
-
$this->assertInstanceOf(Refund::class, $refund);
|
| 133 |
-
$this->assertEquals("re_PsAvxvLsnm", $refund->id);
|
| 134 |
-
|
| 135 |
-
$amount = new Stdclass();
|
| 136 |
-
$amount->value = '20.00';
|
| 137 |
-
$amount->currency = "EUR";
|
| 138 |
-
$this->assertEquals($amount, $refund->amount);
|
| 139 |
-
|
| 140 |
-
$this->assertEquals("pending", $refund->status);
|
| 141 |
-
$this->assertEquals("2018-03-19T12:33:37+00:00", $refund->createdAt);
|
| 142 |
-
$this->assertEquals("My first API payment", $refund->description);
|
| 143 |
-
$this->assertEquals("tr_44aKxzEbr8", $refund->paymentId);
|
| 144 |
-
|
| 145 |
-
$amount = new Stdclass();
|
| 146 |
-
$amount->value = '-20.00';
|
| 147 |
-
$amount->currency = "EUR";
|
| 148 |
-
$this->assertEquals($amount, $refund->settlementAmount);
|
| 149 |
-
|
| 150 |
-
$selfLink = (object)["href" => "https://api.mollie.com/v2/payments/tr_Tgxm3amJBT/refunds/re_PmEtpvSsnm", "type" => "application/hal+json"];
|
| 151 |
-
$this->assertEquals($selfLink, $refund->_links->self);
|
| 152 |
-
|
| 153 |
-
$paymentLink = (object)["href" => "https://api.mollie.com/v2/payments/tr_44aKxzEbr8", "type" => "application/hal+json"];
|
| 154 |
-
$this->assertEquals($paymentLink, $refund->_links->payment);
|
| 155 |
-
|
| 156 |
-
$documentationLink = (object)["href" => "https://docs.mollie.com/reference/v2/refunds-api/create-refund", "type" => "text/html"];
|
| 157 |
-
$this->assertEquals($documentationLink, $refund->_links->documentation);
|
| 158 |
-
}
|
| 159 |
-
|
| 160 |
-
public function testCreateRefund()
|
| 161 |
-
{
|
| 162 |
-
$this->mockApiCall(
|
| 163 |
-
new Request(
|
| 164 |
-
"POST",
|
| 165 |
-
"/v2/payments/tr_44aKxzEbr8/refunds",
|
| 166 |
-
[],
|
| 167 |
-
'{"amount":{"currency":"EUR","value":"20.00"}}'
|
| 168 |
-
),
|
| 169 |
-
new Response(
|
| 170 |
-
201,
|
| 171 |
-
[],
|
| 172 |
-
'{
|
| 173 |
-
"resource":"refund",
|
| 174 |
-
"id":"re_PsAvxvLsnm",
|
| 175 |
-
"amount":{
|
| 176 |
-
"value":"20.00",
|
| 177 |
-
"currency":"EUR"
|
| 178 |
-
},
|
| 179 |
-
"status":"pending",
|
| 180 |
-
"createdAt":"2018-03-19T12:33:37+00:00",
|
| 181 |
-
"description":"My first API payment",
|
| 182 |
-
"paymentId":"tr_44aKxzEbr8",
|
| 183 |
-
"settlementAmount":{
|
| 184 |
-
"value":"-20.00",
|
| 185 |
-
"currency":"EUR"
|
| 186 |
-
},
|
| 187 |
-
"_links":{
|
| 188 |
-
"self":{
|
| 189 |
-
"href":"https://api.mollie.com/v2/payments/tr_Tgxm3amJBT/refunds/re_PmEtpvSsnm",
|
| 190 |
-
"type":"application/hal+json"
|
| 191 |
-
},
|
| 192 |
-
"payment":{
|
| 193 |
-
"href":"https://api.mollie.com/v2/payments/tr_44aKxzEbr8",
|
| 194 |
-
"type":"application/hal+json"
|
| 195 |
-
},
|
| 196 |
-
"documentation":{
|
| 197 |
-
"href":"https://docs.mollie.com/reference/v2/refunds-api/create-refund",
|
| 198 |
-
"type":"text/html"
|
| 199 |
-
}
|
| 200 |
-
}
|
| 201 |
-
}'
|
| 202 |
-
)
|
| 203 |
-
);
|
| 204 |
-
|
| 205 |
-
$refund = $this->getPayment()->refund([
|
| 206 |
-
"amount" => [
|
| 207 |
-
"currency" => "EUR",
|
| 208 |
-
"value" => "20.00"
|
| 209 |
-
]
|
| 210 |
-
]);
|
| 211 |
-
|
| 212 |
-
$this->assertInstanceOf(Refund::class, $refund);
|
| 213 |
-
$this->assertEquals("re_PsAvxvLsnm", $refund->id);
|
| 214 |
-
|
| 215 |
-
$amount = new Stdclass();
|
| 216 |
-
$amount->value = '20.00';
|
| 217 |
-
$amount->currency = "EUR";
|
| 218 |
-
$this->assertEquals($amount, $refund->amount);
|
| 219 |
-
|
| 220 |
-
$this->assertEquals("pending", $refund->status);
|
| 221 |
-
$this->assertEquals("2018-03-19T12:33:37+00:00", $refund->createdAt);
|
| 222 |
-
$this->assertEquals("My first API payment", $refund->description);
|
| 223 |
-
$this->assertEquals("tr_44aKxzEbr8", $refund->paymentId);
|
| 224 |
-
|
| 225 |
-
$amount = new Stdclass();
|
| 226 |
-
$amount->value = '-20.00';
|
| 227 |
-
$amount->currency = "EUR";
|
| 228 |
-
$this->assertEquals($amount, $refund->settlementAmount);
|
| 229 |
-
|
| 230 |
-
$selfLink = (object)["href" => "https://api.mollie.com/v2/payments/tr_Tgxm3amJBT/refunds/re_PmEtpvSsnm", "type" => "application/hal+json"];
|
| 231 |
-
$this->assertEquals($selfLink, $refund->_links->self);
|
| 232 |
-
|
| 233 |
-
$paymentLink = (object)["href" => "https://api.mollie.com/v2/payments/tr_44aKxzEbr8", "type" => "application/hal+json"];
|
| 234 |
-
$this->assertEquals($paymentLink, $refund->_links->payment);
|
| 235 |
-
|
| 236 |
-
$documentationLink = (object)["href" => "https://docs.mollie.com/reference/v2/refunds-api/create-refund", "type" => "text/html"];
|
| 237 |
-
$this->assertEquals($documentationLink, $refund->_links->documentation);
|
| 238 |
-
}
|
| 239 |
-
|
| 240 |
-
public function testGetRefundsOnPaymentResource()
|
| 241 |
-
{
|
| 242 |
-
$this->mockApiCall(
|
| 243 |
-
new Request(
|
| 244 |
-
"GET",
|
| 245 |
-
"/v2/payments/tr_44aKxzEbr8/refunds",
|
| 246 |
-
[],
|
| 247 |
-
''
|
| 248 |
-
),
|
| 249 |
-
new Response(
|
| 250 |
-
201,
|
| 251 |
-
[],
|
| 252 |
-
'{
|
| 253 |
-
"_embedded": {
|
| 254 |
-
"refunds": [
|
| 255 |
-
{
|
| 256 |
-
"resource": "refund",
|
| 257 |
-
"id": "re_haCsig5aru",
|
| 258 |
-
"amount": {
|
| 259 |
-
"value": "2.00",
|
| 260 |
-
"currency": "EUR"
|
| 261 |
-
},
|
| 262 |
-
"status": "pending",
|
| 263 |
-
"createdAt": "2018-03-28T10:56:10+00:00",
|
| 264 |
-
"description": "My first API payment",
|
| 265 |
-
"paymentId": "tr_44aKxzEbr8",
|
| 266 |
-
"settlementAmount": {
|
| 267 |
-
"value": "-2.00",
|
| 268 |
-
"currency": "EUR"
|
| 269 |
-
},
|
| 270 |
-
"_links": {
|
| 271 |
-
"self": {
|
| 272 |
-
"href": "https://api.mollie.com/v2/payments/tr_44aKxzEbr8/refunds/re_haCsig5aru",
|
| 273 |
-
"type": "application/hal+json"
|
| 274 |
-
},
|
| 275 |
-
"payment": {
|
| 276 |
-
"href": "https://api.mollie.com/v2/payments/tr_44aKxzEbr8",
|
| 277 |
-
"type": "application/hal+json"
|
| 278 |
-
}
|
| 279 |
-
}
|
| 280 |
-
}
|
| 281 |
-
]
|
| 282 |
-
},
|
| 283 |
-
"_links": {
|
| 284 |
-
"documentation": {
|
| 285 |
-
"href": "https://docs.mollie.com/reference/v2/refunds-api/list-refunds",
|
| 286 |
-
"type": "text/html"
|
| 287 |
-
},
|
| 288 |
-
"self": {
|
| 289 |
-
"href": "http://api.mollie.nl/v2/payments/tr_44aKxzEbr8/refunds?limit=10",
|
| 290 |
-
"type": "application/hal+json"
|
| 291 |
-
},
|
| 292 |
-
"previous": null,
|
| 293 |
-
"next": null
|
| 294 |
-
},
|
| 295 |
-
"count": 1
|
| 296 |
-
}'
|
| 297 |
-
)
|
| 298 |
-
);
|
| 299 |
-
|
| 300 |
-
$refunds = $this->getPayment()->refunds();
|
| 301 |
-
|
| 302 |
-
$this->assertInstanceOf(RefundCollection::class, $refunds);
|
| 303 |
-
$this->assertEquals(1, $refunds->count);
|
| 304 |
-
$this->assertCount(1, $refunds);
|
| 305 |
-
|
| 306 |
-
$refund = $refunds[0];
|
| 307 |
-
|
| 308 |
-
$this->assertInstanceOf(Refund::class, $refund);
|
| 309 |
-
$this->assertEquals("re_haCsig5aru", $refund->id);
|
| 310 |
-
$this->assertEquals("2.00", $refund->amount->value);
|
| 311 |
-
$this->assertEquals("EUR", $refund->amount->currency);
|
| 312 |
-
$this->assertEquals("pending", $refund->status);
|
| 313 |
-
$this->assertEquals("2018-03-28T10:56:10+00:00", $refund->createdAt);
|
| 314 |
-
$this->assertEquals("My first API payment", $refund->description);
|
| 315 |
-
$this->assertEquals("tr_44aKxzEbr8", $refund->paymentId);
|
| 316 |
-
$this->assertEquals("-2.00", $refund->settlementAmount->value);
|
| 317 |
-
$this->assertEquals("EUR", $refund->settlementAmount->currency);
|
| 318 |
-
|
| 319 |
-
$selfLink = (object)["href" => "https://api.mollie.com/v2/payments/tr_44aKxzEbr8/refunds/re_haCsig5aru", "type" => "application/hal+json"];
|
| 320 |
-
$this->assertEquals($selfLink, $refund->_links->self);
|
| 321 |
-
|
| 322 |
-
$paymentLink = (object)["href" => "https://api.mollie.com/v2/payments/tr_44aKxzEbr8", "type" => "application/hal+json"];
|
| 323 |
-
$this->assertEquals($paymentLink, $refund->_links->payment);
|
| 324 |
-
}
|
| 325 |
-
|
| 326 |
-
/**
|
| 327 |
-
* @return Payment
|
| 328 |
-
*/
|
| 329 |
-
private function getPayment()
|
| 330 |
-
{
|
| 331 |
-
$paymentJson = '{
|
| 332 |
-
"resource":"payment",
|
| 333 |
-
"id":"tr_44aKxzEbr8",
|
| 334 |
-
"mode":"test",
|
| 335 |
-
"createdAt":"2018-03-19T12:17:57+00:00",
|
| 336 |
-
"amount":{
|
| 337 |
-
"value":"20.00",
|
| 338 |
-
"currency":"EUR"
|
| 339 |
-
},
|
| 340 |
-
"description":"My first API payment",
|
| 341 |
-
"method":"ideal",
|
| 342 |
-
"metadata":{
|
| 343 |
-
"order_id":1234
|
| 344 |
-
},
|
| 345 |
-
"status":"paid",
|
| 346 |
-
"paidAt":"2018-03-19T12:18:35+00:00",
|
| 347 |
-
"amountRefunded":{
|
| 348 |
-
"value":"0.00",
|
| 349 |
-
"currency":"EUR"
|
| 350 |
-
},
|
| 351 |
-
"amountRemaining":{
|
| 352 |
-
"value":"20.00",
|
| 353 |
-
"currency":"EUR"
|
| 354 |
-
},
|
| 355 |
-
"details":{
|
| 356 |
-
"consumerName":"T. TEST",
|
| 357 |
-
"consumerAccount":"NL17RABO0213698412",
|
| 358 |
-
"consumerBic":"TESTNL99"
|
| 359 |
-
},
|
| 360 |
-
"locale":"nl_NL",
|
| 361 |
-
"countryCode":"NL",
|
| 362 |
-
"profileId":"pfl_2A1gacu42V",
|
| 363 |
-
"sequenceType":"oneoff",
|
| 364 |
-
"redirectUrl":"http://example.org/examples/03-return-page.php?order_id=1234",
|
| 365 |
-
"webhookUrl":"http://example.org/examples/02-webhook-verification.php",
|
| 366 |
-
"settlementAmount":{
|
| 367 |
-
"value":"20.00",
|
| 368 |
-
"currency":"EUR"
|
| 369 |
-
},
|
| 370 |
-
"_links":{
|
| 371 |
-
"self":{
|
| 372 |
-
"href":"https://api.mollie.com/v2/payments/tr_44aKxzEbr8",
|
| 373 |
-
"type":"application/hal+json"
|
| 374 |
-
},
|
| 375 |
-
"documentation":{
|
| 376 |
-
"href":"https://docs.mollie.com/reference/v2/payments-api/get-payment",
|
| 377 |
-
"type":"text/html"
|
| 378 |
-
},
|
| 379 |
-
"refunds":{
|
| 380 |
-
"href":"https://api.mollie.com/v2/payments/tr_44aKxzEbr8/refunds",
|
| 381 |
-
"type":"application/hal+json"
|
| 382 |
-
}
|
| 383 |
-
}
|
| 384 |
-
}';
|
| 385 |
-
|
| 386 |
-
return $this->copy(json_decode($paymentJson), new Payment($this->apiClient));
|
| 387 |
-
}
|
| 388 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Endpoints/PermissionEndpointTest.php
DELETED
|
@@ -1,169 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\Api\Endpoints;
|
| 4 |
-
|
| 5 |
-
use GuzzleHttp\Psr7\Request;
|
| 6 |
-
use GuzzleHttp\Psr7\Response;
|
| 7 |
-
use Mollie\Api\Resources\Permission;
|
| 8 |
-
use Mollie\Api\Resources\PermissionCollection;
|
| 9 |
-
use Tests\Mollie\TestHelpers\LinkObjectTestHelpers;
|
| 10 |
-
|
| 11 |
-
class PermissionEndpointTest extends BaseEndpointTest
|
| 12 |
-
{
|
| 13 |
-
use LinkObjectTestHelpers;
|
| 14 |
-
|
| 15 |
-
/**
|
| 16 |
-
* @param string id
|
| 17 |
-
*
|
| 18 |
-
* @dataProvider dpTestGetPermissionIds
|
| 19 |
-
*/
|
| 20 |
-
public function testGetPermissionIds($permissionId)
|
| 21 |
-
{
|
| 22 |
-
$this->mockApiCall(
|
| 23 |
-
new Request('GET', '/v2/permissions/' . $permissionId),
|
| 24 |
-
new Response(
|
| 25 |
-
200,
|
| 26 |
-
[],
|
| 27 |
-
'{
|
| 28 |
-
"resource": "permission",
|
| 29 |
-
"id": "' . $permissionId . '",
|
| 30 |
-
"description": "Some dummy permission description",
|
| 31 |
-
"granted": true,
|
| 32 |
-
"_links": {
|
| 33 |
-
"self": {
|
| 34 |
-
"href": "https://api.mollie.com/v2/permissions/' . $permissionId . '",
|
| 35 |
-
"type": "application/hal+json"
|
| 36 |
-
},
|
| 37 |
-
"documentation": {
|
| 38 |
-
"href": "https://docs.mollie.com/reference/v2/permissions-api/get-permission",
|
| 39 |
-
"type": "text/html"
|
| 40 |
-
}
|
| 41 |
-
}
|
| 42 |
-
}'
|
| 43 |
-
)
|
| 44 |
-
);
|
| 45 |
-
|
| 46 |
-
$permission = $this->apiClient->permissions->get($permissionId);
|
| 47 |
-
|
| 48 |
-
$this->assertPermission($permission, $permissionId);
|
| 49 |
-
}
|
| 50 |
-
|
| 51 |
-
public function dpTestGetPermissionIds()
|
| 52 |
-
{
|
| 53 |
-
return [
|
| 54 |
-
['payments.read'],
|
| 55 |
-
['payments.write'],
|
| 56 |
-
['refunds.read'],
|
| 57 |
-
['refunds.write'],
|
| 58 |
-
['customers.read'],
|
| 59 |
-
['customers.write'],
|
| 60 |
-
['mandates.read'],
|
| 61 |
-
['mandates.write'],
|
| 62 |
-
['subscriptions.read'],
|
| 63 |
-
['subscriptions.write'],
|
| 64 |
-
['profiles.read'],
|
| 65 |
-
['profiles.write'],
|
| 66 |
-
['invoices.read'],
|
| 67 |
-
['invoices.write'],
|
| 68 |
-
['settlements.read'],
|
| 69 |
-
['settlements.write'],
|
| 70 |
-
['orders.read'],
|
| 71 |
-
['orders.write'],
|
| 72 |
-
['organizations.read'],
|
| 73 |
-
['organizations.write'],
|
| 74 |
-
];
|
| 75 |
-
}
|
| 76 |
-
|
| 77 |
-
protected function assertPermission($permission, $permissionId)
|
| 78 |
-
{
|
| 79 |
-
$this->assertInstanceOf(Permission::class, $permission);
|
| 80 |
-
$this->assertEquals('permission', $permission->resource);
|
| 81 |
-
$this->assertEquals($permissionId, $permission->id);
|
| 82 |
-
$this->assertEquals(
|
| 83 |
-
'Some dummy permission description',
|
| 84 |
-
$permission->description
|
| 85 |
-
);
|
| 86 |
-
$this->assertTrue($permission->granted);
|
| 87 |
-
|
| 88 |
-
$this->assertLinkObject(
|
| 89 |
-
'https://api.mollie.com/v2/permissions/' . $permissionId,
|
| 90 |
-
'application/hal+json',
|
| 91 |
-
$permission->_links->self
|
| 92 |
-
);
|
| 93 |
-
|
| 94 |
-
$this->assertLinkObject(
|
| 95 |
-
'https://docs.mollie.com/reference/v2/permissions-api/get-permission',
|
| 96 |
-
'text/html',
|
| 97 |
-
$permission->_links->documentation
|
| 98 |
-
);
|
| 99 |
-
}
|
| 100 |
-
|
| 101 |
-
public function testListPermissions()
|
| 102 |
-
{
|
| 103 |
-
$this->mockApiCall(
|
| 104 |
-
new Request('GET', '/v2/permissions'),
|
| 105 |
-
new Response(
|
| 106 |
-
200,
|
| 107 |
-
[],
|
| 108 |
-
'{
|
| 109 |
-
"_embedded": {
|
| 110 |
-
"permissions": [
|
| 111 |
-
{
|
| 112 |
-
"resource": "permission",
|
| 113 |
-
"id": "payments.write",
|
| 114 |
-
"description": "Some dummy permission description",
|
| 115 |
-
"granted": true,
|
| 116 |
-
"_links": {
|
| 117 |
-
"self": {
|
| 118 |
-
"href": "https://api.mollie.com/v2/permissions/payments.write",
|
| 119 |
-
"type": "application/hal+json"
|
| 120 |
-
},
|
| 121 |
-
"documentation": {
|
| 122 |
-
"href": "https://docs.mollie.com/reference/v2/permissions-api/get-permission",
|
| 123 |
-
"type": "text/html"
|
| 124 |
-
}
|
| 125 |
-
}
|
| 126 |
-
},
|
| 127 |
-
{
|
| 128 |
-
"resource": "permission",
|
| 129 |
-
"id": "payments.read",
|
| 130 |
-
"description": "Some dummy permission description",
|
| 131 |
-
"granted": true,
|
| 132 |
-
"_links": {
|
| 133 |
-
"self": {
|
| 134 |
-
"href": "https://api.mollie.com/v2/permissions/payments.read",
|
| 135 |
-
"type": "application/hal+json"
|
| 136 |
-
},
|
| 137 |
-
"documentation": {
|
| 138 |
-
"href": "https://docs.mollie.com/reference/v2/permissions-api/get-permission",
|
| 139 |
-
"type": "text/html"
|
| 140 |
-
}
|
| 141 |
-
}
|
| 142 |
-
}
|
| 143 |
-
]
|
| 144 |
-
},
|
| 145 |
-
"count": 2,
|
| 146 |
-
"_links": {
|
| 147 |
-
"documentation": {
|
| 148 |
-
"href": "https://docs.mollie.com/reference/v2/permissions-api/list-permissions",
|
| 149 |
-
"type": "text/html"
|
| 150 |
-
},
|
| 151 |
-
"self": {
|
| 152 |
-
"href": "https://api.mollie.com/v2/permissions",
|
| 153 |
-
"type": "application/hal+json"
|
| 154 |
-
}
|
| 155 |
-
}
|
| 156 |
-
}'
|
| 157 |
-
)
|
| 158 |
-
);
|
| 159 |
-
|
| 160 |
-
$permissions = $this->apiClient->permissions->all();
|
| 161 |
-
|
| 162 |
-
$this->assertInstanceOf(PermissionCollection::class, $permissions);
|
| 163 |
-
|
| 164 |
-
$this->assertCount(2, $permissions);
|
| 165 |
-
|
| 166 |
-
$this->assertPermission($permissions[0], 'payments.write');
|
| 167 |
-
$this->assertPermission($permissions[1], 'payments.read');
|
| 168 |
-
}
|
| 169 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Endpoints/ProfileEndpointTest.php
DELETED
|
@@ -1,501 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\Api\Endpoints;
|
| 4 |
-
|
| 5 |
-
use GuzzleHttp\Psr7\Request;
|
| 6 |
-
use GuzzleHttp\Psr7\Response;
|
| 7 |
-
use Mollie\Api\Resources\CurrentProfile;
|
| 8 |
-
use Mollie\Api\Resources\Profile;
|
| 9 |
-
use Mollie\Api\Resources\ProfileCollection;
|
| 10 |
-
use Mollie\Api\Types\ProfileStatus;
|
| 11 |
-
|
| 12 |
-
class ProfileEndpointTest extends BaseEndpointTest
|
| 13 |
-
{
|
| 14 |
-
public function testGetProfile()
|
| 15 |
-
{
|
| 16 |
-
$this->mockApiCall(
|
| 17 |
-
new Request(
|
| 18 |
-
"GET",
|
| 19 |
-
"/v2/profiles/pfl_ahe8z8OPut",
|
| 20 |
-
[],
|
| 21 |
-
''
|
| 22 |
-
),
|
| 23 |
-
new Response(
|
| 24 |
-
200,
|
| 25 |
-
[],
|
| 26 |
-
'{
|
| 27 |
-
"resource": "profile",
|
| 28 |
-
"id": "pfl_ahe8z8OPut",
|
| 29 |
-
"mode": "live",
|
| 30 |
-
"name": "My website name",
|
| 31 |
-
"website": "http://www.mywebsite.com",
|
| 32 |
-
"email": "info@mywebsite.com",
|
| 33 |
-
"phone": "31123456789",
|
| 34 |
-
"categoryCode": 5399,
|
| 35 |
-
"status": "verified",
|
| 36 |
-
"review": {
|
| 37 |
-
"status": "pending"
|
| 38 |
-
},
|
| 39 |
-
"createdAt": "2016-01-11T13:03:55+00:00",
|
| 40 |
-
"_links": {
|
| 41 |
-
"self": {
|
| 42 |
-
"href": "https://api.mollie.com/v2/profiles/pfl_ahe8z8OPut",
|
| 43 |
-
"type": "application/hal+json"
|
| 44 |
-
},
|
| 45 |
-
"chargebacks": {
|
| 46 |
-
"href": "https://api.mollie.com/v2/chargebacks?profileId=pfl_ahe8z8OPut",
|
| 47 |
-
"type": "application/hal+json"
|
| 48 |
-
},
|
| 49 |
-
"methods": {
|
| 50 |
-
"href": "https://api.mollie.com/v2/methods?profileId=pfl_ahe8z8OPut",
|
| 51 |
-
"type": "application/hal+json"
|
| 52 |
-
},
|
| 53 |
-
"payments": {
|
| 54 |
-
"href": "https://api.mollie.com/v2/payments?profileId=pfl_ahe8z8OPut",
|
| 55 |
-
"type": "application/hal+json"
|
| 56 |
-
},
|
| 57 |
-
"refunds": {
|
| 58 |
-
"href": "https://api.mollie.com/v2/refunds?profileId=pfl_ahe8z8OPut",
|
| 59 |
-
"type": "application/hal+json"
|
| 60 |
-
},
|
| 61 |
-
"checkoutPreviewUrl": {
|
| 62 |
-
"href": "https://www.mollie.com/payscreen/preview/pfl_ahe8z8OPut",
|
| 63 |
-
"type": "text/html"
|
| 64 |
-
}
|
| 65 |
-
}
|
| 66 |
-
}'
|
| 67 |
-
)
|
| 68 |
-
);
|
| 69 |
-
|
| 70 |
-
$profile = $this->apiClient->profiles->get('pfl_ahe8z8OPut');
|
| 71 |
-
|
| 72 |
-
$this->assertInstanceOf(Profile::class, $profile);
|
| 73 |
-
$this->assertEquals("pfl_ahe8z8OPut", $profile->id);
|
| 74 |
-
$this->assertEquals("live", $profile->mode);
|
| 75 |
-
$this->assertEquals("My website name", $profile->name);
|
| 76 |
-
$this->assertEquals("http://www.mywebsite.com", $profile->website);
|
| 77 |
-
$this->assertEquals("info@mywebsite.com", $profile->email);
|
| 78 |
-
$this->assertEquals("31123456789", $profile->phone);
|
| 79 |
-
$this->assertEquals(5399, $profile->categoryCode);
|
| 80 |
-
$this->assertEquals(ProfileStatus::STATUS_VERIFIED, $profile->status);
|
| 81 |
-
$this->assertEquals((object) ["status" => "pending"], $profile->review);
|
| 82 |
-
|
| 83 |
-
$selfLink = (object)["href" => "https://api.mollie.com/v2/profiles/pfl_ahe8z8OPut", "type" => "application/hal+json"];
|
| 84 |
-
$this->assertEquals($selfLink, $profile->_links->self);
|
| 85 |
-
|
| 86 |
-
$chargebacksLink = (object)["href" => "https://api.mollie.com/v2/chargebacks?profileId=pfl_ahe8z8OPut", "type" => "application/hal+json"];
|
| 87 |
-
$this->assertEquals($chargebacksLink, $profile->_links->chargebacks);
|
| 88 |
-
|
| 89 |
-
$methodsLink = (object)["href" => "https://api.mollie.com/v2/methods?profileId=pfl_ahe8z8OPut", "type" => "application/hal+json"];
|
| 90 |
-
$this->assertEquals($methodsLink, $profile->_links->methods);
|
| 91 |
-
|
| 92 |
-
$paymentsLink = (object)["href" => "https://api.mollie.com/v2/payments?profileId=pfl_ahe8z8OPut", "type" => "application/hal+json"];
|
| 93 |
-
$this->assertEquals($paymentsLink, $profile->_links->payments);
|
| 94 |
-
|
| 95 |
-
$refundsLink = (object)["href" => "https://api.mollie.com/v2/refunds?profileId=pfl_ahe8z8OPut", "type" => "application/hal+json"];
|
| 96 |
-
$this->assertEquals($refundsLink, $profile->_links->refunds);
|
| 97 |
-
|
| 98 |
-
$checkoutPreviewLink = (object)["href" => "https://www.mollie.com/payscreen/preview/pfl_ahe8z8OPut", "type" => "text/html"];
|
| 99 |
-
$this->assertEquals($checkoutPreviewLink, $profile->_links->checkoutPreviewUrl);
|
| 100 |
-
}
|
| 101 |
-
|
| 102 |
-
public function testGetProfileUsingMe()
|
| 103 |
-
{
|
| 104 |
-
$this->mockApiCall(
|
| 105 |
-
new Request(
|
| 106 |
-
"GET",
|
| 107 |
-
"/v2/profiles/me",
|
| 108 |
-
[],
|
| 109 |
-
''
|
| 110 |
-
),
|
| 111 |
-
new Response(
|
| 112 |
-
200,
|
| 113 |
-
[],
|
| 114 |
-
'{
|
| 115 |
-
"resource": "profile",
|
| 116 |
-
"id": "pfl_ahe8z8OPut",
|
| 117 |
-
"mode": "live",
|
| 118 |
-
"name": "My website name",
|
| 119 |
-
"website": "http://www.mywebsite.com",
|
| 120 |
-
"email": "info@mywebsite.com",
|
| 121 |
-
"phone": "31123456789",
|
| 122 |
-
"categoryCode": 5399,
|
| 123 |
-
"status": "verified",
|
| 124 |
-
"review": {
|
| 125 |
-
"status": "pending"
|
| 126 |
-
},
|
| 127 |
-
"createdAt": "2016-01-11T13:03:55+00:00",
|
| 128 |
-
"_links": {
|
| 129 |
-
"self": {
|
| 130 |
-
"href": "https://api.mollie.com/v2/profiles/pfl_ahe8z8OPut",
|
| 131 |
-
"type": "application/hal+json"
|
| 132 |
-
},
|
| 133 |
-
"chargebacks": {
|
| 134 |
-
"href": "https://api.mollie.com/v2/chargebacks?profileId=pfl_ahe8z8OPut",
|
| 135 |
-
"type": "application/hal+json"
|
| 136 |
-
},
|
| 137 |
-
"methods": {
|
| 138 |
-
"href": "https://api.mollie.com/v2/methods?profileId=pfl_ahe8z8OPut",
|
| 139 |
-
"type": "application/hal+json"
|
| 140 |
-
},
|
| 141 |
-
"payments": {
|
| 142 |
-
"href": "https://api.mollie.com/v2/payments?profileId=pfl_ahe8z8OPut",
|
| 143 |
-
"type": "application/hal+json"
|
| 144 |
-
},
|
| 145 |
-
"refunds": {
|
| 146 |
-
"href": "https://api.mollie.com/v2/refunds?profileId=pfl_ahe8z8OPut",
|
| 147 |
-
"type": "application/hal+json"
|
| 148 |
-
},
|
| 149 |
-
"checkoutPreviewUrl": {
|
| 150 |
-
"href": "https://www.mollie.com/payscreen/preview/pfl_ahe8z8OPut",
|
| 151 |
-
"type": "text/html"
|
| 152 |
-
}
|
| 153 |
-
}
|
| 154 |
-
}'
|
| 155 |
-
)
|
| 156 |
-
);
|
| 157 |
-
|
| 158 |
-
$profile = $this->apiClient->profiles->get('me');
|
| 159 |
-
|
| 160 |
-
$this->assertInstanceOf(CurrentProfile::class, $profile);
|
| 161 |
-
$this->assertEquals("pfl_ahe8z8OPut", $profile->id);
|
| 162 |
-
|
| 163 |
-
// No need to test it all again...
|
| 164 |
-
}
|
| 165 |
-
|
| 166 |
-
public function testGetCurrentProfile()
|
| 167 |
-
{
|
| 168 |
-
$this->mockApiCall(
|
| 169 |
-
new Request(
|
| 170 |
-
"GET",
|
| 171 |
-
"/v2/profiles/me",
|
| 172 |
-
[],
|
| 173 |
-
''
|
| 174 |
-
),
|
| 175 |
-
new Response(
|
| 176 |
-
200,
|
| 177 |
-
[],
|
| 178 |
-
'{
|
| 179 |
-
"resource": "profile",
|
| 180 |
-
"id": "pfl_ahe8z8OPut",
|
| 181 |
-
"mode": "live",
|
| 182 |
-
"name": "My website name",
|
| 183 |
-
"website": "http://www.mywebsite.com",
|
| 184 |
-
"email": "info@mywebsite.com",
|
| 185 |
-
"phone": "31123456789",
|
| 186 |
-
"categoryCode": 5399,
|
| 187 |
-
"status": "verified",
|
| 188 |
-
"review": {
|
| 189 |
-
"status": "pending"
|
| 190 |
-
},
|
| 191 |
-
"createdAt": "2016-01-11T13:03:55+00:00",
|
| 192 |
-
"_links": {
|
| 193 |
-
"self": {
|
| 194 |
-
"href": "https://api.mollie.com/v2/profiles/pfl_ahe8z8OPut",
|
| 195 |
-
"type": "application/hal+json"
|
| 196 |
-
},
|
| 197 |
-
"chargebacks": {
|
| 198 |
-
"href": "https://api.mollie.com/v2/chargebacks",
|
| 199 |
-
"type": "application/hal+json"
|
| 200 |
-
},
|
| 201 |
-
"methods": {
|
| 202 |
-
"href": "https://api.mollie.com/v2/methods",
|
| 203 |
-
"type": "application/hal+json"
|
| 204 |
-
},
|
| 205 |
-
"payments": {
|
| 206 |
-
"href": "https://api.mollie.com/v2/payments",
|
| 207 |
-
"type": "application/hal+json"
|
| 208 |
-
},
|
| 209 |
-
"refunds": {
|
| 210 |
-
"href": "https://api.mollie.com/v2/refunds",
|
| 211 |
-
"type": "application/hal+json"
|
| 212 |
-
},
|
| 213 |
-
"checkoutPreviewUrl": {
|
| 214 |
-
"href": "https://www.mollie.com/payscreen/preview/pfl_ahe8z8OPut",
|
| 215 |
-
"type": "text/html"
|
| 216 |
-
}
|
| 217 |
-
}
|
| 218 |
-
}'
|
| 219 |
-
)
|
| 220 |
-
);
|
| 221 |
-
|
| 222 |
-
$profile = $this->apiClient->profiles->getCurrent();
|
| 223 |
-
|
| 224 |
-
$this->assertInstanceOf(CurrentProfile::class, $profile);
|
| 225 |
-
$this->assertEquals("pfl_ahe8z8OPut", $profile->id);
|
| 226 |
-
$this->assertEquals("live", $profile->mode);
|
| 227 |
-
$this->assertEquals("My website name", $profile->name);
|
| 228 |
-
$this->assertEquals("http://www.mywebsite.com", $profile->website);
|
| 229 |
-
$this->assertEquals("info@mywebsite.com", $profile->email);
|
| 230 |
-
$this->assertEquals("31123456789", $profile->phone);
|
| 231 |
-
$this->assertEquals(5399, $profile->categoryCode);
|
| 232 |
-
$this->assertEquals(ProfileStatus::STATUS_VERIFIED, $profile->status);
|
| 233 |
-
$this->assertEquals((object) ["status" => "pending"], $profile->review);
|
| 234 |
-
|
| 235 |
-
$selfLink = (object)["href" => "https://api.mollie.com/v2/profiles/pfl_ahe8z8OPut", "type" => "application/hal+json"];
|
| 236 |
-
$this->assertEquals($selfLink, $profile->_links->self);
|
| 237 |
-
|
| 238 |
-
$chargebacksLink = (object)["href" => "https://api.mollie.com/v2/chargebacks", "type" => "application/hal+json"];
|
| 239 |
-
$this->assertEquals($chargebacksLink, $profile->_links->chargebacks);
|
| 240 |
-
|
| 241 |
-
$methodsLink = (object)["href" => "https://api.mollie.com/v2/methods", "type" => "application/hal+json"];
|
| 242 |
-
$this->assertEquals($methodsLink, $profile->_links->methods);
|
| 243 |
-
|
| 244 |
-
$paymentsLink = (object)["href" => "https://api.mollie.com/v2/payments", "type" => "application/hal+json"];
|
| 245 |
-
$this->assertEquals($paymentsLink, $profile->_links->payments);
|
| 246 |
-
|
| 247 |
-
$refundsLink = (object)["href" => "https://api.mollie.com/v2/refunds", "type" => "application/hal+json"];
|
| 248 |
-
$this->assertEquals($refundsLink, $profile->_links->refunds);
|
| 249 |
-
|
| 250 |
-
$checkoutPreviewLink = (object)["href" => "https://www.mollie.com/payscreen/preview/pfl_ahe8z8OPut", "type" => "text/html"];
|
| 251 |
-
$this->assertEquals($checkoutPreviewLink, $profile->_links->checkoutPreviewUrl);
|
| 252 |
-
}
|
| 253 |
-
|
| 254 |
-
public function testListProfiles()
|
| 255 |
-
{
|
| 256 |
-
$this->mockApiCall(
|
| 257 |
-
new Request(
|
| 258 |
-
"GET",
|
| 259 |
-
"/v2/profiles",
|
| 260 |
-
[],
|
| 261 |
-
''
|
| 262 |
-
),
|
| 263 |
-
new Response(
|
| 264 |
-
201,
|
| 265 |
-
[],
|
| 266 |
-
'{
|
| 267 |
-
"_embedded": {
|
| 268 |
-
"profiles": [{
|
| 269 |
-
"resource": "profile",
|
| 270 |
-
"id": "pfl_ahe8z8OPut",
|
| 271 |
-
"mode": "live",
|
| 272 |
-
"name": "My website name",
|
| 273 |
-
"website": "http://www.mywebsite.com",
|
| 274 |
-
"email": "info@mywebsite.com",
|
| 275 |
-
"phone": "31123456789",
|
| 276 |
-
"categoryCode": 5399,
|
| 277 |
-
"status": "verified",
|
| 278 |
-
"review": {
|
| 279 |
-
"status": "pending"
|
| 280 |
-
},
|
| 281 |
-
"createdAt": "2016-01-11T13:03:55+00:00",
|
| 282 |
-
"_links": {
|
| 283 |
-
"self": {
|
| 284 |
-
"href": "https://api.mollie.com/v2/profiles/pfl_ahe8z8OPut",
|
| 285 |
-
"type": "application/hal+json"
|
| 286 |
-
},
|
| 287 |
-
"chargebacks": {
|
| 288 |
-
"href": "https://api.mollie.com/v2/chargebacks?profileId=pfl_ahe8z8OPut",
|
| 289 |
-
"type": "application/hal+json"
|
| 290 |
-
},
|
| 291 |
-
"methods": {
|
| 292 |
-
"href": "https://api.mollie.com/v2/methods?profileId=pfl_ahe8z8OPut",
|
| 293 |
-
"type": "application/hal+json"
|
| 294 |
-
},
|
| 295 |
-
"payments": {
|
| 296 |
-
"href": "https://api.mollie.com/v2/payments?profileId=pfl_ahe8z8OPut",
|
| 297 |
-
"type": "application/hal+json"
|
| 298 |
-
},
|
| 299 |
-
"refunds": {
|
| 300 |
-
"href": "https://api.mollie.com/v2/refunds?profileId=pfl_ahe8z8OPut",
|
| 301 |
-
"type": "application/hal+json"
|
| 302 |
-
},
|
| 303 |
-
"checkoutPreviewUrl": {
|
| 304 |
-
"href": "https://www.mollie.com/payscreen/preview/pfl_ahe8z8OPut",
|
| 305 |
-
"type": "text/html"
|
| 306 |
-
}
|
| 307 |
-
}
|
| 308 |
-
},
|
| 309 |
-
{
|
| 310 |
-
"resource": "profile",
|
| 311 |
-
"id": "pfl_znNaTRkJs5",
|
| 312 |
-
"mode": "live",
|
| 313 |
-
"name": "My website name 2",
|
| 314 |
-
"website": "http://www.mywebsite2.com",
|
| 315 |
-
"email": "info@mywebsite2.com",
|
| 316 |
-
"phone": "31123456789",
|
| 317 |
-
"categoryCode": 5399,
|
| 318 |
-
"status": "verified",
|
| 319 |
-
"review": {
|
| 320 |
-
"status": "pending"
|
| 321 |
-
},
|
| 322 |
-
"createdAt": "2016-01-11T13:03:55+00:00",
|
| 323 |
-
"_links": {
|
| 324 |
-
"self": {
|
| 325 |
-
"href": "https://api.mollie.com/v2/profiles/pfl_znNaTRkJs5",
|
| 326 |
-
"type": "application/hal+json"
|
| 327 |
-
},
|
| 328 |
-
"chargebacks": {
|
| 329 |
-
"href": "https://api.mollie.com/v2/chargebacks?profileId=pfl_znNaTRkJs5",
|
| 330 |
-
"type": "application/hal+json"
|
| 331 |
-
},
|
| 332 |
-
"methods": {
|
| 333 |
-
"href": "https://api.mollie.com/v2/methods?profileId=pfl_znNaTRkJs5",
|
| 334 |
-
"type": "application/hal+json"
|
| 335 |
-
},
|
| 336 |
-
"payments": {
|
| 337 |
-
"href": "https://api.mollie.com/v2/payments?profileId=pfl_znNaTRkJs5",
|
| 338 |
-
"type": "application/hal+json"
|
| 339 |
-
},
|
| 340 |
-
"refunds": {
|
| 341 |
-
"href": "https://api.mollie.com/v2/refunds?profileId=pfl_znNaTRkJs5",
|
| 342 |
-
"type": "application/hal+json"
|
| 343 |
-
},
|
| 344 |
-
"checkoutPreviewUrl": {
|
| 345 |
-
"href": "https://www.mollie.com/payscreen/preview/pfl_znNaTRkJs5",
|
| 346 |
-
"type": "text/html"
|
| 347 |
-
}
|
| 348 |
-
}
|
| 349 |
-
}
|
| 350 |
-
]
|
| 351 |
-
},
|
| 352 |
-
"count": 2,
|
| 353 |
-
"_links": {
|
| 354 |
-
"documentation": {
|
| 355 |
-
"href": "https://docs.mollie.com/reference/v2/profiles-api/list-profiles",
|
| 356 |
-
"type": "text/html"
|
| 357 |
-
},
|
| 358 |
-
"self": {
|
| 359 |
-
"href": "https://api.mollie.nl/v2/profiles?limit=50",
|
| 360 |
-
"type": "application/hal+json"
|
| 361 |
-
},
|
| 362 |
-
"previous": null,
|
| 363 |
-
"next": null
|
| 364 |
-
}
|
| 365 |
-
}'
|
| 366 |
-
)
|
| 367 |
-
);
|
| 368 |
-
|
| 369 |
-
$profiles = $this->apiClient->profiles->page();
|
| 370 |
-
$this->assertInstanceOf(ProfileCollection::class, $profiles);
|
| 371 |
-
$this->assertEquals(2, $profiles->count);
|
| 372 |
-
|
| 373 |
-
foreach($profiles as $profile) {
|
| 374 |
-
$this->assertInstanceOf(Profile::class, $profile);
|
| 375 |
-
}
|
| 376 |
-
|
| 377 |
-
$selfLink = (object)["href" => "https://api.mollie.nl/v2/profiles?limit=50", "type" => "application/hal+json"];
|
| 378 |
-
$this->assertEquals($selfLink, $profiles->_links->self);
|
| 379 |
-
|
| 380 |
-
$documentationLink = (object)["href" => "https://docs.mollie.com/reference/v2/profiles-api/list-profiles", "type" => "text/html"];
|
| 381 |
-
$this->assertEquals($documentationLink, $profiles->_links->documentation);
|
| 382 |
-
|
| 383 |
-
}
|
| 384 |
-
|
| 385 |
-
public function testUpdateProfile()
|
| 386 |
-
{
|
| 387 |
-
$expectedWebsiteName = 'Mollie';
|
| 388 |
-
$expectedEmail = 'mollie@mollie.com';
|
| 389 |
-
$expectedPhone = '31123456766';
|
| 390 |
-
|
| 391 |
-
$this->mockApiCall(
|
| 392 |
-
new Request('PATCH', '/v2/profiles/pfl_ahe8z8OPut'),
|
| 393 |
-
new Response(
|
| 394 |
-
200,
|
| 395 |
-
[],
|
| 396 |
-
'{
|
| 397 |
-
"resource": "profile",
|
| 398 |
-
"id": "pfl_ahe8z8OPut",
|
| 399 |
-
"mode": "live",
|
| 400 |
-
"name": "' . $expectedWebsiteName . '",
|
| 401 |
-
"website": "http://www.mywebsite.com",
|
| 402 |
-
"email": "' . $expectedEmail . '",
|
| 403 |
-
"phone": "' . $expectedPhone . '",
|
| 404 |
-
"categoryCode": 5399,
|
| 405 |
-
"status": "verified",
|
| 406 |
-
"review": {
|
| 407 |
-
"status": "pending"
|
| 408 |
-
},
|
| 409 |
-
"createdAt": "2016-01-11T13:03:55+00:00",
|
| 410 |
-
"_links": {
|
| 411 |
-
"self": {
|
| 412 |
-
"href": "https://api.mollie.com/v2/profiles/pfl_ahe8z8OPut",
|
| 413 |
-
"type": "application/hal+json"
|
| 414 |
-
},
|
| 415 |
-
"chargebacks": {
|
| 416 |
-
"href": "https://api.mollie.com/v2/chargebacks?profileId=pfl_ahe8z8OPut",
|
| 417 |
-
"type": "application/hal+json"
|
| 418 |
-
},
|
| 419 |
-
"methods": {
|
| 420 |
-
"href": "https://api.mollie.com/v2/methods?profileId=pfl_ahe8z8OPut",
|
| 421 |
-
"type": "application/hal+json"
|
| 422 |
-
},
|
| 423 |
-
"payments": {
|
| 424 |
-
"href": "https://api.mollie.com/v2/payments?profileId=pfl_ahe8z8OPut",
|
| 425 |
-
"type": "application/hal+json"
|
| 426 |
-
},
|
| 427 |
-
"refunds": {
|
| 428 |
-
"href": "https://api.mollie.com/v2/refunds?profileId=pfl_ahe8z8OPut",
|
| 429 |
-
"type": "application/hal+json"
|
| 430 |
-
},
|
| 431 |
-
"checkoutPreviewUrl": {
|
| 432 |
-
"href": "https://www.mollie.com/payscreen/preview/pfl_ahe8z8OPut",
|
| 433 |
-
"type": "text/html"
|
| 434 |
-
}
|
| 435 |
-
}
|
| 436 |
-
}'
|
| 437 |
-
)
|
| 438 |
-
);
|
| 439 |
-
|
| 440 |
-
$profile = $this->getProfile();
|
| 441 |
-
$profile->name = $expectedWebsiteName;
|
| 442 |
-
$profile->email = $expectedEmail;
|
| 443 |
-
$profile->phone = $expectedPhone;
|
| 444 |
-
|
| 445 |
-
$updatedProfile = $profile->update();
|
| 446 |
-
|
| 447 |
-
$this->assertEquals($expectedWebsiteName, $updatedProfile->name);
|
| 448 |
-
$this->assertEquals($expectedEmail, $updatedProfile->email);
|
| 449 |
-
$this->assertEquals($expectedPhone, $updatedProfile->phone);
|
| 450 |
-
}
|
| 451 |
-
|
| 452 |
-
/**
|
| 453 |
-
* @return Profile
|
| 454 |
-
*/
|
| 455 |
-
private function getProfile()
|
| 456 |
-
{
|
| 457 |
-
$json = '{
|
| 458 |
-
"resource": "profile",
|
| 459 |
-
"id": "pfl_ahe8z8OPut",
|
| 460 |
-
"mode": "live",
|
| 461 |
-
"name": "My website name",
|
| 462 |
-
"website": "http://www.mywebsite.com",
|
| 463 |
-
"email": "info@mywebsite.com",
|
| 464 |
-
"phone": "31123456789",
|
| 465 |
-
"categoryCode": 5399,
|
| 466 |
-
"status": "verified",
|
| 467 |
-
"review": {
|
| 468 |
-
"status": "pending"
|
| 469 |
-
},
|
| 470 |
-
"createdAt": "2016-01-11T13:03:55+00:00",
|
| 471 |
-
"_links": {
|
| 472 |
-
"self": {
|
| 473 |
-
"href": "https://api.mollie.com/v2/profiles/pfl_ahe8z8OPut",
|
| 474 |
-
"type": "application/hal+json"
|
| 475 |
-
},
|
| 476 |
-
"chargebacks": {
|
| 477 |
-
"href": "https://api.mollie.com/v2/chargebacks?profileId=pfl_ahe8z8OPut",
|
| 478 |
-
"type": "application/hal+json"
|
| 479 |
-
},
|
| 480 |
-
"methods": {
|
| 481 |
-
"href": "https://api.mollie.com/v2/methods?profileId=pfl_ahe8z8OPut",
|
| 482 |
-
"type": "application/hal+json"
|
| 483 |
-
},
|
| 484 |
-
"payments": {
|
| 485 |
-
"href": "https://api.mollie.com/v2/payments?profileId=pfl_ahe8z8OPut",
|
| 486 |
-
"type": "application/hal+json"
|
| 487 |
-
},
|
| 488 |
-
"refunds": {
|
| 489 |
-
"href": "https://api.mollie.com/v2/refunds?profileId=pfl_ahe8z8OPut",
|
| 490 |
-
"type": "application/hal+json"
|
| 491 |
-
},
|
| 492 |
-
"checkoutPreviewUrl": {
|
| 493 |
-
"href": "https://www.mollie.com/payscreen/preview/pfl_ahe8z8OPut",
|
| 494 |
-
"type": "text/html"
|
| 495 |
-
}
|
| 496 |
-
}
|
| 497 |
-
}';
|
| 498 |
-
|
| 499 |
-
return $this->copy(json_decode($json), new Profile($this->apiClient));
|
| 500 |
-
}
|
| 501 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Endpoints/ProfileMethodEndpointTest.php
DELETED
|
@@ -1,232 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\Api\Endpoints;
|
| 4 |
-
|
| 5 |
-
use GuzzleHttp\Psr7\Request;
|
| 6 |
-
use GuzzleHttp\Psr7\Response;
|
| 7 |
-
use Mollie\Api\Resources\CurrentProfile;
|
| 8 |
-
use Mollie\Api\Resources\Method;
|
| 9 |
-
use Mollie\Api\Resources\Profile;
|
| 10 |
-
use Tests\Mollie\TestHelpers\LinkObjectTestHelpers;
|
| 11 |
-
|
| 12 |
-
class ProfileMethodEndpointTest extends BaseEndpointTest
|
| 13 |
-
{
|
| 14 |
-
use LinkObjectTestHelpers;
|
| 15 |
-
|
| 16 |
-
public function testEnableProfileMethod()
|
| 17 |
-
{
|
| 18 |
-
$this->mockApiCall(
|
| 19 |
-
new Request(
|
| 20 |
-
"POST",
|
| 21 |
-
"/v2/profiles/pfl_v9hTwCvYqw/methods/bancontact"
|
| 22 |
-
),
|
| 23 |
-
new Response(
|
| 24 |
-
201,
|
| 25 |
-
[],
|
| 26 |
-
'{
|
| 27 |
-
"resource": "method",
|
| 28 |
-
"id": "bancontact",
|
| 29 |
-
"description": "Bancontact",
|
| 30 |
-
"image": {
|
| 31 |
-
"size1x": "https://www.mollie.com/external/icons/payment-methods/bancontact.png",
|
| 32 |
-
"size2x": "https://www.mollie.com/external/icons/payment-methods/bancontact%402x.png",
|
| 33 |
-
"svg": "https://www.mollie.com/external/icons/payment-methods/bancontact.svg"
|
| 34 |
-
},
|
| 35 |
-
"_links": {
|
| 36 |
-
"self": {
|
| 37 |
-
"href": "https://api.mollie.com/v2/methods/bancontact",
|
| 38 |
-
"type": "application/hal+json"
|
| 39 |
-
},
|
| 40 |
-
"documentation": {
|
| 41 |
-
"href": "https://docs.mollie.com/reference/v2/profiles-api/activate-method",
|
| 42 |
-
"type": "text/html"
|
| 43 |
-
}
|
| 44 |
-
}
|
| 45 |
-
}'
|
| 46 |
-
)
|
| 47 |
-
);
|
| 48 |
-
|
| 49 |
-
$profile = $this->getProfile();
|
| 50 |
-
$method = $profile->enableMethod('bancontact');
|
| 51 |
-
|
| 52 |
-
$this->assertInstanceOf(Method::class, $method);
|
| 53 |
-
$this->assertEquals('bancontact', $method->id);
|
| 54 |
-
$this->assertEquals('Bancontact', $method->description);
|
| 55 |
-
$this->assertEquals('https://www.mollie.com/external/icons/payment-methods/bancontact.png', $method->image->size1x);
|
| 56 |
-
$this->assertEquals('https://www.mollie.com/external/icons/payment-methods/bancontact%402x.png', $method->image->size2x);
|
| 57 |
-
$this->assertEquals('https://www.mollie.com/external/icons/payment-methods/bancontact.svg', $method->image->svg);
|
| 58 |
-
|
| 59 |
-
$this->assertLinkObject(
|
| 60 |
-
"https://api.mollie.com/v2/methods/bancontact",
|
| 61 |
-
"application/hal+json",
|
| 62 |
-
$method->_links->self
|
| 63 |
-
);
|
| 64 |
-
|
| 65 |
-
$this->assertLinkObject(
|
| 66 |
-
"https://docs.mollie.com/reference/v2/profiles-api/activate-method",
|
| 67 |
-
"text/html",
|
| 68 |
-
$method->_links->documentation
|
| 69 |
-
);
|
| 70 |
-
|
| 71 |
-
}
|
| 72 |
-
|
| 73 |
-
public function testDisableProfileMethod()
|
| 74 |
-
{
|
| 75 |
-
$this->mockApiCall(
|
| 76 |
-
new Request(
|
| 77 |
-
"DELETE",
|
| 78 |
-
"/v2/profiles/pfl_v9hTwCvYqw/methods/bancontact"
|
| 79 |
-
),
|
| 80 |
-
new Response(204)
|
| 81 |
-
);
|
| 82 |
-
|
| 83 |
-
$profile = $this->getProfile();
|
| 84 |
-
$result = $profile->disableMethod('bancontact');
|
| 85 |
-
|
| 86 |
-
$this->assertNull($result);
|
| 87 |
-
}
|
| 88 |
-
|
| 89 |
-
public function testEnableCurrentProfileMethod()
|
| 90 |
-
{
|
| 91 |
-
$this->mockApiCall(
|
| 92 |
-
new Request(
|
| 93 |
-
"POST",
|
| 94 |
-
"/v2/profiles/me/methods/bancontact"
|
| 95 |
-
),
|
| 96 |
-
new Response(
|
| 97 |
-
201,
|
| 98 |
-
[],
|
| 99 |
-
'{
|
| 100 |
-
"resource": "method",
|
| 101 |
-
"id": "bancontact",
|
| 102 |
-
"description": "Bancontact",
|
| 103 |
-
"image": {
|
| 104 |
-
"size1x": "https://www.mollie.com/external/icons/payment-methods/bancontact.png",
|
| 105 |
-
"size2x": "https://www.mollie.com/external/icons/payment-methods/bancontact%402x.png",
|
| 106 |
-
"svg": "https://www.mollie.com/external/icons/payment-methods/bancontact.svg"
|
| 107 |
-
},
|
| 108 |
-
"_links": {
|
| 109 |
-
"self": {
|
| 110 |
-
"href": "https://api.mollie.com/v2/methods/bancontact",
|
| 111 |
-
"type": "application/hal+json"
|
| 112 |
-
},
|
| 113 |
-
"documentation": {
|
| 114 |
-
"href": "https://docs.mollie.com/reference/v2/profiles-api/activate-method",
|
| 115 |
-
"type": "text/html"
|
| 116 |
-
}
|
| 117 |
-
}
|
| 118 |
-
}'
|
| 119 |
-
)
|
| 120 |
-
);
|
| 121 |
-
|
| 122 |
-
$profile = $this->getCurrentProfile();
|
| 123 |
-
$method = $profile->enableMethod('bancontact');
|
| 124 |
-
|
| 125 |
-
$this->assertInstanceOf(Method::class, $method);
|
| 126 |
-
$this->assertEquals('bancontact', $method->id);
|
| 127 |
-
$this->assertEquals('Bancontact', $method->description);
|
| 128 |
-
$this->assertEquals('https://www.mollie.com/external/icons/payment-methods/bancontact.png', $method->image->size1x);
|
| 129 |
-
$this->assertEquals('https://www.mollie.com/external/icons/payment-methods/bancontact%402x.png', $method->image->size2x);
|
| 130 |
-
$this->assertEquals('https://www.mollie.com/external/icons/payment-methods/bancontact.svg', $method->image->svg);
|
| 131 |
-
|
| 132 |
-
$this->assertLinkObject(
|
| 133 |
-
"https://api.mollie.com/v2/methods/bancontact",
|
| 134 |
-
"application/hal+json",
|
| 135 |
-
$method->_links->self
|
| 136 |
-
);
|
| 137 |
-
|
| 138 |
-
$this->assertLinkObject(
|
| 139 |
-
"https://docs.mollie.com/reference/v2/profiles-api/activate-method",
|
| 140 |
-
"text/html",
|
| 141 |
-
$method->_links->documentation
|
| 142 |
-
);
|
| 143 |
-
|
| 144 |
-
}
|
| 145 |
-
|
| 146 |
-
public function testDisableCurrentProfileMethod()
|
| 147 |
-
{
|
| 148 |
-
$this->mockApiCall(
|
| 149 |
-
new Request(
|
| 150 |
-
"DELETE",
|
| 151 |
-
"/v2/profiles/me/methods/bancontact"
|
| 152 |
-
),
|
| 153 |
-
new Response(204)
|
| 154 |
-
);
|
| 155 |
-
|
| 156 |
-
$profile = $this->getCurrentProfile();
|
| 157 |
-
|
| 158 |
-
$result = $profile->disableMethod('bancontact');
|
| 159 |
-
|
| 160 |
-
$this->assertNull($result);
|
| 161 |
-
}
|
| 162 |
-
|
| 163 |
-
/**
|
| 164 |
-
* @return CurrentProfile
|
| 165 |
-
*/
|
| 166 |
-
private function getCurrentProfile()
|
| 167 |
-
{
|
| 168 |
-
return $this->copy(
|
| 169 |
-
json_decode($this->getProfileFixture()),
|
| 170 |
-
new CurrentProfile($this->apiClient)
|
| 171 |
-
);
|
| 172 |
-
}
|
| 173 |
-
|
| 174 |
-
/**
|
| 175 |
-
* @return Profile
|
| 176 |
-
*/
|
| 177 |
-
private function getProfile()
|
| 178 |
-
{
|
| 179 |
-
return $this->copy(
|
| 180 |
-
json_decode($this->getProfileFixture()),
|
| 181 |
-
new Profile($this->apiClient)
|
| 182 |
-
);
|
| 183 |
-
}
|
| 184 |
-
|
| 185 |
-
/**
|
| 186 |
-
* @return string
|
| 187 |
-
*/
|
| 188 |
-
private function getProfileFixture()
|
| 189 |
-
{
|
| 190 |
-
return '{
|
| 191 |
-
"resource": "profile",
|
| 192 |
-
"id": "pfl_v9hTwCvYqw",
|
| 193 |
-
"mode": "live",
|
| 194 |
-
"name": "My website name",
|
| 195 |
-
"website": "http://www.mywebsite.com",
|
| 196 |
-
"email": "info@mywebsite.com",
|
| 197 |
-
"phone": "31123456789",
|
| 198 |
-
"categoryCode": 5399,
|
| 199 |
-
"status": "verified",
|
| 200 |
-
"review": {
|
| 201 |
-
"status": "pending"
|
| 202 |
-
},
|
| 203 |
-
"createdAt": "2016-01-11T13:03:55+00:00",
|
| 204 |
-
"_links": {
|
| 205 |
-
"self": {
|
| 206 |
-
"href": "https://api.mollie.com/v2/profiles/pfl_v9hTwCvYqw",
|
| 207 |
-
"type": "application/hal+json"
|
| 208 |
-
},
|
| 209 |
-
"chargebacks": {
|
| 210 |
-
"href": "https://api.mollie.com/v2/chargebacks?profileId=pfl_v9hTwCvYqw",
|
| 211 |
-
"type": "application/hal+json"
|
| 212 |
-
},
|
| 213 |
-
"methods": {
|
| 214 |
-
"href": "https://api.mollie.com/v2/methods?profileId=pfl_v9hTwCvYqw",
|
| 215 |
-
"type": "application/hal+json"
|
| 216 |
-
},
|
| 217 |
-
"payments": {
|
| 218 |
-
"href": "https://api.mollie.com/v2/payments?profileId=pfl_v9hTwCvYqw",
|
| 219 |
-
"type": "application/hal+json"
|
| 220 |
-
},
|
| 221 |
-
"refunds": {
|
| 222 |
-
"href": "https://api.mollie.com/v2/refunds?profileId=pfl_v9hTwCvYqw",
|
| 223 |
-
"type": "application/hal+json"
|
| 224 |
-
},
|
| 225 |
-
"checkoutPreviewUrl": {
|
| 226 |
-
"href": "https://www.mollie.com/payscreen/preview/pfl_v9hTwCvYqw",
|
| 227 |
-
"type": "text/html"
|
| 228 |
-
}
|
| 229 |
-
}
|
| 230 |
-
}';
|
| 231 |
-
}
|
| 232 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Endpoints/RefundEndpointTest.php
DELETED
|
@@ -1,161 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\Api\Endpoints;
|
| 4 |
-
|
| 5 |
-
use GuzzleHttp\Psr7\Request;
|
| 6 |
-
use GuzzleHttp\Psr7\Response;
|
| 7 |
-
use Mollie\Api\Resources\Payment;
|
| 8 |
-
use Mollie\Api\Resources\Refund;
|
| 9 |
-
use Mollie\Api\Resources\RefundCollection;
|
| 10 |
-
|
| 11 |
-
class RefundEndpointTest extends BaseEndpointTest
|
| 12 |
-
{
|
| 13 |
-
public function testListRefunds()
|
| 14 |
-
{
|
| 15 |
-
$this->mockApiCall(
|
| 16 |
-
new Request(
|
| 17 |
-
"GET",
|
| 18 |
-
"/v2/refunds",
|
| 19 |
-
[],
|
| 20 |
-
''
|
| 21 |
-
),
|
| 22 |
-
new Response(
|
| 23 |
-
201,
|
| 24 |
-
[],
|
| 25 |
-
'{
|
| 26 |
-
"_embedded": {
|
| 27 |
-
"refunds": [
|
| 28 |
-
{
|
| 29 |
-
"resource": "refund",
|
| 30 |
-
"id": "re_haCsig5aru",
|
| 31 |
-
"amount": {
|
| 32 |
-
"value": "2.00",
|
| 33 |
-
"currency": "EUR"
|
| 34 |
-
},
|
| 35 |
-
"status": "pending",
|
| 36 |
-
"createdAt": "2018-03-28T10:56:10+00:00",
|
| 37 |
-
"description": "My first API payment",
|
| 38 |
-
"paymentId": "tr_44aKxzEbr8",
|
| 39 |
-
"settlementAmount": {
|
| 40 |
-
"value": "-2.00",
|
| 41 |
-
"currency": "EUR"
|
| 42 |
-
},
|
| 43 |
-
"_links": {
|
| 44 |
-
"self": {
|
| 45 |
-
"href": "https://api.mollie.com/v2/payments/tr_44aKxzEbr8/refunds/re_haCsig5aru",
|
| 46 |
-
"type": "application/hal+json"
|
| 47 |
-
},
|
| 48 |
-
"payment": {
|
| 49 |
-
"href": "https://api.mollie.com/v2/payments/tr_44aKxzEbr8",
|
| 50 |
-
"type": "application/hal+json"
|
| 51 |
-
}
|
| 52 |
-
}
|
| 53 |
-
}
|
| 54 |
-
]
|
| 55 |
-
},
|
| 56 |
-
"_links": {
|
| 57 |
-
"documentation": {
|
| 58 |
-
"href": "https://docs.mollie.com/reference/v2/refunds-api/list-refunds",
|
| 59 |
-
"type": "text/html"
|
| 60 |
-
},
|
| 61 |
-
"self": {
|
| 62 |
-
"href": "http://api.mollie.nl/v2/payments/tr_44aKxzEbr8/refunds?limit=10",
|
| 63 |
-
"type": "application/hal+json"
|
| 64 |
-
},
|
| 65 |
-
"previous": null,
|
| 66 |
-
"next": null
|
| 67 |
-
},
|
| 68 |
-
"count": 1
|
| 69 |
-
}'
|
| 70 |
-
)
|
| 71 |
-
);
|
| 72 |
-
|
| 73 |
-
$refunds = $this->apiClient->refunds->page();
|
| 74 |
-
|
| 75 |
-
$this->assertInstanceOf(RefundCollection::class, $refunds);
|
| 76 |
-
$this->assertEquals(1, $refunds->count);
|
| 77 |
-
$this->assertCount(1, $refunds);
|
| 78 |
-
|
| 79 |
-
$refund = $refunds[0];
|
| 80 |
-
|
| 81 |
-
$this->assertInstanceOf(Refund::class, $refund);
|
| 82 |
-
$this->assertEquals("re_haCsig5aru", $refund->id);
|
| 83 |
-
$this->assertEquals("2.00", $refund->amount->value);
|
| 84 |
-
$this->assertEquals("EUR", $refund->amount->currency);
|
| 85 |
-
$this->assertEquals("pending", $refund->status);
|
| 86 |
-
$this->assertEquals("2018-03-28T10:56:10+00:00", $refund->createdAt);
|
| 87 |
-
$this->assertEquals("My first API payment", $refund->description);
|
| 88 |
-
$this->assertEquals("tr_44aKxzEbr8", $refund->paymentId);
|
| 89 |
-
$this->assertEquals("-2.00", $refund->settlementAmount->value);
|
| 90 |
-
$this->assertEquals("EUR", $refund->settlementAmount->currency);
|
| 91 |
-
|
| 92 |
-
$selfLink = (object)["href" => "https://api.mollie.com/v2/payments/tr_44aKxzEbr8/refunds/re_haCsig5aru", "type" => "application/hal+json"];
|
| 93 |
-
$this->assertEquals($selfLink, $refund->_links->self);
|
| 94 |
-
|
| 95 |
-
$paymentLink = (object)["href" => "https://api.mollie.com/v2/payments/tr_44aKxzEbr8", "type" => "application/hal+json"];
|
| 96 |
-
$this->assertEquals($paymentLink, $refund->_links->payment);
|
| 97 |
-
}
|
| 98 |
-
|
| 99 |
-
/**
|
| 100 |
-
* @return Payment
|
| 101 |
-
*/
|
| 102 |
-
private function getPayment()
|
| 103 |
-
{
|
| 104 |
-
$paymentJson = '{
|
| 105 |
-
"resource":"payment",
|
| 106 |
-
"id":"tr_44aKxzEbr8",
|
| 107 |
-
"mode":"test",
|
| 108 |
-
"createdAt":"2018-03-19T12:17:57+00:00",
|
| 109 |
-
"amount":{
|
| 110 |
-
"value":"20.00",
|
| 111 |
-
"currency":"EUR"
|
| 112 |
-
},
|
| 113 |
-
"description":"My first API payment",
|
| 114 |
-
"method":"ideal",
|
| 115 |
-
"metadata":{
|
| 116 |
-
"order_id":1234
|
| 117 |
-
},
|
| 118 |
-
"status":"paid",
|
| 119 |
-
"paidAt":"2018-03-19T12:18:35+00:00",
|
| 120 |
-
"amountRefunded":{
|
| 121 |
-
"value":"0.00",
|
| 122 |
-
"currency":"EUR"
|
| 123 |
-
},
|
| 124 |
-
"amountRemaining":{
|
| 125 |
-
"value":"20.00",
|
| 126 |
-
"currency":"EUR"
|
| 127 |
-
},
|
| 128 |
-
"details":{
|
| 129 |
-
"consumerName":"T. TEST",
|
| 130 |
-
"consumerAccount":"NL17RABO0213698412",
|
| 131 |
-
"consumerBic":"TESTNL99"
|
| 132 |
-
},
|
| 133 |
-
"locale":"nl_NL",
|
| 134 |
-
"countryCode":"NL",
|
| 135 |
-
"profileId":"pfl_2A1gacu42V",
|
| 136 |
-
"sequenceType":"oneoff",
|
| 137 |
-
"redirectUrl":"http://example.org/examples/03-return-page.php?order_id=1234",
|
| 138 |
-
"webhookUrl":"http://example.org/examples/02-webhook-verification.php",
|
| 139 |
-
"settlementAmount":{
|
| 140 |
-
"value":"20.00",
|
| 141 |
-
"currency":"EUR"
|
| 142 |
-
},
|
| 143 |
-
"_links":{
|
| 144 |
-
"self":{
|
| 145 |
-
"href":"https://api.mollie.com/v2/payments/tr_44aKxzEbr8",
|
| 146 |
-
"type":"application/hal+json"
|
| 147 |
-
},
|
| 148 |
-
"documentation":{
|
| 149 |
-
"href":"https://docs.mollie.com/reference/v2/payments-api/get-payment",
|
| 150 |
-
"type":"text/html"
|
| 151 |
-
},
|
| 152 |
-
"refunds":{
|
| 153 |
-
"href":"https://api.mollie.com/v2/payments/tr_44aKxzEbr8/refunds",
|
| 154 |
-
"type":"application/hal+json"
|
| 155 |
-
}
|
| 156 |
-
}
|
| 157 |
-
}';
|
| 158 |
-
|
| 159 |
-
return $this->copy(json_decode($paymentJson), new Payment($this->apiClient));
|
| 160 |
-
}
|
| 161 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Endpoints/SettlementEndpointTest.php
DELETED
|
@@ -1,450 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\Api\Endpoints;
|
| 4 |
-
|
| 5 |
-
use GuzzleHttp\Psr7\Request;
|
| 6 |
-
use GuzzleHttp\Psr7\Response;
|
| 7 |
-
use Mollie\Api\Resources\Settlement;
|
| 8 |
-
use Mollie\Api\Resources\SettlementCollection;
|
| 9 |
-
use Mollie\Api\Types\SettlementStatus;
|
| 10 |
-
|
| 11 |
-
class SettlementEndpointTest extends BaseEndpointTest
|
| 12 |
-
{
|
| 13 |
-
public function testGetSettlement()
|
| 14 |
-
{
|
| 15 |
-
$this->mockApiCall(
|
| 16 |
-
new Request(
|
| 17 |
-
"GET",
|
| 18 |
-
"/v2/settlements/stl_xcaSGAHuRt",
|
| 19 |
-
[],
|
| 20 |
-
''
|
| 21 |
-
),
|
| 22 |
-
new Response(
|
| 23 |
-
200,
|
| 24 |
-
[],
|
| 25 |
-
'{
|
| 26 |
-
"resource": "settlement",
|
| 27 |
-
"id": "stl_xcaSGAHuRt",
|
| 28 |
-
"reference": "1234567.1234.12",
|
| 29 |
-
"createdAt": "2018-04-30T04:00:02+00:00",
|
| 30 |
-
"settledAt": "2018-05-01T04:00:02+00:00",
|
| 31 |
-
"status": "pending",
|
| 32 |
-
"amount": {
|
| 33 |
-
"value": "1980.98",
|
| 34 |
-
"currency": "EUR"
|
| 35 |
-
},
|
| 36 |
-
"periods": {
|
| 37 |
-
"2018": {
|
| 38 |
-
"04": {
|
| 39 |
-
"revenue": [
|
| 40 |
-
{
|
| 41 |
-
"description": "Creditcard",
|
| 42 |
-
"method": "creditcard",
|
| 43 |
-
"count": 2,
|
| 44 |
-
"amountNet": {
|
| 45 |
-
"value": "790.00",
|
| 46 |
-
"currency": "EUR"
|
| 47 |
-
},
|
| 48 |
-
"amountVat": null,
|
| 49 |
-
"amountGross": {
|
| 50 |
-
"value": "1000.00",
|
| 51 |
-
"currency": "EUR"
|
| 52 |
-
}
|
| 53 |
-
},
|
| 54 |
-
{
|
| 55 |
-
"description": "iDEAL",
|
| 56 |
-
"method": "ideal",
|
| 57 |
-
"count": 2,
|
| 58 |
-
"amountNet": {
|
| 59 |
-
"value": "790.00",
|
| 60 |
-
"currency": "EUR"
|
| 61 |
-
},
|
| 62 |
-
"amountVat": null,
|
| 63 |
-
"amountGross": {
|
| 64 |
-
"value": "1000.00",
|
| 65 |
-
"currency": "EUR"
|
| 66 |
-
}
|
| 67 |
-
}
|
| 68 |
-
],
|
| 69 |
-
"costs": [
|
| 70 |
-
{
|
| 71 |
-
"description": "Creditcard",
|
| 72 |
-
"method": "creditcard",
|
| 73 |
-
"count": 2,
|
| 74 |
-
"rate": {
|
| 75 |
-
"fixed": {
|
| 76 |
-
"value": "0.00",
|
| 77 |
-
"currency": "EUR"
|
| 78 |
-
},
|
| 79 |
-
"percentage": "1.80"
|
| 80 |
-
},
|
| 81 |
-
"amountNet": {
|
| 82 |
-
"value": "14.22",
|
| 83 |
-
"currency": "EUR"
|
| 84 |
-
},
|
| 85 |
-
"amountVat": {
|
| 86 |
-
"value": "2.9862",
|
| 87 |
-
"currency": "EUR"
|
| 88 |
-
},
|
| 89 |
-
"amountGross": {
|
| 90 |
-
"value": "17.2062",
|
| 91 |
-
"currency": "EUR"
|
| 92 |
-
}
|
| 93 |
-
},
|
| 94 |
-
{
|
| 95 |
-
"description": "Fixed creditcard costs",
|
| 96 |
-
"method": "creditcard",
|
| 97 |
-
"count": 2,
|
| 98 |
-
"rate": {
|
| 99 |
-
"fixed": {
|
| 100 |
-
"value": "0.25",
|
| 101 |
-
"currency": "EUR"
|
| 102 |
-
},
|
| 103 |
-
"percentage": "0"
|
| 104 |
-
},
|
| 105 |
-
"amountNet": {
|
| 106 |
-
"value": "0.50",
|
| 107 |
-
"currency": "EUR"
|
| 108 |
-
},
|
| 109 |
-
"amountVat": {
|
| 110 |
-
"value": "0.105",
|
| 111 |
-
"currency": "EUR"
|
| 112 |
-
},
|
| 113 |
-
"amountGross": {
|
| 114 |
-
"value": "0.605",
|
| 115 |
-
"currency": "EUR"
|
| 116 |
-
}
|
| 117 |
-
},
|
| 118 |
-
{
|
| 119 |
-
"description": "Fixed iDEAL costs",
|
| 120 |
-
"method": "ideal",
|
| 121 |
-
"count": 2,
|
| 122 |
-
"rate": {
|
| 123 |
-
"fixed": {
|
| 124 |
-
"value": "0.25",
|
| 125 |
-
"currency": "EUR"
|
| 126 |
-
},
|
| 127 |
-
"percentage": "0"
|
| 128 |
-
},
|
| 129 |
-
"amountNet": {
|
| 130 |
-
"value": "0.50",
|
| 131 |
-
"currency": "EUR"
|
| 132 |
-
},
|
| 133 |
-
"amountVat": {
|
| 134 |
-
"value": "0.105",
|
| 135 |
-
"currency": "EUR"
|
| 136 |
-
},
|
| 137 |
-
"amountGross": {
|
| 138 |
-
"value": "0.605",
|
| 139 |
-
"currency": "EUR"
|
| 140 |
-
}
|
| 141 |
-
},
|
| 142 |
-
{
|
| 143 |
-
"description": "Refunds iDEAL",
|
| 144 |
-
"method": "refund",
|
| 145 |
-
"count": 2,
|
| 146 |
-
"rate": {
|
| 147 |
-
"fixed": {
|
| 148 |
-
"value": "0.25",
|
| 149 |
-
"currency": "EUR"
|
| 150 |
-
},
|
| 151 |
-
"percentage": "0"
|
| 152 |
-
},
|
| 153 |
-
"amountNet": {
|
| 154 |
-
"value": "0.50",
|
| 155 |
-
"currency": "EUR"
|
| 156 |
-
},
|
| 157 |
-
"amountVat": {
|
| 158 |
-
"value": "0.105",
|
| 159 |
-
"currency": "EUR"
|
| 160 |
-
},
|
| 161 |
-
"amountGross": {
|
| 162 |
-
"value": "0.605",
|
| 163 |
-
"currency": "EUR"
|
| 164 |
-
}
|
| 165 |
-
}
|
| 166 |
-
]
|
| 167 |
-
}
|
| 168 |
-
}
|
| 169 |
-
},
|
| 170 |
-
"invoiceId": "inv_VseyTUhJSy",
|
| 171 |
-
"_links": {
|
| 172 |
-
"self": {
|
| 173 |
-
"href": "https://api.mollie.com/v2/settlements/stl_xcaSGAHuRt",
|
| 174 |
-
"type": "application/hal+json"
|
| 175 |
-
},
|
| 176 |
-
"payments": {
|
| 177 |
-
"href": "https://api.mollie.com/v2/settlements/stl_xcaSGAHuRt/payments",
|
| 178 |
-
"type": "application/hal+json"
|
| 179 |
-
},
|
| 180 |
-
"refunds": {
|
| 181 |
-
"href": "https://api.mollie.com/v2/settlements/stl_xcaSGAHuRt/refunds",
|
| 182 |
-
"type": "application/hal+json"
|
| 183 |
-
},
|
| 184 |
-
"chargebacks": {
|
| 185 |
-
"href": "https://api.mollie.com/v2/settlements/stl_xcaSGAHuRt/chargebacks",
|
| 186 |
-
"type": "application/hal+json"
|
| 187 |
-
},
|
| 188 |
-
"documentation": {
|
| 189 |
-
"href": "https://docs.mollie.com/reference/v2/settlements-api/get-settlement",
|
| 190 |
-
"type": "text/html"
|
| 191 |
-
}
|
| 192 |
-
}
|
| 193 |
-
}'
|
| 194 |
-
)
|
| 195 |
-
);
|
| 196 |
-
|
| 197 |
-
/** @var Settlement $settlement */
|
| 198 |
-
$settlement = $this->apiClient->settlements->get("stl_xcaSGAHuRt");
|
| 199 |
-
|
| 200 |
-
$this->assertInstanceOf(Settlement::class, $settlement);
|
| 201 |
-
$this->assertEquals("settlement", $settlement->resource);
|
| 202 |
-
$this->assertEquals("stl_xcaSGAHuRt", $settlement->id);
|
| 203 |
-
$this->assertEquals("1234567.1234.12", $settlement->reference);
|
| 204 |
-
$this->assertEquals("2018-04-30T04:00:02+00:00", $settlement->createdAt);
|
| 205 |
-
$this->assertEquals("2018-05-01T04:00:02+00:00", $settlement->settledAt);
|
| 206 |
-
$this->assertEquals(SettlementStatus::STATUS_PENDING, $settlement->status);
|
| 207 |
-
$this->assertEquals((object) ["value" => "1980.98", "currency" => "EUR"], $settlement->amount);
|
| 208 |
-
$this->assertNotEmpty($settlement->periods);
|
| 209 |
-
$this->assertEquals("inv_VseyTUhJSy", $settlement->invoiceId);
|
| 210 |
-
|
| 211 |
-
$selfLink = (object)['href' => 'https://api.mollie.com/v2/settlements/stl_xcaSGAHuRt', 'type' => 'application/hal+json'];
|
| 212 |
-
$this->assertEquals($selfLink, $settlement->_links->self);
|
| 213 |
-
|
| 214 |
-
$paymentLink = (object)['href' => 'https://api.mollie.com/v2/settlements/stl_xcaSGAHuRt/payments', 'type' => 'application/hal+json'];
|
| 215 |
-
$this->assertEquals($paymentLink, $settlement->_links->payments);
|
| 216 |
-
|
| 217 |
-
$refundLink = (object)['href' => 'https://api.mollie.com/v2/settlements/stl_xcaSGAHuRt/refunds', 'type' => 'application/hal+json'];
|
| 218 |
-
$this->assertEquals($refundLink, $settlement->_links->refunds);
|
| 219 |
-
|
| 220 |
-
$chargebackLink = (object)['href' => 'https://api.mollie.com/v2/settlements/stl_xcaSGAHuRt/chargebacks', 'type' => 'application/hal+json'];
|
| 221 |
-
$this->assertEquals($chargebackLink, $settlement->_links->chargebacks);
|
| 222 |
-
|
| 223 |
-
$documentationLink = (object)['href' => 'https://docs.mollie.com/reference/v2/settlements-api/get-settlement', 'type' => 'text/html'];
|
| 224 |
-
$this->assertEquals($documentationLink, $settlement->_links->documentation);
|
| 225 |
-
}
|
| 226 |
-
|
| 227 |
-
public function testListSettlement()
|
| 228 |
-
{
|
| 229 |
-
$this->mockApiCall(
|
| 230 |
-
new Request(
|
| 231 |
-
"GET",
|
| 232 |
-
"/v2/settlements",
|
| 233 |
-
[],
|
| 234 |
-
''
|
| 235 |
-
),
|
| 236 |
-
new Response(
|
| 237 |
-
200,
|
| 238 |
-
[],
|
| 239 |
-
'{
|
| 240 |
-
"_embedded": {
|
| 241 |
-
"settlements": [
|
| 242 |
-
{
|
| 243 |
-
"resource": "settlement",
|
| 244 |
-
"id": "stl_xcaSGAHuRt",
|
| 245 |
-
"reference": "1234567.1234.12",
|
| 246 |
-
"createdAt": "2018-04-30T04:00:02+00:00",
|
| 247 |
-
"settledAt": "2018-05-01T04:00:02+00:00",
|
| 248 |
-
"status": "pending",
|
| 249 |
-
"amount": {
|
| 250 |
-
"value": "1980.98",
|
| 251 |
-
"currency": "EUR"
|
| 252 |
-
},
|
| 253 |
-
"periods": {
|
| 254 |
-
"2018": {
|
| 255 |
-
"04": {
|
| 256 |
-
"revenue": [
|
| 257 |
-
{
|
| 258 |
-
"description": "Creditcard",
|
| 259 |
-
"method": "creditcard",
|
| 260 |
-
"count": 2,
|
| 261 |
-
"amountNet": {
|
| 262 |
-
"value": "790.00",
|
| 263 |
-
"currency": "EUR"
|
| 264 |
-
},
|
| 265 |
-
"amountVat": null,
|
| 266 |
-
"amountGross": {
|
| 267 |
-
"value": "1000.00",
|
| 268 |
-
"currency": "EUR"
|
| 269 |
-
}
|
| 270 |
-
},
|
| 271 |
-
{
|
| 272 |
-
"description": "iDEAL",
|
| 273 |
-
"method": "ideal",
|
| 274 |
-
"count": 2,
|
| 275 |
-
"amountNet": {
|
| 276 |
-
"value": "790.00",
|
| 277 |
-
"currency": "EUR"
|
| 278 |
-
},
|
| 279 |
-
"amountVat": null,
|
| 280 |
-
"amountGross": {
|
| 281 |
-
"value": "1000.00",
|
| 282 |
-
"currency": "EUR"
|
| 283 |
-
}
|
| 284 |
-
}
|
| 285 |
-
],
|
| 286 |
-
"costs": [
|
| 287 |
-
{
|
| 288 |
-
"description": "Creditcard",
|
| 289 |
-
"method": "creditcard",
|
| 290 |
-
"count": 2,
|
| 291 |
-
"rate": {
|
| 292 |
-
"fixed": {
|
| 293 |
-
"value": "0.00",
|
| 294 |
-
"currency": "EUR"
|
| 295 |
-
},
|
| 296 |
-
"percentage": "1.80"
|
| 297 |
-
},
|
| 298 |
-
"amountNet": {
|
| 299 |
-
"value": "14.22",
|
| 300 |
-
"currency": "EUR"
|
| 301 |
-
},
|
| 302 |
-
"amountVat": {
|
| 303 |
-
"value": "2.9862",
|
| 304 |
-
"currency": "EUR"
|
| 305 |
-
},
|
| 306 |
-
"amountGross": {
|
| 307 |
-
"value": "17.2062",
|
| 308 |
-
"currency": "EUR"
|
| 309 |
-
}
|
| 310 |
-
},
|
| 311 |
-
{
|
| 312 |
-
"description": "Fixed creditcard costs",
|
| 313 |
-
"method": "creditcard",
|
| 314 |
-
"count": 2,
|
| 315 |
-
"rate": {
|
| 316 |
-
"fixed": {
|
| 317 |
-
"value": "0.25",
|
| 318 |
-
"currency": "EUR"
|
| 319 |
-
},
|
| 320 |
-
"percentage": "0"
|
| 321 |
-
},
|
| 322 |
-
"amountNet": {
|
| 323 |
-
"value": "0.50",
|
| 324 |
-
"currency": "EUR"
|
| 325 |
-
},
|
| 326 |
-
"amountVat": {
|
| 327 |
-
"value": "0.105",
|
| 328 |
-
"currency": "EUR"
|
| 329 |
-
},
|
| 330 |
-
"amountGross": {
|
| 331 |
-
"value": "0.605",
|
| 332 |
-
"currency": "EUR"
|
| 333 |
-
}
|
| 334 |
-
},
|
| 335 |
-
{
|
| 336 |
-
"description": "Fixed iDEAL costs",
|
| 337 |
-
"method": "ideal",
|
| 338 |
-
"count": 2,
|
| 339 |
-
"rate": {
|
| 340 |
-
"fixed": {
|
| 341 |
-
"value": "0.25",
|
| 342 |
-
"currency": "EUR"
|
| 343 |
-
},
|
| 344 |
-
"percentage": "0"
|
| 345 |
-
},
|
| 346 |
-
"amountNet": {
|
| 347 |
-
"value": "0.50",
|
| 348 |
-
"currency": "EUR"
|
| 349 |
-
},
|
| 350 |
-
"amountVat": {
|
| 351 |
-
"value": "0.105",
|
| 352 |
-
"currency": "EUR"
|
| 353 |
-
},
|
| 354 |
-
"amountGross": {
|
| 355 |
-
"value": "0.605",
|
| 356 |
-
"currency": "EUR"
|
| 357 |
-
}
|
| 358 |
-
},
|
| 359 |
-
{
|
| 360 |
-
"description": "Refunds iDEAL",
|
| 361 |
-
"method": "refund",
|
| 362 |
-
"count": 2,
|
| 363 |
-
"rate": {
|
| 364 |
-
"fixed": {
|
| 365 |
-
"value": "0.25",
|
| 366 |
-
"currency": "EUR"
|
| 367 |
-
},
|
| 368 |
-
"percentage": "0"
|
| 369 |
-
},
|
| 370 |
-
"amountNet": {
|
| 371 |
-
"value": "0.50",
|
| 372 |
-
"currency": "EUR"
|
| 373 |
-
},
|
| 374 |
-
"amountVat": {
|
| 375 |
-
"value": "0.105",
|
| 376 |
-
"currency": "EUR"
|
| 377 |
-
},
|
| 378 |
-
"amountGross": {
|
| 379 |
-
"value": "0.605",
|
| 380 |
-
"currency": "EUR"
|
| 381 |
-
}
|
| 382 |
-
}
|
| 383 |
-
]
|
| 384 |
-
}
|
| 385 |
-
}
|
| 386 |
-
},
|
| 387 |
-
"_links": {
|
| 388 |
-
"self": {
|
| 389 |
-
"href": "https://api.mollie.com/v2/settlements/stl_xcaSGAHuRt",
|
| 390 |
-
"type": "application/hal+json"
|
| 391 |
-
},
|
| 392 |
-
"payments": {
|
| 393 |
-
"href": "https://api.mollie.com/v2/settlements/stl_xcaSGAHuRt/payments",
|
| 394 |
-
"type": "application/hal+json"
|
| 395 |
-
},
|
| 396 |
-
"refunds": {
|
| 397 |
-
"href": "https://api.mollie.com/v2/settlements/stl_xcaSGAHuRt/refunds",
|
| 398 |
-
"type": "application/hal+json"
|
| 399 |
-
},
|
| 400 |
-
"chargebacks": {
|
| 401 |
-
"href": "https://api.mollie.com/v2/settlements/stl_xcaSGAHuRt/chargebacks",
|
| 402 |
-
"type": "application/hal+json"
|
| 403 |
-
}
|
| 404 |
-
}
|
| 405 |
-
}
|
| 406 |
-
]
|
| 407 |
-
},
|
| 408 |
-
"count": 1,
|
| 409 |
-
"_links": {
|
| 410 |
-
"documentation": {
|
| 411 |
-
"href": "https://docs.mollie.com/reference/v2/settlements-api/list-settlements",
|
| 412 |
-
"type": "text/html"
|
| 413 |
-
},
|
| 414 |
-
"self": {
|
| 415 |
-
"href": "https://api.mollie.nl/v2/settlements",
|
| 416 |
-
"type": "application/hal+json"
|
| 417 |
-
},
|
| 418 |
-
"previous": null,
|
| 419 |
-
"next": {
|
| 420 |
-
"href": "https://api.mollie.nl/v2/settlements?from=stl_xcaSGAHuRt&limit=1&previous=stl_xcaPACKpLs",
|
| 421 |
-
"type": "application/hal+json"
|
| 422 |
-
}
|
| 423 |
-
}
|
| 424 |
-
}'
|
| 425 |
-
)
|
| 426 |
-
);
|
| 427 |
-
|
| 428 |
-
/** @var Settlement $settlement */
|
| 429 |
-
$settlements = $this->apiClient->settlements->page();
|
| 430 |
-
$this->assertInstanceOf(SettlementCollection::class, $settlements);
|
| 431 |
-
|
| 432 |
-
$documentationLink = (object)['href' => 'https://docs.mollie.com/reference/v2/settlements-api/list-settlements', 'type' => 'text/html'];
|
| 433 |
-
$this->assertEquals($documentationLink, $settlements->_links->documentation);
|
| 434 |
-
|
| 435 |
-
$selfLink = (object)['href' => 'https://api.mollie.nl/v2/settlements', 'type' => 'application/hal+json'];
|
| 436 |
-
$this->assertEquals($selfLink, $settlements->_links->self);
|
| 437 |
-
|
| 438 |
-
$this->assertEmpty($settlements->_links->previous);
|
| 439 |
-
|
| 440 |
-
$nextLink = (object)['href' => 'https://api.mollie.nl/v2/settlements?from=stl_xcaSGAHuRt&limit=1&previous=stl_xcaPACKpLs', 'type' => 'application/hal+json'];
|
| 441 |
-
$this->assertEquals($nextLink, $settlements->_links->next);
|
| 442 |
-
|
| 443 |
-
foreach($settlements as $settlement) {
|
| 444 |
-
$this->assertInstanceOf(Settlement::class, $settlement);
|
| 445 |
-
$this->assertEquals("settlement", $settlement->resource);
|
| 446 |
-
$this->assertNotEmpty($settlement->periods);
|
| 447 |
-
}
|
| 448 |
-
}
|
| 449 |
-
|
| 450 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Endpoints/ShipmentEndpointTest.php
DELETED
|
@@ -1,565 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\Api\Endpoints;
|
| 4 |
-
|
| 5 |
-
use GuzzleHttp\Psr7\Request;
|
| 6 |
-
use GuzzleHttp\Psr7\Response;
|
| 7 |
-
use Mollie\Api\Resources\Order;
|
| 8 |
-
use Mollie\Api\Resources\OrderLine;
|
| 9 |
-
use Mollie\Api\Resources\Shipment;
|
| 10 |
-
use Mollie\Api\Resources\ShipmentCollection;
|
| 11 |
-
use Mollie\Api\Types\OrderLineStatus;
|
| 12 |
-
use Mollie\Api\Types\OrderStatus;
|
| 13 |
-
use Tests\Mollie\TestHelpers\AmountObjectTestHelpers;
|
| 14 |
-
use Tests\Mollie\TestHelpers\LinkObjectTestHelpers;
|
| 15 |
-
|
| 16 |
-
class ShipmentEndpointTest extends BaseEndpointTest
|
| 17 |
-
{
|
| 18 |
-
use LinkObjectTestHelpers;
|
| 19 |
-
use AmountObjectTestHelpers;
|
| 20 |
-
|
| 21 |
-
public function testCreateShipment()
|
| 22 |
-
{
|
| 23 |
-
$this->mockApiCall(
|
| 24 |
-
new Request(
|
| 25 |
-
"POST",
|
| 26 |
-
"/v2/orders/ord_pbjz8x/shipments",
|
| 27 |
-
[],
|
| 28 |
-
'{
|
| 29 |
-
"lines": [
|
| 30 |
-
{
|
| 31 |
-
"id": "odl_dgtxyl",
|
| 32 |
-
"quantity": 1
|
| 33 |
-
},
|
| 34 |
-
{
|
| 35 |
-
"id": "odl_jp31jz"
|
| 36 |
-
}
|
| 37 |
-
]
|
| 38 |
-
}'
|
| 39 |
-
),
|
| 40 |
-
new Response(
|
| 41 |
-
201,
|
| 42 |
-
[],
|
| 43 |
-
$this->getShipmentResponseFixture("shp_3wmsgCJN4U", "ord_pbjz8x")
|
| 44 |
-
)
|
| 45 |
-
);
|
| 46 |
-
|
| 47 |
-
$order = $this->getOrder('ord_pbjz8x');
|
| 48 |
-
$shipment = $order->createShipment([
|
| 49 |
-
'lines' => [
|
| 50 |
-
[
|
| 51 |
-
'id' => 'odl_dgtxyl',
|
| 52 |
-
'quantity' => 1,
|
| 53 |
-
],
|
| 54 |
-
[
|
| 55 |
-
'id' => 'odl_jp31jz'
|
| 56 |
-
],
|
| 57 |
-
],
|
| 58 |
-
]);
|
| 59 |
-
|
| 60 |
-
$this->assertShipment($shipment, 'shp_3wmsgCJN4U', 'ord_pbjz8x');
|
| 61 |
-
}
|
| 62 |
-
|
| 63 |
-
public function testCreateShipmentUsingShorthand()
|
| 64 |
-
{
|
| 65 |
-
$this->mockApiCall(
|
| 66 |
-
new Request(
|
| 67 |
-
"POST",
|
| 68 |
-
"/v2/orders/ord_pbjz8x/shipments",
|
| 69 |
-
[],
|
| 70 |
-
'{
|
| 71 |
-
"lines": []
|
| 72 |
-
}'
|
| 73 |
-
),
|
| 74 |
-
new Response(
|
| 75 |
-
201,
|
| 76 |
-
[],
|
| 77 |
-
$this->getShipmentResponseFixture("shp_3wmsgCJN4U", "ord_pbjz8x")
|
| 78 |
-
)
|
| 79 |
-
);
|
| 80 |
-
|
| 81 |
-
$order = $this->getOrder('ord_pbjz8x');
|
| 82 |
-
$shipment = $order->shipAll();
|
| 83 |
-
|
| 84 |
-
$this->assertShipment($shipment, 'shp_3wmsgCJN4U', 'ord_pbjz8x');
|
| 85 |
-
}
|
| 86 |
-
|
| 87 |
-
public function testGetShipment()
|
| 88 |
-
{
|
| 89 |
-
$this->mockApiCall(
|
| 90 |
-
new Request(
|
| 91 |
-
"GET",
|
| 92 |
-
"/v2/orders/ord_pbjz8x/shipments/shp_3wmsgCJN4U"
|
| 93 |
-
),
|
| 94 |
-
new Response(
|
| 95 |
-
200,
|
| 96 |
-
[],
|
| 97 |
-
$this->getShipmentResponseFixture("shp_3wmsgCJN4U", "ord_pbjz8x")
|
| 98 |
-
)
|
| 99 |
-
);
|
| 100 |
-
|
| 101 |
-
$order = $this->getOrder('ord_pbjz8x');
|
| 102 |
-
$shipment = $this->apiClient->shipments->getFor($order, "shp_3wmsgCJN4U");
|
| 103 |
-
|
| 104 |
-
$this->assertShipment($shipment, 'shp_3wmsgCJN4U', 'ord_pbjz8x');
|
| 105 |
-
}
|
| 106 |
-
|
| 107 |
-
public function testGetShipmentOnOrderResource()
|
| 108 |
-
{
|
| 109 |
-
$this->mockApiCall(
|
| 110 |
-
new Request(
|
| 111 |
-
"GET",
|
| 112 |
-
"/v2/orders/ord_pbjz8x/shipments/shp_3wmsgCJN4U"
|
| 113 |
-
),
|
| 114 |
-
new Response(
|
| 115 |
-
200,
|
| 116 |
-
[],
|
| 117 |
-
$this->getShipmentResponseFixture("shp_3wmsgCJN4U", "ord_pbjz8x")
|
| 118 |
-
)
|
| 119 |
-
);
|
| 120 |
-
|
| 121 |
-
$order = $this->getOrder('ord_pbjz8x');
|
| 122 |
-
$shipment = $order->getShipment('shp_3wmsgCJN4U');
|
| 123 |
-
|
| 124 |
-
$this->assertShipment($shipment, 'shp_3wmsgCJN4U', 'ord_pbjz8x');
|
| 125 |
-
}
|
| 126 |
-
|
| 127 |
-
public function testListShipmentsViaShipmentEndpoint()
|
| 128 |
-
{
|
| 129 |
-
$this->mockApiCall(
|
| 130 |
-
new Request(
|
| 131 |
-
"GET",
|
| 132 |
-
"/v2/orders/ord_pbjz8x/shipments"
|
| 133 |
-
),
|
| 134 |
-
new Response(
|
| 135 |
-
200,
|
| 136 |
-
[],
|
| 137 |
-
'{
|
| 138 |
-
"count": 2,
|
| 139 |
-
"_embedded": {
|
| 140 |
-
"shipments": [
|
| 141 |
-
' . $this->getShipmentResponseFixture("shp_3wmsgCJN4U", "ord_pbjz8x") . ',
|
| 142 |
-
' . $this->getShipmentResponseFixture("shp_kjh234CASX", "ord_pbjz8x") . '
|
| 143 |
-
]
|
| 144 |
-
},
|
| 145 |
-
"_links": {
|
| 146 |
-
"self": {
|
| 147 |
-
"href": "https://api.mollie.com/v2/order/ord_pbjz8x/shipments",
|
| 148 |
-
"type": "application/hal+json"
|
| 149 |
-
},
|
| 150 |
-
"documentation": {
|
| 151 |
-
"href": "https://docs.mollie.com/reference/v2/shipments-api/list-shipments",
|
| 152 |
-
"type": "text/html"
|
| 153 |
-
}
|
| 154 |
-
}
|
| 155 |
-
}'
|
| 156 |
-
)
|
| 157 |
-
);
|
| 158 |
-
|
| 159 |
-
$order = $this->getOrder('ord_pbjz8x');
|
| 160 |
-
$shipments = $this->apiClient->shipments->listFor($order);
|
| 161 |
-
|
| 162 |
-
$this->assertInstanceOf(ShipmentCollection::class, $shipments);
|
| 163 |
-
$this->assertShipment($shipments[0], 'shp_3wmsgCJN4U', 'ord_pbjz8x');
|
| 164 |
-
$this->assertShipment($shipments[1], 'shp_kjh234CASX', 'ord_pbjz8x');
|
| 165 |
-
}
|
| 166 |
-
|
| 167 |
-
public function testListShipmentsOnOrderResource()
|
| 168 |
-
{
|
| 169 |
-
$this->mockApiCall(
|
| 170 |
-
new Request(
|
| 171 |
-
"GET",
|
| 172 |
-
"/v2/orders/ord_pbjz8x/shipments"
|
| 173 |
-
),
|
| 174 |
-
new Response(
|
| 175 |
-
200,
|
| 176 |
-
[],
|
| 177 |
-
'{
|
| 178 |
-
"count": 2,
|
| 179 |
-
"_embedded": {
|
| 180 |
-
"shipments": [
|
| 181 |
-
' . $this->getShipmentResponseFixture("shp_3wmsgCJN4U", "ord_pbjz8x") . ',
|
| 182 |
-
' . $this->getShipmentResponseFixture("shp_kjh234CASX", "ord_pbjz8x") . '
|
| 183 |
-
]
|
| 184 |
-
},
|
| 185 |
-
"_links": {
|
| 186 |
-
"self": {
|
| 187 |
-
"href": "https://api.mollie.com/v2/order/ord_pbjz8x/shipments",
|
| 188 |
-
"type": "application/hal+json"
|
| 189 |
-
},
|
| 190 |
-
"documentation": {
|
| 191 |
-
"href": "https://docs.mollie.com/reference/v2/shipments-api/list-shipments",
|
| 192 |
-
"type": "text/html"
|
| 193 |
-
}
|
| 194 |
-
}
|
| 195 |
-
}'
|
| 196 |
-
)
|
| 197 |
-
);
|
| 198 |
-
|
| 199 |
-
$order = $this->getOrder('ord_pbjz8x');
|
| 200 |
-
|
| 201 |
-
$shipments = $order->shipments();
|
| 202 |
-
|
| 203 |
-
$this->assertInstanceOf(ShipmentCollection::class, $shipments);
|
| 204 |
-
$this->assertShipment($shipments[0], 'shp_3wmsgCJN4U', 'ord_pbjz8x');
|
| 205 |
-
$this->assertShipment($shipments[1], 'shp_kjh234CASX', 'ord_pbjz8x');
|
| 206 |
-
}
|
| 207 |
-
|
| 208 |
-
public function testUpdateShipmentTrackingInfo()
|
| 209 |
-
{
|
| 210 |
-
$this->mockApiCall(
|
| 211 |
-
new Request(
|
| 212 |
-
"PATCH",
|
| 213 |
-
"/v2/orders/ord_pbjz8x/shipments/shp_3wmsgCJN4U",
|
| 214 |
-
[],
|
| 215 |
-
'{
|
| 216 |
-
"tracking": {
|
| 217 |
-
"carrier": "PostNL",
|
| 218 |
-
"code": "3SKABA000000000",
|
| 219 |
-
"url": "http://postnl.nl/tracktrace/?B=3SKABA000000000&P=1016EE&D=NL&T=C"
|
| 220 |
-
}
|
| 221 |
-
}'
|
| 222 |
-
),
|
| 223 |
-
new Response(
|
| 224 |
-
200,
|
| 225 |
-
[],
|
| 226 |
-
$this->getShipmentResponseFixture(
|
| 227 |
-
"shp_3wmsgCJN4U",
|
| 228 |
-
"ord_pbjz8x",
|
| 229 |
-
OrderLineStatus::STATUS_SHIPPING,
|
| 230 |
-
'"tracking": {
|
| 231 |
-
"carrier": "PostNL",
|
| 232 |
-
"code": "3SKABA000000000",
|
| 233 |
-
"url": "http://postnl.nl/tracktrace/?B=3SKABA000000000&P=1016EE&D=NL&T=C"
|
| 234 |
-
},'
|
| 235 |
-
)
|
| 236 |
-
)
|
| 237 |
-
);
|
| 238 |
-
|
| 239 |
-
$shipment = $this->getShipment('shp_3wmsgCJN4U', 'ord_pbjz8x', OrderLineStatus::STATUS_SHIPPING);
|
| 240 |
-
|
| 241 |
-
$shipment->tracking = [
|
| 242 |
-
'carrier' => 'PostNL',
|
| 243 |
-
'code' => '3SKABA000000000',
|
| 244 |
-
'url' => 'http://postnl.nl/tracktrace/?B=3SKABA000000000&P=1016EE&D=NL&T=C',
|
| 245 |
-
];
|
| 246 |
-
$shipment = $shipment->update();
|
| 247 |
-
|
| 248 |
-
$this->assertShipment($shipment, 'shp_3wmsgCJN4U', 'ord_pbjz8x');
|
| 249 |
-
|
| 250 |
-
$this->assertEquals((object) [
|
| 251 |
-
'carrier' => 'PostNL',
|
| 252 |
-
'code' => '3SKABA000000000',
|
| 253 |
-
'url' => 'http://postnl.nl/tracktrace/?B=3SKABA000000000&P=1016EE&D=NL&T=C',
|
| 254 |
-
], $shipment->tracking);
|
| 255 |
-
}
|
| 256 |
-
|
| 257 |
-
protected function assertShipment($shipment, $shipment_id, $order_id)
|
| 258 |
-
{
|
| 259 |
-
$this->assertInstanceOf(Shipment::class, $shipment);
|
| 260 |
-
$this->assertEquals("shipment", $shipment->resource);
|
| 261 |
-
$this->assertEquals($shipment_id, $shipment->id);
|
| 262 |
-
$this->assertEquals($order_id, $shipment->orderId);
|
| 263 |
-
$this->assertEquals('2018-08-02T09:29:56+00:00', $shipment->createdAt);
|
| 264 |
-
$this->assertLinkObject(
|
| 265 |
-
"https://api.mollie.com/v2/orders/ord_pbjz8x/shipments/{$shipment_id}",
|
| 266 |
-
'application/hal+json',
|
| 267 |
-
$shipment->_links->self
|
| 268 |
-
);
|
| 269 |
-
$this->assertLinkObject(
|
| 270 |
-
'https://api.mollie.com/v2/orders/ord_pbjz8x',
|
| 271 |
-
'application/hal+json',
|
| 272 |
-
$shipment->_links->order
|
| 273 |
-
);
|
| 274 |
-
$this->assertLinkObject(
|
| 275 |
-
'https://docs.mollie.com/reference/v2/shipments-api/get-shipment',
|
| 276 |
-
'text/html',
|
| 277 |
-
$shipment->_links->documentation
|
| 278 |
-
);
|
| 279 |
-
|
| 280 |
-
$line1 = $shipment->lines()[0];
|
| 281 |
-
$this->assertEquals('orderline', $line1->resource);
|
| 282 |
-
$this->assertEquals('odl_dgtxyl', $line1->id);
|
| 283 |
-
$this->assertEquals('ord_pbjz8x', $line1->orderId);
|
| 284 |
-
$this->assertEquals('LEGO 42083 Bugatti Chiron', $line1->name);
|
| 285 |
-
$this->assertEquals('https://shop.lego.com/nl-NL/Bugatti-Chiron-42083', $line1->productUrl);
|
| 286 |
-
$this->assertEquals('https://sh-s7-live-s.legocdn.com/is/image//LEGO/42083_alt1?$main$', $line1->imageUrl);
|
| 287 |
-
$this->assertEquals('5702016116977', $line1->sku);
|
| 288 |
-
$this->assertEquals('physical', $line1->type);
|
| 289 |
-
$this->assertEquals(OrderLineStatus::STATUS_SHIPPING, $line1->status);
|
| 290 |
-
$this->assertEquals(2, $line1->quantity);
|
| 291 |
-
$this->assertEquals('2018-08-02T09:29:56+00:00', $line1->createdAt);
|
| 292 |
-
$this->assertEquals('21.00', $line1->vatRate);
|
| 293 |
-
$this->assertAmountObject('121.14', 'EUR', $line1->vatAmount);
|
| 294 |
-
$this->assertAmountObject('399.00', 'EUR', $line1->unitPrice);
|
| 295 |
-
$this->assertAmountObject('100.00', 'EUR', $line1->discountAmount);
|
| 296 |
-
$this->assertAmountObject('698.00', 'EUR', $line1->totalAmount);
|
| 297 |
-
|
| 298 |
-
$line2 = $shipment->lines()[1];
|
| 299 |
-
$this->assertEquals('orderline', $line2->resource);
|
| 300 |
-
$this->assertEquals('odl_jp31jz', $line2->id);
|
| 301 |
-
$this->assertEquals('ord_pbjz8x', $line2->orderId);
|
| 302 |
-
$this->assertEquals('LEGO 42056 Porsche 911 GT3 RS', $line2->name);
|
| 303 |
-
$this->assertEquals('https://shop.lego.com/nl-NL/Porsche-911-GT3-RS-42056', $line2->productUrl);
|
| 304 |
-
$this->assertEquals('https://sh-s7-live-s.legocdn.com/is/image/LEGO/42056?$PDPDefault$', $line2->imageUrl);
|
| 305 |
-
$this->assertEquals('5702015594028', $line2->sku);
|
| 306 |
-
$this->assertEquals('digital', $line2->type);
|
| 307 |
-
$this->assertEquals(OrderLineStatus::STATUS_SHIPPING, $line2->status);
|
| 308 |
-
$this->assertEquals(1, $line2->quantity);
|
| 309 |
-
$this->assertEquals('2018-08-02T09:29:56+00:00', $line2->createdAt);
|
| 310 |
-
$this->assertEquals('21.00', $line2->vatRate);
|
| 311 |
-
$this->assertAmountObject('57.27', 'EUR', $line2->vatAmount);
|
| 312 |
-
$this->assertAmountObject('329.99', 'EUR', $line2->unitPrice);
|
| 313 |
-
$this->assertAmountObject('329.99', 'EUR', $line2->totalAmount);
|
| 314 |
-
}
|
| 315 |
-
|
| 316 |
-
protected function getOrder($id)
|
| 317 |
-
{
|
| 318 |
-
$orderJson = $this->getOrderResponseFixture($id);
|
| 319 |
-
return $this->copy(json_decode($orderJson), new Order($this->apiClient));
|
| 320 |
-
}
|
| 321 |
-
|
| 322 |
-
protected function getShipment($shipment_id, $order_id, $orderLineStatus = OrderLineStatus::STATUS_SHIPPING)
|
| 323 |
-
{
|
| 324 |
-
$shipmentJson = $this->getShipmentResponseFixture($shipment_id, $order_id, $orderLineStatus);
|
| 325 |
-
return $this->copy(json_decode($shipmentJson), new Shipment($this->apiClient));
|
| 326 |
-
}
|
| 327 |
-
|
| 328 |
-
protected function getOrderResponseFixture($order_id, $order_status = OrderStatus::STATUS_CREATED)
|
| 329 |
-
{
|
| 330 |
-
return str_replace(
|
| 331 |
-
"<<order_id>>",
|
| 332 |
-
$order_id,
|
| 333 |
-
'{
|
| 334 |
-
"resource": "order",
|
| 335 |
-
"id": "<<order_id>>",
|
| 336 |
-
"profileId": "pfl_URR55HPMGx",
|
| 337 |
-
"amount": {
|
| 338 |
-
"value": "1027.99",
|
| 339 |
-
"currency": "EUR"
|
| 340 |
-
},
|
| 341 |
-
"amountCaptured": {
|
| 342 |
-
"value": "0.00",
|
| 343 |
-
"currency": "EUR"
|
| 344 |
-
},
|
| 345 |
-
"amountRefunded": {
|
| 346 |
-
"value": "0.00",
|
| 347 |
-
"currency": "EUR"
|
| 348 |
-
},
|
| 349 |
-
"status": "' . $order_status . '",
|
| 350 |
-
"metadata": {
|
| 351 |
-
"order_id": "1337",
|
| 352 |
-
"description": "Lego cars"
|
| 353 |
-
},
|
| 354 |
-
"consumerDateOfBirth": "1958-01-31",
|
| 355 |
-
"createdAt": "2018-08-02T09:29:56+00:00",
|
| 356 |
-
"mode": "live",
|
| 357 |
-
"billingAddress": {
|
| 358 |
-
"streetAndNumber": "Keizersgracht 313",
|
| 359 |
-
"postalCode": "1016 EE",
|
| 360 |
-
"city": "Amsterdam",
|
| 361 |
-
"country": "nl",
|
| 362 |
-
"givenName": "Luke",
|
| 363 |
-
"familyName": "Skywalker",
|
| 364 |
-
"email": "luke@skywalker.com"
|
| 365 |
-
},
|
| 366 |
-
"shippingAddress": {
|
| 367 |
-
"streetAndNumber": "Keizersgracht 313",
|
| 368 |
-
"postalCode": "1016 EE",
|
| 369 |
-
"city": "Amsterdam",
|
| 370 |
-
"country": "nl",
|
| 371 |
-
"givenName": "Luke",
|
| 372 |
-
"familyName": "Skywalker",
|
| 373 |
-
"email": "luke@skywalker.com"
|
| 374 |
-
},
|
| 375 |
-
"orderNumber": "1337",
|
| 376 |
-
"locale": "nl_NL",
|
| 377 |
-
"method" : "klarnapaylater",
|
| 378 |
-
"redirectUrl": "https://example.org/redirect",
|
| 379 |
-
"webhookUrl": "https://example.org/webhook",
|
| 380 |
-
"lines": [
|
| 381 |
-
{
|
| 382 |
-
"resource": "orderline",
|
| 383 |
-
"id": "odl_dgtxyl",
|
| 384 |
-
"orderId": "<<order_id>>",
|
| 385 |
-
"name": "LEGO 42083 Bugatti Chiron",
|
| 386 |
-
"productUrl": "https://shop.lego.com/nl-NL/Bugatti-Chiron-42083",
|
| 387 |
-
"imageUrl": "https://sh-s7-live-s.legocdn.com/is/image//LEGO/42083_alt1?$main$",
|
| 388 |
-
"sku": "5702016116977",
|
| 389 |
-
"type": "physical",
|
| 390 |
-
"status": "created",
|
| 391 |
-
"quantity": 2,
|
| 392 |
-
"unitPrice": {
|
| 393 |
-
"value": "399.00",
|
| 394 |
-
"currency": "EUR"
|
| 395 |
-
},
|
| 396 |
-
"vatRate": "21.00",
|
| 397 |
-
"vatAmount": {
|
| 398 |
-
"value": "121.14",
|
| 399 |
-
"currency": "EUR"
|
| 400 |
-
},
|
| 401 |
-
"discountAmount": {
|
| 402 |
-
"value": "100.00",
|
| 403 |
-
"currency": "EUR"
|
| 404 |
-
},
|
| 405 |
-
"totalAmount": {
|
| 406 |
-
"value": "698.00",
|
| 407 |
-
"currency": "EUR"
|
| 408 |
-
},
|
| 409 |
-
"createdAt": "2018-08-02T09:29:56+00:00",
|
| 410 |
-
"_links": {
|
| 411 |
-
"self": {
|
| 412 |
-
"href": "https://api.mollie.com/v2/orders/<<order_id>>/orderlines/odl_dgtxyl",
|
| 413 |
-
"type": "application/hal+json"
|
| 414 |
-
}
|
| 415 |
-
}
|
| 416 |
-
},
|
| 417 |
-
{
|
| 418 |
-
"resource": "orderline",
|
| 419 |
-
"id": "odl_jp31jz",
|
| 420 |
-
"orderId": "<<order_id>>",
|
| 421 |
-
"name": "LEGO 42056 Porsche 911 GT3 RS",
|
| 422 |
-
"productUrl": "https://shop.lego.com/nl-NL/Porsche-911-GT3-RS-42056",
|
| 423 |
-
"imageUrl": "https://sh-s7-live-s.legocdn.com/is/image/LEGO/42056?$PDPDefault$",
|
| 424 |
-
"sku": "5702015594028",
|
| 425 |
-
"type": "digital",
|
| 426 |
-
"status": "created",
|
| 427 |
-
"quantity": 1,
|
| 428 |
-
"unitPrice": {
|
| 429 |
-
"value": "329.99",
|
| 430 |
-
"currency": "EUR"
|
| 431 |
-
},
|
| 432 |
-
"vatRate": "21.00",
|
| 433 |
-
"vatAmount": {
|
| 434 |
-
"value": "57.27",
|
| 435 |
-
"currency": "EUR"
|
| 436 |
-
},
|
| 437 |
-
"totalAmount": {
|
| 438 |
-
"value": "329.99",
|
| 439 |
-
"currency": "EUR"
|
| 440 |
-
},
|
| 441 |
-
"createdAt": "2018-08-02T09:29:56+00:00",
|
| 442 |
-
"_links": {
|
| 443 |
-
"self": {
|
| 444 |
-
"href": "https://api.mollie.com/v2/orders/<<order_id>>/orderlines/odl_jp31jz",
|
| 445 |
-
"type": "application/hal+json"
|
| 446 |
-
}
|
| 447 |
-
}
|
| 448 |
-
}
|
| 449 |
-
],
|
| 450 |
-
"_links": {
|
| 451 |
-
"self": {
|
| 452 |
-
"href": "https://api.mollie.com/v2/orders/<<order_id>>",
|
| 453 |
-
"type": "application/hal+json"
|
| 454 |
-
},
|
| 455 |
-
"checkout": {
|
| 456 |
-
"href": "https://www.mollie.com/payscreen/select-method/7UhSN1zuXS",
|
| 457 |
-
"type": "text/html"
|
| 458 |
-
},
|
| 459 |
-
"documentation": {
|
| 460 |
-
"href": "https://docs.mollie.com/reference/v2/orders-api/get-order",
|
| 461 |
-
"type": "text/html"
|
| 462 |
-
}
|
| 463 |
-
}
|
| 464 |
-
}'
|
| 465 |
-
);
|
| 466 |
-
}
|
| 467 |
-
|
| 468 |
-
protected function getShipmentResponseFixture($shipment_id, $order_id, $orderline_status = OrderLineStatus::STATUS_SHIPPING, $tracking_info = '')
|
| 469 |
-
{
|
| 470 |
-
return str_replace(
|
| 471 |
-
[
|
| 472 |
-
"<<order_id>>",
|
| 473 |
-
"<<shipment_id>>",
|
| 474 |
-
"<<orderline_status>>",
|
| 475 |
-
"<<tracking_info>>",
|
| 476 |
-
],
|
| 477 |
-
[
|
| 478 |
-
$order_id,
|
| 479 |
-
$shipment_id,
|
| 480 |
-
$orderline_status,
|
| 481 |
-
$tracking_info,
|
| 482 |
-
],
|
| 483 |
-
'{
|
| 484 |
-
"resource": "shipment",
|
| 485 |
-
"id": "<<shipment_id>>",
|
| 486 |
-
"orderId": "<<order_id>>",
|
| 487 |
-
"createdAt": "2018-08-02T09:29:56+00:00",
|
| 488 |
-
"profileId": "pfl_URR55HPMGx",
|
| 489 |
-
<<tracking_info>>
|
| 490 |
-
"lines": [
|
| 491 |
-
{
|
| 492 |
-
"resource": "orderline",
|
| 493 |
-
"id": "odl_dgtxyl",
|
| 494 |
-
"orderId": "<<order_id>>",
|
| 495 |
-
"name": "LEGO 42083 Bugatti Chiron",
|
| 496 |
-
"productUrl": "https://shop.lego.com/nl-NL/Bugatti-Chiron-42083",
|
| 497 |
-
"imageUrl": "https://sh-s7-live-s.legocdn.com/is/image//LEGO/42083_alt1?$main$",
|
| 498 |
-
"sku": "5702016116977",
|
| 499 |
-
"type": "physical",
|
| 500 |
-
"status": "<<orderline_status>>",
|
| 501 |
-
"quantity": 2,
|
| 502 |
-
"unitPrice": {
|
| 503 |
-
"value": "399.00",
|
| 504 |
-
"currency": "EUR"
|
| 505 |
-
},
|
| 506 |
-
"vatRate": "21.00",
|
| 507 |
-
"vatAmount": {
|
| 508 |
-
"value": "121.14",
|
| 509 |
-
"currency": "EUR"
|
| 510 |
-
},
|
| 511 |
-
"discountAmount": {
|
| 512 |
-
"value": "100.00",
|
| 513 |
-
"currency": "EUR"
|
| 514 |
-
},
|
| 515 |
-
"totalAmount": {
|
| 516 |
-
"value": "698.00",
|
| 517 |
-
"currency": "EUR"
|
| 518 |
-
},
|
| 519 |
-
"createdAt": "2018-08-02T09:29:56+00:00"
|
| 520 |
-
},
|
| 521 |
-
{
|
| 522 |
-
"resource": "orderline",
|
| 523 |
-
"id": "odl_jp31jz",
|
| 524 |
-
"orderId": "<<order_id>>",
|
| 525 |
-
"name": "LEGO 42056 Porsche 911 GT3 RS",
|
| 526 |
-
"productUrl": "https://shop.lego.com/nl-NL/Porsche-911-GT3-RS-42056",
|
| 527 |
-
"imageUrl": "https://sh-s7-live-s.legocdn.com/is/image/LEGO/42056?$PDPDefault$",
|
| 528 |
-
"sku": "5702015594028",
|
| 529 |
-
"type": "digital",
|
| 530 |
-
"status": "<<orderline_status>>",
|
| 531 |
-
"quantity": 1,
|
| 532 |
-
"unitPrice": {
|
| 533 |
-
"value": "329.99",
|
| 534 |
-
"currency": "EUR"
|
| 535 |
-
},
|
| 536 |
-
"vatRate": "21.00",
|
| 537 |
-
"vatAmount": {
|
| 538 |
-
"value": "57.27",
|
| 539 |
-
"currency": "EUR"
|
| 540 |
-
},
|
| 541 |
-
"totalAmount": {
|
| 542 |
-
"value": "329.99",
|
| 543 |
-
"currency": "EUR"
|
| 544 |
-
},
|
| 545 |
-
"createdAt": "2018-08-02T09:29:56+00:00"
|
| 546 |
-
}
|
| 547 |
-
],
|
| 548 |
-
"_links": {
|
| 549 |
-
"self": {
|
| 550 |
-
"href": "https://api.mollie.com/v2/orders/<<order_id>>/shipments/<<shipment_id>>",
|
| 551 |
-
"type": "application/hal+json"
|
| 552 |
-
},
|
| 553 |
-
"order": {
|
| 554 |
-
"href": "https://api.mollie.com/v2/orders/<<order_id>>",
|
| 555 |
-
"type": "application/hal+json"
|
| 556 |
-
},
|
| 557 |
-
"documentation": {
|
| 558 |
-
"href": "https://docs.mollie.com/reference/v2/shipments-api/get-shipment",
|
| 559 |
-
"type": "text/html"
|
| 560 |
-
}
|
| 561 |
-
}
|
| 562 |
-
}'
|
| 563 |
-
);
|
| 564 |
-
}
|
| 565 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Endpoints/SubscriptionEndpointTest.php
DELETED
|
@@ -1,491 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\Api\Endpoints;
|
| 4 |
-
|
| 5 |
-
use GuzzleHttp\Psr7\Request;
|
| 6 |
-
use GuzzleHttp\Psr7\Response;
|
| 7 |
-
use Mollie\Api\Resources\Customer;
|
| 8 |
-
use Mollie\Api\Resources\Subscription;
|
| 9 |
-
use Mollie\Api\Resources\SubscriptionCollection;
|
| 10 |
-
use Mollie\Api\Types\SubscriptionStatus;
|
| 11 |
-
|
| 12 |
-
class SubscriptionEndpointTest extends BaseEndpointTest
|
| 13 |
-
{
|
| 14 |
-
public function testCreateWorks()
|
| 15 |
-
{
|
| 16 |
-
$this->mockApiCall(
|
| 17 |
-
new Request('POST', '/v2/customers/cst_FhQJRw4s2n/subscriptions'),
|
| 18 |
-
new Response(
|
| 19 |
-
200,
|
| 20 |
-
[],
|
| 21 |
-
'{
|
| 22 |
-
"resource": "subscription",
|
| 23 |
-
"id": "sub_wByQa6efm6",
|
| 24 |
-
"mode": "test",
|
| 25 |
-
"createdAt": "2018-04-24T11:41:55+00:00",
|
| 26 |
-
"status": "active",
|
| 27 |
-
"amount": {
|
| 28 |
-
"value": "10.00",
|
| 29 |
-
"currency": "EUR"
|
| 30 |
-
},
|
| 31 |
-
"description": "Order 1234",
|
| 32 |
-
"method": null,
|
| 33 |
-
"times": null,
|
| 34 |
-
"interval": "1 month",
|
| 35 |
-
"startDate": "2018-04-24",
|
| 36 |
-
"webhookUrl": null,
|
| 37 |
-
"_links": {
|
| 38 |
-
"self": {
|
| 39 |
-
"href": "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n/subscriptions/sub_wByQa6efm6",
|
| 40 |
-
"type": "application/hal+json"
|
| 41 |
-
},
|
| 42 |
-
"customer": {
|
| 43 |
-
"href": "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n",
|
| 44 |
-
"type": "application/hal+json"
|
| 45 |
-
},
|
| 46 |
-
"documentation": {
|
| 47 |
-
"href": "https://docs.mollie.com/reference/v2/subscriptions-api/create-subscription",
|
| 48 |
-
"type": "text/html"
|
| 49 |
-
}
|
| 50 |
-
}
|
| 51 |
-
}'
|
| 52 |
-
)
|
| 53 |
-
);
|
| 54 |
-
|
| 55 |
-
$customer = $this->getCustomer();
|
| 56 |
-
|
| 57 |
-
/** @var Subscription $subscription */
|
| 58 |
-
$subscription = $customer->createSubscription([
|
| 59 |
-
"amount" => [
|
| 60 |
-
"value" => "10.00",
|
| 61 |
-
"currency" => "EUR"
|
| 62 |
-
],
|
| 63 |
-
"interval" => "1 month",
|
| 64 |
-
"description" => "Order 1234"
|
| 65 |
-
]);
|
| 66 |
-
|
| 67 |
-
$this->assertInstanceOf(Subscription::class, $subscription);
|
| 68 |
-
$this->assertEquals("subscription", $subscription->resource);
|
| 69 |
-
$this->assertEquals("sub_wByQa6efm6", $subscription->id);
|
| 70 |
-
$this->assertEquals("test", $subscription->mode);
|
| 71 |
-
$this->assertEquals("2018-04-24T11:41:55+00:00", $subscription->createdAt);
|
| 72 |
-
$this->assertEquals(SubscriptionStatus::STATUS_ACTIVE, $subscription->status);
|
| 73 |
-
$this->assertEquals((object)["value" => "10.00", "currency" => "EUR"], $subscription->amount);
|
| 74 |
-
$this->assertEquals("Order 1234", $subscription->description);
|
| 75 |
-
$this->assertNull($subscription->method);
|
| 76 |
-
$this->assertNull($subscription->times);
|
| 77 |
-
$this->assertEquals("1 month", $subscription->interval);
|
| 78 |
-
$this->assertEquals("2018-04-24", $subscription->startDate);
|
| 79 |
-
|
| 80 |
-
$selfLink = (object)["href" => "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n/subscriptions/sub_wByQa6efm6", "type" => "application/hal+json"];
|
| 81 |
-
$this->assertEquals($selfLink, $subscription->_links->self);
|
| 82 |
-
|
| 83 |
-
$customerLink = (object)["href" => "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n", "type" => "application/hal+json"];
|
| 84 |
-
$this->assertEquals($customerLink, $subscription->_links->customer);
|
| 85 |
-
|
| 86 |
-
$documentationLink = (object)["href" => "https://docs.mollie.com/reference/v2/subscriptions-api/create-subscription", "type" => "text/html"];
|
| 87 |
-
$this->assertEquals($documentationLink, $subscription->_links->documentation);
|
| 88 |
-
}
|
| 89 |
-
|
| 90 |
-
public function testGetWorks()
|
| 91 |
-
{
|
| 92 |
-
$this->mockApiCall(
|
| 93 |
-
new Request('GET', '/v2/customers/cst_FhQJRw4s2n/subscriptions/sub_wByQa6efm6'),
|
| 94 |
-
new Response(
|
| 95 |
-
200,
|
| 96 |
-
[],
|
| 97 |
-
'{
|
| 98 |
-
"resource": "subscription",
|
| 99 |
-
"id": "sub_wByQa6efm6",
|
| 100 |
-
"mode": "test",
|
| 101 |
-
"createdAt": "2018-04-24T11:41:55+00:00",
|
| 102 |
-
"status": "active",
|
| 103 |
-
"amount": {
|
| 104 |
-
"value": "10.00",
|
| 105 |
-
"currency": "EUR"
|
| 106 |
-
},
|
| 107 |
-
"description": "Order 1234",
|
| 108 |
-
"method": null,
|
| 109 |
-
"times": null,
|
| 110 |
-
"interval": "1 month",
|
| 111 |
-
"startDate": "2018-04-24",
|
| 112 |
-
"webhookUrl": null,
|
| 113 |
-
"_links": {
|
| 114 |
-
"self": {
|
| 115 |
-
"href": "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n/subscriptions/sub_wByQa6efm6",
|
| 116 |
-
"type": "application/hal+json"
|
| 117 |
-
},
|
| 118 |
-
"customer": {
|
| 119 |
-
"href": "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n",
|
| 120 |
-
"type": "application/hal+json"
|
| 121 |
-
},
|
| 122 |
-
"documentation": {
|
| 123 |
-
"href": "https://docs.mollie.com/reference/v2/subscriptions-api/get-subscription",
|
| 124 |
-
"type": "text/html"
|
| 125 |
-
}
|
| 126 |
-
}
|
| 127 |
-
}'
|
| 128 |
-
)
|
| 129 |
-
);
|
| 130 |
-
|
| 131 |
-
$customer = $this->getCustomer();
|
| 132 |
-
|
| 133 |
-
/** @var Subscription $subscription */
|
| 134 |
-
$subscription = $customer->getSubscription("sub_wByQa6efm6");
|
| 135 |
-
|
| 136 |
-
$this->assertInstanceOf(Subscription::class, $subscription);
|
| 137 |
-
$this->assertEquals("subscription", $subscription->resource);
|
| 138 |
-
$this->assertEquals("sub_wByQa6efm6", $subscription->id);
|
| 139 |
-
$this->assertEquals("test", $subscription->mode);
|
| 140 |
-
$this->assertEquals("2018-04-24T11:41:55+00:00", $subscription->createdAt);
|
| 141 |
-
$this->assertEquals(SubscriptionStatus::STATUS_ACTIVE, $subscription->status);
|
| 142 |
-
$this->assertEquals((object)["value" => "10.00", "currency" => "EUR"], $subscription->amount);
|
| 143 |
-
$this->assertEquals("Order 1234", $subscription->description);
|
| 144 |
-
$this->assertNull($subscription->method);
|
| 145 |
-
$this->assertNull($subscription->times);
|
| 146 |
-
$this->assertEquals("1 month", $subscription->interval);
|
| 147 |
-
$this->assertEquals("2018-04-24", $subscription->startDate);
|
| 148 |
-
|
| 149 |
-
$selfLink = (object)["href" => "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n/subscriptions/sub_wByQa6efm6", "type" => "application/hal+json"];
|
| 150 |
-
$this->assertEquals($selfLink, $subscription->_links->self);
|
| 151 |
-
|
| 152 |
-
$customerLink = (object)["href" => "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n", "type" => "application/hal+json"];
|
| 153 |
-
$this->assertEquals($customerLink, $subscription->_links->customer);
|
| 154 |
-
|
| 155 |
-
$documentationLink = (object)["href" => "https://docs.mollie.com/reference/v2/subscriptions-api/get-subscription", "type" => "text/html"];
|
| 156 |
-
$this->assertEquals($documentationLink, $subscription->_links->documentation);
|
| 157 |
-
}
|
| 158 |
-
|
| 159 |
-
public function testListWorks()
|
| 160 |
-
{
|
| 161 |
-
$this->mockApiCall(
|
| 162 |
-
new Request('GET', '/v2/customers/cst_FhQJRw4s2n/subscriptions'),
|
| 163 |
-
new Response(
|
| 164 |
-
200,
|
| 165 |
-
[],
|
| 166 |
-
'{
|
| 167 |
-
"_embedded": {
|
| 168 |
-
"subscriptions": [{
|
| 169 |
-
"resource": "subscription",
|
| 170 |
-
"id": "sub_wByQa6efm6",
|
| 171 |
-
"mode": "test",
|
| 172 |
-
"createdAt": "2018-04-24T11:41:55+00:00",
|
| 173 |
-
"status": "active",
|
| 174 |
-
"amount": {
|
| 175 |
-
"value": "10.00",
|
| 176 |
-
"currency": "EUR"
|
| 177 |
-
},
|
| 178 |
-
"description": "Order 1234",
|
| 179 |
-
"method": null,
|
| 180 |
-
"times": null,
|
| 181 |
-
"interval": "1 month",
|
| 182 |
-
"startDate": "2018-04-24",
|
| 183 |
-
"webhookUrl": null,
|
| 184 |
-
"_links": {
|
| 185 |
-
"self": {
|
| 186 |
-
"href": "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n/subscriptions/sub_wByQa6efm6",
|
| 187 |
-
"type": "application/hal+json"
|
| 188 |
-
},
|
| 189 |
-
"customer": {
|
| 190 |
-
"href": "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n",
|
| 191 |
-
"type": "application/hal+json"
|
| 192 |
-
}
|
| 193 |
-
}
|
| 194 |
-
}]
|
| 195 |
-
},
|
| 196 |
-
"count": 1,
|
| 197 |
-
"_links": {
|
| 198 |
-
"documentation": {
|
| 199 |
-
"href": "https://docs.mollie.com/reference/v2/subscriptions-api/list-subscriptions",
|
| 200 |
-
"type": "text/html"
|
| 201 |
-
},
|
| 202 |
-
"self": {
|
| 203 |
-
"href": "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n/subscriptions?limit=50",
|
| 204 |
-
"type": "application/hal+json"
|
| 205 |
-
},
|
| 206 |
-
"previous": null,
|
| 207 |
-
"next": null
|
| 208 |
-
}
|
| 209 |
-
}'
|
| 210 |
-
)
|
| 211 |
-
);
|
| 212 |
-
|
| 213 |
-
$customer = $this->getCustomer();
|
| 214 |
-
|
| 215 |
-
$subscriptions = $customer->subscriptions();
|
| 216 |
-
|
| 217 |
-
$this->assertInstanceOf(SubscriptionCollection::class, $subscriptions);
|
| 218 |
-
|
| 219 |
-
$this->assertEquals(count($subscriptions), $subscriptions->count);
|
| 220 |
-
|
| 221 |
-
$documentationLink = (object)["href" => "https://docs.mollie.com/reference/v2/subscriptions-api/list-subscriptions", "type" => "text/html"];
|
| 222 |
-
$this->assertEquals($documentationLink, $subscriptions->_links->documentation);
|
| 223 |
-
|
| 224 |
-
$selfLink = (object)["href" => "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n/subscriptions?limit=50", "type" => "application/hal+json"];
|
| 225 |
-
$this->assertEquals($selfLink, $subscriptions->_links->self);
|
| 226 |
-
|
| 227 |
-
foreach ($subscriptions as $subscription) {
|
| 228 |
-
$this->assertInstanceOf(Subscription::class, $subscription);
|
| 229 |
-
$this->assertEquals("subscription", $subscription->resource);
|
| 230 |
-
$this->assertNotEmpty($subscription->createdAt);
|
| 231 |
-
}
|
| 232 |
-
}
|
| 233 |
-
|
| 234 |
-
public function testCancelViaCustomerResourceWorks()
|
| 235 |
-
{
|
| 236 |
-
$this->mockApiCall(
|
| 237 |
-
new Request('DELETE', '/v2/customers/cst_FhQJRw4s2n/subscriptions/sub_wByQa6efm6'),
|
| 238 |
-
new Response(
|
| 239 |
-
200,
|
| 240 |
-
[],
|
| 241 |
-
'{
|
| 242 |
-
"resource": "subscription",
|
| 243 |
-
"id": "sub_wByQa6efm6",
|
| 244 |
-
"mode": "test",
|
| 245 |
-
"createdAt": "2018-04-24T11:41:55+00:00",
|
| 246 |
-
"status": "canceled",
|
| 247 |
-
"amount": {
|
| 248 |
-
"value": "10.00",
|
| 249 |
-
"currency": "EUR"
|
| 250 |
-
},
|
| 251 |
-
"description": "Order 1234",
|
| 252 |
-
"method": null,
|
| 253 |
-
"times": null,
|
| 254 |
-
"interval": "1 month",
|
| 255 |
-
"startDate": "2018-04-24",
|
| 256 |
-
"webhookUrl": null,
|
| 257 |
-
"canceledAt": "2018-04-24T12:31:32+00:00",
|
| 258 |
-
"_links": {
|
| 259 |
-
"self": {
|
| 260 |
-
"href": "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n/subscriptions/sub_wByQa6efm6",
|
| 261 |
-
"type": "application/hal+json"
|
| 262 |
-
},
|
| 263 |
-
"customer": {
|
| 264 |
-
"href": "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n",
|
| 265 |
-
"type": "application/hal+json"
|
| 266 |
-
},
|
| 267 |
-
"documentation": {
|
| 268 |
-
"href": "https://docs.mollie.com/reference/v2/subscriptions-api/cancel-subscription",
|
| 269 |
-
"type": "text/html"
|
| 270 |
-
}
|
| 271 |
-
}
|
| 272 |
-
}'
|
| 273 |
-
)
|
| 274 |
-
);
|
| 275 |
-
|
| 276 |
-
$customer = $this->getCustomer();
|
| 277 |
-
|
| 278 |
-
/** @var Subscription $subscription */
|
| 279 |
-
$subscription = $customer->cancelSubscription("sub_wByQa6efm6");
|
| 280 |
-
|
| 281 |
-
$this->assertInstanceOf(Subscription::class, $subscription);
|
| 282 |
-
$this->assertEquals("subscription", $subscription->resource);
|
| 283 |
-
$this->assertEquals("sub_wByQa6efm6", $subscription->id);
|
| 284 |
-
$this->assertEquals("test", $subscription->mode);
|
| 285 |
-
$this->assertEquals(SubscriptionStatus::STATUS_CANCELED, $subscription->status);
|
| 286 |
-
$this->assertEquals("2018-04-24T11:41:55+00:00", $subscription->createdAt);
|
| 287 |
-
$this->assertEquals("2018-04-24T12:31:32+00:00", $subscription->canceledAt);
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
$selfLink = (object)["href" => "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n/subscriptions/sub_wByQa6efm6", "type" => "application/hal+json"];
|
| 291 |
-
$this->assertEquals($selfLink, $subscription->_links->self);
|
| 292 |
-
|
| 293 |
-
$customerLink = (object)["href" => "https://api.mollie.com/v2/customers/cst_FhQJRw4s2n", "type" => "application/hal+json"];
|
| 294 |
-
$this->assertEquals($customerLink, $subscription->_links->customer);
|
| 295 |
-
|
| 296 |
-
$documentationLink = (object)["href" => "https://docs.mollie.com/reference/v2/subscriptions-api/cancel-subscription", "type" => "text/html"];
|
| 297 |
-
$this->assertEquals($documentationLink, $subscription->_links->documentation);
|
| 298 |
-
}
|
| 299 |
-
|
| 300 |
-
public function testCancelOnSubscriptionResourceWorks($value='')
|
| 301 |
-
{
|
| 302 |
-
$this->mockApiCall(
|
| 303 |
-
new Request('DELETE', '/v2/customers/cst_VhjQebNW5j/subscriptions/sub_DRjwaT5qHx'),
|
| 304 |
-
new Response(
|
| 305 |
-
200,
|
| 306 |
-
[],
|
| 307 |
-
'{
|
| 308 |
-
"resource": "subscription",
|
| 309 |
-
"id": "sub_DRjwaT5qHx",
|
| 310 |
-
"mode": "test",
|
| 311 |
-
"createdAt": "2018-04-24T11:41:55+00:00",
|
| 312 |
-
"status": "canceled",
|
| 313 |
-
"amount": {
|
| 314 |
-
"value": "10.00",
|
| 315 |
-
"currency": "EUR"
|
| 316 |
-
},
|
| 317 |
-
"description": "Order 1234",
|
| 318 |
-
"method": null,
|
| 319 |
-
"times": null,
|
| 320 |
-
"interval": "1 month",
|
| 321 |
-
"startDate": "2018-04-24",
|
| 322 |
-
"webhookUrl": null,
|
| 323 |
-
"canceledAt": "2018-04-24T12:31:32+00:00",
|
| 324 |
-
"_links": {
|
| 325 |
-
"self": {
|
| 326 |
-
"href": "https://api.mollie.com/v2/customers/cst_VhjQebNW5j/subscriptions/sub_DRjwaT5qHx",
|
| 327 |
-
"type": "application/hal+json"
|
| 328 |
-
},
|
| 329 |
-
"customer": {
|
| 330 |
-
"href": "https://api.mollie.com/v2/customers/cst_VhjQebNW5j",
|
| 331 |
-
"type": "application/hal+json"
|
| 332 |
-
},
|
| 333 |
-
"documentation": {
|
| 334 |
-
"href": "https://docs.mollie.com/reference/v2/subscriptions-api/cancel-subscription",
|
| 335 |
-
"type": "text/html"
|
| 336 |
-
}
|
| 337 |
-
}
|
| 338 |
-
}'
|
| 339 |
-
)
|
| 340 |
-
);
|
| 341 |
-
|
| 342 |
-
$subscription = $this->getSubscription();
|
| 343 |
-
|
| 344 |
-
$subscription = $subscription->cancel();
|
| 345 |
-
|
| 346 |
-
$this->assertInstanceOf(Subscription::class, $subscription);
|
| 347 |
-
$this->assertEquals("subscription", $subscription->resource);
|
| 348 |
-
$this->assertEquals("sub_DRjwaT5qHx", $subscription->id);
|
| 349 |
-
$this->assertEquals("test", $subscription->mode);
|
| 350 |
-
$this->assertEquals(SubscriptionStatus::STATUS_CANCELED, $subscription->status);
|
| 351 |
-
$this->assertEquals("2018-04-24T11:41:55+00:00", $subscription->createdAt);
|
| 352 |
-
$this->assertEquals("2018-04-24T12:31:32+00:00", $subscription->canceledAt);
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
$selfLink = (object)["href" => "https://api.mollie.com/v2/customers/cst_VhjQebNW5j/subscriptions/sub_DRjwaT5qHx", "type" => "application/hal+json"];
|
| 356 |
-
$this->assertEquals($selfLink, $subscription->_links->self);
|
| 357 |
-
|
| 358 |
-
$customerLink = (object)["href" => "https://api.mollie.com/v2/customers/cst_VhjQebNW5j", "type" => "application/hal+json"];
|
| 359 |
-
$this->assertEquals($customerLink, $subscription->_links->customer);
|
| 360 |
-
|
| 361 |
-
$documentationLink = (object)["href" => "https://docs.mollie.com/reference/v2/subscriptions-api/cancel-subscription", "type" => "text/html"];
|
| 362 |
-
$this->assertEquals($documentationLink, $subscription->_links->documentation);
|
| 363 |
-
}
|
| 364 |
-
|
| 365 |
-
public function testThatUpdateSubscriptionWorks()
|
| 366 |
-
{
|
| 367 |
-
$expectedAmountValue = '12.00';
|
| 368 |
-
$expectedAmountCurrency = 'EUR';
|
| 369 |
-
$expectedStartDate = '2018-12-12';
|
| 370 |
-
|
| 371 |
-
$this->mockApiCall(
|
| 372 |
-
new Request('PATCH', '/v2/customers/cst_VhjQebNW5j/subscriptions/sub_DRjwaT5qHx'),
|
| 373 |
-
new Response(
|
| 374 |
-
200,
|
| 375 |
-
[],
|
| 376 |
-
'{
|
| 377 |
-
"resource": "subscription",
|
| 378 |
-
"id": "sub_DRjwaT5qHx",
|
| 379 |
-
"customerId": "cst_VhjQebNW5j",
|
| 380 |
-
"mode": "live",
|
| 381 |
-
"createdAt": "2018-07-17T07:45:52+00:00",
|
| 382 |
-
"status": "active",
|
| 383 |
-
"amount": {
|
| 384 |
-
"value": "' . $expectedAmountValue . '",
|
| 385 |
-
"currency": "' . $expectedAmountCurrency . '"
|
| 386 |
-
},
|
| 387 |
-
"description": "Mollie Recurring subscription #1",
|
| 388 |
-
"method": null,
|
| 389 |
-
"times": 42,
|
| 390 |
-
"interval": "15 days",
|
| 391 |
-
"startDate": "' . $expectedStartDate . '",
|
| 392 |
-
"webhookUrl": "https://example.org/webhook",
|
| 393 |
-
"_links": {
|
| 394 |
-
"self": {
|
| 395 |
-
"href": "http://api.mollie.test/v2/customers/cst_VhjQebNW5j/subscriptions/sub_DRjwaT5qHx",
|
| 396 |
-
"type": "application/hal+json"
|
| 397 |
-
},
|
| 398 |
-
"customer": {
|
| 399 |
-
"href": "http://api.mollie.test/v2/customers/cst_VhjQebNW5j",
|
| 400 |
-
"type": "application/hal+json"
|
| 401 |
-
},
|
| 402 |
-
"documentation": {
|
| 403 |
-
"href": "https://docs.mollie.com/reference/v2/subscriptions-api/update-subscription",
|
| 404 |
-
"type": "text/html"
|
| 405 |
-
}
|
| 406 |
-
}
|
| 407 |
-
}'
|
| 408 |
-
)
|
| 409 |
-
);
|
| 410 |
-
|
| 411 |
-
$subscription = $this->getSubscription();
|
| 412 |
-
$expectedAmountObject = (object)[
|
| 413 |
-
'value' => $expectedAmountValue,
|
| 414 |
-
'currency' => $expectedAmountCurrency,
|
| 415 |
-
];
|
| 416 |
-
$subscription->amount = $expectedAmountObject;
|
| 417 |
-
$subscription->startDate = $expectedStartDate;
|
| 418 |
-
|
| 419 |
-
$updatedSubscription = $subscription->update();
|
| 420 |
-
|
| 421 |
-
$this->assertEquals($expectedStartDate, $updatedSubscription->startDate);
|
| 422 |
-
$this->assertEquals($expectedAmountObject, $updatedSubscription->amount);
|
| 423 |
-
}
|
| 424 |
-
|
| 425 |
-
/**
|
| 426 |
-
* @return Subscription
|
| 427 |
-
*/
|
| 428 |
-
private function getSubscription()
|
| 429 |
-
{
|
| 430 |
-
$subscriptionJson = '{
|
| 431 |
-
"resource": "subscription",
|
| 432 |
-
"id": "sub_DRjwaT5qHx",
|
| 433 |
-
"customerId": "cst_VhjQebNW5j",
|
| 434 |
-
"mode": "live",
|
| 435 |
-
"createdAt": "2018-07-17T07:45:52+00:00",
|
| 436 |
-
"status": "active",
|
| 437 |
-
"amount": {
|
| 438 |
-
"value": "10.00",
|
| 439 |
-
"currency": "EUR"
|
| 440 |
-
},
|
| 441 |
-
"description": "Mollie Recurring subscription #1",
|
| 442 |
-
"method": null,
|
| 443 |
-
"times": 42,
|
| 444 |
-
"interval": "15 days",
|
| 445 |
-
"startDate": "2018-12-12",
|
| 446 |
-
"webhookUrl": "https://example.org/webhook",
|
| 447 |
-
"_links": {
|
| 448 |
-
"self": {
|
| 449 |
-
"href": "http://api.mollie.test/v2/customers/cst_VhjQebNW5j/subscriptions/sub_DRjwaT5qHx",
|
| 450 |
-
"type": "application/hal+json"
|
| 451 |
-
},
|
| 452 |
-
"customer": {
|
| 453 |
-
"href": "http://api.mollie.test/v2/customers/cst_VhjQebNW5j",
|
| 454 |
-
"type": "application/hal+json"
|
| 455 |
-
},
|
| 456 |
-
"documentation": {
|
| 457 |
-
"href": "https://docs.mollie.com/reference/v2/subscriptions-api/update-subscription",
|
| 458 |
-
"type": "text/html"
|
| 459 |
-
}
|
| 460 |
-
}
|
| 461 |
-
}';
|
| 462 |
-
|
| 463 |
-
return $this->copy(json_decode($subscriptionJson), new Subscription($this->apiClient));
|
| 464 |
-
}
|
| 465 |
-
|
| 466 |
-
/**
|
| 467 |
-
* @return Customer
|
| 468 |
-
*/
|
| 469 |
-
private function getCustomer()
|
| 470 |
-
{
|
| 471 |
-
$customerJson = '{
|
| 472 |
-
"resource": "customer",
|
| 473 |
-
"id": "cst_FhQJRw4s2n",
|
| 474 |
-
"mode": "test",
|
| 475 |
-
"name": "John Doe",
|
| 476 |
-
"email": "johndoe@example.org",
|
| 477 |
-
"locale": null,
|
| 478 |
-
"metadata": null,
|
| 479 |
-
"recentlyUsedMethods": [],
|
| 480 |
-
"createdAt": "2018-04-19T08:49:01+00:00",
|
| 481 |
-
"_links": {
|
| 482 |
-
"documentation": {
|
| 483 |
-
"href": "https://docs.mollie.com/reference/v2/customers-api/get-customer",
|
| 484 |
-
"type": "text/html"
|
| 485 |
-
}
|
| 486 |
-
}
|
| 487 |
-
}';
|
| 488 |
-
|
| 489 |
-
return $this->copy(json_decode($customerJson), new Customer($this->apiClient));
|
| 490 |
-
}
|
| 491 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Exceptions/ApiExceptionTest.php
DELETED
|
@@ -1,89 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\API\Exceptions;
|
| 4 |
-
|
| 5 |
-
use GuzzleHttp\Exception\RequestException;
|
| 6 |
-
use GuzzleHttp\Psr7\Request;
|
| 7 |
-
use GuzzleHttp\Psr7\Response;
|
| 8 |
-
use Mollie\Api\Exceptions\ApiException;
|
| 9 |
-
use PHPUnit\Framework\TestCase;
|
| 10 |
-
use Tests\Mollie\TestHelpers\LinkObjectTestHelpers;
|
| 11 |
-
|
| 12 |
-
class ApiExceptionTest extends TestCase
|
| 13 |
-
{
|
| 14 |
-
use LinkObjectTestHelpers;
|
| 15 |
-
|
| 16 |
-
public function testCreateFromGuzzleException()
|
| 17 |
-
{
|
| 18 |
-
$response = new Response(
|
| 19 |
-
422,
|
| 20 |
-
[],
|
| 21 |
-
'{
|
| 22 |
-
"status": 422,
|
| 23 |
-
"title": "Unprocessable Entity",
|
| 24 |
-
"detail": "Can not enable Credit card via the API. Please go to the dashboard to enable this payment method.",
|
| 25 |
-
"_links": {
|
| 26 |
-
"dashboard": {
|
| 27 |
-
"href": "https://www.mollie.com/dashboard/settings/profiles/pfl_v9hTwCvYqw/payment-methods",
|
| 28 |
-
"type": "text/html"
|
| 29 |
-
},
|
| 30 |
-
"documentation": {
|
| 31 |
-
"href": "https://docs.mollie.com/guides/handling-errors",
|
| 32 |
-
"type": "text/html"
|
| 33 |
-
}
|
| 34 |
-
}
|
| 35 |
-
}'
|
| 36 |
-
);
|
| 37 |
-
|
| 38 |
-
$guzzleException = new RequestException(
|
| 39 |
-
'Something went wrong...',
|
| 40 |
-
new Request(
|
| 41 |
-
'POST',
|
| 42 |
-
'https://api.mollie.com/v2/profiles/pfl_v9hTwCvYqw/methods/bancontact'
|
| 43 |
-
),
|
| 44 |
-
$response
|
| 45 |
-
);
|
| 46 |
-
|
| 47 |
-
$exception = ApiException::createFromGuzzleException($guzzleException);
|
| 48 |
-
|
| 49 |
-
$this->assertInstanceOf(ApiException::class, $exception);
|
| 50 |
-
$this->assertInstanceOf(Response::class, $exception->getResponse());
|
| 51 |
-
|
| 52 |
-
$this->assertEquals($response, $exception->getResponse());
|
| 53 |
-
$this->assertTrue($exception->hasResponse());
|
| 54 |
-
|
| 55 |
-
$this->assertTrue($exception->hasLink('dashboard'));
|
| 56 |
-
$this->assertTrue($exception->hasLink('documentation'));
|
| 57 |
-
$this->assertFalse($exception->hasLink('foo'));
|
| 58 |
-
|
| 59 |
-
$this->assertLinkObject(
|
| 60 |
-
'https://www.mollie.com/dashboard/settings/profiles/pfl_v9hTwCvYqw/payment-methods',
|
| 61 |
-
'text/html',
|
| 62 |
-
$exception->getLink('dashboard')
|
| 63 |
-
);
|
| 64 |
-
|
| 65 |
-
$this->assertEquals(
|
| 66 |
-
'https://www.mollie.com/dashboard/settings/profiles/pfl_v9hTwCvYqw/payment-methods',
|
| 67 |
-
$exception->getUrl('dashboard')
|
| 68 |
-
);
|
| 69 |
-
|
| 70 |
-
$this->assertEquals(
|
| 71 |
-
'https://www.mollie.com/dashboard/settings/profiles/pfl_v9hTwCvYqw/payment-methods',
|
| 72 |
-
$exception->getDashboardUrl()
|
| 73 |
-
);
|
| 74 |
-
|
| 75 |
-
$this->assertLinkObject(
|
| 76 |
-
'https://docs.mollie.com/guides/handling-errors',
|
| 77 |
-
'text/html',
|
| 78 |
-
$exception->getLink('documentation')
|
| 79 |
-
);
|
| 80 |
-
|
| 81 |
-
$this->assertEquals(
|
| 82 |
-
'https://docs.mollie.com/guides/handling-errors',
|
| 83 |
-
$exception->getDocumentationUrl()
|
| 84 |
-
);
|
| 85 |
-
|
| 86 |
-
$this->assertNull($exception->getLink('foo'));
|
| 87 |
-
$this->assertNull($exception->getUrl('foo'));
|
| 88 |
-
}
|
| 89 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/MollieApiClientTest.php
DELETED
|
@@ -1,159 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
namespace Tests\Mollie\Api;
|
| 3 |
-
|
| 4 |
-
use Eloquent\Liberator\Liberator;
|
| 5 |
-
use GuzzleHttp\Client;
|
| 6 |
-
use GuzzleHttp\ClientInterface;
|
| 7 |
-
use GuzzleHttp\Psr7\Response;
|
| 8 |
-
use Mollie\Api\Exceptions\ApiException;
|
| 9 |
-
use Mollie\Api\MollieApiClient;
|
| 10 |
-
|
| 11 |
-
class MollieApiClientTest extends \PHPUnit\Framework\TestCase
|
| 12 |
-
{
|
| 13 |
-
/**
|
| 14 |
-
* @var ClientInterface|\PHPUnit_Framework_MockObject_MockObject
|
| 15 |
-
*/
|
| 16 |
-
private $guzzleClient;
|
| 17 |
-
|
| 18 |
-
/**
|
| 19 |
-
* @var MollieApiClient
|
| 20 |
-
*/
|
| 21 |
-
private $mollieApiClient;
|
| 22 |
-
|
| 23 |
-
protected function setUp()
|
| 24 |
-
{
|
| 25 |
-
parent::setUp();
|
| 26 |
-
|
| 27 |
-
$this->guzzleClient = $this->createMock(Client::class);
|
| 28 |
-
$this->mollieApiClient = new MollieApiClient($this->guzzleClient);
|
| 29 |
-
|
| 30 |
-
$this->mollieApiClient->setApiKey('test_foobarfoobarfoobarfoobarfoobar');
|
| 31 |
-
}
|
| 32 |
-
|
| 33 |
-
public function testPerformHttpCallReturnsBodyAsObject()
|
| 34 |
-
{
|
| 35 |
-
$response = new Response(200, [], '{"resource": "payment"}');
|
| 36 |
-
|
| 37 |
-
$this->guzzleClient
|
| 38 |
-
->expects($this->once())
|
| 39 |
-
->method('send')
|
| 40 |
-
->willReturn($response);
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
$parsedResponse = $this->mollieApiClient->performHttpCall('GET', '');
|
| 44 |
-
|
| 45 |
-
$this->assertEquals(
|
| 46 |
-
(object)['resource' => 'payment'],
|
| 47 |
-
$parsedResponse
|
| 48 |
-
);
|
| 49 |
-
}
|
| 50 |
-
|
| 51 |
-
public function testPerformHttpCallCreatesApiExceptionCorrectly()
|
| 52 |
-
{
|
| 53 |
-
$this->expectException(ApiException::class);
|
| 54 |
-
$this->expectExceptionMessage('Error executing API call (422: Unprocessable Entity): Non-existent parameter "recurringType" for this API call. Did you mean: "sequenceType"?');
|
| 55 |
-
$this->expectExceptionCode(422);
|
| 56 |
-
|
| 57 |
-
$response = new Response(422, [], '{
|
| 58 |
-
"status": 422,
|
| 59 |
-
"title": "Unprocessable Entity",
|
| 60 |
-
"detail": "Non-existent parameter \"recurringType\" for this API call. Did you mean: \"sequenceType\"?",
|
| 61 |
-
"field": "recurringType",
|
| 62 |
-
"_links": {
|
| 63 |
-
"documentation": {
|
| 64 |
-
"href": "https://docs.mollie.com/guides/handling-errors",
|
| 65 |
-
"type": "text/html"
|
| 66 |
-
}
|
| 67 |
-
}
|
| 68 |
-
}');
|
| 69 |
-
|
| 70 |
-
$this->guzzleClient
|
| 71 |
-
->expects($this->once())
|
| 72 |
-
->method('send')
|
| 73 |
-
->willReturn($response);
|
| 74 |
-
|
| 75 |
-
try {
|
| 76 |
-
$parsedResponse = $this->mollieApiClient->performHttpCall('GET', '');
|
| 77 |
-
} catch (ApiException $e) {
|
| 78 |
-
$this->assertEquals('recurringType', $e->getField());
|
| 79 |
-
$this->assertEquals('https://docs.mollie.com/guides/handling-errors', $e->getDocumentationUrl());
|
| 80 |
-
$this->assertEquals($response, $e->getResponse());
|
| 81 |
-
|
| 82 |
-
throw $e;
|
| 83 |
-
}
|
| 84 |
-
}
|
| 85 |
-
|
| 86 |
-
public function testPerformHttpCallCreatesApiExceptionWithoutFieldAndDocumentationUrl()
|
| 87 |
-
{
|
| 88 |
-
$this->expectException(ApiException::class);
|
| 89 |
-
$this->expectExceptionMessage('Error executing API call (422: Unprocessable Entity): Non-existent parameter "recurringType" for this API call. Did you mean: "sequenceType"?');
|
| 90 |
-
$this->expectExceptionCode(422);
|
| 91 |
-
|
| 92 |
-
$response = new Response(422, [], '{
|
| 93 |
-
"status": 422,
|
| 94 |
-
"title": "Unprocessable Entity",
|
| 95 |
-
"detail": "Non-existent parameter \"recurringType\" for this API call. Did you mean: \"sequenceType\"?"
|
| 96 |
-
}');
|
| 97 |
-
|
| 98 |
-
$this->guzzleClient
|
| 99 |
-
->expects($this->once())
|
| 100 |
-
->method('send')
|
| 101 |
-
->willReturn($response);
|
| 102 |
-
|
| 103 |
-
try {
|
| 104 |
-
$parsedResponse = $this->mollieApiClient->performHttpCall('GET', '');
|
| 105 |
-
} catch (ApiException $e) {
|
| 106 |
-
$this->assertNull($e->getField());
|
| 107 |
-
$this->assertNull($e->getDocumentationUrl());
|
| 108 |
-
$this->assertEquals($response, $e->getResponse());
|
| 109 |
-
|
| 110 |
-
throw $e;
|
| 111 |
-
}
|
| 112 |
-
}
|
| 113 |
-
|
| 114 |
-
public function testCanBeSerializedAndUnserialized()
|
| 115 |
-
{
|
| 116 |
-
$this->mollieApiClient->setApiEndpoint("https://mymollieproxy.local");
|
| 117 |
-
$serialized = \serialize($this->mollieApiClient);
|
| 118 |
-
|
| 119 |
-
$this->assertNotContains('test_foobarfoobarfoobarfoobarfoobar', $serialized, "API key should not be in serialized data or it will end up in caches.");
|
| 120 |
-
|
| 121 |
-
/** @var MollieApiClient $client_copy */
|
| 122 |
-
$client_copy = Liberator::liberate(unserialize($serialized));
|
| 123 |
-
|
| 124 |
-
$this->assertEmpty($client_copy->apiKey, "API key should not have been remembered");
|
| 125 |
-
$this->assertInstanceOf(ClientInterface::class, $client_copy->httpClient, "A Guzzle client should have been set.");
|
| 126 |
-
$this->assertNull($client_copy->usesOAuth());
|
| 127 |
-
$this->assertEquals("https://mymollieproxy.local", $client_copy->getApiEndpoint(), "The API endpoint should be remembered");
|
| 128 |
-
|
| 129 |
-
$this->assertNotEmpty($client_copy->customerPayments);
|
| 130 |
-
$this->assertNotEmpty($client_copy->payments);
|
| 131 |
-
$this->assertNotEmpty($client_copy->methods);
|
| 132 |
-
// no need to assert them all.
|
| 133 |
-
}
|
| 134 |
-
|
| 135 |
-
public function testResponseBodyCanBeReadMultipleTimesIfMiddlewareReadsItFirst()
|
| 136 |
-
{
|
| 137 |
-
$response = new Response(200, [], '{"resource": "payment"}');
|
| 138 |
-
|
| 139 |
-
// Before the MollieApiClient gets the response, some middleware reads the body first.
|
| 140 |
-
$bodyAsReadFromMiddleware = (string) $response->getBody();
|
| 141 |
-
|
| 142 |
-
$this->guzzleClient
|
| 143 |
-
->expects($this->once())
|
| 144 |
-
->method('send')
|
| 145 |
-
->willReturn($response);
|
| 146 |
-
|
| 147 |
-
$parsedResponse = $this->mollieApiClient->performHttpCall('GET', '');
|
| 148 |
-
|
| 149 |
-
$this->assertEquals(
|
| 150 |
-
'{"resource": "payment"}',
|
| 151 |
-
$bodyAsReadFromMiddleware
|
| 152 |
-
);
|
| 153 |
-
|
| 154 |
-
$this->assertEquals(
|
| 155 |
-
(object)['resource' => 'payment'],
|
| 156 |
-
$parsedResponse
|
| 157 |
-
);
|
| 158 |
-
}
|
| 159 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Resources/InvoiceTest.php
DELETED
|
@@ -1,42 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\Api\Resources;
|
| 4 |
-
|
| 5 |
-
use Mollie\Api\MollieApiClient;
|
| 6 |
-
use Mollie\Api\Resources\Invoice;
|
| 7 |
-
use Mollie\Api\Types\InvoiceStatus;
|
| 8 |
-
use PHPUnit\Framework\TestCase;
|
| 9 |
-
|
| 10 |
-
class InvoiceTest extends TestCase
|
| 11 |
-
{
|
| 12 |
-
/**
|
| 13 |
-
* @param string $status
|
| 14 |
-
* @param string $function
|
| 15 |
-
* @param boolean $expected_boolean
|
| 16 |
-
*
|
| 17 |
-
* @dataProvider dpTestInvoiceStatuses
|
| 18 |
-
*/
|
| 19 |
-
public function testInvoiceStatuses($status, $function, $expected_boolean)
|
| 20 |
-
{
|
| 21 |
-
$invoice = new Invoice($this->createMock(MollieApiClient::class));
|
| 22 |
-
$invoice->status = $status;
|
| 23 |
-
|
| 24 |
-
$this->assertEquals($expected_boolean, $invoice->{$function}());
|
| 25 |
-
}
|
| 26 |
-
public function dpTestInvoiceStatuses()
|
| 27 |
-
{
|
| 28 |
-
return [
|
| 29 |
-
[InvoiceStatus::STATUS_PAID, "isPaid", true],
|
| 30 |
-
[InvoiceStatus::STATUS_PAID, "isOpen", false],
|
| 31 |
-
[InvoiceStatus::STATUS_PAID, "isOverdue", false],
|
| 32 |
-
|
| 33 |
-
[InvoiceStatus::STATUS_OPEN, "isPaid", false],
|
| 34 |
-
[InvoiceStatus::STATUS_OPEN, "isOpen", true],
|
| 35 |
-
[InvoiceStatus::STATUS_OPEN, "isOverdue", false],
|
| 36 |
-
|
| 37 |
-
[InvoiceStatus::STATUS_OVERDUE, "isPaid", false],
|
| 38 |
-
[InvoiceStatus::STATUS_OVERDUE, "isOpen", false],
|
| 39 |
-
[InvoiceStatus::STATUS_OVERDUE, "isOverdue", true],
|
| 40 |
-
];
|
| 41 |
-
}
|
| 42 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Resources/OnboardingTest.php
DELETED
|
@@ -1,42 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\API\Resources;
|
| 4 |
-
|
| 5 |
-
use Mollie\Api\MollieApiClient;
|
| 6 |
-
use Mollie\Api\Resources\Onboarding;
|
| 7 |
-
use Mollie\Api\Types\OnboardingStatus;
|
| 8 |
-
|
| 9 |
-
class OnboardingTest extends \PHPUnit\Framework\TestCase
|
| 10 |
-
{
|
| 11 |
-
/**
|
| 12 |
-
* @param string $status
|
| 13 |
-
* @param string $function
|
| 14 |
-
* @param boolean $expected_boolean
|
| 15 |
-
*
|
| 16 |
-
* @dataProvider dpTestOnboardingStatuses
|
| 17 |
-
*/
|
| 18 |
-
public function testOnboardingStatuses($status, $function, $expected_boolean)
|
| 19 |
-
{
|
| 20 |
-
$orderLine = new Onboarding($this->createMock(MollieApiClient::class));
|
| 21 |
-
$orderLine->status = $status;
|
| 22 |
-
|
| 23 |
-
$this->assertEquals($expected_boolean, $orderLine->{$function}());
|
| 24 |
-
}
|
| 25 |
-
|
| 26 |
-
public function dpTestOnboardingStatuses()
|
| 27 |
-
{
|
| 28 |
-
return [
|
| 29 |
-
[OnboardingStatus::NEEDS_DATA, "needsData", true],
|
| 30 |
-
[OnboardingStatus::NEEDS_DATA, "isInReview", false],
|
| 31 |
-
[OnboardingStatus::NEEDS_DATA, "isCompleted", false],
|
| 32 |
-
|
| 33 |
-
[OnboardingStatus::IN_REVIEW, "needsData", false],
|
| 34 |
-
[OnboardingStatus::IN_REVIEW, "isInReview", true],
|
| 35 |
-
[OnboardingStatus::IN_REVIEW, "isCompleted", false],
|
| 36 |
-
|
| 37 |
-
[OnboardingStatus::COMPLETED, "needsData", false],
|
| 38 |
-
[OnboardingStatus::COMPLETED, "isInReview", false],
|
| 39 |
-
[OnboardingStatus::COMPLETED, "isCompleted", true],
|
| 40 |
-
];
|
| 41 |
-
}
|
| 42 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Resources/OrderLineCollectionTest.php
DELETED
|
@@ -1,36 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\Api\Resources;
|
| 4 |
-
|
| 5 |
-
use Mollie\Api\MollieApiClient;
|
| 6 |
-
use Mollie\Api\Resources\OrderLine;
|
| 7 |
-
use Mollie\Api\Resources\OrderLineCollection;
|
| 8 |
-
|
| 9 |
-
class OrderLineCollectionTest extends \PHPUnit\Framework\TestCase
|
| 10 |
-
{
|
| 11 |
-
public function testCanGetOrderLine()
|
| 12 |
-
{
|
| 13 |
-
$mockApi = $this->createMock(MollieApiClient::class);
|
| 14 |
-
$lines = new OrderLineCollection($mockApi, 3, []);
|
| 15 |
-
|
| 16 |
-
$line1 = new OrderLine($mockApi);
|
| 17 |
-
$line1->id = 'odl_aaaaaaaaaaa1';
|
| 18 |
-
|
| 19 |
-
$line2 = new OrderLine($mockApi);
|
| 20 |
-
$line2->id = 'odl_aaaaaaaaaaa2';
|
| 21 |
-
|
| 22 |
-
$line3 = new OrderLine($mockApi);
|
| 23 |
-
$line3->id = 'odl_aaaaaaaaaaa3';
|
| 24 |
-
|
| 25 |
-
$lines[] = $line1;
|
| 26 |
-
$lines[] = $line2;
|
| 27 |
-
$lines[] = $line3;
|
| 28 |
-
|
| 29 |
-
$this->assertNull($lines->get('odl_not_existent'));
|
| 30 |
-
|
| 31 |
-
$line = $lines->get('odl_aaaaaaaaaaa2');
|
| 32 |
-
|
| 33 |
-
$this->assertInstanceOf(OrderLine::class, $line);
|
| 34 |
-
$this->assertEquals($line2, $line);
|
| 35 |
-
}
|
| 36 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Resources/OrderLineTest.php
DELETED
|
@@ -1,149 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\Api\Resources;
|
| 4 |
-
|
| 5 |
-
use Mollie\Api\MollieApiClient;
|
| 6 |
-
use Mollie\Api\Resources\OrderLine;
|
| 7 |
-
use Mollie\Api\Types\OrderLineStatus;
|
| 8 |
-
use Mollie\Api\Types\OrderLineType;
|
| 9 |
-
|
| 10 |
-
class OrderLineTest extends \PHPUnit\Framework\TestCase
|
| 11 |
-
{
|
| 12 |
-
/**
|
| 13 |
-
* @param string $status
|
| 14 |
-
* @param string $function
|
| 15 |
-
* @param boolean $expected_boolean
|
| 16 |
-
*
|
| 17 |
-
* @dataProvider dpTestOrderLineStatuses
|
| 18 |
-
*/
|
| 19 |
-
public function testOrderLineStatuses($status, $function, $expected_boolean)
|
| 20 |
-
{
|
| 21 |
-
$orderLine = new OrderLine($this->createMock(MollieApiClient::class));
|
| 22 |
-
$orderLine->status = $status;
|
| 23 |
-
|
| 24 |
-
$this->assertEquals($expected_boolean, $orderLine->{$function}());
|
| 25 |
-
}
|
| 26 |
-
|
| 27 |
-
/**
|
| 28 |
-
* @param string $type
|
| 29 |
-
* @param string $function
|
| 30 |
-
* @param boolean $expected_boolean
|
| 31 |
-
*
|
| 32 |
-
* @dataProvider dpTestOrderLineTypes
|
| 33 |
-
*/
|
| 34 |
-
public function testOrderLineTypes($type, $function, $expected_boolean)
|
| 35 |
-
{
|
| 36 |
-
$orderLine = new OrderLine($this->createMock(MollieApiClient::class));
|
| 37 |
-
$orderLine->type = $type;
|
| 38 |
-
|
| 39 |
-
$this->assertEquals($expected_boolean, $orderLine->{$function}());
|
| 40 |
-
}
|
| 41 |
-
|
| 42 |
-
public function dpTestOrderLineTypes()
|
| 43 |
-
{
|
| 44 |
-
return [
|
| 45 |
-
[OrderLineType::TYPE_PHYSICAL, "isPhysical", true],
|
| 46 |
-
[OrderLineType::TYPE_PHYSICAL, "isDiscount", false],
|
| 47 |
-
[OrderLineType::TYPE_PHYSICAL, "isDigital", false],
|
| 48 |
-
[OrderLineType::TYPE_PHYSICAL, "isShippingFee", false],
|
| 49 |
-
[OrderLineType::TYPE_PHYSICAL, "isStoreCredit", false],
|
| 50 |
-
[OrderLineType::TYPE_PHYSICAL, "isGiftCard", false],
|
| 51 |
-
[OrderLineType::TYPE_PHYSICAL, "isSurcharge", false],
|
| 52 |
-
|
| 53 |
-
[OrderLineType::TYPE_DISCOUNT, "isPhysical", false],
|
| 54 |
-
[OrderLineType::TYPE_DISCOUNT, "isDiscount", true],
|
| 55 |
-
[OrderLineType::TYPE_DISCOUNT, "isDigital", false],
|
| 56 |
-
[OrderLineType::TYPE_DISCOUNT, "isShippingFee", false],
|
| 57 |
-
[OrderLineType::TYPE_DISCOUNT, "isStoreCredit", false],
|
| 58 |
-
[OrderLineType::TYPE_DISCOUNT, "isGiftCard", false],
|
| 59 |
-
[OrderLineType::TYPE_DISCOUNT, "isSurcharge", false],
|
| 60 |
-
|
| 61 |
-
[OrderLineType::TYPE_DIGITAL, "isPhysical", false],
|
| 62 |
-
[OrderLineType::TYPE_DIGITAL, "isDiscount", false],
|
| 63 |
-
[OrderLineType::TYPE_DIGITAL, "isDigital", true],
|
| 64 |
-
[OrderLineType::TYPE_DIGITAL, "isShippingFee", false],
|
| 65 |
-
[OrderLineType::TYPE_DIGITAL, "isStoreCredit", false],
|
| 66 |
-
[OrderLineType::TYPE_DIGITAL, "isGiftCard", false],
|
| 67 |
-
[OrderLineType::TYPE_DIGITAL, "isSurcharge", false],
|
| 68 |
-
|
| 69 |
-
[OrderLineType::TYPE_SHIPPING_FEE, "isPhysical", false],
|
| 70 |
-
[OrderLineType::TYPE_SHIPPING_FEE, "isDiscount", false],
|
| 71 |
-
[OrderLineType::TYPE_SHIPPING_FEE, "isDigital", false],
|
| 72 |
-
[OrderLineType::TYPE_SHIPPING_FEE, "isShippingFee", true],
|
| 73 |
-
[OrderLineType::TYPE_SHIPPING_FEE, "isStoreCredit", false],
|
| 74 |
-
[OrderLineType::TYPE_SHIPPING_FEE, "isGiftCard", false],
|
| 75 |
-
[OrderLineType::TYPE_SHIPPING_FEE, "isSurcharge", false],
|
| 76 |
-
|
| 77 |
-
[OrderLineType::TYPE_STORE_CREDIT, "isPhysical", false],
|
| 78 |
-
[OrderLineType::TYPE_STORE_CREDIT, "isDiscount", false],
|
| 79 |
-
[OrderLineType::TYPE_STORE_CREDIT, "isDigital", false],
|
| 80 |
-
[OrderLineType::TYPE_STORE_CREDIT, "isShippingFee", false],
|
| 81 |
-
[OrderLineType::TYPE_STORE_CREDIT, "isStoreCredit", true],
|
| 82 |
-
[OrderLineType::TYPE_STORE_CREDIT, "isGiftCard", false],
|
| 83 |
-
[OrderLineType::TYPE_STORE_CREDIT, "isSurcharge", false],
|
| 84 |
-
|
| 85 |
-
[OrderLineType::TYPE_GIFT_CARD, "isPhysical", false],
|
| 86 |
-
[OrderLineType::TYPE_GIFT_CARD, "isDiscount", false],
|
| 87 |
-
[OrderLineType::TYPE_GIFT_CARD, "isDigital", false],
|
| 88 |
-
[OrderLineType::TYPE_GIFT_CARD, "isShippingFee", false],
|
| 89 |
-
[OrderLineType::TYPE_GIFT_CARD, "isStoreCredit", false],
|
| 90 |
-
[OrderLineType::TYPE_GIFT_CARD, "isGiftCard", true],
|
| 91 |
-
[OrderLineType::TYPE_GIFT_CARD, "isSurcharge", false],
|
| 92 |
-
|
| 93 |
-
[OrderLineType::TYPE_SURCHARGE, "isPhysical", false],
|
| 94 |
-
[OrderLineType::TYPE_SURCHARGE, "isDiscount", false],
|
| 95 |
-
[OrderLineType::TYPE_SURCHARGE, "isDigital", false],
|
| 96 |
-
[OrderLineType::TYPE_SURCHARGE, "isShippingFee", false],
|
| 97 |
-
[OrderLineType::TYPE_SURCHARGE, "isStoreCredit", false],
|
| 98 |
-
[OrderLineType::TYPE_SURCHARGE, "isGiftCard", false],
|
| 99 |
-
[OrderLineType::TYPE_SURCHARGE, "isSurcharge", true],
|
| 100 |
-
];
|
| 101 |
-
}
|
| 102 |
-
|
| 103 |
-
public function dpTestOrderLineStatuses()
|
| 104 |
-
{
|
| 105 |
-
return [
|
| 106 |
-
[OrderLineStatus::STATUS_CREATED, "isCreated", true],
|
| 107 |
-
[OrderLineStatus::STATUS_CREATED, "isPaid", false],
|
| 108 |
-
[OrderLineStatus::STATUS_CREATED, "isAuthorized", false],
|
| 109 |
-
[OrderLineStatus::STATUS_CREATED, "isCanceled", false],
|
| 110 |
-
[OrderLineStatus::STATUS_CREATED, "isShipping", false],
|
| 111 |
-
[OrderLineStatus::STATUS_CREATED, "isCompleted", false],
|
| 112 |
-
|
| 113 |
-
[OrderLineStatus::STATUS_PAID, "isCreated", false],
|
| 114 |
-
[OrderLineStatus::STATUS_PAID, "isPaid", true],
|
| 115 |
-
[OrderLineStatus::STATUS_PAID, "isAuthorized", false],
|
| 116 |
-
[OrderLineStatus::STATUS_PAID, "isCanceled", false],
|
| 117 |
-
[OrderLineStatus::STATUS_PAID, "isShipping", false],
|
| 118 |
-
[OrderLineStatus::STATUS_PAID, "isCompleted", false],
|
| 119 |
-
|
| 120 |
-
[OrderLineStatus::STATUS_AUTHORIZED, "isCreated", false],
|
| 121 |
-
[OrderLineStatus::STATUS_AUTHORIZED, "isPaid", false],
|
| 122 |
-
[OrderLineStatus::STATUS_AUTHORIZED, "isAuthorized", true],
|
| 123 |
-
[OrderLineStatus::STATUS_AUTHORIZED, "isCanceled", false],
|
| 124 |
-
[OrderLineStatus::STATUS_AUTHORIZED, "isShipping", false],
|
| 125 |
-
[OrderLineStatus::STATUS_AUTHORIZED, "isCompleted", false],
|
| 126 |
-
|
| 127 |
-
[OrderLineStatus::STATUS_CANCELED, "isCreated", false],
|
| 128 |
-
[OrderLineStatus::STATUS_CANCELED, "isPaid", false],
|
| 129 |
-
[OrderLineStatus::STATUS_CANCELED, "isAuthorized", false],
|
| 130 |
-
[OrderLineStatus::STATUS_CANCELED, "isCanceled", true],
|
| 131 |
-
[OrderLineStatus::STATUS_CANCELED, "isShipping", false],
|
| 132 |
-
[OrderLineStatus::STATUS_CANCELED, "isCompleted", false],
|
| 133 |
-
|
| 134 |
-
[OrderLineStatus::STATUS_SHIPPING, "isCreated", false],
|
| 135 |
-
[OrderLineStatus::STATUS_SHIPPING, "isPaid", false],
|
| 136 |
-
[OrderLineStatus::STATUS_SHIPPING, "isAuthorized", false],
|
| 137 |
-
[OrderLineStatus::STATUS_SHIPPING, "isCanceled", false],
|
| 138 |
-
[OrderLineStatus::STATUS_SHIPPING, "isShipping", true],
|
| 139 |
-
[OrderLineStatus::STATUS_SHIPPING, "isCompleted", false],
|
| 140 |
-
|
| 141 |
-
[OrderLineStatus::STATUS_COMPLETED, "isCreated", false],
|
| 142 |
-
[OrderLineStatus::STATUS_COMPLETED, "isPaid", false],
|
| 143 |
-
[OrderLineStatus::STATUS_COMPLETED, "isAuthorized", false],
|
| 144 |
-
[OrderLineStatus::STATUS_COMPLETED, "isCanceled", false],
|
| 145 |
-
[OrderLineStatus::STATUS_COMPLETED, "isShipping", false],
|
| 146 |
-
[OrderLineStatus::STATUS_COMPLETED, "isCompleted", true],
|
| 147 |
-
];
|
| 148 |
-
}
|
| 149 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Resources/OrderTest.php
DELETED
|
@@ -1,295 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\Api\Resources;
|
| 4 |
-
|
| 5 |
-
use Mollie\Api\MollieApiClient;
|
| 6 |
-
use Mollie\Api\Resources\Order;
|
| 7 |
-
use Mollie\Api\Resources\OrderLine;
|
| 8 |
-
use Mollie\Api\Resources\OrderLineCollection;
|
| 9 |
-
use Mollie\Api\Types\OrderLineStatus;
|
| 10 |
-
use Mollie\Api\Types\OrderLineType;
|
| 11 |
-
use Mollie\Api\Types\OrderStatus;
|
| 12 |
-
use Tests\Mollie\TestHelpers\AmountObjectTestHelpers;
|
| 13 |
-
use Tests\Mollie\TestHelpers\LinkObjectTestHelpers;
|
| 14 |
-
use stdClass;
|
| 15 |
-
|
| 16 |
-
class OrderTest extends \PHPUnit\Framework\TestCase
|
| 17 |
-
{
|
| 18 |
-
use AmountObjectTestHelpers;
|
| 19 |
-
use LinkObjectTestHelpers;
|
| 20 |
-
|
| 21 |
-
/**
|
| 22 |
-
* @param string $status
|
| 23 |
-
* @param string $function
|
| 24 |
-
* @param boolean $expected_boolean
|
| 25 |
-
*
|
| 26 |
-
* @dataProvider dpTestOrderStatuses
|
| 27 |
-
*/
|
| 28 |
-
public function testOrderStatuses($status, $function, $expected_boolean)
|
| 29 |
-
{
|
| 30 |
-
$order = new Order($this->createMock(MollieApiClient::class));
|
| 31 |
-
$order->status = $status;
|
| 32 |
-
|
| 33 |
-
$this->assertEquals($expected_boolean, $order->{$function}());
|
| 34 |
-
}
|
| 35 |
-
|
| 36 |
-
public function dpTestOrderStatuses()
|
| 37 |
-
{
|
| 38 |
-
return [
|
| 39 |
-
[OrderStatus::STATUS_CREATED, "isCreated", true],
|
| 40 |
-
[OrderStatus::STATUS_CREATED, "isPaid", false],
|
| 41 |
-
[OrderStatus::STATUS_CREATED, "isAuthorized", false],
|
| 42 |
-
[OrderStatus::STATUS_CREATED, "isCanceled", false],
|
| 43 |
-
[OrderStatus::STATUS_CREATED, "isShipping", false],
|
| 44 |
-
[OrderStatus::STATUS_CREATED, "isCompleted", false],
|
| 45 |
-
[OrderStatus::STATUS_CREATED, "isExpired", false],
|
| 46 |
-
[OrderStatus::STATUS_CREATED, "isPending", false],
|
| 47 |
-
|
| 48 |
-
[OrderStatus::STATUS_PAID, "isCreated", false],
|
| 49 |
-
[OrderStatus::STATUS_PAID, "isPaid", true],
|
| 50 |
-
[OrderStatus::STATUS_PAID, "isAuthorized", false],
|
| 51 |
-
[OrderStatus::STATUS_PAID, "isCanceled", false],
|
| 52 |
-
[OrderStatus::STATUS_PAID, "isShipping", false],
|
| 53 |
-
[OrderStatus::STATUS_PAID, "isCompleted", false],
|
| 54 |
-
[OrderStatus::STATUS_PAID, "isExpired", false],
|
| 55 |
-
[OrderStatus::STATUS_PAID, "isPending", false],
|
| 56 |
-
|
| 57 |
-
[OrderStatus::STATUS_AUTHORIZED, "isCreated", false],
|
| 58 |
-
[OrderStatus::STATUS_AUTHORIZED, "isPaid", false],
|
| 59 |
-
[OrderStatus::STATUS_AUTHORIZED, "isAuthorized", true],
|
| 60 |
-
[OrderStatus::STATUS_AUTHORIZED, "isCanceled", false],
|
| 61 |
-
[OrderStatus::STATUS_AUTHORIZED, "isShipping", false],
|
| 62 |
-
[OrderStatus::STATUS_AUTHORIZED, "isCompleted", false],
|
| 63 |
-
[OrderStatus::STATUS_AUTHORIZED, "isExpired", false],
|
| 64 |
-
[OrderStatus::STATUS_AUTHORIZED, "isPending", false],
|
| 65 |
-
|
| 66 |
-
[OrderStatus::STATUS_CANCELED, "isCreated", false],
|
| 67 |
-
[OrderStatus::STATUS_CANCELED, "isPaid", false],
|
| 68 |
-
[OrderStatus::STATUS_CANCELED, "isAuthorized", false],
|
| 69 |
-
[OrderStatus::STATUS_CANCELED, "isCanceled", true],
|
| 70 |
-
[OrderStatus::STATUS_CANCELED, "isShipping", false],
|
| 71 |
-
[OrderStatus::STATUS_CANCELED, "isCompleted", false],
|
| 72 |
-
[OrderStatus::STATUS_CANCELED, "isExpired", false],
|
| 73 |
-
[OrderStatus::STATUS_CANCELED, "isPending", false],
|
| 74 |
-
|
| 75 |
-
[OrderStatus::STATUS_SHIPPING, "isCreated", false],
|
| 76 |
-
[OrderStatus::STATUS_SHIPPING, "isPaid", false],
|
| 77 |
-
[OrderStatus::STATUS_SHIPPING, "isAuthorized", false],
|
| 78 |
-
[OrderStatus::STATUS_SHIPPING, "isCanceled", false],
|
| 79 |
-
[OrderStatus::STATUS_SHIPPING, "isShipping", true],
|
| 80 |
-
[OrderStatus::STATUS_SHIPPING, "isCompleted", false],
|
| 81 |
-
[OrderStatus::STATUS_SHIPPING, "isExpired", false],
|
| 82 |
-
[OrderStatus::STATUS_SHIPPING, "isPending", false],
|
| 83 |
-
|
| 84 |
-
[OrderStatus::STATUS_COMPLETED, "isCreated", false],
|
| 85 |
-
[OrderStatus::STATUS_COMPLETED, "isPaid", false],
|
| 86 |
-
[OrderStatus::STATUS_COMPLETED, "isAuthorized", false],
|
| 87 |
-
[OrderStatus::STATUS_COMPLETED, "isCanceled", false],
|
| 88 |
-
[OrderStatus::STATUS_COMPLETED, "isShipping", false],
|
| 89 |
-
[OrderStatus::STATUS_COMPLETED, "isCompleted", true],
|
| 90 |
-
[OrderStatus::STATUS_COMPLETED, "isExpired", false],
|
| 91 |
-
[OrderStatus::STATUS_COMPLETED, "isPending", false],
|
| 92 |
-
|
| 93 |
-
[OrderStatus::STATUS_EXPIRED, "isCreated", false],
|
| 94 |
-
[OrderStatus::STATUS_EXPIRED, "isPaid", false],
|
| 95 |
-
[OrderStatus::STATUS_EXPIRED, "isAuthorized", false],
|
| 96 |
-
[OrderStatus::STATUS_EXPIRED, "isCanceled", false],
|
| 97 |
-
[OrderStatus::STATUS_EXPIRED, "isShipping", false],
|
| 98 |
-
[OrderStatus::STATUS_EXPIRED, "isCompleted", false],
|
| 99 |
-
[OrderStatus::STATUS_EXPIRED, "isExpired", true],
|
| 100 |
-
[OrderStatus::STATUS_EXPIRED, "isPending", false],
|
| 101 |
-
|
| 102 |
-
[OrderStatus::STATUS_PENDING, "isCreated", false],
|
| 103 |
-
[OrderStatus::STATUS_PENDING, "isPaid", false],
|
| 104 |
-
[OrderStatus::STATUS_PENDING, "isAuthorized", false],
|
| 105 |
-
[OrderStatus::STATUS_PENDING, "isCanceled", false],
|
| 106 |
-
[OrderStatus::STATUS_PENDING, "isShipping", false],
|
| 107 |
-
[OrderStatus::STATUS_PENDING, "isCompleted", false],
|
| 108 |
-
[OrderStatus::STATUS_PENDING, "isExpired", false],
|
| 109 |
-
[OrderStatus::STATUS_PENDING, "isPending", true],
|
| 110 |
-
];
|
| 111 |
-
}
|
| 112 |
-
|
| 113 |
-
public function testCanGetLinesAsResourcesOnOrderResource()
|
| 114 |
-
{
|
| 115 |
-
$order = new Order($this->createMock(MollieApiClient::class));
|
| 116 |
-
$orderLine = new stdClass;
|
| 117 |
-
$lineArray = [
|
| 118 |
-
'resource' => 'orderline',
|
| 119 |
-
'id' => 'odl_dgtxyl',
|
| 120 |
-
'orderId' => 'ord_pbjz8x',
|
| 121 |
-
'type' => 'physical',
|
| 122 |
-
'name' => 'LEGO 42083 Bugatti Chiron',
|
| 123 |
-
'productUrl' => 'https://shop.lego.com/nl-NL/Bugatti-Chiron-42083',
|
| 124 |
-
'imageUrl' => 'https://sh-s7-live-s.legocdn.com/is/image//LEGO/42083_alt1?$main$',
|
| 125 |
-
'sku' => '5702016116977',
|
| 126 |
-
'type' => 'physical',
|
| 127 |
-
'status' => 'created',
|
| 128 |
-
'quantity' => 2,
|
| 129 |
-
'unitPrice' => (object) [
|
| 130 |
-
'value' => '399.00',
|
| 131 |
-
'currency' => 'EUR',
|
| 132 |
-
],
|
| 133 |
-
'vatRate' => '21.00',
|
| 134 |
-
'vatAmount' => (object) [
|
| 135 |
-
'value' => '121.14',
|
| 136 |
-
'currency' => 'EUR',
|
| 137 |
-
],
|
| 138 |
-
'discountAmount' => (object) [
|
| 139 |
-
'value' => '100.00',
|
| 140 |
-
'currency' => 'EUR',
|
| 141 |
-
],
|
| 142 |
-
'totalAmount' => (object) [
|
| 143 |
-
'value' => '698.00',
|
| 144 |
-
'currency' => 'EUR',
|
| 145 |
-
],
|
| 146 |
-
'createdAt' => '2018-08-02T09:29:56+00:00',
|
| 147 |
-
];
|
| 148 |
-
|
| 149 |
-
foreach ($lineArray as $key => $value) {
|
| 150 |
-
$orderLine->{$key} = $value;
|
| 151 |
-
}
|
| 152 |
-
|
| 153 |
-
$order->lines = [$orderLine];
|
| 154 |
-
|
| 155 |
-
$lines = $order->lines();
|
| 156 |
-
|
| 157 |
-
$this->assertInstanceOf(OrderLineCollection::class, $lines);
|
| 158 |
-
$this->assertCount(1, $lines);
|
| 159 |
-
|
| 160 |
-
$line = $lines[0];
|
| 161 |
-
|
| 162 |
-
$this->assertInstanceOf(OrderLine::class, $line);
|
| 163 |
-
|
| 164 |
-
$this->assertEquals("orderline", $line->resource);
|
| 165 |
-
$this->assertEquals("odl_dgtxyl", $line->id);
|
| 166 |
-
$this->assertEquals('ord_pbjz8x', $line->orderId);
|
| 167 |
-
$this->assertEquals("LEGO 42083 Bugatti Chiron", $line->name);
|
| 168 |
-
$this->assertEquals("https://shop.lego.com/nl-NL/Bugatti-Chiron-42083", $line->productUrl);
|
| 169 |
-
$this->assertEquals('https://sh-s7-live-s.legocdn.com/is/image//LEGO/42083_alt1?$main$', $line->imageUrl);
|
| 170 |
-
$this->assertEquals("5702016116977", $line->sku);
|
| 171 |
-
$this->assertEquals(OrderLineType::TYPE_PHYSICAL, $line->type);
|
| 172 |
-
$this->assertEquals(OrderLineStatus::STATUS_CREATED, $line->status);
|
| 173 |
-
$this->assertEquals(2, $line->quantity);
|
| 174 |
-
$this->assertAmountObject("399.00", "EUR", $line->unitPrice);
|
| 175 |
-
$this->assertEquals("21.00", $line->vatRate);
|
| 176 |
-
$this->assertAmountObject("121.14", "EUR", $line->vatAmount);
|
| 177 |
-
$this->assertAmountObject("100.00", "EUR", $line->discountAmount);
|
| 178 |
-
$this->assertAmountObject("698.00", "EUR", $line->totalAmount);
|
| 179 |
-
$this->assertEquals("2018-08-02T09:29:56+00:00", $line->createdAt);
|
| 180 |
-
}
|
| 181 |
-
|
| 182 |
-
public function testCanGetPaymentsAsResourcesOnOrderResource()
|
| 183 |
-
{
|
| 184 |
-
$order = new Order($this->createMock(MollieApiClient::class));
|
| 185 |
-
$orderLine = new stdClass;
|
| 186 |
-
$lineArray = [
|
| 187 |
-
'resource' => 'orderline',
|
| 188 |
-
'id' => 'odl_dgtxyl',
|
| 189 |
-
'orderId' => 'ord_pbjz8x',
|
| 190 |
-
'type' => 'physical',
|
| 191 |
-
'name' => 'LEGO 42083 Bugatti Chiron',
|
| 192 |
-
'productUrl' => 'https://shop.lego.com/nl-NL/Bugatti-Chiron-42083',
|
| 193 |
-
'imageUrl' => 'https://sh-s7-live-s.legocdn.com/is/image//LEGO/42083_alt1?$main$',
|
| 194 |
-
'sku' => '5702016116977',
|
| 195 |
-
'type' => 'physical',
|
| 196 |
-
'status' => 'created',
|
| 197 |
-
'quantity' => 2,
|
| 198 |
-
'unitPrice' => (object) [
|
| 199 |
-
'value' => '399.00',
|
| 200 |
-
'currency' => 'EUR',
|
| 201 |
-
],
|
| 202 |
-
'vatRate' => '21.00',
|
| 203 |
-
'vatAmount' => (object) [
|
| 204 |
-
'value' => '121.14',
|
| 205 |
-
'currency' => 'EUR',
|
| 206 |
-
],
|
| 207 |
-
'discountAmount' => (object) [
|
| 208 |
-
'value' => '100.00',
|
| 209 |
-
'currency' => 'EUR',
|
| 210 |
-
],
|
| 211 |
-
'totalAmount' => (object) [
|
| 212 |
-
'value' => '698.00',
|
| 213 |
-
'currency' => 'EUR',
|
| 214 |
-
],
|
| 215 |
-
'createdAt' => '2018-08-02T09:29:56+00:00',
|
| 216 |
-
];
|
| 217 |
-
|
| 218 |
-
foreach ($lineArray as $key => $value) {
|
| 219 |
-
$orderLine->{$key} = $value;
|
| 220 |
-
}
|
| 221 |
-
|
| 222 |
-
$order->lines = [$orderLine];
|
| 223 |
-
|
| 224 |
-
$lines = $order->lines();
|
| 225 |
-
|
| 226 |
-
$this->assertInstanceOf(OrderLineCollection::class, $lines);
|
| 227 |
-
$this->assertCount(1, $lines);
|
| 228 |
-
|
| 229 |
-
$line = $lines[0];
|
| 230 |
-
|
| 231 |
-
$this->assertInstanceOf(OrderLine::class, $line);
|
| 232 |
-
|
| 233 |
-
$this->assertEquals("orderline", $line->resource);
|
| 234 |
-
$this->assertEquals("odl_dgtxyl", $line->id);
|
| 235 |
-
$this->assertEquals('ord_pbjz8x', $line->orderId);
|
| 236 |
-
$this->assertEquals("LEGO 42083 Bugatti Chiron", $line->name);
|
| 237 |
-
$this->assertEquals("https://shop.lego.com/nl-NL/Bugatti-Chiron-42083", $line->productUrl);
|
| 238 |
-
$this->assertEquals('https://sh-s7-live-s.legocdn.com/is/image//LEGO/42083_alt1?$main$', $line->imageUrl);
|
| 239 |
-
$this->assertEquals("5702016116977", $line->sku);
|
| 240 |
-
$this->assertEquals(OrderLineType::TYPE_PHYSICAL, $line->type);
|
| 241 |
-
$this->assertEquals(OrderLineStatus::STATUS_CREATED, $line->status);
|
| 242 |
-
$this->assertEquals(2, $line->quantity);
|
| 243 |
-
$this->assertAmountObject("399.00", "EUR", $line->unitPrice);
|
| 244 |
-
$this->assertEquals("21.00", $line->vatRate);
|
| 245 |
-
$this->assertAmountObject("121.14", "EUR", $line->vatAmount);
|
| 246 |
-
$this->assertAmountObject("100.00", "EUR", $line->discountAmount);
|
| 247 |
-
$this->assertAmountObject("698.00", "EUR", $line->totalAmount);
|
| 248 |
-
$this->assertEquals("2018-08-02T09:29:56+00:00", $line->createdAt);
|
| 249 |
-
}
|
| 250 |
-
|
| 251 |
-
public function testGetCheckoutUrlWorks()
|
| 252 |
-
{
|
| 253 |
-
$order = new Order($this->createMock(MollieApiClient::class));
|
| 254 |
-
$order->_links = $this->getOrderLinksDummy([
|
| 255 |
-
'checkout' => (object) [
|
| 256 |
-
'href' => 'https://www.some-mollie-checkout-url.com/123',
|
| 257 |
-
'type' => 'text/html',
|
| 258 |
-
]
|
| 259 |
-
]);
|
| 260 |
-
|
| 261 |
-
$this->assertEquals(
|
| 262 |
-
'https://www.some-mollie-checkout-url.com/123',
|
| 263 |
-
$order->getCheckoutUrl()
|
| 264 |
-
);
|
| 265 |
-
}
|
| 266 |
-
|
| 267 |
-
public function testGetCheckoutUrlReturnsNullIfNoCheckoutUrlAvailable()
|
| 268 |
-
{
|
| 269 |
-
$order = new Order($this->createMock(MollieApiClient::class));
|
| 270 |
-
$order->_links = $this->getOrderLinksDummy(['checkout' => null]);
|
| 271 |
-
|
| 272 |
-
$this->assertNull($order->getCheckoutUrl());
|
| 273 |
-
}
|
| 274 |
-
|
| 275 |
-
public function testPaymentsHelperReturnsIfNoEmbedAvailable()
|
| 276 |
-
{
|
| 277 |
-
$order = new Order($this->createMock(MollieApiClient::class));
|
| 278 |
-
$this->assertNull($order->payments());
|
| 279 |
-
}
|
| 280 |
-
|
| 281 |
-
public function testPaymentsHelperReturnsIfNoPaymentsEmbedded()
|
| 282 |
-
{
|
| 283 |
-
$order = new Order($this->createMock(MollieApiClient::class));
|
| 284 |
-
$order->_embedded = [];
|
| 285 |
-
$this->assertNull($order->payments());
|
| 286 |
-
}
|
| 287 |
-
|
| 288 |
-
protected function getOrderLinksDummy($overrides = [])
|
| 289 |
-
{
|
| 290 |
-
return (object) array_merge(
|
| 291 |
-
[],
|
| 292 |
-
$overrides
|
| 293 |
-
);
|
| 294 |
-
}
|
| 295 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Resources/PaymentTest.php
DELETED
|
@@ -1,212 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\Api\Resources;
|
| 4 |
-
|
| 5 |
-
use Mollie\Api\MollieApiClient;
|
| 6 |
-
use Mollie\Api\Resources\Payment;
|
| 7 |
-
use Mollie\Api\Types\PaymentStatus;
|
| 8 |
-
use Mollie\Api\Types\SequenceType;
|
| 9 |
-
use stdClass;
|
| 10 |
-
|
| 11 |
-
class PaymentTest extends \PHPUnit\Framework\TestCase
|
| 12 |
-
{
|
| 13 |
-
/**
|
| 14 |
-
* @param string $status
|
| 15 |
-
* @param string $function
|
| 16 |
-
* @param boolean $expected_boolean
|
| 17 |
-
*
|
| 18 |
-
* @dataProvider dpTestPaymentStatuses
|
| 19 |
-
*/
|
| 20 |
-
public function testPaymentStatuses($status, $function, $expected_boolean)
|
| 21 |
-
{
|
| 22 |
-
$payment = new Payment($this->createMock(MollieApiClient::class));
|
| 23 |
-
$payment->status = $status;
|
| 24 |
-
|
| 25 |
-
$this->assertEquals($expected_boolean, $payment->{$function}());
|
| 26 |
-
}
|
| 27 |
-
|
| 28 |
-
public function dpTestPaymentStatuses()
|
| 29 |
-
{
|
| 30 |
-
return [
|
| 31 |
-
[PaymentStatus::STATUS_PENDING, "isPending", true],
|
| 32 |
-
[PaymentStatus::STATUS_PENDING, "isAuthorized", false],
|
| 33 |
-
[PaymentStatus::STATUS_PENDING, "isFailed", false],
|
| 34 |
-
[PaymentStatus::STATUS_PENDING, "isOpen", false],
|
| 35 |
-
[PaymentStatus::STATUS_PENDING, "isCanceled", false],
|
| 36 |
-
[PaymentStatus::STATUS_PENDING, "isPaid", false],
|
| 37 |
-
[PaymentStatus::STATUS_PENDING, "isExpired", false],
|
| 38 |
-
|
| 39 |
-
[PaymentStatus::STATUS_AUTHORIZED, "isPending", false],
|
| 40 |
-
[PaymentStatus::STATUS_AUTHORIZED, "isAuthorized", true],
|
| 41 |
-
[PaymentStatus::STATUS_AUTHORIZED, "isFailed", false],
|
| 42 |
-
[PaymentStatus::STATUS_AUTHORIZED, "isOpen", false],
|
| 43 |
-
[PaymentStatus::STATUS_AUTHORIZED, "isCanceled", false],
|
| 44 |
-
[PaymentStatus::STATUS_AUTHORIZED, "isPaid", false],
|
| 45 |
-
[PaymentStatus::STATUS_AUTHORIZED, "isExpired", false],
|
| 46 |
-
|
| 47 |
-
[PaymentStatus::STATUS_FAILED, "isPending", false],
|
| 48 |
-
[PaymentStatus::STATUS_FAILED, "isAuthorized", false],
|
| 49 |
-
[PaymentStatus::STATUS_FAILED, "isFailed", true],
|
| 50 |
-
[PaymentStatus::STATUS_FAILED, "isOpen", false],
|
| 51 |
-
[PaymentStatus::STATUS_FAILED, "isCanceled", false],
|
| 52 |
-
[PaymentStatus::STATUS_FAILED, "isPaid", false],
|
| 53 |
-
[PaymentStatus::STATUS_FAILED, "isExpired", false],
|
| 54 |
-
|
| 55 |
-
[PaymentStatus::STATUS_OPEN, "isPending", false],
|
| 56 |
-
[PaymentStatus::STATUS_OPEN, "isAuthorized", false],
|
| 57 |
-
[PaymentStatus::STATUS_OPEN, "isFailed", false],
|
| 58 |
-
[PaymentStatus::STATUS_OPEN, "isOpen", true],
|
| 59 |
-
[PaymentStatus::STATUS_OPEN, "isCanceled", false],
|
| 60 |
-
[PaymentStatus::STATUS_OPEN, "isPaid", false],
|
| 61 |
-
[PaymentStatus::STATUS_OPEN, "isExpired", false],
|
| 62 |
-
|
| 63 |
-
[PaymentStatus::STATUS_CANCELED, "isPending", false],
|
| 64 |
-
[PaymentStatus::STATUS_CANCELED, "isAuthorized", false],
|
| 65 |
-
[PaymentStatus::STATUS_CANCELED, "isFailed", false],
|
| 66 |
-
[PaymentStatus::STATUS_CANCELED, "isOpen", false],
|
| 67 |
-
[PaymentStatus::STATUS_CANCELED, "isCanceled", true],
|
| 68 |
-
[PaymentStatus::STATUS_CANCELED, "isPaid", false],
|
| 69 |
-
[PaymentStatus::STATUS_CANCELED, "isExpired", false],
|
| 70 |
-
|
| 71 |
-
[PaymentStatus::STATUS_EXPIRED, "isPending", false],
|
| 72 |
-
[PaymentStatus::STATUS_EXPIRED, "isAuthorized", false],
|
| 73 |
-
[PaymentStatus::STATUS_EXPIRED, "isFailed", false],
|
| 74 |
-
[PaymentStatus::STATUS_EXPIRED, "isOpen", false],
|
| 75 |
-
[PaymentStatus::STATUS_EXPIRED, "isCanceled", false],
|
| 76 |
-
[PaymentStatus::STATUS_EXPIRED, "isPaid", false],
|
| 77 |
-
[PaymentStatus::STATUS_EXPIRED, "isExpired", true],
|
| 78 |
-
];
|
| 79 |
-
}
|
| 80 |
-
|
| 81 |
-
public function testIsPaidReturnsTrueWhenPaidDatetimeIsSet()
|
| 82 |
-
{
|
| 83 |
-
$payment = new Payment($this->createMock(MollieApiClient::class));
|
| 84 |
-
|
| 85 |
-
$payment->paidAt = "2016-10-24";
|
| 86 |
-
$this->assertTrue($payment->isPaid());
|
| 87 |
-
}
|
| 88 |
-
|
| 89 |
-
public function testHasRefundsReturnsTrueWhenPaymentHasRefunds()
|
| 90 |
-
{
|
| 91 |
-
$payment = new Payment($this->createMock(MollieApiClient::class));
|
| 92 |
-
|
| 93 |
-
$payment->_links = new stdClass();
|
| 94 |
-
$payment->_links->refunds = (object) ["href" => "https://api.mollie.com/v2/payments/tr_44aKxzEbr8/refunds", "type" => "application/hal+json"];
|
| 95 |
-
|
| 96 |
-
$this->assertTrue($payment->hasRefunds());
|
| 97 |
-
}
|
| 98 |
-
|
| 99 |
-
public function testHasRefundsReturnsFalseWhenPaymentHasNoRefunds()
|
| 100 |
-
{
|
| 101 |
-
$payment = new Payment($this->createMock(MollieApiClient::class));
|
| 102 |
-
|
| 103 |
-
$payment->_links = new stdClass();
|
| 104 |
-
$this->assertFalse($payment->hasRefunds());
|
| 105 |
-
}
|
| 106 |
-
|
| 107 |
-
public function testHasChargedbacksReturnsTrueWhenPaymentHasChargebacks()
|
| 108 |
-
{
|
| 109 |
-
$payment = new Payment($this->createMock(MollieApiClient::class));
|
| 110 |
-
|
| 111 |
-
$payment->_links = new stdClass();
|
| 112 |
-
$payment->_links->chargebacks = (object) ["href" => "https://api.mollie.com/v2/payments/tr_44aKxzEbr8/chargebacks", "type" => "application/hal+json"];
|
| 113 |
-
|
| 114 |
-
$this->assertTrue($payment->hasChargebacks());
|
| 115 |
-
}
|
| 116 |
-
|
| 117 |
-
public function testHasChargedbacksReturnsFalseWhenPaymentHasNoChargebacks()
|
| 118 |
-
{
|
| 119 |
-
$payment = new Payment($this->createMock(MollieApiClient::class));
|
| 120 |
-
|
| 121 |
-
$payment->_links = new stdClass();
|
| 122 |
-
$this->assertFalse($payment->hasChargebacks());
|
| 123 |
-
}
|
| 124 |
-
|
| 125 |
-
public function testHasRecurringTypeReturnsTrueWhenRecurringTypeIsFirst()
|
| 126 |
-
{
|
| 127 |
-
$payment = new Payment($this->createMock(MollieApiClient::class));
|
| 128 |
-
|
| 129 |
-
$payment->sequenceType = SequenceType::SEQUENCETYPE_FIRST;
|
| 130 |
-
$this->assertFalse($payment->hasSequenceTypeRecurring());
|
| 131 |
-
$this->assertTrue($payment->hasSequenceTypeFirst());
|
| 132 |
-
}
|
| 133 |
-
|
| 134 |
-
public function testHasRecurringTypeReturnsTrueWhenRecurringTypeIsRecurring()
|
| 135 |
-
{
|
| 136 |
-
$payment = new Payment($this->createMock(MollieApiClient::class));
|
| 137 |
-
|
| 138 |
-
$payment->sequenceType = SequenceType::SEQUENCETYPE_RECURRING;
|
| 139 |
-
$this->assertTrue($payment->hasSequenceTypeRecurring());
|
| 140 |
-
$this->assertFalse($payment->hasSequenceTypeFirst());
|
| 141 |
-
}
|
| 142 |
-
|
| 143 |
-
public function testHasRecurringTypeReturnsFalseWhenRecurringTypeIsNone()
|
| 144 |
-
{
|
| 145 |
-
$payment = new Payment($this->createMock(MollieApiClient::class));
|
| 146 |
-
|
| 147 |
-
$payment->sequenceType = SequenceType::SEQUENCETYPE_ONEOFF;
|
| 148 |
-
$this->assertFalse($payment->hasSequenceTypeFirst());
|
| 149 |
-
$this->assertFalse($payment->hasSequenceTypeRecurring());
|
| 150 |
-
}
|
| 151 |
-
|
| 152 |
-
public function testGetCheckoutUrlReturnsPaymentUrlFromLinksObject()
|
| 153 |
-
{
|
| 154 |
-
$payment = new Payment($this->createMock(MollieApiClient::class));
|
| 155 |
-
|
| 156 |
-
$payment->_links = new stdClass();
|
| 157 |
-
$payment->_links->checkout = new stdClass();
|
| 158 |
-
$payment->_links->checkout->href = "https://example.com";
|
| 159 |
-
|
| 160 |
-
$this->assertSame($payment->getCheckoutUrl(), "https://example.com");
|
| 161 |
-
}
|
| 162 |
-
|
| 163 |
-
public function testCanBeRefundedReturnsTrueWhenAmountRemainingIsSet()
|
| 164 |
-
{
|
| 165 |
-
$payment = new Payment($this->createMock(MollieApiClient::class));
|
| 166 |
-
|
| 167 |
-
$payment->amountRemaining = 15;
|
| 168 |
-
$this->assertTrue($payment->canBeRefunded());
|
| 169 |
-
$this->assertTrue($payment->canBePartiallyRefunded());
|
| 170 |
-
}
|
| 171 |
-
|
| 172 |
-
public function testCanBeRefundedReturnsFalseWhenAmountRemainingIsNull()
|
| 173 |
-
{
|
| 174 |
-
$payment = new Payment($this->createMock(MollieApiClient::class));
|
| 175 |
-
|
| 176 |
-
$payment->amountRemaining = null;
|
| 177 |
-
$this->assertFalse($payment->canBeRefunded());
|
| 178 |
-
$this->assertFalse($payment->canBePartiallyRefunded());
|
| 179 |
-
}
|
| 180 |
-
|
| 181 |
-
public function testGetAmountRefundedReturnsAmountRefundedAsFloat()
|
| 182 |
-
{
|
| 183 |
-
$payment = new Payment($this->createMock(MollieApiClient::class));
|
| 184 |
-
|
| 185 |
-
$payment->amountRefunded = (object)["value" => 22.0, "currency" => "EUR"];
|
| 186 |
-
self::assertSame(22.0, $payment->getAmountRefunded());
|
| 187 |
-
}
|
| 188 |
-
|
| 189 |
-
public function testGetAmountRefundedReturns0WhenAmountRefundedIsSetToNull()
|
| 190 |
-
{
|
| 191 |
-
$payment = new Payment($this->createMock(MollieApiClient::class));
|
| 192 |
-
|
| 193 |
-
$payment->amountRefunded = null;
|
| 194 |
-
self::assertSame(0.0, $payment->getAmountRefunded());
|
| 195 |
-
}
|
| 196 |
-
|
| 197 |
-
public function testGetAmountRemainingReturnsAmountRemainingAsFloat()
|
| 198 |
-
{
|
| 199 |
-
$payment = new Payment($this->createMock(MollieApiClient::class));
|
| 200 |
-
|
| 201 |
-
$payment->amountRemaining = (object)["value" => 22.0, "currency" => "EUR"];
|
| 202 |
-
self::assertSame(22.0, $payment->getAmountRemaining());
|
| 203 |
-
}
|
| 204 |
-
|
| 205 |
-
public function testGetAmountRemainingReturns0WhenAmountRemainingIsSetToNull()
|
| 206 |
-
{
|
| 207 |
-
$payment = new Payment($this->createMock(MollieApiClient::class));
|
| 208 |
-
|
| 209 |
-
$payment->amountRefunded = null;
|
| 210 |
-
self::assertSame(0.0, $payment->getAmountRemaining());
|
| 211 |
-
}
|
| 212 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Resources/ProfileTest.php
DELETED
|
@@ -1,42 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\Api\Resources;
|
| 4 |
-
|
| 5 |
-
use Mollie\Api\MollieApiClient;
|
| 6 |
-
use Mollie\Api\Resources\Profile;
|
| 7 |
-
use Mollie\Api\Types\ProfileStatus;
|
| 8 |
-
|
| 9 |
-
class ProfileTest extends \PHPUnit\Framework\TestCase
|
| 10 |
-
{
|
| 11 |
-
/**
|
| 12 |
-
* @param string $status
|
| 13 |
-
* @param string $function
|
| 14 |
-
* @param boolean $expected_boolean
|
| 15 |
-
*
|
| 16 |
-
* @dataProvider dpTestProfileStatusses
|
| 17 |
-
*/
|
| 18 |
-
public function testProfileStatusses($status, $function, $expected_boolean)
|
| 19 |
-
{
|
| 20 |
-
$profile = new Profile($this->createMock(MollieApiClient::class));
|
| 21 |
-
$profile->status = $status;
|
| 22 |
-
|
| 23 |
-
$this->assertEquals($expected_boolean, $profile->{$function}());
|
| 24 |
-
}
|
| 25 |
-
|
| 26 |
-
public function dpTestProfileStatusses()
|
| 27 |
-
{
|
| 28 |
-
return [
|
| 29 |
-
[ProfileStatus::STATUS_BLOCKED, "isBlocked", true],
|
| 30 |
-
[ProfileStatus::STATUS_BLOCKED, "isVerified", false],
|
| 31 |
-
[ProfileStatus::STATUS_BLOCKED, "isUnverified", false],
|
| 32 |
-
|
| 33 |
-
[ProfileStatus::STATUS_VERIFIED, "isBlocked", false],
|
| 34 |
-
[ProfileStatus::STATUS_VERIFIED, "isVerified", true],
|
| 35 |
-
[ProfileStatus::STATUS_VERIFIED, "isUnverified", false],
|
| 36 |
-
|
| 37 |
-
[ProfileStatus::STATUS_UNVERIFIED, "isBlocked", false],
|
| 38 |
-
[ProfileStatus::STATUS_UNVERIFIED, "isVerified", false],
|
| 39 |
-
[ProfileStatus::STATUS_UNVERIFIED, "isUnverified", true],
|
| 40 |
-
];
|
| 41 |
-
}
|
| 42 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Resources/RefundTest.php
DELETED
|
@@ -1,50 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\Api\Resources;
|
| 4 |
-
|
| 5 |
-
use Mollie\Api\MollieApiClient;
|
| 6 |
-
use Mollie\Api\Resources\Refund;
|
| 7 |
-
use Mollie\Api\Types\RefundStatus;
|
| 8 |
-
|
| 9 |
-
class RefundTest extends \PHPUnit\Framework\TestCase
|
| 10 |
-
{
|
| 11 |
-
/**
|
| 12 |
-
* @param string $status
|
| 13 |
-
* @param string $function
|
| 14 |
-
* @param boolean $expected_boolean
|
| 15 |
-
*
|
| 16 |
-
* @dataProvider dpTestRefundStatuses
|
| 17 |
-
*/
|
| 18 |
-
public function testRefundStatuses($status, $function, $expected_boolean)
|
| 19 |
-
{
|
| 20 |
-
$refund = new Refund($this->createMock(MollieApiClient::class));
|
| 21 |
-
$refund->status = $status;
|
| 22 |
-
|
| 23 |
-
$this->assertEquals($expected_boolean, $refund->{$function}());
|
| 24 |
-
}
|
| 25 |
-
|
| 26 |
-
public function dpTestRefundStatuses()
|
| 27 |
-
{
|
| 28 |
-
return [
|
| 29 |
-
[RefundStatus::STATUS_PENDING, "isPending", true],
|
| 30 |
-
[RefundStatus::STATUS_PENDING, "isProcessing", false],
|
| 31 |
-
[RefundStatus::STATUS_PENDING, "isQueued", false],
|
| 32 |
-
[RefundStatus::STATUS_PENDING, "isTransferred", false],
|
| 33 |
-
|
| 34 |
-
[RefundStatus::STATUS_PROCESSING, "isPending", false],
|
| 35 |
-
[RefundStatus::STATUS_PROCESSING, "isProcessing", true],
|
| 36 |
-
[RefundStatus::STATUS_PROCESSING, "isQueued", false],
|
| 37 |
-
[RefundStatus::STATUS_PROCESSING, "isTransferred", false],
|
| 38 |
-
|
| 39 |
-
[RefundStatus::STATUS_QUEUED, "isPending", false],
|
| 40 |
-
[RefundStatus::STATUS_QUEUED, "isProcessing", false],
|
| 41 |
-
[RefundStatus::STATUS_QUEUED, "isQueued", true],
|
| 42 |
-
[RefundStatus::STATUS_QUEUED, "isTransferred", false],
|
| 43 |
-
|
| 44 |
-
[RefundStatus::STATUS_REFUNDED, "isPending", false],
|
| 45 |
-
[RefundStatus::STATUS_REFUNDED, "isProcessing", false],
|
| 46 |
-
[RefundStatus::STATUS_REFUNDED, "isQueued", false],
|
| 47 |
-
[RefundStatus::STATUS_REFUNDED, "isTransferred", true],
|
| 48 |
-
];
|
| 49 |
-
}
|
| 50 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Resources/ResourceFactoryTest.php
DELETED
|
@@ -1,34 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\Api\Resources;
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
use Mollie\Api\MollieApiClient;
|
| 7 |
-
use Mollie\Api\Resources\Payment;
|
| 8 |
-
use Mollie\Api\Resources\ResourceFactory;
|
| 9 |
-
|
| 10 |
-
class ResourceFactoryTest extends \PHPUnit\Framework\TestCase
|
| 11 |
-
{
|
| 12 |
-
public function testCreateFromApiResponseWorks()
|
| 13 |
-
{
|
| 14 |
-
$apiResult = json_decode('{
|
| 15 |
-
"resource":"payment",
|
| 16 |
-
"id":"tr_44aKxzEbr8",
|
| 17 |
-
"mode":"test",
|
| 18 |
-
"createdAt":"2018-03-13T14:02:29+00:00",
|
| 19 |
-
"amount":{
|
| 20 |
-
"value":"20.00",
|
| 21 |
-
"currency":"EUR"
|
| 22 |
-
}
|
| 23 |
-
}');
|
| 24 |
-
|
| 25 |
-
$payment = ResourceFactory::createFromApiResult($apiResult, new Payment($this->createMock(MollieApiClient::class)));
|
| 26 |
-
|
| 27 |
-
$this->assertInstanceOf(Payment::class, $payment);
|
| 28 |
-
$this->assertEquals("payment", $payment->resource);
|
| 29 |
-
$this->assertEquals("tr_44aKxzEbr8", $payment->id);
|
| 30 |
-
$this->assertEquals("test", $payment->mode);
|
| 31 |
-
$this->assertEquals("2018-03-13T14:02:29+00:00", $payment->createdAt);
|
| 32 |
-
$this->assertEquals((object) ["value" => "20.00", "currency" => "EUR"], $payment->amount);
|
| 33 |
-
}
|
| 34 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Resources/SettlementTest.php
DELETED
|
@@ -1,50 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\Api\Resources;
|
| 4 |
-
|
| 5 |
-
use Mollie\Api\MollieApiClient;
|
| 6 |
-
use Mollie\Api\Resources\Settlement;
|
| 7 |
-
use Mollie\Api\Types\SettlementStatus;
|
| 8 |
-
|
| 9 |
-
class SettlementTest extends \PHPUnit\Framework\TestCase
|
| 10 |
-
{
|
| 11 |
-
/**
|
| 12 |
-
* @param string $status
|
| 13 |
-
* @param string $function
|
| 14 |
-
* @param boolean $expected_boolean
|
| 15 |
-
*
|
| 16 |
-
* @dataProvider dpTestSettlementStatuses
|
| 17 |
-
*/
|
| 18 |
-
public function testSettlementStatuses($status, $function, $expected_boolean)
|
| 19 |
-
{
|
| 20 |
-
$settlement = new Settlement($this->createMock(MollieApiClient::class));
|
| 21 |
-
$settlement->status = $status;
|
| 22 |
-
|
| 23 |
-
$this->assertEquals($expected_boolean, $settlement->{$function}());
|
| 24 |
-
}
|
| 25 |
-
|
| 26 |
-
public function dpTestSettlementStatuses()
|
| 27 |
-
{
|
| 28 |
-
return [
|
| 29 |
-
[SettlementStatus::STATUS_PENDING, "isPending", true],
|
| 30 |
-
[SettlementStatus::STATUS_PENDING, "isOpen", false],
|
| 31 |
-
[SettlementStatus::STATUS_PENDING, "isPaidout", false],
|
| 32 |
-
[SettlementStatus::STATUS_PENDING, "isFailed", false],
|
| 33 |
-
|
| 34 |
-
[SettlementStatus::STATUS_OPEN, "isPending", false],
|
| 35 |
-
[SettlementStatus::STATUS_OPEN, "isOpen", true],
|
| 36 |
-
[SettlementStatus::STATUS_OPEN, "isPaidout", false],
|
| 37 |
-
[SettlementStatus::STATUS_OPEN, "isFailed", false],
|
| 38 |
-
|
| 39 |
-
[SettlementStatus::STATUS_PAIDOUT, "isPending", false],
|
| 40 |
-
[SettlementStatus::STATUS_PAIDOUT, "isOpen", false],
|
| 41 |
-
[SettlementStatus::STATUS_PAIDOUT, "isPaidout", true],
|
| 42 |
-
[SettlementStatus::STATUS_PAIDOUT, "isFailed", false],
|
| 43 |
-
|
| 44 |
-
[SettlementStatus::STATUS_FAILED, "isPending", false],
|
| 45 |
-
[SettlementStatus::STATUS_FAILED, "isOpen", false],
|
| 46 |
-
[SettlementStatus::STATUS_FAILED, "isPaidout", false],
|
| 47 |
-
[SettlementStatus::STATUS_FAILED, "isFailed", true],
|
| 48 |
-
];
|
| 49 |
-
}
|
| 50 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Resources/ShipmentTest.php
DELETED
|
@@ -1,84 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\Api\Resources;
|
| 4 |
-
|
| 5 |
-
use Mollie\Api\MollieApiClient;
|
| 6 |
-
use Mollie\Api\Resources\Shipment;
|
| 7 |
-
use PHPUnit\Framework\TestCase;
|
| 8 |
-
|
| 9 |
-
class ShipmentTest extends TestCase
|
| 10 |
-
{
|
| 11 |
-
public function testHasTrackingReturnsTrueIfObjectNotNull()
|
| 12 |
-
{
|
| 13 |
-
$shipment = new Shipment($this->createMock(MollieApiClient::class));
|
| 14 |
-
$shipment->tracking = $this->getTrackingDummy();
|
| 15 |
-
$this->assertTrue($shipment->hasTracking());
|
| 16 |
-
}
|
| 17 |
-
|
| 18 |
-
public function testHasTrackingReturnsFalseIfObjectIsNull()
|
| 19 |
-
{
|
| 20 |
-
$shipment = new Shipment($this->createMock(MollieApiClient::class));
|
| 21 |
-
$shipment->tracking = null;
|
| 22 |
-
$this->assertFalse($shipment->hasTracking());
|
| 23 |
-
}
|
| 24 |
-
|
| 25 |
-
public function testHasTrackingUrlReturnsFalseIfTrackingIsNotSet()
|
| 26 |
-
{
|
| 27 |
-
$shipment = new Shipment($this->createMock(MollieApiClient::class));
|
| 28 |
-
$shipment->tracking = null;
|
| 29 |
-
$this->assertFalse($shipment->hasTrackingUrl());
|
| 30 |
-
}
|
| 31 |
-
|
| 32 |
-
public function testHasTrackingUrlReturnsTrueIfUrlIsSet()
|
| 33 |
-
{
|
| 34 |
-
$shipment = new Shipment($this->createMock(MollieApiClient::class));
|
| 35 |
-
$shipment->tracking = $this->getTrackingDummy([
|
| 36 |
-
'url' => 'https://www.some-tracking-url.com/123',
|
| 37 |
-
]);
|
| 38 |
-
$this->assertTrue($shipment->hasTrackingUrl());
|
| 39 |
-
}
|
| 40 |
-
|
| 41 |
-
public function testHasTrackingUrlReturnsFalseIfUrlIsNotSet()
|
| 42 |
-
{
|
| 43 |
-
$shipment = new Shipment($this->createMock(MollieApiClient::class));
|
| 44 |
-
$shipment->tracking = $this->getTrackingDummy([
|
| 45 |
-
'url' => null,
|
| 46 |
-
]);
|
| 47 |
-
$this->assertFalse($shipment->hasTrackingUrl());
|
| 48 |
-
}
|
| 49 |
-
|
| 50 |
-
public function testGetTrackingUrlReturnsNullIfNotAvailable()
|
| 51 |
-
{
|
| 52 |
-
$shipment = new Shipment($this->createMock(MollieApiClient::class));
|
| 53 |
-
|
| 54 |
-
$shipment->tracking = null;
|
| 55 |
-
$this->assertNull($shipment->getTrackingUrl());
|
| 56 |
-
|
| 57 |
-
$shipment->tracking = $this->getTrackingDummy([
|
| 58 |
-
'url' => null,
|
| 59 |
-
]);
|
| 60 |
-
$this->assertNull($shipment->getTrackingUrl());
|
| 61 |
-
}
|
| 62 |
-
|
| 63 |
-
public function testGetTrackingUrlReturnsUrlIfAvailable()
|
| 64 |
-
{
|
| 65 |
-
$shipment = new Shipment($this->createMock(MollieApiClient::class));
|
| 66 |
-
$shipment->tracking = $this->getTrackingDummy([
|
| 67 |
-
'url' => 'https://www.some-tracking-url.com/123',
|
| 68 |
-
]);
|
| 69 |
-
|
| 70 |
-
$this->assertEquals(
|
| 71 |
-
'https://www.some-tracking-url.com/123',
|
| 72 |
-
$shipment->getTrackingUrl()
|
| 73 |
-
);
|
| 74 |
-
}
|
| 75 |
-
|
| 76 |
-
protected function getTrackingDummy($overrides = [])
|
| 77 |
-
{
|
| 78 |
-
return (object) array_merge([
|
| 79 |
-
'carrier' => 'DummyCarrier',
|
| 80 |
-
'code' => '123456ABCD',
|
| 81 |
-
'url' => 'https://www.example.org/tracktrace/1234',
|
| 82 |
-
], $overrides);
|
| 83 |
-
}
|
| 84 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Resources/SubscriptionTest.php
DELETED
|
@@ -1,60 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\Api\Resources;
|
| 4 |
-
|
| 5 |
-
use Mollie\Api\MollieApiClient;
|
| 6 |
-
use Mollie\Api\Resources\Subscription;
|
| 7 |
-
use Mollie\Api\Types\SubscriptionStatus;
|
| 8 |
-
|
| 9 |
-
class SubscriptionTest extends \PHPUnit\Framework\TestCase
|
| 10 |
-
{
|
| 11 |
-
/**
|
| 12 |
-
* @param string $status
|
| 13 |
-
* @param string $function
|
| 14 |
-
* @param boolean $expected_boolean
|
| 15 |
-
*
|
| 16 |
-
* @dataProvider dpTestSubscriptionStatuses
|
| 17 |
-
*/
|
| 18 |
-
public function testSubscriptionStatuses($status, $function, $expected_boolean)
|
| 19 |
-
{
|
| 20 |
-
$subscription = new Subscription($this->createMock(MollieApiClient::class));
|
| 21 |
-
$subscription->status = $status;
|
| 22 |
-
|
| 23 |
-
$this->assertEquals($expected_boolean, $subscription->{$function}());
|
| 24 |
-
}
|
| 25 |
-
|
| 26 |
-
public function dpTestSubscriptionStatuses()
|
| 27 |
-
{
|
| 28 |
-
return [
|
| 29 |
-
[SubscriptionStatus::STATUS_PENDING, "isPending", true],
|
| 30 |
-
[SubscriptionStatus::STATUS_PENDING, "isCanceled", false],
|
| 31 |
-
[SubscriptionStatus::STATUS_PENDING, "isCompleted", false],
|
| 32 |
-
[SubscriptionStatus::STATUS_PENDING, "isSuspended", false],
|
| 33 |
-
[SubscriptionStatus::STATUS_PENDING, "isActive", false],
|
| 34 |
-
|
| 35 |
-
[SubscriptionStatus::STATUS_CANCELED, "isPending", false],
|
| 36 |
-
[SubscriptionStatus::STATUS_CANCELED, "isCanceled", true],
|
| 37 |
-
[SubscriptionStatus::STATUS_CANCELED, "isCompleted", false],
|
| 38 |
-
[SubscriptionStatus::STATUS_CANCELED, "isSuspended", false],
|
| 39 |
-
[SubscriptionStatus::STATUS_CANCELED, "isActive", false],
|
| 40 |
-
|
| 41 |
-
[SubscriptionStatus::STATUS_COMPLETED, "isPending", false],
|
| 42 |
-
[SubscriptionStatus::STATUS_COMPLETED, "isCanceled", false],
|
| 43 |
-
[SubscriptionStatus::STATUS_COMPLETED, "isCompleted", true],
|
| 44 |
-
[SubscriptionStatus::STATUS_COMPLETED, "isSuspended", false],
|
| 45 |
-
[SubscriptionStatus::STATUS_COMPLETED, "isActive", false],
|
| 46 |
-
|
| 47 |
-
[SubscriptionStatus::STATUS_SUSPENDED, "isPending", false],
|
| 48 |
-
[SubscriptionStatus::STATUS_SUSPENDED, "isCanceled", false],
|
| 49 |
-
[SubscriptionStatus::STATUS_SUSPENDED, "isCompleted", false],
|
| 50 |
-
[SubscriptionStatus::STATUS_SUSPENDED, "isSuspended", true],
|
| 51 |
-
[SubscriptionStatus::STATUS_SUSPENDED, "isActive", false],
|
| 52 |
-
|
| 53 |
-
[SubscriptionStatus::STATUS_ACTIVE, "isPending", false],
|
| 54 |
-
[SubscriptionStatus::STATUS_ACTIVE, "isCanceled", false],
|
| 55 |
-
[SubscriptionStatus::STATUS_ACTIVE, "isCompleted", false],
|
| 56 |
-
[SubscriptionStatus::STATUS_ACTIVE, "isSuspended", false],
|
| 57 |
-
[SubscriptionStatus::STATUS_ACTIVE, "isActive", true],
|
| 58 |
-
];
|
| 59 |
-
}
|
| 60 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/API/Types/MandateMethodTest.php
DELETED
|
@@ -1,37 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\API\Types;
|
| 4 |
-
|
| 5 |
-
use Mollie\Api\Types\MandateMethod;
|
| 6 |
-
use Mollie\Api\Types\PaymentMethod;
|
| 7 |
-
use PHPUnit\Framework\TestCase;
|
| 8 |
-
|
| 9 |
-
class MandateMethodTest extends TestCase
|
| 10 |
-
{
|
| 11 |
-
/**
|
| 12 |
-
* @param string $firstPaymentMethod
|
| 13 |
-
* @param string $expectedMethod
|
| 14 |
-
* @dataProvider dpTestGetForFirstPaymentMethod
|
| 15 |
-
*/
|
| 16 |
-
public function testGetForFirstPaymentMethod($firstPaymentMethod, $expectedMethod)
|
| 17 |
-
{
|
| 18 |
-
$actualMethod = MandateMethod::getForFirstPaymentMethod($firstPaymentMethod);
|
| 19 |
-
$this->assertEquals($expectedMethod, $actualMethod);
|
| 20 |
-
}
|
| 21 |
-
|
| 22 |
-
public function dpTestGetForFirstPaymentMethod()
|
| 23 |
-
{
|
| 24 |
-
return [
|
| 25 |
-
[PaymentMethod::APPLEPAY, MandateMethod::CREDITCARD],
|
| 26 |
-
[PaymentMethod::CREDITCARD, MandateMethod::CREDITCARD],
|
| 27 |
-
[PaymentMethod::BANCONTACT, MandateMethod::DIRECTDEBIT],
|
| 28 |
-
[PaymentMethod::BELFIUS, MandateMethod::DIRECTDEBIT],
|
| 29 |
-
[PaymentMethod::EPS, MandateMethod::DIRECTDEBIT],
|
| 30 |
-
[PaymentMethod::GIROPAY, MandateMethod::DIRECTDEBIT],
|
| 31 |
-
[PaymentMethod::IDEAL, MandateMethod::DIRECTDEBIT],
|
| 32 |
-
[PaymentMethod::INGHOMEPAY, MandateMethod::DIRECTDEBIT],
|
| 33 |
-
[PaymentMethod::KBC, MandateMethod::DIRECTDEBIT],
|
| 34 |
-
[PaymentMethod::SOFORT, MandateMethod::DIRECTDEBIT],
|
| 35 |
-
];
|
| 36 |
-
}
|
| 37 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/TestHelpers/AmountObjectTestHelpers.php
DELETED
|
@@ -1,22 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\TestHelpers;
|
| 4 |
-
|
| 5 |
-
trait AmountObjectTestHelpers
|
| 6 |
-
{
|
| 7 |
-
protected function assertAmountObject($value, $currency, $amountObject)
|
| 8 |
-
{
|
| 9 |
-
return $this->assertEquals(
|
| 10 |
-
$this->createAmountObject($value, $currency),
|
| 11 |
-
$amountObject
|
| 12 |
-
);
|
| 13 |
-
}
|
| 14 |
-
|
| 15 |
-
protected function createAmountObject($value, $currency)
|
| 16 |
-
{
|
| 17 |
-
return (object) [
|
| 18 |
-
'value' => $value,
|
| 19 |
-
'currency' => $currency,
|
| 20 |
-
];
|
| 21 |
-
}
|
| 22 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/tests/Mollie/TestHelpers/LinkObjectTestHelpers.php
DELETED
|
@@ -1,29 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
namespace Tests\Mollie\TestHelpers;
|
| 4 |
-
|
| 5 |
-
trait LinkObjectTestHelpers
|
| 6 |
-
{
|
| 7 |
-
protected function assertLinkObject($href, $type, $linkObject)
|
| 8 |
-
{
|
| 9 |
-
return $this->assertEquals(
|
| 10 |
-
$this->createLinkObject($href, $type),
|
| 11 |
-
$linkObject
|
| 12 |
-
);
|
| 13 |
-
}
|
| 14 |
-
|
| 15 |
-
protected function createNamedLinkObject($name, $href, $type)
|
| 16 |
-
{
|
| 17 |
-
return (object) [
|
| 18 |
-
$name => $this->createLinkObject($href, $type),
|
| 19 |
-
];
|
| 20 |
-
}
|
| 21 |
-
|
| 22 |
-
protected function createLinkObject($href, $type)
|
| 23 |
-
{
|
| 24 |
-
return (object) [
|
| 25 |
-
'href' => $href,
|
| 26 |
-
'type' => $type,
|
| 27 |
-
];
|
| 28 |
-
}
|
| 29 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/mollie-api-php/vendor/autoload.php
CHANGED
|
@@ -4,4 +4,4 @@
|
|
| 4 |
|
| 5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
| 6 |
|
| 7 |
-
return
|
| 4 |
|
| 5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
| 6 |
|
| 7 |
+
return ComposerAutoloaderInit42ba6b9fccd44e6582bb4dfeab7736a9::getLoader();
|
includes/mollie-api-php/vendor/composer/autoload_classmap.php
CHANGED
|
@@ -6,166 +6,4 @@ $vendorDir = dirname(dirname(__FILE__));
|
|
| 6 |
$baseDir = dirname($vendorDir);
|
| 7 |
|
| 8 |
return array(
|
| 9 |
-
'Composer\\CaBundle\\CaBundle' => $vendorDir . '/composer/ca-bundle/src/CaBundle.php',
|
| 10 |
-
'GuzzleHttp\\Client' => $vendorDir . '/guzzlehttp/guzzle/src/Client.php',
|
| 11 |
-
'GuzzleHttp\\ClientInterface' => $vendorDir . '/guzzlehttp/guzzle/src/ClientInterface.php',
|
| 12 |
-
'GuzzleHttp\\Cookie\\CookieJar' => $vendorDir . '/guzzlehttp/guzzle/src/Cookie/CookieJar.php',
|
| 13 |
-
'GuzzleHttp\\Cookie\\CookieJarInterface' => $vendorDir . '/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php',
|
| 14 |
-
'GuzzleHttp\\Cookie\\FileCookieJar' => $vendorDir . '/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php',
|
| 15 |
-
'GuzzleHttp\\Cookie\\SessionCookieJar' => $vendorDir . '/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php',
|
| 16 |
-
'GuzzleHttp\\Cookie\\SetCookie' => $vendorDir . '/guzzlehttp/guzzle/src/Cookie/SetCookie.php',
|
| 17 |
-
'GuzzleHttp\\Exception\\BadResponseException' => $vendorDir . '/guzzlehttp/guzzle/src/Exception/BadResponseException.php',
|
| 18 |
-
'GuzzleHttp\\Exception\\ClientException' => $vendorDir . '/guzzlehttp/guzzle/src/Exception/ClientException.php',
|
| 19 |
-
'GuzzleHttp\\Exception\\ConnectException' => $vendorDir . '/guzzlehttp/guzzle/src/Exception/ConnectException.php',
|
| 20 |
-
'GuzzleHttp\\Exception\\GuzzleException' => $vendorDir . '/guzzlehttp/guzzle/src/Exception/GuzzleException.php',
|
| 21 |
-
'GuzzleHttp\\Exception\\RequestException' => $vendorDir . '/guzzlehttp/guzzle/src/Exception/RequestException.php',
|
| 22 |
-
'GuzzleHttp\\Exception\\SeekException' => $vendorDir . '/guzzlehttp/guzzle/src/Exception/SeekException.php',
|
| 23 |
-
'GuzzleHttp\\Exception\\ServerException' => $vendorDir . '/guzzlehttp/guzzle/src/Exception/ServerException.php',
|
| 24 |
-
'GuzzleHttp\\Exception\\TooManyRedirectsException' => $vendorDir . '/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php',
|
| 25 |
-
'GuzzleHttp\\Exception\\TransferException' => $vendorDir . '/guzzlehttp/guzzle/src/Exception/TransferException.php',
|
| 26 |
-
'GuzzleHttp\\HandlerStack' => $vendorDir . '/guzzlehttp/guzzle/src/HandlerStack.php',
|
| 27 |
-
'GuzzleHttp\\Handler\\CurlFactory' => $vendorDir . '/guzzlehttp/guzzle/src/Handler/CurlFactory.php',
|
| 28 |
-
'GuzzleHttp\\Handler\\CurlFactoryInterface' => $vendorDir . '/guzzlehttp/guzzle/src/Handler/CurlFactoryInterface.php',
|
| 29 |
-
'GuzzleHttp\\Handler\\CurlHandler' => $vendorDir . '/guzzlehttp/guzzle/src/Handler/CurlHandler.php',
|
| 30 |
-
'GuzzleHttp\\Handler\\CurlMultiHandler' => $vendorDir . '/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php',
|
| 31 |
-
'GuzzleHttp\\Handler\\EasyHandle' => $vendorDir . '/guzzlehttp/guzzle/src/Handler/EasyHandle.php',
|
| 32 |
-
'GuzzleHttp\\Handler\\MockHandler' => $vendorDir . '/guzzlehttp/guzzle/src/Handler/MockHandler.php',
|
| 33 |
-
'GuzzleHttp\\Handler\\Proxy' => $vendorDir . '/guzzlehttp/guzzle/src/Handler/Proxy.php',
|
| 34 |
-
'GuzzleHttp\\Handler\\StreamHandler' => $vendorDir . '/guzzlehttp/guzzle/src/Handler/StreamHandler.php',
|
| 35 |
-
'GuzzleHttp\\MessageFormatter' => $vendorDir . '/guzzlehttp/guzzle/src/MessageFormatter.php',
|
| 36 |
-
'GuzzleHttp\\Middleware' => $vendorDir . '/guzzlehttp/guzzle/src/Middleware.php',
|
| 37 |
-
'GuzzleHttp\\Pool' => $vendorDir . '/guzzlehttp/guzzle/src/Pool.php',
|
| 38 |
-
'GuzzleHttp\\PrepareBodyMiddleware' => $vendorDir . '/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php',
|
| 39 |
-
'GuzzleHttp\\Promise\\AggregateException' => $vendorDir . '/guzzlehttp/promises/src/AggregateException.php',
|
| 40 |
-
'GuzzleHttp\\Promise\\CancellationException' => $vendorDir . '/guzzlehttp/promises/src/CancellationException.php',
|
| 41 |
-
'GuzzleHttp\\Promise\\Coroutine' => $vendorDir . '/guzzlehttp/promises/src/Coroutine.php',
|
| 42 |
-
'GuzzleHttp\\Promise\\EachPromise' => $vendorDir . '/guzzlehttp/promises/src/EachPromise.php',
|
| 43 |
-
'GuzzleHttp\\Promise\\FulfilledPromise' => $vendorDir . '/guzzlehttp/promises/src/FulfilledPromise.php',
|
| 44 |
-
'GuzzleHttp\\Promise\\Promise' => $vendorDir . '/guzzlehttp/promises/src/Promise.php',
|
| 45 |
-
'GuzzleHttp\\Promise\\PromiseInterface' => $vendorDir . '/guzzlehttp/promises/src/PromiseInterface.php',
|
| 46 |
-
'GuzzleHttp\\Promise\\PromisorInterface' => $vendorDir . '/guzzlehttp/promises/src/PromisorInterface.php',
|
| 47 |
-
'GuzzleHttp\\Promise\\RejectedPromise' => $vendorDir . '/guzzlehttp/promises/src/RejectedPromise.php',
|
| 48 |
-
'GuzzleHttp\\Promise\\RejectionException' => $vendorDir . '/guzzlehttp/promises/src/RejectionException.php',
|
| 49 |
-
'GuzzleHttp\\Promise\\TaskQueue' => $vendorDir . '/guzzlehttp/promises/src/TaskQueue.php',
|
| 50 |
-
'GuzzleHttp\\Promise\\TaskQueueInterface' => $vendorDir . '/guzzlehttp/promises/src/TaskQueueInterface.php',
|
| 51 |
-
'GuzzleHttp\\Psr7\\AppendStream' => $vendorDir . '/guzzlehttp/psr7/src/AppendStream.php',
|
| 52 |
-
'GuzzleHttp\\Psr7\\BufferStream' => $vendorDir . '/guzzlehttp/psr7/src/BufferStream.php',
|
| 53 |
-
'GuzzleHttp\\Psr7\\CachingStream' => $vendorDir . '/guzzlehttp/psr7/src/CachingStream.php',
|
| 54 |
-
'GuzzleHttp\\Psr7\\DroppingStream' => $vendorDir . '/guzzlehttp/psr7/src/DroppingStream.php',
|
| 55 |
-
'GuzzleHttp\\Psr7\\FnStream' => $vendorDir . '/guzzlehttp/psr7/src/FnStream.php',
|
| 56 |
-
'GuzzleHttp\\Psr7\\InflateStream' => $vendorDir . '/guzzlehttp/psr7/src/InflateStream.php',
|
| 57 |
-
'GuzzleHttp\\Psr7\\LazyOpenStream' => $vendorDir . '/guzzlehttp/psr7/src/LazyOpenStream.php',
|
| 58 |
-
'GuzzleHttp\\Psr7\\LimitStream' => $vendorDir . '/guzzlehttp/psr7/src/LimitStream.php',
|
| 59 |
-
'GuzzleHttp\\Psr7\\MessageTrait' => $vendorDir . '/guzzlehttp/psr7/src/MessageTrait.php',
|
| 60 |
-
'GuzzleHttp\\Psr7\\MultipartStream' => $vendorDir . '/guzzlehttp/psr7/src/MultipartStream.php',
|
| 61 |
-
'GuzzleHttp\\Psr7\\NoSeekStream' => $vendorDir . '/guzzlehttp/psr7/src/NoSeekStream.php',
|
| 62 |
-
'GuzzleHttp\\Psr7\\PumpStream' => $vendorDir . '/guzzlehttp/psr7/src/PumpStream.php',
|
| 63 |
-
'GuzzleHttp\\Psr7\\Request' => $vendorDir . '/guzzlehttp/psr7/src/Request.php',
|
| 64 |
-
'GuzzleHttp\\Psr7\\Response' => $vendorDir . '/guzzlehttp/psr7/src/Response.php',
|
| 65 |
-
'GuzzleHttp\\Psr7\\Rfc7230' => $vendorDir . '/guzzlehttp/psr7/src/Rfc7230.php',
|
| 66 |
-
'GuzzleHttp\\Psr7\\ServerRequest' => $vendorDir . '/guzzlehttp/psr7/src/ServerRequest.php',
|
| 67 |
-
'GuzzleHttp\\Psr7\\Stream' => $vendorDir . '/guzzlehttp/psr7/src/Stream.php',
|
| 68 |
-
'GuzzleHttp\\Psr7\\StreamDecoratorTrait' => $vendorDir . '/guzzlehttp/psr7/src/StreamDecoratorTrait.php',
|
| 69 |
-
'GuzzleHttp\\Psr7\\StreamWrapper' => $vendorDir . '/guzzlehttp/psr7/src/StreamWrapper.php',
|
| 70 |
-
'GuzzleHttp\\Psr7\\UploadedFile' => $vendorDir . '/guzzlehttp/psr7/src/UploadedFile.php',
|
| 71 |
-
'GuzzleHttp\\Psr7\\Uri' => $vendorDir . '/guzzlehttp/psr7/src/Uri.php',
|
| 72 |
-
'GuzzleHttp\\Psr7\\UriNormalizer' => $vendorDir . '/guzzlehttp/psr7/src/UriNormalizer.php',
|
| 73 |
-
'GuzzleHttp\\Psr7\\UriResolver' => $vendorDir . '/guzzlehttp/psr7/src/UriResolver.php',
|
| 74 |
-
'GuzzleHttp\\RedirectMiddleware' => $vendorDir . '/guzzlehttp/guzzle/src/RedirectMiddleware.php',
|
| 75 |
-
'GuzzleHttp\\RequestOptions' => $vendorDir . '/guzzlehttp/guzzle/src/RequestOptions.php',
|
| 76 |
-
'GuzzleHttp\\RetryMiddleware' => $vendorDir . '/guzzlehttp/guzzle/src/RetryMiddleware.php',
|
| 77 |
-
'GuzzleHttp\\TransferStats' => $vendorDir . '/guzzlehttp/guzzle/src/TransferStats.php',
|
| 78 |
-
'GuzzleHttp\\UriTemplate' => $vendorDir . '/guzzlehttp/guzzle/src/UriTemplate.php',
|
| 79 |
-
'Mollie\\Api\\CompatibilityChecker' => $baseDir . '/src/CompatibilityChecker.php',
|
| 80 |
-
'Mollie\\Api\\Endpoints\\ChargebackEndpoint' => $baseDir . '/src/Endpoints/ChargebackEndpoint.php',
|
| 81 |
-
'Mollie\\Api\\Endpoints\\CollectionEndpointAbstract' => $baseDir . '/src/Endpoints/CollectionEndpointAbstract.php',
|
| 82 |
-
'Mollie\\Api\\Endpoints\\CustomerEndpoint' => $baseDir . '/src/Endpoints/CustomerEndpoint.php',
|
| 83 |
-
'Mollie\\Api\\Endpoints\\CustomerPaymentsEndpoint' => $baseDir . '/src/Endpoints/CustomerPaymentsEndpoint.php',
|
| 84 |
-
'Mollie\\Api\\Endpoints\\EndpointAbstract' => $baseDir . '/src/Endpoints/EndpointAbstract.php',
|
| 85 |
-
'Mollie\\Api\\Endpoints\\InvoiceEndpoint' => $baseDir . '/src/Endpoints/InvoiceEndpoint.php',
|
| 86 |
-
'Mollie\\Api\\Endpoints\\MandateEndpoint' => $baseDir . '/src/Endpoints/MandateEndpoint.php',
|
| 87 |
-
'Mollie\\Api\\Endpoints\\MethodEndpoint' => $baseDir . '/src/Endpoints/MethodEndpoint.php',
|
| 88 |
-
'Mollie\\Api\\Endpoints\\OnboardingEndpoint' => $baseDir . '/src/Endpoints/OnboardingEndpoint.php',
|
| 89 |
-
'Mollie\\Api\\Endpoints\\OrderEndpoint' => $baseDir . '/src/Endpoints/OrderEndpoint.php',
|
| 90 |
-
'Mollie\\Api\\Endpoints\\OrderLineEndpoint' => $baseDir . '/src/Endpoints/OrderLineEndpoint.php',
|
| 91 |
-
'Mollie\\Api\\Endpoints\\OrderPaymentEndpoint' => $baseDir . '/src/Endpoints/OrderPaymentEndpoint.php',
|
| 92 |
-
'Mollie\\Api\\Endpoints\\OrderRefundEndpoint' => $baseDir . '/src/Endpoints/OrderRefundEndpoint.php',
|
| 93 |
-
'Mollie\\Api\\Endpoints\\OrganizationEndpoint' => $baseDir . '/src/Endpoints/OrganizationEndpoint.php',
|
| 94 |
-
'Mollie\\Api\\Endpoints\\PaymentCaptureEndpoint' => $baseDir . '/src/Endpoints/PaymentCaptureEndpoint.php',
|
| 95 |
-
'Mollie\\Api\\Endpoints\\PaymentChargebackEndpoint' => $baseDir . '/src/Endpoints/PaymentChargebackEndpoint.php',
|
| 96 |
-
'Mollie\\Api\\Endpoints\\PaymentEndpoint' => $baseDir . '/src/Endpoints/PaymentEndpoint.php',
|
| 97 |
-
'Mollie\\Api\\Endpoints\\PaymentRefundEndpoint' => $baseDir . '/src/Endpoints/PaymentRefundEndpoint.php',
|
| 98 |
-
'Mollie\\Api\\Endpoints\\PermissionEndpoint' => $baseDir . '/src/Endpoints/PermissionEndpoint.php',
|
| 99 |
-
'Mollie\\Api\\Endpoints\\ProfileEndpoint' => $baseDir . '/src/Endpoints/ProfileEndpoint.php',
|
| 100 |
-
'Mollie\\Api\\Endpoints\\ProfileMethodEndpoint' => $baseDir . '/src/Endpoints/ProfileMethodEndpoint.php',
|
| 101 |
-
'Mollie\\Api\\Endpoints\\RefundEndpoint' => $baseDir . '/src/Endpoints/RefundEndpoint.php',
|
| 102 |
-
'Mollie\\Api\\Endpoints\\SettlementsEndpoint' => $baseDir . '/src/Endpoints/SettlementsEndpoint.php',
|
| 103 |
-
'Mollie\\Api\\Endpoints\\ShipmentEndpoint' => $baseDir . '/src/Endpoints/ShipmentEndpoint.php',
|
| 104 |
-
'Mollie\\Api\\Endpoints\\SubscriptionEndpoint' => $baseDir . '/src/Endpoints/SubscriptionEndpoint.php',
|
| 105 |
-
'Mollie\\Api\\Exceptions\\ApiException' => $baseDir . '/src/Exceptions/ApiException.php',
|
| 106 |
-
'Mollie\\Api\\Exceptions\\IncompatiblePlatform' => $baseDir . '/src/Exceptions/IncompatiblePlatform.php',
|
| 107 |
-
'Mollie\\Api\\MollieApiClient' => $baseDir . '/src/MollieApiClient.php',
|
| 108 |
-
'Mollie\\Api\\Resources\\BaseCollection' => $baseDir . '/src/Resources/BaseCollection.php',
|
| 109 |
-
'Mollie\\Api\\Resources\\BaseResource' => $baseDir . '/src/Resources/BaseResource.php',
|
| 110 |
-
'Mollie\\Api\\Resources\\Capture' => $baseDir . '/src/Resources/Capture.php',
|
| 111 |
-
'Mollie\\Api\\Resources\\CaptureCollection' => $baseDir . '/src/Resources/CaptureCollection.php',
|
| 112 |
-
'Mollie\\Api\\Resources\\Chargeback' => $baseDir . '/src/Resources/Chargeback.php',
|
| 113 |
-
'Mollie\\Api\\Resources\\ChargebackCollection' => $baseDir . '/src/Resources/ChargebackCollection.php',
|
| 114 |
-
'Mollie\\Api\\Resources\\CurrentProfile' => $baseDir . '/src/Resources/CurrentProfile.php',
|
| 115 |
-
'Mollie\\Api\\Resources\\CursorCollection' => $baseDir . '/src/Resources/CursorCollection.php',
|
| 116 |
-
'Mollie\\Api\\Resources\\Customer' => $baseDir . '/src/Resources/Customer.php',
|
| 117 |
-
'Mollie\\Api\\Resources\\CustomerCollection' => $baseDir . '/src/Resources/CustomerCollection.php',
|
| 118 |
-
'Mollie\\Api\\Resources\\Invoice' => $baseDir . '/src/Resources/Invoice.php',
|
| 119 |
-
'Mollie\\Api\\Resources\\InvoiceCollection' => $baseDir . '/src/Resources/InvoiceCollection.php',
|
| 120 |
-
'Mollie\\Api\\Resources\\Issuer' => $baseDir . '/src/Resources/Issuer.php',
|
| 121 |
-
'Mollie\\Api\\Resources\\IssuerCollection' => $baseDir . '/src/Resources/IssuerCollection.php',
|
| 122 |
-
'Mollie\\Api\\Resources\\Mandate' => $baseDir . '/src/Resources/Mandate.php',
|
| 123 |
-
'Mollie\\Api\\Resources\\MandateCollection' => $baseDir . '/src/Resources/MandateCollection.php',
|
| 124 |
-
'Mollie\\Api\\Resources\\Method' => $baseDir . '/src/Resources/Method.php',
|
| 125 |
-
'Mollie\\Api\\Resources\\MethodCollection' => $baseDir . '/src/Resources/MethodCollection.php',
|
| 126 |
-
'Mollie\\Api\\Resources\\MethodPrice' => $baseDir . '/src/Resources/MethodPrice.php',
|
| 127 |
-
'Mollie\\Api\\Resources\\MethodPriceCollection' => $baseDir . '/src/Resources/MethodPriceCollection.php',
|
| 128 |
-
'Mollie\\Api\\Resources\\Onboarding' => $baseDir . '/src/Resources/Onboarding.php',
|
| 129 |
-
'Mollie\\Api\\Resources\\Order' => $baseDir . '/src/Resources/Order.php',
|
| 130 |
-
'Mollie\\Api\\Resources\\OrderCollection' => $baseDir . '/src/Resources/OrderCollection.php',
|
| 131 |
-
'Mollie\\Api\\Resources\\OrderLine' => $baseDir . '/src/Resources/OrderLine.php',
|
| 132 |
-
'Mollie\\Api\\Resources\\OrderLineCollection' => $baseDir . '/src/Resources/OrderLineCollection.php',
|
| 133 |
-
'Mollie\\Api\\Resources\\Organization' => $baseDir . '/src/Resources/Organization.php',
|
| 134 |
-
'Mollie\\Api\\Resources\\OrganizationCollection' => $baseDir . '/src/Resources/OrganizationCollection.php',
|
| 135 |
-
'Mollie\\Api\\Resources\\Payment' => $baseDir . '/src/Resources/Payment.php',
|
| 136 |
-
'Mollie\\Api\\Resources\\PaymentCollection' => $baseDir . '/src/Resources/PaymentCollection.php',
|
| 137 |
-
'Mollie\\Api\\Resources\\Permission' => $baseDir . '/src/Resources/Permission.php',
|
| 138 |
-
'Mollie\\Api\\Resources\\PermissionCollection' => $baseDir . '/src/Resources/PermissionCollection.php',
|
| 139 |
-
'Mollie\\Api\\Resources\\Profile' => $baseDir . '/src/Resources/Profile.php',
|
| 140 |
-
'Mollie\\Api\\Resources\\ProfileCollection' => $baseDir . '/src/Resources/ProfileCollection.php',
|
| 141 |
-
'Mollie\\Api\\Resources\\Refund' => $baseDir . '/src/Resources/Refund.php',
|
| 142 |
-
'Mollie\\Api\\Resources\\RefundCollection' => $baseDir . '/src/Resources/RefundCollection.php',
|
| 143 |
-
'Mollie\\Api\\Resources\\ResourceFactory' => $baseDir . '/src/Resources/ResourceFactory.php',
|
| 144 |
-
'Mollie\\Api\\Resources\\Settlement' => $baseDir . '/src/Resources/Settlement.php',
|
| 145 |
-
'Mollie\\Api\\Resources\\SettlementCollection' => $baseDir . '/src/Resources/SettlementCollection.php',
|
| 146 |
-
'Mollie\\Api\\Resources\\Shipment' => $baseDir . '/src/Resources/Shipment.php',
|
| 147 |
-
'Mollie\\Api\\Resources\\ShipmentCollection' => $baseDir . '/src/Resources/ShipmentCollection.php',
|
| 148 |
-
'Mollie\\Api\\Resources\\Subscription' => $baseDir . '/src/Resources/Subscription.php',
|
| 149 |
-
'Mollie\\Api\\Resources\\SubscriptionCollection' => $baseDir . '/src/Resources/SubscriptionCollection.php',
|
| 150 |
-
'Mollie\\Api\\Types\\InvoiceStatus' => $baseDir . '/src/Types/InvoiceStatus.php',
|
| 151 |
-
'Mollie\\Api\\Types\\MandateMethod' => $baseDir . '/src/Types/MandateMethod.php',
|
| 152 |
-
'Mollie\\Api\\Types\\MandateStatus' => $baseDir . '/src/Types/MandateStatus.php',
|
| 153 |
-
'Mollie\\Api\\Types\\OnboardingStatus' => $baseDir . '/src/Types/OnboardingStatus.php',
|
| 154 |
-
'Mollie\\Api\\Types\\OrderLineStatus' => $baseDir . '/src/Types/OrderLineStatus.php',
|
| 155 |
-
'Mollie\\Api\\Types\\OrderLineType' => $baseDir . '/src/Types/OrderLineType.php',
|
| 156 |
-
'Mollie\\Api\\Types\\OrderStatus' => $baseDir . '/src/Types/OrderStatus.php',
|
| 157 |
-
'Mollie\\Api\\Types\\PaymentMethod' => $baseDir . '/src/Types/PaymentMethod.php',
|
| 158 |
-
'Mollie\\Api\\Types\\PaymentStatus' => $baseDir . '/src/Types/PaymentStatus.php',
|
| 159 |
-
'Mollie\\Api\\Types\\ProfileStatus' => $baseDir . '/src/Types/ProfileStatus.php',
|
| 160 |
-
'Mollie\\Api\\Types\\RefundStatus' => $baseDir . '/src/Types/RefundStatus.php',
|
| 161 |
-
'Mollie\\Api\\Types\\SequenceType' => $baseDir . '/src/Types/SequenceType.php',
|
| 162 |
-
'Mollie\\Api\\Types\\SettlementStatus' => $baseDir . '/src/Types/SettlementStatus.php',
|
| 163 |
-
'Mollie\\Api\\Types\\SubscriptionStatus' => $baseDir . '/src/Types/SubscriptionStatus.php',
|
| 164 |
-
'Psr\\Http\\Message\\MessageInterface' => $vendorDir . '/psr/http-message/src/MessageInterface.php',
|
| 165 |
-
'Psr\\Http\\Message\\RequestInterface' => $vendorDir . '/psr/http-message/src/RequestInterface.php',
|
| 166 |
-
'Psr\\Http\\Message\\ResponseInterface' => $vendorDir . '/psr/http-message/src/ResponseInterface.php',
|
| 167 |
-
'Psr\\Http\\Message\\ServerRequestInterface' => $vendorDir . '/psr/http-message/src/ServerRequestInterface.php',
|
| 168 |
-
'Psr\\Http\\Message\\StreamInterface' => $vendorDir . '/psr/http-message/src/StreamInterface.php',
|
| 169 |
-
'Psr\\Http\\Message\\UploadedFileInterface' => $vendorDir . '/psr/http-message/src/UploadedFileInterface.php',
|
| 170 |
-
'Psr\\Http\\Message\\UriInterface' => $vendorDir . '/psr/http-message/src/UriInterface.php',
|
| 171 |
);
|
| 6 |
$baseDir = dirname($vendorDir);
|
| 7 |
|
| 8 |
return array(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
);
|
includes/mollie-api-php/vendor/composer/autoload_real.php
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
|
| 3 |
// autoload_real.php @generated by Composer
|
| 4 |
|
| 5 |
-
class
|
| 6 |
{
|
| 7 |
private static $loader;
|
| 8 |
|
|
@@ -19,15 +19,15 @@ class ComposerAutoloaderInitbadbc7c27712fe1126301394a10557db
|
|
| 19 |
return self::$loader;
|
| 20 |
}
|
| 21 |
|
| 22 |
-
spl_autoload_register(array('
|
| 23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
| 24 |
-
spl_autoload_unregister(array('
|
| 25 |
|
| 26 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
| 27 |
if ($useStaticLoader) {
|
| 28 |
require_once __DIR__ . '/autoload_static.php';
|
| 29 |
|
| 30 |
-
call_user_func(\Composer\Autoload\
|
| 31 |
} else {
|
| 32 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
| 33 |
foreach ($map as $namespace => $path) {
|
|
@@ -48,19 +48,19 @@ class ComposerAutoloaderInitbadbc7c27712fe1126301394a10557db
|
|
| 48 |
$loader->register(true);
|
| 49 |
|
| 50 |
if ($useStaticLoader) {
|
| 51 |
-
$includeFiles = Composer\Autoload\
|
| 52 |
} else {
|
| 53 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
| 54 |
}
|
| 55 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
| 56 |
-
|
| 57 |
}
|
| 58 |
|
| 59 |
return $loader;
|
| 60 |
}
|
| 61 |
}
|
| 62 |
|
| 63 |
-
function
|
| 64 |
{
|
| 65 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
| 66 |
require $file;
|
| 2 |
|
| 3 |
// autoload_real.php @generated by Composer
|
| 4 |
|
| 5 |
+
class ComposerAutoloaderInit42ba6b9fccd44e6582bb4dfeab7736a9
|
| 6 |
{
|
| 7 |
private static $loader;
|
| 8 |
|
| 19 |
return self::$loader;
|
| 20 |
}
|
| 21 |
|
| 22 |
+
spl_autoload_register(array('ComposerAutoloaderInit42ba6b9fccd44e6582bb4dfeab7736a9', 'loadClassLoader'), true, true);
|
| 23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
| 24 |
+
spl_autoload_unregister(array('ComposerAutoloaderInit42ba6b9fccd44e6582bb4dfeab7736a9', 'loadClassLoader'));
|
| 25 |
|
| 26 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
| 27 |
if ($useStaticLoader) {
|
| 28 |
require_once __DIR__ . '/autoload_static.php';
|
| 29 |
|
| 30 |
+
call_user_func(\Composer\Autoload\ComposerStaticInit42ba6b9fccd44e6582bb4dfeab7736a9::getInitializer($loader));
|
| 31 |
} else {
|
| 32 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
| 33 |
foreach ($map as $namespace => $path) {
|
| 48 |
$loader->register(true);
|
| 49 |
|
| 50 |
if ($useStaticLoader) {
|
| 51 |
+
$includeFiles = Composer\Autoload\ComposerStaticInit42ba6b9fccd44e6582bb4dfeab7736a9::$files;
|
| 52 |
} else {
|
| 53 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
| 54 |
}
|
| 55 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
| 56 |
+
composerRequire42ba6b9fccd44e6582bb4dfeab7736a9($fileIdentifier, $file);
|
| 57 |
}
|
| 58 |
|
| 59 |
return $loader;
|
| 60 |
}
|
| 61 |
}
|
| 62 |
|
| 63 |
+
function composerRequire42ba6b9fccd44e6582bb4dfeab7736a9($fileIdentifier, $file)
|
| 64 |
{
|
| 65 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
| 66 |
require $file;
|
includes/mollie-api-php/vendor/composer/autoload_static.php
CHANGED
|
@@ -4,7 +4,7 @@
|
|
| 4 |
|
| 5 |
namespace Composer\Autoload;
|
| 6 |
|
| 7 |
-
class
|
| 8 |
{
|
| 9 |
public static $files = array (
|
| 10 |
'7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
|
|
@@ -61,177 +61,11 @@ class ComposerStaticInitbadbc7c27712fe1126301394a10557db
|
|
| 61 |
),
|
| 62 |
);
|
| 63 |
|
| 64 |
-
public static $classMap = array (
|
| 65 |
-
'Composer\\CaBundle\\CaBundle' => __DIR__ . '/..' . '/composer/ca-bundle/src/CaBundle.php',
|
| 66 |
-
'GuzzleHttp\\Client' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Client.php',
|
| 67 |
-
'GuzzleHttp\\ClientInterface' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/ClientInterface.php',
|
| 68 |
-
'GuzzleHttp\\Cookie\\CookieJar' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Cookie/CookieJar.php',
|
| 69 |
-
'GuzzleHttp\\Cookie\\CookieJarInterface' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php',
|
| 70 |
-
'GuzzleHttp\\Cookie\\FileCookieJar' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php',
|
| 71 |
-
'GuzzleHttp\\Cookie\\SessionCookieJar' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php',
|
| 72 |
-
'GuzzleHttp\\Cookie\\SetCookie' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Cookie/SetCookie.php',
|
| 73 |
-
'GuzzleHttp\\Exception\\BadResponseException' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Exception/BadResponseException.php',
|
| 74 |
-
'GuzzleHttp\\Exception\\ClientException' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Exception/ClientException.php',
|
| 75 |
-
'GuzzleHttp\\Exception\\ConnectException' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Exception/ConnectException.php',
|
| 76 |
-
'GuzzleHttp\\Exception\\GuzzleException' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Exception/GuzzleException.php',
|
| 77 |
-
'GuzzleHttp\\Exception\\RequestException' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Exception/RequestException.php',
|
| 78 |
-
'GuzzleHttp\\Exception\\SeekException' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Exception/SeekException.php',
|
| 79 |
-
'GuzzleHttp\\Exception\\ServerException' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Exception/ServerException.php',
|
| 80 |
-
'GuzzleHttp\\Exception\\TooManyRedirectsException' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php',
|
| 81 |
-
'GuzzleHttp\\Exception\\TransferException' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Exception/TransferException.php',
|
| 82 |
-
'GuzzleHttp\\HandlerStack' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/HandlerStack.php',
|
| 83 |
-
'GuzzleHttp\\Handler\\CurlFactory' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Handler/CurlFactory.php',
|
| 84 |
-
'GuzzleHttp\\Handler\\CurlFactoryInterface' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Handler/CurlFactoryInterface.php',
|
| 85 |
-
'GuzzleHttp\\Handler\\CurlHandler' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Handler/CurlHandler.php',
|
| 86 |
-
'GuzzleHttp\\Handler\\CurlMultiHandler' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php',
|
| 87 |
-
'GuzzleHttp\\Handler\\EasyHandle' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Handler/EasyHandle.php',
|
| 88 |
-
'GuzzleHttp\\Handler\\MockHandler' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Handler/MockHandler.php',
|
| 89 |
-
'GuzzleHttp\\Handler\\Proxy' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Handler/Proxy.php',
|
| 90 |
-
'GuzzleHttp\\Handler\\StreamHandler' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Handler/StreamHandler.php',
|
| 91 |
-
'GuzzleHttp\\MessageFormatter' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/MessageFormatter.php',
|
| 92 |
-
'GuzzleHttp\\Middleware' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Middleware.php',
|
| 93 |
-
'GuzzleHttp\\Pool' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Pool.php',
|
| 94 |
-
'GuzzleHttp\\PrepareBodyMiddleware' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php',
|
| 95 |
-
'GuzzleHttp\\Promise\\AggregateException' => __DIR__ . '/..' . '/guzzlehttp/promises/src/AggregateException.php',
|
| 96 |
-
'GuzzleHttp\\Promise\\CancellationException' => __DIR__ . '/..' . '/guzzlehttp/promises/src/CancellationException.php',
|
| 97 |
-
'GuzzleHttp\\Promise\\Coroutine' => __DIR__ . '/..' . '/guzzlehttp/promises/src/Coroutine.php',
|
| 98 |
-
'GuzzleHttp\\Promise\\EachPromise' => __DIR__ . '/..' . '/guzzlehttp/promises/src/EachPromise.php',
|
| 99 |
-
'GuzzleHttp\\Promise\\FulfilledPromise' => __DIR__ . '/..' . '/guzzlehttp/promises/src/FulfilledPromise.php',
|
| 100 |
-
'GuzzleHttp\\Promise\\Promise' => __DIR__ . '/..' . '/guzzlehttp/promises/src/Promise.php',
|
| 101 |
-
'GuzzleHttp\\Promise\\PromiseInterface' => __DIR__ . '/..' . '/guzzlehttp/promises/src/PromiseInterface.php',
|
| 102 |
-
'GuzzleHttp\\Promise\\PromisorInterface' => __DIR__ . '/..' . '/guzzlehttp/promises/src/PromisorInterface.php',
|
| 103 |
-
'GuzzleHttp\\Promise\\RejectedPromise' => __DIR__ . '/..' . '/guzzlehttp/promises/src/RejectedPromise.php',
|
| 104 |
-
'GuzzleHttp\\Promise\\RejectionException' => __DIR__ . '/..' . '/guzzlehttp/promises/src/RejectionException.php',
|
| 105 |
-
'GuzzleHttp\\Promise\\TaskQueue' => __DIR__ . '/..' . '/guzzlehttp/promises/src/TaskQueue.php',
|
| 106 |
-
'GuzzleHttp\\Promise\\TaskQueueInterface' => __DIR__ . '/..' . '/guzzlehttp/promises/src/TaskQueueInterface.php',
|
| 107 |
-
'GuzzleHttp\\Psr7\\AppendStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/AppendStream.php',
|
| 108 |
-
'GuzzleHttp\\Psr7\\BufferStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/BufferStream.php',
|
| 109 |
-
'GuzzleHttp\\Psr7\\CachingStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/CachingStream.php',
|
| 110 |
-
'GuzzleHttp\\Psr7\\DroppingStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/DroppingStream.php',
|
| 111 |
-
'GuzzleHttp\\Psr7\\FnStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/FnStream.php',
|
| 112 |
-
'GuzzleHttp\\Psr7\\InflateStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/InflateStream.php',
|
| 113 |
-
'GuzzleHttp\\Psr7\\LazyOpenStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/LazyOpenStream.php',
|
| 114 |
-
'GuzzleHttp\\Psr7\\LimitStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/LimitStream.php',
|
| 115 |
-
'GuzzleHttp\\Psr7\\MessageTrait' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/MessageTrait.php',
|
| 116 |
-
'GuzzleHttp\\Psr7\\MultipartStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/MultipartStream.php',
|
| 117 |
-
'GuzzleHttp\\Psr7\\NoSeekStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/NoSeekStream.php',
|
| 118 |
-
'GuzzleHttp\\Psr7\\PumpStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/PumpStream.php',
|
| 119 |
-
'GuzzleHttp\\Psr7\\Request' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/Request.php',
|
| 120 |
-
'GuzzleHttp\\Psr7\\Response' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/Response.php',
|
| 121 |
-
'GuzzleHttp\\Psr7\\Rfc7230' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/Rfc7230.php',
|
| 122 |
-
'GuzzleHttp\\Psr7\\ServerRequest' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/ServerRequest.php',
|
| 123 |
-
'GuzzleHttp\\Psr7\\Stream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/Stream.php',
|
| 124 |
-
'GuzzleHttp\\Psr7\\StreamDecoratorTrait' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/StreamDecoratorTrait.php',
|
| 125 |
-
'GuzzleHttp\\Psr7\\StreamWrapper' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/StreamWrapper.php',
|
| 126 |
-
'GuzzleHttp\\Psr7\\UploadedFile' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/UploadedFile.php',
|
| 127 |
-
'GuzzleHttp\\Psr7\\Uri' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/Uri.php',
|
| 128 |
-
'GuzzleHttp\\Psr7\\UriNormalizer' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/UriNormalizer.php',
|
| 129 |
-
'GuzzleHttp\\Psr7\\UriResolver' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/UriResolver.php',
|
| 130 |
-
'GuzzleHttp\\RedirectMiddleware' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/RedirectMiddleware.php',
|
| 131 |
-
'GuzzleHttp\\RequestOptions' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/RequestOptions.php',
|
| 132 |
-
'GuzzleHttp\\RetryMiddleware' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/RetryMiddleware.php',
|
| 133 |
-
'GuzzleHttp\\TransferStats' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/TransferStats.php',
|
| 134 |
-
'GuzzleHttp\\UriTemplate' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/UriTemplate.php',
|
| 135 |
-
'Mollie\\Api\\CompatibilityChecker' => __DIR__ . '/../..' . '/src/CompatibilityChecker.php',
|
| 136 |
-
'Mollie\\Api\\Endpoints\\ChargebackEndpoint' => __DIR__ . '/../..' . '/src/Endpoints/ChargebackEndpoint.php',
|
| 137 |
-
'Mollie\\Api\\Endpoints\\CollectionEndpointAbstract' => __DIR__ . '/../..' . '/src/Endpoints/CollectionEndpointAbstract.php',
|
| 138 |
-
'Mollie\\Api\\Endpoints\\CustomerEndpoint' => __DIR__ . '/../..' . '/src/Endpoints/CustomerEndpoint.php',
|
| 139 |
-
'Mollie\\Api\\Endpoints\\CustomerPaymentsEndpoint' => __DIR__ . '/../..' . '/src/Endpoints/CustomerPaymentsEndpoint.php',
|
| 140 |
-
'Mollie\\Api\\Endpoints\\EndpointAbstract' => __DIR__ . '/../..' . '/src/Endpoints/EndpointAbstract.php',
|
| 141 |
-
'Mollie\\Api\\Endpoints\\InvoiceEndpoint' => __DIR__ . '/../..' . '/src/Endpoints/InvoiceEndpoint.php',
|
| 142 |
-
'Mollie\\Api\\Endpoints\\MandateEndpoint' => __DIR__ . '/../..' . '/src/Endpoints/MandateEndpoint.php',
|
| 143 |
-
'Mollie\\Api\\Endpoints\\MethodEndpoint' => __DIR__ . '/../..' . '/src/Endpoints/MethodEndpoint.php',
|
| 144 |
-
'Mollie\\Api\\Endpoints\\OnboardingEndpoint' => __DIR__ . '/../..' . '/src/Endpoints/OnboardingEndpoint.php',
|
| 145 |
-
'Mollie\\Api\\Endpoints\\OrderEndpoint' => __DIR__ . '/../..' . '/src/Endpoints/OrderEndpoint.php',
|
| 146 |
-
'Mollie\\Api\\Endpoints\\OrderLineEndpoint' => __DIR__ . '/../..' . '/src/Endpoints/OrderLineEndpoint.php',
|
| 147 |
-
'Mollie\\Api\\Endpoints\\OrderPaymentEndpoint' => __DIR__ . '/../..' . '/src/Endpoints/OrderPaymentEndpoint.php',
|
| 148 |
-
'Mollie\\Api\\Endpoints\\OrderRefundEndpoint' => __DIR__ . '/../..' . '/src/Endpoints/OrderRefundEndpoint.php',
|
| 149 |
-
'Mollie\\Api\\Endpoints\\OrganizationEndpoint' => __DIR__ . '/../..' . '/src/Endpoints/OrganizationEndpoint.php',
|
| 150 |
-
'Mollie\\Api\\Endpoints\\PaymentCaptureEndpoint' => __DIR__ . '/../..' . '/src/Endpoints/PaymentCaptureEndpoint.php',
|
| 151 |
-
'Mollie\\Api\\Endpoints\\PaymentChargebackEndpoint' => __DIR__ . '/../..' . '/src/Endpoints/PaymentChargebackEndpoint.php',
|
| 152 |
-
'Mollie\\Api\\Endpoints\\PaymentEndpoint' => __DIR__ . '/../..' . '/src/Endpoints/PaymentEndpoint.php',
|
| 153 |
-
'Mollie\\Api\\Endpoints\\PaymentRefundEndpoint' => __DIR__ . '/../..' . '/src/Endpoints/PaymentRefundEndpoint.php',
|
| 154 |
-
'Mollie\\Api\\Endpoints\\PermissionEndpoint' => __DIR__ . '/../..' . '/src/Endpoints/PermissionEndpoint.php',
|
| 155 |
-
'Mollie\\Api\\Endpoints\\ProfileEndpoint' => __DIR__ . '/../..' . '/src/Endpoints/ProfileEndpoint.php',
|
| 156 |
-
'Mollie\\Api\\Endpoints\\ProfileMethodEndpoint' => __DIR__ . '/../..' . '/src/Endpoints/ProfileMethodEndpoint.php',
|
| 157 |
-
'Mollie\\Api\\Endpoints\\RefundEndpoint' => __DIR__ . '/../..' . '/src/Endpoints/RefundEndpoint.php',
|
| 158 |
-
'Mollie\\Api\\Endpoints\\SettlementsEndpoint' => __DIR__ . '/../..' . '/src/Endpoints/SettlementsEndpoint.php',
|
| 159 |
-
'Mollie\\Api\\Endpoints\\ShipmentEndpoint' => __DIR__ . '/../..' . '/src/Endpoints/ShipmentEndpoint.php',
|
| 160 |
-
'Mollie\\Api\\Endpoints\\SubscriptionEndpoint' => __DIR__ . '/../..' . '/src/Endpoints/SubscriptionEndpoint.php',
|
| 161 |
-
'Mollie\\Api\\Exceptions\\ApiException' => __DIR__ . '/../..' . '/src/Exceptions/ApiException.php',
|
| 162 |
-
'Mollie\\Api\\Exceptions\\IncompatiblePlatform' => __DIR__ . '/../..' . '/src/Exceptions/IncompatiblePlatform.php',
|
| 163 |
-
'Mollie\\Api\\MollieApiClient' => __DIR__ . '/../..' . '/src/MollieApiClient.php',
|
| 164 |
-
'Mollie\\Api\\Resources\\BaseCollection' => __DIR__ . '/../..' . '/src/Resources/BaseCollection.php',
|
| 165 |
-
'Mollie\\Api\\Resources\\BaseResource' => __DIR__ . '/../..' . '/src/Resources/BaseResource.php',
|
| 166 |
-
'Mollie\\Api\\Resources\\Capture' => __DIR__ . '/../..' . '/src/Resources/Capture.php',
|
| 167 |
-
'Mollie\\Api\\Resources\\CaptureCollection' => __DIR__ . '/../..' . '/src/Resources/CaptureCollection.php',
|
| 168 |
-
'Mollie\\Api\\Resources\\Chargeback' => __DIR__ . '/../..' . '/src/Resources/Chargeback.php',
|
| 169 |
-
'Mollie\\Api\\Resources\\ChargebackCollection' => __DIR__ . '/../..' . '/src/Resources/ChargebackCollection.php',
|
| 170 |
-
'Mollie\\Api\\Resources\\CurrentProfile' => __DIR__ . '/../..' . '/src/Resources/CurrentProfile.php',
|
| 171 |
-
'Mollie\\Api\\Resources\\CursorCollection' => __DIR__ . '/../..' . '/src/Resources/CursorCollection.php',
|
| 172 |
-
'Mollie\\Api\\Resources\\Customer' => __DIR__ . '/../..' . '/src/Resources/Customer.php',
|
| 173 |
-
'Mollie\\Api\\Resources\\CustomerCollection' => __DIR__ . '/../..' . '/src/Resources/CustomerCollection.php',
|
| 174 |
-
'Mollie\\Api\\Resources\\Invoice' => __DIR__ . '/../..' . '/src/Resources/Invoice.php',
|
| 175 |
-
'Mollie\\Api\\Resources\\InvoiceCollection' => __DIR__ . '/../..' . '/src/Resources/InvoiceCollection.php',
|
| 176 |
-
'Mollie\\Api\\Resources\\Issuer' => __DIR__ . '/../..' . '/src/Resources/Issuer.php',
|
| 177 |
-
'Mollie\\Api\\Resources\\IssuerCollection' => __DIR__ . '/../..' . '/src/Resources/IssuerCollection.php',
|
| 178 |
-
'Mollie\\Api\\Resources\\Mandate' => __DIR__ . '/../..' . '/src/Resources/Mandate.php',
|
| 179 |
-
'Mollie\\Api\\Resources\\MandateCollection' => __DIR__ . '/../..' . '/src/Resources/MandateCollection.php',
|
| 180 |
-
'Mollie\\Api\\Resources\\Method' => __DIR__ . '/../..' . '/src/Resources/Method.php',
|
| 181 |
-
'Mollie\\Api\\Resources\\MethodCollection' => __DIR__ . '/../..' . '/src/Resources/MethodCollection.php',
|
| 182 |
-
'Mollie\\Api\\Resources\\MethodPrice' => __DIR__ . '/../..' . '/src/Resources/MethodPrice.php',
|
| 183 |
-
'Mollie\\Api\\Resources\\MethodPriceCollection' => __DIR__ . '/../..' . '/src/Resources/MethodPriceCollection.php',
|
| 184 |
-
'Mollie\\Api\\Resources\\Onboarding' => __DIR__ . '/../..' . '/src/Resources/Onboarding.php',
|
| 185 |
-
'Mollie\\Api\\Resources\\Order' => __DIR__ . '/../..' . '/src/Resources/Order.php',
|
| 186 |
-
'Mollie\\Api\\Resources\\OrderCollection' => __DIR__ . '/../..' . '/src/Resources/OrderCollection.php',
|
| 187 |
-
'Mollie\\Api\\Resources\\OrderLine' => __DIR__ . '/../..' . '/src/Resources/OrderLine.php',
|
| 188 |
-
'Mollie\\Api\\Resources\\OrderLineCollection' => __DIR__ . '/../..' . '/src/Resources/OrderLineCollection.php',
|
| 189 |
-
'Mollie\\Api\\Resources\\Organization' => __DIR__ . '/../..' . '/src/Resources/Organization.php',
|
| 190 |
-
'Mollie\\Api\\Resources\\OrganizationCollection' => __DIR__ . '/../..' . '/src/Resources/OrganizationCollection.php',
|
| 191 |
-
'Mollie\\Api\\Resources\\Payment' => __DIR__ . '/../..' . '/src/Resources/Payment.php',
|
| 192 |
-
'Mollie\\Api\\Resources\\PaymentCollection' => __DIR__ . '/../..' . '/src/Resources/PaymentCollection.php',
|
| 193 |
-
'Mollie\\Api\\Resources\\Permission' => __DIR__ . '/../..' . '/src/Resources/Permission.php',
|
| 194 |
-
'Mollie\\Api\\Resources\\PermissionCollection' => __DIR__ . '/../..' . '/src/Resources/PermissionCollection.php',
|
| 195 |
-
'Mollie\\Api\\Resources\\Profile' => __DIR__ . '/../..' . '/src/Resources/Profile.php',
|
| 196 |
-
'Mollie\\Api\\Resources\\ProfileCollection' => __DIR__ . '/../..' . '/src/Resources/ProfileCollection.php',
|
| 197 |
-
'Mollie\\Api\\Resources\\Refund' => __DIR__ . '/../..' . '/src/Resources/Refund.php',
|
| 198 |
-
'Mollie\\Api\\Resources\\RefundCollection' => __DIR__ . '/../..' . '/src/Resources/RefundCollection.php',
|
| 199 |
-
'Mollie\\Api\\Resources\\ResourceFactory' => __DIR__ . '/../..' . '/src/Resources/ResourceFactory.php',
|
| 200 |
-
'Mollie\\Api\\Resources\\Settlement' => __DIR__ . '/../..' . '/src/Resources/Settlement.php',
|
| 201 |
-
'Mollie\\Api\\Resources\\SettlementCollection' => __DIR__ . '/../..' . '/src/Resources/SettlementCollection.php',
|
| 202 |
-
'Mollie\\Api\\Resources\\Shipment' => __DIR__ . '/../..' . '/src/Resources/Shipment.php',
|
| 203 |
-
'Mollie\\Api\\Resources\\ShipmentCollection' => __DIR__ . '/../..' . '/src/Resources/ShipmentCollection.php',
|
| 204 |
-
'Mollie\\Api\\Resources\\Subscription' => __DIR__ . '/../..' . '/src/Resources/Subscription.php',
|
| 205 |
-
'Mollie\\Api\\Resources\\SubscriptionCollection' => __DIR__ . '/../..' . '/src/Resources/SubscriptionCollection.php',
|
| 206 |
-
'Mollie\\Api\\Types\\InvoiceStatus' => __DIR__ . '/../..' . '/src/Types/InvoiceStatus.php',
|
| 207 |
-
'Mollie\\Api\\Types\\MandateMethod' => __DIR__ . '/../..' . '/src/Types/MandateMethod.php',
|
| 208 |
-
'Mollie\\Api\\Types\\MandateStatus' => __DIR__ . '/../..' . '/src/Types/MandateStatus.php',
|
| 209 |
-
'Mollie\\Api\\Types\\OnboardingStatus' => __DIR__ . '/../..' . '/src/Types/OnboardingStatus.php',
|
| 210 |
-
'Mollie\\Api\\Types\\OrderLineStatus' => __DIR__ . '/../..' . '/src/Types/OrderLineStatus.php',
|
| 211 |
-
'Mollie\\Api\\Types\\OrderLineType' => __DIR__ . '/../..' . '/src/Types/OrderLineType.php',
|
| 212 |
-
'Mollie\\Api\\Types\\OrderStatus' => __DIR__ . '/../..' . '/src/Types/OrderStatus.php',
|
| 213 |
-
'Mollie\\Api\\Types\\PaymentMethod' => __DIR__ . '/../..' . '/src/Types/PaymentMethod.php',
|
| 214 |
-
'Mollie\\Api\\Types\\PaymentStatus' => __DIR__ . '/../..' . '/src/Types/PaymentStatus.php',
|
| 215 |
-
'Mollie\\Api\\Types\\ProfileStatus' => __DIR__ . '/../..' . '/src/Types/ProfileStatus.php',
|
| 216 |
-
'Mollie\\Api\\Types\\RefundStatus' => __DIR__ . '/../..' . '/src/Types/RefundStatus.php',
|
| 217 |
-
'Mollie\\Api\\Types\\SequenceType' => __DIR__ . '/../..' . '/src/Types/SequenceType.php',
|
| 218 |
-
'Mollie\\Api\\Types\\SettlementStatus' => __DIR__ . '/../..' . '/src/Types/SettlementStatus.php',
|
| 219 |
-
'Mollie\\Api\\Types\\SubscriptionStatus' => __DIR__ . '/../..' . '/src/Types/SubscriptionStatus.php',
|
| 220 |
-
'Psr\\Http\\Message\\MessageInterface' => __DIR__ . '/..' . '/psr/http-message/src/MessageInterface.php',
|
| 221 |
-
'Psr\\Http\\Message\\RequestInterface' => __DIR__ . '/..' . '/psr/http-message/src/RequestInterface.php',
|
| 222 |
-
'Psr\\Http\\Message\\ResponseInterface' => __DIR__ . '/..' . '/psr/http-message/src/ResponseInterface.php',
|
| 223 |
-
'Psr\\Http\\Message\\ServerRequestInterface' => __DIR__ . '/..' . '/psr/http-message/src/ServerRequestInterface.php',
|
| 224 |
-
'Psr\\Http\\Message\\StreamInterface' => __DIR__ . '/..' . '/psr/http-message/src/StreamInterface.php',
|
| 225 |
-
'Psr\\Http\\Message\\UploadedFileInterface' => __DIR__ . '/..' . '/psr/http-message/src/UploadedFileInterface.php',
|
| 226 |
-
'Psr\\Http\\Message\\UriInterface' => __DIR__ . '/..' . '/psr/http-message/src/UriInterface.php',
|
| 227 |
-
);
|
| 228 |
-
|
| 229 |
public static function getInitializer(ClassLoader $loader)
|
| 230 |
{
|
| 231 |
return \Closure::bind(function () use ($loader) {
|
| 232 |
-
$loader->prefixLengthsPsr4 =
|
| 233 |
-
$loader->prefixDirsPsr4 =
|
| 234 |
-
$loader->classMap = ComposerStaticInitbadbc7c27712fe1126301394a10557db::$classMap;
|
| 235 |
|
| 236 |
}, null, ClassLoader::class);
|
| 237 |
}
|
| 4 |
|
| 5 |
namespace Composer\Autoload;
|
| 6 |
|
| 7 |
+
class ComposerStaticInit42ba6b9fccd44e6582bb4dfeab7736a9
|
| 8 |
{
|
| 9 |
public static $files = array (
|
| 10 |
'7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
|
| 61 |
),
|
| 62 |
);
|
| 63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
public static function getInitializer(ClassLoader $loader)
|
| 65 |
{
|
| 66 |
return \Closure::bind(function () use ($loader) {
|
| 67 |
+
$loader->prefixLengthsPsr4 = ComposerStaticInit42ba6b9fccd44e6582bb4dfeab7736a9::$prefixLengthsPsr4;
|
| 68 |
+
$loader->prefixDirsPsr4 = ComposerStaticInit42ba6b9fccd44e6582bb4dfeab7736a9::$prefixDirsPsr4;
|
|
|
|
| 69 |
|
| 70 |
}, null, ClassLoader::class);
|
| 71 |
}
|
includes/mollie-api-php/vendor/composer/ca-bundle/res/cacert.pem
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
##
|
| 2 |
## Bundle of CA Root Certificates
|
| 3 |
##
|
| 4 |
-
## Certificate data from Mozilla as of: Wed
|
| 5 |
##
|
| 6 |
## This is a bundle of X.509 certificates of public Certificate Authorities
|
| 7 |
## (CA). These were automatically extracted from Mozilla's root certificates
|
|
@@ -14,7 +14,7 @@
|
|
| 14 |
## Just configure this file as the SSLCACertificateFile.
|
| 15 |
##
|
| 16 |
## Conversion done with mk-ca-bundle.pl version 1.27.
|
| 17 |
-
## SHA256:
|
| 18 |
##
|
| 19 |
|
| 20 |
|
|
@@ -2613,37 +2613,6 @@ kbcFgKyLmZJ956LYBws2J+dIeWCKw9cTXPhyQN9Ky8+ZAAoACxGV2lZFA4gKn2fQ1XmxqI1AbQ3C
|
|
| 2613 |
ekD6819kR5LLU7m7Wc5P/dAVUwHY3+vZ5nbv0CO7O6l5s9UCKc2Jo5YPSjXnTkLAdc0Hz+Ys63su
|
| 2614 |
-----END CERTIFICATE-----
|
| 2615 |
|
| 2616 |
-
Certinomis - Root CA
|
| 2617 |
-
====================
|
| 2618 |
-
-----BEGIN CERTIFICATE-----
|
| 2619 |
-
MIIFkjCCA3qgAwIBAgIBATANBgkqhkiG9w0BAQsFADBaMQswCQYDVQQGEwJGUjETMBEGA1UEChMK
|
| 2620 |
-
Q2VydGlub21pczEXMBUGA1UECxMOMDAwMiA0MzM5OTg5MDMxHTAbBgNVBAMTFENlcnRpbm9taXMg
|
| 2621 |
-
LSBSb290IENBMB4XDTEzMTAyMTA5MTcxOFoXDTMzMTAyMTA5MTcxOFowWjELMAkGA1UEBhMCRlIx
|
| 2622 |
-
EzARBgNVBAoTCkNlcnRpbm9taXMxFzAVBgNVBAsTDjAwMDIgNDMzOTk4OTAzMR0wGwYDVQQDExRD
|
| 2623 |
-
ZXJ0aW5vbWlzIC0gUm9vdCBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANTMCQos
|
| 2624 |
-
P5L2fxSeC5yaah1AMGT9qt8OHgZbn1CF6s2Nq0Nn3rD6foCWnoR4kkjW4znuzuRZWJflLieY6pOo
|
| 2625 |
-
d5tK8O90gC3rMB+12ceAnGInkYjwSond3IjmFPnVAy//ldu9n+ws+hQVWZUKxkd8aRi5pwP5ynap
|
| 2626 |
-
z8dvtF4F/u7BUrJ1Mofs7SlmO/NKFoL21prbcpjp3vDFTKWrteoB4owuZH9kb/2jJZOLyKIOSY00
|
| 2627 |
-
8B/sWEUuNKqEUL3nskoTuLAPrjhdsKkb5nPJWqHZZkCqqU2mNAKthH6yI8H7KsZn9DS2sJVqM09x
|
| 2628 |
-
RLWtwHkziOC/7aOgFLScCbAK42C++PhmiM1b8XcF4LVzbsF9Ri6OSyemzTUK/eVNfaoqoynHWmgE
|
| 2629 |
-
6OXWk6RiwsXm9E/G+Z8ajYJJGYrKWUM66A0ywfRMEwNvbqY/kXPLynNvEiCL7sCCeN5LLsJJwx3t
|
| 2630 |
-
FvYk9CcbXFcx3FXuqB5vbKziRcxXV4p1VxngtViZSTYxPDMBbRZKzbgqg4SGm/lg0h9tkQPTYKbV
|
| 2631 |
-
PZrdd5A9NaSfD171UkRpucC63M9933zZxKyGIjK8e2uR73r4F2iw4lNVYC2vPsKD2NkJK/DAZNuH
|
| 2632 |
-
i5HMkesE/Xa0lZrmFAYb1TQdvtj/dBxThZngWVJKYe2InmtJiUZ+IFrZ50rlau7SZRFDAgMBAAGj
|
| 2633 |
-
YzBhMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTvkUz1pcMw6C8I
|
| 2634 |
-
6tNxIqSSaHh02TAfBgNVHSMEGDAWgBTvkUz1pcMw6C8I6tNxIqSSaHh02TANBgkqhkiG9w0BAQsF
|
| 2635 |
-
AAOCAgEAfj1U2iJdGlg+O1QnurrMyOMaauo++RLrVl89UM7g6kgmJs95Vn6RHJk/0KGRHCwPT5iV
|
| 2636 |
-
WVO90CLYiF2cN/z7ZMF4jIuaYAnq1fohX9B0ZedQxb8uuQsLrbWwF6YSjNRieOpWauwK0kDDPAUw
|
| 2637 |
-
Pk2Ut59KA9N9J0u2/kTO+hkzGm2kQtHdzMjI1xZSg081lLMSVX3l4kLr5JyTCcBMWwerx20RoFAX
|
| 2638 |
-
lCOotQqSD7J6wWAsOMwaplv/8gzjqh8c3LigkyfeY+N/IZ865Z764BNqdeuWXGKRlI5nU7aJ+BIJ
|
| 2639 |
-
y29SWwNyhlCVCNSNh4YVH5Uk2KRvms6knZtt0rJ2BobGVgjF6wnaNsIbW0G+YSrjcOa4pvi2WsS9
|
| 2640 |
-
Iff/ql+hbHY5ZtbqTFXhADObE5hjyW/QASAJN1LnDE8+zbz1X5YnpyACleAu6AdBBR8Vbtaw5Bng
|
| 2641 |
-
DwKTACdyxYvRVB9dSsNAl35VpnzBMwQUAR1JIGkLGZOdblgi90AMRgwjY/M50n92Uaf0yKHxDHYi
|
| 2642 |
-
I0ZSKS3io0EHVmmY0gUJvGnHWmHNj4FgFU2A3ZDifcRQ8ow7bkrHxuaAKzyBvBGAFhAn1/DNP3nM
|
| 2643 |
-
cyrDflOR1m749fPH0FFNjkulW+YZFzvWgQncItzujrnEj1PhZ7szuIgVRs/taTX/dQ1G885x4cVr
|
| 2644 |
-
hkIGuUE=
|
| 2645 |
-
-----END CERTIFICATE-----
|
| 2646 |
-
|
| 2647 |
OISTE WISeKey Global Root GB CA
|
| 2648 |
===============================
|
| 2649 |
-----BEGIN CERTIFICATE-----
|
| 1 |
##
|
| 2 |
## Bundle of CA Root Certificates
|
| 3 |
##
|
| 4 |
+
## Certificate data from Mozilla as of: Wed Aug 28 03:12:10 2019 GMT
|
| 5 |
##
|
| 6 |
## This is a bundle of X.509 certificates of public Certificate Authorities
|
| 7 |
## (CA). These were automatically extracted from Mozilla's root certificates
|
| 14 |
## Just configure this file as the SSLCACertificateFile.
|
| 15 |
##
|
| 16 |
## Conversion done with mk-ca-bundle.pl version 1.27.
|
| 17 |
+
## SHA256: fffa309937c3be940649293f749b8207fabc6eb224e50e4bb3f2c5e44e0d6a6b
|
| 18 |
##
|
| 19 |
|
| 20 |
|
| 2613 |
ekD6819kR5LLU7m7Wc5P/dAVUwHY3+vZ5nbv0CO7O6l5s9UCKc2Jo5YPSjXnTkLAdc0Hz+Ys63su
|
| 2614 |
-----END CERTIFICATE-----
|
| 2615 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2616 |
OISTE WISeKey Global Root GB CA
|
| 2617 |
===============================
|
| 2618 |
-----BEGIN CERTIFICATE-----
|
includes/mollie-api-php/vendor/composer/installed.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
| 1 |
[
|
| 2 |
{
|
| 3 |
"name": "composer/ca-bundle",
|
| 4 |
-
"version": "1.2.
|
| 5 |
-
"version_normalized": "1.2.
|
| 6 |
"source": {
|
| 7 |
"type": "git",
|
| 8 |
"url": "https://github.com/composer/ca-bundle.git",
|
| 9 |
-
"reference": "
|
| 10 |
},
|
| 11 |
"dist": {
|
| 12 |
"type": "zip",
|
| 13 |
-
"url": "https://api.github.com/repos/composer/ca-bundle/zipball/
|
| 14 |
-
"reference": "
|
| 15 |
"shasum": ""
|
| 16 |
},
|
| 17 |
"require": {
|
|
@@ -24,7 +24,7 @@
|
|
| 24 |
"psr/log": "^1.0",
|
| 25 |
"symfony/process": "^2.5 || ^3.0 || ^4.0"
|
| 26 |
},
|
| 27 |
-
"time": "2019-08-
|
| 28 |
"type": "library",
|
| 29 |
"extra": {
|
| 30 |
"branch-alias": {
|
|
@@ -59,33 +59,34 @@
|
|
| 59 |
},
|
| 60 |
{
|
| 61 |
"name": "guzzlehttp/guzzle",
|
| 62 |
-
"version": "6.
|
| 63 |
-
"version_normalized": "6.
|
| 64 |
"source": {
|
| 65 |
"type": "git",
|
| 66 |
"url": "https://github.com/guzzle/guzzle.git",
|
| 67 |
-
"reference": "
|
| 68 |
},
|
| 69 |
"dist": {
|
| 70 |
"type": "zip",
|
| 71 |
-
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/
|
| 72 |
-
"reference": "
|
| 73 |
"shasum": ""
|
| 74 |
},
|
| 75 |
"require": {
|
|
|
|
| 76 |
"guzzlehttp/promises": "^1.0",
|
| 77 |
-
"guzzlehttp/psr7": "^1.
|
| 78 |
"php": ">=5.5"
|
| 79 |
},
|
| 80 |
"require-dev": {
|
| 81 |
"ext-curl": "*",
|
| 82 |
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0",
|
| 83 |
-
"psr/log": "^1.
|
| 84 |
},
|
| 85 |
"suggest": {
|
| 86 |
"psr/log": "Required for using the Log middleware"
|
| 87 |
},
|
| 88 |
-
"time": "
|
| 89 |
"type": "library",
|
| 90 |
"extra": {
|
| 91 |
"branch-alias": {
|
|
@@ -94,12 +95,12 @@
|
|
| 94 |
},
|
| 95 |
"installation-source": "dist",
|
| 96 |
"autoload": {
|
| 97 |
-
"files": [
|
| 98 |
-
"src/functions_include.php"
|
| 99 |
-
],
|
| 100 |
"psr-4": {
|
| 101 |
"GuzzleHttp\\": "src/"
|
| 102 |
-
}
|
|
|
|
|
|
|
|
|
|
| 103 |
},
|
| 104 |
"notification-url": "https://packagist.org/downloads/",
|
| 105 |
"license": [
|
| 1 |
[
|
| 2 |
{
|
| 3 |
"name": "composer/ca-bundle",
|
| 4 |
+
"version": "1.2.4",
|
| 5 |
+
"version_normalized": "1.2.4.0",
|
| 6 |
"source": {
|
| 7 |
"type": "git",
|
| 8 |
"url": "https://github.com/composer/ca-bundle.git",
|
| 9 |
+
"reference": "10bb96592168a0f8e8f6dcde3532d9fa50b0b527"
|
| 10 |
},
|
| 11 |
"dist": {
|
| 12 |
"type": "zip",
|
| 13 |
+
"url": "https://api.github.com/repos/composer/ca-bundle/zipball/10bb96592168a0f8e8f6dcde3532d9fa50b0b527",
|
| 14 |
+
"reference": "10bb96592168a0f8e8f6dcde3532d9fa50b0b527",
|
| 15 |
"shasum": ""
|
| 16 |
},
|
| 17 |
"require": {
|
| 24 |
"psr/log": "^1.0",
|
| 25 |
"symfony/process": "^2.5 || ^3.0 || ^4.0"
|
| 26 |
},
|
| 27 |
+
"time": "2019-08-30T08:44:50+00:00",
|
| 28 |
"type": "library",
|
| 29 |
"extra": {
|
| 30 |
"branch-alias": {
|
| 59 |
},
|
| 60 |
{
|
| 61 |
"name": "guzzlehttp/guzzle",
|
| 62 |
+
"version": "6.4.1",
|
| 63 |
+
"version_normalized": "6.4.1.0",
|
| 64 |
"source": {
|
| 65 |
"type": "git",
|
| 66 |
"url": "https://github.com/guzzle/guzzle.git",
|
| 67 |
+
"reference": "0895c932405407fd3a7368b6910c09a24d26db11"
|
| 68 |
},
|
| 69 |
"dist": {
|
| 70 |
"type": "zip",
|
| 71 |
+
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/0895c932405407fd3a7368b6910c09a24d26db11",
|
| 72 |
+
"reference": "0895c932405407fd3a7368b6910c09a24d26db11",
|
| 73 |
"shasum": ""
|
| 74 |
},
|
| 75 |
"require": {
|
| 76 |
+
"ext-json": "*",
|
| 77 |
"guzzlehttp/promises": "^1.0",
|
| 78 |
+
"guzzlehttp/psr7": "^1.6.1",
|
| 79 |
"php": ">=5.5"
|
| 80 |
},
|
| 81 |
"require-dev": {
|
| 82 |
"ext-curl": "*",
|
| 83 |
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0",
|
| 84 |
+
"psr/log": "^1.1"
|
| 85 |
},
|
| 86 |
"suggest": {
|
| 87 |
"psr/log": "Required for using the Log middleware"
|
| 88 |
},
|
| 89 |
+
"time": "2019-10-23T15:58:00+00:00",
|
| 90 |
"type": "library",
|
| 91 |
"extra": {
|
| 92 |
"branch-alias": {
|
| 95 |
},
|
| 96 |
"installation-source": "dist",
|
| 97 |
"autoload": {
|
|
|
|
|
|
|
|
|
|
| 98 |
"psr-4": {
|
| 99 |
"GuzzleHttp\\": "src/"
|
| 100 |
+
},
|
| 101 |
+
"files": [
|
| 102 |
+
"src/functions_include.php"
|
| 103 |
+
]
|
| 104 |
},
|
| 105 |
"notification-url": "https://packagist.org/downloads/",
|
| 106 |
"license": [
|
includes/mollie-api-php/vendor/guzzlehttp/guzzle/.php_cs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
$config = PhpCsFixer\Config::create()
|
| 4 |
+
->setRiskyAllowed(true)
|
| 5 |
+
->setRules([
|
| 6 |
+
'@PSR2' => true,
|
| 7 |
+
'array_syntax' => ['syntax' => 'short'],
|
| 8 |
+
'declare_strict_types' => false,
|
| 9 |
+
'concat_space' => ['spacing'=>'one'],
|
| 10 |
+
// 'ordered_imports' => true,
|
| 11 |
+
// 'phpdoc_align' => ['align'=>'vertical'],
|
| 12 |
+
// 'native_function_invocation' => true,
|
| 13 |
+
])
|
| 14 |
+
->setFinder(
|
| 15 |
+
PhpCsFixer\Finder::create()
|
| 16 |
+
->in(__DIR__.'/src')
|
| 17 |
+
->name('*.php')
|
| 18 |
+
)
|
| 19 |
+
;
|
| 20 |
+
|
| 21 |
+
return $config;
|
includes/mollie-api-php/vendor/guzzlehttp/guzzle/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
| 1 |
# Change Log
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
## 6.3.3 - 2018-04-22
|
| 4 |
|
| 5 |
* Fix: Default headers when decode_content is specified
|
| 1 |
# Change Log
|
| 2 |
|
| 3 |
+
## 6.4.1 - 2019-10-23
|
| 4 |
+
|
| 5 |
+
* No `guzzle.phar` was created in 6.4.0 due expired API token. This release will fix that
|
| 6 |
+
* Added `parent::__construct()` to `FileCookieJar` and `SessionCookieJar`
|
| 7 |
+
|
| 8 |
+
## 6.4.0 - 2019-10-23
|
| 9 |
+
|
| 10 |
+
* Improvement: Improved error messages when using curl < 7.21.2 [#2108](https://github.com/guzzle/guzzle/pull/2108)
|
| 11 |
+
* Fix: Test if response is readable before returning a summary in `RequestException::getResponseBodySummary()` [#2081](https://github.com/guzzle/guzzle/pull/2081)
|
| 12 |
+
* Fix: Add support for GUZZLE_CURL_SELECT_TIMEOUT environment variable [#2161](https://github.com/guzzle/guzzle/pull/2161)
|
| 13 |
+
* Improvement: Added `GuzzleHttp\Exception\InvalidArgumentException` [#2163](https://github.com/guzzle/guzzle/pull/2163)
|
| 14 |
+
* Improvement: Added `GuzzleHttp\_current_time()` to use `hrtime()` if that function exists. [#2242](https://github.com/guzzle/guzzle/pull/2242)
|
| 15 |
+
* Improvement: Added curl's `appconnect_time` in `TransferStats` [#2284](https://github.com/guzzle/guzzle/pull/2284)
|
| 16 |
+
* Improvement: Make GuzzleException extend Throwable wherever it's available [#2273](https://github.com/guzzle/guzzle/pull/2273)
|
| 17 |
+
* Fix: Prevent concurrent writes to file when saving `CookieJar` [#2335](https://github.com/guzzle/guzzle/pull/2335)
|
| 18 |
+
* Improvement: Update `MockHandler` so we can test transfer time [#2362](https://github.com/guzzle/guzzle/pull/2362)
|
| 19 |
+
|
| 20 |
## 6.3.3 - 2018-04-22
|
| 21 |
|
| 22 |
* Fix: Default headers when decode_content is specified
|
includes/mollie-api-php/vendor/guzzlehttp/guzzle/Dockerfile
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM composer:latest as setup
|
| 2 |
+
|
| 3 |
+
RUN mkdir /guzzle
|
| 4 |
+
|
| 5 |
+
WORKDIR /guzzle
|
| 6 |
+
|
| 7 |
+
RUN set -xe \
|
| 8 |
+
&& composer init --name=guzzlehttp/test --description="Simple project for testing Guzzle scripts" --author="Márk Sági-Kazár <mark.sagikazar@gmail.com>" --no-interaction \
|
| 9 |
+
&& composer require guzzlehttp/guzzle
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
FROM php:7.3
|
| 13 |
+
|
| 14 |
+
RUN mkdir /guzzle
|
| 15 |
+
|
| 16 |
+
WORKDIR /guzzle
|
| 17 |
+
|
| 18 |
+
COPY --from=setup /guzzle /guzzle
|
includes/mollie-api-php/vendor/guzzlehttp/guzzle/README.md
CHANGED
|
@@ -21,19 +21,18 @@ trivial to integrate with web services.
|
|
| 21 |
|
| 22 |
```php
|
| 23 |
$client = new \GuzzleHttp\Client();
|
| 24 |
-
$
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
echo $
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
// Send an asynchronous request.
|
| 33 |
$request = new \GuzzleHttp\Psr7\Request('GET', 'http://httpbin.org');
|
| 34 |
$promise = $client->sendAsync($request)->then(function ($response) {
|
| 35 |
echo 'I completed! ' . $response->getBody();
|
| 36 |
});
|
|
|
|
| 37 |
$promise->wait();
|
| 38 |
```
|
| 39 |
|
|
@@ -57,7 +56,7 @@ curl -sS https://getcomposer.org/installer | php
|
|
| 57 |
Next, run the Composer command to install the latest stable version of Guzzle:
|
| 58 |
|
| 59 |
```bash
|
| 60 |
-
|
| 61 |
```
|
| 62 |
|
| 63 |
After installing, you need to require Composer's autoloader:
|
|
@@ -69,7 +68,7 @@ require 'vendor/autoload.php';
|
|
| 69 |
You can then later update Guzzle using composer:
|
| 70 |
|
| 71 |
```bash
|
| 72 |
-
composer
|
| 73 |
```
|
| 74 |
|
| 75 |
|
|
@@ -86,6 +85,6 @@ composer.phar update
|
|
| 86 |
[guzzle-4-repo]: https://github.com/guzzle/guzzle/tree/4.x
|
| 87 |
[guzzle-5-repo]: https://github.com/guzzle/guzzle/tree/5.3
|
| 88 |
[guzzle-6-repo]: https://github.com/guzzle/guzzle
|
| 89 |
-
[guzzle-3-docs]: http://guzzle3.readthedocs.org
|
| 90 |
[guzzle-5-docs]: http://guzzle.readthedocs.org/en/5.3/
|
| 91 |
[guzzle-6-docs]: http://guzzle.readthedocs.org/en/latest/
|
| 21 |
|
| 22 |
```php
|
| 23 |
$client = new \GuzzleHttp\Client();
|
| 24 |
+
$response = $client->request('GET', 'https://api.github.com/repos/guzzle/guzzle');
|
| 25 |
+
|
| 26 |
+
echo $response->getStatusCode(); # 200
|
| 27 |
+
echo $response->getHeaderLine('content-type'); # 'application/json; charset=utf8'
|
| 28 |
+
echo $response->getBody(); # '{"id": 1420053, "name": "guzzle", ...}'
|
| 29 |
+
|
| 30 |
+
# Send an asynchronous request.
|
|
|
|
|
|
|
| 31 |
$request = new \GuzzleHttp\Psr7\Request('GET', 'http://httpbin.org');
|
| 32 |
$promise = $client->sendAsync($request)->then(function ($response) {
|
| 33 |
echo 'I completed! ' . $response->getBody();
|
| 34 |
});
|
| 35 |
+
|
| 36 |
$promise->wait();
|
| 37 |
```
|
| 38 |
|
| 56 |
Next, run the Composer command to install the latest stable version of Guzzle:
|
| 57 |
|
| 58 |
```bash
|
| 59 |
+
composer require guzzlehttp/guzzle
|
| 60 |
```
|
| 61 |
|
| 62 |
After installing, you need to require Composer's autoloader:
|
| 68 |
You can then later update Guzzle using composer:
|
| 69 |
|
| 70 |
```bash
|
| 71 |
+
composer update
|
| 72 |
```
|
| 73 |
|
| 74 |
|
| 85 |
[guzzle-4-repo]: https://github.com/guzzle/guzzle/tree/4.x
|
| 86 |
[guzzle-5-repo]: https://github.com/guzzle/guzzle/tree/5.3
|
| 87 |
[guzzle-6-repo]: https://github.com/guzzle/guzzle
|
| 88 |
+
[guzzle-3-docs]: http://guzzle3.readthedocs.org
|
| 89 |
[guzzle-5-docs]: http://guzzle.readthedocs.org/en/5.3/
|
| 90 |
[guzzle-6-docs]: http://guzzle.readthedocs.org/en/latest/
|
includes/mollie-api-php/vendor/guzzlehttp/guzzle/composer.json
CHANGED
|
@@ -2,7 +2,15 @@
|
|
| 2 |
"name": "guzzlehttp/guzzle",
|
| 3 |
"type": "library",
|
| 4 |
"description": "Guzzle is a PHP HTTP client library",
|
| 5 |
-
"keywords": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
"homepage": "http://guzzlephp.org/",
|
| 7 |
"license": "MIT",
|
| 8 |
"authors": [
|
|
@@ -14,31 +22,37 @@
|
|
| 14 |
],
|
| 15 |
"require": {
|
| 16 |
"php": ">=5.5",
|
| 17 |
-
"
|
| 18 |
-
"guzzlehttp/promises": "^1.0"
|
|
|
|
| 19 |
},
|
| 20 |
"require-dev": {
|
| 21 |
"ext-curl": "*",
|
| 22 |
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0",
|
| 23 |
-
"psr/log": "^1.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
},
|
| 25 |
"autoload": {
|
| 26 |
-
"files": ["src/functions_include.php"],
|
| 27 |
"psr-4": {
|
| 28 |
"GuzzleHttp\\": "src/"
|
| 29 |
-
}
|
|
|
|
|
|
|
|
|
|
| 30 |
},
|
| 31 |
"autoload-dev": {
|
| 32 |
"psr-4": {
|
| 33 |
"GuzzleHttp\\Tests\\": "tests/"
|
| 34 |
}
|
| 35 |
-
},
|
| 36 |
-
"suggest": {
|
| 37 |
-
"psr/log": "Required for using the Log middleware"
|
| 38 |
-
},
|
| 39 |
-
"extra": {
|
| 40 |
-
"branch-alias": {
|
| 41 |
-
"dev-master": "6.3-dev"
|
| 42 |
-
}
|
| 43 |
}
|
| 44 |
}
|
| 2 |
"name": "guzzlehttp/guzzle",
|
| 3 |
"type": "library",
|
| 4 |
"description": "Guzzle is a PHP HTTP client library",
|
| 5 |
+
"keywords": [
|
| 6 |
+
"framework",
|
| 7 |
+
"http",
|
| 8 |
+
"rest",
|
| 9 |
+
"web service",
|
| 10 |
+
"curl",
|
| 11 |
+
"client",
|
| 12 |
+
"HTTP client"
|
| 13 |
+
],
|
| 14 |
"homepage": "http://guzzlephp.org/",
|
| 15 |
"license": "MIT",
|
| 16 |
"authors": [
|
| 22 |
],
|
| 23 |
"require": {
|
| 24 |
"php": ">=5.5",
|
| 25 |
+
"ext-json": "*",
|
| 26 |
+
"guzzlehttp/promises": "^1.0",
|
| 27 |
+
"guzzlehttp/psr7": "^1.6.1"
|
| 28 |
},
|
| 29 |
"require-dev": {
|
| 30 |
"ext-curl": "*",
|
| 31 |
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0",
|
| 32 |
+
"psr/log": "^1.1"
|
| 33 |
+
},
|
| 34 |
+
"suggest": {
|
| 35 |
+
"psr/log": "Required for using the Log middleware"
|
| 36 |
+
},
|
| 37 |
+
"config": {
|
| 38 |
+
"sort-packages": true
|
| 39 |
+
},
|
| 40 |
+
"extra": {
|
| 41 |
+
"branch-alias": {
|
| 42 |
+
"dev-master": "6.3-dev"
|
| 43 |
+
}
|
| 44 |
},
|
| 45 |
"autoload": {
|
|
|
|
| 46 |
"psr-4": {
|
| 47 |
"GuzzleHttp\\": "src/"
|
| 48 |
+
},
|
| 49 |
+
"files": [
|
| 50 |
+
"src/functions_include.php"
|
| 51 |
+
]
|
| 52 |
},
|
| 53 |
"autoload-dev": {
|
| 54 |
"psr-4": {
|
| 55 |
"GuzzleHttp\\Tests\\": "tests/"
|
| 56 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
}
|
| 58 |
}
|
includes/mollie-api-php/vendor/guzzlehttp/guzzle/phpstan.neon.dist
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
parameters:
|
| 2 |
+
level: 1
|
| 3 |
+
paths:
|
| 4 |
+
- src
|
| 5 |
+
|
| 6 |
+
ignoreErrors:
|
| 7 |
+
-
|
| 8 |
+
message: '#Function uri_template not found#'
|
| 9 |
+
path: %currentWorkingDirectory%/src/functions.php
|
includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Client.php
CHANGED
|
@@ -210,7 +210,7 @@ class Client implements ClientInterface
|
|
| 210 |
*
|
| 211 |
* @return array
|
| 212 |
*/
|
| 213 |
-
private function prepareDefaults($options)
|
| 214 |
{
|
| 215 |
$defaults = $this->config;
|
| 216 |
|
| 210 |
*
|
| 211 |
* @return array
|
| 212 |
*/
|
| 213 |
+
private function prepareDefaults(array $options)
|
| 214 |
{
|
| 215 |
$defaults = $this->config;
|
| 216 |
|
includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/ClientInterface.php
CHANGED
|
@@ -12,7 +12,7 @@ use Psr\Http\Message\UriInterface;
|
|
| 12 |
*/
|
| 13 |
interface ClientInterface
|
| 14 |
{
|
| 15 |
-
const VERSION = '6.
|
| 16 |
|
| 17 |
/**
|
| 18 |
* Send an HTTP request.
|
| 12 |
*/
|
| 13 |
interface ClientInterface
|
| 14 |
{
|
| 15 |
+
const VERSION = '6.4.1';
|
| 16 |
|
| 17 |
/**
|
| 18 |
* Send an HTTP request.
|
includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php
CHANGED
|
@@ -120,7 +120,7 @@ class CookieJar implements CookieJarInterface
|
|
| 120 |
} elseif (!$path) {
|
| 121 |
$this->cookies = array_filter(
|
| 122 |
$this->cookies,
|
| 123 |
-
function (SetCookie $cookie) use ($
|
| 124 |
return !$cookie->matchesDomain($domain);
|
| 125 |
}
|
| 126 |
);
|
| 120 |
} elseif (!$path) {
|
| 121 |
$this->cookies = array_filter(
|
| 122 |
$this->cookies,
|
| 123 |
+
function (SetCookie $cookie) use ($domain) {
|
| 124 |
return !$cookie->matchesDomain($domain);
|
| 125 |
}
|
| 126 |
);
|
includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php
CHANGED
|
@@ -23,6 +23,7 @@ class FileCookieJar extends CookieJar
|
|
| 23 |
*/
|
| 24 |
public function __construct($cookieFile, $storeSessionCookies = false)
|
| 25 |
{
|
|
|
|
| 26 |
$this->filename = $cookieFile;
|
| 27 |
$this->storeSessionCookies = $storeSessionCookies;
|
| 28 |
|
|
@@ -56,7 +57,7 @@ class FileCookieJar extends CookieJar
|
|
| 56 |
}
|
| 57 |
|
| 58 |
$jsonStr = \GuzzleHttp\json_encode($json);
|
| 59 |
-
if (false === file_put_contents($filename, $jsonStr)) {
|
| 60 |
throw new \RuntimeException("Unable to save file {$filename}");
|
| 61 |
}
|
| 62 |
}
|
| 23 |
*/
|
| 24 |
public function __construct($cookieFile, $storeSessionCookies = false)
|
| 25 |
{
|
| 26 |
+
parent::__construct();
|
| 27 |
$this->filename = $cookieFile;
|
| 28 |
$this->storeSessionCookies = $storeSessionCookies;
|
| 29 |
|
| 57 |
}
|
| 58 |
|
| 59 |
$jsonStr = \GuzzleHttp\json_encode($json);
|
| 60 |
+
if (false === file_put_contents($filename, $jsonStr, LOCK_EX)) {
|
| 61 |
throw new \RuntimeException("Unable to save file {$filename}");
|
| 62 |
}
|
| 63 |
}
|
includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php
CHANGED
|
@@ -22,6 +22,7 @@ class SessionCookieJar extends CookieJar
|
|
| 22 |
*/
|
| 23 |
public function __construct($sessionKey, $storeSessionCookies = false)
|
| 24 |
{
|
|
|
|
| 25 |
$this->sessionKey = $sessionKey;
|
| 26 |
$this->storeSessionCookies = $storeSessionCookies;
|
| 27 |
$this->load();
|
| 22 |
*/
|
| 23 |
public function __construct($sessionKey, $storeSessionCookies = false)
|
| 24 |
{
|
| 25 |
+
parent::__construct();
|
| 26 |
$this->sessionKey = $sessionKey;
|
| 27 |
$this->storeSessionCookies = $storeSessionCookies;
|
| 28 |
$this->load();
|
includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php
CHANGED
|
@@ -227,7 +227,7 @@ class SetCookie
|
|
| 227 |
/**
|
| 228 |
* Get whether or not this is a secure cookie
|
| 229 |
*
|
| 230 |
-
* @return null
|
| 231 |
*/
|
| 232 |
public function getSecure()
|
| 233 |
{
|
|
@@ -247,7 +247,7 @@ class SetCookie
|
|
| 247 |
/**
|
| 248 |
* Get whether or not this is a session cookie
|
| 249 |
*
|
| 250 |
-
* @return null
|
| 251 |
*/
|
| 252 |
public function getDiscard()
|
| 253 |
{
|
| 227 |
/**
|
| 228 |
* Get whether or not this is a secure cookie
|
| 229 |
*
|
| 230 |
+
* @return bool|null
|
| 231 |
*/
|
| 232 |
public function getSecure()
|
| 233 |
{
|
| 247 |
/**
|
| 248 |
* Get whether or not this is a session cookie
|
| 249 |
*
|
| 250 |
+
* @return bool|null
|
| 251 |
*/
|
| 252 |
public function getDiscard()
|
| 253 |
{
|
includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Exception/ClientException.php
CHANGED
|
@@ -4,4 +4,6 @@ namespace GuzzleHttp\Exception;
|
|
| 4 |
/**
|
| 5 |
* Exception when a client error is encountered (4xx codes)
|
| 6 |
*/
|
| 7 |
-
class ClientException extends BadResponseException
|
|
|
|
|
|
| 4 |
/**
|
| 5 |
* Exception when a client error is encountered (4xx codes)
|
| 6 |
*/
|
| 7 |
+
class ClientException extends BadResponseException
|
| 8 |
+
{
|
| 9 |
+
}
|
includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Exception/GuzzleException.php
CHANGED
|
@@ -1,13 +1,23 @@
|
|
| 1 |
<?php
|
| 2 |
namespace GuzzleHttp\Exception;
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
<?php
|
| 2 |
namespace GuzzleHttp\Exception;
|
| 3 |
|
| 4 |
+
use Throwable;
|
| 5 |
+
|
| 6 |
+
if (interface_exists(Throwable::class)) {
|
| 7 |
+
interface GuzzleException extends Throwable
|
| 8 |
+
{
|
| 9 |
+
}
|
| 10 |
+
} else {
|
| 11 |
+
/**
|
| 12 |
+
* @method string getMessage()
|
| 13 |
+
* @method \Throwable|null getPrevious()
|
| 14 |
+
* @method mixed getCode()
|
| 15 |
+
* @method string getFile()
|
| 16 |
+
* @method int getLine()
|
| 17 |
+
* @method array getTrace()
|
| 18 |
+
* @method string getTraceAsString()
|
| 19 |
+
*/
|
| 20 |
+
interface GuzzleException
|
| 21 |
+
{
|
| 22 |
+
}
|
| 23 |
+
}
|
includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Exception/InvalidArgumentException.php
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace GuzzleHttp\Exception;
|
| 4 |
+
|
| 5 |
+
final class InvalidArgumentException extends \InvalidArgumentException implements GuzzleException
|
| 6 |
+
{
|
| 7 |
+
}
|
includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php
CHANGED
|
@@ -126,7 +126,7 @@ class RequestException extends TransferException
|
|
| 126 |
{
|
| 127 |
$body = $response->getBody();
|
| 128 |
|
| 129 |
-
if (!$body->isSeekable()) {
|
| 130 |
return null;
|
| 131 |
}
|
| 132 |
|
| 126 |
{
|
| 127 |
$body = $response->getBody();
|
| 128 |
|
| 129 |
+
if (!$body->isSeekable() || !$body->isReadable()) {
|
| 130 |
return null;
|
| 131 |
}
|
| 132 |
|
includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Exception/ServerException.php
CHANGED
|
@@ -4,4 +4,6 @@ namespace GuzzleHttp\Exception;
|
|
| 4 |
/**
|
| 5 |
* Exception when a server error is encountered (5xx codes)
|
| 6 |
*/
|
| 7 |
-
class ServerException extends BadResponseException
|
|
|
|
|
|
| 4 |
/**
|
| 5 |
* Exception when a server error is encountered (5xx codes)
|
| 6 |
*/
|
| 7 |
+
class ServerException extends BadResponseException
|
| 8 |
+
{
|
| 9 |
+
}
|
includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php
CHANGED
|
@@ -1,4 +1,6 @@
|
|
| 1 |
<?php
|
| 2 |
namespace GuzzleHttp\Exception;
|
| 3 |
|
| 4 |
-
class TooManyRedirectsException extends RequestException
|
|
|
|
|
|
| 1 |
<?php
|
| 2 |
namespace GuzzleHttp\Exception;
|
| 3 |
|
| 4 |
+
class TooManyRedirectsException extends RequestException
|
| 5 |
+
{
|
| 6 |
+
}
|
includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Exception/TransferException.php
CHANGED
|
@@ -1,4 +1,6 @@
|
|
| 1 |
<?php
|
| 2 |
namespace GuzzleHttp\Exception;
|
| 3 |
|
| 4 |
-
class TransferException extends \RuntimeException implements GuzzleException
|
|
|
|
|
|
| 1 |
<?php
|
| 2 |
namespace GuzzleHttp\Exception;
|
| 3 |
|
| 4 |
+
class TransferException extends \RuntimeException implements GuzzleException
|
| 5 |
+
{
|
| 6 |
+
}
|
includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php
CHANGED
|
@@ -14,6 +14,9 @@ use Psr\Http\Message\RequestInterface;
|
|
| 14 |
*/
|
| 15 |
class CurlFactory implements CurlFactoryInterface
|
| 16 |
{
|
|
|
|
|
|
|
|
|
|
| 17 |
/** @var array */
|
| 18 |
private $handles = [];
|
| 19 |
|
|
@@ -117,6 +120,7 @@ class CurlFactory implements CurlFactoryInterface
|
|
| 117 |
private static function invokeStats(EasyHandle $easy)
|
| 118 |
{
|
| 119 |
$curlStats = curl_getinfo($easy->handle);
|
|
|
|
| 120 |
$stats = new TransferStats(
|
| 121 |
$easy->request,
|
| 122 |
$easy->response,
|
|
@@ -136,7 +140,9 @@ class CurlFactory implements CurlFactoryInterface
|
|
| 136 |
$ctx = [
|
| 137 |
'errno' => $easy->errno,
|
| 138 |
'error' => curl_error($easy->handle),
|
|
|
|
| 139 |
] + curl_getinfo($easy->handle);
|
|
|
|
| 140 |
$factory->release($easy);
|
| 141 |
|
| 142 |
// Retry when nothing is present or when curl failed to rewind.
|
|
@@ -172,13 +178,22 @@ class CurlFactory implements CurlFactoryInterface
|
|
| 172 |
)
|
| 173 |
);
|
| 174 |
}
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
|
| 183 |
// Create a connection exception if it was a specific error code.
|
| 184 |
$error = isset($connectionErrors[$easy->errno])
|
| 14 |
*/
|
| 15 |
class CurlFactory implements CurlFactoryInterface
|
| 16 |
{
|
| 17 |
+
const CURL_VERSION_STR = 'curl_version';
|
| 18 |
+
const LOW_CURL_VERSION_NUMBER = '7.21.2';
|
| 19 |
+
|
| 20 |
/** @var array */
|
| 21 |
private $handles = [];
|
| 22 |
|
| 120 |
private static function invokeStats(EasyHandle $easy)
|
| 121 |
{
|
| 122 |
$curlStats = curl_getinfo($easy->handle);
|
| 123 |
+
$curlStats['appconnect_time'] = curl_getinfo($easy->handle, CURLINFO_APPCONNECT_TIME);
|
| 124 |
$stats = new TransferStats(
|
| 125 |
$easy->request,
|
| 126 |
$easy->response,
|
| 140 |
$ctx = [
|
| 141 |
'errno' => $easy->errno,
|
| 142 |
'error' => curl_error($easy->handle),
|
| 143 |
+
'appconnect_time' => curl_getinfo($easy->handle, CURLINFO_APPCONNECT_TIME),
|
| 144 |
] + curl_getinfo($easy->handle);
|
| 145 |
+
$ctx[self::CURL_VERSION_STR] = curl_version()['version'];
|
| 146 |
$factory->release($easy);
|
| 147 |
|
| 148 |
// Retry when nothing is present or when curl failed to rewind.
|
| 178 |
)
|
| 179 |
);
|
| 180 |
}
|
| 181 |
+
if (version_compare($ctx[self::CURL_VERSION_STR], self::LOW_CURL_VERSION_NUMBER)) {
|
| 182 |
+
$message = sprintf(
|
| 183 |
+
'cURL error %s: %s (%s)',
|
| 184 |
+
$ctx['errno'],
|
| 185 |
+
$ctx['error'],
|
| 186 |
+
'see https://curl.haxx.se/libcurl/c/libcurl-errors.html'
|
| 187 |
+
);
|
| 188 |
+
} else {
|
| 189 |
+
$message = sprintf(
|
| 190 |
+
'cURL error %s: %s (%s) for %s',
|
| 191 |
+
$ctx['errno'],
|
| 192 |
+
$ctx['error'],
|
| 193 |
+
'see https://curl.haxx.se/libcurl/c/libcurl-errors.html',
|
| 194 |
+
$easy->request->getUri()
|
| 195 |
+
);
|
| 196 |
+
}
|
| 197 |
|
| 198 |
// Create a connection exception if it was a specific error code.
|
| 199 |
$error = isset($connectionErrors[$easy->errno])
|
includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php
CHANGED
|
@@ -37,8 +37,14 @@ class CurlMultiHandler
|
|
| 37 |
{
|
| 38 |
$this->factory = isset($options['handle_factory'])
|
| 39 |
? $options['handle_factory'] : new CurlFactory(50);
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
}
|
| 43 |
|
| 44 |
public function __get($name)
|
|
@@ -82,7 +88,7 @@ class CurlMultiHandler
|
|
| 82 |
{
|
| 83 |
// Add any delayed handles if needed.
|
| 84 |
if ($this->delays) {
|
| 85 |
-
$currentTime =
|
| 86 |
foreach ($this->delays as $id => $delay) {
|
| 87 |
if ($currentTime >= $delay) {
|
| 88 |
unset($this->delays[$id]);
|
|
@@ -134,7 +140,7 @@ class CurlMultiHandler
|
|
| 134 |
if (empty($easy->options['delay'])) {
|
| 135 |
curl_multi_add_handle($this->_mh, $easy->handle);
|
| 136 |
} else {
|
| 137 |
-
$this->delays[$id] =
|
| 138 |
}
|
| 139 |
}
|
| 140 |
|
|
@@ -186,7 +192,7 @@ class CurlMultiHandler
|
|
| 186 |
|
| 187 |
private function timeToNext()
|
| 188 |
{
|
| 189 |
-
$currentTime =
|
| 190 |
$nextTime = PHP_INT_MAX;
|
| 191 |
foreach ($this->delays as $time) {
|
| 192 |
if ($time < $nextTime) {
|
| 37 |
{
|
| 38 |
$this->factory = isset($options['handle_factory'])
|
| 39 |
? $options['handle_factory'] : new CurlFactory(50);
|
| 40 |
+
|
| 41 |
+
if (isset($options['select_timeout'])) {
|
| 42 |
+
$this->selectTimeout = $options['select_timeout'];
|
| 43 |
+
} elseif ($selectTimeout = getenv('GUZZLE_CURL_SELECT_TIMEOUT')) {
|
| 44 |
+
$this->selectTimeout = $selectTimeout;
|
| 45 |
+
} else {
|
| 46 |
+
$this->selectTimeout = 1;
|
| 47 |
+
}
|
| 48 |
}
|
| 49 |
|
| 50 |
public function __get($name)
|
| 88 |
{
|
| 89 |
// Add any delayed handles if needed.
|
| 90 |
if ($this->delays) {
|
| 91 |
+
$currentTime = \GuzzleHttp\_current_time();
|
| 92 |
foreach ($this->delays as $id => $delay) {
|
| 93 |
if ($currentTime >= $delay) {
|
| 94 |
unset($this->delays[$id]);
|
| 140 |
if (empty($easy->options['delay'])) {
|
| 141 |
curl_multi_add_handle($this->_mh, $easy->handle);
|
| 142 |
} else {
|
| 143 |
+
$this->delays[$id] = \GuzzleHttp\_current_time() + ($easy->options['delay'] / 1000);
|
| 144 |
}
|
| 145 |
}
|
| 146 |
|
| 192 |
|
| 193 |
private function timeToNext()
|
| 194 |
{
|
| 195 |
+
$currentTime = \GuzzleHttp\_current_time();
|
| 196 |
$nextTime = PHP_INT_MAX;
|
| 197 |
foreach ($this->delays as $time) {
|
| 198 |
if ($time < $nextTime) {
|
includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php
CHANGED
|
@@ -182,7 +182,8 @@ class MockHandler implements \Countable
|
|
| 182 |
$reason = null
|
| 183 |
) {
|
| 184 |
if (isset($options['on_stats'])) {
|
| 185 |
-
$
|
|
|
|
| 186 |
call_user_func($options['on_stats'], $stats);
|
| 187 |
}
|
| 188 |
}
|
| 182 |
$reason = null
|
| 183 |
) {
|
| 184 |
if (isset($options['on_stats'])) {
|
| 185 |
+
$transferTime = isset($options['transfer_time']) ? $options['transfer_time'] : 0;
|
| 186 |
+
$stats = new TransferStats($request, $response, $transferTime, $reason);
|
| 187 |
call_user_func($options['on_stats'], $stats);
|
| 188 |
}
|
| 189 |
}
|
includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php
CHANGED
|
@@ -33,7 +33,7 @@ class StreamHandler
|
|
| 33 |
usleep($options['delay'] * 1000);
|
| 34 |
}
|
| 35 |
|
| 36 |
-
$startTime = isset($options['on_stats']) ?
|
| 37 |
|
| 38 |
try {
|
| 39 |
// Does not support the expect header.
|
|
@@ -42,7 +42,7 @@ class StreamHandler
|
|
| 42 |
// Append a content-length header if body size is zero to match
|
| 43 |
// cURL's behavior.
|
| 44 |
if (0 === $request->getBody()->getSize()) {
|
| 45 |
-
$request = $request->withHeader('Content-Length', 0);
|
| 46 |
}
|
| 47 |
|
| 48 |
return $this->createResponse(
|
|
@@ -82,7 +82,7 @@ class StreamHandler
|
|
| 82 |
$stats = new TransferStats(
|
| 83 |
$request,
|
| 84 |
$response,
|
| 85 |
-
|
| 86 |
$error,
|
| 87 |
[]
|
| 88 |
);
|
|
@@ -343,13 +343,25 @@ class StreamHandler
|
|
| 343 |
if ('v4' === $options['force_ip_resolve']) {
|
| 344 |
$records = dns_get_record($uri->getHost(), DNS_A);
|
| 345 |
if (!isset($records[0]['ip'])) {
|
| 346 |
-
throw new ConnectException(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 347 |
}
|
| 348 |
$uri = $uri->withHost($records[0]['ip']);
|
| 349 |
} elseif ('v6' === $options['force_ip_resolve']) {
|
| 350 |
$records = dns_get_record($uri->getHost(), DNS_AAAA);
|
| 351 |
if (!isset($records[0]['ipv6'])) {
|
| 352 |
-
throw new ConnectException(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 353 |
}
|
| 354 |
$uri = $uri->withHost('[' . $records[0]['ipv6'] . ']');
|
| 355 |
}
|
| 33 |
usleep($options['delay'] * 1000);
|
| 34 |
}
|
| 35 |
|
| 36 |
+
$startTime = isset($options['on_stats']) ? \GuzzleHttp\_current_time() : null;
|
| 37 |
|
| 38 |
try {
|
| 39 |
// Does not support the expect header.
|
| 42 |
// Append a content-length header if body size is zero to match
|
| 43 |
// cURL's behavior.
|
| 44 |
if (0 === $request->getBody()->getSize()) {
|
| 45 |
+
$request = $request->withHeader('Content-Length', '0');
|
| 46 |
}
|
| 47 |
|
| 48 |
return $this->createResponse(
|
| 82 |
$stats = new TransferStats(
|
| 83 |
$request,
|
| 84 |
$response,
|
| 85 |
+
\GuzzleHttp\_current_time() - $startTime,
|
| 86 |
$error,
|
| 87 |
[]
|
| 88 |
);
|
| 343 |
if ('v4' === $options['force_ip_resolve']) {
|
| 344 |
$records = dns_get_record($uri->getHost(), DNS_A);
|
| 345 |
if (!isset($records[0]['ip'])) {
|
| 346 |
+
throw new ConnectException(
|
| 347 |
+
sprintf(
|
| 348 |
+
"Could not resolve IPv4 address for host '%s'",
|
| 349 |
+
$uri->getHost()
|
| 350 |
+
),
|
| 351 |
+
$request
|
| 352 |
+
);
|
| 353 |
}
|
| 354 |
$uri = $uri->withHost($records[0]['ip']);
|
| 355 |
} elseif ('v6' === $options['force_ip_resolve']) {
|
| 356 |
$records = dns_get_record($uri->getHost(), DNS_AAAA);
|
| 357 |
if (!isset($records[0]['ipv6'])) {
|
| 358 |
+
throw new ConnectException(
|
| 359 |
+
sprintf(
|
| 360 |
+
"Could not resolve IPv6 address for host '%s'",
|
| 361 |
+
$uri->getHost()
|
| 362 |
+
),
|
| 363 |
+
$request
|
| 364 |
+
);
|
| 365 |
}
|
| 366 |
$uri = $uri->withHost('[' . $records[0]['ipv6'] . ']');
|
| 367 |
}
|
includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/HandlerStack.php
CHANGED
|
@@ -206,7 +206,7 @@ class HandlerStack
|
|
| 206 |
}
|
| 207 |
|
| 208 |
/**
|
| 209 |
-
* @param $name
|
| 210 |
* @return int
|
| 211 |
*/
|
| 212 |
private function findByName($name)
|
|
@@ -223,10 +223,10 @@ class HandlerStack
|
|
| 223 |
/**
|
| 224 |
* Splices a function into the middleware list at a specific position.
|
| 225 |
*
|
| 226 |
-
* @param
|
| 227 |
-
* @param
|
| 228 |
* @param callable $middleware
|
| 229 |
-
* @param
|
| 230 |
*/
|
| 231 |
private function splice($findName, $withName, callable $middleware, $before)
|
| 232 |
{
|
| 206 |
}
|
| 207 |
|
| 208 |
/**
|
| 209 |
+
* @param string $name
|
| 210 |
* @return int
|
| 211 |
*/
|
| 212 |
private function findByName($name)
|
| 223 |
/**
|
| 224 |
* Splices a function into the middleware list at a specific position.
|
| 225 |
*
|
| 226 |
+
* @param string $findName
|
| 227 |
+
* @param string $withName
|
| 228 |
* @param callable $middleware
|
| 229 |
+
* @param bool $before
|
| 230 |
*/
|
| 231 |
private function splice($findName, $withName, callable $middleware, $before)
|
| 232 |
{
|
includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Middleware.php
CHANGED
|
@@ -7,7 +7,6 @@ use GuzzleHttp\Promise\RejectedPromise;
|
|
| 7 |
use GuzzleHttp\Psr7;
|
| 8 |
use Psr\Http\Message\ResponseInterface;
|
| 9 |
use Psr\Log\LoggerInterface;
|
| 10 |
-
use Psr\Log\LogLevel;
|
| 11 |
|
| 12 |
/**
|
| 13 |
* Functions used to create and wrap handlers with handler middleware.
|
|
@@ -39,7 +38,7 @@ final class Middleware
|
|
| 39 |
$cookieJar->extractCookies($request, $response);
|
| 40 |
return $response;
|
| 41 |
}
|
| 42 |
-
|
| 43 |
};
|
| 44 |
};
|
| 45 |
}
|
|
@@ -58,7 +57,7 @@ final class Middleware
|
|
| 58 |
return $handler($request, $options);
|
| 59 |
}
|
| 60 |
return $handler($request, $options)->then(
|
| 61 |
-
function (ResponseInterface $response) use ($request
|
| 62 |
$code = $response->getStatusCode();
|
| 63 |
if ($code < 400) {
|
| 64 |
return $response;
|
|
@@ -183,7 +182,7 @@ final class Middleware
|
|
| 183 |
*
|
| 184 |
* @return callable Returns a function that accepts the next handler.
|
| 185 |
*/
|
| 186 |
-
public static function log(LoggerInterface $logger, MessageFormatter $formatter, $logLevel = LogLevel::INFO)
|
| 187 |
{
|
| 188 |
return function (callable $handler) use ($logger, $formatter, $logLevel) {
|
| 189 |
return function ($request, array $options) use ($handler, $logger, $formatter, $logLevel) {
|
| 7 |
use GuzzleHttp\Psr7;
|
| 8 |
use Psr\Http\Message\ResponseInterface;
|
| 9 |
use Psr\Log\LoggerInterface;
|
|
|
|
| 10 |
|
| 11 |
/**
|
| 12 |
* Functions used to create and wrap handlers with handler middleware.
|
| 38 |
$cookieJar->extractCookies($request, $response);
|
| 39 |
return $response;
|
| 40 |
}
|
| 41 |
+
);
|
| 42 |
};
|
| 43 |
};
|
| 44 |
}
|
| 57 |
return $handler($request, $options);
|
| 58 |
}
|
| 59 |
return $handler($request, $options)->then(
|
| 60 |
+
function (ResponseInterface $response) use ($request) {
|
| 61 |
$code = $response->getStatusCode();
|
| 62 |
if ($code < 400) {
|
| 63 |
return $response;
|
| 182 |
*
|
| 183 |
* @return callable Returns a function that accepts the next handler.
|
| 184 |
*/
|
| 185 |
+
public static function log(LoggerInterface $logger, MessageFormatter $formatter, $logLevel = 'info' /* \Psr\Log\LogLevel::INFO */)
|
| 186 |
{
|
| 187 |
return function (callable $handler) use ($logger, $formatter, $logLevel) {
|
| 188 |
return function ($request, array $options) use ($handler, $logger, $formatter, $logLevel) {
|
includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/Pool.php
CHANGED
|
@@ -6,7 +6,7 @@ use Psr\Http\Message\RequestInterface;
|
|
| 6 |
use GuzzleHttp\Promise\EachPromise;
|
| 7 |
|
| 8 |
/**
|
| 9 |
-
* Sends
|
| 10 |
*
|
| 11 |
* The pool will read from an iterator until it is cancelled or until the
|
| 12 |
* iterator is consumed. When a request is yielded, the request is sent after
|
| 6 |
use GuzzleHttp\Promise\EachPromise;
|
| 7 |
|
| 8 |
/**
|
| 9 |
+
* Sends an iterator of requests concurrently using a capped pool size.
|
| 10 |
*
|
| 11 |
* The pool will read from an iterator until it is cancelled or until the
|
| 12 |
* iterator is consumed. When a request is yielded, the request is sent after
|
includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php
CHANGED
|
@@ -186,7 +186,7 @@ class RedirectMiddleware
|
|
| 186 |
if ($options['allow_redirects']['referer']
|
| 187 |
&& $modify['uri']->getScheme() === $request->getUri()->getScheme()
|
| 188 |
) {
|
| 189 |
-
$uri = $request->getUri()->withUserInfo(''
|
| 190 |
$modify['set_headers']['Referer'] = (string) $uri;
|
| 191 |
} else {
|
| 192 |
$modify['remove_headers'][] = 'Referer';
|
| 186 |
if ($options['allow_redirects']['referer']
|
| 187 |
&& $modify['uri']->getScheme() === $request->getUri()->getScheme()
|
| 188 |
) {
|
| 189 |
+
$uri = $request->getUri()->withUserInfo('');
|
| 190 |
$modify['set_headers']['Referer'] = (string) $uri;
|
| 191 |
} else {
|
| 192 |
$modify['remove_headers'][] = 'Referer';
|
includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/RequestOptions.php
CHANGED
|
@@ -22,7 +22,7 @@ final class RequestOptions
|
|
| 22 |
* - strict: (bool, default=false) Set to true to use strict redirects
|
| 23 |
* meaning redirect POST requests with POST requests vs. doing what most
|
| 24 |
* browsers do which is redirect POST requests with GET requests
|
| 25 |
-
* - referer: (bool, default=
|
| 26 |
* header.
|
| 27 |
* - protocols: (array, default=['http', 'https']) Allowed redirect
|
| 28 |
* protocols.
|
| 22 |
* - strict: (bool, default=false) Set to true to use strict redirects
|
| 23 |
* meaning redirect POST requests with POST requests vs. doing what most
|
| 24 |
* browsers do which is redirect POST requests with GET requests
|
| 25 |
+
* - referer: (bool, default=false) Set to true to enable the Referer
|
| 26 |
* header.
|
| 27 |
* - protocols: (array, default=['http', 'https']) Allowed redirect
|
| 28 |
* protocols.
|
includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php
CHANGED
|
@@ -19,6 +19,9 @@ class RetryMiddleware
|
|
| 19 |
/** @var callable */
|
| 20 |
private $decider;
|
| 21 |
|
|
|
|
|
|
|
|
|
|
| 22 |
/**
|
| 23 |
* @param callable $decider Function that accepts the number of retries,
|
| 24 |
* a request, [response], and [exception] and
|
|
@@ -42,7 +45,7 @@ class RetryMiddleware
|
|
| 42 |
/**
|
| 43 |
* Default exponential backoff delay function.
|
| 44 |
*
|
| 45 |
-
* @param $retries
|
| 46 |
*
|
| 47 |
* @return int
|
| 48 |
*/
|
| 19 |
/** @var callable */
|
| 20 |
private $decider;
|
| 21 |
|
| 22 |
+
/** @var callable */
|
| 23 |
+
private $delay;
|
| 24 |
+
|
| 25 |
/**
|
| 26 |
* @param callable $decider Function that accepts the number of retries,
|
| 27 |
* a request, [response], and [exception] and
|
| 45 |
/**
|
| 46 |
* Default exponential backoff delay function.
|
| 47 |
*
|
| 48 |
+
* @param int $retries
|
| 49 |
*
|
| 50 |
* @return int
|
| 51 |
*/
|
includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/TransferStats.php
CHANGED
|
@@ -20,7 +20,7 @@ final class TransferStats
|
|
| 20 |
/**
|
| 21 |
* @param RequestInterface $request Request that was sent.
|
| 22 |
* @param ResponseInterface $response Response received (if any)
|
| 23 |
-
* @param null
|
| 24 |
* @param mixed $handlerErrorData Handler error data.
|
| 25 |
* @param array $handlerStats Handler specific stats.
|
| 26 |
*/
|
| 20 |
/**
|
| 21 |
* @param RequestInterface $request Request that was sent.
|
| 22 |
* @param ResponseInterface $response Response received (if any)
|
| 23 |
+
* @param float|null $transferTime Total handler transfer time.
|
| 24 |
* @param mixed $handlerErrorData Handler error data.
|
| 25 |
* @param array $handlerStats Handler specific stats.
|
| 26 |
*/
|
includes/mollie-api-php/vendor/guzzlehttp/guzzle/src/functions.php
CHANGED
|
@@ -196,7 +196,8 @@ function default_ca_bundle()
|
|
| 196 |
}
|
| 197 |
}
|
| 198 |
|
| 199 |
-
throw new \RuntimeException(
|
|
|
|
| 200 |
No system CA bundle could be found in any of the the common system locations.
|
| 201 |
PHP versions earlier than 5.6 are not properly configured to use the system's
|
| 202 |
CA bundle by default. In order to verify peer certificates, you will need to
|
|
@@ -294,14 +295,14 @@ function is_host_in_noproxy($host, array $noProxyArray)
|
|
| 294 |
* @param int $options Bitmask of JSON decode options.
|
| 295 |
*
|
| 296 |
* @return mixed
|
| 297 |
-
* @throws \InvalidArgumentException if the JSON cannot be decoded.
|
| 298 |
* @link http://www.php.net/manual/en/function.json-decode.php
|
| 299 |
*/
|
| 300 |
function json_decode($json, $assoc = false, $depth = 512, $options = 0)
|
| 301 |
{
|
| 302 |
$data = \json_decode($json, $assoc, $depth, $options);
|
| 303 |
if (JSON_ERROR_NONE !== json_last_error()) {
|
| 304 |
-
throw new \InvalidArgumentException(
|
| 305 |
'json_decode error: ' . json_last_error_msg()
|
| 306 |
);
|
| 307 |
}
|
|
@@ -317,17 +318,29 @@ function json_decode($json, $assoc = false, $depth = 512, $options = 0)
|
|
| 317 |
* @param int $depth Set the maximum depth. Must be greater than zero.
|
| 318 |
*
|
| 319 |
* @return string
|
| 320 |
-
* @throws \InvalidArgumentException if the JSON cannot be encoded.
|
| 321 |
* @link http://www.php.net/manual/en/function.json-encode.php
|
| 322 |
*/
|
| 323 |
function json_encode($value, $options = 0, $depth = 512)
|
| 324 |
{
|
| 325 |
$json = \json_encode($value, $options, $depth);
|
| 326 |
if (JSON_ERROR_NONE !== json_last_error()) {
|
| 327 |
-
throw new \InvalidArgumentException(
|
| 328 |
'json_encode error: ' . json_last_error_msg()
|
| 329 |
);
|
| 330 |
}
|
| 331 |
|
| 332 |
return $json;
|
| 333 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
}
|
| 197 |
}
|
| 198 |
|
| 199 |
+
throw new \RuntimeException(
|
| 200 |
+
<<< EOT
|
| 201 |
No system CA bundle could be found in any of the the common system locations.
|
| 202 |
PHP versions earlier than 5.6 are not properly configured to use the system's
|
| 203 |
CA bundle by default. In order to verify peer certificates, you will need to
|
| 295 |
* @param int $options Bitmask of JSON decode options.
|
| 296 |
*
|
| 297 |
* @return mixed
|
| 298 |
+
* @throws Exception\InvalidArgumentException if the JSON cannot be decoded.
|
| 299 |
* @link http://www.php.net/manual/en/function.json-decode.php
|
| 300 |
*/
|
| 301 |
function json_decode($json, $assoc = false, $depth = 512, $options = 0)
|
| 302 |
{
|
| 303 |
$data = \json_decode($json, $assoc, $depth, $options);
|
| 304 |
if (JSON_ERROR_NONE !== json_last_error()) {
|
| 305 |
+
throw new Exception\InvalidArgumentException(
|
| 306 |
'json_decode error: ' . json_last_error_msg()
|
| 307 |
);
|
| 308 |
}
|
| 318 |
* @param int $depth Set the maximum depth. Must be greater than zero.
|
| 319 |
*
|
| 320 |
* @return string
|
| 321 |
+
* @throws Exception\InvalidArgumentException if the JSON cannot be encoded.
|
| 322 |
* @link http://www.php.net/manual/en/function.json-encode.php
|
| 323 |
*/
|
| 324 |
function json_encode($value, $options = 0, $depth = 512)
|
| 325 |
{
|
| 326 |
$json = \json_encode($value, $options, $depth);
|
| 327 |
if (JSON_ERROR_NONE !== json_last_error()) {
|
| 328 |
+
throw new Exception\InvalidArgumentException(
|
| 329 |
'json_encode error: ' . json_last_error_msg()
|
| 330 |
);
|
| 331 |
}
|
| 332 |
|
| 333 |
return $json;
|
| 334 |
}
|
| 335 |
+
|
| 336 |
+
/**
|
| 337 |
+
* Wrapper for the hrtime() or microtime() functions
|
| 338 |
+
* (depending on the PHP version, one of the two is used)
|
| 339 |
+
*
|
| 340 |
+
* @return float|mixed UNIX timestamp
|
| 341 |
+
* @internal
|
| 342 |
+
*/
|
| 343 |
+
function _current_time()
|
| 344 |
+
{
|
| 345 |
+
return function_exists('hrtime') ? hrtime(true) / 1e9 : microtime(true);
|
| 346 |
+
}
|
includes/mollie/OrderLineStatus.php
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
use Mollie\Api\Types\OrderLineStatus as ApiOrderLineStatus;
|
| 4 |
+
|
| 5 |
+
/**
|
| 6 |
+
* Class OrderLineStatuses
|
| 7 |
+
*/
|
| 8 |
+
class OrderLineStatus extends ApiOrderLineStatus
|
| 9 |
+
{
|
| 10 |
+
const CAN_BE_CANCELED = [
|
| 11 |
+
self::STATUS_CREATED,
|
| 12 |
+
self::STATUS_AUTHORIZED,
|
| 13 |
+
];
|
| 14 |
+
|
| 15 |
+
const CAN_BE_REFUNDED = [
|
| 16 |
+
self::STATUS_PAID,
|
| 17 |
+
self::STATUS_SHIPPING,
|
| 18 |
+
self::STATUS_COMPLETED,
|
| 19 |
+
];
|
| 20 |
+
}
|
includes/mollie/wc/gateway/abstract.php
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
<?php
|
| 2 |
|
|
|
|
| 3 |
use Mollie\Api\Types\PaymentMethod;
|
| 4 |
|
| 5 |
abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
|
|
@@ -437,14 +438,13 @@ abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
|
|
| 437 |
0 != $order->get_user_id() && ( wcs_order_contains_switch( $order ) )
|
| 438 |
) {
|
| 439 |
|
| 440 |
-
|
| 441 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 442 |
|
| 443 |
-
$data = array_filter( $paymentRequestData );
|
| 444 |
-
|
| 445 |
-
$data = apply_filters( 'woocommerce_' . $this->id . '_args', $data, $order );
|
| 446 |
-
|
| 447 |
-
try {
|
| 448 |
Mollie_WC_Plugin::debug( $this->id . ': Subscription switch started, fetching mandate(s) for order #' . $order_id );
|
| 449 |
$mandates = Mollie_WC_Plugin::getApiHelper()->getApiClient( $test_mode )->customers->get( $customer_id )->mandates();
|
| 450 |
$validMandate = false;
|
|
@@ -533,7 +533,14 @@ abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
|
|
| 533 |
Mollie_WC_Plugin::debug( $this->id . ': Create Mollie payment object for order ' . $order->get_id(), true );
|
| 534 |
}
|
| 535 |
|
| 536 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 537 |
$paymentRequestData = $payment_object->getPaymentRequestData( $order, $customer_id );
|
| 538 |
|
| 539 |
$data = array_filter( $paymentRequestData );
|
|
@@ -867,7 +874,15 @@ abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
|
|
| 867 |
$test_mode = $data_helper->getActiveMolliePaymentMode($order_id) == 'test';
|
| 868 |
|
| 869 |
// Load the payment from Mollie, do not use cache
|
| 870 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 871 |
$payment = $payment_object->getPaymentObject( $payment_object->data, $test_mode, $use_cache = false );
|
| 872 |
|
| 873 |
// Payment not found
|
|
@@ -1340,8 +1355,14 @@ abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
|
|
| 1340 |
return new WP_Error( '1', $error_message );
|
| 1341 |
}
|
| 1342 |
|
| 1343 |
-
|
| 1344 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1345 |
|
| 1346 |
if ( ! $payment_object ) {
|
| 1347 |
|
| 1 |
<?php
|
| 2 |
|
| 3 |
+
use Mollie\Api\Exceptions\ApiException;
|
| 4 |
use Mollie\Api\Types\PaymentMethod;
|
| 5 |
|
| 6 |
abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
|
| 438 |
0 != $order->get_user_id() && ( wcs_order_contains_switch( $order ) )
|
| 439 |
) {
|
| 440 |
|
| 441 |
+
try {
|
| 442 |
+
$payment_object = Mollie_WC_Plugin::getPaymentFactoryHelper()
|
| 443 |
+
->getPaymentObject('payment');
|
| 444 |
+
$paymentRequestData = $payment_object->getPaymentRequestData($order, $customer_id);
|
| 445 |
+
$data = array_filter($paymentRequestData);
|
| 446 |
+
$data = apply_filters('woocommerce_' . $this->id . '_args', $data, $order);
|
| 447 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 448 |
Mollie_WC_Plugin::debug( $this->id . ': Subscription switch started, fetching mandate(s) for order #' . $order_id );
|
| 449 |
$mandates = Mollie_WC_Plugin::getApiHelper()->getApiClient( $test_mode )->customers->get( $customer_id )->mandates();
|
| 450 |
$validMandate = false;
|
| 533 |
Mollie_WC_Plugin::debug( $this->id . ': Create Mollie payment object for order ' . $order->get_id(), true );
|
| 534 |
}
|
| 535 |
|
| 536 |
+
try {
|
| 537 |
+
$payment_object = Mollie_WC_Plugin::getPaymentFactoryHelper()
|
| 538 |
+
->getPaymentObject('order');
|
| 539 |
+
} catch (ApiException $exception) {
|
| 540 |
+
Mollie_WC_Plugin::debug($exception->getMessage());
|
| 541 |
+
return array('result' => 'failure');
|
| 542 |
+
}
|
| 543 |
+
|
| 544 |
$paymentRequestData = $payment_object->getPaymentRequestData( $order, $customer_id );
|
| 545 |
|
| 546 |
$data = array_filter( $paymentRequestData );
|
| 874 |
$test_mode = $data_helper->getActiveMolliePaymentMode($order_id) == 'test';
|
| 875 |
|
| 876 |
// Load the payment from Mollie, do not use cache
|
| 877 |
+
try {
|
| 878 |
+
$payment_object = Mollie_WC_Plugin::getPaymentFactoryHelper()
|
| 879 |
+
->getPaymentObject($payment_object_id);
|
| 880 |
+
} catch (ApiException $exception) {
|
| 881 |
+
Mollie_WC_Plugin::setHttpResponseCode(400);
|
| 882 |
+
Mollie_WC_Plugin::debug($exception->getMessage());
|
| 883 |
+
return;
|
| 884 |
+
}
|
| 885 |
+
|
| 886 |
$payment = $payment_object->getPaymentObject( $payment_object->data, $test_mode, $use_cache = false );
|
| 887 |
|
| 888 |
// Payment not found
|
| 1355 |
return new WP_Error( '1', $error_message );
|
| 1356 |
}
|
| 1357 |
|
| 1358 |
+
try {
|
| 1359 |
+
$payment_object = Mollie_WC_Plugin::getPaymentFactoryHelper()
|
| 1360 |
+
->getPaymentObject($payment_object_id);
|
| 1361 |
+
} catch (ApiException $exception) {
|
| 1362 |
+
$exceptionMessage = $exception->getMessage();
|
| 1363 |
+
Mollie_WC_Plugin::debug($exceptionMessage);
|
| 1364 |
+
return new WP_Error('error', $exceptionMessage);
|
| 1365 |
+
}
|
| 1366 |
|
| 1367 |
if ( ! $payment_object ) {
|
| 1368 |
|
includes/mollie/wc/gateway/abstractseparecurring.php
CHANGED
|
@@ -1,4 +1,7 @@
|
|
| 1 |
<?php
|
|
|
|
|
|
|
|
|
|
| 2 |
abstract class Mollie_WC_Gateway_AbstractSepaRecurring extends Mollie_WC_Gateway_AbstractSubscription
|
| 3 |
{
|
| 4 |
|
|
@@ -133,42 +136,47 @@ abstract class Mollie_WC_Gateway_AbstractSepaRecurring extends Mollie_WC_Gateway
|
|
| 133 |
*/
|
| 134 |
protected function handlePaidOrderWebhook($order, $payment)
|
| 135 |
{
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
|
| 170 |
parent::handlePaidOrderWebhook($order, $payment);
|
| 171 |
-
|
| 172 |
}
|
| 173 |
-
|
| 174 |
}
|
| 1 |
<?php
|
| 2 |
+
|
| 3 |
+
use Mollie\Api\Types\SequenceType;
|
| 4 |
+
|
| 5 |
abstract class Mollie_WC_Gateway_AbstractSepaRecurring extends Mollie_WC_Gateway_AbstractSubscription
|
| 6 |
{
|
| 7 |
|
| 136 |
*/
|
| 137 |
protected function handlePaidOrderWebhook($order, $payment)
|
| 138 |
{
|
| 139 |
+
$orderId = version_compare(WC_VERSION, '3.0', '<')
|
| 140 |
+
? $order->id
|
| 141 |
+
: $order->get_id();
|
| 142 |
+
|
| 143 |
+
// Duplicate webhook call
|
| 144 |
+
if (Mollie_WC_Plugin::getDataHelper()->isSubscription($orderId)
|
| 145 |
+
&& isset($payment->sequenceType)
|
| 146 |
+
&& $payment->sequenceType == SequenceType::SEQUENCETYPE_RECURRING
|
| 147 |
+
) {
|
| 148 |
+
$payment_method_title = $this->getPaymentMethodTitle($payment);
|
| 149 |
+
|
| 150 |
+
$isTestMode = $payment->mode === 'test';
|
| 151 |
+
$paymentMessage = $payment->id . (
|
| 152 |
+
$isTestMode
|
| 153 |
+
? (' - ' . __('test mode', 'mollie-payments-for-woocommerce'))
|
| 154 |
+
: ''
|
| 155 |
+
);
|
| 156 |
+
$order->add_order_note(
|
| 157 |
+
sprintf(
|
| 158 |
+
/* translators: Placeholder 1: payment method title, placeholder 2: payment ID */
|
| 159 |
+
__(
|
| 160 |
+
'Order completed using %1$s payment (%2$s).',
|
| 161 |
+
'mollie-payments-for-woocommerce'
|
| 162 |
+
),
|
| 163 |
+
$payment_method_title,
|
| 164 |
+
$paymentMessage
|
| 165 |
+
)
|
| 166 |
+
);
|
| 167 |
+
|
| 168 |
+
try {
|
| 169 |
+
$payment_object = Mollie_WC_Plugin::getPaymentFactoryHelper()
|
| 170 |
+
->getPaymentObject($payment);
|
| 171 |
+
} catch (ApiException $exception) {
|
| 172 |
+
Mollie_WC_Plugin::debug($exception->getMessage());
|
| 173 |
+
return;
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
$payment_object->deleteSubscriptionOrderFromPendingPaymentQueue($order);
|
| 177 |
+
return;
|
| 178 |
+
}
|
| 179 |
|
| 180 |
parent::handlePaidOrderWebhook($order, $payment);
|
|
|
|
| 181 |
}
|
|
|
|
| 182 |
}
|
includes/mollie/wc/helper/api.php
CHANGED
|
@@ -41,22 +41,17 @@ class Mollie_WC_Helper_Api {
|
|
| 41 |
throw new \Mollie\Api\Exceptions\ApiException( sprintf(__( "Invalid API key(s). Get them on the %sDevelopers page in the Mollie dashboard%s. The API key(s) must start with 'live_' or 'test_', be at least 30 characters and can't further contain any special characters.", 'mollie-payments-for-woocommerce' ), '<a href="https://www.mollie.com/dashboard/developers/api-keys" target="_blank">', '</a>' ) );
|
| 42 |
}
|
| 43 |
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
$client->addVersionString( 'MollieWoo/' . Mollie_WC_Plugin::PLUGIN_VERSION );
|
| 53 |
-
}
|
| 54 |
-
catch ( Mollie\Api\Exceptions\ApiException $e ) {
|
| 55 |
-
throw new \Mollie\Api\Exceptions\ApiException( $e->getMessage() );
|
| 56 |
-
}
|
| 57 |
|
| 58 |
-
|
| 59 |
-
|
| 60 |
|
| 61 |
return self::$api_client;
|
| 62 |
}
|
| 41 |
throw new \Mollie\Api\Exceptions\ApiException( sprintf(__( "Invalid API key(s). Get them on the %sDevelopers page in the Mollie dashboard%s. The API key(s) must start with 'live_' or 'test_', be at least 30 characters and can't further contain any special characters.", 'mollie-payments-for-woocommerce' ), '<a href="https://www.mollie.com/dashboard/developers/api-keys" target="_blank">', '</a>' ) );
|
| 42 |
}
|
| 43 |
|
| 44 |
+
if (empty(self::$api_client)) {
|
| 45 |
+
$client = new MollieApiClient();
|
| 46 |
+
$client->setApiKey( $api_key );
|
| 47 |
+
$client->setApiEndpoint( self::getApiEndpoint() );
|
| 48 |
+
$client->addVersionString( 'WordPress/' . ( isset( $wp_version ) ? $wp_version : 'Unknown' ) );
|
| 49 |
+
$client->addVersionString( 'WooCommerce/' . get_option( 'woocommerce_version', 'Unknown' ) );
|
| 50 |
+
$client->addVersionString( 'WooCommerceSubscriptions/' . get_option( 'woocommerce_subscriptions_active_version', 'Unknown' ) );
|
| 51 |
+
$client->addVersionString( 'MollieWoo/' . Mollie_WC_Plugin::PLUGIN_VERSION );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
+
self::$api_client = $client;
|
| 54 |
+
}
|
| 55 |
|
| 56 |
return self::$api_client;
|
| 57 |
}
|
includes/mollie/wc/helper/paymentfactory.php
CHANGED
|
@@ -1,19 +1,42 @@
|
|
| 1 |
<?php
|
| 2 |
|
| 3 |
-
|
| 4 |
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
}
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
|
|
|
|
|
|
| 18 |
}
|
| 19 |
|
| 1 |
<?php
|
| 2 |
|
| 3 |
+
use Mollie\Api\Exceptions\ApiException;
|
| 4 |
|
| 5 |
+
class Mollie_WC_Helper_PaymentFactory
|
| 6 |
+
{
|
| 7 |
+
/**
|
| 8 |
+
* @param $data
|
| 9 |
+
* @return bool|Mollie_WC_Payment_Order|Mollie_WC_Payment_Payment
|
| 10 |
+
* @throws ApiException
|
| 11 |
+
*/
|
| 12 |
+
public static function getPaymentObject($data)
|
| 13 |
+
{
|
| 14 |
+
if ((!is_object($data) && $data == 'order')
|
| 15 |
+
|| (!is_object($data) && strpos($data, 'ord_') !== false)
|
| 16 |
+
|| (is_object($data) && $data->resource == 'order')
|
| 17 |
+
) {
|
| 18 |
+
$dataHelper = Mollie_WC_Plugin::getDataHelper();
|
| 19 |
+
$refundLineItemsBuilder = new RefundLineItemsBuilder($dataHelper);
|
| 20 |
+
$apiHelper = Mollie_WC_Plugin::getApiHelper();
|
| 21 |
+
$settingsHelper = Mollie_WC_Plugin::getSettingsHelper();
|
| 22 |
|
| 23 |
+
$orderItemsRefunded = new OrderItemsRefunder(
|
| 24 |
+
$refundLineItemsBuilder,
|
| 25 |
+
$dataHelper,
|
| 26 |
+
$apiHelper->getApiClient($settingsHelper->isTestModeEnabled())->orders
|
| 27 |
+
);
|
| 28 |
|
| 29 |
+
return new Mollie_WC_Payment_Order($orderItemsRefunded, $data);
|
| 30 |
+
}
|
|
|
|
| 31 |
|
| 32 |
+
if ((!is_object($data) && $data == 'payment')
|
| 33 |
+
|| (!is_object($data) && strpos($data, 'tr_') !== false)
|
| 34 |
+
|| (is_object($data) && $data->resource == 'payment')
|
| 35 |
+
) {
|
| 36 |
+
return new Mollie_WC_Payment_Payment($data);
|
| 37 |
+
}
|
| 38 |
|
| 39 |
+
return false;
|
| 40 |
+
}
|
| 41 |
}
|
| 42 |
|
includes/mollie/wc/payment/OrderItemsRefunder.php
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
use Mollie\Api\Endpoints\OrderEndpoint;
|
| 4 |
+
use Mollie\Api\Exceptions\ApiException;
|
| 5 |
+
use Mollie\Api\Resources\Order;
|
| 6 |
+
use Mollie\Api\Resources\Refund;
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* Refund a WooCommerce order by line items
|
| 10 |
+
*/
|
| 11 |
+
class OrderItemsRefunder
|
| 12 |
+
{
|
| 13 |
+
const ACTION_AFTER_REFUND_ORDER_ITEMS = Mollie_WC_Plugin::PLUGIN_ID . '_refund_items_created';
|
| 14 |
+
const ACTION_AFTER_CANCELED_ORDER_ITEMS = Mollie_WC_Plugin::PLUGIN_ID . '_line_items_cancelled';
|
| 15 |
+
|
| 16 |
+
/**
|
| 17 |
+
* @var RefundLineItemsBuilder
|
| 18 |
+
*/
|
| 19 |
+
private $refundLineItemsBuilder;
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* @var Mollie_WC_Helper_Data
|
| 23 |
+
*/
|
| 24 |
+
private $dataHelper;
|
| 25 |
+
|
| 26 |
+
/**
|
| 27 |
+
* @var OrderEndpoint
|
| 28 |
+
*/
|
| 29 |
+
private $ordersApiClient;
|
| 30 |
+
|
| 31 |
+
/**
|
| 32 |
+
* OrderItemsRefunder constructor.
|
| 33 |
+
* @param RefundLineItemsBuilder $refundLineItemsBuilder
|
| 34 |
+
* @param Mollie_WC_Helper_Data $dataHelper
|
| 35 |
+
* @param OrderEndpoint $ordersApiClient
|
| 36 |
+
*/
|
| 37 |
+
public function __construct(
|
| 38 |
+
RefundLineItemsBuilder $refundLineItemsBuilder,
|
| 39 |
+
Mollie_WC_Helper_Data $dataHelper,
|
| 40 |
+
OrderEndpoint $ordersApiClient
|
| 41 |
+
) {
|
| 42 |
+
|
| 43 |
+
$this->refundLineItemsBuilder = $refundLineItemsBuilder;
|
| 44 |
+
$this->dataHelper = $dataHelper;
|
| 45 |
+
$this->ordersApiClient = $ordersApiClient;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
/**
|
| 49 |
+
* @param WC_Order $order WooCommerce Order
|
| 50 |
+
* @param array $items WooCommerce Order Items
|
| 51 |
+
* @param Order $remotePaymentObject Mollie Order service
|
| 52 |
+
* @param string $refundReason The reason of refunding
|
| 53 |
+
* @return bool
|
| 54 |
+
* @throws ApiException When the API call fails for any reason
|
| 55 |
+
* @throws UnexpectedValueException
|
| 56 |
+
*/
|
| 57 |
+
public function refund(
|
| 58 |
+
WC_Order $order,
|
| 59 |
+
array $items,
|
| 60 |
+
Order $remotePaymentObject,
|
| 61 |
+
$refundReason
|
| 62 |
+
) {
|
| 63 |
+
|
| 64 |
+
$toRefundItems = $this->normalizedWooCommerceItemsList($items);
|
| 65 |
+
$toRefundRemoteItems = $this->toRefundRemoteItems(
|
| 66 |
+
$remotePaymentObject->lines,
|
| 67 |
+
$toRefundItems
|
| 68 |
+
);
|
| 69 |
+
|
| 70 |
+
$this->bailIfNoItemsToRefund($toRefundItems, $toRefundRemoteItems);
|
| 71 |
+
|
| 72 |
+
$lineItems = $this->refundLineItemsBuilder->buildLineItems(
|
| 73 |
+
$toRefundRemoteItems,
|
| 74 |
+
$toRefundItems,
|
| 75 |
+
$this->dataHelper->getOrderCurrency($order),
|
| 76 |
+
$refundReason
|
| 77 |
+
);
|
| 78 |
+
|
| 79 |
+
$remoteOrder = $this->ordersApiClient->get($remotePaymentObject->id);
|
| 80 |
+
|
| 81 |
+
if (!empty($lineItems['toCancel']['lines'])) {
|
| 82 |
+
$this->cancelOrderLines($lineItems['toCancel'], $remoteOrder, $order);
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
if (!empty($lineItems['toRefund']['lines'])) {
|
| 86 |
+
$this->refundOrderLines($lineItems['toRefund'], $remoteOrder, $order);
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
return true;
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
/**
|
| 93 |
+
* Normalized version of WooCommerce order items where the key is the id of the item to refund
|
| 94 |
+
*
|
| 95 |
+
* @param array $items WooCommerce Order Items
|
| 96 |
+
* @return array
|
| 97 |
+
* @throws UnexpectedValueException
|
| 98 |
+
*/
|
| 99 |
+
private function normalizedWooCommerceItemsList(array $items)
|
| 100 |
+
{
|
| 101 |
+
$toRefundItems = [];
|
| 102 |
+
/** @var WC_Order_Item $item */
|
| 103 |
+
foreach ($items as $key => $item) {
|
| 104 |
+
$toRefundItemId = $item->get_meta('_refunded_item_id', true);
|
| 105 |
+
|
| 106 |
+
if (!$toRefundItemId) {
|
| 107 |
+
throw new UnexpectedValueException(
|
| 108 |
+
__(
|
| 109 |
+
'One of the WooCommerce order items does not have the refund item id meta value associated to Mollie Order item.',
|
| 110 |
+
'mollie-payments-for-woocommerce'
|
| 111 |
+
)
|
| 112 |
+
);
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
$toRefundItems[$toRefundItemId] = $item;
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
return $toRefundItems;
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
/**
|
| 122 |
+
* Given remote items of an order extract the ones for which the refund was requested
|
| 123 |
+
*
|
| 124 |
+
* @param array $remoteItems
|
| 125 |
+
* @param array $toRefundItems
|
| 126 |
+
* @return array
|
| 127 |
+
* @throws UnexpectedValueException
|
| 128 |
+
*/
|
| 129 |
+
private function toRefundRemoteItems(array $remoteItems, array $toRefundItems)
|
| 130 |
+
{
|
| 131 |
+
return array_intersect_key(
|
| 132 |
+
$this->normalizedRemoteItems($remoteItems),
|
| 133 |
+
$toRefundItems
|
| 134 |
+
);
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
/**
|
| 138 |
+
* Normalized version of remote items where the key is the id of the item to refund
|
| 139 |
+
*
|
| 140 |
+
* @param array $remoteItems
|
| 141 |
+
* @return array
|
| 142 |
+
* @throws UnexpectedValueException
|
| 143 |
+
*/
|
| 144 |
+
private function normalizedRemoteItems(array $remoteItems)
|
| 145 |
+
{
|
| 146 |
+
$relatedRemoteItems = [];
|
| 147 |
+
|
| 148 |
+
foreach ($remoteItems as $remoteItem) {
|
| 149 |
+
$orderItemId = isset($remoteItem->metadata->order_item_id)
|
| 150 |
+
? $remoteItem->metadata->order_item_id
|
| 151 |
+
: 0;
|
| 152 |
+
|
| 153 |
+
if (!$orderItemId) {
|
| 154 |
+
throw new UnexpectedValueException(
|
| 155 |
+
sprintf(
|
| 156 |
+
__(
|
| 157 |
+
'Impossible to retrieve the order item id related to the remote item: %1$s. Try to do a refund by amount.',
|
| 158 |
+
'mollie-payments-for-woocommerce'
|
| 159 |
+
),
|
| 160 |
+
$remoteItem->id
|
| 161 |
+
)
|
| 162 |
+
);
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
$relatedRemoteItems[$orderItemId] = $remoteItem;
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
return $relatedRemoteItems;
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
/**
|
| 172 |
+
* Throw an exception if one of the given items list is empty
|
| 173 |
+
*
|
| 174 |
+
* @param array $items
|
| 175 |
+
* @param array $remoteItems
|
| 176 |
+
* @throws UnexpectedValueException
|
| 177 |
+
*/
|
| 178 |
+
private function bailIfNoItemsToRefund(array $items, array $remoteItems)
|
| 179 |
+
{
|
| 180 |
+
if (empty($items) || empty($remoteItems)) {
|
| 181 |
+
throw new UnexpectedValueException(
|
| 182 |
+
__(
|
| 183 |
+
'Empty woocommerce order items or mollie order lines.',
|
| 184 |
+
'mollie-payments-for-woocommerce'
|
| 185 |
+
)
|
| 186 |
+
);
|
| 187 |
+
}
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
/**
|
| 191 |
+
* @param array $data
|
| 192 |
+
* @param Order $remoteOrder
|
| 193 |
+
* @param WC_Order $order
|
| 194 |
+
* @throws ApiException
|
| 195 |
+
*/
|
| 196 |
+
private function cancelOrderLines(array $data, Order $remoteOrder, WC_Order $order)
|
| 197 |
+
{
|
| 198 |
+
$remoteOrder->cancelLines($data);
|
| 199 |
+
|
| 200 |
+
/**
|
| 201 |
+
* Canceled Order Lines
|
| 202 |
+
*
|
| 203 |
+
* @param array $data Data sent to Mollie cancel endpoint
|
| 204 |
+
* @param WC_Order $order
|
| 205 |
+
*/
|
| 206 |
+
do_action(self::ACTION_AFTER_CANCELED_ORDER_ITEMS, $data, $order);
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
/**
|
| 210 |
+
* @param array $data
|
| 211 |
+
* @param Order $remoteOrder
|
| 212 |
+
* @param WC_Order $order
|
| 213 |
+
*/
|
| 214 |
+
private function refundOrderLines(array $data, Order $remoteOrder, WC_Order $order)
|
| 215 |
+
{
|
| 216 |
+
$refund = $remoteOrder->refund($data);
|
| 217 |
+
|
| 218 |
+
/**
|
| 219 |
+
* Refund Orders Lines
|
| 220 |
+
*
|
| 221 |
+
* @param Refund $refund Refund instance
|
| 222 |
+
* @param WC_Order $order
|
| 223 |
+
* @param array $data Data sent to Mollie refund endpoint
|
| 224 |
+
*/
|
| 225 |
+
do_action(self::ACTION_AFTER_REFUND_ORDER_ITEMS, $refund, $order, $data);
|
| 226 |
+
}
|
| 227 |
+
}
|
includes/mollie/wc/payment/PartialRefundException.php
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class PartialRefundException extends UnexpectedValueException
|
| 4 |
+
{
|
| 5 |
+
}
|
includes/mollie/wc/payment/RefundLineItemsBuilder.php
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Create the line items list to refund according to Mollie rest api documentation
|
| 5 |
+
*
|
| 6 |
+
* @link https://docs.mollie.com/reference/v2/orders-api/create-order-refund
|
| 7 |
+
*/
|
| 8 |
+
class RefundLineItemsBuilder
|
| 9 |
+
{
|
| 10 |
+
/**
|
| 11 |
+
* @var Mollie_WC_Helper_Data
|
| 12 |
+
*/
|
| 13 |
+
private $dataHelper;
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* RefundLineItemsBuilder constructor.
|
| 17 |
+
* @param Mollie_WC_Helper_Data $dataHelper
|
| 18 |
+
*/
|
| 19 |
+
public function __construct(Mollie_WC_Helper_Data $dataHelper)
|
| 20 |
+
{
|
| 21 |
+
$this->dataHelper = $dataHelper;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
/**
|
| 25 |
+
* @param array $toRefundRemoteItems
|
| 26 |
+
* @param array $toRefundItems
|
| 27 |
+
* @param string $currency
|
| 28 |
+
* @param string $refundReason
|
| 29 |
+
* @return array
|
| 30 |
+
* @throws PartialRefundException
|
| 31 |
+
* @throws UnexpectedValueException
|
| 32 |
+
*/
|
| 33 |
+
public function buildLineItems(
|
| 34 |
+
array $toRefundRemoteItems,
|
| 35 |
+
array $toRefundItems,
|
| 36 |
+
$currency,
|
| 37 |
+
$refundReason
|
| 38 |
+
) {
|
| 39 |
+
|
| 40 |
+
$toCancel = [
|
| 41 |
+
'description' => $refundReason,
|
| 42 |
+
'lines' => [],
|
| 43 |
+
];
|
| 44 |
+
$toRefund = [
|
| 45 |
+
'description' => $refundReason,
|
| 46 |
+
'lines' => [],
|
| 47 |
+
];
|
| 48 |
+
|
| 49 |
+
foreach ($toRefundItems as $toRefundItemId => $toRefundItem) {
|
| 50 |
+
$toRefundRemoteItem = isset($toRefundRemoteItems[$toRefundItemId])
|
| 51 |
+
? $toRefundRemoteItems[$toRefundItemId]
|
| 52 |
+
: null;
|
| 53 |
+
|
| 54 |
+
if ($toRefundRemoteItem === null) {
|
| 55 |
+
throw new UnexpectedValueException(
|
| 56 |
+
"Cannot refund {$toRefundItemId} item because it was not found in Mollie order. Aborting refund process. Try to do a refund by amount."
|
| 57 |
+
);
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
$lineItem = $this->buildLineItem(
|
| 61 |
+
$toRefundItem,
|
| 62 |
+
$toRefundRemoteItem,
|
| 63 |
+
$currency
|
| 64 |
+
);
|
| 65 |
+
|
| 66 |
+
if (!$lineItem) {
|
| 67 |
+
continue;
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
if (in_array($toRefundRemoteItem->status, OrderLineStatus::CAN_BE_CANCELED, true)) {
|
| 71 |
+
$toCancel['lines'][] = $lineItem;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
if (in_array($toRefundRemoteItem->status, OrderLineStatus::CAN_BE_REFUNDED, true)) {
|
| 75 |
+
$toRefund['lines'][] = $lineItem;
|
| 76 |
+
}
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
return compact('toCancel', 'toRefund');
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
/**
|
| 83 |
+
* @param WC_Order_Item $toRefundItem
|
| 84 |
+
* @param stdClass $toRefundRemoteItem
|
| 85 |
+
* @param string $currency
|
| 86 |
+
* @return array
|
| 87 |
+
* @throws PartialRefundException
|
| 88 |
+
*/
|
| 89 |
+
private function buildLineItem(
|
| 90 |
+
WC_Order_Item $toRefundItem,
|
| 91 |
+
stdClass $toRefundRemoteItem,
|
| 92 |
+
$currency
|
| 93 |
+
) {
|
| 94 |
+
|
| 95 |
+
$toRefundItemQuantity = abs($toRefundItem->get_quantity());
|
| 96 |
+
$toRefundItemAmount = number_format(
|
| 97 |
+
abs($toRefundItem->get_total() + $toRefundItem->get_total_tax()),
|
| 98 |
+
2
|
| 99 |
+
);
|
| 100 |
+
$toRefundRemoteItemPrice = isset($toRefundRemoteItem->unitPrice->value)
|
| 101 |
+
? $toRefundRemoteItem->unitPrice->value
|
| 102 |
+
: 0;
|
| 103 |
+
|
| 104 |
+
if ($toRefundItemAmount <= 0 || $toRefundItemQuantity < 1 || $toRefundRemoteItemPrice <= 0) {
|
| 105 |
+
return [];
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
$toRefundRemoteItemAmount = number_format(
|
| 109 |
+
$toRefundItemQuantity * $toRefundRemoteItemPrice,
|
| 110 |
+
2
|
| 111 |
+
);
|
| 112 |
+
|
| 113 |
+
if ($toRefundRemoteItemAmount !== $toRefundItemAmount) {
|
| 114 |
+
throw new PartialRefundException(
|
| 115 |
+
__(
|
| 116 |
+
'Mollie doesn\'t allow a partial refund of the full amount or quantity of at least one order line. Trying to process this as an amount refund instead.',
|
| 117 |
+
'mollie-payments-for-woocommerce'
|
| 118 |
+
)
|
| 119 |
+
);
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
$remoteClientData = [
|
| 123 |
+
'id' => $toRefundRemoteItem->id,
|
| 124 |
+
'quantity' => $toRefundItemQuantity,
|
| 125 |
+
];
|
| 126 |
+
|
| 127 |
+
if (!empty($toRefundRemoteItem->discountAmount)) {
|
| 128 |
+
$remoteClientData['amount'] = [
|
| 129 |
+
'value' => $this->dataHelper->formatCurrencyValue($toRefundItemAmount, $currency),
|
| 130 |
+
'currency' => $currency,
|
| 131 |
+
];
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
return $remoteClientData;
|
| 135 |
+
}
|
| 136 |
+
}
|
includes/mollie/wc/payment/object.php
CHANGED
|
@@ -396,7 +396,14 @@ class Mollie_WC_Payment_Object {
|
|
| 396 |
// If there is no payment ID, try to get order ID and if it's stored, try getting payment ID from API
|
| 397 |
if ( $this->hasActiveMollieOrder( $order_id ) ) {
|
| 398 |
$mollie_order = $this->getPaymentObjectOrder($this->getActiveMollieOrderId( $order_id ));
|
| 399 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 400 |
|
| 401 |
return $this->getPaymentObjectPayment(
|
| 402 |
$mollie_order->getMolliePaymentIdFromPaymentObject(),
|
|
@@ -635,4 +642,4 @@ class Mollie_WC_Payment_Object {
|
|
| 635 |
}
|
| 636 |
}
|
| 637 |
|
| 638 |
-
}
|
| 396 |
// If there is no payment ID, try to get order ID and if it's stored, try getting payment ID from API
|
| 397 |
if ( $this->hasActiveMollieOrder( $order_id ) ) {
|
| 398 |
$mollie_order = $this->getPaymentObjectOrder($this->getActiveMollieOrderId( $order_id ));
|
| 399 |
+
|
| 400 |
+
try {
|
| 401 |
+
$mollie_order = Mollie_WC_Plugin::getPaymentFactoryHelper()
|
| 402 |
+
->getPaymentObject($mollie_order);
|
| 403 |
+
} catch (ApiException $exception) {
|
| 404 |
+
Mollie_WC_Plugin::debug($exception->getMessage());
|
| 405 |
+
return;
|
| 406 |
+
}
|
| 407 |
|
| 408 |
return $this->getPaymentObjectPayment(
|
| 409 |
$mollie_order->getMolliePaymentIdFromPaymentObject(),
|
| 642 |
}
|
| 643 |
}
|
| 644 |
|
| 645 |
+
}
|
includes/mollie/wc/payment/order.php
CHANGED
|
@@ -1,16 +1,34 @@
|
|
| 1 |
<?php
|
| 2 |
|
|
|
|
|
|
|
|
|
|
| 3 |
class Mollie_WC_Payment_Order extends Mollie_WC_Payment_Object {
|
| 4 |
|
|
|
|
|
|
|
|
|
|
| 5 |
public static $paymentId;
|
| 6 |
public static $customerId;
|
| 7 |
public static $order;
|
| 8 |
public static $payment;
|
| 9 |
public static $shop_country;
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
public function getPaymentObject( $payment_id, $test_mode = false, $use_cache = true ) {
|
| 16 |
try {
|
|
@@ -23,7 +41,7 @@ class Mollie_WC_Payment_Order extends Mollie_WC_Payment_Object {
|
|
| 23 |
|
| 24 |
return parent::getPaymentObject( $payment_id, $test_mode = false, $use_cache = true );
|
| 25 |
}
|
| 26 |
-
catch (
|
| 27 |
Mollie_WC_Plugin::debug( __CLASS__ . __FUNCTION__ . ": Could not load payment $payment_id (" . ( $test_mode ? 'test' : 'live' ) . "): " . $e->getMessage() . ' (' . get_class( $e ) . ')' );
|
| 28 |
}
|
| 29 |
|
|
@@ -182,78 +200,59 @@ class Mollie_WC_Payment_Order extends Mollie_WC_Payment_Object {
|
|
| 182 |
return parent::setActiveMolliePayment( $order_id );
|
| 183 |
}
|
| 184 |
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
$payment = $this->getPaymentObject($this->data->id);
|
| 189 |
-
|
| 190 |
-
if ( isset( $payment->_embedded->payments{0}->id ) ) {
|
| 191 |
-
|
| 192 |
-
return $payment->_embedded->payments{0}->id;
|
| 193 |
-
|
| 194 |
-
}
|
| 195 |
-
|
| 196 |
-
return null;
|
| 197 |
-
}
|
| 198 |
-
|
| 199 |
-
public function getMollieCustomerIdFromPaymentObject( $payment = null ) {
|
| 200 |
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
|
| 206 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
|
| 208 |
-
|
| 209 |
|
| 210 |
-
|
|
|
|
|
|
|
|
|
|
| 211 |
|
| 212 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
|
| 214 |
-
|
| 215 |
-
}
|
| 216 |
|
| 217 |
-
|
|
|
|
|
|
|
|
|
|
| 218 |
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
|
|
|
| 223 |
|
| 224 |
-
|
| 225 |
|
| 226 |
-
|
|
|
|
|
|
|
| 227 |
|
| 228 |
-
|
|
|
|
|
|
|
| 229 |
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
return null;
|
| 233 |
-
}
|
| 234 |
-
|
| 235 |
-
public function getMollieCustomerIbanDetailsFromPaymentObject( $payment = null ) {
|
| 236 |
-
|
| 237 |
-
// TODO David: Quick fix, make sure payment object has payments embedded, there needs to be a better way to do this!
|
| 238 |
-
if ( $payment == null ) {
|
| 239 |
-
$payment = $this->data->id;
|
| 240 |
-
}
|
| 241 |
-
|
| 242 |
-
$payment = $this->getPaymentObject( $payment );
|
| 243 |
-
|
| 244 |
-
if ( isset( $payment->_embedded->payments{0}->id ) ) {
|
| 245 |
-
|
| 246 |
-
$actual_payment = new Mollie_WC_Payment_Payment( $payment->_embedded->payments{0}->id );
|
| 247 |
-
$actual_payment = $actual_payment->getPaymentObject( $actual_payment->data );
|
| 248 |
-
|
| 249 |
-
$iban_details['consumerName'] = $actual_payment->details->consumerName;
|
| 250 |
-
$iban_details['consumerAccount'] = $actual_payment->details->consumerAccount;
|
| 251 |
-
|
| 252 |
-
}
|
| 253 |
-
|
| 254 |
-
return $iban_details;
|
| 255 |
-
|
| 256 |
-
}
|
| 257 |
|
| 258 |
/**
|
| 259 |
* @param WC_Order $order
|
|
@@ -762,64 +761,71 @@ class Mollie_WC_Payment_Order extends Mollie_WC_Payment_Object {
|
|
| 762 |
// Get order items from refund
|
| 763 |
$items = $woocommerce_refund->get_items( array ( 'line_item', 'fee', 'shipping' ) );
|
| 764 |
|
| 765 |
-
|
| 766 |
-
|
| 767 |
-
|
| 768 |
-
|
| 769 |
-
|
| 770 |
-
|
| 771 |
-
|
| 772 |
-
|
| 773 |
-
|
| 774 |
-
|
| 775 |
-
|
| 776 |
-
|
| 777 |
-
|
| 778 |
-
|
| 779 |
-
|
| 780 |
-
|
| 781 |
-
|
| 782 |
-
|
| 783 |
-
|
| 784 |
-
|
| 785 |
-
|
| 786 |
-
|
| 787 |
-
|
| 788 |
-
|
| 789 |
-
|
| 790 |
-
|
| 791 |
-
|
| 792 |
-
|
| 793 |
-
|
| 794 |
-
|
| 795 |
-
|
| 796 |
-
|
| 797 |
-
|
| 798 |
-
|
| 799 |
-
|
| 800 |
-
|
| 801 |
-
|
| 802 |
-
|
| 803 |
-
|
| 804 |
-
|
| 805 |
-
|
| 806 |
-
|
| 807 |
-
|
| 808 |
-
|
| 809 |
-
|
| 810 |
-
|
| 811 |
-
|
| 812 |
-
|
| 813 |
-
|
| 814 |
-
|
| 815 |
-
|
| 816 |
-
|
| 817 |
-
|
| 818 |
-
|
| 819 |
-
|
| 820 |
-
|
| 821 |
-
|
| 822 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 823 |
public function refund_order_items( $order, $order_id, $amount, $items, $payment_object, $reason ) {
|
| 824 |
|
| 825 |
Mollie_WC_Plugin::debug( 'Try to process individual order item refunds or cancels.' );
|
|
@@ -840,12 +846,10 @@ class Mollie_WC_Payment_Order extends Mollie_WC_Payment_Object {
|
|
| 840 |
|
| 841 |
// If there is no metadata wth the order item ID, this order can't process individual order lines
|
| 842 |
if ( empty( $line->metadata->order_item_id ) ) {
|
| 843 |
-
|
| 844 |
$note_message = 'Refunds for this specific order can not be processed per order line. Trying to process this as an amount refund instead.';
|
| 845 |
Mollie_WC_Plugin::debug( __METHOD__ . " - " . $note_message );
|
| 846 |
|
| 847 |
-
return $this->refund_amount( $order, $
|
| 848 |
-
|
| 849 |
}
|
| 850 |
|
| 851 |
// Get the Mollie order line information that we need later
|
|
@@ -937,7 +941,18 @@ class Mollie_WC_Payment_Order extends Mollie_WC_Payment_Object {
|
|
| 937 |
);
|
| 938 |
}
|
| 939 |
|
| 940 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 941 |
|
| 942 |
$order->add_order_note( $note_message );
|
| 943 |
Mollie_WC_Plugin::debug( $note_message );
|
|
@@ -966,13 +981,17 @@ class Mollie_WC_Payment_Order extends Mollie_WC_Payment_Object {
|
|
| 966 |
* @param $reason
|
| 967 |
*
|
| 968 |
* @return bool
|
| 969 |
-
* @throws
|
| 970 |
*/
|
| 971 |
-
|
|
|
|
|
|
|
| 972 |
|
| 973 |
Mollie_WC_Plugin::debug( 'Try to process an amount refund (not individual order line)' );
|
| 974 |
|
| 975 |
-
|
|
|
|
|
|
|
| 976 |
|
| 977 |
// Is test mode enabled?
|
| 978 |
$test_mode = Mollie_WC_Plugin::getSettingsHelper()->isTestModeEnabled();
|
|
@@ -1005,7 +1024,21 @@ class Mollie_WC_Payment_Order extends Mollie_WC_Payment_Object {
|
|
| 1005 |
$order->add_order_note( $note_message );
|
| 1006 |
Mollie_WC_Plugin::debug( $note_message );
|
| 1007 |
|
| 1008 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1009 |
|
| 1010 |
return true;
|
| 1011 |
|
|
@@ -1014,4 +1047,4 @@ class Mollie_WC_Payment_Order extends Mollie_WC_Payment_Object {
|
|
| 1014 |
return false;
|
| 1015 |
}
|
| 1016 |
|
| 1017 |
-
}
|
| 1 |
<?php
|
| 2 |
|
| 3 |
+
use Mollie\Api\Exceptions\ApiException;
|
| 4 |
+
use Mollie\Api\Resources\Refund;
|
| 5 |
+
|
| 6 |
class Mollie_WC_Payment_Order extends Mollie_WC_Payment_Object {
|
| 7 |
|
| 8 |
+
const ACTION_AFTER_REFUND_AMOUNT_CREATED = Mollie_WC_Plugin::PLUGIN_ID . '_refund_amount_created';
|
| 9 |
+
const ACTION_AFTER_REFUND_ORDER_CREATED = Mollie_WC_Plugin::PLUGIN_ID . '_refund_order_created';
|
| 10 |
+
|
| 11 |
public static $paymentId;
|
| 12 |
public static $customerId;
|
| 13 |
public static $order;
|
| 14 |
public static $payment;
|
| 15 |
public static $shop_country;
|
| 16 |
|
| 17 |
+
/**
|
| 18 |
+
* @var OrderItemsRefunder
|
| 19 |
+
*/
|
| 20 |
+
private $orderItemsRefunder;
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* Mollie_WC_Payment_Order constructor.
|
| 24 |
+
* @param OrderItemsRefunder $orderItemsRefunder
|
| 25 |
+
* @param $data
|
| 26 |
+
*/
|
| 27 |
+
public function __construct(OrderItemsRefunder $orderItemsRefunder, $data)
|
| 28 |
+
{
|
| 29 |
+
$this->data = $data;
|
| 30 |
+
$this->orderItemsRefunder = $orderItemsRefunder;
|
| 31 |
+
}
|
| 32 |
|
| 33 |
public function getPaymentObject( $payment_id, $test_mode = false, $use_cache = true ) {
|
| 34 |
try {
|
| 41 |
|
| 42 |
return parent::getPaymentObject( $payment_id, $test_mode = false, $use_cache = true );
|
| 43 |
}
|
| 44 |
+
catch ( ApiException $e ) {
|
| 45 |
Mollie_WC_Plugin::debug( __CLASS__ . __FUNCTION__ . ": Could not load payment $payment_id (" . ( $test_mode ? 'test' : 'live' ) . "): " . $e->getMessage() . ' (' . get_class( $e ) . ')' );
|
| 46 |
}
|
| 47 |
|
| 200 |
return parent::setActiveMolliePayment( $order_id );
|
| 201 |
}
|
| 202 |
|
| 203 |
+
public function getMolliePaymentIdFromPaymentObject()
|
| 204 |
+
{
|
| 205 |
+
$payment = $this->getPaymentObject($this->data->id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
|
| 207 |
+
if (isset($payment->_embedded->payments[0]->id)) {
|
| 208 |
+
return $payment->_embedded->payments[0]->id;
|
| 209 |
+
}
|
| 210 |
+
}
|
| 211 |
|
| 212 |
+
public function getMollieCustomerIdFromPaymentObject($payment = null)
|
| 213 |
+
{
|
| 214 |
+
if ($payment == null) {
|
| 215 |
+
$payment = $this->data->id;
|
| 216 |
+
}
|
| 217 |
|
| 218 |
+
$payment = $this->getPaymentObject($payment);
|
| 219 |
|
| 220 |
+
if (isset($payment->_embedded->payments[0]->customerId)) {
|
| 221 |
+
return $payment->_embedded->payments[0]->customerId;
|
| 222 |
+
}
|
| 223 |
+
}
|
| 224 |
|
| 225 |
+
public function getSequenceTypeFromPaymentObject($payment = null)
|
| 226 |
+
{
|
| 227 |
+
if ($payment == null) {
|
| 228 |
+
$payment = $this->data->id;
|
| 229 |
+
}
|
| 230 |
|
| 231 |
+
$payment = $this->getPaymentObject($payment);
|
|
|
|
| 232 |
|
| 233 |
+
if (isset($payment->_embedded->payments[0]->sequenceType)) {
|
| 234 |
+
return $payment->_embedded->payments[0]->sequenceType;
|
| 235 |
+
}
|
| 236 |
+
}
|
| 237 |
|
| 238 |
+
public function getMollieCustomerIbanDetailsFromPaymentObject($payment = null)
|
| 239 |
+
{
|
| 240 |
+
if ($payment == null) {
|
| 241 |
+
$payment = $this->data->id;
|
| 242 |
+
}
|
| 243 |
|
| 244 |
+
$payment = $this->getPaymentObject($payment);
|
| 245 |
|
| 246 |
+
if (isset($payment->_embedded->payments[0]->id)) {
|
| 247 |
+
$actual_payment = new Mollie_WC_Payment_Payment($payment->_embedded->payments[0]->id);
|
| 248 |
+
$actual_payment = $actual_payment->getPaymentObject($actual_payment->data);
|
| 249 |
|
| 250 |
+
$iban_details['consumerName'] = $actual_payment->details->consumerName;
|
| 251 |
+
$iban_details['consumerAccount'] = $actual_payment->details->consumerAccount;
|
| 252 |
+
}
|
| 253 |
|
| 254 |
+
return $iban_details;
|
| 255 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 256 |
|
| 257 |
/**
|
| 258 |
* @param WC_Order $order
|
| 761 |
// Get order items from refund
|
| 762 |
$items = $woocommerce_refund->get_items( array ( 'line_item', 'fee', 'shipping' ) );
|
| 763 |
|
| 764 |
+
if (empty ($items)) {
|
| 765 |
+
return $this->refund_amount($order, $amount, $payment_object, $reason);
|
| 766 |
+
}
|
| 767 |
+
|
| 768 |
+
// Compare total amount of the refund to the combined totals of all refunded items,
|
| 769 |
+
// if the refund total is greater than sum of refund items, merchant is also doing a
|
| 770 |
+
// 'Refund amount', which the Mollie API does not support. In that case, stop entire
|
| 771 |
+
// process and warn the merchant.
|
| 772 |
+
|
| 773 |
+
$totals = 0;
|
| 774 |
+
|
| 775 |
+
foreach ($items as $item_id => $item_data) {
|
| 776 |
+
$totals += $item_data->get_total() + $item_data->get_total_tax();
|
| 777 |
+
}
|
| 778 |
+
|
| 779 |
+
$totals = number_format(abs($totals), 2); // WooCommerce - sum of all refund items
|
| 780 |
+
$amount = number_format($amount, 2); // WooCommerce - refund amount
|
| 781 |
+
|
| 782 |
+
if ($amount !== $totals) {
|
| 783 |
+
$error_message = "The sum of refunds for all order lines is not identical to the refund amount, so this refund will be processed as a payment amount refund, not an order line refund.";
|
| 784 |
+
$order->add_order_note($error_message);
|
| 785 |
+
Mollie_WC_Plugin::debug(__METHOD__ . ' - ' . $error_message);
|
| 786 |
+
|
| 787 |
+
return $this->refund_amount($order, $amount, $payment_object, $reason);
|
| 788 |
+
}
|
| 789 |
+
|
| 790 |
+
Mollie_WC_Plugin::debug('Try to process individual order item refunds or cancels.');
|
| 791 |
+
|
| 792 |
+
try {
|
| 793 |
+
return $this->orderItemsRefunder->refund(
|
| 794 |
+
$order,
|
| 795 |
+
$items,
|
| 796 |
+
$payment_object,
|
| 797 |
+
$reason
|
| 798 |
+
);
|
| 799 |
+
} catch (PartialRefundException $exception) {
|
| 800 |
+
Mollie_WC_Plugin::debug(__METHOD__ . ' - ' . $exception->getMessage());
|
| 801 |
+
return $this->refund_amount(
|
| 802 |
+
$order,
|
| 803 |
+
$amount,
|
| 804 |
+
$payment_object,
|
| 805 |
+
$reason
|
| 806 |
+
);
|
| 807 |
+
}
|
| 808 |
+
} catch (Exception $exception) {
|
| 809 |
+
$exceptionMessage = $exception->getMessage();
|
| 810 |
+
Mollie_WC_Plugin::debug(__METHOD__ . ' - ' . $exceptionMessage);
|
| 811 |
+
return new WP_Error(1, $exceptionMessage);
|
| 812 |
+
}
|
| 813 |
+
|
| 814 |
+
return false;
|
| 815 |
+
}
|
| 816 |
+
|
| 817 |
+
/**
|
| 818 |
+
* @param $order
|
| 819 |
+
* @param $order_id
|
| 820 |
+
* @param $amount
|
| 821 |
+
* @param $items
|
| 822 |
+
* @param $payment_object
|
| 823 |
+
* @param $reason
|
| 824 |
+
*
|
| 825 |
+
* @return bool
|
| 826 |
+
* @throws ApiException
|
| 827 |
+
* @deprecated Not recommended because merchant will be charged for every refunded item, use OrderItemsRefunder instead.
|
| 828 |
+
*/
|
| 829 |
public function refund_order_items( $order, $order_id, $amount, $items, $payment_object, $reason ) {
|
| 830 |
|
| 831 |
Mollie_WC_Plugin::debug( 'Try to process individual order item refunds or cancels.' );
|
| 846 |
|
| 847 |
// If there is no metadata wth the order item ID, this order can't process individual order lines
|
| 848 |
if ( empty( $line->metadata->order_item_id ) ) {
|
|
|
|
| 849 |
$note_message = 'Refunds for this specific order can not be processed per order line. Trying to process this as an amount refund instead.';
|
| 850 |
Mollie_WC_Plugin::debug( __METHOD__ . " - " . $note_message );
|
| 851 |
|
| 852 |
+
return $this->refund_amount( $order, $amount, $payment_object, $reason );
|
|
|
|
| 853 |
}
|
| 854 |
|
| 855 |
// Get the Mollie order line information that we need later
|
| 941 |
);
|
| 942 |
}
|
| 943 |
|
| 944 |
+
do_action(
|
| 945 |
+
Mollie_WC_Plugin::PLUGIN_ID . '_refund_order_created',
|
| 946 |
+
$refund,
|
| 947 |
+
$order
|
| 948 |
+
);
|
| 949 |
+
|
| 950 |
+
do_action_deprecated(
|
| 951 |
+
Mollie_WC_Plugin::PLUGIN_ID . '_refund_created',
|
| 952 |
+
[$refund, $order],
|
| 953 |
+
'[next-version]',
|
| 954 |
+
self::ACTION_AFTER_REFUND_PAYMENT_CREATED
|
| 955 |
+
);
|
| 956 |
|
| 957 |
$order->add_order_note( $note_message );
|
| 958 |
Mollie_WC_Plugin::debug( $note_message );
|
| 981 |
* @param $reason
|
| 982 |
*
|
| 983 |
* @return bool
|
| 984 |
+
* @throws ApiException|Exception
|
| 985 |
*/
|
| 986 |
+
public function refund_amount($order, $amount, $payment_object, $reason)
|
| 987 |
+
{
|
| 988 |
+
$orderId = version_compare(WC_VERSION, '3.0', '<') ? $order->id : $order->get_id();
|
| 989 |
|
| 990 |
Mollie_WC_Plugin::debug( 'Try to process an amount refund (not individual order line)' );
|
| 991 |
|
| 992 |
+
$payment_object_payment = Mollie_WC_Plugin::getPaymentObject()->getActiveMolliePayment(
|
| 993 |
+
$orderId
|
| 994 |
+
);
|
| 995 |
|
| 996 |
// Is test mode enabled?
|
| 997 |
$test_mode = Mollie_WC_Plugin::getSettingsHelper()->isTestModeEnabled();
|
| 1024 |
$order->add_order_note( $note_message );
|
| 1025 |
Mollie_WC_Plugin::debug( $note_message );
|
| 1026 |
|
| 1027 |
+
/**
|
| 1028 |
+
* After Refund Amount Created
|
| 1029 |
+
*
|
| 1030 |
+
* @param Refund $refund
|
| 1031 |
+
* @param WC_Order $order
|
| 1032 |
+
* @param string $amount
|
| 1033 |
+
*/
|
| 1034 |
+
do_action(self::ACTION_AFTER_REFUND_AMOUNT_CREATED, $refund, $order, $amount);
|
| 1035 |
+
|
| 1036 |
+
do_action_deprecated(
|
| 1037 |
+
Mollie_WC_Plugin::PLUGIN_ID . '_refund_created',
|
| 1038 |
+
[$refund, $order],
|
| 1039 |
+
'[next-version]',
|
| 1040 |
+
self::ACTION_AFTER_REFUND_AMOUNT_CREATED
|
| 1041 |
+
);
|
| 1042 |
|
| 1043 |
return true;
|
| 1044 |
|
| 1047 |
return false;
|
| 1048 |
}
|
| 1049 |
|
| 1050 |
+
}
|
includes/mollie/wc/payment/payment.php
CHANGED
|
@@ -1,7 +1,11 @@
|
|
| 1 |
<?php
|
| 2 |
|
|
|
|
|
|
|
| 3 |
class Mollie_WC_Payment_Payment extends Mollie_WC_Payment_Object {
|
| 4 |
|
|
|
|
|
|
|
| 5 |
public function __construct( $data ) {
|
| 6 |
$this->data = $data;
|
| 7 |
}
|
|
@@ -560,7 +564,20 @@ class Mollie_WC_Payment_Payment extends Mollie_WC_Payment_Object {
|
|
| 560 |
|
| 561 |
Mollie_WC_Plugin::debug( __METHOD__ . ' - Refund created - refund: ' . $refund->id . ', payment: ' . $payment_object->id . ', order: ' . $order_id . ', amount: ' . Mollie_WC_Plugin::getDataHelper()->getOrderCurrency( $order ) . $amount . ( ! empty( $reason ) ? ', reason: ' . $reason : '' ) );
|
| 562 |
|
| 563 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 564 |
|
| 565 |
$order->add_order_note( sprintf(
|
| 566 |
/* translators: Placeholder 1: currency, placeholder 2: refunded amount, placeholder 3: optional refund reason, placeholder 4: payment ID, placeholder 5: refund ID */
|
|
@@ -580,4 +597,4 @@ class Mollie_WC_Payment_Payment extends Mollie_WC_Payment_Object {
|
|
| 580 |
}
|
| 581 |
}
|
| 582 |
|
| 583 |
-
}
|
| 1 |
<?php
|
| 2 |
|
| 3 |
+
use Mollie\Api\Resources\Refund;
|
| 4 |
+
|
| 5 |
class Mollie_WC_Payment_Payment extends Mollie_WC_Payment_Object {
|
| 6 |
|
| 7 |
+
const ACTION_AFTER_REFUND_PAYMENT_CREATED = Mollie_WC_Plugin::PLUGIN_ID . '_refund_payment_created';
|
| 8 |
+
|
| 9 |
public function __construct( $data ) {
|
| 10 |
$this->data = $data;
|
| 11 |
}
|
| 564 |
|
| 565 |
Mollie_WC_Plugin::debug( __METHOD__ . ' - Refund created - refund: ' . $refund->id . ', payment: ' . $payment_object->id . ', order: ' . $order_id . ', amount: ' . Mollie_WC_Plugin::getDataHelper()->getOrderCurrency( $order ) . $amount . ( ! empty( $reason ) ? ', reason: ' . $reason : '' ) );
|
| 566 |
|
| 567 |
+
/**
|
| 568 |
+
* After Payment Refund has been created
|
| 569 |
+
*
|
| 570 |
+
* @param Refund $refund
|
| 571 |
+
* @param WC_Order $order
|
| 572 |
+
*/
|
| 573 |
+
do_action(self::ACTION_AFTER_REFUND_PAYMENT_CREATED, $refund, $order);
|
| 574 |
+
|
| 575 |
+
do_action_deprecated(
|
| 576 |
+
Mollie_WC_Plugin::PLUGIN_ID . '_refund_created',
|
| 577 |
+
[$refund, $order],
|
| 578 |
+
'[next-version]',
|
| 579 |
+
self::ACTION_AFTER_REFUND_PAYMENT_CREATED
|
| 580 |
+
);
|
| 581 |
|
| 582 |
$order->add_order_note( sprintf(
|
| 583 |
/* translators: Placeholder 1: currency, placeholder 2: refunded amount, placeholder 3: optional refund reason, placeholder 4: payment ID, placeholder 5: refund ID */
|
| 597 |
}
|
| 598 |
}
|
| 599 |
|
| 600 |
+
}
|
includes/mollie/wc/plugin.php
CHANGED
|
@@ -1,5 +1,7 @@
|
|
| 1 |
<?php
|
| 2 |
// Require WooCommerce fallback functions
|
|
|
|
|
|
|
| 3 |
require_once dirname(dirname(dirname(__FILE__))) . '/woocommerce_functions.php';
|
| 4 |
require_once dirname(dirname(dirname(__FILE__))) . '/subscriptions_status_check_functions.php';
|
| 5 |
|
|
@@ -7,14 +9,14 @@ class Mollie_WC_Plugin
|
|
| 7 |
{
|
| 8 |
const PLUGIN_ID = 'mollie-payments-for-woocommerce';
|
| 9 |
const PLUGIN_TITLE = 'Mollie Payments for WooCommerce';
|
| 10 |
-
const PLUGIN_VERSION = '5.3.
|
| 11 |
|
| 12 |
const DB_VERSION = '1.0';
|
| 13 |
const DB_VERSION_PARAM_NAME = 'mollie-db-version';
|
| 14 |
const PENDING_PAYMENT_DB_TABLE_NAME = 'mollie_pending_payment';
|
| 15 |
|
| 16 |
const POST_DATA_KEY = 'post_data';
|
| 17 |
-
const
|
| 18 |
|
| 19 |
/**
|
| 20 |
* @var bool
|
|
@@ -195,6 +197,12 @@ class Mollie_WC_Plugin
|
|
| 195 |
add_filter( 'woocommerce_payment_gateways', array ( __CLASS__, 'addGateways' ) );
|
| 196 |
|
| 197 |
add_filter('woocommerce_payment_gateways', [__CLASS__, 'maybeDisableApplePayGateway'], 20);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
|
| 199 |
// Add settings link to plugins page
|
| 200 |
add_filter( 'plugin_action_links_' . $plugin_basename, array ( __CLASS__, 'addPluginActionLinks' ) );
|
|
@@ -226,6 +234,19 @@ class Mollie_WC_Plugin
|
|
| 226 |
// Enqueue Scripts
|
| 227 |
add_action('wp_enqueue_scripts', [__CLASS__, 'enqueueFrontendScripts']);
|
| 228 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
self::initDb();
|
| 230 |
self::schedulePendingPaymentOrdersExpirationCheck();
|
| 231 |
self::registerFrontendScripts();
|
|
@@ -234,6 +255,47 @@ class Mollie_WC_Plugin
|
|
| 234 |
self::$initiated = true;
|
| 235 |
}
|
| 236 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 237 |
/**
|
| 238 |
* Register Scripts
|
| 239 |
*
|
|
@@ -426,22 +488,33 @@ class Mollie_WC_Plugin
|
|
| 426 |
*/
|
| 427 |
public static function maybeDisableApplePayGateway(array $gateways)
|
| 428 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 429 |
$postData = (string)filter_input(
|
| 430 |
INPUT_POST,
|
| 431 |
self::POST_DATA_KEY,
|
| 432 |
FILTER_SANITIZE_STRING
|
| 433 |
) ?: '';
|
|
|
|
| 434 |
|
| 435 |
-
|
| 436 |
-
|
|
|
|
|
|
|
| 437 |
}
|
| 438 |
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
$index = array_search('Mollie_WC_Gateway_Applepay', $gateways, true);
|
| 442 |
-
if ($index !== false) {
|
| 443 |
-
unset($gateways[$index]);
|
| 444 |
-
}
|
| 445 |
}
|
| 446 |
|
| 447 |
return $gateways;
|
|
@@ -919,5 +992,13 @@ class Mollie_WC_Plugin
|
|
| 919 |
|
| 920 |
}
|
| 921 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 922 |
}
|
| 923 |
|
| 1 |
<?php
|
| 2 |
// Require WooCommerce fallback functions
|
| 3 |
+
use Mollie\Api\Resources\Refund;
|
| 4 |
+
|
| 5 |
require_once dirname(dirname(dirname(__FILE__))) . '/woocommerce_functions.php';
|
| 6 |
require_once dirname(dirname(dirname(__FILE__))) . '/subscriptions_status_check_functions.php';
|
| 7 |
|
| 9 |
{
|
| 10 |
const PLUGIN_ID = 'mollie-payments-for-woocommerce';
|
| 11 |
const PLUGIN_TITLE = 'Mollie Payments for WooCommerce';
|
| 12 |
+
const PLUGIN_VERSION = '5.3.1';
|
| 13 |
|
| 14 |
const DB_VERSION = '1.0';
|
| 15 |
const DB_VERSION_PARAM_NAME = 'mollie-db-version';
|
| 16 |
const PENDING_PAYMENT_DB_TABLE_NAME = 'mollie_pending_payment';
|
| 17 |
|
| 18 |
const POST_DATA_KEY = 'post_data';
|
| 19 |
+
const APPLE_PAY_METHOD_ALLOWED_KEY = 'mollie_apple_pay_method_allowed';
|
| 20 |
|
| 21 |
/**
|
| 22 |
* @var bool
|
| 197 |
add_filter( 'woocommerce_payment_gateways', array ( __CLASS__, 'addGateways' ) );
|
| 198 |
|
| 199 |
add_filter('woocommerce_payment_gateways', [__CLASS__, 'maybeDisableApplePayGateway'], 20);
|
| 200 |
+
add_action(
|
| 201 |
+
'woocommerce_after_order_object_save',
|
| 202 |
+
function () {
|
| 203 |
+
mollieWooCommerceSession()->__unset(self::APPLE_PAY_METHOD_ALLOWED_KEY);
|
| 204 |
+
}
|
| 205 |
+
);
|
| 206 |
|
| 207 |
// Add settings link to plugins page
|
| 208 |
add_filter( 'plugin_action_links_' . $plugin_basename, array ( __CLASS__, 'addPluginActionLinks' ) );
|
| 234 |
// Enqueue Scripts
|
| 235 |
add_action('wp_enqueue_scripts', [__CLASS__, 'enqueueFrontendScripts']);
|
| 236 |
|
| 237 |
+
add_action(
|
| 238 |
+
OrderItemsRefunder::ACTION_AFTER_REFUND_ORDER_ITEMS,
|
| 239 |
+
[__CLASS__, 'addOrderNoteForRefundCreated'],
|
| 240 |
+
10,
|
| 241 |
+
3
|
| 242 |
+
);
|
| 243 |
+
add_action(
|
| 244 |
+
OrderItemsRefunder::ACTION_AFTER_CANCELED_ORDER_ITEMS,
|
| 245 |
+
[__CLASS__, 'addOrderNoteForCancelledLineItems'],
|
| 246 |
+
10,
|
| 247 |
+
2
|
| 248 |
+
);
|
| 249 |
+
|
| 250 |
self::initDb();
|
| 251 |
self::schedulePendingPaymentOrdersExpirationCheck();
|
| 252 |
self::registerFrontendScripts();
|
| 255 |
self::$initiated = true;
|
| 256 |
}
|
| 257 |
|
| 258 |
+
/**
|
| 259 |
+
* @param Refund $refund
|
| 260 |
+
* @param WC_Order $order
|
| 261 |
+
* @param array $data
|
| 262 |
+
*/
|
| 263 |
+
public static function addOrderNoteForRefundCreated(
|
| 264 |
+
Refund $refund,
|
| 265 |
+
WC_Order $order,
|
| 266 |
+
array $data
|
| 267 |
+
) {
|
| 268 |
+
|
| 269 |
+
$orderNote = sprintf(
|
| 270 |
+
__(
|
| 271 |
+
'%1$s items refunded in WooCommerce and at Mollie.',
|
| 272 |
+
'mollie-payments-for-woocommerce'
|
| 273 |
+
),
|
| 274 |
+
self::extractRemoteItemsIds($data)
|
| 275 |
+
);
|
| 276 |
+
|
| 277 |
+
$order->add_order_note($orderNote);
|
| 278 |
+
Mollie_WC_Plugin::debug($orderNote);
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
/**
|
| 282 |
+
* @param array $data
|
| 283 |
+
* @param WC_Order $order
|
| 284 |
+
*/
|
| 285 |
+
public static function addOrderNoteForCancelledLineItems(array $data, WC_Order $order)
|
| 286 |
+
{
|
| 287 |
+
$orderNote = sprintf(
|
| 288 |
+
__(
|
| 289 |
+
'%1$s items cancelled in WooCommerce and at Mollie.',
|
| 290 |
+
'mollie-payments-for-woocommerce'
|
| 291 |
+
),
|
| 292 |
+
self::extractRemoteItemsIds($data)
|
| 293 |
+
);
|
| 294 |
+
|
| 295 |
+
$order->add_order_note($orderNote);
|
| 296 |
+
Mollie_WC_Plugin::debug($orderNote);
|
| 297 |
+
}
|
| 298 |
+
|
| 299 |
/**
|
| 300 |
* Register Scripts
|
| 301 |
*
|
| 488 |
*/
|
| 489 |
public static function maybeDisableApplePayGateway(array $gateways)
|
| 490 |
{
|
| 491 |
+
$wooCommerceSession = mollieWooCommerceSession();
|
| 492 |
+
|
| 493 |
+
if (is_admin()) {
|
| 494 |
+
return $gateways;
|
| 495 |
+
}
|
| 496 |
+
|
| 497 |
+
if ($wooCommerceSession->get(self::APPLE_PAY_METHOD_ALLOWED_KEY, false)) {
|
| 498 |
+
return $gateways;
|
| 499 |
+
}
|
| 500 |
+
|
| 501 |
+
$applePayGatewayClassName = 'Mollie_WC_Gateway_Applepay';
|
| 502 |
+
$applePayGatewayIndex = array_search($applePayGatewayClassName, $gateways, true);
|
| 503 |
$postData = (string)filter_input(
|
| 504 |
INPUT_POST,
|
| 505 |
self::POST_DATA_KEY,
|
| 506 |
FILTER_SANITIZE_STRING
|
| 507 |
) ?: '';
|
| 508 |
+
parse_str($postData, $postData);
|
| 509 |
|
| 510 |
+
$applePayAllowed = isset($postData[self::APPLE_PAY_METHOD_ALLOWED_KEY]) && $postData[self::APPLE_PAY_METHOD_ALLOWED_KEY];
|
| 511 |
+
|
| 512 |
+
if ($applePayGatewayIndex !== false && !$applePayAllowed) {
|
| 513 |
+
unset($gateways[$applePayGatewayIndex]);
|
| 514 |
}
|
| 515 |
|
| 516 |
+
if ($applePayGatewayIndex !== false && $applePayAllowed) {
|
| 517 |
+
$wooCommerceSession->set(self::APPLE_PAY_METHOD_ALLOWED_KEY, true);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 518 |
}
|
| 519 |
|
| 520 |
return $gateways;
|
| 992 |
|
| 993 |
}
|
| 994 |
|
| 995 |
+
private static function extractRemoteItemsIds(array $data)
|
| 996 |
+
{
|
| 997 |
+
if (empty($data['lines'])) {
|
| 998 |
+
return [];
|
| 999 |
+
}
|
| 1000 |
+
|
| 1001 |
+
return implode(',', wp_list_pluck($data['lines'], 'id'));
|
| 1002 |
+
}
|
| 1003 |
}
|
| 1004 |
|
includes/woocommerce_functions.php
CHANGED
|
@@ -35,4 +35,9 @@ if (!function_exists('untrailingslashit'))
|
|
| 35 |
{
|
| 36 |
return rtrim($string, '/');
|
| 37 |
}
|
| 38 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
{
|
| 36 |
return rtrim($string, '/');
|
| 37 |
}
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
function mollieWooCommerceSession()
|
| 41 |
+
{
|
| 42 |
+
return WC()->session;
|
| 43 |
+
}
|
mollie-payments-for-woocommerce.php
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
* Plugin Name: Mollie Payments for WooCommerce
|
| 4 |
* Plugin URI: https://www.mollie.com
|
| 5 |
* Description: Accept payments in WooCommerce with the official Mollie plugin
|
| 6 |
-
* Version: 5.3.
|
| 7 |
* Author: Mollie
|
| 8 |
* Author URI: https://www.mollie.com
|
| 9 |
* Requires at least: 3.8
|
|
@@ -75,6 +75,13 @@ add_action( 'plugins_loaded', 'mollie_wc_check_woocommerce_status' );
|
|
| 75 |
*/
|
| 76 |
function mollie_wc_plugin_init() {
|
| 77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
// Register Mollie autoloader
|
| 79 |
Mollie_WC_Autoload::register();
|
| 80 |
|
| 3 |
* Plugin Name: Mollie Payments for WooCommerce
|
| 4 |
* Plugin URI: https://www.mollie.com
|
| 5 |
* Description: Accept payments in WooCommerce with the official Mollie plugin
|
| 6 |
+
* Version: 5.3.1
|
| 7 |
* Author: Mollie
|
| 8 |
* Author URI: https://www.mollie.com
|
| 9 |
* Requires at least: 3.8
|
| 75 |
*/
|
| 76 |
function mollie_wc_plugin_init() {
|
| 77 |
|
| 78 |
+
$pluginDir = untrailingslashit(plugin_dir_path(__FILE__));
|
| 79 |
+
|
| 80 |
+
require_once $pluginDir . '/includes/mollie/OrderLineStatus.php';
|
| 81 |
+
require_once $pluginDir . '/includes/mollie/wc/payment/OrderItemsRefunder.php';
|
| 82 |
+
require_once $pluginDir . '/includes/mollie/wc/payment/PartialRefundException.php';
|
| 83 |
+
require_once $pluginDir . '/includes/mollie/wc/payment/RefundLineItemsBuilder.php';
|
| 84 |
+
|
| 85 |
// Register Mollie autoloader
|
| 86 |
Mollie_WC_Autoload::register();
|
| 87 |
|
readme.txt
CHANGED
|
@@ -3,7 +3,7 @@ Contributors: daanvm, danielhuesken, davdebcom, dinamiko, inpsyde, l.vangunst, n
|
|
| 3 |
Tags: mollie, payments, payment gateway, woocommerce, credit card, ideal, bancontact, klarna, sofort, giropay, woocommerce subscriptions
|
| 4 |
Requires at least: 3.8
|
| 5 |
Tested up to: 5.2
|
| 6 |
-
Stable tag: 5.3.
|
| 7 |
Requires PHP: 5.6
|
| 8 |
License: GPLv2 or later
|
| 9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
|
@@ -181,6 +181,12 @@ Automatic updates should work like a charm; as always though, ensure you backup
|
|
| 181 |
|
| 182 |
== Changelog ==
|
| 183 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
= 5.3.0 - 21-08-2019 =
|
| 185 |
|
| 186 |
* Add - Introduce MyBank payment method
|
| 3 |
Tags: mollie, payments, payment gateway, woocommerce, credit card, ideal, bancontact, klarna, sofort, giropay, woocommerce subscriptions
|
| 4 |
Requires at least: 3.8
|
| 5 |
Tested up to: 5.2
|
| 6 |
+
Stable tag: 5.3.1
|
| 7 |
Requires PHP: 5.6
|
| 8 |
License: GPLv2 or later
|
| 9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 181 |
|
| 182 |
== Changelog ==
|
| 183 |
|
| 184 |
+
= 5.3.1 - 04-11-2019 =
|
| 185 |
+
|
| 186 |
+
* Fix - Apple Pay payment method appear temporary in checkout page even if the device does not support Apple Pay
|
| 187 |
+
* Fix - Refunding per line items is not possible when the refund amount field is disabled in WooCommerce order edit page
|
| 188 |
+
* Fix - Compatibility with Php 7.4
|
| 189 |
+
|
| 190 |
= 5.3.0 - 21-08-2019 =
|
| 191 |
|
| 192 |
* Add - Introduce MyBank payment method
|
