From 241b4b9a2b5e38bc73c977b0213e5951a1338721 Mon Sep 17 00:00:00 2001 From: Frank Verhoeven Date: Wed, 1 Jun 2022 16:38:30 +0200 Subject: [PATCH 1/3] feat: Allow enabling payment callbacks when creating an order Not every payment status change results in an order status change; thus a relevant payment status change may not be provided via the order webhook callback. With this change it will be (optionally) possible to enable callbacks for payment status changes in addition to order status changes. Moreover, it is possible to embed the payments in the response when creating an order. Payment status callbacks will provide a payment ID, thus this information has to be saved along with the order ID. --- .gitattributes | 9 + .github/workflows/run-tests.yml | 39 ---- .github/workflows/test.yaml | 42 ++++ composer.json | 22 +- phpcs.xml.dist | 13 +- phpunit.xml.dist | 25 +- psalm-baseline.xml | 228 +++++++++++++++++++ psalm.xml.dist | 5 + src/Message/Request/CreateOrderRequest.php | 126 +++++----- src/Message/Response/FetchOrderResponse.php | 20 ++ tests/Message/CreateOrderRequestTest.php | 42 +++- tests/Mock/CreateOrderWithPaymentSuccess.txt | 220 ++++++++++++++++++ 12 files changed, 660 insertions(+), 131 deletions(-) create mode 100644 .gitattributes delete mode 100644 .github/workflows/run-tests.yml create mode 100644 .github/workflows/test.yaml create mode 100644 psalm-baseline.xml create mode 100644 tests/Mock/CreateOrderWithPaymentSuccess.txt diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..27fae50 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,9 @@ +/.gitattributes export-ignore +/.github export-ignore +/.gitignore export-ignore +/CONTRIBUTING.md export-ignore +/phpcs.xml.dist export-ignore +/phpunit.xml.dist export-ignore +/psalm.xml.dist export-ignore +/README.md export-ignore +/tests export-ignore diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml deleted file mode 100644 index 4a0b3ba..0000000 --- a/.github/workflows/run-tests.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Test - -on: push - -jobs: - test: - runs-on: ubuntu-latest - - strategy: - matrix: - php: [ 8.0, 7.4, 7.2 ] - - name: PHP-${{ matrix.php }} - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - coverage: none - - - name: Cache Dependencies - uses: actions/cache@v2 - with: - path: ~/.composer/cache - key: php-${{ matrix.php}}-composer-${{ hashFiles('**/composer.json') }} - restore-keys: php-${{ matrix.php}}-composer- - - - name: Install Dependencies - run: composer install --no-interaction --no-ansi --no-progress - - - name: Coding Standard - run: vendor/bin/phpcs --exclude=SlevomatCodingStandard.TypeHints.ReturnTypeHint,SlevomatCodingStandard.TypeHints.DeclareStrictTypes,SlevomatCodingStandard.Operators.DisallowEqualOperators,SlevomatCodingStandard.TypeHints.ParameterTypeHint,Generic.Files.LineLength,SlevomatCodingStandard.Classes.SuperfluousTraitNaming,SlevomatCodingStandard.TypeHints.PropertyTypeHint,SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming,Squiz.Strings.DoubleQuoteUsage,Squiz.Commenting.FunctionComment - - - name: Execute Unit Tests - run: composer test diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..19315b2 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,42 @@ +name: Test + +on: push + +jobs: + setup: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: shivammathur/setup-php@v2 + with: + php-version: 8.1 + coverage: none + - uses: ramsey/composer-install@v2 + - id: set-php-versions + run: echo "::set-output name=php-versions::$(bin/devtools list:php-versions)" + - id: set-tools + run: echo "::set-output name=tools::$(bin/devtools list:enabled-tools)" + outputs: + php-versions: ${{ steps.set-php-versions.outputs.php-versions }} + tools: ${{ steps.set-tools.outputs.tools }} + + test: + needs: setup + runs-on: ubuntu-latest + strategy: + matrix: + php-version: ${{ fromJson(needs.setup.outputs.php-versions) }} + tool: ${{ fromJson(needs.setup.outputs.tools) }} + fail-fast: false + name: ${{ matrix.php-version }} - ${{ matrix.tool }} + steps: + - uses: actions/checkout@v3 + - uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + tools: cs2pr + - uses: ramsey/composer-install@v2 + - run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + - run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - run: bin/devtools ${{ matrix.tool }} --format=github diff --git a/composer.json b/composer.json index dcb9eca..61f2169 100755 --- a/composer.json +++ b/composer.json @@ -33,23 +33,19 @@ "psr-4": { "Omnipay\\Mollie\\Test\\": "tests/" } }, "require": { - "php": "^7.2|^8.0", + "php": "^8.1", "omnipay/common": "^3.1" }, "require-dev": { "omnipay/tests": "^4.1", - "vimeo/psalm": "^4.10", - "myonlinestore/coding-standard": "^3.1" + "vimeo/psalm": "^4.23", + "myonlinestore/coding-standard": "^3.1", + "myonlinestore/php-devtools": "^0.3.2" }, - "extra": { - "branch-alias": { - "dev-master": "5.4.x-dev" + "prefer-stable": true, + "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true } - }, - "scripts": { - "test": "phpunit", - "check-style": "phpcs -p --standard=PSR2 src/", - "fix-style": "phpcbf -p --standard=PSR2 src/" - }, - "prefer-stable": true + } } diff --git a/phpcs.xml.dist b/phpcs.xml.dist index d773b99..956405e 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -12,5 +12,16 @@ src tests - + + + + + + + + + + + + diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 126591a..ebfc2d2 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,25 +1,18 @@ - + + + src + + + ./tests/ - - - - src - - diff --git a/psalm-baseline.xml b/psalm-baseline.xml new file mode 100644 index 0000000..8d359c2 --- /dev/null +++ b/psalm-baseline.xml @@ -0,0 +1,228 @@ + + + + + $value + + + $this->createRequest(CancelOrderRequest::class, $parameters) + $this->createRequest(CreateCustomerMandateRequest::class, $parameters) + $this->createRequest(FetchCustomerMandatesRequest::class, $parameters) + $this->createRequest(FetchProfileRequest::class, $parameters) + $this->createRequest(RevokeCustomerMandateRequest::class, $parameters) + + + CancelOrderRequest + CreateCustomerMandateRequest + FetchCustomerMandatesRequest + FetchProfileRequest + RevokeCustomerMandateRequest + + + + + $key + $value + $value + $value + $value + $value + $value + $value + $value + $value + $value + $value + $value + $value + $value + $value + $value + $value + $value + $value + $value + $value + $value + $value + $value + $value + + + getAmountCanceled + getAmountRefunded + getAmountShipped + getCancelableQuantity + getCreatedAt + getDiscountAmount + getId + getImageUrl + getIsCancelable + getOrderId + getProductUrl + getQuantityCanceled + getQuantityRefunded + getQuantityShipped + getRefundableQuantity + getResource + getShippableQuantity + getSku + getStatus + getTotalAmount + getType + getUnitPrice + getVatAmount + getVatRate + setAmountCanceled + setAmountRefunded + setAmountShipped + setCancelableQuantity + setCreatedAt + setDiscountAmount + setId + setImageUrl + setIsCancelable + setOrderId + setProductUrl + setQuantityCanceled + setQuantityRefunded + setQuantityShipped + setRefundableQuantity + setResource + setShippableQuantity + setSku + setStatus + setTotalAmount + setType + setUnitPrice + setVatAmount + setVatRate + + + + + \is_array($item) + + + $response->getBody() + + + $value + + + $amount + + + createAmountObject + + + $items + + + + + $data + + + + + $data + + + + + $data + + + + + $data + + + + + $data + + + $card + $card + + + $card = $this->getCard() + + + + + $data + + + + + $data + + + + + $data + + + + + $data + + + + + $data + + + + + $sequenceType + + + $data + + + + + $data + + + + + $data + + + null !== $webhookUrl + + + + + $data + + + + + $data + + + $data + + + + + $data + + + + + ?array + + + $this->data['metadata']['transactionId'] ?? null + null + null + + + diff --git a/psalm.xml.dist b/psalm.xml.dist index 0a6f64d..4ddfe9b 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -1,5 +1,6 @@ + + + + diff --git a/src/Message/Request/CreateOrderRequest.php b/src/Message/Request/CreateOrderRequest.php index 0a0afc6..4371a40 100755 --- a/src/Message/Request/CreateOrderRequest.php +++ b/src/Message/Request/CreateOrderRequest.php @@ -1,13 +1,12 @@ |null */ - public function getMetadata() + public function getMetadata(): ?array { return $this->getParameter('metadata'); } /** - * @param array $value + * @param array $value * * @return $this */ - public function setMetadata(array $value) + public function setMetadata(array $value): static { return $this->setParameter('metadata', $value); } - /** - * @return string - */ - public function getLocale() + public function getLocale(): ?string { return $this->getParameter('locale'); } /** - * @param string $value - * * @return $this */ - public function setLocale($value) + public function setLocale(string $value): static { return $this->setParameter('locale', $value); } - /** - * @return string - */ - public function getOrderNumber() + public function getOrderNumber(): ?string { return $this->getParameter('orderNumber'); } /** - * @param string $value - * * @return $this */ - public function setOrderNumber($value) + public function setOrderNumber(string $value): static { return $this->setParameter('orderNumber', $value); } - /** - * @return string - */ - public function getBillingEmail() + public function getBillingEmail(): ?string { return $this->getParameter('billingEmail'); } /** - * @param string $value - * * @return $this */ - public function setBillingEmail($value) + public function setBillingEmail(string $value): static { return $this->setParameter('billingEmail', $value); } - /** - * @return string - */ - public function getCustomerReference() + public function getCustomerReference(): ?string { return $this->getParameter('customerReference'); } /** - * @param string $value - * * @return $this */ - public function setCustomerReference($value) + public function setCustomerReference(string $value): static { return $this->setParameter('customerReference', $value); } - /** - * @return string - */ - public function getSequenceType() + public function getSequenceType(): ?string { return $this->getParameter('sequenceType'); } /** - * @param string $value - * * @return $this */ - public function setSequenceType($value) + public function setSequenceType(string $value): static { return $this->setParameter('sequenceType', $value); } + public function hasIncludePayments(): bool + { + return (bool) $this->getParameter('includePayments'); + } + /** - * Alias for lines - * - * @param $items + * @return $this + */ + public function setIncludePayments(bool $includePayments = true): static + { + return $this->setParameter('includePayments', $includePayments); + } + + public function hasEnablePaymentWebhook(): bool + { + return (bool) $this->getParameter('enablePaymentWebhook'); + } + + /** + * Enable webhook callbacks for payment changes. By default, your webhook is + * only called for order changes. Note that a payment (transaction) ID will + * be provided instead of an order ID for payment callbacks. * * @return $this */ - public function setLines($items) + public function setEnablePaymentWebhook(bool $enablePaymentWebhook = true): static { - return $this->setItems($items); + return $this->setParameter('enablePaymentWebhook', $enablePaymentWebhook); } /** - * A list of items in this order + * Alias for lines * - * @return Item[]|null A bag containing items in this order + * @param array $items + * + * @return $this */ - public function getItems() + public function setLines(array $items): static { - return $this->getParameter('items'); + return $this->setItems($items); } /** - * @return array + * @return array * * @throws InvalidRequestException */ - public function getData() + public function getData(): array { $this->validate('apiKey', 'amount', 'locale', 'card', 'items', 'currency', 'orderNumber', 'returnUrl'); @@ -211,10 +205,17 @@ public function getData() $data['payment']['cardToken'] = $cardToken; } + if ($this->hasEnablePaymentWebhook()) { + $data['payment']['webhookUrl'] = $data['webhookUrl']; + } + return \array_filter($data); } - protected function getCardData(CreditCard $card) + /** + * @return array + */ + protected function getCardData(CreditCard $card): array { $data = []; @@ -253,7 +254,10 @@ protected function getCardData(CreditCard $card) return $data; } - protected function getLines(ItemBag $items) + /** + * @return list> + */ + protected function getLines(ItemBag $items): array { $lines = []; foreach ($items as $item) { @@ -291,13 +295,15 @@ protected function getLines(ItemBag $items) } /** - * @param array $data - * - * @return PurchaseResponse + * @param array $data */ - public function sendData($data) + public function sendData($data): CreateOrderResponse { - $response = $this->sendRequest(self::POST, '/orders', $data); + $response = $this->sendRequest( + self::POST, + '/orders' . ($this->hasIncludePayments() ? '?embed=payments' : ''), + $data + ); return $this->response = new CreateOrderResponse($this, $response); } diff --git a/src/Message/Response/FetchOrderResponse.php b/src/Message/Response/FetchOrderResponse.php index 14ab876..f27b8c7 100644 --- a/src/Message/Response/FetchOrderResponse.php +++ b/src/Message/Response/FetchOrderResponse.php @@ -33,4 +33,24 @@ public function getItems(): ?ItemBag return null; } + + /** + * Get the payments provided by enabling FetchOrderRequest::setIncludePayments() + * + * @return list + */ + public function getPayments(): array + { + if ( + !isset($this->data['_embedded']['payments']) + || !\is_array($this->data['_embedded']['payments']) + ) { + return []; + } + + return \array_map( + fn (array $payment): FetchTransactionResponse => new FetchTransactionResponse($this->request, $payment), + $this->data['_embedded']['payments'] + ); + } } diff --git a/tests/Message/CreateOrderRequestTest.php b/tests/Message/CreateOrderRequestTest.php index f9e54f3..3842614 100644 --- a/tests/Message/CreateOrderRequestTest.php +++ b/tests/Message/CreateOrderRequestTest.php @@ -6,14 +6,14 @@ use GuzzleHttp\Psr7\Request; use Omnipay\Mollie\Message\Request\CreateOrderRequest; use Omnipay\Mollie\Message\Response\CreateOrderResponse; +use Omnipay\Mollie\Message\Response\FetchTransactionResponse; use Omnipay\Tests\TestCase; final class CreateOrderRequestTest extends TestCase { use AssertRequestTrait; - /** @var CreateOrderRequest */ - protected $request; + protected CreateOrderRequest $request; public function setUp(): void { @@ -107,6 +107,7 @@ public function testGetAddressData(): void $data = $this->request->getData(); $shippingAddress = $data['shippingAddress']; + self::assertIsArray($shippingAddress); $this->assertSame('Mollie B.V.', $shippingAddress['organizationName']); $this->assertSame('Prinsengracht 313', $shippingAddress['streetAndNumber']); $this->assertSame('4th floor', $shippingAddress['streetAdditional']); @@ -120,6 +121,7 @@ public function testGetAddressData(): void $this->assertSame('norris@chucknorrisfacts.net', $shippingAddress['email']); $billingAddress = $data['billingAddress']; + self::assertIsArray($billingAddress); $this->assertSame('Mollie B.V.', $billingAddress['organizationName']); $this->assertSame('Keizersgracht 313', $billingAddress['streetAndNumber']); $this->assertSame('Amsterdam', $billingAddress['city']); @@ -137,9 +139,11 @@ public function testGetLines(): void { $data = $this->request->getData(); + self::assertIsArray($data['lines']); $this->assertCount(2, $data['lines']); $line = $data['lines'][0]; + self::assertIsArray($line); $this->assertSame('physical', $line['type']); $this->assertSame('5702016116977', $line['sku']); $this->assertSame('LEGO 42083 Bugatti Chiron', $line['name']); @@ -233,4 +237,38 @@ public function testSendFailure(): void $response->getMessage() ); } + + public function testSendWithPaymentEmbeddedSuccess(): void + { + self::assertFalse($this->request->hasIncludePayments()); + self::assertFalse($this->request->hasEnablePaymentWebhook()); + + $data = $this->request->getData(); + self::assertArrayNotHasKey('webhookUrl', $data['payment']); + + $this->request->setIncludePayments(); + $this->request->setEnablePaymentWebhook(); + + $data = $this->request->getData(); + + self::assertTrue($this->request->hasIncludePayments()); + self::assertTrue($this->request->hasEnablePaymentWebhook()); + self::assertArrayHasKey('webhookUrl', $data['payment']); + self::assertSame($data['payment']['webhookUrl'], $data['webhookUrl']); + + $this->setMockHttpResponse('CreateOrderWithPaymentSuccess.txt'); + $response = $this->request->send(); + + self::assertStringContainsString( + '?embed=payments', + (string) $this->getMockClient()->getLastRequest()->getUri() + ); + self::assertInstanceOf(CreateOrderResponse::class, $response); + self::assertFalse($response->isSuccessful()); + + $payments = $response->getPayments(); + + self::assertCount(1, $payments); + self::assertContainsOnlyInstancesOf(FetchTransactionResponse::class, $payments); + } } diff --git a/tests/Mock/CreateOrderWithPaymentSuccess.txt b/tests/Mock/CreateOrderWithPaymentSuccess.txt new file mode 100644 index 0000000..296386b --- /dev/null +++ b/tests/Mock/CreateOrderWithPaymentSuccess.txt @@ -0,0 +1,220 @@ +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" + } + } + } + ], + "_embedded": { + "payments": [ + { + "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" + } + } + } + ] + }, + "_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" + } + } +} From ff46a142d4ea0138073e818ae4bd0eef295b71ee Mon Sep 17 00:00:00 2001 From: Frank Verhoeven Date: Wed, 1 Jun 2022 16:48:28 +0200 Subject: [PATCH 2/3] fixup! feat: Allow enabling payment callbacks when creating an order --- .github/workflows/test.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 19315b2..9ae1699 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -13,9 +13,9 @@ jobs: coverage: none - uses: ramsey/composer-install@v2 - id: set-php-versions - run: echo "::set-output name=php-versions::$(bin/devtools list:php-versions)" + run: echo "::set-output name=php-versions::$(vendor/bin/devtools list:php-versions)" - id: set-tools - run: echo "::set-output name=tools::$(bin/devtools list:enabled-tools)" + run: echo "::set-output name=tools::$(vendor/bin/devtools list:enabled-tools)" outputs: php-versions: ${{ steps.set-php-versions.outputs.php-versions }} tools: ${{ steps.set-tools.outputs.tools }} @@ -39,4 +39,4 @@ jobs: - run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" - run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - - run: bin/devtools ${{ matrix.tool }} --format=github + - run: vendor/bin/devtools ${{ matrix.tool }} --format=github From db99ac2e660d2e873d9491b7b9301fa1d0bd3077 Mon Sep 17 00:00:00 2001 From: Frank Verhoeven Date: Wed, 1 Jun 2022 16:57:48 +0200 Subject: [PATCH 3/3] fixup! feat: Allow enabling payment callbacks when creating an order --- src/Message/Request/CompleteOrderRequest.php | 10 +++---- src/Message/Request/FetchOrderRequest.php | 31 ++++++++------------ 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/src/Message/Request/CompleteOrderRequest.php b/src/Message/Request/CompleteOrderRequest.php index 4ad118d..3556284 100755 --- a/src/Message/Request/CompleteOrderRequest.php +++ b/src/Message/Request/CompleteOrderRequest.php @@ -15,11 +15,11 @@ class CompleteOrderRequest extends FetchOrderRequest { /** - * @return array + * @return array * * @throws InvalidRequestException */ - public function getData() + public function getData(): array { $this->validate('apiKey'); @@ -38,11 +38,9 @@ public function getData() } /** - * @param array $data - * - * @return CompleteOrderResponse + * @param array $data */ - public function sendData($data) + public function sendData($data): CompleteOrderResponse { $response = $this->sendRequest(self::GET, '/orders/' . $data['id']); diff --git a/src/Message/Request/FetchOrderRequest.php b/src/Message/Request/FetchOrderRequest.php index 7d3ae49..18a5b28 100755 --- a/src/Message/Request/FetchOrderRequest.php +++ b/src/Message/Request/FetchOrderRequest.php @@ -15,11 +15,11 @@ class FetchOrderRequest extends AbstractMollieRequest { /** - * @return array + * @return array * * @throws InvalidRequestException */ - public function getData() + public function getData(): array { $this->validate('apiKey', 'transactionReference'); @@ -29,20 +29,23 @@ public function getData() return $data; } + public function hasIncludePayments(): bool + { + return (bool) $this->getParameter('includePayments'); + } + /** - * @return bool + * @return $this */ - public function hasIncludePayments() + public function setIncludePayments(bool $includePayments = true): static { - return (bool) $this->getParameter('includePayments'); + return $this->setParameter('includePayments', $includePayments); } /** - * @param array $data - * - * @return FetchOrderResponse + * @param array $data */ - public function sendData($data) + public function sendData($data): FetchOrderResponse { $response = $this->sendRequest( self::GET, @@ -55,14 +58,4 @@ public function sendData($data) return $this->response = new FetchOrderResponse($this, $response); } - - /** - * @param bool $includePayments - * - * @return self - */ - public function setIncludePayments($includePayments) - { - return $this->setParameter('includePayments', $includePayments); - } }