File manager - Edit - /home/premiey/www/wp-includes/images/media/mollie.tar
Back
phpunit.xml.dist 0000666 00000001230 15165345042 0007724 0 ustar 00 <?xml version="1.0" encoding="UTF-8"?> <phpunit backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" syntaxCheck="false"> <testsuites> <testsuite name="Omnipay Test Suite"> <directory>./tests/</directory> </testsuite> </testsuites> <filter> <whitelist> <directory>./src</directory> </whitelist> </filter> </phpunit> README.md 0000666 00000014527 15165345042 0006045 0 ustar 00 # Omnipay: Mollie **Mollie driver for the Omnipay PHP payment processing library** [](https://travis-ci.org/thephpleague/omnipay-mollie) [](https://packagist.org/packages/omnipay/mollie) [](https://packagist.org/packages/omnipay/mollie) [Omnipay](https://github.com/thephpleague/omnipay) is a framework agnostic, multi-gateway payment processing library for PHP. This package implements Mollie support for Omnipay. ## Installation Omnipay is installed via [Composer](http://getcomposer.org/). To install, simply require `league/omnipay` and `omnipay/mollie` with Composer: ``` composer require league/omnipay omnipay/mollie ``` ## Basic Usage The following gateways are provided by this package: * Mollie For general usage instructions, please see the main [Omnipay](https://github.com/thephpleague/omnipay) repository. ### Basic purchase example ```php $gateway = \Omnipay\Omnipay::create('Mollie'); $gateway->setApiKey('test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM'); $response = $gateway->purchase( [ "amount" => "10.00", "currency" => "EUR", "description" => "My first Payment", "returnUrl" => "https://webshop.example.org/mollie-return.php" ] )->send(); // Process response if ($response->isSuccessful()) { // Payment was successful print_r($response); } elseif ($response->isRedirect()) { // Redirect to offsite payment gateway $response->redirect(); } else { // Payment failed echo $response->getMessage(); } ``` ### Example using the Order API 1. Create the order and pass the order items in the parameters. ```php $response = $gateway->createOrder( [ 'amount' => '1027.99', 'currency' => 'EUR', 'orderNumber' => '1337', 'lines' => [ [ 'type' => 'physical', 'sku' => '5702016116977', 'name' => 'LEGO 42083 Bugatti Chiron', 'productUrl' => 'https://shop.lego.com/nl-NL/Bugatti-Chiron-42083', 'imageUrl' => 'https://sh-s7-live-s.legocdn.com/is/image//LEGO/42083_alt1?$main$', 'quantity' => 2, 'vatRate' => '21.00', 'unitPrice' => '399.00', 'totalAmount' => '698.00', 'discountAmount' => '100.00', 'vatAmount' => '121.14', ], [ 'type' => 'physical', 'sku' => '5702015594028', 'name' => 'LEGO 42056 Porsche 911 GT3 RS', 'productUrl' => 'https://shop.lego.com/nl-NL/Porsche-911-GT3-RS-42056', 'imageUrl' => 'https://sh-s7-live-s.legocdn.com/is/image/LEGO/42056?$PDPDefault$', 'quantity' => 1, 'vatRate' => '21.00', 'unitPrice' => '329.99', 'totalAmount' => '329.99', 'vatAmount' => '57.27', ] ], 'card' => [ 'company' => 'Mollie B.V.', 'email' => 'norris@chucknorrisfacts.net', 'birthday' => '1958-01-31', 'billingTitle' => 'Dhr', 'billingFirstName' => 'Piet', 'billingLastName' => 'Mondriaan', 'billingAddress1' => 'Keizersgracht 313', 'billingCity' => 'Amsterdam', 'billingPostcode' => '1234AB', 'billingState' => 'Noord-Holland', 'billingCountry' => 'NL', 'billingPhone' => '+31208202070', 'shippingTitle' => 'Mr', 'shippingFirstName' => 'Chuck', 'shippingLastName' => 'Norris', 'shippingAddress1' => 'Prinsengracht 313', 'shippingAddress2' => '4th floor', 'shippingCity' => 'Haarlem', 'shippingPostcode' => '5678AB', 'shippingState' => 'Noord-Holland', 'shippingCountry' => 'NL', ], 'metadata' => [ 'order_id' => '1337', 'description' => 'Lego cars', ], 'locale' => 'nl_NL', 'returnUrl' => 'https://example.org/redirect', 'notifyUrl' => 'https://example.org/webhook', 'paymentMethod' => 'klarnapaylater', 'billingEmail' => 'piet@mondriaan.com', ] )->send(); // Process response if ($response->isSuccessful()) { // Payment was successful print_r($response); } elseif ($response->isRedirect()) { // Redirect to offsite payment gateway $response->redirect(); } else { // Payment failed echo $response->getMessage(); } ``` 2. On return/notify, complete the order. This will not always be completed, because for Klarna the shipments needs to be created first. ```php $response = $gateway->completeOrder( [ "transactionReference" => "ord_xxxx", ] )->send(); ``` 3. When shipping the items, create the shipment for this order. You can leave the `items` emtpy to ship all items. ```php $response = $gateway->createShipment( [ "transactionReference" => "ord_xxx", 'items' => [ [ 'id' => 'odl_xxx', 'quantity' => 1, ] ] ] )->send(); ``` 4. As long as the order is `created`, `authorized` or `shipping`, it may be cancelled (voided) ```php $response = $gateway->void(["transactionReference" => "ord_xxx"])->send(); ``` ## Support If you are having general issues with Omnipay, we suggest posting on [Stack Overflow](http://stackoverflow.com/). Be sure to add the [omnipay tag](http://stackoverflow.com/questions/tagged/omnipay) so it can be easily found. If you want to keep up to date with release anouncements, discuss ideas for the project, or ask more detailed questions, there is also a [mailing list](https://groups.google.com/forum/#!forum/omnipay) which you can subscribe to. If you believe you have found a bug, please report it using the [GitHub issue tracker](https://github.com/thephpleague/omnipay-mollie/issues), or better yet, fork the library and submit a pull request. composer.json 0000666 00000002726 15165345042 0007306 0 ustar 00 { "name": "omnipay/mollie", "type": "library", "description": "Mollie driver for the Omnipay payment processing library", "keywords": [ "gateway", "merchant", "mollie", "omnipay", "pay", "payment" ], "homepage": "https://github.com/thephpleague/omnipay-mollie", "license": "MIT", "authors": [ { "name": "Adrian Macneil", "email": "adrian@adrianmacneil.com" }, { "name": "Barry vd. Heuvel", "email": "barryvdh@gmail.com" }, { "name": "Omnipay Contributors", "homepage": "https://github.com/thephpleague/omnipay-mollie/contributors" } ], "autoload": { "psr-4": { "Omnipay\\Mollie\\" : "src/" } }, "autoload-dev": { "psr-4": { "Omnipay\\Mollie\\Test\\": "tests/" } }, "require": { "omnipay/common": "^3.0.1" }, "require-dev": { "omnipay/tests": "^3.1", "squizlabs/php_codesniffer": "^3", "phpro/grumphp": "^0.14", "phpmd/phpmd": "^2", "overtrue/phplint": "^1", "jakub-onderka/php-parallel-lint": "^1" }, "extra": { "branch-alias": { "dev-master": "5.1.x-dev" } }, "scripts": { "test": "phpunit", "check-style": "phpcs -p --standard=PSR2 src/", "fix-style": "phpcbf -p --standard=PSR2 src/" }, "prefer-stable": true } grumphp.yml 0000666 00000001106 15165345042 0006760 0 ustar 00 parameters: git_dir: . bin_dir: vendor/bin tasks: phpunit: config_file: ~ testsuite: ~ group: [] always_execute: false phpcs: standard: PSR2 warning_severity: ~ ignore_patterns: - tests/ triggered_by: [php] phpmd: exclude: [] ruleset: ['cleancode', 'codesize', 'naming'] triggered_by: ['php'] phplint: exclude: [] triggered_by: ['php', 'phtml', 'php3', 'php4', 'php5'] src/Item.php 0000666 00000012772 15165345042 0006764 0 ustar 00 <?php namespace Omnipay\Mollie; class Item extends \Omnipay\Common\Item { /** * Check if a Amount object is used, store the value * * @param $key * @param $value * @return $this */ protected function setParameter($key, $value) { if (is_array($value) && isset($value['value'])) { $value = $value['value']; } $this->parameters->set($key, $value); return $this; } public function getId() { return $this->getParameter('id'); } public function setId($value) { return $this->setParameter('id', $value); } public function getUnitPrice() { return $this->getParameter('unitPrice'); } public function setUnitPrice($value) { return $this->setParameter('unitPrice', $value); } public function getDiscountAmount() { return $this->getParameter('discountAmount'); } public function setDiscountAmount($value) { return $this->setParameter('discountAmount', $value); } public function getTotalAmount() { return $this->getParameter('totalAmount'); } public function setTotalAmount($value) { return $this->setParameter('totalAmount', $value); } public function getVatRate() { return $this->getParameter('vatRate'); } public function setVatRate($value) { return $this->setParameter('vatRate', $value); } public function getVatAmount() { return $this->getParameter('vatAmount'); } public function setVatAmount($value) { return $this->setParameter('vatAmount', $value); } public function getSku() { return $this->getParameter('sku'); } public function setSku($value) { return $this->setParameter('sku', $value); } public function getType() { return $this->getParameter('type'); } public function setType($value) { return $this->setParameter('type', $value); } public function getProductUrl() { return $this->getParameter('productUrl'); } public function setProductUrl($value) { return $this->setParameter('productUrl', $value); } public function getImageUrl() { return $this->getParameter('imageUrl'); } public function setImageUrl($value) { return $this->setParameter('imageUrl', $value); } public function getResource() { return $this->getParameter('resource'); } public function setResource($value) { return $this->setParameter('resource', $value); } public function getStatus() { return $this->getParameter('status'); } public function setStatus($value) { return $this->setParameter('status', $value); } public function getIsCancelable() { return $this->getParameter('isCancelable'); } public function setIsCancelable($value) { return $this->setParameter('isCancelable', $value); } public function getOrderId() { return $this->getParameter('orderId'); } public function setOrderId($value) { return $this->setParameter('orderId', $value); } public function getQuantityShipped() { return $this->getParameter('quantityShipped'); } public function setQuantityShipped($value) { return $this->setParameter('quantityShipped', $value); } public function getAmountShipped() { return $this->getParameter('amountShipped'); } public function setAmountShipped($value) { return $this->setParameter('amountShipped', $value); } public function getQuantityRefunded() { return $this->getParameter('quantityRefunded'); } public function setQuantityRefunded($value) { return $this->setParameter('quantityRefunded', $value); } public function getAmountRefunded() { return $this->getParameter('amountRefunded'); } public function setAmountRefunded($value) { return $this->setParameter('amountRefunded', $value); } public function getQuantityCanceled() { return $this->getParameter('quantityCanceled'); } public function setQuantityCanceled($value) { return $this->setParameter('quantityCanceled', $value); } public function getAmountCanceled() { return $this->getParameter('amountCanceled'); } public function setAmountCanceled($value) { return $this->setParameter('amountCanceled', $value); } public function getShippableQuantity() { return $this->getParameter('shippableQuantity'); } public function setShippableQuantity($value) { return $this->setParameter('shippableQuantity', $value); } public function getRefundableQuantity() { return $this->getParameter('refundableQuantity'); } public function setRefundableQuantity($value) { return $this->setParameter('refundableQuantity', $value); } public function getCancelableQuantity() { return $this->getParameter('cancelableQuantity'); } public function setCancelableQuantity($value) { return $this->setParameter('cancelableQuantity', $value); } public function getCreatedAt() { return $this->getParameter('createdAt'); } public function setCreatedAt($value) { return $this->setParameter('createdAt', $value); } } src/Message/Response/RefundResponse.php 0000666 00000001101 15165345042 0014172 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Response; /** * @see https://docs.mollie.com/reference/v2/refunds-api/create-refund */ class RefundResponse extends AbstractMollieResponse { /** * @return null|string */ public function getTransactionReference() { return $this->data['paymentId']; } /** * @return string */ public function getTransactionId() { return $this->data['id']; } /** * @return bool */ public function isSuccessful() { return isset($this->data['id']); } } src/Message/Response/PurchaseResponse.php 0000666 00000000670 15165345042 0014533 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Response; /** * @see https://docs.mollie.com/reference/v2/payments-api/create-payment */ class PurchaseResponse extends FetchTransactionResponse { /** * When you do a `purchase` the request is never successful because * you need to redirect off-site to complete the purchase. * * {@inheritdoc} */ public function isSuccessful() { return false; } } src/Message/Response/CreateOrderResponse.php 0000666 00000000656 15165345042 0015164 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Response; /** * @see https://docs.mollie.com/reference/v2/orders-api/create-order */ class CreateOrderResponse extends FetchOrderResponse { /** * When you do a `order` the request is never successful because * you need to redirect off-site to complete the purchase. * * {@inheritdoc} */ public function isSuccessful() { return false; } } src/Message/Response/FetchOrderResponse.php 0000666 00000001247 15165345042 0015007 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Response; use Omnipay\Common\ItemBag; use Omnipay\Mollie\Item; /** * @see https://docs.mollie.com/reference/v2/payments-api/get-order */ class FetchOrderResponse extends FetchTransactionResponse { public function getLines() { if (isset($this->data['lines'])) { return $this->data['lines']; } return null; } public function getItems() { if (isset($this->data['lines'])) { $items = []; foreach ($this->data['lines'] as $line) { $items[] = new Item($line); } return new ItemBag($items); } } } src/Message/Response/FetchPaymentMethodsResponse.php 0000666 00000001521 15165345042 0016670 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Response; use Omnipay\Common\Message\FetchPaymentMethodsResponseInterface; use Omnipay\Common\PaymentMethod; /** * @see https://docs.mollie.com/reference/v2/methods-api/list-methods */ class FetchPaymentMethodsResponse extends AbstractMollieResponse implements FetchPaymentMethodsResponseInterface { /** * Return available payment methods as an associative array. * * @return PaymentMethod[] */ public function getPaymentMethods() { if (isset($this->data['_embedded']["methods"]) === false) { return []; } $paymentMethods = []; foreach ($this->data['_embedded']["methods"] as $method) { $paymentMethods[] = new PaymentMethod($method['id'], $method['description']); } return $paymentMethods; } } src/Message/Response/CompleteOrderResponse.php 0000666 00000000746 15165345042 0015531 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Response; /** * @see https://docs.mollie.com/reference/v2/payments-api/get-payment */ class CompleteOrderResponse extends FetchOrderResponse { /** * {@inheritdoc} */ public function isSuccessful() { return parent::isSuccessful() && $this->isPaid(); } /** * The order status is never a redirect * * {@inheritdoc} */ public function isRedirect() { return false; } } src/Message/Response/CompletePurchaseResponse.php 0000666 00000000523 15165345042 0016221 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Response; /** * @see https://docs.mollie.com/reference/v2/payments-api/get-payment */ class CompletePurchaseResponse extends FetchTransactionResponse { /** * {@inheritdoc} */ public function isSuccessful() { return parent::isSuccessful() && $this->isPaid(); } } src/Message/Response/UpdateCustomerResponse.php 0000666 00000000626 15165345042 0015726 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Response; /** * @see https://docs.mollie.com/reference/v2/customers-api/update-customer */ class UpdateCustomerResponse extends AbstractMollieResponse { /** * @return string|null */ public function getCustomerReference() { if (isset($this->data['id'])) { return $this->data['id']; } return null; } } src/Message/Response/FetchCustomerMandatesResponse.php 0000666 00000001237 15165345042 0017211 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Response; /** * @see https://docs.mollie.com/reference/v2/mandates-api/list-mandates */ class FetchCustomerMandatesResponse extends AbstractMollieResponse { public function getMandates() { if (isset($this->data['_embedded']['mandates'])) { return $this->data['_embedded']['mandates']; } } public function hasValidMandates() { if ($mandates = $this->getMandates()) { foreach ($mandates as $mandate) { if ($mandate['status'] == "valid") { return true; } } } return false; } } src/Message/Response/CreateCustomerResponse.php 0000666 00000000626 15165345042 0015707 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Response; /** * @see https://docs.mollie.com/reference/v2/customers-api/create-customer */ class CreateCustomerResponse extends AbstractMollieResponse { /** * @return string|null */ public function getCustomerReference() { if (isset($this->data['id'])) { return $this->data['id']; } return null; } } src/Message/Response/FetchIssuersResponse.php 0000666 00000001363 15165345042 0015370 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Response; use Omnipay\Common\Issuer; use Omnipay\Common\Message\FetchIssuersResponseInterface; /** * @see https://docs.mollie.com/reference/v2/methods-api/get-method */ class FetchIssuersResponse extends AbstractMollieResponse implements FetchIssuersResponseInterface { /** * Return available issuers as an associative array. * * @return Issuer[] */ public function getIssuers() { if (isset($this->data['issuers']) === false) { return []; } $issuers = []; foreach ($this->data['issuers'] as $issuer) { $issuers[] = new Issuer($issuer['id'], $issuer['name'], $this->data['id']); } return $issuers; } } src/Message/Response/CreateCustomerMandateResponse.php 0000666 00000000765 15165345042 0017205 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Response; /** * @see https://docs.mollie.com/reference/v2/mandates-api/create-mandate */ class CreateCustomerMandateResponse extends AbstractMollieResponse { /** * @return string */ public function getMandateId() { if (isset($this->data['id'])) { return $this->data['id']; } } /** * @return bool */ public function isSuccessful() { return isset($this->data['id']); } } src/Message/Response/FetchTransactionResponse.php 0000666 00000010070 15165345042 0016213 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Response; use Omnipay\Common\Message\RedirectResponseInterface; /** * @see https://docs.mollie.com/reference/v2/payments-api/get-payment */ class FetchTransactionResponse extends AbstractMollieResponse implements RedirectResponseInterface { /** * {@inheritdoc} */ public function getRedirectMethod() { return 'GET'; } /** * {@inheritdoc} */ public function isRedirect() { return isset($this->data['_links']['checkout']['href']); } /** * {@inheritdoc} */ public function getRedirectUrl() { if ($this->isRedirect()) { return $this->data['_links']['checkout']['href']; } return null; } /** * {@inheritdoc} */ public function getRedirectData() { return null; } /** * {@inheritdoc} */ public function isSuccessful() { return parent::isSuccessful(); } /** * @return boolean */ public function isOpen() { return isset($this->data['status']) && ('open' === $this->data['status'] || 'created' === $this->data['status']); } /** * @return boolean */ public function isCancelled() { return isset($this->data['status']) && 'canceled' === $this->data['status']; } /** * @return boolean */ public function isPaid() { return isset($this->data['status']) && 'paid' === $this->data['status']; } /** * @return boolean */ public function isAuthorized() { return isset($this->data['status']) && 'authorized' === $this->data['status']; } /** * @return boolean */ public function isPaidOut() { return isset($this->data['_links']['settlement']); } /** * @return boolean */ public function isExpired() { return isset($this->data['status']) && 'expired' === $this->data['status']; } public function isRefunded() { return isset($this->data['_links']['refunds']); } public function isPartialRefunded() { return $this->isRefunded() && isset($this->data['amountRemaining']) && $this->data['amountRemaining']['value'] > 0; } /** * @return boolean */ public function hasChargebacks() { return !empty($this->data['_links']['chargebacks']); } /** * @return string|null */ public function getTransactionReference() { if (isset($this->data['id'])) { return $this->data['id']; } return null; } /** * @return string|null */ public function getTransactionId() { if (isset($this->data['metadata']['transactionId'])) { return $this->data['metadata']['transactionId']; } return null; } /** * @return string|null */ public function getStatus() { if (isset($this->data['status'])) { return $this->data['status']; } return null; } /** * @return string|null */ public function getAmount() { if (isset($this->data['amount']) && is_array($this->data['amount'])) { /** * $this->data['amount'] = [ * "currency" => "EUR", * "value" => "50", * ] */ return $this->data['amount']['value']; } return null; } public function getCurrency() { if ($this->isSuccessful() && is_array($this->data['amount'])) { /** * $this->data['amount'] = [ * "currency" => "EUR", * "value" => "50", * ] */ return $this->data['amount']['currency']; } return null; } /** * @return array|null */ public function getMetadata() { if (isset($this->data['metadata'])) { return $this->data['metadata']; } return null; } } src/Message/Response/CreateShipmentResponse.php 0000666 00000000303 15165345042 0015665 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Response; /** * @see https://docs.mollie.com/reference/v2/shipments-api/create-shipment */ class CreateShipmentResponse extends FetchOrderResponse { } src/Message/Response/CancelOrderResponse.php 0000666 00000000631 15165345042 0015137 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Response; /** * @see https://docs.mollie.com/reference/v2/orders-api/cancel-order */ final class CancelOrderResponse extends FetchOrderResponse { /** * @return bool */ public function isSuccessful() { if (!isset($this->data['status'])) { return false; } return 'canceled' === $this->data['status']; } } src/Message/Response/FetchCustomerResponse.php 0000666 00000000622 15165345042 0015531 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Response; /** * @see https://docs.mollie.com/reference/v2/customers-api/get-customer */ class FetchCustomerResponse extends AbstractMollieResponse { /** * @return string|null */ public function getCustomerReference() { if (isset($this->data['id'])) { return $this->data['id']; } return null; } } src/Message/Response/AbstractMollieResponse.php 0000666 00000000761 15165345042 0015667 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Response; use Omnipay\Common\Message\AbstractResponse; class AbstractMollieResponse extends AbstractResponse { /** * @return bool */ public function isSuccessful() { if (isset($this->data['status']) && isset($this->data['detail'])) { return false; } return true; } /** * @return string */ public function getMessage() { return json_encode($this->data); } } src/Message/Response/RevokeCustomerMandateResponse.php 0000666 00000000313 15165345042 0017222 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Response; /** * @see https://docs.mollie.com/reference/v2/mandates-api/create-mandate */ class RevokeCustomerMandateResponse extends AbstractMollieResponse { } src/Message/Request/FetchOrderRequest.php 0000666 00000002704 15165345042 0014472 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Request; use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\Mollie\Message\Response\FetchOrderResponse; /** * Retrieve a single order object by its payment token. * * @see https://docs.mollie.com/reference/v2/payments-api/get-order * @method FetchOrderResponse send() */ class FetchOrderRequest extends AbstractMollieRequest { /** * @return array * @throws InvalidRequestException */ public function getData() { $this->validate('apiKey', 'transactionReference'); $data = []; $data['id'] = $this->getTransactionReference(); return $data; } /** * @return bool */ public function hasIncludePayments() { return (bool) $this->getParameter('includePayments'); } /** * @param array $data * @return FetchOrderResponse */ public function sendData($data) { $response = $this->sendRequest( self::GET, \sprintf( '/orders/%s%s', $data['id'], $this->hasIncludePayments() ? '?embed=payments' : '' ) ); return $this->response = new FetchOrderResponse($this, $response); } /** * @param bool $includePayments * @return self */ public function setIncludePayments($includePayments) { return $this->setParameter('includePayments', $includePayments); } } src/Message/Request/UpdateCustomerRequest.php 0000666 00000005425 15165345042 0015414 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Request; use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\Common\Message\AbstractRequest; use Omnipay\Mollie\Message\Response\UpdateCustomerResponse; /** * Update an existing customer. * * @see https://docs.mollie.com/reference/v2/customers-api/update-customer * @method UpdateCustomerResponse send() */ class UpdateCustomerRequest extends AbstractMollieRequest { /** * Get the customer's reference id. * * @return string */ public function getCustomerReference() { return $this->getParameter('customerReference'); } /** * @param string $value * @return AbstractRequest */ public function setCustomerReference($value) { return $this->setParameter('customerReference', $value); } /** * Get the customer's email address. * * @return string */ public function getEmail() { return $this->getParameter('email'); } /** * @param string $value * @return AbstractRequest */ public function setEmail($value) { return $this->setParameter('email', $value); } /** * Get the customer's locale. * * Possible values: de_DE, en_US, es_ES, fr_FR, nl_BE, fr_BE, nl_NL. * * @return string */ public function getLocale() { return $this->getParameter('locale'); } /** * Optional value. * * @param string $value * @return AbstractRequest */ public function setLocale($value) { return $this->setParameter('locale', $value); } /** * Get the customer's metadata. * * @return array */ public function getMetadata() { return $this->getParameter('metadata'); } /** * Optional value. * * @param array $value * @return AbstractRequest */ public function setMetadata($value) { return $this->setParameter('metadata', $value); } /** * @return array * @throws InvalidRequestException */ public function getData() { $this->validate('apiKey', 'customerReference'); $data = []; $data['name'] = $this->getDescription(); $data['email'] = $this->getEmail(); $data['locale'] = $this->getLocale(); if ($this->getMetadata()) { $data['metadata'] = $this->getMetadata(); } return $data; } /** * @param array $data * @return UpdateCustomerResponse */ public function sendData($data) { $response = $this->sendRequest(self::POST, '/customers/' . $this->getCustomerReference(), $data); return $this->response = new UpdateCustomerResponse($this, $response); } } src/Message/Request/CreateCustomerMandateRequest.php 0000666 00000010013 15165345042 0016654 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Request; use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\Common\Message\AbstractRequest; use Omnipay\Mollie\Message\Response\CreateCustomerMandateResponse; /** * Create a mandate for a specific customer. * * @see https://docs.mollie.com/reference/v2/mandates-api/create-mandate * @method CreateCustomerMandateResponse send() */ class CreateCustomerMandateRequest extends AbstractMollieRequest { /** * @return string */ public function getMethod() { return $this->getParameter('method'); } /** * @param string $method * @return AbstractRequest */ public function setMethod($method) { return $this->setParameter('method', $method); } /** * @return string */ public function getConsumerName() { return $this->getParameter('consumerName'); } /** * @param string $consumerName * @return AbstractRequest */ public function setConsumerName($consumerName) { return $this->setParameter('consumerName', $consumerName); } /** * @return string */ public function getConsumerAccount() { return $this->getParameter('consumerAccount'); } /** * @param string $consumerAccount * @return AbstractRequest */ public function setConsumerAccount($consumerAccount) { return $this->setParameter('consumerAccount', $consumerAccount); } /** * @return string */ public function getConsumerBic() { return $this->getParameter('consumerBic'); } /** * @param string $consumerBic * @return AbstractRequest */ public function setConsumerBic($consumerBic) { return $this->setParameter('consumerBic', $consumerBic); } /** * @return string */ public function getSignatureDate() { return $this->getParameter('signatureDate'); } /** * @param string $signatureDate * @return AbstractRequest */ public function setSignatureDate($signatureDate) { return $this->setParameter('signatureDate', $signatureDate); } /** * @return string */ public function getMandateReference() { return $this->getParameter('mandateReference'); } /** * @param string $mandateReference * @return AbstractRequest */ public function setMandateReference($mandateReference) { return $this->setParameter('mandateReference', $mandateReference); } /** * @return string */ public function getCustomerReference() { return $this->getParameter('customerReference'); } /** * @param string $customerReference * @return AbstractRequest */ public function setCustomerReference($customerReference) { return $this->setParameter('customerReference', $customerReference); } /** * @return array * @throws InvalidRequestException */ public function getData() { $this->validate('apiKey', 'customerReference', 'method', 'consumerName', 'consumerAccount'); $data = array(); $data['method'] = $this->getMethod(); $data['consumerName'] = $this->getConsumerName(); $data['consumerAccount'] = $this->getConsumerAccount(); if ($this->getConsumerBic()) { $data['consumerBic'] = $this->getConsumerBic(); } if ($this->getSignatureDate()) { $data['signatureDate'] = $this->getSignatureDate(); } if ($this->getMandateReference()) { $data['mandateReference'] = $this->getMandateReference(); } return $data; } /** * @param array $data * @return CreateCustomerMandateResponse */ public function sendData($data) { $response = $this->sendRequest(self::POST, "/customers/{$this->getCustomerReference()}/mandates", $data); return $this->response = new CreateCustomerMandateResponse($this, $response); } } src/Message/Request/RevokeCustomerMandateRequest.php 0000666 00000003470 15165345042 0016715 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Request; use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\Common\Message\AbstractRequest; use Omnipay\Mollie\Message\Response\RevokeCustomerMandateResponse; /** * Revoke a customer's mandate. * * @see https://docs.mollie.com/reference/v2/mandates-api/revoke-mandate * @method RevokeCustomerMandateResponse send() */ class RevokeCustomerMandateRequest extends AbstractMollieRequest { /** * @return string */ public function getCustomerReference() { return $this->getParameter('customerReference'); } /** * @param string $value * @return AbstractRequest */ public function setCustomerReference($value) { return $this->setParameter('customerReference', $value); } /** * @return string */ public function getMandateId() { return $this->getParameter('mandateId'); } /** * @param string $value * @return AbstractRequest */ public function setMandateId($value) { return $this->setParameter('mandateId', $value); } /** * @return array * @throws InvalidRequestException */ public function getData() { $this->validate('apiKey', 'customerReference', 'mandateId'); $data['customerReference'] = $this->getCustomerReference(); $data['mandateId'] = $this->getMandateId(); return $data; } /** * @param array $data * @return RevokeCustomerMandateResponse */ public function sendData($data) { $response = $this->sendRequest( self::DELETE, "/customers/{$this->getCustomerReference()}/mandates/{$this->getMandateId()}" ); return $this->response = new RevokeCustomerMandateResponse($this, $response); } } src/Message/Request/FetchCustomerRequest.php 0000666 00000002414 15165345042 0015216 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Request; use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\Common\Message\AbstractRequest; use Omnipay\Mollie\Message\Response\FetchCustomerResponse; /** * Retrieve a single customer by its ID. * * @see https://docs.mollie.com/reference/v2/customers-api/get-customer * @method FetchCustomerResponse send() */ class FetchCustomerRequest extends AbstractMollieRequest { /** * @return string */ public function getCustomerReference() { return $this->getParameter('customerReference'); } /** * @param string $value * @return AbstractRequest */ public function setCustomerReference($value) { return $this->setParameter('customerReference', $value); } /** * @return array * @throws InvalidRequestException */ public function getData() { $this->validate('apiKey', 'customerReference'); return []; } /** * @param array $data * @return FetchCustomerResponse */ public function sendData($data) { $response = $this->sendRequest(self::GET, '/customers/' . $this->getCustomerReference(), $data); return $this->response = new FetchCustomerResponse($this, $response); } } src/Message/Request/CompleteOrderRequest.php 0000666 00000002243 15165345042 0015207 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Request; use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\Mollie\Message\Response\CompleteOrderResponse; /** * Retrieve a single order object by its payment token. * * @see https://docs.mollie.com/reference/v2/payments-api/get-order * @method CompleteOrderResponse send() */ class CompleteOrderRequest extends FetchOrderRequest { /** * @return array * @throws InvalidRequestException */ public function getData() { $this->validate('apiKey'); $data = []; $data['id'] = $this->getTransactionReference(); if (!isset($data['id'])) { $data['id'] = $this->httpRequest->request->get('id'); } if (empty($data['id'])) { throw new InvalidRequestException("The transactionReference parameter is required"); } return $data; } /** * @param array $data * @return CompleteOrderResponse */ public function sendData($data) { $response = $this->sendRequest(self::GET, '/orders/' . $data['id']); return $this->response = new CompleteOrderResponse($this, $response); } } src/Message/Request/FetchIssuersRequest.php 0000666 00000002174 15165345042 0015055 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Request; use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\Mollie\Message\Response\FetchIssuersResponse; use AmeliaPsr\Http\Message\ResponseInterface; /** * Returns issuers available for the ideal payment method. * * @see https://docs.mollie.com/reference/v2/methods-api/get-method * @method FetchIssuersResponse send() */ class FetchIssuersRequest extends AbstractMollieRequest { /** * Since the Issuer endpoint got removed in the Mollie v2 api. * We now use the include parameter on the get-method endpoint. * * @var string */ protected $endpoint = '/methods/ideal?include=issuers'; /** * @return array * @throws InvalidRequestException */ public function getData() { $this->validate('apiKey'); return []; } /** * @param array $data * @return ResponseInterface|FetchIssuersResponse */ public function sendData($data) { $response = $this->sendRequest(self::GET, $this->endpoint); return $this->response = new FetchIssuersResponse($this, $response); } } src/Message/Request/CreateShipmentRequest.php 0000666 00000003203 15165345042 0015353 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Request; use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\Mollie\Message\Response\CreateShipmentResponse; /** * Create a shipment with the Mollie API. * * @see https://docs.mollie.com/reference/v2/shipments-api/create-shipment * @method CreateShipmentResponse send() */ class CreateShipmentRequest extends AbstractMollieRequest { /** * @return array */ public function getTracking() { return $this->getParameter('tracking'); } /** * @param array $value * @return $this */ public function setTracking(array $value) { return $this->setParameter('tracking', $value); } /** * @return array * @throws InvalidRequestException */ public function getData() { $this->validate('apiKey', 'transactionReference'); $data = []; $data['lines'] = []; if ($items = $this->getItems()) { foreach ($items as $item) { $data['lines'][] = array_filter([ 'id' => $item->getId(), 'quantity' => $item->getQuantity(), ]); } } if ($tracking = $this->getTracking()) { $data['tracking'] = $tracking; } return $data; } /** * @param array $data * @return CreateShipmentResponse */ public function sendData($data) { $response = $this->sendRequest(self::POST, '/orders/' . $this->getTransactionReference() . '/shipments', $data); return $this->response = new CreateShipmentResponse($this, $response); } } src/Message/Request/FetchCustomerMandatesRequest.php 0000666 00000002511 15165345042 0016671 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Request; use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\Common\Message\AbstractRequest; use Omnipay\Mollie\Message\Response\FetchCustomerMandatesResponse; /** * Retrieve all mandates for the given customer. * * @see https://docs.mollie.com/reference/v2/mandates-api/list-mandates * @method FetchCustomerMandatesResponse send() */ class FetchCustomerMandatesRequest extends AbstractMollieRequest { /** * @return string */ public function getCustomerReference() { return $this->getParameter('customerReference'); } /** * @param string $value * @return AbstractRequest */ public function setCustomerReference($value) { return $this->setParameter('customerReference', $value); } /** * @return array * @throws InvalidRequestException */ public function getData() { $this->validate('apiKey', 'customerReference'); return array(); } /** * @param array $data * @return FetchCustomerMandatesResponse */ public function sendData($data) { $response = $this->sendRequest(self::GET, "/customers/{$this->getCustomerReference()}/mandates", $data); return $this->response = new FetchCustomerMandatesResponse($this, $response); } } src/Message/Request/CancelOrderRequest.php 0000666 00000001364 15165345042 0014627 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Request; use Omnipay\Mollie\Message\Response\CancelOrderResponse; /** * Cancel an order with the Mollie API. * * @see https://docs.mollie.com/reference/v2/orders-api/cancel-order * @method CancelOrderResponse send() */ final class CancelOrderRequest extends AbstractMollieRequest { /** * @inheritdoc */ public function getData() { $this->validate('apiKey', 'transactionReference'); return []; } /** * @inheritdoc */ public function sendData($data) { return $this->response = new CancelOrderResponse( $this, $this->sendRequest(self::DELETE, '/orders/'.$this->getTransactionReference(), $data) ); } } src/Message/Request/CreateCustomerRequest.php 0000666 00000004573 15165345042 0015400 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Request; use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\Common\Message\AbstractRequest; use Omnipay\Mollie\Message\Response\CreateCustomerResponse; /** * Creates a simple minimal representation of a customer in the Mollie API. * * @see https://docs.mollie.com/reference/v2/customers-api/create-customer * @method CreateCustomerResponse send() */ class CreateCustomerRequest extends AbstractMollieRequest { /** * Get the customer's email address. * * @return string */ public function getEmail() { return $this->getParameter('email'); } /** * @param string $value * @return AbstractRequest */ public function setEmail($value) { return $this->setParameter('email', $value); } /** * Get the customer's locale. * * Possible values: de_DE, en_US, es_ES, fr_FR, nl_BE, fr_BE, nl_NL. * * @return string */ public function getLocale() { return $this->getParameter('locale'); } /** * Optional value. * * @param string $value * @return AbstractRequest */ public function setLocale($value) { return $this->setParameter('locale', $value); } /** * Get the customer's metadata. * * @return array */ public function getMetadata() { return $this->getParameter('metadata'); } /** * Optional value. * * @param array $value * @return AbstractRequest */ public function setMetadata($value) { return $this->setParameter('metadata', $value); } /** * @return array * @throws InvalidRequestException */ public function getData() { $this->validate('apiKey'); $data = []; $data['name'] = $this->getDescription(); $data['email'] = $this->getEmail(); $data['locale'] = $this->getLocale(); if ($this->getMetadata()) { $data['metadata'] = $this->getMetadata(); } return $data; } /** * @param array $data * @return CreateCustomerResponse */ public function sendData($data) { $response = $this->sendRequest(self::POST, '/customers', $data); return $this->response = new CreateCustomerResponse($this, $response); } } src/Message/Request/AbstractMollieRequest.php 0000666 00000006625 15165345042 0015360 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Request; use Omnipay\Common\ItemBag; use Omnipay\Common\Message\AbstractRequest; use Omnipay\Mollie\Gateway; use Omnipay\Mollie\Item; /** * This class holds all the common things for all of Mollie requests. * * @see https://docs.mollie.com/index */ abstract class AbstractMollieRequest extends AbstractRequest { const POST = 'POST'; const GET = 'GET'; const DELETE = 'DELETE'; /** * @var string */ protected $apiVersion = "v2"; /** * @var string */ protected $baseUrl = 'https://api.mollie.com/'; /** * @return string */ public function getApiKey() { return $this->getParameter('apiKey'); } /** * @param string $value * @return $this */ public function setApiKey($value) { return $this->setParameter('apiKey', $value); } /** * @return array|null */ public function getVersionStrings() { return $this->getParameter('versionStrings'); } /** * @param string $value * @return $this */ public function setVersionStrings(array $values) { return $this->setParameter('versionStrings', $values); } /** * @param string $value * @return $this */ public function setTransactionId($value) { return $this->setParameter('transactionId', $value); } /** * @return string */ public function getTransactionId() { return $this->getParameter('transactionId'); } /** * Set the items in this order * * @param Item[] $items An array of items in this order * @return $this */ public function setItems($items) { $orderItems = []; foreach ($items as $item) { if (is_array($item)) { $orderItems[] = new Item($item); } elseif (! ($item instanceof Item)) { throw new \InvalidArgumentException('Item should be an instance of ' . Item::class); } } return parent::setItems($orderItems); } /** * @param string $method * @param string $endpoint * @param array $data * @return array */ protected function sendRequest($method, $endpoint, array $data = null) { $versions = [ 'Omnipay-Mollie/' . Gateway::GATEWAY_VERSION, 'PHP/' . phpversion(), ]; if ($customVersions = $this->getParameter('versionStrings')) { $versions = array_merge($versions, $customVersions); } $headers = [ 'Accept' => "application/json", 'Content-Type' => "application/json", 'Authorization' => 'Bearer ' . $this->getApiKey(), 'User-Agent' => implode(' ', $versions), ]; if (function_exists("php_uname")) { $headers['X-Mollie-Client-Info'] = php_uname(); } $response = $this->httpClient->request( $method, $this->baseUrl . $this->apiVersion . $endpoint, $headers, ($data === null || $data === []) ? null : json_encode($data) ); return json_decode($response->getBody(), true); } protected function createAmountObject($amount) { return isset($amount) ? [ 'currency' => $this->getCurrency(), 'value' => $this->formatCurrency($amount), ] : null; } } src/Message/Request/CompletePurchaseRequest.php 0000666 00000002276 15165345042 0015714 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Request; use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\Mollie\Message\Response\CompletePurchaseResponse; /** * Retrieve a single payment object by its payment token. * * @see https://docs.mollie.com/reference/v2/payments-api/get-payment * @method CompletePurchaseResponse send() */ class CompletePurchaseRequest extends FetchTransactionRequest { /** * @return array * @throws InvalidRequestException */ public function getData() { $this->validate('apiKey'); $data = []; $data['id'] = $this->getTransactionReference(); if (!isset($data['id'])) { $data['id'] = $this->httpRequest->request->get('id'); } if (empty($data['id'])) { throw new InvalidRequestException("The transactionReference parameter is required"); } return $data; } /** * @param array $data * @return CompletePurchaseResponse */ public function sendData($data) { $response = $this->sendRequest(self::GET, '/payments/' . $data['id']); return $this->response = new CompletePurchaseResponse($this, $response); } } src/Message/Request/CreateOrderRequest.php 0000666 00000017327 15165345042 0014653 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Request; use Omnipay\Common\CreditCard; use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\Common\ItemBag; use Omnipay\Common\Message\ResponseInterface; use Omnipay\Mollie\Item; use Omnipay\Mollie\Message\Response\CreateOrderResponse; use Omnipay\Mollie\Message\Response\PurchaseResponse; /** * Create an order with the Mollie API. * * @see https://docs.mollie.com/reference/v2/orders-api/create-order * @method CreateOrderResponse send() */ class CreateOrderRequest extends AbstractMollieRequest { /** * Lines can contain a negative amount (discounts etc.) * * @var bool */ protected $negativeAmountAllowed = true; /** * @return array */ public function getMetadata() { return $this->getParameter('metadata'); } /** * @param array $value * @return $this */ public function setMetadata(array $value) { return $this->setParameter('metadata', $value); } /** * @return string */ public function getLocale() { return $this->getParameter('locale'); } /** * @param string $value * @return $this */ public function setLocale($value) { return $this->setParameter('locale', $value); } /** * @return string */ public function getOrderNumber() { return $this->getParameter('orderNumber'); } /** * @param string $value * @return $this */ public function setOrderNumber($value) { return $this->setParameter('orderNumber', $value); } /** * @return string */ public function getBillingEmail() { return $this->getParameter('billingEmail'); } /** * @param string $value * @return $this */ public function setBillingEmail($value) { return $this->setParameter('billingEmail', $value); } /** * @return string */ public function getCustomerReference() { return $this->getParameter('customerReference'); } /** * @param string $value * @return $this */ public function setCustomerReference($value) { return $this->setParameter('customerReference', $value); } /** * @return string */ public function getSequenceType() { return $this->getParameter('sequenceType'); } /** * @param string $value * @return $this */ public function setSequenceType($value) { return $this->setParameter('sequenceType', $value); } /** * Alias for lines * * @param $items * @return $this */ public function setLines($items) { return $this->setItems($items); } /** * A list of items in this order * * @return Item[]|null A bag containing items in this order */ public function getItems() { return $this->getParameter('items'); } /** * @return array * @throws InvalidRequestException */ public function getData() { $this->validate('apiKey', 'amount', 'locale', 'card', 'items', 'currency', 'orderNumber', 'returnUrl'); $data = []; $data['amount'] = [ 'value' => $this->getAmount(), 'currency' => $this->getCurrency() ]; if ($card = $this->getCard()) { $data += $this->getCardData($card); } $data['metadata'] = $this->getMetadata(); if ($this->getTransactionId()) { $data['metadata']['transactionId'] = $this->getTransactionId(); } if ($card && $birthday = $card->getBirthday()) { $data['consumerDateOfBirth'] = $birthday; } $data['locale'] = $this->getLocale(); $data['orderNumber'] = (string) $this->getOrderNumber(); $data['redirectUrl'] = $this->getReturnUrl(); $data['webhookUrl'] = $this->getNotifyUrl(); $data['method'] = $this->getPaymentMethod(); $data['lines'] = []; if ($items = $this->getItems()) { $data['lines'] = $this->getLines($items); } $data['payment'] = []; if ($issuer = $this->getIssuer()) { $data['payment']['issuer'] = $issuer; } if ($customerReference = $this->getCustomerReference()) { $data['payment']['customerId'] = $customerReference; } if ($sequenceType = $this->getSequenceType()) { $data['payment']['sequenceType'] = $sequenceType; } return array_filter($data); } protected function getCardData(CreditCard $card) { $data = []; $data['billingAddress'] = array_filter([ 'organizationName' => $card->getCompany(), 'streetAndNumber' => $card->getAddress1(), 'streetAdditional' => $card->getAddress2(), 'city' => $card->getCity(), 'region' => $card->getState(), 'postalCode' => $card->getPostcode(), 'country' => $card->getCountry(), 'title' => $card->getTitle(), 'givenName' => $card->getFirstName(), 'familyName' => $card->getLastName(), 'email' => $this->getBillingEmail() ?: $card->getEmail(), 'phone' => $card->getPhone(), ]); if ($card->getShippingAddress1()) { $data['shippingAddress'] = array_filter([ 'organizationName' => $card->getCompany(), 'streetAndNumber' => $card->getShippingAddress1(), 'streetAdditional' => $card->getShippingAddress2(), 'city' => $card->getShippingCity(), 'region' => $card->getShippingState(), 'postalCode' => $card->getShippingPostcode(), 'country' => $card->getShippingCountry(), 'title' => $card->getShippingTitle(), 'givenName' => $card->getShippingFirstName(), 'familyName' => $card->getShippingLastName(), 'email' => $card->getEmail(), 'phone' => $card->getShippingPhone(), ]); } return $data; } protected function getLines(ItemBag $items) { $lines = []; foreach ($items as $item) { $vatRate = $item->getVatRate(); $totalAmount = $item->getTotalAmount(); $vatAmount = $item->getVatAmount(); if (null === $totalAmount) { $totalAmount = $item->getQuantity() * $item->getPrice(); } if (null === $vatAmount) { $vatAmount = round($totalAmount * ($vatRate / (100 + $vatRate)), $this->getCurrencyDecimalPlaces()); } $data = [ 'type' => $item->getType(), 'sku' => $item->getSku(), 'name' => $item->getName(), 'productUrl' => $item->getProductUrl(), 'imageUrl' => $item->getImageUrl(), 'quantity' => (int) $item->getQuantity(), 'vatRate' => $vatRate, 'unitPrice' => $this->createAmountObject($item->getUnitPrice()), 'totalAmount' => $this->createAmountObject($totalAmount), 'discountAmount' => $this->createAmountObject($item->getDiscountAmount()), 'vatAmount' => $this->createAmountObject($vatAmount), ]; // Strip null values $lines[] = array_filter($data); } return $lines; } /** * @param array $data * @return ResponseInterface|PurchaseResponse */ public function sendData($data) { $response = $this->sendRequest(self::POST, '/orders', $data); return $this->response = new CreateOrderResponse($this, $response); } } src/Message/Request/FetchPaymentMethodsRequest.php 0000666 00000006431 15165345042 0016361 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Request; use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\Common\Message\ResponseInterface; use Omnipay\Mollie\Message\Response\FetchPaymentMethodsResponse; /** * Retrieve all available payment methods. * * @see https://docs.mollie.com/reference/v2/methods-api/list-methods * @method FetchPaymentMethodsResponse send() */ class FetchPaymentMethodsRequest extends AbstractMollieRequest { /** * @param string $billingCountry * @return $this */ public function setBillingCountry($billingCountry) { return $this->setParameter('billingCountry', $billingCountry); } /** * @return string */ public function getBillingCountry() { return $this->getParameter('billingCountry'); } /** * @param string $includeWallets * @return $this */ public function setIncludeWallets($includeWallets) { return $this->setParameter('includeWallets', $includeWallets); } /** * @return string */ public function getIncludeWallets() { return $this->getParameter('includeWallets'); } /** * @param string $locale * @return $this */ public function setLocale($locale) { return $this->setParameter('locale', $locale); } /** * @return string */ public function getLocale() { return $this->getParameter('locale'); } /** * @param string $resource * @return $this */ public function setResource($resource) { return $this->setParameter('resource', $resource); } /** * @return string */ public function getResource() { return $this->getParameter('resource'); } /** * @param $sequenceType * @return $this */ public function setSequenceType($sequenceType) { return $this->setParameter('sequenceType', $sequenceType); } /** * @return string */ public function getSequenceType() { return $this->getParameter('sequenceType'); } /** * @return array * @throws InvalidRequestException */ public function getData() { $this->validate('apiKey'); // Currency and amount are optional but both required when either one is supplied $amount = null; if ($this->getAmount() || $this->getCurrency()) { $this->validate('amount', 'currency'); $amount = [ 'value' => $this->getAmount(), 'currency' => $this->getCurrency(), ]; } return [ 'amount' => $amount, 'billingCountry' => $this->getBillingCountry(), 'locale' => $this->getLocale(), 'resource' => $this->getResource(), 'includeWallets' => $this->getIncludeWallets(), 'sequenceType' => $this->getSequenceType(), ]; } /** * @param array $data * @return ResponseInterface|FetchPaymentMethodsResponse */ public function sendData($data) { $query = http_build_query($data); $response = $this->sendRequest(self::GET, '/methods' . ($query ? '?' . $query : '')); return $this->response = new FetchPaymentMethodsResponse($this, $response); } } src/Message/Request/FetchTransactionRequest.php 0000666 00000002026 15165345042 0015701 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Request; use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\Common\Message\ResponseInterface; use Omnipay\Mollie\Message\Response\FetchTransactionResponse; /** * Retrieve a single payment object by its payment token. * * @see https://docs.mollie.com/reference/v2/payments-api/get-payment * @method FetchTransactionResponse send() */ class FetchTransactionRequest extends AbstractMollieRequest { /** * @return array * @throws InvalidRequestException */ public function getData() { $this->validate('apiKey', 'transactionReference'); $data = []; $data['id'] = $this->getTransactionReference(); return $data; } /** * @param array $data * @return ResponseInterface|FetchTransactionResponse */ public function sendData($data) { $response = $this->sendRequest(self::GET, '/payments/' . $data['id']); return $this->response = new FetchTransactionResponse($this, $response); } } src/Message/Request/RefundRequest.php 0000666 00000002704 15165345042 0013670 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Request; use function is_string; use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\Common\Message\ResponseInterface; use Omnipay\Mollie\Message\Response\RefundResponse; /** * Most payment methods support refunds. This means you can request your payment to be refunded to the consumer. * The amount of the refund will be withheld from your next settlement. * * @see https://docs.mollie.com/reference/v2/refunds-api/create-refund * @method RefundResponse send() */ class RefundRequest extends AbstractMollieRequest { /** * @return array * @throws InvalidRequestException */ public function getData() { $this->validate('apiKey', 'transactionReference', 'amount', 'currency'); $data = []; $data['amount'] = [ "value" => $this->getAmount(), "currency" => $this->getCurrency() ]; if (is_string($this->getParameter('description'))) { $data['description'] = $this->getParameter('description'); } return $data; } /** * @param array $data * @return ResponseInterface|RefundResponse */ public function sendData($data) { $response = $this->sendRequest( self::POST, '/payments/' . $this->getTransactionReference() . '/refunds', $data ); return $this->response = new RefundResponse($this, $response); } } src/Message/Request/PurchaseRequest.php 0000666 00000010755 15165345042 0014224 0 ustar 00 <?php namespace Omnipay\Mollie\Message\Request; use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\Common\Message\ResponseInterface; use Omnipay\Mollie\Message\Response\PurchaseResponse; /** * Create a payment with the Mollie API. * * @see https://docs.mollie.com/reference/v2/payments-api/create-payment * @method PurchaseResponse send() */ class PurchaseRequest extends AbstractMollieRequest { /** * @return array */ public function getMetadata() { return $this->getParameter('metadata'); } /** * @param array $value * @return $this */ public function setMetadata(array $value) { return $this->setParameter('metadata', $value); } /** * @return string */ public function getLocale() { return $this->getParameter('locale'); } /** * @param string $value * @return $this */ public function setLocale($value) { return $this->setParameter('locale', $value); } /** * @return string */ public function getBillingEmail() { return $this->getParameter('billingEmail'); } /** * @param string $value * @return $this */ public function setBillingEmail($value) { return $this->setParameter('billingEmail', $value); } /** * @return string */ public function getCustomerReference() { return $this->getParameter('customerReference'); } /** * @param string $value * @return $this */ public function setCustomerReference($value) { return $this->setParameter('customerReference', $value); } /** * @return string */ public function getMandateId() { return $this->getParameter('mandateId'); } /** * @param string $value * @return $this */ public function setMandateId($value) { return $this->setParameter('mandateId', $value); } /** * @return string */ public function getSequenceType() { return $this->getParameter('sequenceType'); } /** * @param string $value * @return $this */ public function setSequenceType($value) { return $this->setParameter('sequenceType', $value); } /** * @return string */ public function getInclude() { return $this->getParameter('include'); } /** * @param string $value * @return $this */ public function setInclude($value) { return $this->setParameter('include', $value); } /** * @return array * @throws InvalidRequestException */ public function getData() { $this->validate('apiKey', 'amount', 'currency', 'description', 'returnUrl'); $data = []; $data['amount'] = [ "value" => $this->getAmount(), "currency" => $this->getCurrency() ]; $data['description'] = $this->getDescription(); $data['redirectUrl'] = $this->getReturnUrl(); $data['method'] = $this->getPaymentMethod(); $data['metadata'] = $this->getMetadata(); if ($this->getTransactionId()) { $data['metadata']['transactionId'] = $this->getTransactionId(); } if ($issuer = $this->getIssuer()) { $data['issuer'] = $issuer; } $webhookUrl = $this->getNotifyUrl(); if (null !== $webhookUrl) { $data['webhookUrl'] = $webhookUrl; } if ($locale = $this->getLocale()) { $data['locale'] = $locale; } if ($billingEmail = $this->getBillingEmail()) { $data['billingEmail'] = $billingEmail; } if ($customerReference = $this->getCustomerReference()) { $data['customerId'] = $customerReference; } if ($sequenceType = $this->getSequenceType()) { $data['sequenceType'] = $sequenceType; } if ($mandateId = $this->getMandateId()) { $data['mandateId'] = $mandateId; } return $data; } /** * @param array $data * @return ResponseInterface|PurchaseResponse */ public function sendData($data) { $endpoint = '/payments'; if ($include = $this->getInclude()) { $endpoint .= '?include=' . $include; } $response = $this->sendRequest(self::POST, $endpoint, $data); return $this->response = new PurchaseResponse($this, $response); } } src/Gateway.php 0000666 00000020044 15165345042 0007456 0 ustar 00 <?php namespace Omnipay\Mollie; use Omnipay\Common\AbstractGateway; use Omnipay\Common\Message\RequestInterface; use Omnipay\Mollie\Message\Request\CancelOrderRequest; use Omnipay\Mollie\Message\Request\CompleteOrderRequest; use Omnipay\Mollie\Message\Request\CompletePurchaseRequest; use Omnipay\Mollie\Message\Request\CreateCustomerMandateRequest; use Omnipay\Mollie\Message\Request\CreateCustomerRequest; use Omnipay\Mollie\Message\Request\CreateOrderRequest; use Omnipay\Mollie\Message\Request\CreateShipmentRequest; use Omnipay\Mollie\Message\Request\FetchCustomerMandatesRequest; use Omnipay\Mollie\Message\Request\FetchCustomerRequest; use Omnipay\Mollie\Message\Request\FetchIssuersRequest; use Omnipay\Mollie\Message\Request\FetchOrderRequest; use Omnipay\Mollie\Message\Request\FetchPaymentMethodsRequest; use Omnipay\Mollie\Message\Request\FetchTransactionRequest; use Omnipay\Mollie\Message\Request\PurchaseRequest; use Omnipay\Mollie\Message\Request\RefundRequest; use Omnipay\Mollie\Message\Request\RevokeCustomerMandateRequest; use Omnipay\Mollie\Message\Request\UpdateCustomerRequest; /** * Mollie Gateway provides a wrapper for Mollie API. * Please have a look at links below to have a high-level overview and see the API specification * * @see https://www.mollie.com/en/developers * @see https://docs.mollie.com/index * * @method RequestInterface authorize(array $options = array()) * @method RequestInterface completeAuthorize(array $options = array()) * @method RequestInterface capture(array $options = array()) * @method RequestInterface createCard(array $options = array()) * @method RequestInterface updateCard(array $options = array()) * @method RequestInterface deleteCard(array $options = array()) * * @SuppressWarnings(PHPMD.TooManyPublicMethods) */ class Gateway extends AbstractGateway { /** * Version of our gateway. */ const GATEWAY_VERSION = "5.2"; /** * @return string */ public function getName() { return 'Mollie'; } /** * @return array */ public function getDefaultParameters() { return array( 'apiKey' => '', ); } /** * @return string */ public function getApiKey() { return $this->getParameter('apiKey'); } /** * @param string $value * @return $this */ public function setApiKey($value) { return $this->setParameter('apiKey', $value); } /** * @return array|null */ public function getVersionStrings() { return $this->getParameter('versionStrings'); } /** * @param string $value * @return $this */ public function setVersionStrings(array $values) { return $this->setParameter('versionStrings', $values); } /** * @param string $value * @return $this */ public function addVersionString($value) { $versionStrings = $this->getVersionStrings() ?: []; $versionStrings[] = str_replace([" ", "\t", "\n", "\r"], '-', $value); return $this->setVersionStrings($versionStrings); } /** * @param array $parameters * @return FetchIssuersRequest */ public function fetchIssuers(array $parameters = []) { /** @var FetchIssuersRequest $request */ $request = $this->createRequest(FetchIssuersRequest::class, $parameters); return $request; } /** * @param array $parameters * @return FetchPaymentMethodsRequest */ public function fetchPaymentMethods(array $parameters = []) { /** @var FetchPaymentMethodsRequest $request */ $request = $this->createRequest(FetchPaymentMethodsRequest::class, $parameters); return $request; } /** * @param array $parameters * @return FetchTransactionRequest */ public function fetchTransaction(array $parameters = []) { /** @var FetchTransactionRequest $request */ $request = $this->createRequest(FetchTransactionRequest::class, $parameters); return $request; } /** * @param array $parameters * @return PurchaseRequest */ public function purchase(array $parameters = []) { /** @var PurchaseRequest $request */ $request = $this->createRequest(PurchaseRequest::class, $parameters); return $request; } /** * @param array $parameters * @return CompletePurchaseRequest */ public function completePurchase(array $parameters = []) { /** @var CompletePurchaseRequest $request */ $request = $this->createRequest(CompletePurchaseRequest::class, $parameters); return $request; } /** * @param array $parameters * @return RefundRequest */ public function refund(array $parameters = []) { /** @var RefundRequest $request */ $request = $this->createRequest(RefundRequest::class, $parameters); return $request; } /** * @param array $parameters * @return CreateOrderRequest */ public function createOrder(array $parameters = []) { /** @var CreateOrderRequest $request */ $request = $this->createRequest(CreateOrderRequest::class, $parameters); return $request; } /** * @param array $parameters * @return FetchOrderRequest */ public function fetchOrder(array $parameters = []) { /** @var FetchOrderRequest $request */ $request = $this->createRequest(FetchOrderRequest::class, $parameters); return $request; } /** * @param array $parameters * @return CompleteOrderRequest */ public function completeOrder(array $parameters = []) { /** @var CompleteOrderRequest $request */ $request = $this->createRequest(CompleteOrderRequest::class, $parameters); return $request; } /** * @param array $parameters * @return CreateShipmentRequest */ public function createShipment(array $parameters = []) { /** @var CreateShipmentRequest $request */ $request = $this->createRequest(CreateShipmentRequest::class, $parameters); return $request; } /** * @param array $parameters * @return CreateCustomerRequest */ public function createCustomer(array $parameters = []) { /** @var CreateCustomerRequest $request */ $request = $this->createRequest(CreateCustomerRequest::class, $parameters); return $request; } /** * @param array $parameters * @return UpdateCustomerRequest */ public function updateCustomer(array $parameters = []) { /** @var UpdateCustomerRequest $request */ $request = $this->createRequest(UpdateCustomerRequest::class, $parameters); return $request; } /** * @param array $parameters * @return FetchCustomerRequest */ public function fetchCustomer(array $parameters = []) { /** @var FetchCustomerRequest $request */ $request = $this->createRequest(FetchCustomerRequest::class, $parameters); return $request; } /** * @param array $parameters * @return FetchCustomerMandatesRequest */ public function fetchCustomerMandates(array $parameters = []) { return $this->createRequest(FetchCustomerMandatesRequest::class, $parameters); } /** * @param array $parameters * @return CreateCustomerMandateRequest */ public function createCustomerMandate(array $parameters = []) { return $this->createRequest(CreateCustomerMandateRequest::class, $parameters); } /** * @param array $parameters * @return RevokeCustomerMandateRequest */ public function revokeCustomerMandate(array $parameters = []) { return $this->createRequest(RevokeCustomerMandateRequest::class, $parameters); } /** * @param array $parameters * @return CancelOrderRequest */ public function void(array $parameters = []) { return $this->createRequest(CancelOrderRequest::class, $parameters); } } .gitignore 0000666 00000000067 15165345042 0006550 0 ustar 00 /vendor composer.lock composer.phar phpunit.xml /.idea .travis.yml 0000666 00000001331 15165345042 0006664 0 ustar 00 language: php php: - 5.6 - 7.0 - 7.1 - 7.2 # This triggers builds to run on the new TravisCI infrastructure. # See: http://docs.travis-ci.com/user/workers/container-based-infrastructure/ sudo: false ## Cache composer cache: directories: - $HOME/.composer/cache env: global: - setup=basic matrix: include: - php: 5.6 env: setup=lowest install: - if [[ $setup = 'basic' ]]; then travis_retry composer install --prefer-dist --no-interaction; fi - if [[ $setup = 'lowest' ]]; then travis_retry composer update --prefer-dist --no-interaction --prefer-lowest --prefer-stable; fi script: - composer validate --strict - vendor/bin/phpcs --standard=PSR2 src - vendor/bin/phpunit --coverage-text CONTRIBUTING.md 0000666 00000001040 15165345042 0007001 0 ustar 00 # Contributing Guidelines * Fork the project. * Make your feature addition or bug fix. * Add tests for it. This is important so I don't break it in a future version unintentionally. * Commit just the modifications, do not mess with the composer.json or CHANGELOG.md files. * Ensure your code is nicely formatted in the [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) style and that all tests pass. * Send the pull request. * Check that the Travis CI build passed. If not, rinse and repeat. tests/Message/FetchCustomerMandatesRequestTest.php 0000666 00000006577 15165345042 0016474 0 ustar 00 <?php namespace Omnipay\Mollie\Test\Message; use AmeliaGuzzleHttp\Psr7\Request; use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\Mollie\Message\Request\FetchCustomerMandatesRequest; use Omnipay\Mollie\Message\Response\FetchCustomerMandatesResponse; use Omnipay\Tests\TestCase; class FetchCustomerMandatesRequestTest extends TestCase { use AssertRequestTrait; /** * @var FetchCustomerMandatesRequest */ protected $request; public function setUp() { $this->request = new FetchCustomerMandatesRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize( array( 'apiKey' => 'mykey', 'customerReference' => 'cst_R6JLAuqEgm', ) ); } /** * @throws InvalidRequestException */ public function testGetData() { $data = $this->request->getData(); $this->assertEmpty($data); } public function testSendSuccess() { $this->setMockHttpResponse("FetchCustomerMandatesSuccess.txt"); $response = $this->request->send(); $this->assertEqualRequest(new Request("GET", "https://api.mollie.com/v2/customers/cst_R6JLAuqEgm/mandates"), $this->getMockClient()->getLastRequest()); $this->assertInstanceOf(FetchCustomerMandatesResponse::class, $response); $mandates = $response->getMandates(); $this->assertSame("mdt_AcQl5fdL4h", $mandates[0]['id']); $this->assertSame("directdebit", $mandates[0]['method']); $this->assertTrue($response->hasValidMandates()); $this->assertJsonStringEqualsJsonString( '{"count":5,"_embedded":{"mandates":[{"resource":"mandate","id":"mdt_AcQl5fdL4h","mode":"test","status":"valid","method":"directdebit","details":{"consumerName":"John Doe","consumerAccount":"NL55INGB0000000000","consumerBic":"INGBNL2A"},"mandateReference":null,"signatureDate":"2018-05-07","createdAt":"2018-05-07T10:49:08+00:00","_links":{"self":{"href":"https:\/\/api.mollie.com\/v2\/customers\/cst_8wmqcHMN4U\/mandates\/mdt_AcQl5fdL4h","type":"application\/hal+json"},"customer":{"href":"https:\/\/api.mollie.com\/v2\/customers\/cst_8wmqcHMN4U","type":"application\/hal+json"},"documentation":{"href":"https:\/\/mollie.com\/en\/docs\/reference\/customers\/create-mandate","type":"text\/html"}}},[],[],[],[]]},"_links":{"self":{"href":"https:\/\/api.mollie.com\/v2\/customers\/cst_8wmqcHMN4U\/mandates?limit=5","type":"application\/hal+json"},"previous":null,"next":{"href":"https:\/\/api.mollie.com\/v2\/customers\/cst_8wmqcHMN4U\/mandates?from=mdt_AcQl5fdL4h&limit=5","type":"application\/hal+json"},"documentation":{"href":"https:\/\/docs.mollie.com\/reference\/v2\/mandates-api\/revoke-mandate","type":"text\/html"}}}', $response->getMessage() ); } public function testSendFailure() { $this->setMockHttpResponse('FetchCustomerMandatesFailure.txt'); $response = $this->request->send(); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertJsonStringEqualsJsonString( '{"status":404,"title":"Not Found","detail":"No customer exists with token cst_6HUkmjwzBBa.","_links":{"documentation":{"href":"https:\/\/docs.mollie.com\/guides\/handling-errors","type":"text\/html"}}}', $response->getMessage() ); } } tests/Message/CreateCustomerMandateRequestTest.php 0000666 00000006515 15165345042 0016453 0 ustar 00 <?php namespace Omnipay\Mollie\Test\Message; use AmeliaGuzzleHttp\Psr7\Request; use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\Mollie\Message\Request\CreateCustomerMandateRequest; use Omnipay\Mollie\Message\Response\CreateCustomerMandateResponse; use Omnipay\Tests\TestCase; class CreateCustomerMandateRequestTest extends TestCase { use AssertRequestTrait; /** * @var CreateCustomerMandateRequest */ protected $request; public function setUp() { $this->request = new CreateCustomerMandateRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize(array( 'apiKey' => "mykey", 'consumerName' => "Customer A", 'consumerAccount' => "NL53INGB0000000000", "method" => "directdebit", 'customerReference' => 'cst_bSNBBJBzdG', 'mandateReference' => "YOUR-COMPANY-MD13804" )); } /** * @throws InvalidRequestException */ public function testGetData() { $data = $this->request->getData(); $this->assertSame("NL53INGB0000000000", $data['consumerAccount']); $this->assertSame('directdebit', $data['method']); $this->assertSame("YOUR-COMPANY-MD13804", $data['mandateReference']); $this->assertCount(4, $data); } public function testSendSuccess() { $this->setMockHttpResponse('CreateCustomerMandateSuccess.txt'); /** @var CreateCustomerMandateResponse $response */ $response = $this->request->send(); $this->assertEqualRequest(new Request("POST", "https://api.mollie.com/v2/customers/cst_bSNBBJBzdG/mandates"), $this->getMockClient()->getLastRequest()); $this->assertInstanceOf(CreateCustomerMandateResponse::class, $response); $this->assertSame("mdt_h3gAaD5zP", $response->getMandateId()); $this->assertTrue($response->isSuccessful()); $this->assertJsonStringEqualsJsonString( '{"resource":"mandate","id":"mdt_h3gAaD5zP","mode":"test","status":"valid","method":"directdebit","details":{"consumerName":"John Doe","consumerAccount":"NL55INGB0000000000","consumerBic":"INGBNL2A"},"mandateReference":"YOUR-COMPANY-MD13804","signatureDate":"2018-05-07","createdAt":"2018-05-07T10:49:08+00:00","_links":{"self":{"href":"https:\/\/api.mollie.com\/v2\/customers\/cst_4qqhO89gsT\/mandates\/mdt_h3gAaD5zP","type":"application\/hal+json"},"customer":{"href":"https:\/\/api.mollie.com\/v2\/customers\/cst_4qqhO89gsT","type":"application\/hal+json"},"documentation":{"href":"https:\/\/docs.mollie.com\/reference\/v2\/mandates-api\/create-mandate","type":"text\/html"}}}', $response->getMessage() ); } public function testSendFailure() { $this->setMockHttpResponse('CreateCustomerMandateFailure.txt'); $response = $this->request->send(); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertNull($response->getTransactionReference()); $this->assertJsonStringEqualsJsonString( '{"status":401,"title":"Unauthorized Request","detail":"Missing authentication, or failed to authenticate","_links":{"documentation":{"href":"https:\/\/docs.mollie.com\/guides\/authentication","type":"text\/html"}}}', $response->getMessage() ); } } tests/Message/RefundRequestTest.php 0000666 00000010204 15165345042 0013445 0 ustar 00 <?php namespace Omnipay\Mollie\Test\Message; use AmeliaGuzzleHttp\Psr7\Request; use Omnipay\Mollie\Message\Request\PurchaseRequest; use Omnipay\Mollie\Message\Request\RefundRequest; use Omnipay\Mollie\Message\Response\RefundResponse; use Omnipay\Tests\TestCase; class RefundRequestTest extends TestCase { use AssertRequestTrait; /** * @var PurchaseRequest */ protected $request; public function setUp() { $this->request = new RefundRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize([ 'apiKey' => 'mykey', 'transactionReference' => 'tr_WDqYK6vllg', 'amount' => '12.00', 'currency' => 'EUR', ]); } /** * @throws \Omnipay\Common\Exception\InvalidRequestException */ public function testGetData() { $this->request->initialize([ 'apiKey' => 'mykey', 'amount' => '12.00', 'currency' => 'EUR', 'transactionReference' => 'tr_WDqYK6vllg' ]); $data = $this->request->getData(); $this->assertSame(["value" => "12.00", "currency" => "EUR"], $data['amount']); $this->assertCount(1, $data); } /** * @expectedException \Omnipay\Common\Exception\InvalidRequestException */ public function testGetDataWithoutAmount() { $this->request->initialize( [ 'apiKey' => 'mykey', 'transactionReference' => 'tr_WDqYK6vllg', ] ); $data = $this->request->getData(); $this->assertCount(0, $data); } public function testSendSuccess() { $this->setMockHttpResponse('RefundSuccess.txt'); /** @var RefundResponse $response */ $response = $this->request->send(); $this->assertEqualRequest( new Request( "POST", "https://api.mollie.com/v2/payments/tr_WDqYK6vllg/refunds", [], '{"amount":{"value":"12.00","currency":"EUR"}}' ), $this->getMockClient()->getLastRequest() ); $this->assertInstanceOf(RefundResponse::class, $response); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertSame('tr_WDqYK6vllg', $response->getTransactionReference()); $this->assertSame('re_4qqhO89gsT', $response->getTransactionId()); } public function test401Failure() { $this->setMockHttpResponse('Refund401Failure.txt'); /** @var RefundResponse $response */ $response = $this->request->send(); $this->assertEqualRequest( new Request("POST", "https://api.mollie.com/v2/payments/tr_WDqYK6vllg/refunds", [], ''), $this->getMockClient()->getLastRequest() ); $this->assertInstanceOf(RefundResponse::class, $response); $this->assertFalse($response->isSuccessful()); $this->assertEquals('{"status":401,"title":"Unauthorized Request","detail":"Missing authentication, or failed to authenticate","_links":{"documentation":{"href":"https:\/\/docs.mollie.com\/guides\/authentication","type":"text\/html"}}}', $response->getMessage()); } public function test422Failure() { $this->setMockHttpResponse('Refund422Failure.txt'); /** @var RefundResponse $response */ $response = $this->request->send(); $this->assertEqualRequest( new Request( "POST", "https://api.mollie.com/v2/payments/tr_WDqYK6vllg/refunds", [], '{"amount":{"value":"12.00","currency":"EUR"}}' ), $this->getMockClient()->getLastRequest() ); $this->assertInstanceOf(RefundResponse::class, $response); $this->assertFalse($response->isSuccessful()); $this->assertEquals('{"status":422,"title":"Unprocessable Entity","detail":"The payment method is invalid","field":"method","_links":{"documentation":{"href":"https:\/\/docs.mollie.com\/guides\/handling-errors","type":"text\/html"}}}', $response->getMessage()); } } tests/Message/AssertRequestTrait.php 0000666 00000002030 15165345042 0013625 0 ustar 00 <?php namespace Omnipay\Mollie\Test\Message; trait AssertRequestTrait { abstract function assertEquals($expected, $actual, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false); abstract function assertJsonStringEqualsJsonString($expected, $actual, $message = null); public function assertEqualRequest(\AmeliaPsr\Http\Message\RequestInterface $expectedRequest, \AmeliaPsr\Http\Message\RequestInterface $actualRequest) { $this->assertEquals($expectedRequest->getMethod(), $actualRequest->getMethod(), "Expected request Method should be equal to actual request method."); $this->assertEquals($expectedRequest->getUri(), $actualRequest->getUri(), "Expected request Uri should be equal to actual request body."); if(!empty((string) $expectedRequest->getBody())) { $this->assertJsonStringEqualsJsonString((string) $expectedRequest->getBody(), (string) $actualRequest->getBody(), "Expected request Body should be equal to actual request body."); } } } tests/Message/CompletePurchaseRequestTest.php 0000666 00000005247 15165345042 0015500 0 ustar 00 <?php namespace Omnipay\Mollie\Test\Message; use AmeliaGuzzleHttp\Psr7\Request; use Omnipay\Mollie\Message\Request\CompletePurchaseRequest; use Omnipay\Mollie\Message\Response\CompletePurchaseResponse; use Omnipay\Tests\TestCase; class CompletePurchaseRequestTest extends TestCase { use AssertRequestTrait; /** * @var CompletePurchaseRequest */ protected $request; public function setUp() { $this->request = new CompletePurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize(array( 'apiKey' => 'mykey', )); $this->getHttpRequest()->request->replace(array( 'id' => 'tr_Qzin4iTWrU', )); } /** * @expectedException \Omnipay\Common\Exception\InvalidRequestException * @expectedExceptionMessage The transactionReference parameter is required */ public function testGetDataWithoutIDParameter() { $this->getHttpRequest()->request->remove('id'); $data = $this->request->getData(); $this->assertEmpty($data); } /** * @throws \Omnipay\Common\Exception\InvalidRequestException */ public function testGetData() { $data = $this->request->getData(); $this->assertSame("tr_Qzin4iTWrU", $data['id']); $this->assertCount(1, $data); } public function testSendSuccess() { $this->setMockHttpResponse('CompletePurchaseSuccess.txt'); $response = $this->request->send(); $this->assertEqualRequest(new Request("GET", "https://api.mollie.com/v2/payments/tr_Qzin4iTWrU"), $this->getMockClient()->getLastRequest()); $this->assertInstanceOf(CompletePurchaseResponse::class, $response); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isOpen()); $this->assertTrue($response->isPaid()); $this->assertFalse($response->isRedirect()); $this->assertSame('tr_Qzin4iTWrU', $response->getTransactionReference()); } public function testSendExpired() { $this->setMockHttpResponse('CompletePurchaseExpired.txt'); $response = $this->request->send(); $this->assertEqualRequest(new Request("GET", "https://api.mollie.com/v2/payments/tr_Qzin4iTWrU"), $this->getMockClient()->getLastRequest()); $this->assertInstanceOf(CompletePurchaseResponse::class, $response); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isPaid()); $this->assertTrue($response->isExpired()); $this->assertFalse($response->isRedirect()); $this->assertSame('tr_Qzin4iTWrU', $response->getTransactionReference()); } } tests/Message/FetchIssuersRequestTest.php 0000666 00000005111 15165345042 0014632 0 ustar 00 <?php namespace Omnipay\Mollie\Test\Message; use AmeliaGuzzleHttp\Psr7\Request; use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\Common\Issuer; use Omnipay\Mollie\Message\Request\FetchIssuersRequest; use Omnipay\Mollie\Message\Response\FetchIssuersResponse; use Omnipay\Tests\TestCase; class FetchIssuersRequestTest extends TestCase { use AssertRequestTrait; /** * @var FetchIssuersRequest */ protected $request; public function setUp() { $this->request = new FetchIssuersRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize(array( 'apiKey' => 'mykey' )); } /** * @throws InvalidRequestException */ public function testGetData() { $data = $this->request->getData(); $this->assertEmpty($data); } public function testSendSuccess() { $this->setMockHttpResponse('FetchIssuersSuccess.txt'); $response = $this->request->send(); $this->assertEqualRequest( new Request("GET", "https://api.mollie.com/v2/methods/ideal?include=issuers"), $this->getMockClient()->getLastRequest() ); $this->assertInstanceOf(FetchIssuersResponse::class, $response); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertNull($response->getTransactionReference()); $expectedIssuer = new Issuer('ideal_ABNANL2A', 'ABN AMRO', 'ideal'); $expectedIssuer2 = new Issuer('ideal_ASNBNL21', 'ASN Bank', 'ideal'); $this->assertEquals(array($expectedIssuer, $expectedIssuer2), $response->getIssuers()); } public function testSendFailure() { $this->setMockHttpResponse('FetchIssuersFailure.txt'); $response = $this->request->send(); $this->assertEqualRequest( new Request("GET", "https://api.mollie.com/v2/methods/ideal?include=issuers"), $this->getMockClient()->getLastRequest() ); $this->assertInstanceOf(FetchIssuersResponse::class, $response); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertNull($response->getTransactionReference()); $this->assertSame('{"status":401,"title":"Unauthorized Request","detail":"Missing authentication, or failed to authenticate","_links":{"documentation":{"href":"https:\/\/docs.mollie.com\/guides\/authentication","type":"text\/html"}}}', $response->getMessage()); $this->assertEmpty($response->getIssuers()); } } tests/Message/CancelOrderRequestTest.php 0000666 00000005246 15165345042 0014415 0 ustar 00 <?php namespace Omnipay\Mollie\Test\Message; use Omnipay\Common\Http\ClientInterface; use Omnipay\Mollie\Message\Request\CancelOrderRequest; use Omnipay\Mollie\Message\Response\CancelOrderResponse; use Omnipay\Tests\TestCase; use AmeliaPsr\Http\Message\ResponseInterface; final class CancelOrderRequestTest extends TestCase { /** * @var ClientInterface|\PHPUnit_Framework_MockObject_MockObject */ private $httpClient; /** * @var CancelOrderRequest */ private $request; public function setUp() { $this->httpClient = $this->createMock(ClientInterface::class); $this->request = new CancelOrderRequest($this->httpClient, $this->getHttpRequest()); } public function insufficientDataProvider() { return [ [['apiKey' => 'mykey']], [['transactionReference' => 'myref']], ]; } public function responseDataProvider() { return [ [['id' => 'ord_kEn1PlbGa'], false], [['status' => 'paid', 'id' => 'ord_kEn1PlbGa'], false], [['status' => 'canceled', 'id' => 'ord_kEn1PlbGa'], true], ]; } /** * @dataProvider insufficientDataProvider * * @expectedException \Omnipay\Common\Exception\InvalidRequestException * * @param array $input */ public function testGetDataWillValidateRequiredData(array $input) { $this->request->initialize($input); $this->request->getData(); } public function testGetDataWillReturnEmptyArray() { $this->request->initialize(['apiKey' => 'mykey', 'transactionReference' => 'myref']); self::assertEquals([], $this->request->getData()); } /** * @dataProvider responseDataProvider */ public function testSendData(array $responseData, $success) { $response = $this->createMock(ResponseInterface::class); $response->expects(self::once()) ->method('getBody') ->willReturn(\json_encode($responseData)); $this->httpClient->expects(self::once()) ->method('request') ->with( 'DELETE', 'https://api.mollie.com/v2/orders/ord_kEn1PlbGa', ['Authorization' => 'Bearer mykey'] )->willReturn($response); $this->request->initialize(['apiKey' => 'mykey', 'transactionReference' => 'ord_kEn1PlbGa']); $voidResponse = $this->request->sendData([]); $this->assertInstanceOf(CancelOrderResponse::class, $voidResponse); $this->assertEquals($success, $voidResponse->isSuccessful()); $this->assertSame('ord_kEn1PlbGa', $voidResponse->getTransactionReference()); } } tests/Message/CompleteOrderRequestTest.php 0000666 00000004233 15165345042 0014773 0 ustar 00 <?php namespace Omnipay\Mollie\Test\Message; use AmeliaGuzzleHttp\Psr7\Request; use Omnipay\Mollie\Message\Request\CompleteOrderRequest; use Omnipay\Mollie\Message\Request\CompletePurchaseRequest; use Omnipay\Mollie\Message\Response\CompleteOrderResponse; use Omnipay\Mollie\Message\Response\CompletePurchaseResponse; use Omnipay\Tests\TestCase; class CompleteOrderRequestTest extends TestCase { use AssertRequestTrait; /** * @var CompletePurchaseRequest */ protected $request; public function setUp() { $this->request = new CompleteOrderRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize(array( 'apiKey' => 'mykey', )); $this->getHttpRequest()->request->replace(array( 'id' => 'ord_kEn1PlbGa', )); } /** * @expectedException \Omnipay\Common\Exception\InvalidRequestException * @expectedExceptionMessage The transactionReference parameter is required */ public function testGetDataWithoutIDParameter() { $this->getHttpRequest()->request->remove('id'); $data = $this->request->getData(); $this->assertEmpty($data); } /** * @throws \Omnipay\Common\Exception\InvalidRequestException */ public function testGetData() { $data = $this->request->getData(); $this->assertSame("ord_kEn1PlbGa", $data['id']); $this->assertCount(1, $data); } public function testSendSuccess() { $this->setMockHttpResponse('CompleteOrderSuccess.txt'); /** @var CompleteOrderResponse $response */ $response = $this->request->send(); $this->assertEqualRequest(new Request("GET", "https://api.mollie.com/v2/orders/ord_kEn1PlbGa"), $this->getMockClient()->getLastRequest()); $this->assertInstanceOf(CompleteOrderResponse::class, $response); $this->assertFalse($response->isSuccessful()); $this->assertTrue($response->isOpen()); $this->assertFalse($response->isPaid()); $this->assertFalse($response->isRedirect()); $this->assertSame('ord_kEn1PlbGa', $response->getTransactionReference()); } } tests/Message/CreateCustomerRequestTest.php 0000666 00000007144 15165345042 0015160 0 ustar 00 <?php namespace Omnipay\Mollie\Test\Message; use AmeliaGuzzleHttp\Psr7\Request; use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\Mollie\Message\Request\CreateCustomerRequest; use Omnipay\Mollie\Message\Response\CreateCustomerResponse; use Omnipay\Tests\TestCase; class CreateCustomerRequestTest extends TestCase { use AssertRequestTrait; /** * * @var CreateCustomerRequest */ protected $request; public function setUp() { $this->request = new CreateCustomerRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize(array( 'apiKey' => 'mykey', 'description' => 'John Doe', 'email' => 'john@doe.com', 'locale' => 'nl_NL', 'metadata' => 'Just some meta data.', )); } /** * @throws InvalidRequestException */ public function testData() { $this->request->initialize(array( 'apiKey' => 'mykey', 'description' => 'John Doe', 'email' => 'john@doe.com', 'metadata' => 'Just some meta data.', )); $data = $this->request->getData(); $this->assertSame("John Doe", $data['name']); $this->assertSame('john@doe.com', $data['email']); $this->assertSame('Just some meta data.', $data['metadata']); $this->assertCount(4, $data); } public function testSendSuccess() { $this->setMockHttpResponse('CreateCustomerSuccess.txt'); /** @var CreateCustomerResponse $response */ $response = $this->request->send(); $this->assertEqualRequest( new Request( "POST", "https://api.mollie.com/v2/customers", [], '{ "name":"John Doe", "email":"john@doe.com", "metadata":"Just some meta data.", "locale":"nl_NL" }' ), $this->getMockClient()->getLastRequest() ); $this->assertInstanceOf(CreateCustomerResponse::class, $response); $this->assertSame('cst_bSNBBJBzdG', $response->getCustomerReference()); $this->assertTrue($response->isSuccessful()); $this->assertJsonStringEqualsJsonString( '{"resource":"customer","id":"cst_bSNBBJBzdG","mode":"test","name":"John Doe","email":"john@doe.com","locale":"nl_NL","metadata":"Just some meta data.","createdAt":"2018-07-19T12:58:47+00:00","_links":{"self":{"href":"https:\/\/api.mollie.com\/v2\/customers\/cst_6HUkmjwzBB","type":"application\/hal+json"},"documentation":{"href":"https:\/\/docs.mollie.com\/reference\/v2\/customers-api\/create-customer","type":"text\/html"}}}', $response->getMessage() ); } public function testSendFailure() { $this->setMockHttpResponse('CreateCustomerFailure.txt'); $response = $this->request->send(); $this->assertEqualRequest(new Request("POST", "https://api.mollie.com/v2/customers"), $this->getMockClient()->getLastRequest()); $this->assertInstanceOf(CreateCustomerResponse::class, $response); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertNull($response->getTransactionReference()); $this->assertSame('{"status":401,"title":"Unauthorized Request","detail":"Missing authentication, or failed to authenticate","_links":{"documentation":{"href":"https:\/\/docs.mollie.com\/guides\/authentication","type":"text\/html"}}}', $response->getMessage()); } } tests/Message/RevokeCustomerMandateRequestTest.php 0000666 00000003413 15165345042 0016475 0 ustar 00 <?php namespace Omnipay\Mollie\Test\Message; use AmeliaGuzzleHttp\Psr7\Request; use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\Mollie\Message\Request\RevokeCustomerMandateRequest; use Omnipay\Mollie\Message\Response\RevokeCustomerMandateResponse; use Omnipay\Tests\TestCase; class RevokeCustomerMandateRequestTest extends TestCase { use AssertRequestTrait; /** * @var RevokeCustomerMandateRequest */ protected $request; public function setUp() { $this->request = new RevokeCustomerMandateRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize([ 'apiKey' => "mykey", 'customerReference' => 'cst_bSNBBJBzdG', 'mandateId' => "mdt_pWUnw6pkBN", ]); } /** * @throws InvalidRequestException */ public function testData() { $this->request->initialize([ 'apiKey' => "mykey", 'customerReference' => 'cst_bSNBBJBzdG', 'mandateId' => "mdt_pWUnw6pkBN", ]); $data = $this->request->getData(); $this->assertSame("cst_bSNBBJBzdG", $data['customerReference']); $this->assertSame("mdt_pWUnw6pkBN", $data['mandateId']); } public function testSendSuccess() { $this->setMockHttpResponse('RevokeCustomerMandateSuccess.txt'); /** @var RevokeCustomerMandateResponse $response */ $response = $this->request->send(); $this->assertEqualRequest(new Request("DELETE", "https://api.mollie.com/v2/customers/cst_bSNBBJBzdG/mandates/mdt_pWUnw6pkBN"), $this->getMockClient()->getLastRequest()); $this->assertInstanceOf(RevokeCustomerMandateResponse::class, $response); $this->assertTrue($response->isSuccessful()); } } tests/Message/PurchaseRequestTest.php 0000666 00000022521 15165345042 0014001 0 ustar 00 <?php namespace Omnipay\Mollie\Test\Message; use AmeliaGuzzleHttp\Psr7\Request; use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\Mollie\Message\Request\PurchaseRequest; use Omnipay\Mollie\Message\Response\PurchaseResponse; use Omnipay\Tests\TestCase; class PurchaseRequestTest extends TestCase { use AssertRequestTrait; /** * @var PurchaseRequest */ protected $request; public function setUp() { $this->request = new PurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize(array( 'apiKey' => 'mykey', 'amount' => '12.00', 'currency' => 'USD', 'issuer' => 'my bank', 'description' => 'Description', 'returnUrl' => 'https://www.example.com/return', 'method' => 'ideal', 'metadata' => ['meta'], 'locale' => 'fr_FR', 'billingEmail' => 'billing-email@example.com', )); } /** * @throws InvalidRequestException */ public function testGetData() { $this->request->initialize([ 'apiKey' => 'mykey', 'amount' => '12.00', 'currency' => 'USD', 'description' => 'Description', 'returnUrl' => 'https://www.example.com/return', 'paymentMethod' => 'ideal', 'metadata' => ['meta'], 'issuer' => 'my bank', 'locale' => 'fr_FR', 'billingEmail' => 'billing-email@example.com', ]); $data = $this->request->getData(); $this->assertSame(["value" => "12.00", "currency" => "USD"], $data['amount']); $this->assertSame('Description', $data['description']); $this->assertSame('https://www.example.com/return', $data['redirectUrl']); $this->assertSame('ideal', $data['method']); $this->assertSame(['meta'], $data['metadata']); $this->assertSame('my bank', $data['issuer']); $this->assertSame('fr_FR', $data['locale']); $this->assertSame('billing-email@example.com', $data['billingEmail']); $this->assertCount(8, $data); } /** * @throws InvalidRequestException */ public function testGetDataWithWebhook() { $this->request->initialize(array( 'apiKey' => 'mykey', 'amount' => '12.00', 'currency' => 'EUR', 'description' => 'Description', 'returnUrl' => 'https://www.example.com/return', 'paymentMethod' => 'ideal', 'metadata' => ['meta'], 'issuer' => 'my bank', 'locale' => 'fr_FR', 'billingEmail' => 'billing-email@example.com', 'notifyUrl' => 'https://www.example.com/hook', )); $data = $this->request->getData(); $this->assertSame(["value" => "12.00", "currency" => "EUR"], $data['amount']); $this->assertSame('Description', $data['description']); $this->assertSame('https://www.example.com/return', $data['redirectUrl']); $this->assertSame('ideal', $data['method']); $this->assertSame(['meta'], $data['metadata']); $this->assertSame('my bank', $data['issuer']); $this->assertSame('fr_FR', $data['locale']); $this->assertSame('billing-email@example.com', $data['billingEmail']); $this->assertSame('https://www.example.com/hook', $data['webhookUrl']); $this->assertCount(9, $data); } /** * @throws InvalidRequestException */ public function testNoIssuer() { $this->request->initialize(array( 'apiKey' => 'mykey', 'amount' => '12.00', 'currency' => 'SEK', 'description' => 'Description', 'returnUrl' => 'https://www.example.com/return', 'paymentMethod' => 'ideal', 'metadata' => ['meta'], 'locale' => 'fr_FR', 'billingEmail' => 'billing-email@example.com', 'notifyUrl' => 'https://www.example.com/hook', )); $data = $this->request->getData(); $this->assertSame(["value" => "12.00", "currency" => "SEK"], $data['amount']); $this->assertSame('Description', $data['description']); $this->assertSame('https://www.example.com/return', $data['redirectUrl']); $this->assertSame('ideal', $data['method']); $this->assertSame(['meta'], $data['metadata']); $this->assertSame('fr_FR', $data['locale']); $this->assertSame('billing-email@example.com', $data['billingEmail']); $this->assertSame('https://www.example.com/hook', $data['webhookUrl']); $this->assertCount(8, $data); } public function testSendSuccess() { $this->setMockHttpResponse('PurchaseSuccess.txt'); $response = $this->request->send(); $this->assertEqualRequest( new Request( "POST", "https://api.mollie.com/v2/payments", [], '{ "amount":{ "value":"12.00", "currency":"USD" }, "description":"Description", "redirectUrl":"https:\/\/www.example.com\/return", "method":null, "metadata":[ "meta" ], "issuer":"my bank", "locale":"fr_FR", "billingEmail":"billing-email@example.com" }' ), $this->getMockClient()->getLastRequest() ); $this->assertInstanceOf(PurchaseResponse::class, $response); $this->assertFalse($response->isSuccessful()); $this->assertTrue($response->isRedirect()); $this->assertSame('GET', $response->getRedirectMethod()); $this->assertSame('https://www.mollie.com/payscreen/select-method/7UhSN1zuXS', $response->getRedirectUrl()); $this->assertNull($response->getRedirectData()); $this->assertSame('tr_7UhSN1zuXS', $response->getTransactionReference()); $this->assertTrue($response->isOpen()); $this->assertFalse($response->isPaid()); $this->assertNull($response->getCode()); $this->assertJsonStringEqualsJsonString( '{"resource":"payment","id":"tr_7UhSN1zuXS","mode":"test","createdAt":"2018-03-20T09:13:37+00:00","amount":{"value":"10.00","currency":"EUR"},"description":"My first payment","method":null,"metadata":{"order_id":"12345"},"status":"open","isCancelable":false,"expiresAt":"2018-03-20T09:28:37+00:00","details":null,"profileId":"pfl_QkEhN94Ba","sequenceType":"oneoff","redirectUrl":"https:\/\/webshop.example.org\/order\/12345\/","webhookUrl":"https:\/\/webshop.example.org\/payments\/webhook\/","_links":{"self":{"href":"https:\/\/api.mollie.com\/v2\/payments\/tr_7UhSN1zuXS","type":"application\/json"},"checkout":{"href":"https:\/\/www.mollie.com\/payscreen\/select-method\/7UhSN1zuXS","type":"text\/html"},"documentation":{"href":"https:\/\/docs.mollie.com\/reference\/v2\/payments-api\/create-payment","type":"text\/html"}}}', $response->getMessage() ); } public function testSendSuccessWithQrcode() { $this->setMockHttpResponse('PurchaseSuccess.txt'); $response = $this->request->setInclude('details.qrCode')->send(); $this->assertEqualRequest( new Request( "POST", "https://api.mollie.com/v2/payments?include=details.qrCode", [], '{ "amount":{ "value":"12.00", "currency":"USD" }, "description":"Description", "redirectUrl":"https:\/\/www.example.com\/return", "method":null, "metadata":[ "meta" ], "issuer":"my bank", "locale":"fr_FR", "billingEmail":"billing-email@example.com" }' ), $this->getMockClient()->getLastRequest() ); $this->assertInstanceOf(PurchaseResponse::class, $response); $this->assertFalse($response->isSuccessful()); $this->assertTrue($response->isRedirect()); } public function testIssuerFailure() { $this->setMockHttpResponse('PurchaseIssuerFailure.txt'); $response = $this->request->send(); $this->assertEqualRequest( new Request( "POST", "https://api.mollie.com/v2/payments" ), $this->getMockClient()->getLastRequest() ); $this->assertInstanceOf(PurchaseResponse::class, $response); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertNull($response->getTransactionReference()); $this->assertNull($response->getRedirectUrl()); $this->assertNull($response->getRedirectData()); $this->assertSame('{"status":422,"title":"Unprocessable Entity","detail":"The payment method is invalid","field":"method","_links":{"documentation":{"href":"https:\/\/docs.mollie.com\/guides\/handling-errors","type":"text\/html"}}}', $response->getMessage()); } } tests/Message/FetchTransactionRequestTest.php 0000666 00000007002 15165345042 0015463 0 ustar 00 <?php namespace Omnipay\Mollie\Test\Message; use AmeliaGuzzleHttp\Psr7\Request; use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\Mollie\Message\Request\FetchTransactionRequest; use Omnipay\Mollie\Message\Response\FetchTransactionResponse; use Omnipay\Tests\TestCase; class FetchTransactionRequestTest extends TestCase { use AssertRequestTrait; /** * @var FetchTransactionRequest */ protected $request; public function setUp() { $this->request = new FetchTransactionRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize( array( 'apiKey' => 'mykey', 'transactionReference' => 'tr_WDqYK6vllg', ) ); } /** * @throws InvalidRequestException */ public function testGetData() { $data = $this->request->getData(); $this->assertSame("tr_WDqYK6vllg", $data['id']); $this->assertCount(1, $data); } public function testSendSuccess() { $this->setMockHttpResponse('FetchTransactionSuccess.txt'); /** @var FetchTransactionResponse $response */ $response = $this->request->send(); $this->assertEqualRequest( new Request( "GET", "https://api.mollie.com/v2/payments/tr_WDqYK6vllg" ), $this->getMockClient()->getLastRequest() ); $this->assertInstanceOf(FetchTransactionResponse::class, $response); $this->assertTrue($response->isSuccessful()); $this->assertTrue($response->isPaid()); $this->assertFalse($response->isCancelled()); $this->assertFalse($response->isPaidOut()); $this->assertTrue($response->isRedirect()); $this->assertFalse($response->isRefunded()); $this->assertFalse($response->isPartialRefunded()); $this->assertSame("paid", $response->getStatus()); $this->assertSame('tr_WDqYK6vllg', $response->getTransactionReference()); $this->assertSame("10.00", $response->getAmount()); } public function testSendExpired() { $this->setMockHttpResponse('FetchTransactionExpired.txt'); $response = $this->request->send(); $this->assertEqualRequest( new Request( "GET", "https://api.mollie.com/v2/payments/tr_WDqYK6vllg" ), $this->getMockClient()->getLastRequest() ); $this->assertInstanceOf(FetchTransactionResponse::class, $response); $this->assertTrue($response->isSuccessful()); $this->assertTrue($response->isRedirect()); $this->assertSame('tr_WDqYK6vllg', $response->getTransactionReference()); $this->assertTrue($response->isExpired()); } public function testSendFailure() { $this->setMockHttpResponse('FetchTransaction404Failure.txt'); $response = $this->request->send(); $this->assertEqualRequest( new Request( "GET", "https://api.mollie.com/v2/payments/tr_WDqYK6vllg" ), $this->getMockClient()->getLastRequest() ); $this->assertInstanceOf(FetchTransactionResponse::class, $response); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertNull($response->getTransactionReference()); $this->assertEquals(404, $response->getStatus()); $this->assertNull($response->getAmount()); } } tests/Message/AbstractMollieRequestTest.php 0000666 00000004070 15165345042 0015133 0 ustar 00 <?php namespace Omnipay\Mollie\Test\Message; use AmeliaGuzzleHttp\Psr7\Request; use Omnipay\Mollie\Gateway; use Omnipay\Mollie\Message\Request\CompleteOrderRequest; use Omnipay\Mollie\Message\Request\CompletePurchaseRequest; use Omnipay\Mollie\Message\Response\CompleteOrderResponse; use Omnipay\Mollie\Message\Response\CompletePurchaseResponse; use Omnipay\Tests\TestCase; class AbstractMollieRequestTest extends TestCase { /** * @var Gateway */ protected $gateway; public function setUp() { $this->gateway = new Gateway($this->getHttpClient()); } public function testVersionString() { $request = $this->gateway->fetchIssuers(); $request->send(); /** @var \AmeliaPsr\Http\Message\RequestInterface $httpRequest */ $httpRequest = $this->getMockedRequests()[0]; $versionString = 'Omnipay-Mollie/'.Gateway::GATEWAY_VERSION.' PHP/' . phpversion(); $this->assertEquals($versionString, $httpRequest->getHeaderLine('User-Agent')); } public function testCustomVersionStrings() { $this->gateway->initialize([ 'versionStrings' => ['Acme/6.84'] ]); $request = $this->gateway->fetchIssuers(); $request->send(); /** @var \AmeliaPsr\Http\Message\RequestInterface $httpRequest */ $httpRequest = $this->getMockedRequests()[0]; $versionString = 'Omnipay-Mollie/'.Gateway::GATEWAY_VERSION.' PHP/' . phpversion() . ' Acme/6.84'; $this->assertEquals($versionString, $httpRequest->getHeaderLine('User-Agent')); } public function testAddVersionString() { $this->gateway->addVersionString('Acme/6.84'); $request = $this->gateway->fetchIssuers(); $request->send(); /** @var \AmeliaPsr\Http\Message\RequestInterface $httpRequest */ $httpRequest = $this->getMockedRequests()[0]; $versionString = 'Omnipay-Mollie/'.Gateway::GATEWAY_VERSION.' PHP/' . phpversion() . ' Acme/6.84'; $this->assertEquals($versionString, $httpRequest->getHeaderLine('User-Agent')); } } tests/Message/FetchCustomerRequestTest.php 0000666 00000005527 15165345042 0015011 0 ustar 00 <?php namespace Omnipay\Mollie\Test\Message; use AmeliaGuzzleHttp\Psr7\Request; use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\Mollie\Message\Request\FetchCustomerRequest; use Omnipay\Mollie\Message\Response\FetchCustomerResponse; use Omnipay\Tests\TestCase; class FetchCustomerRequestTest extends TestCase { use AssertRequestTrait; /** * @var FetchCustomerRequest */ protected $request; public function setUp() { $this->request = new FetchCustomerRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize( array( 'apiKey' => 'mykey', 'customerReference' => 'cst_bSNBBJBzdG', ) ); } /** * @throws InvalidRequestException */ public function testGetData() { $data = $this->request->getData(); $this->assertCount(0, $data); } public function testSendSuccess() { $this->setMockHttpResponse('FetchCustomerSuccess.txt'); /** @var FetchCustomerResponse $response */ $response = $this->request->send(); $this->assertEqualRequest(new Request("GET", "https://api.mollie.com/v2/customers/cst_bSNBBJBzdG"), $this->getMockClient()->getLastRequest()); $this->assertInstanceOf(FetchCustomerResponse::class, $response); $this->assertSame('cst_bSNBBJBzdG', $response->getCustomerReference()); $this->assertTrue($response->isSuccessful()); $this->assertJsonStringEqualsJsonString( '{"resource":"customer","id":"cst_bSNBBJBzdG","mode":"test","name":"John Doe","email":"john@doe.com","locale":"nl_NL","metadata":null,"createdAt":"2018-07-19T12:58:47+00:00","_links":{"self":{"href":"https:\/\/api.mollie.com\/v2\/customers\/cst_6HUkmjwzBB","type":"application\/hal+json"},"documentation":{"href":"https:\/\/docs.mollie.com\/reference\/v2\/customers-api\/get-customer","type":"text\/html"}}}', $response->getMessage() ); } public function testSendFailure() { $this->setMockHttpResponse('FetchCustomerFailure.txt'); /** @var FetchCustomerResponse $response */ $response = $this->request->send(); $this->assertEqualRequest(new Request("GET", "https://api.mollie.com/v2/customers/cst_bSNBBJBzdG"), $this->getMockClient()->getLastRequest()); $this->assertInstanceOf(FetchCustomerResponse::class, $response); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertNull($response->getCustomerReference()); $this->assertSame('{"status":404,"title":"Not Found","detail":"No customer exists with token cst_6HUkmjwzBBa.","_links":{"documentation":{"href":"https:\/\/docs.mollie.com\/guides\/handling-errors","type":"text\/html"}}}', $response->getMessage()); } } tests/Message/UpdateCustomerRequestTest.php 0000666 00000007536 15165345042 0015204 0 ustar 00 <?php namespace Omnipay\Mollie\Test\Message; use AmeliaGuzzleHttp\Psr7\Request; use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\Mollie\Message\Request\UpdateCustomerRequest; use Omnipay\Mollie\Message\Response\UpdateCustomerResponse; use Omnipay\Tests\TestCase; class UpdateCustomerRequestTest extends TestCase { use AssertRequestTrait; /** * * @var UpdateCustomerRequest */ protected $request; public function setUp() { $this->request = new UpdateCustomerRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize(array( 'apiKey' => 'mykey', 'customerReference' => 'cst_bSNBBJBzdG', 'description' => 'Jane Doe', 'email' => 'john@doe.com', 'locale' => 'nl_NL', 'metadata' => 'Just some meta data.', )); } /** * @throws InvalidRequestException */ public function testData() { $this->request->initialize(array( 'apiKey' => 'mykey', 'customerReference' => 'cst_bSNBBJBzdG', 'description' => 'Jane Doe', 'email' => 'john@doe.com', 'metadata' => 'Just some meta data.', )); $data = $this->request->getData(); $this->assertSame("Jane Doe", $data['name']); $this->assertSame('john@doe.com', $data['email']); $this->assertSame('Just some meta data.', $data['metadata']); $this->assertCount(4, $data); } public function testSendSuccess() { $this->setMockHttpResponse('UpdateCustomerSuccess.txt'); /** @var UpdateCustomerResponse $response */ $response = $this->request->send(); $this->assertEqualRequest( new Request( "POST", "https://api.mollie.com/v2/customers/cst_bSNBBJBzdG", [], '{ "name": "Jane Doe", "email": "john@doe.com", "metadata": "Just some meta data.", "locale": "nl_NL" }' ), $this->getMockClient()->getLastRequest() ); $this->assertInstanceOf(UpdateCustomerResponse::class, $response); $this->assertSame('cst_bSNBBJBzdG', $response->getCustomerReference()); $this->assertTrue($response->isSuccessful()); $this->assertJsonStringEqualsJsonString( '{"resource":"customer","id":"cst_bSNBBJBzdG","mode":"test","name":"Jane Doe","email":"john@doe.com","locale":"nl_NL","metadata":"Just some meta data.","createdAt":"2018-07-19T12:58:47+00:00","_links":{"self":{"href":"https:\/\/api.mollie.com\/v2\/customers\/cst_6HUkmjwzBB","type":"application\/hal+json"},"documentation":{"href":"https:\/\/docs.mollie.com\/reference\/v2\/customers-api\/update-customer","type":"text\/html"}}}', $response->getMessage() ); } public function testSendFailure() { $this->setMockHttpResponse('UpdateCustomerFailure.txt'); /** @var UpdateCustomerResponse $response */ $response = $this->request->send(); $this->assertEqualRequest(new Request("POST", "https://api.mollie.com/v2/customers/cst_bSNBBJBzdG"), $this->getMockClient()->getLastRequest()); $this->assertInstanceOf(UpdateCustomerResponse::class, $response); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertNull($response->getCustomerReference()); $this->assertSame('{"status":401,"title":"Unauthorized Request","detail":"Missing authentication, or failed to authenticate","_links":{"documentation":{"href":"https:\/\/docs.mollie.com\/guides\/authentication","type":"text\/html"}}}', $response->getMessage()); } } tests/Message/FetchPaymentMethodsRequestTest.php 0000666 00000010400 15165345042 0016133 0 ustar 00 <?php namespace Omnipay\Mollie\Test\Message; use AmeliaGuzzleHttp\Psr7\Request; use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\Common\PaymentMethod; use Omnipay\Mollie\Message\Request\FetchPaymentMethodsRequest; use Omnipay\Mollie\Message\Response\FetchPaymentMethodsResponse; use Omnipay\Tests\TestCase; class FetchPaymentMethodsRequestTest extends TestCase { use AssertRequestTrait; protected static $expectedRequestUri = 'https://api.mollie.com/v2/methods?amount%5Bvalue%5D=22.56&amount%5Bcurrency%5D=SEK&billingCountry=SE&locale=sv_SE&resource=orders&includeWallets=applepay&sequenceType=oneoff'; /** * @var FetchPaymentMethodsRequest */ protected $request; public function setUp() { $this->request = new FetchPaymentMethodsRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize([ 'apiKey' => 'mykey', 'amount' => '22.56', 'billingCountry' => 'SE', 'currency' => 'SEK', 'locale' => 'sv_SE', 'resource' => 'orders', 'sequenceType' => 'oneoff', 'includeWallets' => 'applepay', ]); } /** * @throws InvalidRequestException */ public function testGetData() { $data = $this->request->getData(); $this->assertSame('SEK', $data['amount']['currency']); $this->assertSame('22.56', $data['amount']['value']); $this->assertSame('SE', $data['billingCountry']); $this->assertSame('sv_SE', $data['locale']); $this->assertSame('orders', $data['resource']); $this->assertSame('oneoff', $data['sequenceType']); $this->assertSame('applepay', $data['includeWallets']); } /** * @throws InvalidRequestException */ public function testOptionalParameters() { $this->request->initialize([ 'apiKey' => 'mykey', ]); $this->assertEmpty(array_filter($this->request->getData())); $this->request->send(); $this->assertEqualRequest( new Request('GET', 'https://api.mollie.com/v2/methods'), $this->getMockClient()->getLastRequest() ); } /** * Require both amount and currency when either one is set. * * @throws InvalidRequestException */ public function testRequiredAmountParameters() { $this->expectException(InvalidRequestException::class); $this->request->initialize([ 'apiKey' => 'mykey', 'amount' => '78.02', ]); $this->request->getData(); } public function testSendSuccess() { $this->setMockHttpResponse('FetchPaymentMethodsSuccess.txt'); $response = $this->request->send(); $this->assertEqualRequest( new Request('GET', self::$expectedRequestUri), $this->getMockClient()->getLastRequest() ); $this->assertInstanceOf(FetchPaymentMethodsResponse::class, $response); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertNull($response->getTransactionReference()); $paymentMethods = $response->getPaymentMethods(); $this->assertCount(12, $paymentMethods); $paymentMethod = new PaymentMethod('ideal', 'iDEAL'); $this->assertEquals($paymentMethod, $paymentMethods[0]); } public function testSendFailure() { $this->setMockHttpResponse('FetchPaymentMethodsFailure.txt'); $response = $this->request->send(); $this->assertEqualRequest( new Request('GET', self::$expectedRequestUri), $this->getMockClient()->getLastRequest() ); $this->assertInstanceOf(FetchPaymentMethodsResponse::class, $response); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertNull($response->getTransactionReference()); $this->assertSame('{"status":401,"title":"Unauthorized Request","detail":"Missing authentication, or failed to authenticate","_links":{"documentation":{"href":"https:\/\/docs.mollie.com\/guides\/authentication","type":"text\/html"}}}', $response->getMessage()); $this->assertEmpty($response->getPaymentMethods()); } } tests/Message/FetchOrderRequestTest.php 0000666 00000010457 15165345042 0014261 0 ustar 00 <?php namespace Omnipay\Mollie\Test\Message; use AmeliaGuzzleHttp\Psr7\Request; use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\Common\Http\ClientInterface; use Omnipay\Mollie\Item; use Omnipay\Mollie\Message\Request\FetchOrderRequest; use Omnipay\Mollie\Message\Request\FetchTransactionRequest; use Omnipay\Mollie\Message\Response\FetchOrderResponse; use Omnipay\Tests\TestCase; use AmeliaPsr\Http\Message\ResponseInterface; class FetchOrderRequestTest extends TestCase { use AssertRequestTrait; /** * @var FetchTransactionRequest */ protected $request; public function setUp() { $this->request = new FetchOrderRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize( array( 'apiKey' => 'mykey', 'transactionReference' => 'ord_kEn1PlbGa', ) ); } /** * @throws InvalidRequestException */ public function testGetData() { $data = $this->request->getData(); $this->assertSame("ord_kEn1PlbGa", $data['id']); $this->assertCount(1, $data); } public function testSendSuccess() { $this->setMockHttpResponse('FetchOrderSuccess.txt'); /** @var FetchOrderResponse $response */ $response = $this->request->send(); $this->assertEqualRequest( new Request( "GET", "https://api.mollie.com/v2/orders/ord_kEn1PlbGa" ), $this->getMockClient()->getLastRequest() ); $this->assertInstanceOf(FetchOrderResponse::class, $response); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isPaid()); $this->assertFalse($response->isCancelled()); $this->assertFalse($response->isPaidOut()); $this->assertTrue($response->isRedirect()); $this->assertFalse($response->isRefunded()); $this->assertFalse($response->isPartialRefunded()); $this->assertSame("created", $response->getStatus()); $this->assertSame('ord_kEn1PlbGa', $response->getTransactionReference()); $this->assertSame("1027.99", $response->getAmount()); $this->assertCount(2, $response->getLines()); $line = $response->getLines()[0]; $this->assertSame('5702016116977', $line['sku']); $this->assertSame(2, $line['quantity']); $this->assertSame('0.00', $line['amountShipped']['value']); $this->assertCount(2, $response->getItems()->all()); /** @var Item $item */ $item = $response->getItems()->all()[0]; $this->assertSame('5702016116977', $item->getSku()); $this->assertSame(2, $item->getQuantity()); $this->assertSame('0.00', $item->getAmountShipped()); // We cannot parse _links, rest should match unset($line['_links']); $this->assertSame(array_keys($line), array_keys($item->getParameters())); } public function testSendDataWithIncludingPayments() { $expectedData = ['_embedded' => 'some-payments']; $clientResponse = $this->createMock(ResponseInterface::class); $clientResponse->expects(self::once()) ->method('getBody') ->willReturn(\json_encode($expectedData)); $httpClient = $this->createMock(ClientInterface::class); $httpClient->expects(self::once()) ->method('request') ->with( FetchOrderRequest::GET, 'https://api.mollie.com/v2/orders/ord_kEn1PlbGa?embed=payments', $this->callback(function ($headers) { return $headers['Authorization'] == 'Bearer mykey'; }), null )->willReturn($clientResponse); $request = new FetchOrderRequest($httpClient, $this->getHttpRequest()); $request->initialize( [ 'apiKey' => 'mykey', 'transactionReference' => 'ord_kEn1PlbGa', 'includePayments' => true, ] ); $response = $request->sendData(['id' => 'ord_kEn1PlbGa']); self::assertInstanceOf(FetchOrderResponse::class, $response); self::assertEquals($request, $response->getRequest()); self::assertEquals($expectedData, $response->getData()); } } tests/Message/CreateShipmentRequestTest.php 0000666 00000010043 15165345042 0015136 0 ustar 00 <?php namespace Omnipay\Mollie\Test\Message; use AmeliaGuzzleHttp\Psr7\Request; use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\Mollie\Item; use Omnipay\Mollie\Message\Request\CreateCustomerRequest; use Omnipay\Mollie\Message\Request\CreateShipmentRequest; use Omnipay\Mollie\Message\Response\CreateCustomerResponse; use Omnipay\Mollie\Message\Response\CreateShipmentResponse; use Omnipay\Tests\TestCase; class CreateShipmentRequestTest extends TestCase { use AssertRequestTrait; /** * * @var CreateCustomerRequest */ protected $request; public function setUp() { $this->request = new CreateShipmentRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize(array( 'apiKey' => 'mykey', 'transactionReference' => 'ord_xxx', 'items' => [ [ 'id' => 'odl_dgtxyl', 'quantity' => 1, ], [ 'id' => 'odl_jp31jz', ] ], 'tracking' => [ 'carrier' => 'PostNL', 'code' => '3SKABA000000000', 'url' => 'http://postnl.nl/tracktrace/?B=3SKABA000000000&P=1016EE&D=NL&T=C', ] )); } /** * @throws InvalidRequestException */ public function testData() { $data = $this->request->getData(); $this->assertSame("odl_dgtxyl", $data['lines'][0]['id']); $this->assertSame(1, $data['lines'][0]['quantity']); $this->assertCount(2, $data['lines'][0]); $this->assertSame("odl_jp31jz", $data['lines'][1]['id']); $this->assertCount(1, $data['lines'][1]); $this->assertSame([ 'carrier' => 'PostNL', 'code' => '3SKABA000000000', 'url' => 'http://postnl.nl/tracktrace/?B=3SKABA000000000&P=1016EE&D=NL&T=C', ], $data['tracking']); $this->assertCount(2, $data); } public function testSendSuccess() { $this->setMockHttpResponse('CreateShipmentSuccess.txt'); /** @var CreateShipmentResponse $response */ $response = $this->request->send(); $orderId = $this->request->getTransactionReference(); $this->assertEqualRequest( new Request( "POST", "https://api.mollie.com/v2/orders/{$orderId}/shipments", [], '{ "lines": [ { "id": "odl_dgtxyl", "quantity": 1 }, { "id": "odl_jp31jz" } ], "tracking": { "carrier": "PostNL", "code": "3SKABA000000000", "url": "http://postnl.nl/tracktrace/?B=3SKABA000000000&P=1016EE&D=NL&T=C" } }' ), $this->getMockClient()->getLastRequest() ); $this->assertInstanceOf(CreateShipmentResponse::class, $response); $this->assertSame('shp_3wmsgCJN4U', $response->getTransactionReference()); $this->assertTrue($response->isSuccessful()); $this->assertCount(2, $response->getLines()); $line = $response->getLines()[0]; $this->assertSame('5702016116977', $line['sku']); $this->assertSame(1, $line['quantity']); $this->assertSame('299.00', $line['totalAmount']['value']); $this->assertCount(2, $response->getItems()->all()); /** @var Item $item */ $item = $response->getItems()->all()[0]; $this->assertSame('5702016116977', $item->getSku()); $this->assertSame(1, $item->getQuantity()); $this->assertSame('299.00', $item->getTotalAmount()); // We cannot parse _links, rest should match unset($line['_links']); $this->assertSame(array_keys($line), array_keys($item->getParameters())); } } tests/Message/CreateOrderRequestTest.php 0000666 00000023374 15165345042 0014435 0 ustar 00 <?php namespace Omnipay\Mollie\Test\Message; use AmeliaGuzzleHttp\Psr7\Request; use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\Common\ItemBag; use Omnipay\Mollie\Item; use Omnipay\Mollie\Message\Request\CreateOrderRequest; use Omnipay\Mollie\Message\Request\PurchaseRequest; use Omnipay\Mollie\Message\Response\CreateOrderResponse; use Omnipay\Mollie\Message\Response\PurchaseResponse; use Omnipay\Tests\TestCase; class CreateOrderRequestTest extends TestCase { use AssertRequestTrait; /** * @var CreateOrderRequest */ protected $request; public function setUp() { $this->request = new CreateOrderRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize(array( 'apiKey' => 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM', 'amount' => '1027.99', 'currency' => 'EUR', 'orderNumber' => '1337', 'lines' => [ [ 'type' => 'physical', 'sku' => '5702016116977', 'name' => 'LEGO 42083 Bugatti Chiron', 'productUrl' => 'https://shop.lego.com/nl-NL/Bugatti-Chiron-42083', 'imageUrl' => 'https://sh-s7-live-s.legocdn.com/is/image//LEGO/42083_alt1?$main$', 'quantity' => 2, 'vatRate' => '21.00', 'unitPrice' => '399.00', 'totalAmount' => '698.00', 'discountAmount' => '100.00', 'vatAmount' => '121.14', ], [ 'type' => 'physical', 'sku' => '5702015594028', 'name' => 'LEGO 42056 Porsche 911 GT3 RS', 'productUrl' => 'https://shop.lego.com/nl-NL/Porsche-911-GT3-RS-42056', 'imageUrl' => 'https://sh-s7-live-s.legocdn.com/is/image/LEGO/42056?$PDPDefault$', 'quantity' => 1, 'vatRate' => '21.00', 'unitPrice' => '329.99', 'totalAmount' => '329.99', 'vatAmount' => '57.27', ], ], 'card' => [ 'company' => 'Mollie B.V.', 'email' => 'norris@chucknorrisfacts.net', 'birthday' => '1958-01-31', 'billingTitle' => 'Dhr', 'billingFirstName' => 'Piet', 'billingLastName' => 'Mondriaan', 'billingAddress1' => 'Keizersgracht 313', 'billingCity' => 'Amsterdam', 'billingPostcode' => '1234AB', 'billingState' => 'Noord-Holland', 'billingCountry' => 'NL', 'billingPhone' => '+31208202070', 'shippingTitle' => 'Mr', 'shippingFirstName' => 'Chuck', 'shippingLastName' => 'Norris', 'shippingAddress1' => 'Prinsengracht 313', 'shippingAddress2' => '4th floor', 'shippingCity' => 'Haarlem', 'shippingPostcode' => '5678AB', 'shippingState' => 'Noord-Holland', 'shippingCountry' => 'NL', ], 'metadata' => [ 'order_id' => '1337', 'description' => 'Lego cars', ], 'locale' => 'nl_NL', 'returnUrl' => 'https://example.org/redirect', 'notifyUrl' => 'https://example.org/webhook', 'paymentMethod' => 'klarnapaylater', 'billingEmail' => 'piet@mondriaan.com', )); } /** * @throws InvalidRequestException */ public function testGetData() { $data = $this->request->getData(); $this->assertSame(["value" => "1027.99", "currency" => "EUR"], $data['amount']); $this->assertSame('1337', $data['orderNumber']); $this->assertSame('https://example.org/redirect', $data['redirectUrl']); $this->assertSame('klarnapaylater', $data['method']); $this->assertSame('Lego cars', $data['metadata']['description']); $this->assertSame('nl_NL', $data['locale']); $this->assertCount(11, $data); } public function testGetAddressData() { $data = $this->request->getData(); $shippingAddress = $data['shippingAddress']; $this->assertSame('Mollie B.V.', $shippingAddress['organizationName']); $this->assertSame('Prinsengracht 313', $shippingAddress['streetAndNumber']); $this->assertSame('4th floor', $shippingAddress['streetAdditional']); $this->assertSame('Haarlem', $shippingAddress['city']); $this->assertSame('Noord-Holland', $shippingAddress['region']); $this->assertSame('5678AB', $shippingAddress['postalCode']); $this->assertSame('NL', $shippingAddress['country']); $this->assertSame('Mr', $shippingAddress['title']); $this->assertSame('Chuck', $shippingAddress['givenName']); $this->assertSame('Norris', $shippingAddress['familyName']); $this->assertSame('norris@chucknorrisfacts.net', $shippingAddress['email']); $billingAddress = $data['billingAddress']; $this->assertSame('Mollie B.V.', $billingAddress['organizationName']); $this->assertSame('Keizersgracht 313', $billingAddress['streetAndNumber']); $this->assertSame('Amsterdam', $billingAddress['city']); $this->assertSame('Noord-Holland', $billingAddress['region']); $this->assertSame('1234AB', $billingAddress['postalCode']); $this->assertSame('NL', $billingAddress['country']); $this->assertSame('Dhr', $billingAddress['title']); $this->assertSame('Piet', $billingAddress['givenName']); $this->assertSame('Mondriaan', $billingAddress['familyName']); $this->assertSame('piet@mondriaan.com', $billingAddress['email']); $this->assertSame('+31208202070', $billingAddress['phone']); } public function testGetLines() { $data = $this->request->getData(); $this->assertCount(2, $data['lines']); $line = $data['lines'][0]; $this->assertSame('physical', $line['type']); $this->assertSame('5702016116977', $line['sku']); $this->assertSame('LEGO 42083 Bugatti Chiron', $line['name']); $this->assertSame('https://shop.lego.com/nl-NL/Bugatti-Chiron-42083', $line['productUrl']); $this->assertSame('https://sh-s7-live-s.legocdn.com/is/image//LEGO/42083_alt1?$main$', $line['imageUrl']); $this->assertSame(2, $line['quantity']); $this->assertSame('21.00', $line['vatRate']); $this->assertSame('399.00', $line['unitPrice']['value']); $this->assertSame('698.00', $line['totalAmount']['value']); $this->assertSame('100.00', $line['discountAmount']['value']); $this->assertSame('121.14', $line['vatAmount']['value']); } public function testDiscountLines() { $this->request->setLines([ [ 'type' => 'physical', 'sku' => '5702016116977', 'name' => 'LEGO 42083 Bugatti Chiron', 'quantity' => 2, 'vatRate' => '21.00', 'unitPrice' => '399.00', 'totalAmount' => '698.00', 'discountAmount' => '100.00', 'vatAmount' => '121.14', ], [ 'type' => 'discount', 'name' => 'Discount 100 EURO', 'quantity' => 1, 'vatRate' => '21.00', 'unitPrice' => '-100.00', 'totalAmount' => '-100.00', 'vatAmount' => '-17.36', ], ]); $this->setMockHttpResponse('CreateOrderSuccess.txt'); $response = $this->request->send(); $this->assertInstanceOf(CreateOrderResponse::class, $response); } public function testSendSuccess() { $this->setMockHttpResponse('CreateOrderSuccess.txt'); $response = $this->request->send(); $this->assertEqualRequest( new Request( "POST", "https://api.mollie.com/v2/orders", [], file_get_contents(__DIR__ . '/../Mock/CreateOrderRequest.txt') ), $this->getMockClient()->getLastRequest() ); $this->assertInstanceOf(CreateOrderResponse::class, $response); $this->assertFalse($response->isSuccessful()); $this->assertTrue($response->isRedirect()); $this->assertSame('GET', $response->getRedirectMethod()); $this->assertSame('https://www.mollie.com/payscreen/order/checkout/pbjz8x', $response->getRedirectUrl()); $this->assertNull($response->getRedirectData()); $this->assertSame('ord_pbjz8x', $response->getTransactionReference()); $this->assertSame('created' ,$response->getStatus()); $this->assertTrue($response->isOpen()); $this->assertFalse($response->isPaid()); $this->assertNull($response->getCode()); } public function testSendFailure() { $this->setMockHttpResponse('CreateOrderFailure.txt'); $response = $this->request->send(); $this->assertEqualRequest(new Request("POST", "https://api.mollie.com/v2/orders"), $this->getMockClient()->getLastRequest()); $this->assertInstanceOf(CreateOrderResponse::class, $response); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertNull($response->getTransactionReference()); $this->assertSame('{"status":401,"title":"Unauthorized Request","detail":"Missing authentication, or failed to authenticate","_links":{"documentation":{"href":"https:\/\/docs.mollie.com\/guides\/authentication","type":"text\/html"}}}', $response->getMessage()); } } tests/Mock/PurchaseIssuerFailure.txt 0000666 00000000530 15165345042 0013624 0 ustar 00 HTTP/1.1 422 Unprocessable Entity Content-Type: application/hal+json; charset=utf-8 { "status": 422, "title": "Unprocessable Entity", "detail": "The payment method is invalid", "field": "method", "_links": { "documentation": { "href": "https://docs.mollie.com/guides/handling-errors", "type": "text/html" } } } tests/Mock/Refund422Failure.txt 0000666 00000000530 15165345042 0012332 0 ustar 00 HTTP/1.1 422 Unprocessable Entity Content-Type: application/hal+json; charset=utf-8 { "status": 422, "title": "Unprocessable Entity", "detail": "The payment method is invalid", "field": "method", "_links": { "documentation": { "href": "https://docs.mollie.com/guides/handling-errors", "type": "text/html" } } } tests/Mock/CreateOrderFailure.txt 0000666 00000000525 15165345042 0013062 0 ustar 00 HTTP/1.1 401 Unauthorized Request Content-Type: application/hal+json; charset=utf-8 { "status": 401, "title": "Unauthorized Request", "detail": "Missing authentication, or failed to authenticate", "_links": { "documentation": { "href": "https://docs.mollie.com/guides/authentication", "type": "text/html" } } } tests/Mock/CompletePurchaseSuccess.txt 0000666 00000002231 15165345042 0014143 0 ustar 00 HTTP/1.1 200 OK Content-Type: application/hal+json; charset=utf-8 { "resource": "payment", "id": "tr_Qzin4iTWrU", "mode": "test", "createdAt": "2018-07-19T12:38:21+00:00", "amount": { "value": "10.00", "currency": "EUR" }, "description": "Order #1234", "method": "ideal", "metadata": null, "status": "paid", "paidAt": "2018-07-19T12:38:34+00:00", "amountRefunded": { "value": "0.00", "currency": "EUR" }, "amountRemaining": { "value": "35.00", "currency": "EUR" }, "locale": "nl_NL", "countryCode": "NL", "profileId": "pfl_7N5qjbu42V", "sequenceType": "oneoff", "redirectUrl": "http://mollie.com", "webhookUrl": "http://mollie.com", "settlementAmount": { "value": "10.00", "currency": "EUR" }, "details": { "consumerName": "T. TEST", "consumerAccount": "NL17RABO0213698412", "consumerBic": "INGBNL2A" }, "_links": { "self": { "href": "https://api.mollie.com/v2/payments/tr_2bMMNCF5A2", "type": "application/hal+json" }, "documentation": { "href": "https://docs.mollie.com/reference/v2/payments-api/get-payment", "type": "text/html" } } } tests/Mock/FetchTransactionExpired.txt 0000666 00000001443 15165345042 0014133 0 ustar 00 HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 { "resource": "payment", "id": "tr_WDqYK6vllg", "mode": "test", "createdAt": "2018-03-12T10:56:15+00:00", "amount": { "value": "1.00", "currency": "EUR" }, "description": "Order 66", "method": null, "metadata": null, "status": "expired", "isCancelable": false, "expiresAt": "2018-03-12T11:11:15+00:00", "details": null, "profileId": "pfl_7N5qjbu42V", "sequenceType": "oneoff", "redirectUrl": "https://www.example.org/payment/completed", "_links": { "self": { "href": "https://api.mollie.com/v2/payments/tr_WDqYK6vllg" }, "checkout": { "href": "https://www.mollie.com/payscreen/select-method/PSj7b45bkj" } } } tests/Mock/FetchIssuersFailure.txt 0000666 00000000526 15165345042 0013273 0 ustar 00 HTTP/1.1 401 Unauthorized Request Content-Type: application/hal+json; charset=utf-8 { "status": 401, "title": "Unauthorized Request", "detail": "Missing authentication, or failed to authenticate", "_links": { "documentation": { "href": "https://docs.mollie.com/guides/authentication", "type": "text/html" } } } tests/Mock/FetchCustomerMandatesFailure.txt 0000666 00000000475 15165345042 0015117 0 ustar 00 HTTP/1.1 404 Not Found Content-Type: application/hal+json; charset=utf-8 { "status": 404, "title": "Not Found", "detail": "No customer exists with token cst_6HUkmjwzBBa.", "_links": { "documentation": { "href": "https://docs.mollie.com/guides/handling-errors", "type": "text/html" } } } tests/Mock/UpdateCustomerSuccess.txt 0000666 00000001077 15165345042 0013653 0 ustar 00 HTTP/1.1 200 OK Content-Type: application/hal+json; charset=utf-8 { "resource": "customer", "id": "cst_bSNBBJBzdG", "mode": "test", "name": "Jane Doe", "email": "john@doe.com", "locale": "nl_NL", "metadata": "Just some meta data.", "createdAt": "2018-07-19T12:58:47+00:00", "_links": { "self": { "href": "https://api.mollie.com/v2/customers/cst_6HUkmjwzBB", "type": "application/hal+json" }, "documentation": { "href": "https://docs.mollie.com/reference/v2/customers-api/update-customer", "type": "text/html" } } } tests/Mock/PurchaseSuccess.txt 0000666 00000002206 15165345042 0012454 0 ustar 00 HTTP/1.1 201 Created Content-Type: application/hal+json; charset=utf-8 { "resource": "payment", "id": "tr_7UhSN1zuXS", "mode": "test", "createdAt": "2018-03-20T09:13:37+00:00", "amount": { "value": "10.00", "currency": "EUR" }, "description": "My first payment", "method": null, "metadata": { "order_id": "12345" }, "status": "open", "isCancelable": false, "expiresAt": "2018-03-20T09:28:37+00:00", "details": null, "profileId": "pfl_QkEhN94Ba", "sequenceType": "oneoff", "redirectUrl": "https://webshop.example.org/order/12345/", "webhookUrl": "https://webshop.example.org/payments/webhook/", "_links": { "self": { "href": "https://api.mollie.com/v2/payments/tr_7UhSN1zuXS", "type": "application/json" }, "checkout": { "href": "https://www.mollie.com/payscreen/select-method/7UhSN1zuXS", "type": "text/html" }, "documentation": { "href": "https://docs.mollie.com/reference/v2/payments-api/create-payment", "type": "text/html" } } } tests/Mock/CreateCustomerMandateFailure.txt 0000666 00000000525 15165345042 0015102 0 ustar 00 HTTP/1.1 401 Unauthorized Request Content-Type: application/hal+json; charset=utf-8 { "status": 401, "title": "Unauthorized Request", "detail": "Missing authentication, or failed to authenticate", "_links": { "documentation": { "href": "https://docs.mollie.com/guides/authentication", "type": "text/html" } } } tests/Mock/CreateShipmentSuccess.txt 0000666 00000006515 15165345042 0013624 0 ustar 00 HTTP/1.1 201 Created Content-Type: application/hal+json { "resource": "shipment", "id": "shp_3wmsgCJN4U", "orderId": "ord_kEn1PlbGa", "createdAt": "2018-08-09T14:33:54+00:00", "tracking": { "carrier": "PostNL", "code": "3SKABA000000000", "url": "http://postnl.nl/tracktrace/?B=3SKABA000000000&P=1016EE&D=NL&T=C" }, "lines": [ { "resource": "orderline", "id": "odl_dgtxyl", "orderId": "ord_pbjz8x", "name": "LEGO 42083 Bugatti Chiron", "sku": "5702016116977", "type": "physical", "status": "shipping", "isCancelable": true, "quantity": 1, "unitPrice": { "value": "399.00", "currency": "EUR" }, "vatRate": "21.00", "vatAmount": { "value": "51.89", "currency": "EUR" }, "discountAmount": { "value": "100.00", "currency": "EUR" }, "totalAmount": { "value": "299.00", "currency": "EUR" }, "createdAt": "2018-08-02T09:29:56+00:00", "_links": { "productUrl": { "href": "https://shop.lego.com/nl-NL/Bugatti-Chiron-42083", "type": "text/html" }, "imageUrl": { "href": "https://sh-s7-live-s.legocdn.com/is/image//LEGO/42083_alt1?$main$", "type": "text/html" } } }, { "resource": "orderline", "id": "odl_jp31jz", "orderId": "ord_pbjz8x", "name": "LEGO 42056 Porsche 911 GT3 RS", "sku": "5702015594028", "type": "physical", "status": "completed", "isCancelable": false, "quantity": 1, "unitPrice": { "value": "329.99", "currency": "EUR" }, "vatRate": "21.00", "vatAmount": { "value": "57.27", "currency": "EUR" }, "totalAmount": { "value": "329.99", "currency": "EUR" }, "createdAt": "2018-08-02T09:29:56+00:00", "_links": { "productUrl": { "href": "https://shop.lego.com/nl-NL/Porsche-911-GT3-RS-42056", "type": "text/html" }, "imageUrl": { "href": "https://sh-s7-live-s.legocdn.com/is/image/LEGO/42056?$PDPDefault$", "type": "text/html" } } } ], "_links": { "self": { "href": "https://api.mollie.com/v2/order/ord_kEn1PlbGa/shipments/shp_3wmsgCJN4U", "type": "application/hal+json" }, "order": { "href": "https://api.mollie.com/v2/orders/ord_kEn1PlbGa", "type": "application/hal+json" }, "documentation": { "href": "https://docs.mollie.com/reference/v2/shipments-api/get-shipment", "type": "text/html" } } } tests/Mock/FetchTransactionSuccess.txt 0000666 00000002201 15165345042 0014134 0 ustar 00 HTTP/1.1 200 OK Content-Type: application/hal+json; charset=utf-8 { "resource": "payment", "id": "tr_WDqYK6vllg", "mode": "test", "createdAt": "2018-03-20T13:13:37+00:00", "amount": { "value": "10.00", "currency": "EUR" }, "description": "My first payment", "method": null, "metadata": { "order_id": "12345" }, "status": "paid", "isCancelable": false, "expiresAt": "2018-03-20T13:28:37+00:00", "details": null, "profileId": "pfl_QkEhN94Ba", "sequenceType": "oneoff", "redirectUrl": "https://webshop.example.org/order/12345/", "webhookUrl": "https://webshop.example.org/payments/webhook/", "_links": { "self": { "href": "https://api.mollie.com/v2/payments/tr_WDqYK6vllg", "type": "application/hal+json" }, "checkout": { "href": "https://www.mollie.com/payscreen/select-method/WDqYK6vllg", "type": "text/html" }, "documentation": { "href": "https://docs.mollie.com/reference/v2/payments-api/get-payment", "type": "text/html" } } } tests/Mock/CompletePurchaseExpired.txt 0000666 00000001317 15165345042 0014137 0 ustar 00 HTTP/1.1 200 OK Content-Type: application/hal+json; charset=utf-8 { "resource": "payment", "id": "tr_Qzin4iTWrU", "mode": "test", "createdAt": "2018-07-19T12:04:56+00:00", "amount": { "value": "100.00", "currency": "EUR" }, "description": "apex.sh performance test payment", "method": null, "metadata": null, "status": "expired", "expiredAt": "2018-07-19T12:21:04+00:00", "locale": "nl_NL", "profileId": "pfl_7N5qjbu42V", "sequenceType": "oneoff", "redirectUrl": "https://www.example.org/", "_links": { "self": { "href": "https://api.mollie.com/v2/payments/tr_wnUB738Suu", "type": "application/hal+json" } } } tests/Mock/CreateCustomerFailure.txt 0000666 00000000525 15165345042 0013610 0 ustar 00 HTTP/1.1 401 Unauthorized Request Content-Type: application/hal+json; charset=utf-8 { "status": 401, "title": "Unauthorized Request", "detail": "Missing authentication, or failed to authenticate", "_links": { "documentation": { "href": "https://docs.mollie.com/guides/authentication", "type": "text/html" } } } tests/Mock/FetchCustomerSuccess.txt 0000666 00000001052 15165345042 0013453 0 ustar 00 HTTP/1.1 200 OK Content-Type: application/hal+json; charset=utf-8 { "resource": "customer", "id": "cst_bSNBBJBzdG", "mode": "test", "name": "John Doe", "email": "john@doe.com", "locale": "nl_NL", "metadata": null, "createdAt": "2018-07-19T12:58:47+00:00", "_links": { "self": { "href": "https://api.mollie.com/v2/customers/cst_6HUkmjwzBB", "type": "application/hal+json" }, "documentation": { "href": "https://docs.mollie.com/reference/v2/customers-api/get-customer", "type": "text/html" } } } tests/Mock/FetchPaymentMethodsFailure.txt 0000666 00000000525 15165345042 0014576 0 ustar 00 HTTP/1.1 401 Unauthorized Request Content-Type: application/hal+json; charset=utf-8 { "status": 401, "title": "Unauthorized Request", "detail": "Missing authentication, or failed to authenticate", "_links": { "documentation": { "href": "https://docs.mollie.com/guides/authentication", "type": "text/html" } } } tests/Mock/FetchOrderSuccess.txt 0000666 00000015217 15165345042 0012735 0 ustar 00 HTTP/1.1 200 OK Content-Type: application/hal+json { "resource": "order", "id": "ord_kEn1PlbGa", "profileId": "pfl_URR55HPMGx", "method": "ideal", "amount": { "value": "1027.99", "currency": "EUR" }, "status": "created", "isCancelable": true, "metadata": null, "createdAt": "2018-08-02T09:29:56+00:00", "expiresAt": "2018-08-30T09:29:56+00:00", "mode": "live", "locale": "nl_NL", "billingAddress": { "organizationName": "Mollie B.V.", "streetAndNumber": "Keizersgracht 313", "postalCode": "1016 EE", "city": "Amsterdam", "country": "nl", "givenName": "Luke", "familyName": "Skywalker", "email": "luke@skywalker.com" }, "orderNumber": "18475", "shippingAddress": { "organizationName": "Mollie B.V.", "streetAndNumber": "Keizersgracht 313", "postalCode": "1016 EE", "city": "Amsterdam", "country": "nl", "givenName": "Luke", "familyName": "Skywalker", "email": "luke@skywalker.com" }, "redirectUrl": "https://example.org/redirect", "lines": [ { "resource": "orderline", "id": "odl_dgtxyl", "orderId": "ord_pbjz8x", "name": "LEGO 42083 Bugatti Chiron", "sku": "5702016116977", "type": "physical", "status": "created", "isCancelable": false, "quantity": 2, "quantityShipped": 0, "amountShipped": { "value": "0.00", "currency": "EUR" }, "quantityRefunded": 0, "amountRefunded": { "value": "0.00", "currency": "EUR" }, "quantityCanceled": 0, "amountCanceled": { "value": "0.00", "currency": "EUR" }, "shippableQuantity": 0, "refundableQuantity": 0, "cancelableQuantity": 0, "unitPrice": { "value": "399.00", "currency": "EUR" }, "vatRate": "21.00", "vatAmount": { "value": "121.14", "currency": "EUR" }, "discountAmount": { "value": "100.00", "currency": "EUR" }, "totalAmount": { "value": "698.00", "currency": "EUR" }, "createdAt": "2018-08-02T09:29:56+00:00", "_links": { "productUrl": { "href": "https://shop.lego.com/nl-NL/Bugatti-Chiron-42083", "type": "text/html" }, "imageUrl": { "href": "https://sh-s7-live-s.legocdn.com/is/image//LEGO/42083_alt1?$main$", "type": "text/html" } } }, { "resource": "orderline", "id": "odl_jp31jz", "orderId": "ord_pbjz8x", "name": "LEGO 42056 Porsche 911 GT3 RS", "sku": "5702015594028", "type": "physical", "status": "created", "isCancelable": false, "quantity": 1, "quantityShipped": 0, "amountShipped": { "value": "0.00", "currency": "EUR" }, "quantityRefunded": 0, "amountRefunded": { "value": "0.00", "currency": "EUR" }, "quantityCanceled": 0, "amountCanceled": { "value": "0.00", "currency": "EUR" }, "shippableQuantity": 0, "refundableQuantity": 0, "cancelableQuantity": 0, "unitPrice": { "value": "329.99", "currency": "EUR" }, "vatRate": "21.00", "vatAmount": { "value": "57.27", "currency": "EUR" }, "totalAmount": { "value": "329.99", "currency": "EUR" }, "createdAt": "2018-08-02T09:29:56+00:00", "_links": { "productUrl": { "href": "https://shop.lego.com/nl-NL/Porsche-911-GT3-RS-42056", "type": "text/html" }, "imageUrl": { "href": "https://sh-s7-live-s.legocdn.com/is/image/LEGO/42056?$PDPDefault$", "type": "text/html" } } } ], "_embedded": { "payments": [ { "resource": "payment", "id": "tr_ncaPcAhuUV", "mode": "live", "createdAt": "2018-09-07T12:00:05+00:00", "amount": { "value": "1027.99", "currency": "EUR" }, "description": "Order #1337 (Lego cars)", "method": null, "metadata": null, "status": "open", "isCancelable": false, "locale": "nl_NL", "profileId": "pfl_URR55HPMGx", "orderId": "ord_kEn1PlbGa", "sequenceType": "oneoff", "redirectUrl": "https://example.org/redirect", "_links": { "self": { "href": "https://api.mollie.com/v2/payments/tr_ncaPcAhuUV", "type": "application/hal+json" }, "checkout": { "href": "https://www.mollie.com/payscreen/select-method/ncaPcAhuUV", "type": "text/html" }, "order": { "href": "https://api.mollie.com/v2/orders/ord_kEn1PlbGa", "type": "application/hal+json" } } } ] }, "_links": { "self": { "href": "https://api.mollie.com/v2/orders/ord_pbjz8x", "type": "application/hal+json" }, "checkout": { "href": "https://www.mollie.com/payscreen/order/checkout/pbjz8x", "type": "text/html" }, "documentation": { "href": "https://docs.mollie.com/reference/v2/orders-api/get-order", "type": "text/html" } } } tests/Mock/CompleteOrderSuccess.txt 0000666 00000015217 15165345042 0013454 0 ustar 00 HTTP/1.1 200 OK Content-Type: application/hal+json { "resource": "order", "id": "ord_kEn1PlbGa", "profileId": "pfl_URR55HPMGx", "method": "ideal", "amount": { "value": "1027.99", "currency": "EUR" }, "status": "created", "isCancelable": true, "metadata": null, "createdAt": "2018-08-02T09:29:56+00:00", "expiresAt": "2018-08-30T09:29:56+00:00", "mode": "live", "locale": "nl_NL", "billingAddress": { "organizationName": "Mollie B.V.", "streetAndNumber": "Keizersgracht 313", "postalCode": "1016 EE", "city": "Amsterdam", "country": "nl", "givenName": "Luke", "familyName": "Skywalker", "email": "luke@skywalker.com" }, "orderNumber": "18475", "shippingAddress": { "organizationName": "Mollie B.V.", "streetAndNumber": "Keizersgracht 313", "postalCode": "1016 EE", "city": "Amsterdam", "country": "nl", "givenName": "Luke", "familyName": "Skywalker", "email": "luke@skywalker.com" }, "redirectUrl": "https://example.org/redirect", "lines": [ { "resource": "orderline", "id": "odl_dgtxyl", "orderId": "ord_pbjz8x", "name": "LEGO 42083 Bugatti Chiron", "sku": "5702016116977", "type": "physical", "status": "created", "isCancelable": false, "quantity": 2, "quantityShipped": 0, "amountShipped": { "value": "0.00", "currency": "EUR" }, "quantityRefunded": 0, "amountRefunded": { "value": "0.00", "currency": "EUR" }, "quantityCanceled": 0, "amountCanceled": { "value": "0.00", "currency": "EUR" }, "shippableQuantity": 0, "refundableQuantity": 0, "cancelableQuantity": 0, "unitPrice": { "value": "399.00", "currency": "EUR" }, "vatRate": "21.00", "vatAmount": { "value": "121.14", "currency": "EUR" }, "discountAmount": { "value": "100.00", "currency": "EUR" }, "totalAmount": { "value": "698.00", "currency": "EUR" }, "createdAt": "2018-08-02T09:29:56+00:00", "_links": { "productUrl": { "href": "https://shop.lego.com/nl-NL/Bugatti-Chiron-42083", "type": "text/html" }, "imageUrl": { "href": "https://sh-s7-live-s.legocdn.com/is/image//LEGO/42083_alt1?$main$", "type": "text/html" } } }, { "resource": "orderline", "id": "odl_jp31jz", "orderId": "ord_pbjz8x", "name": "LEGO 42056 Porsche 911 GT3 RS", "sku": "5702015594028", "type": "physical", "status": "created", "isCancelable": false, "quantity": 1, "quantityShipped": 0, "amountShipped": { "value": "0.00", "currency": "EUR" }, "quantityRefunded": 0, "amountRefunded": { "value": "0.00", "currency": "EUR" }, "quantityCanceled": 0, "amountCanceled": { "value": "0.00", "currency": "EUR" }, "shippableQuantity": 0, "refundableQuantity": 0, "cancelableQuantity": 0, "unitPrice": { "value": "329.99", "currency": "EUR" }, "vatRate": "21.00", "vatAmount": { "value": "57.27", "currency": "EUR" }, "totalAmount": { "value": "329.99", "currency": "EUR" }, "createdAt": "2018-08-02T09:29:56+00:00", "_links": { "productUrl": { "href": "https://shop.lego.com/nl-NL/Porsche-911-GT3-RS-42056", "type": "text/html" }, "imageUrl": { "href": "https://sh-s7-live-s.legocdn.com/is/image/LEGO/42056?$PDPDefault$", "type": "text/html" } } } ], "_embedded": { "payments": [ { "resource": "payment", "id": "tr_ncaPcAhuUV", "mode": "live", "createdAt": "2018-09-07T12:00:05+00:00", "amount": { "value": "1027.99", "currency": "EUR" }, "description": "Order #1337 (Lego cars)", "method": null, "metadata": null, "status": "open", "isCancelable": false, "locale": "nl_NL", "profileId": "pfl_URR55HPMGx", "orderId": "ord_kEn1PlbGa", "sequenceType": "oneoff", "redirectUrl": "https://example.org/redirect", "_links": { "self": { "href": "https://api.mollie.com/v2/payments/tr_ncaPcAhuUV", "type": "application/hal+json" }, "checkout": { "href": "https://www.mollie.com/payscreen/select-method/ncaPcAhuUV", "type": "text/html" }, "order": { "href": "https://api.mollie.com/v2/orders/ord_kEn1PlbGa", "type": "application/hal+json" } } } ] }, "_links": { "self": { "href": "https://api.mollie.com/v2/orders/ord_pbjz8x", "type": "application/hal+json" }, "checkout": { "href": "https://www.mollie.com/payscreen/order/checkout/pbjz8x", "type": "text/html" }, "documentation": { "href": "https://docs.mollie.com/reference/v2/orders-api/get-order", "type": "text/html" } } } tests/Mock/FetchTransaction404Failure.txt 0000666 00000000476 15165345042 0014357 0 ustar 00 HTTP/1.1 404 Not Found Content-Type: application/hal+json; charset=utf-8 { "status": 404, "title": "Not Found", "detail": "No transaction exists with token tr_Qzin4iTWrU.", "_links": { "documentation": { "href": "https://docs.mollie.com/guides/handling-errors", "type": "text/html" } } } tests/Mock/CreateOrderRequest.txt 0000666 00000006200 15165345042 0013117 0 ustar 00 { "amount": { "value": "1027.99", "currency": "EUR" }, "billingAddress": { "organizationName": "Mollie B.V.", "streetAndNumber": "Keizersgracht 313", "city": "Amsterdam", "region": "Noord-Holland", "postalCode": "1234AB", "country": "NL", "title": "Dhr", "givenName": "Piet", "familyName": "Mondriaan", "email": "piet@mondriaan.com", "phone": "+31208202070" }, "shippingAddress": { "organizationName": "Mollie B.V.", "streetAndNumber": "Prinsengracht 313", "streetAdditional": "4th floor", "city": "Haarlem", "region": "Noord-Holland", "postalCode": "5678AB", "country": "NL", "title": "Mr", "givenName": "Chuck", "familyName": "Norris", "email": "norris@chucknorrisfacts.net" }, "metadata": { "order_id": "1337", "description": "Lego cars" }, "consumerDateOfBirth": "1958-01-31", "locale": "nl_NL", "orderNumber": "1337", "redirectUrl": "https://example.org/redirect", "webhookUrl": "https://example.org/webhook", "method": "klarnapaylater", "lines": [ { "type": "physical", "sku": "5702016116977", "name": "LEGO 42083 Bugatti Chiron", "productUrl": "https://shop.lego.com/nl-NL/Bugatti-Chiron-42083", "imageUrl": "https://sh-s7-live-s.legocdn.com/is/image//LEGO/42083_alt1?$main$", "quantity": 2, "vatRate": "21.00", "unitPrice": { "currency": "EUR", "value": "399.00" }, "totalAmount": { "currency": "EUR", "value": "698.00" }, "discountAmount": { "currency": "EUR", "value": "100.00" }, "vatAmount": { "currency": "EUR", "value": "121.14" } }, { "type": "physical", "sku": "5702015594028", "name": "LEGO 42056 Porsche 911 GT3 RS", "productUrl": "https://shop.lego.com/nl-NL/Porsche-911-GT3-RS-42056", "imageUrl": "https://sh-s7-live-s.legocdn.com/is/image/LEGO/42056?$PDPDefault$", "quantity": 1, "vatRate": "21.00", "unitPrice": { "currency": "EUR", "value": "329.99" }, "totalAmount": { "currency": "EUR", "value": "329.99" }, "vatAmount": { "currency": "EUR", "value": "57.27" } } ] } tests/Mock/Refund401Failure.txt 0000666 00000001311 15165345042 0012325 0 ustar 00 HTTP/1.1 401 Authorization Required Server: nginx/1.4.4 Date: Mon, 20 Jan 2014 10:04:18 GMT Content-Type: application/json; charset=utf-8 Content-Length: 155 Connection: keep-alive Access-Control-Allow-Credentials: true Access-Control-Allow-Methods: GET, POST, HEAD, OPTIONS, DELETE Access-Control-Max-Age: 300 Cache-Control: no-cache, no-store Strict-Transport-Security: max-age=31556926; includeSubDomains Www-Authenticate: Basic realm="Mollie API Key" { "status": 401, "title": "Unauthorized Request", "detail": "Missing authentication, or failed to authenticate", "_links": { "documentation": { "href": "https://docs.mollie.com/guides/authentication", "type": "text/html" } } } tests/Mock/CreateCustomerMandateSuccess.txt 0000666 00000001707 15165345042 0015126 0 ustar 00 HTTP/1.1 201 Created Content-Type: application/json; charset=utf-8 { "resource": "mandate", "id": "mdt_h3gAaD5zP", "mode": "test", "status": "valid", "method": "directdebit", "details": { "consumerName": "John Doe", "consumerAccount": "NL55INGB0000000000", "consumerBic": "INGBNL2A" }, "mandateReference": "YOUR-COMPANY-MD13804", "signatureDate": "2018-05-07", "createdAt": "2018-05-07T10:49:08+00:00", "_links": { "self": { "href": "https://api.mollie.com/v2/customers/cst_4qqhO89gsT/mandates/mdt_h3gAaD5zP", "type": "application/hal+json" }, "customer": { "href": "https://api.mollie.com/v2/customers/cst_4qqhO89gsT", "type": "application/hal+json" }, "documentation": { "href": "https://docs.mollie.com/reference/v2/mandates-api/create-mandate", "type": "text/html" } } } tests/Mock/RevokeCustomerMandateSuccess.txt 0000666 00000000031 15165345042 0015143 0 ustar 00 HTTP/1.1 204 No Content tests/Mock/FetchPaymentMethodsSuccess.txt 0000666 00000014012 15165345042 0014613 0 ustar 00 HTTP/1.1 200 OK Content-Type: application/hal+json; charset=utf-8 { "_embedded": { "methods": [ { "resource": "method", "id": "ideal", "description": "iDEAL", "image": { "size1x": "https://www.mollie.com/images/payscreen/methods/ideal.png", "size2x": "https://www.mollie.com/images/payscreen/methods/ideal%402x.png" }, "_links": { "self": { "href": "https://api.mollie.com/v2/methods/ideal", "type": "application/hal+json" } } }, { "resource": "method", "id": "creditcard", "description": "Credit card", "image": { "size1x": "https://www.mollie.com/images/payscreen/methods/creditcard.png", "size2x": "https://www.mollie.com/images/payscreen/methods/creditcard%402x.png" }, "_links": { "self": { "href": "https://api.mollie.com/v2/methods/creditcard", "type": "application/hal+json" } } }, { "resource": "method", "id": "paypal", "description": "PayPal", "image": { "size1x": "https://www.mollie.com/images/payscreen/methods/paypal.png", "size2x": "https://www.mollie.com/images/payscreen/methods/paypal%402x.png" }, "_links": { "self": { "href": "https://api.mollie.com/v2/methods/paypal", "type": "application/hal+json" } } }, { "resource": "method", "id": "bancontact", "description": "Bancontact", "image": { "size1x": "https://www.mollie.com/images/payscreen/methods/mistercash.png", "size2x": "https://www.mollie.com/images/payscreen/methods/mistercash%402x.png" }, "_links": { "self": { "href": "https://api.mollie.com/v2/methods/mistercash", "type": "application/hal+json" } } }, { "resource": "method", "id": "banktransfer", "description": "Bank transfer", "image": { "size1x": "https://www.mollie.com/images/payscreen/methods/banktransfer.png", "size2x": "https://www.mollie.com/images/payscreen/methods/banktransfer%402x.png" }, "_links": { "self": { "href": "https://api.mollie.com/v2/methods/banktransfer", "type": "application/hal+json" } } }, { "resource": "method", "id": "sofort", "description": "SOFORT Banking", "image": { "size1x": "https://www.mollie.com/images/payscreen/methods/sofort.png", "size2x": "https://www.mollie.com/images/payscreen/methods/sofort%402x.png" }, "_links": { "self": { "href": "https://api.mollie.com/v2/methods/sofort", "type": "application/hal+json" } } }, { "resource": "method", "id": "eps", "description": "eps", "image": { "size1x": "https://www.mollie.com/images/payscreen/methods/eps.png", "size2x": "https://www.mollie.com/images/payscreen/methods/eps%402x.png" }, "_links": { "self": { "href": "https://api.mollie.com/v2/methods/eps", "type": "application/hal+json" } } }, { "resource": "method", "id": "giropay", "description": "Giropay", "image": { "size1x": "https://www.mollie.com/images/payscreen/methods/giropay.png", "size2x": "https://www.mollie.com/images/payscreen/methods/giropay%402x.png" }, "_links": { "self": { "href": "https://api.mollie.com/v2/methods/giropay", "type": "application/hal+json" } } }, { "resource": "method", "id": "kbc", "description": "KBC/CBC Payment Button", "image": { "size1x": "https://www.mollie.com/images/payscreen/methods/kbc.png", "size2x": "https://www.mollie.com/images/payscreen/methods/kbc%402x.png" }, "_links": { "self": { "href": "https://api.mollie.com/v2/methods/kbc", "type": "application/hal+json" } } }, { "resource": "method", "id": "belfius", "description": "Belfius Pay Button", "image": { "size1x": "https://www.mollie.com/images/payscreen/methods/belfius.png", "size2x": "https://www.mollie.com/images/payscreen/methods/belfius%402x.png" }, "_links": { "self": { "href": "https://api.mollie.com/v2/methods/belfius", "type": "application/hal+json" } } }, { "resource": "method", "id": "inghomepay", "description": "ING Home'Pay", "image": { "size1x": "https://www.mollie.com/images/payscreen/methods/inghomepay.png", "size2x": "https://www.mollie.com/images/payscreen/methods/inghomepay%402x.png" }, "_links": { "self": { "href": "https://api.mollie.com/v2/methods/inghomepay", "type": "application/hal+json" } } }, { "resource": "method", "id": "bitcoin", "description": "Bitcoin", "image": { "size1x": "https://www.mollie.com/images/payscreen/methods/bitcoin.png", "size2x": "https://www.mollie.com/images/payscreen/methods/bitcoin%402x.png" }, "_links": { "self": { "href": "https://api.mollie.com/v2/methods/bitcoin", "type": "application/hal+json" } } } ] }, "count": 12, "_links": { "documentation": { "href": "https://docs.mollie.com/reference/v2/methods-api/list-methods", "type": "text/html" }, "self": { "href": "https://api.mollie.nl/v2/methods", "type": "application/hal+json" } } } tests/Mock/RefundSuccess.txt 0000666 00000002212 15165345042 0012122 0 ustar 00 HTTP/1.1 201 Created Server: nginx/1.4.4 Date: Sun, 19 Jan 2014 11:41:55 GMT Content-Type: application/json; charset=utf-8 Content-Length: 344 Connection: keep-alive Access-Control-Allow-Credentials: true Access-Control-Allow-Methods: GET, POST, HEAD, OPTIONS, DELETE Access-Control-Max-Age: 300 Cache-Control: no-cache, no-store Strict-Transport-Security: max-age=31556926; includeSubDomains X-Whom: dc1-web-2 { "resource": "refund", "id": "re_4qqhO89gsT", "amount": { "currency": "EUR", "value": "5.95" }, "status": "pending", "createdAt": "2018-03-14T17:09:02.0Z", "description": "Order", "paymentId": "tr_WDqYK6vllg", "_links": { "self": { "href": "https://api.mollie.com/v2/payments/tr_WDqYK6vllg/refunds/re_4qqhO89gsT", "type": "application/hal+json" }, "payment": { "href": "https://api.mollie.com/v2/payments/tr_WDqYK6vllg", "type": "application/hal+json" }, "documentation": { "href": "https://docs.mollie.com/reference/v2/refunds-api/create-refund", "type": "text/html" } } } tests/Mock/CreateCustomerSuccess.txt 0000666 00000001104 15165345042 0013623 0 ustar 00 HTTP/1.1 201 Created Content-Type: application/hal+json; charset=utf-8 { "resource": "customer", "id": "cst_bSNBBJBzdG", "mode": "test", "name": "John Doe", "email": "john@doe.com", "locale": "nl_NL", "metadata": "Just some meta data.", "createdAt": "2018-07-19T12:58:47+00:00", "_links": { "self": { "href": "https://api.mollie.com/v2/customers/cst_6HUkmjwzBB", "type": "application/hal+json" }, "documentation": { "href": "https://docs.mollie.com/reference/v2/customers-api/create-customer", "type": "text/html" } } } tests/Mock/FetchCustomerFailure.txt 0000666 00000000475 15165345042 0013442 0 ustar 00 HTTP/1.1 404 Not Found Content-Type: application/hal+json; charset=utf-8 { "status": 404, "title": "Not Found", "detail": "No customer exists with token cst_6HUkmjwzBBa.", "_links": { "documentation": { "href": "https://docs.mollie.com/guides/handling-errors", "type": "text/html" } } } tests/Mock/CreateOrderSuccess.txt 0000666 00000012651 15165345042 0013106 0 ustar 00 HTTP/1.1 201 Created Content-Type: application/hal+json; charset=utf-8 { "resource": "order", "id": "ord_pbjz8x", "profileId": "pfl_URR55HPMGx", "method": "klarnapaylater", "amount": { "value": "1027.99", "currency": "EUR" }, "status": "created", "isCancelable": true, "metadata": { "order_id": "1337", "description": "Lego cars" }, "createdAt": "2018-08-02T09:29:56+00:00", "expiresAt": "2018-08-30T09:29:56+00:00", "mode": "test", "locale": "nl_NL", "billingAddress": { "organizationName": "Mollie B.V.", "streetAndNumber": "Keizersgracht 313", "city": "Amsterdam", "region": "Noord-Holland", "postalCode": "1234AB", "country": "NL", "title": "Dhr.", "givenName": "Piet", "familyName": "Mondriaan", "email": "piet@mondriaan.com", "phone": "+31309202070" }, "consumerDateOfBirth": "1958-01-31", "orderNumber": "1337", "shippingAddress": { "organizationName": "Mollie B.V.", "streetAndNumber": "Keizersgracht 313", "streetAdditional": "4th floor", "city": "Haarlem", "region": "Noord-Holland", "postalCode": "5678AB", "country": "NL", "title": "Mr.", "givenName": "Chuck", "familyName": "Norris", "email": "norris@chucknorrisfacts.net" }, "redirectUrl": "https://example.org/redirect", "webhookUrl": "https://example.org/webhook", "lines": [ { "resource": "orderline", "id": "odl_dgtxyl", "orderId": "ord_pbjz8x", "name": "LEGO 42083 Bugatti Chiron", "sku": "5702016116977", "type": "physical", "status": "created", "isCancelable": false, "quantity": 2, "quantityShipped": 0, "amountShipped": { "value": "0.00", "currency": "EUR" }, "quantityRefunded": 0, "amountRefunded": { "value": "0.00", "currency": "EUR" }, "quantityCanceled": 0, "amountCanceled": { "value": "0.00", "currency": "EUR" }, "shippableQuantity": 0, "refundableQuantity": 0, "cancelableQuantity": 0, "unitPrice": { "value": "399.00", "currency": "EUR" }, "vatRate": "21.00", "vatAmount": { "value": "121.14", "currency": "EUR" }, "discountAmount": { "value": "100.00", "currency": "EUR" }, "totalAmount": { "value": "698.00", "currency": "EUR" }, "createdAt": "2018-08-02T09:29:56+00:00", "_links": { "productUrl": { "href": "https://shop.lego.com/nl-NL/Bugatti-Chiron-42083", "type": "text/html" }, "imageUrl": { "href": "https://sh-s7-live-s.legocdn.com/is/image//LEGO/42083_alt1?$main$", "type": "text/html" } } }, { "resource": "orderline", "id": "odl_jp31jz", "orderId": "ord_pbjz8x", "name": "LEGO 42056 Porsche 911 GT3 RS", "sku": "5702015594028", "type": "physical", "status": "created", "isCancelable": false, "quantity": 1, "quantityShipped": 0, "amountShipped": { "value": "0.00", "currency": "EUR" }, "quantityRefunded": 0, "amountRefunded": { "value": "0.00", "currency": "EUR" }, "quantityCanceled": 0, "amountCanceled": { "value": "0.00", "currency": "EUR" }, "shippableQuantity": 0, "refundableQuantity": 0, "cancelableQuantity": 0, "unitPrice": { "value": "329.99", "currency": "EUR" }, "vatRate": "21.00", "vatAmount": { "value": "57.27", "currency": "EUR" }, "totalAmount": { "value": "329.99", "currency": "EUR" }, "createdAt": "2018-08-02T09:29:56+00:00", "_links": { "productUrl": { "href": "https://shop.lego.com/nl-NL/Porsche-911-GT3-RS-42056", "type": "text/html" }, "imageUrl": { "href": "https://sh-s7-live-s.legocdn.com/is/image/LEGO/42056?$PDPDefault$", "type": "text/html" } } } ], "_links": { "self": { "href": "https://api.mollie.com/v2/orders/ord_pbjz8x", "type": "application/hal+json" }, "checkout": { "href": "https://www.mollie.com/payscreen/order/checkout/pbjz8x", "type": "text/html" }, "documentation": { "href": "https://docs.mollie.com/reference/v2/orders-api/get-order", "type": "text/html" } } } tests/Mock/UpdateCustomerFailure.txt 0000666 00000000526 15165345042 0013630 0 ustar 00 HTTP/1.1 401 Unauthorized Request Content-Type: application/hal+json; charset=utf-8 { "status": 401, "title": "Unauthorized Request", "detail": "Missing authentication, or failed to authenticate", "_links": { "documentation": { "href": "https://docs.mollie.com/guides/authentication", "type": "text/html" } } } tests/Mock/FetchCustomerMandatesSuccess.txt 0000666 00000003710 15165345042 0015133 0 ustar 00 HTTP/1.1 200 OK Content-Type: application/hal+json; charset=utf-8 { "count": 5, "_embedded": { "mandates": [ { "resource": "mandate", "id": "mdt_AcQl5fdL4h", "mode": "test", "status": "valid", "method": "directdebit", "details": { "consumerName": "John Doe", "consumerAccount": "NL55INGB0000000000", "consumerBic": "INGBNL2A" }, "mandateReference": null, "signatureDate": "2018-05-07", "createdAt": "2018-05-07T10:49:08+00:00", "_links": { "self": { "href": "https://api.mollie.com/v2/customers/cst_8wmqcHMN4U/mandates/mdt_AcQl5fdL4h", "type": "application/hal+json" }, "customer": { "href": "https://api.mollie.com/v2/customers/cst_8wmqcHMN4U", "type": "application/hal+json" }, "documentation": { "href": "https://mollie.com/en/docs/reference/customers/create-mandate", "type": "text/html" } } }, { }, { }, { }, { } ] }, "_links": { "self": { "href": "https://api.mollie.com/v2/customers/cst_8wmqcHMN4U/mandates?limit=5", "type": "application/hal+json" }, "previous": null, "next": { "href": "https://api.mollie.com/v2/customers/cst_8wmqcHMN4U/mandates?from=mdt_AcQl5fdL4h&limit=5", "type": "application/hal+json" }, "documentation": { "href": "https://docs.mollie.com/reference/v2/mandates-api/revoke-mandate", "type": "text/html" } } } tests/Mock/FetchIssuersSuccess.txt 0000666 00000002624 15165345042 0013315 0 ustar 00 HTTP/1.1 200 OK Content-Type: application/hal+json; charset=utf-8 { "resource": "method", "id": "ideal", "description": "iDEAL", "image": { "size1x": "https://www.mollie.com/images/payscreen/methods/ideal.png", "size2x": "https://www.mollie.com/images/payscreen/methods/ideal%402x.png" }, "issuers": [ { "resource": "issuer", "id": "ideal_ABNANL2A", "name": "ABN AMRO", "image": { "size1x": "https://www.mollie.com/images/checkout/v2/ideal-issuer-icons/ABNANL2A.png", "size2x": "https://www.mollie.com/images/checkout/v2/ideal-issuer-icons/ABNANL2A.png" } }, { "resource": "issuer", "id": "ideal_ASNBNL21", "name": "ASN Bank", "image": { "size1x": "https://www.mollie.com/images/checkout/v2/ideal-issuer-icons/ASNBNL21.png", "size2x": "https://www.mollie.com/images/checkout/v2/ideal-issuer-icons/ASNBNL21.png" } } ], "_links": { "self": { "href": "https://api.mollie.com/v2/methods/ideal", "type": "application/hal+json" }, "documentation": { "href": "https://docs.mollie.com/reference/v2/methods-api/get-method", "type": "text/html" } } } tests/GatewayTest.php 0000666 00000014671 15165345042 0010702 0 ustar 00 <?php namespace Omnipay\Mollie\Test; use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\Mollie\Gateway; use Omnipay\Mollie\Message\Request\CancelOrderRequest; use Omnipay\Mollie\Message\Request\CompletePurchaseRequest; use Omnipay\Mollie\Message\Request\CreateCustomerMandateRequest; use Omnipay\Mollie\Message\Request\CreateCustomerRequest; use Omnipay\Mollie\Message\Request\FetchCustomerMandatesRequest; use Omnipay\Mollie\Message\Request\FetchCustomerRequest; use Omnipay\Mollie\Message\Request\FetchIssuersRequest; use Omnipay\Mollie\Message\Request\FetchPaymentMethodsRequest; use Omnipay\Mollie\Message\Request\FetchTransactionRequest; use Omnipay\Mollie\Message\Request\PurchaseRequest; use Omnipay\Mollie\Message\Request\RefundRequest; use Omnipay\Mollie\Message\Request\RevokeCustomerMandateRequest; use Omnipay\Mollie\Message\Request\UpdateCustomerRequest; use Omnipay\Tests\GatewayTestCase; /** * @SuppressWarnings(PHPMD.TooManyPublicMethods) */ class GatewayTest extends GatewayTestCase { /** * @var Gateway */ protected $gateway; public function setUp() { parent::setUp(); $this->gateway = new Gateway(); } public function testFetchIssuers() { $request = $this->gateway->fetchIssuers(); $this->assertInstanceOf(FetchIssuersRequest::class, $request); } public function testFetchPaymentMethods() { $request = $this->gateway->fetchPaymentMethods(); $this->assertInstanceOf(FetchPaymentMethodsRequest::class, $request); } /** * @throws InvalidRequestException */ public function testPurchase() { $request = $this->gateway->purchase(array('amount' => '10.00', 'currency' => 'EUR')); $this->assertInstanceOf(PurchaseRequest::class, $request); $this->assertSame('10.00', $request->getAmount()); $this->assertSame('EUR', $request->getCurrency()); } /** * @throws InvalidRequestException */ public function testPurchaseReturn() { $request = $this->gateway->completePurchase(array('amount' => '10.00', 'currency' => 'EUR')); $this->assertInstanceOf(CompletePurchaseRequest::class, $request); $this->assertSame('10.00', $request->getAmount()); $this->assertSame('EUR', $request->getCurrency()); } public function testRefund() { $request = $this->gateway->refund( array( 'apiKey' => 'key', 'transactionReference' => 'tr_Qzin4iTWrU', 'amount' => '10.00', 'currency' => 'EUR' ) ); $this->assertInstanceOf(RefundRequest::class, $request); $data = $request->getData(); $this->assertSame( [ 'value' => '10.00', 'currency' => 'EUR' ], $data['amount'] ); } /** * @expectedException \Omnipay\Common\Exception\InvalidRequestException */ public function testThatRefundDoesntWorkWithoutAmount() { $request = $this->gateway->refund( array( 'apiKey' => 'key', 'transactionReference' => 'tr_Qzin4iTWrU' ) ); $this->assertInstanceOf(RefundRequest::class, $request); $request->getData(); } public function testFetchTransaction() { $request = $this->gateway->fetchTransaction( array( 'apiKey' => 'key', 'transactionReference' => 'tr_Qzin4iTWrU', ) ); $this->assertInstanceOf(FetchTransactionRequest::class, $request); $data = $request->getData(); $this->assertSame('tr_Qzin4iTWrU', $data['id']); } public function testCreateCustomer() { $request = $this->gateway->createCustomer( array( 'description' => 'Test name', 'email' => 'test@example.com', 'metadata' => 'Something something something dark side.', 'locale' => 'nl_NL', ) ); $this->assertInstanceOf(CreateCustomerRequest::class, $request); } public function testUpdateCustomer() { $request = $this->gateway->updateCustomer( array( 'apiKey' => 'key', 'customerReference' => 'cst_bSNBBJBzdG', 'description' => 'Test name2', 'email' => 'test@example.com', 'metadata' => 'Something something something dark side.', 'locale' => 'nl_NL', ) ); $this->assertInstanceOf(UpdateCustomerRequest::class, $request); $data = $request->getData(); $this->assertSame('Test name2', $data['name']); } public function testFetchCustomer() { $request = $this->gateway->fetchCustomer( array( 'apiKey' => 'key', 'customerReference' => 'cst_bSNBBJBzdG', ) ); $this->assertInstanceOf(FetchCustomerRequest::class, $request); } public function testFetchCustomerMandates() { $request = $this->gateway->fetchCustomerMandates( array( 'apiKey' => 'key', 'customerReference' => 'cst_bSNBBJBzdG', ) ); $this->assertInstanceOf(FetchCustomerMandatesRequest::class, $request); } public function testRevokeCustomerMandate() { $request = $this->gateway->revokeCustomerMandate( array( 'apiKey' => "key", "customerReference" => "cst_bSNBBJBzdG", "mandateId" => "mdt_pWUnw6pkBN", ) ); $this->assertInstanceOf(RevokeCustomerMandateRequest::class, $request); } public function testCreateCustomerMandate() { $request = $this->gateway->createCustomerMandate( array( 'apiKey' => "mykey", 'consumerName' => "Customer A", 'consumerAccount' => "NL53INGB0000000000", "method" => "directdebit", 'customerReference' => 'cst_bSNBBJBzdG', 'mandateReference' => "YOUR-COMPANY-MD13804", ) ); $this->assertInstanceOf(CreateCustomerMandateRequest::class, $request); } public function testVoid() { $this->assertInstanceOf(CancelOrderRequest::class, $this->gateway->void()); } } LICENSE 0000666 00000002047 15165345042 0005565 0 ustar 00 Copyright (c) 2012-2013 Adrian Macneil Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
| ver. 1.4 |
Github
|
.
| PHP 5.4.45 | Generation time: 0 |
proxy
|
phpinfo
|
Settings