├── .coveralls.yml ├── .editorconfig ├── .github └── workflows │ └── test.yml ├── .gitignore ├── LICENSE ├── README.md ├── SECURITY.md ├── composer.json ├── examples ├── README.md ├── authorization │ └── 01-token.php ├── checkout │ └── 01-checkout-create.php ├── payment │ ├── 01-epayment-init.php │ ├── 02-epayment-get.php │ ├── 03-epayment-adjust-cancel.php │ └── 04-epayment-adjust-modify.php ├── recurring_payment │ ├── 01-recurring-payment-create.php │ ├── 01-recurring-payment-get.php │ ├── 02-recurring-payment-create-charge.php │ └── 02-recurring-payment-get-charge.php └── webhook │ ├── 01-webhook-get.php │ ├── 02-webhook-register.php │ └── 03-webhook-delete.php ├── phpcs.xml.dist ├── phpstan-baseline.neon ├── phpstan.neon ├── phpunit.xml.dist ├── src ├── Api │ ├── ApiBase.php │ ├── Authorization.php │ ├── AuthorizationInterface.php │ ├── UserInfo.php │ ├── UserInfoInterface.php │ ├── v1 │ │ ├── EPayment.php │ │ ├── EPaymentInterface.php │ │ ├── Webhook.php │ │ └── WebhookInterface.php │ └── v3 │ │ ├── Checkout.php │ │ ├── CheckoutInterface.php │ │ ├── RecurringPayment.php │ │ └── RecurringPaymentInterface.php ├── Authentication │ ├── TokenMemoryCacheStorage.php │ └── TokenStorageInterface.php ├── Client.php ├── ClientInterface.php ├── Endpoint.php ├── EndpointInterface.php ├── Exceptions │ ├── Api │ │ └── InvalidArgumentException.php │ ├── Authentication │ │ └── InvalidArgumentException.php │ ├── Client │ │ └── InvalidArgumentException.php │ └── VippsException.php ├── Model │ ├── Authorization │ │ └── ResponseGetToken.php │ ├── Checkout │ │ └── v3 │ │ │ ├── Aggregate.php │ │ │ ├── Amount.php │ │ │ ├── BillingDetails.php │ │ │ ├── Configuration.php │ │ │ ├── Countries.php │ │ │ ├── CreateCheckoutSessionRequest.php │ │ │ ├── CreateCheckoutSessionResponse.php │ │ │ ├── CustomConsent.php │ │ │ ├── ExternalPaymentMethod.php │ │ │ ├── GetCheckoutSessionResponse.php │ │ │ ├── HeltHjem.php │ │ │ ├── Integrations.php │ │ │ ├── Logistics.php │ │ │ ├── MerchantInfo.php │ │ │ ├── OrderBottomLine.php │ │ │ ├── OrderLine.php │ │ │ ├── OrderSummary.php │ │ │ ├── OtherLogisticsOption.php │ │ │ ├── PaymentSources.php │ │ │ ├── PickupPoint.php │ │ │ ├── PorterBuddy.php │ │ │ ├── PorterBuddyOrigin.php │ │ │ ├── PorterBuddyOriginAddress.php │ │ │ ├── PrefillCustomer.php │ │ │ ├── ShippingDetails.php │ │ │ ├── SubscriptionDetails.php │ │ │ ├── Transaction.php │ │ │ ├── UnitInfo.php │ │ │ ├── UserInfo.php │ │ │ └── WalletPaymentDetails.php │ ├── EPayment │ │ └── v1 │ │ │ ├── Aggregate.php │ │ │ ├── AirlineData.php │ │ │ ├── Amount.php │ │ │ ├── Barcode.php │ │ │ ├── BottomLine.php │ │ │ ├── CancelModificationRequest.php │ │ │ ├── CaptureModificationRequest.php │ │ │ ├── CreatePaymentRequest.php │ │ │ ├── CreatePaymentResponse.php │ │ │ ├── Customer.php │ │ │ ├── EventLog.php │ │ │ ├── GetPaymentResponse.php │ │ │ ├── IndustryData.php │ │ │ ├── OrderLine.php │ │ │ ├── PaymentAdjustResponse.php │ │ │ ├── PaymentMethod.php │ │ │ ├── PaymentMethodResponse.php │ │ │ ├── PaymentSources.php │ │ │ ├── Profile.php │ │ │ ├── ProfileResponse.php │ │ │ ├── QrFormat.php │ │ │ ├── Receipt.php │ │ │ ├── RefundModificationRequest.php │ │ │ ├── ShippingInfo.php │ │ │ └── UnitInfo.php │ ├── Error │ │ ├── AuthorizationError.php │ │ ├── ErrorInterface.php │ │ └── PaymentError.php │ ├── FromStringInterface.php │ ├── FromStringTrait.php │ ├── OrderStatus.php │ ├── RecurringPayment │ │ └── v3 │ │ │ ├── Agreement.php │ │ │ ├── AgreementInterval.php │ │ │ ├── CampaignRequest.php │ │ │ ├── Charge.php │ │ │ ├── ChargeHistory.php │ │ │ ├── InitialCharge.php │ │ │ ├── Interval.php │ │ │ ├── Pricing.php │ │ │ ├── RequestCaptureCharge.php │ │ │ ├── RequestCreateAgreement.php │ │ │ ├── RequestCreateCharge.php │ │ │ ├── RequestRefundCharge.php │ │ │ ├── RequestUpdateAgreement.php │ │ │ ├── ResponseCreateAgreement.php │ │ │ ├── ResponseCreateCharge.php │ │ │ ├── ResponseGetAgreement.php │ │ │ ├── ResponseGetCharge.php │ │ │ ├── Status.php │ │ │ ├── Summary.php │ │ │ └── TransactionType.php │ ├── SupportsSerializationInterface.php │ ├── ToStringInterface.php │ ├── ToStringTrait.php │ ├── UserInfo │ │ ├── AccountInfo.php │ │ ├── Address.php │ │ └── ResponseUserInfo.php │ └── Webhook │ │ └── v1 │ │ ├── GetWebhooksResponse.php │ │ ├── RegisterWebhookRequest.php │ │ ├── RegisterWebhookResponse.php │ │ └── Webhook.php └── Resource │ ├── Authorization │ └── GetToken.php │ ├── AuthorizedResourceBase.php │ ├── Checkout │ └── v3 │ │ ├── CreateCheckoutSession.php │ │ └── GetCheckoutSession.php │ ├── EPayment │ └── v1 │ │ ├── CancelPayment.php │ │ ├── CapturePayment.php │ │ ├── CreatePayment.php │ │ ├── GetPayment.php │ │ ├── GetPaymentEvents.php │ │ └── RefundPayment.php │ ├── HttpMethod.php │ ├── IdempotencyKeyFactory.php │ ├── PaymentResourceBase.php │ ├── PaymentsInterface.php │ ├── RecurringPayment │ └── v3 │ │ ├── CancelCharge.php │ │ ├── CaptureCharge.php │ │ ├── CreateAgreement.php │ │ ├── CreateCharge.php │ │ ├── GetAgreement.php │ │ ├── GetAgreements.php │ │ ├── GetCharge.php │ │ ├── GetCharges.php │ │ ├── RecurringPaymentResourceBase.php │ │ ├── RefundCharge.php │ │ └── UpdateAgreement.php │ ├── RequestIdFactory.php │ ├── ResourceBase.php │ ├── ResourceInterface.php │ ├── SerializableInterface.php │ ├── UserInfo │ └── UserInfo.php │ └── Webhook │ └── v1 │ ├── DeleteWebhook.php │ ├── GetWebhooks.php │ └── RegisterWebhook.php └── test ├── Integration ├── Api │ ├── AuthorizationTest.php │ └── RecurringPaymentsTest.php └── IntegrationTestBase.php └── Unit ├── Api └── ApiBaseTest.php ├── Authentication ├── TestTokenStorage.php └── TokenMemoryCacheStorageTest.php ├── ClientTest.php ├── EndpointTest.php ├── Exception └── VippsExceptionTest.php ├── Model ├── Authorization │ └── ResponseGetTokenTest.php ├── Error │ ├── AuthorizationErrorTest.php │ └── PaymentErrorTest.php └── ModelTestBase.php ├── Resource ├── Authorization │ └── GetTokenTest.php ├── AuthorizedResourceBaseTest.php ├── RequestIdFactoryTest.php ├── ResourceBaseTest.php └── ResourceTestBase.php └── VippsTest.php /.coveralls.yml: -------------------------------------------------------------------------------- 1 | coverage_clover: test/output/clover.xml 2 | json_path: test/output/coveralls-upload.json 3 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Drupal editor configuration normalization 2 | # @see http://editorconfig.org/ 3 | 4 | # This is the top-most .editorconfig file; do not search in parent directories. 5 | root = true 6 | 7 | # All files. 8 | [*] 9 | end_of_line = LF 10 | indent_style = space 11 | indent_size = 4 12 | charset = utf-8 13 | trim_trailing_whitespace = true 14 | insert_final_newline = true 15 | 16 | [composer.{json,lock}] 17 | indent_size = 4 18 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | on: 3 | push: 4 | branches: 5 | - 2.x 6 | - 3.x 7 | pull_request: 8 | branches: 9 | - 2.x 10 | - 3.x 11 | 12 | jobs: 13 | test: 14 | name: Run tests 15 | runs-on: 'ubuntu-20.04' 16 | env: 17 | PRIVATE_REPO_GITHUB: ${{ secrets.PRIVATE_REPO_GITHUB }} 18 | PRIVATE_USER_TOKEN_GITHUB: ${{ secrets.PRIVATE_USER_TOKEN_GITHUB }} 19 | strategy: 20 | fail-fast: false 21 | matrix: 22 | php-version: 23 | - "7.4" 24 | - "8.0" 25 | - "8.1" 26 | - "8.2" 27 | - "8.3" 28 | composer-version: 29 | - "2" 30 | steps: 31 | - name: Dump matrix context 32 | env: 33 | MATRIX_CONTEXT: ${{ toJSON(matrix) }} 34 | run: echo "$MATRIX_CONTEXT" 35 | 36 | - name: Checkout 37 | uses: actions/checkout@v2 38 | 39 | - name: Setup PHP 40 | uses: shivammathur/setup-php@v2 41 | with: 42 | php-version: ${{ matrix.php-version }} 43 | 44 | - name: Update composer 45 | run: composer --verbose self-update --${{ matrix.composer-version }} 46 | 47 | - name: Dump composer verson 48 | run: composer --version 49 | 50 | - name: Validate composer.json 51 | run: composer --verbose validate 52 | 53 | - name: Install dependencies 54 | run: composer --verbose install 55 | 56 | - name: Run tests 57 | run: composer test 58 | 59 | - name: Upload coverage to Codecov 60 | uses: codecov/codecov-action@v2 61 | with: 62 | token: ${{ secrets.CODECOV_TOKEN }} 63 | env_vars: PHP 64 | fail_ci_if_error: false 65 | files: ./test/output/clover.xml 66 | flags: unittests 67 | name: codecov 68 | verbose: true 69 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor/ 2 | /test/output 3 | .phpunit.result.cache 4 | /build 5 | .idea 6 | composer.lock 7 | /examples/config.yml 8 | *.p12 9 | *.pem 10 | *.crt 11 | *.key 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Jakub Piasecki 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Vipps PHP SDK 2 | ===================== 3 | [![Packagist](https://img.shields.io/packagist/v/zaporylie/vipps.svg?maxAge=3600)](https://packagist.org/packages/zaporylie/vipps) 4 | [![Packagist](https://img.shields.io/packagist/dt/zaporylie/vipps.svg?maxAge=3600)](https://packagist.org/packages/zaporylie/vipps) 5 | [![codecov](https://codecov.io/gh/zaporylie/php-vipps/branch/2.x/graph/badge.svg)](https://codecov.io/gh/zaporylie/php-vipps) 6 | [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/zaporylie/php-vipps/badges/quality-score.png?b=2.x)](https://scrutinizer-ci.com/g/zaporylie/php-vipps/?branch=2.x) 7 | [![Build status](https://github.com/zaporylie/php-vipps/actions/workflows/test.yml/badge.svg)](https://github.com/zaporylie/php-vipps/actions/workflows/test.yml) 8 | [![Donate](https://img.shields.io/badge/paypal-donate-yellow.svg)](https://www.paypal.com/paypalme/zaporylie/50) 9 | 10 | [Vipps](https://vipps.no) is a Norwegian payment service, used by more than 3 million people. 11 | Vipps was originally developed by DNB, but is now a separate company, which includes BankID and BankAxept. 12 | Vipps merged with MobilePay of Denmark and Finland in 2022 to form Vipps MobilePay 13 | 14 | ## Prerequisites 15 | 16 | Authorization is token-based and you can generate tokens yourself using Merchant Portal. 17 | 18 | ## Quick start 19 | 20 | Add Vipps SDK to your project using [Composer]. 21 | 22 | ```bash 23 | $ composer require zaporylie/vipps:^3.0 24 | ``` 25 | 26 | Vipps SDK uses [PSR-7] compliant http-message plugin system, hence before you require `zaporylie/vipps` you must 27 | add http client adapter of your choice, ex. `php-http/guzzle6-adapter` [(read more)](https://github.com/php-http/guzzle6-adapter). 28 | 29 | ## References 30 | - [SDK documentation] 31 | - [API documentation] 32 | - [Read more about Vipps on Wikipedia][Wikipedia] 33 | 34 | ## Author 35 | - [Jakub Piasecki](mailto:jakub@piaseccy.pl) - Development and maintenance 36 | 37 | ## Donate 38 | 39 | Do you like the library? Do you find it useful? Please donate so I can allocate some of my free time to maintain the 40 | project. 41 | 42 | [![Donate](https://img.shields.io/badge/paypal-donate-yellow.svg?longCache=true&style=for-the-badge)](https://www.paypal.com/paypalme/zaporylie/50) 43 | 44 | Default amount with the link above is 50 PLN but you can modify according to your will. 45 | 46 | If you want to support my work on this library in a different way please [contact me](mailto:jakub@piaseccy.pl). 47 | 48 | [Wikipedia]: https://en.wikipedia.org/wiki/Vipps "Wikipedia" 49 | [Documentation]: https://developer.vippsmobilepay.com/docs/APIs/ "Documentation" 50 | [Composer]: https://getcomposer.org/ "Composer" 51 | [PSR-7]: http://www.php-fig.org/psr/psr-7/ "PSR-7" 52 | [API documentation]: https://developer.vippsmobilepay.com/docs/APIs/ "API Documentation" 53 | [SDK documentation]: https://github.com/zaporylie/php-vipps/wiki 54 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | | Version | Supported | 6 | | ------- | ------------------ | 7 | | 2.x | :white_check_mark: | 8 | | 1.x | :x: | 9 | 10 | ## Reporting a Vulnerability 11 | 12 | If you spot any potential security vulnerability please contact me directly at jakub(at)piaseccy.pl rather than creating an issue. 13 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "zaporylie/vipps", 3 | "description": "PHP SDK for Vipps", 4 | "type": "library", 5 | "keywords": ["payment"], 6 | "require": { 7 | "php": "^7.4 || ^8.0", 8 | "psr/http-message": "^2", 9 | "psr/http-client-implementation": "^1.0", 10 | "php-http/message": "^1.6", 11 | "php-http/httplug": "^1.0 || ^2.0", 12 | "php-http/discovery": "^1.17", 13 | "eloquent/enumeration": "^5.1", 14 | "jms/serializer": "^1.8 || ^3.0", 15 | "doctrine/annotations": "^1.14 || ^2.0" 16 | }, 17 | "require-dev": { 18 | "guzzlehttp/guzzle": "^7", 19 | "php-http/guzzle7-adapter": "^1", 20 | "phpunit/phpunit": ">=5 <9", 21 | "symfony/yaml": "^2.0", 22 | "symfony/filesystem": "^3.1", 23 | "squizlabs/php_codesniffer": "^3.0", 24 | "phpstan/phpstan": "^1.8", 25 | "phpstan/phpstan-phpunit": "^1.1", 26 | "phpstan/phpstan-deprecation-rules": "^1.0", 27 | "editorconfig-checker/editorconfig-checker": "^10.4" 28 | }, 29 | "suggest": { 30 | "php-http/guzzle7-adapter": "Guzzle adapter" 31 | }, 32 | "license": "MIT", 33 | "authors": [ 34 | { 35 | "name": "Jakub Piasecki", 36 | "email": "jakub@piaseccy.pl" 37 | } 38 | ], 39 | "scripts": { 40 | "test": [ 41 | "composer test-style", 42 | "composer test-phpstan" 43 | ], 44 | "test-style": "./vendor/bin/phpcs -p", 45 | "fix-style": "./vendor/bin/phpcbf -p", 46 | "test-unit": "./vendor/bin/phpunit", 47 | "test-phpstan": "./vendor/bin/phpstan analyze" 48 | }, 49 | "autoload": { 50 | "psr-4": { "zaporylie\\Vipps\\": "src/" } 51 | }, 52 | "autoload-dev": { 53 | "psr-4": { "zaporylie\\Vipps\\Tests\\": "test/" } 54 | }, 55 | "config": { 56 | "allow-plugins": { 57 | "php-http/discovery": true 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | Test SDK with examples 2 | ========== 3 | 4 | You can test different features supported by this SDK by simply starting PHP server: 5 | 6 | ```bash 7 | $ php -S 0.0.0.0.8123 8 | ``` 9 | 10 | and visiting one of the php files in your browser, ex. http://127.0.0.1:8123/examples/authorization/01-token.php 11 | 12 | But before you start make sure to create a config file in the /examples directory, ie. 13 | 14 | ```bash 15 | $ touch examples/config.yml 16 | ``` 17 | 18 | and add required configuration 19 | 20 | ```bash 21 | mode: test 22 | client_id: 23 | client_secret: 24 | subscription_key: 25 | merchant_serial_number: 26 | ``` 27 | Happy testing! 28 | -------------------------------------------------------------------------------- /examples/authorization/01-token.php: -------------------------------------------------------------------------------- 1 | $http_client, 12 | 'vipps_system_name' => 'vipps_zaporylie_example', 13 | 'vipps_system_version' => \zaporylie\Vipps\Client::VERSION, 14 | ]); 15 | 16 | $authorization = new \zaporylie\Vipps\Api\Authorization($client); 17 | $result = $authorization->getToken($settings['client_secret']); 18 | echo '
';
19 |     var_dump($result);
20 |     echo '
'; 21 | 22 | } 23 | catch (\Exception $e) { 24 | var_dump($e->getMessage()); 25 | var_dump($e->getTraceAsString()); 26 | } 27 | 28 | ?> 29 | -------------------------------------------------------------------------------- /examples/payment/01-epayment-init.php: -------------------------------------------------------------------------------- 1 | $http_client, 12 | 'vipps_system_name' => 'vipps_zaporylie_example', 13 | 'vipps_system_version' => \zaporylie\Vipps\Client::VERSION, 14 | ]); 15 | 16 | $authorization = new \zaporylie\Vipps\Api\Authorization($client); 17 | $authorization->getToken($settings['client_secret']); 18 | $payment = new \zaporylie\Vipps\Api\v1\EPayment($client); 19 | $result = $payment->createPayment((new \zaporylie\Vipps\Model\EPayment\v1\CreatePaymentRequest()) 20 | ->setAmount((new \zaporylie\Vipps\Model\EPayment\v1\Amount())->setValue(1000)->setCurrency('NOK')) 21 | ->setPaymentMethod((new \zaporylie\Vipps\Model\EPayment\v1\PaymentMethod())->setType('WALLET')) 22 | ->setReference('test-12121212-5') 23 | ->setUserFlow('WEB_REDIRECT') 24 | ->setReturnUrl('https://eoncxehuh2o2qyq.m.pipedream.net') 25 | ->setMetadata(['order_id' => 1]), 'costam5'); 26 | echo '
';
27 |     var_dump($result);
28 |     echo '
'; 29 | 30 | } 31 | catch (\Exception $e) { 32 | var_dump($e->getMessage()); 33 | var_dump($e->getTraceAsString()); 34 | } 35 | 36 | ?> 37 | -------------------------------------------------------------------------------- /examples/payment/02-epayment-get.php: -------------------------------------------------------------------------------- 1 | [ 11 | 'Merchant-Serial-Number' => $settings['merchant_serial_number'], 12 | ]] 13 | ); 14 | $client = new \zaporylie\Vipps\Client($settings['client_id'], $settings['client_secret'], $settings['subscription_key'], $settings['merchant_serial_number'], [ 15 | 'http_client' => $http_client, 16 | 'vipps_system_name' => 'vipps_zaporylie_example', 17 | 'vipps_system_version' => \zaporylie\Vipps\Client::VERSION, 18 | ]); 19 | 20 | $authorization = new \zaporylie\Vipps\Api\Authorization($client); 21 | $authorization->getToken($settings['client_secret']); 22 | $payment = new \zaporylie\Vipps\Api\v1\EPayment($client); 23 | $result = $payment->getPayment('test-12121212-4'); 24 | echo '
';
25 |     var_dump($result);
26 |     echo '
'; 27 | $result = $payment->getPaymentEvents('test-12121212-4'); 28 | echo '
';
29 |     var_dump($result);
30 |     echo '
'; 31 | 32 | } 33 | catch (\Exception $e) { 34 | var_dump($e->getMessage()); 35 | var_dump($e->getTraceAsString()); 36 | } 37 | 38 | ?> 39 | -------------------------------------------------------------------------------- /examples/payment/03-epayment-adjust-cancel.php: -------------------------------------------------------------------------------- 1 | $http_client, 12 | 'vipps_system_name' => 'vipps_zaporylie_example', 13 | 'vipps_system_version' => \zaporylie\Vipps\Client::VERSION, 14 | ]); 15 | 16 | $authorization = new \zaporylie\Vipps\Api\Authorization($client); 17 | $authorization->getToken($settings['client_secret']); 18 | $payment = new \zaporylie\Vipps\Api\v1\EPayment($client); 19 | $result = $payment->cancelPayment('test-12121212-3', new \zaporylie\Vipps\Model\EPayment\v1\CancelModificationRequest(), 'costam'); 20 | echo '
';
21 |     var_dump($result);
22 |     echo '
'; 23 | 24 | } 25 | catch (\Exception $e) { 26 | var_dump($e->getMessage()); 27 | var_dump($e->getTraceAsString()); 28 | } 29 | 30 | ?> 31 | -------------------------------------------------------------------------------- /examples/payment/04-epayment-adjust-modify.php: -------------------------------------------------------------------------------- 1 | $http_client, 12 | 'vipps_system_name' => 'vipps_zaporylie_example', 13 | 'vipps_system_version' => \zaporylie\Vipps\Client::VERSION, 14 | ]); 15 | 16 | $authorization = new \zaporylie\Vipps\Api\Authorization($client); 17 | $authorization->getToken($settings['client_secret']); 18 | $payment = new \zaporylie\Vipps\Api\v1\EPayment($client); 19 | $result = $payment->capturePayment('test-12121212-3', (new \zaporylie\Vipps\Model\EPayment\v1\CaptureModificationRequest())->setModificationAmount((new \zaporylie\Vipps\Model\EPayment\v1\Amount())->setCurrency('NOK')->setValue(101)), 'costam3'); 20 | echo '
';
21 |     var_dump($result);
22 |     echo '
'; 23 | $result = $payment->refundPayment('test-12121212-3', (new \zaporylie\Vipps\Model\EPayment\v1\RefundModificationRequest())->setModificationAmount((new \zaporylie\Vipps\Model\EPayment\v1\Amount())->setCurrency('NOK')->setValue(100)), 'costam3'); 24 | echo '
';
25 |     var_dump($result);
26 |     echo '
'; 27 | 28 | } 29 | catch (\Exception $e) { 30 | var_dump($e->getMessage()); 31 | var_dump($e->getTraceAsString()); 32 | } 33 | 34 | ?> 35 | -------------------------------------------------------------------------------- /examples/recurring_payment/01-recurring-payment-create.php: -------------------------------------------------------------------------------- 1 | $http_client, 12 | 'vipps_system_name' => 'vipps_zaporylie_example', 13 | 'vipps_system_version' => \zaporylie\Vipps\Client::VERSION, 14 | ]); 15 | 16 | $authorization = new \zaporylie\Vipps\Api\Authorization($client); 17 | $authorization->getToken($settings['client_secret']); 18 | $payment = new \zaporylie\Vipps\Api\v3\RecurringPayment($client); 19 | $result = $payment->createAgreement((new \zaporylie\Vipps\Model\RecurringPayment\v3\RequestCreateAgreement()) 20 | ->setPricing((new \zaporylie\Vipps\Model\RecurringPayment\v3\Pricing()) 21 | ->setCurrency('NOK') 22 | ->setAmount(1000)) 23 | ->setMerchantRedirectUrl('https://eoncxehuh2o2qyq.m.pipedream.net') 24 | ->setMerchantAgreementUrl('https://eoncxehuh2o2qyq.m.pipedream.net') 25 | ->setProductName('Recurring Product that is being purchased')); 26 | echo '
';
27 |     var_dump($result);
28 |     echo '
'; 29 | 30 | } 31 | catch (\Exception $e) { 32 | echo '
';
33 |     var_dump($e->getMessage());
34 |     var_dump($e->getTraceAsString());
35 |     echo '
'; 36 | } 37 | 38 | ?> 39 | -------------------------------------------------------------------------------- /examples/recurring_payment/01-recurring-payment-get.php: -------------------------------------------------------------------------------- 1 | $http_client, 12 | 'vipps_system_name' => 'vipps_zaporylie_example', 13 | 'vipps_system_version' => \zaporylie\Vipps\Client::VERSION, 14 | ]); 15 | 16 | $authorization = new \zaporylie\Vipps\Api\Authorization($client); 17 | $authorization->getToken($settings['client_secret']); 18 | $payment = new \zaporylie\Vipps\Api\v3\RecurringPayment($client); 19 | $result = $payment->getAgreement('agr_KG6k3X3'); 20 | echo '
';
21 |     var_dump($result);
22 |     echo '
'; 23 | 24 | } 25 | catch (\Exception $e) { 26 | echo '
';
27 |     var_dump($e->getMessage());
28 |     var_dump($e->getTraceAsString());
29 |     echo '
'; 30 | } 31 | 32 | ?> 33 | -------------------------------------------------------------------------------- /examples/recurring_payment/02-recurring-payment-create-charge.php: -------------------------------------------------------------------------------- 1 | $http_client, 12 | 'vipps_system_name' => 'vipps_zaporylie_example', 13 | 'vipps_system_version' => \zaporylie\Vipps\Client::VERSION, 14 | ]); 15 | 16 | $authorization = new \zaporylie\Vipps\Api\Authorization($client); 17 | $authorization->getToken($settings['client_secret']); 18 | $payment = new \zaporylie\Vipps\Api\v3\RecurringPayment($client); 19 | $result = $payment->createCharge('agr_KG6k3X3', (new \zaporylie\Vipps\Model\RecurringPayment\v3\RequestCreateCharge()) 20 | ->setAmount(1000) 21 | ->setDescription('Ok, that worked') 22 | ->setDue(new DateTime('+1 day')) 23 | ->setTransactionType('DIRECT_CAPTURE')); 24 | echo '
';
25 |     var_dump($result);
26 |     echo '
'; 27 | $result = $payment->createCharge('agr_KG6k3X3', (new \zaporylie\Vipps\Model\RecurringPayment\v3\RequestCreateCharge()) 28 | ->setAmount(1100) 29 | ->setType('UNSCHEDULED') 30 | ->setDescription('Ok, that worked too') 31 | ->setTransactionType('DIRECT_CAPTURE')); 32 | echo '
';
33 |     var_dump($result);
34 |     echo '
'; 35 | 36 | } 37 | catch (\Exception $e) { 38 | echo '
';
39 |     var_dump($e->getMessage());
40 |     var_dump($e->getTraceAsString());
41 |     echo '
'; 42 | } 43 | 44 | ?> 45 | -------------------------------------------------------------------------------- /examples/recurring_payment/02-recurring-payment-get-charge.php: -------------------------------------------------------------------------------- 1 | $http_client, 12 | 'vipps_system_name' => 'vipps_zaporylie_example', 13 | 'vipps_system_version' => \zaporylie\Vipps\Client::VERSION, 14 | ]); 15 | 16 | $authorization = new \zaporylie\Vipps\Api\Authorization($client); 17 | $authorization->getToken($settings['client_secret']); 18 | $payment = new \zaporylie\Vipps\Api\v3\RecurringPayment($client); 19 | $result = $payment->getCharge('agr_KG6k3X3','chr-gTHPbNE'); 20 | echo '
';
21 |     var_dump($result);
22 |     echo '
'; 23 | 24 | } 25 | catch (\Exception $e) { 26 | echo '
';
27 |     var_dump($e->getMessage());
28 |     var_dump($e->getTraceAsString());
29 |     echo '
'; 30 | } 31 | 32 | ?> 33 | -------------------------------------------------------------------------------- /examples/webhook/01-webhook-get.php: -------------------------------------------------------------------------------- 1 | $http_client, 12 | 'vipps_system_name' => 'vipps_zaporylie_example', 13 | 'vipps_system_version' => \zaporylie\Vipps\Client::VERSION, 14 | ]); 15 | 16 | $authorization = new \zaporylie\Vipps\Api\Authorization($client); 17 | $authorization->getToken($settings['client_secret']); 18 | $payment = new \zaporylie\Vipps\Api\v1\Webhook($client); 19 | $result = $payment->getWebhooks(); 20 | echo '
';
21 |     var_dump($result);
22 |     echo '
'; 23 | 24 | } 25 | catch (\Exception $e) { 26 | var_dump($e->getMessage()); 27 | var_dump($e->getTraceAsString()); 28 | } 29 | 30 | ?> 31 | -------------------------------------------------------------------------------- /examples/webhook/02-webhook-register.php: -------------------------------------------------------------------------------- 1 | $http_client, 12 | 'vipps_system_name' => 'vipps_zaporylie_example', 13 | 'vipps_system_version' => \zaporylie\Vipps\Client::VERSION, 14 | ]); 15 | 16 | $authorization = new \zaporylie\Vipps\Api\Authorization($client); 17 | $authorization->getToken($settings['client_secret']); 18 | $payment = new \zaporylie\Vipps\Api\v1\Webhook($client); 19 | $request = new \zaporylie\Vipps\Model\Webhook\v1\RegisterWebhookRequest(); 20 | $request->setUrl("https://eoncxehuh2o2qyq.m.pipedream.net/"); 21 | $request->setEvents([ 22 | 'epayments.payment.authorized.v1', 23 | ]); 24 | $result = $payment->registerWebhook($request); 25 | echo '
';
26 |     var_dump($result);
27 |     echo '
'; 28 | 29 | } 30 | catch (\Exception $e) { 31 | var_dump($e->getMessage()); 32 | var_dump($e->getTraceAsString()); 33 | } 34 | 35 | ?> 36 | -------------------------------------------------------------------------------- /examples/webhook/03-webhook-delete.php: -------------------------------------------------------------------------------- 1 | $http_client, 12 | 'vipps_system_name' => 'vipps_zaporylie_example', 13 | 'vipps_system_version' => \zaporylie\Vipps\Client::VERSION, 14 | ]); 15 | 16 | $authorization = new \zaporylie\Vipps\Api\Authorization($client); 17 | $authorization->getToken($settings['client_secret']); 18 | $payment = new \zaporylie\Vipps\Api\v1\Webhook($client); 19 | $payment->deleteWebhook('1aaf0fde-afed-43c0-9af3-b876bba34e48'); 20 | echo 'ok'; 21 | 22 | } 23 | catch (\Exception $e) { 24 | var_dump($e->getMessage()); 25 | var_dump($e->getTraceAsString()); 26 | } 27 | 28 | ?> 29 | -------------------------------------------------------------------------------- /phpcs.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ./src 5 | ./test/Unit 6 | ./test/Integration 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /phpstan-baseline.neon: -------------------------------------------------------------------------------- 1 | parameters: 2 | ignoreErrors: 3 | - 4 | message: "#^Call to an undefined static method zaporylie\\\\Vipps\\\\Endpoint\\:\\:test\\(\\)\\.$#" 5 | count: 1 6 | path: src/Client.php 7 | 8 | - 9 | message: "#^Unsafe usage of new static\\(\\)\\.$#" 10 | count: 1 11 | path: src/Endpoint.php 12 | 13 | - 14 | message: "#^Unsafe usage of new static\\(\\)\\.$#" 15 | count: 2 16 | path: src/Exceptions/VippsException.php 17 | -------------------------------------------------------------------------------- /phpstan.neon: -------------------------------------------------------------------------------- 1 | parameters: 2 | level: 1 3 | paths: 4 | - src 5 | ignoreErrors: 6 | 7 | includes: 8 | - phpstan-baseline.neon 9 | - vendor/phpstan/phpstan-phpunit/extension.neon 10 | - vendor/phpstan/phpstan-deprecation-rules/rules.neon 11 | 12 | -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ./test/Unit 5 | 6 | 7 | ./test/Integration 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | ./ 19 | 20 | ./examples 21 | ./test 22 | ./vendor 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/Api/ApiBase.php: -------------------------------------------------------------------------------- 1 | client = $client; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Api/Authorization.php: -------------------------------------------------------------------------------- 1 | client); 20 | 21 | /** @var \zaporylie\Vipps\Model\Authorization\ResponseGetToken $response */ 22 | $response = $resource->call(); 23 | 24 | // Save token on Client for future use. 25 | $this->client->getTokenStorage()->set($response); 26 | 27 | return $response; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Api/AuthorizationInterface.php: -------------------------------------------------------------------------------- 1 | client, $sub); 22 | /** @var \zaporylie\Vipps\Model\UserInfo\ResponseUserInfo $response */ 23 | $response = $resource->call(); 24 | return $response; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Api/UserInfoInterface.php: -------------------------------------------------------------------------------- 1 | client, $request); 43 | return $resource->call(); 44 | } 45 | 46 | /** 47 | * {@inheritDoc} 48 | */ 49 | public function getWebhooks(): GetWebhooksResponse 50 | { 51 | $resource = new GetWebhooks($this->client); 52 | return $resource->call(); 53 | } 54 | 55 | /** 56 | * {@inheritDoc} 57 | */ 58 | public function deleteWebhook(string $reference): void 59 | { 60 | $resource = new DeleteWebhook($this->client, $reference); 61 | $resource->call(); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/Api/v1/WebhookInterface.php: -------------------------------------------------------------------------------- 1 | client, $request); 49 | return $resource->call(); 50 | } 51 | 52 | /** 53 | * {@inheritDoc} 54 | */ 55 | public function getCheckoutSession(string $reference): GetCheckoutSessionResponse 56 | { 57 | $resource = new GetCheckoutSession($this->client, $reference); 58 | return $resource->call(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/Api/v3/CheckoutInterface.php: -------------------------------------------------------------------------------- 1 | has()) { 27 | throw new InvalidArgumentException('Missing Token'); 28 | } 29 | return $this->token; 30 | } 31 | 32 | /** 33 | * {@inheritdoc} 34 | */ 35 | public function set(ResponseGetToken $token) 36 | { 37 | $this->token = $token; 38 | return $this; 39 | } 40 | 41 | /** 42 | * {@inheritdoc} 43 | */ 44 | public function has() 45 | { 46 | if (!($this->token instanceof ResponseGetToken)) { 47 | return false; 48 | } 49 | 50 | if ($this->token->getExpiresOn()->getTimestamp() < (new \DateTime())->getTimestamp()) { 51 | $this->delete(); 52 | return false; 53 | } 54 | 55 | return true; 56 | } 57 | 58 | /** 59 | * {@inheritdoc} 60 | */ 61 | public function delete() 62 | { 63 | $this->token = null; 64 | return $this; 65 | } 66 | 67 | /** 68 | * {@inheritdoc} 69 | */ 70 | public function clear() 71 | { 72 | $this->delete(); 73 | return $this; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/Authentication/TokenStorageInterface.php: -------------------------------------------------------------------------------- 1 | ") 36 | */ 37 | protected $expiresOn; 38 | 39 | /** 40 | * @var \DateTimeInterface 41 | * @Serializer\Type("DateTime<'U'>") 42 | */ 43 | protected $notBefore; 44 | 45 | /** 46 | * @var string 47 | * @Serializer\Type("string") 48 | */ 49 | protected $resource; 50 | 51 | /** 52 | * @var string 53 | * @Serializer\Type("string") 54 | */ 55 | protected $accessToken; 56 | 57 | /** 58 | * Gets accessToken value. 59 | * 60 | * @return string 61 | */ 62 | public function getAccessToken() 63 | { 64 | return $this->accessToken; 65 | } 66 | 67 | /** 68 | * Gets expiresIn value. 69 | * 70 | * @return int 71 | */ 72 | public function getExpiresIn() 73 | { 74 | return $this->expiresIn; 75 | } 76 | 77 | /** 78 | * Gets expiresOn value. 79 | * 80 | * @return \DateTimeInterface 81 | */ 82 | public function getExpiresOn() 83 | { 84 | return $this->expiresOn; 85 | } 86 | 87 | /** 88 | * Gets extExpiresIn value. 89 | * 90 | * @return int 91 | */ 92 | public function getExtExpiresIn() 93 | { 94 | return $this->extExpiresIn; 95 | } 96 | 97 | /** 98 | * Gets notBefore value. 99 | * 100 | * @return \DateTimeInterface 101 | */ 102 | public function getNotBefore() 103 | { 104 | return $this->notBefore; 105 | } 106 | 107 | /** 108 | * Gets resource value. 109 | * 110 | * @return string 111 | */ 112 | public function getResource() 113 | { 114 | return $this->resource; 115 | } 116 | 117 | /** 118 | * Gets tokenType value. 119 | * 120 | * @return string 121 | */ 122 | public function getTokenType() 123 | { 124 | return $this->tokenType; 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /src/Model/Checkout/v3/Amount.php: -------------------------------------------------------------------------------- 1 | currency; 30 | } 31 | 32 | /** 33 | * Gets value value. 34 | * 35 | * @return int 36 | */ 37 | public function getValue(): int 38 | { 39 | return $this->value; 40 | } 41 | 42 | /** 43 | * Sets currency variable. 44 | * 45 | * @param string $currency 46 | * 47 | * @return $this 48 | */ 49 | public function setCurrency(string $currency) 50 | { 51 | $this->currency = $currency; 52 | return $this; 53 | } 54 | 55 | /** 56 | * Sets value variable. 57 | * 58 | * @param int $value 59 | * 60 | * @return $this 61 | */ 62 | public function setValue(int $value) 63 | { 64 | $this->value = $value; 65 | return $this; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/Model/Checkout/v3/Countries.php: -------------------------------------------------------------------------------- 1 | supported = $supported; 26 | return $this; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Model/Checkout/v3/CreateCheckoutSessionResponse.php: -------------------------------------------------------------------------------- 1 | checkoutFrontendUrl; 36 | } 37 | 38 | /** 39 | * Gets poolingUrl value. 40 | * 41 | * @return string|null 42 | */ 43 | public function getPoolingUrl(): ?string 44 | { 45 | return $this->poolingUrl; 46 | } 47 | 48 | /** 49 | * Gets token value. 50 | * 51 | * @return string 52 | */ 53 | public function getToken(): string 54 | { 55 | return $this->token; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/Model/Checkout/v3/CustomConsent.php: -------------------------------------------------------------------------------- 1 | required = $required; 32 | return $this; 33 | } 34 | 35 | /** 36 | * Sets text variable. 37 | * 38 | * @param string $text 39 | * 40 | * @return $this 41 | */ 42 | public function setText(string $text) 43 | { 44 | $this->text = $text; 45 | return $this; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Model/Checkout/v3/ExternalPaymentMethod.php: -------------------------------------------------------------------------------- 1 | paymentMethod = $paymentMethod; 32 | return $this; 33 | } 34 | 35 | /** 36 | * Sets redirectUrl variable. 37 | * 38 | * @param string $redirectUrl 39 | * 40 | * @return $this 41 | */ 42 | public function setRedirectUrl(string $redirectUrl) 43 | { 44 | $this->redirectUrl = $redirectUrl; 45 | return $this; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Model/Checkout/v3/HeltHjem.php: -------------------------------------------------------------------------------- 1 | password = $password; 37 | return $this; 38 | } 39 | 40 | /** 41 | * Sets shopId variable. 42 | * 43 | * @param int $shopId 44 | * 45 | * @return $this 46 | */ 47 | public function setShopId(int $shopId) { 48 | $this->shopId = $shopId; 49 | return $this; 50 | } 51 | 52 | /** 53 | * Sets username variable. 54 | * 55 | * @param string $username 56 | * 57 | * @return $this 58 | */ 59 | public function setUsername(string $username) { 60 | $this->username = $username; 61 | return $this; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/Model/Checkout/v3/Integrations.php: -------------------------------------------------------------------------------- 1 | ") 19 | */ 20 | protected $fixedOptions; 21 | 22 | /** 23 | * @var \zaporylie\Vipps\Model\Checkout\v3\Integrations 24 | * @Serializer\Type("zaporylie\Vipps\Model\Checkout\v3\Integrations") 25 | */ 26 | protected $integrations; 27 | 28 | /** 29 | * Sets dynamicOptionsCallback variable. 30 | * 31 | * @param string $dynamicOptionsCallback 32 | * 33 | * @return $this 34 | */ 35 | public function setDynamicOptionsCallback(string $dynamicOptionsCallback) { 36 | $this->dynamicOptionsCallback = $dynamicOptionsCallback; 37 | return $this; 38 | } 39 | 40 | /** 41 | * Sets fixedOptions variable. 42 | * 43 | * @param \zaporylie\Vipps\Model\Checkout\v3\OtherLogisticsOption[] $fixedOptions 44 | * 45 | * @return $this 46 | */ 47 | public function setFixedOptions(array $fixedOptions) { 48 | $this->fixedOptions = $fixedOptions; 49 | return $this; 50 | } 51 | 52 | /** 53 | * Sets integrations variable. 54 | * 55 | * @param \zaporylie\Vipps\Model\Checkout\v3\Integrations $integrations 56 | * 57 | * @return $this 58 | */ 59 | public function setIntegrations(Integrations $integrations) { 60 | $this->integrations = $integrations; 61 | return $this; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/Model/Checkout/v3/MerchantInfo.php: -------------------------------------------------------------------------------- 1 | callbackAuthorizationToken = $callbackAuthorizationToken; 45 | return $this; 46 | } 47 | 48 | /** 49 | * Sets callbackUrl variable. 50 | * 51 | * @param string $callbackUrl 52 | * 53 | * @return $this 54 | */ 55 | public function setCallbackUrl(string $callbackUrl) 56 | { 57 | $this->callbackUrl = $callbackUrl; 58 | return $this; 59 | } 60 | 61 | /** 62 | * Sets returnUrl variable. 63 | * 64 | * @param string $returnUrl 65 | * 66 | * @return $this 67 | */ 68 | public function setReturnUrl(string $returnUrl) 69 | { 70 | $this->returnUrl = $returnUrl; 71 | return $this; 72 | } 73 | 74 | /** 75 | * Sets termsAndConditionsUrl variable. 76 | * 77 | * @param string $termsAndConditionsUrl 78 | * 79 | * @return $this 80 | */ 81 | public function setTermsAndConditionsUrl(string $termsAndConditionsUrl) 82 | { 83 | $this->termsAndConditionsUrl = $termsAndConditionsUrl; 84 | return $this; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/Model/Checkout/v3/OrderSummary.php: -------------------------------------------------------------------------------- 1 | ") 13 | */ 14 | protected $orderLines; 15 | 16 | /** 17 | * @var \zaporylie\Vipps\Model\Checkout\v3\OrderBottomLine 18 | * @Serializer\Type("zaporylie\Vipps\Model\Checkout\v3\OrderBottomLine") 19 | */ 20 | protected $orderBottomLine; 21 | 22 | /** 23 | * Sets orderBottomLine variable. 24 | * 25 | * @param \zaporylie\Vipps\Model\Checkout\v3\OrderBottomLine $orderBottomLine 26 | * 27 | * @return $this 28 | */ 29 | public function setOrderBottomLine(OrderBottomLine $orderBottomLine) 30 | { 31 | $this->orderBottomLine = $orderBottomLine; 32 | return $this; 33 | } 34 | 35 | /** 36 | * Sets orderLines variable. 37 | * 38 | * @param \zaporylie\Vipps\Model\Checkout\v3\OrderLine[] $orderLines 39 | * 40 | * @return $this 41 | */ 42 | public function setOrderLines(array $orderLines) 43 | { 44 | $this->orderLines = $orderLines; 45 | return $this; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Model/Checkout/v3/PaymentSources.php: -------------------------------------------------------------------------------- 1 | card = $card; 45 | return $this; 46 | } 47 | 48 | /** 49 | * Sets cash variable. 50 | * 51 | * @param int $cash 52 | * 53 | * @return $this 54 | */ 55 | public function setCash(int $cash) 56 | { 57 | $this->cash = $cash; 58 | return $this; 59 | } 60 | 61 | /** 62 | * Sets giftCard variable. 63 | * 64 | * @param int $giftCard 65 | * 66 | * @return $this 67 | */ 68 | public function setGiftCard(int $giftCard) 69 | { 70 | $this->giftCard = $giftCard; 71 | return $this; 72 | } 73 | 74 | /** 75 | * Sets voucher variable. 76 | * 77 | * @param int $voucher 78 | * 79 | * @return $this 80 | */ 81 | public function setVoucher(int $voucher) 82 | { 83 | $this->voucher = $voucher; 84 | return $this; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/Model/Checkout/v3/PickupPoint.php: -------------------------------------------------------------------------------- 1 | postalCode; 60 | } 61 | 62 | /** 63 | * Gets country value. 64 | * 65 | * @return string 66 | */ 67 | public function getCountry(): string 68 | { 69 | return $this->country; 70 | } 71 | 72 | /** 73 | * Gets city value. 74 | * 75 | * @return string 76 | */ 77 | public function getCity(): string 78 | { 79 | return $this->city; 80 | } 81 | 82 | /** 83 | * Gets id value. 84 | * 85 | * @return string 86 | */ 87 | public function getId(): string 88 | { 89 | return $this->id; 90 | } 91 | 92 | /** 93 | * Gets name value. 94 | * 95 | * @return int 96 | */ 97 | public function getName(): int 98 | { 99 | return $this->name; 100 | } 101 | 102 | /** 103 | * Gets address value. 104 | * 105 | * @return string 106 | */ 107 | public function getAddress(): string 108 | { 109 | return $this->address; 110 | } 111 | 112 | /** 113 | * Gets openingHours value. 114 | * 115 | * @return array 116 | */ 117 | public function getOpeningHours(): array 118 | { 119 | return $this->openingHours; 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /src/Model/Checkout/v3/PorterBuddy.php: -------------------------------------------------------------------------------- 1 | apiKey = $apiKey; 37 | return $this; 38 | } 39 | 40 | /** 41 | * Sets origin variable. 42 | * 43 | * @param \zaporylie\Vipps\Model\Checkout\v3\PorterBuddyOrigin $origin 44 | * 45 | * @return $this 46 | */ 47 | public function setOrigin(PorterBuddyOrigin $origin) { 48 | $this->origin = $origin; 49 | return $this; 50 | } 51 | 52 | /** 53 | * Sets publicToken variable. 54 | * 55 | * @param string $publicToken 56 | * 57 | * @return $this 58 | */ 59 | public function setPublicToken(string $publicToken) { 60 | $this->publicToken = $publicToken; 61 | return $this; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/Model/Checkout/v3/PorterBuddyOrigin.php: -------------------------------------------------------------------------------- 1 | name = $name; 43 | return $this; 44 | } 45 | 46 | /** 47 | * Sets email variable. 48 | * 49 | * @param string $email 50 | * 51 | * @return $this 52 | */ 53 | public function setEmail(string $email) { 54 | $this->email = $email; 55 | return $this; 56 | } 57 | 58 | /** 59 | * Sets phoneNumber variable. 60 | * 61 | * @param string $phoneNumber 62 | * 63 | * @return $this 64 | */ 65 | public function setPhoneNumber(string $phoneNumber) { 66 | $this->phoneNumber = $phoneNumber; 67 | return $this; 68 | } 69 | 70 | /** 71 | * Sets address variable. 72 | * 73 | * @param \zaporylie\Vipps\Model\Checkout\v3\PorterBuddyOriginAddress $address 74 | * 75 | * @return $this 76 | */ 77 | public function setAddress(PorterBuddyOriginAddress $address) { 78 | $this->address = $address; 79 | return $this; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/Model/Checkout/v3/PorterBuddyOriginAddress.php: -------------------------------------------------------------------------------- 1 | city = $city; 44 | return $this; 45 | } 46 | 47 | /** 48 | * Sets country variable. 49 | * 50 | * @param string $country 51 | * 52 | * @return $this 53 | */ 54 | public function setCountry(string $country) 55 | { 56 | $this->country = $country; 57 | return $this; 58 | } 59 | 60 | /** 61 | * Sets postalCode variable. 62 | * 63 | * @param string $postalCode 64 | * 65 | * @return $this 66 | */ 67 | public function setPostalCode(string $postalCode) 68 | { 69 | $this->postalCode = $postalCode; 70 | return $this; 71 | } 72 | 73 | /** 74 | * Sets streetAddress variable. 75 | * 76 | * @param string $streetAddress 77 | * 78 | * @return $this 79 | */ 80 | public function setStreetAddress(string $streetAddress) 81 | { 82 | $this->streetAddress = $streetAddress; 83 | return $this; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/Model/Checkout/v3/SubscriptionDetails.php: -------------------------------------------------------------------------------- 1 | agreementId = $agreementId; 32 | return $this; 33 | } 34 | 35 | /** 36 | * Sets state variable. 37 | * 38 | * @param string $state 39 | * 40 | * @return $this 41 | */ 42 | public function setState(string $state) 43 | { 44 | $this->state = $state; 45 | return $this; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Model/Checkout/v3/Transaction.php: -------------------------------------------------------------------------------- 1 | amount = $amount; 48 | return $this; 49 | } 50 | 51 | /** 52 | * Sets orderSummary variable. 53 | * 54 | * @param \zaporylie\Vipps\Model\Checkout\v3\OrderSummary $orderSummary 55 | * 56 | * @return $this 57 | */ 58 | public function setOrderSummary( 59 | \zaporylie\Vipps\Model\Checkout\v3\OrderSummary $orderSummary 60 | ) { 61 | $this->orderSummary = $orderSummary; 62 | return $this; 63 | } 64 | 65 | /** 66 | * Sets paymentDescription variable. 67 | * 68 | * @param string $paymentDescription 69 | * 70 | * @return $this 71 | */ 72 | public function setPaymentDescription(string $paymentDescription) 73 | { 74 | $this->paymentDescription = $paymentDescription; 75 | return $this; 76 | } 77 | 78 | /** 79 | * Sets reference variable. 80 | * 81 | * @param string $reference 82 | * 83 | * @return $this 84 | */ 85 | public function setReference(string $reference) 86 | { 87 | $this->reference = $reference; 88 | return $this; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/Model/Checkout/v3/UnitInfo.php: -------------------------------------------------------------------------------- 1 | quantity = $quantity; 38 | return $this; 39 | } 40 | 41 | /** 42 | * Sets quantityUnit variable. 43 | * 44 | * @param string $quantityUnit 45 | * 46 | * @return $this 47 | */ 48 | public function setQuantityUnit(string $quantityUnit) 49 | { 50 | $this->quantityUnit = $quantityUnit; 51 | return $this; 52 | } 53 | 54 | /** 55 | * Sets unitPrice variable. 56 | * 57 | * @param int $unitPrice 58 | * 59 | * @return $this 60 | */ 61 | public function setUnitPrice(int $unitPrice) 62 | { 63 | $this->unitPrice = $unitPrice; 64 | return $this; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Model/Checkout/v3/UserInfo.php: -------------------------------------------------------------------------------- 1 | sub; 30 | } 31 | 32 | /** 33 | * Gets email value. 34 | * 35 | * @return string 36 | */ 37 | public function getEmail(): string 38 | { 39 | return $this->email; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Model/Checkout/v3/WalletPaymentDetails.php: -------------------------------------------------------------------------------- 1 | amount; 42 | } 43 | 44 | /** 45 | * Gets state value. 46 | * 47 | * @return string 48 | */ 49 | public function getState(): string 50 | { 51 | return $this->state; 52 | } 53 | 54 | /** 55 | * Gets aggregate value. 56 | * 57 | * @return \zaporylie\Vipps\Model\Checkout\v3\Aggregate|null 58 | */ 59 | public function getAggregate(): ?Aggregate 60 | { 61 | return $this->aggregate; 62 | } 63 | 64 | /** 65 | * Gets type value. 66 | * 67 | * @return string 68 | */ 69 | public function getType(): string 70 | { 71 | return $this->type; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/Model/EPayment/v1/AirlineData.php: -------------------------------------------------------------------------------- 1 | currency; 30 | } 31 | 32 | /** 33 | * Gets value value. 34 | * 35 | * @return int 36 | */ 37 | public function getValue(): int 38 | { 39 | return $this->value; 40 | } 41 | 42 | /** 43 | * Sets currency variable. 44 | * 45 | * @param string $currency 46 | * 47 | * @return $this 48 | */ 49 | public function setCurrency(string $currency) 50 | { 51 | $this->currency = $currency; 52 | return $this; 53 | } 54 | 55 | /** 56 | * Sets value variable. 57 | * 58 | * @param int $value 59 | * 60 | * @return $this 61 | */ 62 | public function setValue(int $value) 63 | { 64 | $this->value = $value; 65 | return $this; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/Model/EPayment/v1/Barcode.php: -------------------------------------------------------------------------------- 1 | format = $format; 35 | return $this; 36 | } 37 | 38 | /** 39 | * Sets data variable. 40 | * 41 | * @param string|null $data 42 | * 43 | * @return $this 44 | */ 45 | public function setData(?string $data) 46 | { 47 | $this->data = $data; 48 | return $this; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/Model/EPayment/v1/CancelModificationRequest.php: -------------------------------------------------------------------------------- 1 | cancelTransactionOnly = $cancelTransactionOnly; 31 | return $this; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Model/EPayment/v1/CaptureModificationRequest.php: -------------------------------------------------------------------------------- 1 | modificationAmount = $modificationAmount; 30 | return $this; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Model/EPayment/v1/CreatePaymentResponse.php: -------------------------------------------------------------------------------- 1 | redirectUrl; 35 | } 36 | 37 | /** 38 | * Gets reference value. 39 | * 40 | * @return string 41 | */ 42 | public function getReference(): string 43 | { 44 | return $this->reference; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Model/EPayment/v1/Customer.php: -------------------------------------------------------------------------------- 1 | phoneNumber; 30 | } 31 | 32 | /** 33 | * Gets personalQr value. 34 | * 35 | * @return string 36 | */ 37 | public function getPersonalQr(): string 38 | { 39 | return $this->personalQr; 40 | } 41 | 42 | /** 43 | * Sets phoneNumber variable. 44 | * 45 | * @param string $phoneNumber 46 | * 47 | * @return $this 48 | */ 49 | public function setPhoneNumber(string $phoneNumber) 50 | { 51 | $this->phoneNumber = $phoneNumber; 52 | return $this; 53 | } 54 | 55 | /** 56 | * Sets personalQr variable. 57 | * 58 | * @param string $personalQr 59 | * 60 | * @return $this 61 | */ 62 | public function setPersonalQr(string $personalQr) 63 | { 64 | $this->personalQr = $personalQr; 65 | return $this; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/Model/EPayment/v1/IndustryData.php: -------------------------------------------------------------------------------- 1 | airlineData; 29 | } 30 | 31 | /** 32 | * Sets airlineData variable. 33 | * 34 | * @param \zaporylie\Vipps\Model\EPayment\v1\AirlineData $airlineData 35 | * 36 | * @return $this 37 | */ 38 | public function setAirlineData(AirlineData $airlineData): self 39 | { 40 | $this->airlineData = $airlineData; 41 | return $this; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Model/EPayment/v1/PaymentAdjustResponse.php: -------------------------------------------------------------------------------- 1 | aggregate; 52 | } 53 | 54 | /** 55 | * Gets amount value. 56 | * 57 | * @return \zaporylie\Vipps\Model\EPayment\v1\Amount 58 | */ 59 | public function getAmount(): Amount 60 | { 61 | return $this->amount; 62 | } 63 | 64 | /** 65 | * Gets pspReference value. 66 | * 67 | * @return string 68 | */ 69 | public function getPspReference(): string 70 | { 71 | return $this->pspReference; 72 | } 73 | 74 | /** 75 | * Gets reference value. 76 | * 77 | * @return string 78 | */ 79 | public function getReference(): string 80 | { 81 | return $this->reference; 82 | } 83 | 84 | /** 85 | * Gets state value. 86 | * 87 | * @return string 88 | */ 89 | public function getState(): string 90 | { 91 | return $this->state; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/Model/EPayment/v1/PaymentMethod.php: -------------------------------------------------------------------------------- 1 | type; 30 | } 31 | 32 | /** 33 | * Sets type variable. 34 | * 35 | * @param string $type 36 | * 37 | * @return $this 38 | */ 39 | public function setType(string $type): self 40 | { 41 | assert(in_array($type, ['WALLET', 'CARD'])); 42 | $this->type = $type; 43 | return $this; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Model/EPayment/v1/PaymentMethodResponse.php: -------------------------------------------------------------------------------- 1 | type; 34 | } 35 | 36 | /** 37 | * Gets cardBin value. 38 | * 39 | * @return string 40 | */ 41 | public function getCardBin(): string 42 | { 43 | return $this->cardBin; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Model/EPayment/v1/PaymentSources.php: -------------------------------------------------------------------------------- 1 | giftCard; 45 | } 46 | 47 | /** 48 | * Gets card value. 49 | * 50 | * @return int 51 | */ 52 | public function getCard(): int 53 | { 54 | return $this->card; 55 | } 56 | 57 | /** 58 | * Gets voucher value. 59 | * 60 | * @return int 61 | */ 62 | public function getVoucher(): int 63 | { 64 | return $this->voucher; 65 | } 66 | 67 | /** 68 | * Gets cash value. 69 | * 70 | * @return int 71 | */ 72 | public function getCash(): int 73 | { 74 | return $this->cash; 75 | } 76 | 77 | /** 78 | * Sets giftCard variable. 79 | * 80 | * @param int $giftCard 81 | * 82 | * @return $this 83 | */ 84 | public function setGiftCard(int $giftCard) 85 | { 86 | $this->giftCard = $giftCard; 87 | return $this; 88 | } 89 | 90 | /** 91 | * Sets card variable. 92 | * 93 | * @param int $card 94 | * 95 | * @return $this 96 | */ 97 | public function setCard(int $card) 98 | { 99 | $this->card = $card; 100 | return $this; 101 | } 102 | 103 | /** 104 | * Sets voucher variable. 105 | * 106 | * @param int $voucher 107 | * 108 | * @return $this 109 | */ 110 | public function setVoucher(int $voucher) 111 | { 112 | $this->voucher = $voucher; 113 | return $this; 114 | } 115 | 116 | /** 117 | * Sets cash variable. 118 | * 119 | * @param int $cash 120 | * 121 | * @return $this 122 | */ 123 | public function setCash(int $cash) 124 | { 125 | $this->cash = $cash; 126 | return $this; 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /src/Model/EPayment/v1/Profile.php: -------------------------------------------------------------------------------- 1 | scope; 28 | } 29 | 30 | /** 31 | * Sets scope variable. 32 | * 33 | * @param string $scope 34 | * 35 | * @return $this 36 | */ 37 | public function setScope(string $scope) 38 | { 39 | $this->scope = $scope; 40 | return $this; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Model/EPayment/v1/ProfileResponse.php: -------------------------------------------------------------------------------- 1 | sub; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Model/EPayment/v1/QrFormat.php: -------------------------------------------------------------------------------- 1 | format; 36 | } 37 | 38 | /** 39 | * Gets size value. 40 | * 41 | * @return int|null 42 | */ 43 | public function getSize(): ?int 44 | { 45 | return $this->size; 46 | } 47 | 48 | /** 49 | * Sets format variable. 50 | * 51 | * @param string $format 52 | * 53 | * @return $this 54 | */ 55 | public function setFormat(string $format) 56 | { 57 | $this->format = $format; 58 | return $this; 59 | } 60 | 61 | /** 62 | * Sets size variable. 63 | * 64 | * @param int|null $size 65 | * 66 | * @return $this 67 | */ 68 | public function setSize(?int $size) 69 | { 70 | $this->size = $size; 71 | return $this; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/Model/EPayment/v1/Receipt.php: -------------------------------------------------------------------------------- 1 | ") 18 | */ 19 | protected $orderLines; 20 | 21 | /** 22 | * @var \zaporylie\Vipps\Model\EPayment\v1\BottomLine 23 | * @Serializer\Type("zaporylie\Vipps\Model\EPayment\v1\BottomLine") 24 | */ 25 | protected $bottomLine; 26 | } 27 | -------------------------------------------------------------------------------- /src/Model/EPayment/v1/RefundModificationRequest.php: -------------------------------------------------------------------------------- 1 | modificationAmount = $modificationAmount; 30 | return $this; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Model/EPayment/v1/ShippingInfo.php: -------------------------------------------------------------------------------- 1 | amount; 45 | } 46 | 47 | /** 48 | * Gets amountExcludingTax value. 49 | * 50 | * @return int|null 51 | */ 52 | public function getAmountExcludingTax(): ?int 53 | { 54 | return $this->amountExcludingTax; 55 | } 56 | 57 | /** 58 | * Gets taxAmount value. 59 | * 60 | * @return int|null 61 | */ 62 | public function getTaxAmount(): ?int 63 | { 64 | return $this->taxAmount; 65 | } 66 | 67 | /** 68 | * Gets taxPercentage value. 69 | * 70 | * @return int|null 71 | */ 72 | public function getTaxPercentage(): ?int 73 | { 74 | return $this->taxPercentage; 75 | } 76 | 77 | /** 78 | * Sets amount variable. 79 | * 80 | * @param int|null $amount 81 | * 82 | * @return $this 83 | */ 84 | public function setAmount(?int $amount) 85 | { 86 | $this->amount = $amount; 87 | return $this; 88 | } 89 | 90 | /** 91 | * Sets amountExcludingTax variable. 92 | * 93 | * @param int|null $amountExcludingTax 94 | * 95 | * @return $this 96 | */ 97 | public function setAmountExcludingTax(?int $amountExcludingTax) 98 | { 99 | $this->amountExcludingTax = $amountExcludingTax; 100 | return $this; 101 | } 102 | 103 | /** 104 | * Sets taxAmount variable. 105 | * 106 | * @param int|null $taxAmount 107 | * 108 | * @return $this 109 | */ 110 | public function setTaxAmount(?int $taxAmount) 111 | { 112 | $this->taxAmount = $taxAmount; 113 | return $this; 114 | } 115 | 116 | /** 117 | * Sets taxPercentage variable. 118 | * 119 | * @param int|null $taxPercentage 120 | * 121 | * @return $this 122 | */ 123 | public function setTaxPercentage(?int $taxPercentage) 124 | { 125 | $this->taxPercentage = $taxPercentage; 126 | return $this; 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /src/Model/EPayment/v1/UnitInfo.php: -------------------------------------------------------------------------------- 1 | unitPrice; 45 | } 46 | 47 | /** 48 | * Gets quantity value. 49 | * 50 | * @return string 51 | */ 52 | public function getQuantity(): string 53 | { 54 | return $this->quantity; 55 | } 56 | 57 | /** 58 | * Gets quantityUnit value. 59 | * 60 | * @return string 61 | */ 62 | public function getQuantityUnit(): string 63 | { 64 | return $this->quantityUnit; 65 | } 66 | 67 | /** 68 | * Sets unitPrice variable. 69 | * 70 | * @param int|null $unitPrice 71 | * 72 | * @return $this 73 | */ 74 | public function setUnitPrice(?int $unitPrice) 75 | { 76 | $this->unitPrice = $unitPrice; 77 | return $this; 78 | } 79 | 80 | /** 81 | * Sets quantity variable. 82 | * 83 | * @param string $quantity 84 | * 85 | * @return $this 86 | */ 87 | public function setQuantity(string $quantity) 88 | { 89 | // Less equal 10 characters and marches regex pattern "^\d+([\.]\d{1,8})?$". 90 | if (strlen($quantity) > 10 || !preg_match('/^\d+([\.]\d{1,8})?$/', $quantity)) { 91 | throw new \InvalidArgumentException( 92 | 'Quantity must be less equal 10 characters and marches regex pattern "^\d+([\.]\d{1,8})?$".' 93 | ); 94 | } 95 | $this->quantity = $quantity; 96 | return $this; 97 | } 98 | 99 | /** 100 | * Sets quantityUnit variable. 101 | * 102 | * @param string $quantityUnit 103 | * 104 | * @return $this 105 | */ 106 | public function setQuantityUnit(string $quantityUnit) 107 | { 108 | assert(in_array($quantityUnit, [ 109 | 'PCS', 110 | 'KG', 111 | 'KM', 112 | 'MINUTE', 113 | 'LITRE', 114 | 'KWH', 115 | ]), 'Quantity unit must be one of PCS, KG, KM, MINUTE, LITRE, KWH.'); 116 | $this->quantityUnit = $quantityUnit; 117 | return $this; 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /src/Model/Error/AuthorizationError.php: -------------------------------------------------------------------------------- 1 | ") 31 | */ 32 | protected $timestamp; 33 | 34 | /** 35 | * @var string 36 | * @Serializer\Type("string") 37 | */ 38 | protected $traceId; 39 | 40 | /** 41 | * @var string 42 | * @Serializer\Type("string") 43 | */ 44 | protected $correlationId; 45 | 46 | /** 47 | * Gets error value. 48 | * 49 | * @return string 50 | */ 51 | public function getError() 52 | { 53 | return $this->error; 54 | } 55 | 56 | /** 57 | * Gets errorDescription value. 58 | * 59 | * @return string 60 | */ 61 | public function getErrorDescription() 62 | { 63 | return $this->errorDescription; 64 | } 65 | 66 | /** 67 | * Gets errorCodes value. 68 | * 69 | * @return array 70 | */ 71 | public function getErrorCodes() 72 | { 73 | return $this->errorCodes; 74 | } 75 | 76 | /** 77 | * Gets timestamp value. 78 | * 79 | * @return \DateTimeInterface 80 | */ 81 | public function getTimestamp() 82 | { 83 | return $this->timestamp; 84 | } 85 | 86 | /** 87 | * Gets traceId value. 88 | * 89 | * @return string 90 | */ 91 | public function getTraceId() 92 | { 93 | return $this->traceId; 94 | } 95 | 96 | /** 97 | * Gets correlationId value. 98 | * 99 | * @return string 100 | */ 101 | public function getCorrelationId() 102 | { 103 | return $this->correlationId; 104 | } 105 | 106 | /** 107 | * {@inheritdoc} 108 | */ 109 | public function getCode() 110 | { 111 | return implode(',', $this->getErrorCodes()); 112 | } 113 | 114 | /** 115 | * {@inheritdoc} 116 | */ 117 | public function getMessage() 118 | { 119 | return $this->getErrorDescription(); 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /src/Model/Error/ErrorInterface.php: -------------------------------------------------------------------------------- 1 | errorCode; 38 | } 39 | 40 | /** 41 | * Gets errorGroup value. 42 | * 43 | * @return string 44 | */ 45 | public function getErrorGroup() 46 | { 47 | return $this->errorGroup; 48 | } 49 | 50 | /** 51 | * Gets errorMessage value. 52 | * 53 | * @return string 54 | */ 55 | public function getErrorMessage() 56 | { 57 | return $this->errorMessage; 58 | } 59 | 60 | /** 61 | * {@inheritdoc} 62 | */ 63 | public function getCode() 64 | { 65 | return $this->getErrorCode(); 66 | } 67 | 68 | /** 69 | * {@inheritdoc} 70 | */ 71 | public function getMessage() 72 | { 73 | return $this->getErrorMessage(); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/Model/FromStringInterface.php: -------------------------------------------------------------------------------- 1 | deserialize( 24 | $string, 25 | static::class, 26 | 'json' 27 | ); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Model/OrderStatus.php: -------------------------------------------------------------------------------- 1 | unit; 43 | } 44 | 45 | /** 46 | * Gets count value. 47 | * 48 | * @return int 49 | */ 50 | public function getCount(): int 51 | { 52 | return $this->count; 53 | } 54 | 55 | /** 56 | * Gets text value. 57 | * 58 | * @return string 59 | */ 60 | public function getText(): string 61 | { 62 | return $this->text; 63 | } 64 | 65 | /** 66 | * Sets unit variable. 67 | * 68 | * @param string $unit 69 | * 70 | * @return $this 71 | */ 72 | public function setUnit(string $unit) 73 | { 74 | $this->unit = $unit; 75 | return $this; 76 | } 77 | 78 | /** 79 | * Sets count variable. 80 | * 81 | * @param int $count 82 | * 83 | * @return $this 84 | */ 85 | public function setCount(int $count) 86 | { 87 | $this->count = $count; 88 | return $this; 89 | } 90 | 91 | /** 92 | * Sets text variable. 93 | * 94 | * @param string $text 95 | * 96 | * @return $this 97 | */ 98 | public function setText(string $text) 99 | { 100 | $this->text = $text; 101 | return $this; 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/Model/RecurringPayment/v3/CampaignRequest.php: -------------------------------------------------------------------------------- 1 | ") 29 | */ 30 | protected $end; 31 | 32 | /** 33 | * Get the value of end 34 | * 35 | * @return \DateTimeInterface 36 | */ 37 | public function getEnd(): \DateTimeInterface 38 | { 39 | return $this->end; 40 | } 41 | 42 | /** 43 | * Set the value of end 44 | * 45 | * @param \DateTimeInterface $end 46 | * 47 | * @return self 48 | */ 49 | public function setEnd(\DateTimeInterface $end) 50 | { 51 | $this->end = $end; 52 | 53 | return $this; 54 | } 55 | 56 | /** 57 | * Gets price value. 58 | * 59 | * @return int 60 | */ 61 | public function getPrice(): int 62 | { 63 | return $this->price; 64 | } 65 | 66 | /** 67 | * Sets price variable. 68 | * 69 | * @param int $price 70 | * 71 | * @return $this 72 | */ 73 | public function setPrice(int $price) 74 | { 75 | $this->price = $price; 76 | return $this; 77 | } 78 | 79 | /** 80 | * Gets type value. 81 | * 82 | * @return string 83 | */ 84 | public function getType(): string 85 | { 86 | return $this->type; 87 | } 88 | 89 | /** 90 | * Sets type variable. 91 | * 92 | * @param string $type 93 | * 94 | * @return $this 95 | */ 96 | public function setType(string $type) 97 | { 98 | $this->type = $type; 99 | return $this; 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /src/Model/RecurringPayment/v3/ChargeHistory.php: -------------------------------------------------------------------------------- 1 | ") 18 | */ 19 | protected $occurred; 20 | 21 | /** 22 | * @var string 23 | * @Serializer\Type("string") 24 | */ 25 | protected $event; 26 | 27 | /** 28 | * @var int 29 | * @Serializer\Type("integer") 30 | */ 31 | protected $amount; 32 | 33 | /** 34 | * @var string 35 | * @Serializer\Type("string") 36 | */ 37 | protected $idempotencyKey; 38 | 39 | /** 40 | * @var bool 41 | * @Serializer\Type("boolean") 42 | */ 43 | protected $success; 44 | 45 | /** 46 | * Gets occurred value. 47 | * 48 | * @return \DateTimeInterface 49 | */ 50 | public function getOccurred(): \DateTimeInterface 51 | { 52 | return $this->occurred; 53 | } 54 | 55 | /** 56 | * Gets event value. 57 | * 58 | * @return string 59 | */ 60 | public function getEvent(): string 61 | { 62 | return $this->event; 63 | } 64 | 65 | /** 66 | * Gets amount value. 67 | * 68 | * @return int 69 | */ 70 | public function getAmount(): int 71 | { 72 | return $this->amount; 73 | } 74 | 75 | /** 76 | * Gets idempotencyKey value. 77 | * 78 | * @return string 79 | */ 80 | public function getIdempotencyKey(): string 81 | { 82 | return $this->idempotencyKey; 83 | } 84 | 85 | /** 86 | * Gets success value. 87 | * 88 | * @return bool 89 | */ 90 | public function getSuccess(): bool 91 | { 92 | return $this->success; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/Model/RecurringPayment/v3/Interval.php: -------------------------------------------------------------------------------- 1 | amount = $amount; 49 | return $this; 50 | } 51 | 52 | /** 53 | * Gets amount value. 54 | * 55 | * @return int 56 | */ 57 | public function getAmount(): int 58 | { 59 | return $this->amount; 60 | } 61 | 62 | /** 63 | * Sets suggestedMaxAmount variable. 64 | * 65 | * @param int $suggestedMaxAmount 66 | * 67 | * @return $this 68 | */ 69 | public function setSuggestedMaxAmount(int $suggestedMaxAmount) 70 | { 71 | $this->suggestedMaxAmount = $suggestedMaxAmount; 72 | return $this; 73 | } 74 | 75 | /** 76 | * Gets suggestedMaxAmount value. 77 | * 78 | * @return int 79 | */ 80 | public function getSuggestedMaxAmount(): int 81 | { 82 | return $this->suggestedMaxAmount; 83 | } 84 | 85 | /** 86 | * Sets type variable. 87 | * 88 | * @param string $type 89 | * 90 | * @return $this 91 | */ 92 | public function setType(string $type) 93 | { 94 | $this->type = $type; 95 | return $this; 96 | } 97 | 98 | /** 99 | * Gets type value. 100 | * 101 | * @return string 102 | */ 103 | public function getType(): string 104 | { 105 | return $this->type; 106 | } 107 | 108 | /** 109 | * Sets currency variable. 110 | * 111 | * @param string $currency 112 | * 113 | * @return $this 114 | */ 115 | public function setCurrency(string $currency) 116 | { 117 | $this->currency = $currency; 118 | return $this; 119 | } 120 | 121 | /** 122 | * Gets currency value. 123 | * 124 | * @return string 125 | */ 126 | public function getCurrency(): string 127 | { 128 | return $this->currency; 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /src/Model/RecurringPayment/v3/RequestCaptureCharge.php: -------------------------------------------------------------------------------- 1 | amount = $amount; 30 | return $this; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Model/RecurringPayment/v3/RequestRefundCharge.php: -------------------------------------------------------------------------------- 1 | amount = $amount; 36 | return $this; 37 | } 38 | 39 | /** 40 | * Sets description variable. 41 | * 42 | * @param string $description 43 | * 44 | * @return $this 45 | */ 46 | public function setDescription(string $description) 47 | { 48 | $this->description = $description; 49 | return $this; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/Model/RecurringPayment/v3/RequestUpdateAgreement.php: -------------------------------------------------------------------------------- 1 | pricing = $pricing; 49 | return $this; 50 | } 51 | 52 | /** 53 | * Sets productDescription variable. 54 | * 55 | * @param string $productDescription 56 | * 57 | * @return $this 58 | */ 59 | public function setProductDescription($productDescription) 60 | { 61 | $this->productDescription = $productDescription; 62 | return $this; 63 | } 64 | 65 | /** 66 | * Sets productName variable. 67 | * 68 | * @param string $productName 69 | * 70 | * @return $this 71 | */ 72 | public function setProductName($productName) 73 | { 74 | $this->productName = $productName; 75 | return $this; 76 | } 77 | 78 | /** 79 | * Sets status variable. 80 | * 81 | * @param string $status 82 | * 83 | * @return $this 84 | */ 85 | public function setStatus($status) 86 | { 87 | $this->status = $status; 88 | return $this; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/Model/RecurringPayment/v3/ResponseCreateAgreement.php: -------------------------------------------------------------------------------- 1 | uuid; 47 | } 48 | 49 | /** 50 | * Gets agreementId value. 51 | * 52 | * @return string 53 | */ 54 | public function getAgreementId(): string 55 | { 56 | return $this->agreementId; 57 | } 58 | 59 | /** 60 | * Gets vippsConfirmetionUrl value. 61 | * 62 | * @return string 63 | */ 64 | public function getVippsConfirmationUrl(): string 65 | { 66 | return $this->vippsConfirmationUrl; 67 | } 68 | 69 | /** 70 | * Gets chargeId value. 71 | * 72 | * @return string|null 73 | */ 74 | public function getChargeId(): ?string 75 | { 76 | return $this->chargeId; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/Model/RecurringPayment/v3/ResponseCreateCharge.php: -------------------------------------------------------------------------------- 1 | chargeId; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Model/RecurringPayment/v3/ResponseGetAgreement.php: -------------------------------------------------------------------------------- 1 | captured; 40 | } 41 | 42 | /** 43 | * Gets refunded value. 44 | * 45 | * @return int 46 | */ 47 | public function getRefunded(): int 48 | { 49 | return $this->refunded; 50 | } 51 | 52 | /** 53 | * Gets cancelled value. 54 | * 55 | * @return int 56 | */ 57 | public function getCancelled(): int 58 | { 59 | return $this->cancelled; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/Model/RecurringPayment/v3/TransactionType.php: -------------------------------------------------------------------------------- 1 | serializer) && ($this instanceof SupportsSerializationInterface)) { 16 | if (class_exists(AnnotationRegistry::class) && method_exists(AnnotationRegistry::class, 'registerLoader')) { 17 | AnnotationRegistry::registerLoader('class_exists'); 18 | } 19 | $serializer = static::getSerializer(); 20 | } elseif (!isset($this->serializer)) { 21 | throw new \InvalidArgumentException(sprintf('Missing %s', SerializerInterface::class)); 22 | } else { 23 | $serializer = $this->serializer; 24 | } 25 | return $serializer->serialize( 26 | $this, 27 | 'json' 28 | ); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Model/UserInfo/AccountInfo.php: -------------------------------------------------------------------------------- 1 | address_type; 58 | } 59 | 60 | /** 61 | * Gets street_address value. 62 | * 63 | * @return string 64 | */ 65 | public function getStreetAddress() 66 | { 67 | return $this->street_address; 68 | } 69 | 70 | /** 71 | * Gets region value. 72 | * 73 | * @return string 74 | */ 75 | public function getRegion() 76 | { 77 | return $this->region; 78 | } 79 | 80 | /** 81 | * Gets country value. 82 | * 83 | * @return string 84 | */ 85 | public function getCountry() 86 | { 87 | return $this->country; 88 | } 89 | 90 | /** 91 | * Gets postal_code value. 92 | * 93 | * @return string 94 | */ 95 | public function getPostalCode() 96 | { 97 | return $this->postal_code; 98 | } 99 | 100 | /** 101 | * Gets formatted value. 102 | * 103 | * @return string 104 | */ 105 | public function getFormatted() 106 | { 107 | return $this->formatted; 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /src/Model/Webhook/v1/GetWebhooksResponse.php: -------------------------------------------------------------------------------- 1 | ") 18 | */ 19 | protected $webhooks; 20 | 21 | /** 22 | * Gets webhooks value. 23 | * 24 | * @return \zaporylie\Vipps\Model\Webhook\v1\Webhook[] 25 | */ 26 | public function getWebhooks(): array 27 | { 28 | return $this->webhooks; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Model/Webhook/v1/RegisterWebhookRequest.php: -------------------------------------------------------------------------------- 1 | ") 24 | */ 25 | protected $events; 26 | 27 | /** 28 | * Sets url variable. 29 | * 30 | * @param string $url 31 | * 32 | * @return $this 33 | */ 34 | public function setUrl(string $url) 35 | { 36 | $this->url = $url; 37 | return $this; 38 | } 39 | 40 | /** 41 | * Sets events variable. 42 | * 43 | * @param array $events 44 | * 45 | * @return $this 46 | */ 47 | public function setEvents(array $events) 48 | { 49 | $this->events = $events; 50 | return $this; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/Model/Webhook/v1/RegisterWebhookResponse.php: -------------------------------------------------------------------------------- 1 | id; 35 | } 36 | 37 | /** 38 | * Gets secret value. 39 | * 40 | * @return string 41 | */ 42 | public function getSecret(): string 43 | { 44 | return $this->secret; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Model/Webhook/v1/Webhook.php: -------------------------------------------------------------------------------- 1 | ") 30 | */ 31 | protected $events; 32 | 33 | /** 34 | * Gets id value. 35 | * 36 | * @return string 37 | */ 38 | public function getId(): string 39 | { 40 | return $this->id; 41 | } 42 | 43 | /** 44 | * Gets url value. 45 | * 46 | * @return string 47 | */ 48 | public function getUrl(): string 49 | { 50 | return $this->url; 51 | } 52 | 53 | /** 54 | * Gets events value. 55 | * 56 | * @return array 57 | */ 58 | public function getEvents(): array 59 | { 60 | return $this->events; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/Resource/Authorization/GetToken.php: -------------------------------------------------------------------------------- 1 | headers['client_id'] = $this->client->getClientId(); 41 | $this->headers['client_secret'] = $this->client->getClientSecret(); 42 | } 43 | 44 | /** 45 | * @return \zaporylie\Vipps\Model\Authorization\ResponseGetToken 46 | */ 47 | public function call() 48 | { 49 | $response = $this->makeCall(); 50 | /** @var \zaporylie\Vipps\Model\Authorization\ResponseGetToken $responseObject */ 51 | $responseObject = $this 52 | ->getSerializer() 53 | ->deserialize( 54 | $response->getBody()->getContents(), 55 | ResponseGetToken::class, 56 | 'json' 57 | ); 58 | 59 | return $responseObject; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/Resource/AuthorizedResourceBase.php: -------------------------------------------------------------------------------- 1 | headers['Authorization'] = 25 | $this->client->getTokenStorage()->get()->getTokenType() 26 | .' '. 27 | $this->client->getTokenStorage()->get()->getAccessToken(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Resource/Checkout/v3/CreateCheckoutSession.php: -------------------------------------------------------------------------------- 1 | headers['client_id'] = $this->client->getClientId(); 41 | $this->headers['client_secret'] = $this->client->getClientSecret(); 42 | 43 | $this->body = $this 44 | ->getSerializer() 45 | ->serialize( 46 | $request, 47 | 'json' 48 | ); 49 | } 50 | 51 | /** 52 | * @return \zaporylie\Vipps\Model\Checkout\v3\CreateCheckoutSessionResponse 53 | */ 54 | public function call() 55 | { 56 | $response = $this->makeCall(); 57 | $body = $response->getBody()->getContents(); 58 | /** @var \zaporylie\Vipps\Model\Checkout\v3\CreateCheckoutSessionResponse $responseObject */ 59 | $responseObject = $this 60 | ->getSerializer() 61 | ->deserialize( 62 | $body, 63 | CreateCheckoutSessionResponse::class, 64 | 'json' 65 | ); 66 | 67 | return $responseObject; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/Resource/Checkout/v3/GetCheckoutSession.php: -------------------------------------------------------------------------------- 1 | id = $reference; 38 | 39 | // Checkout module requires client_id and client_secret headers. 40 | $this->headers['client_id'] = $this->client->getClientId(); 41 | $this->headers['client_secret'] = $this->client->getClientSecret(); 42 | } 43 | 44 | /** 45 | * @return \zaporylie\Vipps\Model\Checkout\v3\GetCheckoutSessionResponse 46 | */ 47 | public function call() 48 | { 49 | $response = $this->makeCall(); 50 | $body = $response->getBody()->getContents(); 51 | /** @var \zaporylie\Vipps\Model\Checkout\v3\GetCheckoutSessionResponse $responseObject */ 52 | $responseObject = $this 53 | ->getSerializer() 54 | ->deserialize( 55 | $body, 56 | GetCheckoutSessionResponse::class, 57 | 'json' 58 | ); 59 | 60 | return $responseObject; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/Resource/EPayment/v1/CancelPayment.php: -------------------------------------------------------------------------------- 1 | headers['Idempotency-Key'] = $idempotency_key; 44 | $this->id = $reference; 45 | $this->body = $this 46 | ->getSerializer() 47 | ->serialize( 48 | $request, 49 | 'json' 50 | ); 51 | } 52 | 53 | /** 54 | * @return \zaporylie\Vipps\Model\EPayment\v1\PaymentAdjustResponse 55 | */ 56 | public function call() 57 | { 58 | $response = $this->makeCall(); 59 | $body = $response->getBody()->getContents(); 60 | /** @var \zaporylie\Vipps\Model\EPayment\v1\PaymentAdjustResponse $responseObject */ 61 | $responseObject = $this 62 | ->getSerializer() 63 | ->deserialize( 64 | $body, 65 | PaymentAdjustResponse::class, 66 | 'json' 67 | ); 68 | 69 | return $responseObject; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/Resource/EPayment/v1/CapturePayment.php: -------------------------------------------------------------------------------- 1 | headers['Idempotency-Key'] = $idempotency_key; 44 | $this->id = $reference; 45 | $this->body = $this 46 | ->getSerializer() 47 | ->serialize( 48 | $request, 49 | 'json' 50 | ); 51 | } 52 | 53 | /** 54 | * @return \zaporylie\Vipps\Model\EPayment\v1\PaymentAdjustResponse 55 | */ 56 | public function call() 57 | { 58 | $response = $this->makeCall(); 59 | $body = $response->getBody()->getContents(); 60 | /** @var \zaporylie\Vipps\Model\EPayment\v1\PaymentAdjustResponse $responseObject */ 61 | $responseObject = $this 62 | ->getSerializer() 63 | ->deserialize( 64 | $body, 65 | PaymentAdjustResponse::class, 66 | 'json' 67 | ); 68 | 69 | return $responseObject; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/Resource/EPayment/v1/CreatePayment.php: -------------------------------------------------------------------------------- 1 | headers['Idempotency-Key'] = $idempotency_key; 40 | $this->body = $this 41 | ->getSerializer() 42 | ->serialize( 43 | $request, 44 | 'json' 45 | ); 46 | } 47 | 48 | /** 49 | * @return \zaporylie\Vipps\Model\EPayment\v1\CreatePaymentResponse 50 | */ 51 | public function call() 52 | { 53 | $response = $this->makeCall(); 54 | $body = $response->getBody()->getContents(); 55 | /** @var \zaporylie\Vipps\Model\EPayment\v1\CreatePaymentResponse $responseObject */ 56 | $responseObject = $this 57 | ->getSerializer() 58 | ->deserialize( 59 | $body, 60 | CreatePaymentResponse::class, 61 | 'json' 62 | ); 63 | 64 | return $responseObject; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Resource/EPayment/v1/GetPayment.php: -------------------------------------------------------------------------------- 1 | id = $reference; 33 | } 34 | 35 | /** 36 | * @return \zaporylie\Vipps\Model\EPayment\v1\GetPaymentResponse 37 | */ 38 | public function call() 39 | { 40 | $response = $this->makeCall(); 41 | $body = $response->getBody()->getContents(); 42 | /** @var \zaporylie\Vipps\Model\EPayment\v1\GetPaymentResponse $responseObject */ 43 | $responseObject = $this 44 | ->getSerializer() 45 | ->deserialize( 46 | $body, 47 | GetPaymentResponse::class, 48 | 'json' 49 | ); 50 | 51 | return $responseObject; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/Resource/EPayment/v1/GetPaymentEvents.php: -------------------------------------------------------------------------------- 1 | id = $reference; 33 | } 34 | 35 | /** 36 | * @return \zaporylie\Vipps\Model\EPayment\v1\EventLog[] 37 | */ 38 | public function call() 39 | { 40 | $response = $this->makeCall(); 41 | $body = $response->getBody()->getContents(); 42 | /** @var \zaporylie\Vipps\Model\EPayment\v1\EventLog[] $responseObject */ 43 | $responseObject = $this 44 | ->getSerializer() 45 | ->deserialize( 46 | $body, 47 | sprintf("array<%s>", EventLog::class), 48 | 'json' 49 | ); 50 | 51 | return $responseObject; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/Resource/EPayment/v1/RefundPayment.php: -------------------------------------------------------------------------------- 1 | headers['Idempotency-Key'] = $idempotency_key; 44 | $this->id = $reference; 45 | $this->body = $this 46 | ->getSerializer() 47 | ->serialize( 48 | $request, 49 | 'json' 50 | ); 51 | } 52 | 53 | /** 54 | * @return \zaporylie\Vipps\Model\EPayment\v1\PaymentAdjustResponse 55 | */ 56 | public function call() 57 | { 58 | $response = $this->makeCall(); 59 | $body = $response->getBody()->getContents(); 60 | /** @var \zaporylie\Vipps\Model\EPayment\v1\PaymentAdjustResponse $responseObject */ 61 | $responseObject = $this 62 | ->getSerializer() 63 | ->deserialize( 64 | $body, 65 | PaymentAdjustResponse::class, 66 | 'json' 67 | ); 68 | 69 | return $responseObject; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/Resource/HttpMethod.php: -------------------------------------------------------------------------------- 1 | serializer = SerializerBuilder::create() 27 | ->setPropertyNamingStrategy(new SerializedNameAnnotationStrategy(new IdenticalPropertyNamingStrategy())) 28 | ->build(); 29 | 30 | // Content type for all requests must be set. 31 | $this->headers['Content-Type'] = 'application/json'; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Resource/PaymentsInterface.php: -------------------------------------------------------------------------------- 1 | id = $agreement_id; 41 | $this->charge_id = $charge_id; 42 | $this->headers['Idempotency-Key'] = $idempotency_key; 43 | parent::__construct($client); 44 | } 45 | 46 | /** 47 | * @return string 48 | */ 49 | public function call() 50 | { 51 | $response = $this->makeCall(); 52 | $body = $response->getBody()->getContents(); 53 | return $body; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/Resource/RecurringPayment/v3/CaptureCharge.php: -------------------------------------------------------------------------------- 1 | id = $agreement_id; 44 | $this->charge_id = $charge_id; 45 | $this->headers['Idempotency-Key'] = $idempotency_key; 46 | parent::__construct($client); 47 | $this->body = $this 48 | ->getSerializer() 49 | ->serialize( 50 | $requestObject, 51 | 'json' 52 | ); 53 | } 54 | 55 | /** 56 | * @return string 57 | */ 58 | public function call() 59 | { 60 | $response = $this->makeCall(); 61 | $body = $response->getBody()->getContents(); 62 | return $body; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/Resource/RecurringPayment/v3/CreateAgreement.php: -------------------------------------------------------------------------------- 1 | headers['Idempotency-Key'] = $idempotency_key; 38 | parent::__construct($client); 39 | $this->body = $this 40 | ->getSerializer() 41 | ->serialize( 42 | $requestObject, 43 | 'json' 44 | ); 45 | } 46 | 47 | /** 48 | * @return \zaporylie\Vipps\Model\RecurringPayment\v3\ResponseCreateAgreement 49 | */ 50 | public function call() 51 | { 52 | $response = $this->makeCall(); 53 | $body = $response->getBody()->getContents(); 54 | /** @var \zaporylie\Vipps\Model\RecurringPayment\v3\ResponseCreateAgreement $responseObject */ 55 | $responseObject = $this 56 | ->getSerializer() 57 | ->deserialize( 58 | $body, 59 | ResponseCreateAgreement::class, 60 | 'json' 61 | ); 62 | 63 | return $responseObject; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/Resource/RecurringPayment/v3/CreateCharge.php: -------------------------------------------------------------------------------- 1 | id = $agreement_id; 43 | $this->headers['Idempotency-Key'] = $idempotency_key; 44 | parent::__construct($client); 45 | $this->body = $this 46 | ->getSerializer() 47 | ->serialize( 48 | $requestObject, 49 | 'json' 50 | ); 51 | } 52 | 53 | /** 54 | * @return \zaporylie\Vipps\Model\RecurringPayment\v3\ResponseCreateCharge 55 | */ 56 | public function call() 57 | { 58 | $response = $this->makeCall(); 59 | $body = $response->getBody()->getContents(); 60 | /** @var \zaporylie\Vipps\Model\RecurringPayment\v3\ResponseCreateCharge $responseObject */ 61 | $responseObject = $this 62 | ->getSerializer() 63 | ->deserialize( 64 | $body, 65 | ResponseCreateCharge::class, 66 | 'json' 67 | ); 68 | 69 | return $responseObject; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/Resource/RecurringPayment/v3/GetAgreement.php: -------------------------------------------------------------------------------- 1 | id = $agreement_id; 37 | } 38 | 39 | /** 40 | * @return \zaporylie\Vipps\Model\RecurringPayment\v3\ResponseGetAgreement 41 | */ 42 | public function call() 43 | { 44 | $response = $this->makeCall(); 45 | $body = $response->getBody()->getContents(); 46 | /** @var \zaporylie\Vipps\Model\RecurringPayment\v3\ResponseGetAgreement $responseObject */ 47 | $responseObject = $this 48 | ->getSerializer() 49 | ->deserialize( 50 | $body, 51 | ResponseGetAgreement::class, 52 | 'json' 53 | ); 54 | 55 | return $responseObject; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/Resource/RecurringPayment/v3/GetAgreements.php: -------------------------------------------------------------------------------- 1 | makeCall(); 32 | $body = $response->getBody()->getContents(); 33 | /** @var \zaporylie\Vipps\Model\RecurringPayment\v3\ResponseGetAgreement[] $responseObject */ 34 | $responseObject = $this 35 | ->getSerializer() 36 | ->deserialize( 37 | $body, 38 | sprintf("array<%s>", ResponseGetAgreement::class), 39 | 'json' 40 | ); 41 | 42 | return $responseObject; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Resource/RecurringPayment/v3/GetCharge.php: -------------------------------------------------------------------------------- 1 | id = $agreement_id; 39 | $this->charge_id = $charge_id; 40 | } 41 | 42 | /** 43 | * @return \zaporylie\Vipps\Model\RecurringPayment\v3\ResponseGetCharge 44 | */ 45 | public function call() 46 | { 47 | $response = $this->makeCall(); 48 | $body = $response->getBody()->getContents(); 49 | /** @var \zaporylie\Vipps\Model\RecurringPayment\v3\ResponseGetCharge $responseObject */ 50 | $responseObject = $this 51 | ->getSerializer() 52 | ->deserialize( 53 | $body, 54 | ResponseGetCharge::class, 55 | 'json' 56 | ); 57 | 58 | return $responseObject; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/Resource/RecurringPayment/v3/GetCharges.php: -------------------------------------------------------------------------------- 1 | id = $agreement_id; 37 | } 38 | 39 | /** 40 | * @return \zaporylie\Vipps\Model\RecurringPayment\v3\Charge[] 41 | */ 42 | public function call() 43 | { 44 | $response = $this->makeCall(); 45 | $body = $response->getBody()->getContents(); 46 | /** @var \zaporylie\Vipps\Model\RecurringPayment\v3\Charge[] $responseObject */ 47 | $responseObject = $this 48 | ->getSerializer() 49 | ->deserialize( 50 | $body, 51 | sprintf("array<%s>", Charge::class), 52 | 'json' 53 | ); 54 | 55 | return $responseObject; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/Resource/RecurringPayment/v3/RecurringPaymentResourceBase.php: -------------------------------------------------------------------------------- 1 | serializer = SerializerBuilder::create() 33 | ->setPropertyNamingStrategy(new SerializedNameAnnotationStrategy(new IdenticalPropertyNamingStrategy())) 34 | ->build(); 35 | 36 | // Content type for all requests must be set. 37 | $this->headers['Content-Type'] = 'application/json'; 38 | } 39 | 40 | 41 | /** 42 | * {@inheritdoc} 43 | * 44 | * All occurrences of {id} pattern will be replaced with $this->id 45 | */ 46 | public function getPath() 47 | { 48 | $path = parent::getPath(); 49 | // If ID is set replace {id} pattern with model's ID. 50 | if (isset($this->charge_id)) { 51 | $path = str_replace('{charge_id}', $this->charge_id, $path); 52 | } 53 | return $path; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/Resource/RecurringPayment/v3/RefundCharge.php: -------------------------------------------------------------------------------- 1 | id = $agreement_id; 44 | $this->charge_id = $charge_id; 45 | $this->headers['Idempotency-Key'] = $idempotency_key; 46 | parent::__construct($client); 47 | $this->body = $this 48 | ->getSerializer() 49 | ->serialize( 50 | $requestObject, 51 | 'json' 52 | ); 53 | } 54 | 55 | /** 56 | * @return string 57 | */ 58 | public function call() 59 | { 60 | $response = $this->makeCall(); 61 | $body = $response->getBody()->getContents(); 62 | return $body; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/Resource/RecurringPayment/v3/UpdateAgreement.php: -------------------------------------------------------------------------------- 1 | headers['Idempotency-Key'] = $idempotency_key; 42 | parent::__construct($client); 43 | $this->id = $agreement_id; 44 | $this->body = $this 45 | ->getSerializer() 46 | ->serialize( 47 | $requestObject, 48 | 'json' 49 | ); 50 | } 51 | 52 | /** 53 | * @return mixed 54 | */ 55 | public function call() 56 | { 57 | $response = $this->makeCall(); 58 | $body = $response->getBody()->getContents(); 59 | return $body; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/Resource/RequestIdFactory.php: -------------------------------------------------------------------------------- 1 | client = $client; 38 | // Initiate serializer. 39 | $this->serializer = SerializerBuilder::create() 40 | ->build(); 41 | $this->id = $sub; 42 | $this->headers['Authorization'] = 43 | $this->client->getTokenStorage()->get()->getTokenType() 44 | .' '. 45 | $this->client->getTokenStorage()->get()->getAccessToken(); 46 | } 47 | 48 | /** 49 | * @return \zaporylie\Vipps\Model\UserInfo\ResponseUserInfo 50 | */ 51 | public function call() 52 | { 53 | $response = $this->makeCall(); 54 | $body = $response->getBody()->getContents(); 55 | /** @var \zaporylie\Vipps\Model\UserInfo\ResponseUserInfo $responseObject */ 56 | $responseObject = $this 57 | ->getSerializer() 58 | ->deserialize( 59 | $body, 60 | ResponseUserInfo::class, 61 | 'json' 62 | ); 63 | 64 | return $responseObject; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Resource/Webhook/v1/DeleteWebhook.php: -------------------------------------------------------------------------------- 1 | id = $reference; 37 | } 38 | 39 | /** 40 | * @return mixed 41 | */ 42 | public function call() 43 | { 44 | $response = $this->makeCall(); 45 | $body = $response->getBody()->getContents(); 46 | return $body; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/Resource/Webhook/v1/GetWebhooks.php: -------------------------------------------------------------------------------- 1 | makeCall(); 44 | /** @var \zaporylie\Vipps\Model\Webhook\v1\GetWebhooksResponse $responseObject */ 45 | $responseObject = $this 46 | ->getSerializer() 47 | ->deserialize( 48 | $response->getBody()->getContents(), 49 | GetWebhooksResponse::class, 50 | 'json' 51 | ); 52 | 53 | return $responseObject; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/Resource/Webhook/v1/RegisterWebhook.php: -------------------------------------------------------------------------------- 1 | body = $this 38 | ->getSerializer() 39 | ->serialize( 40 | $request, 41 | 'json' 42 | ); 43 | // This is important bit for making webhooks api not to fail. 44 | $this->headers['Content-Type'] = 'application/json'; 45 | } 46 | 47 | /** 48 | * @return \zaporylie\Vipps\Model\Webhook\v1\RegisterWebhookResponse 49 | */ 50 | public function call() 51 | { 52 | $response = $this->makeCall(); 53 | /** @var \zaporylie\Vipps\Model\Webhook\v1\RegisterWebhookResponse $responseObject */ 54 | $responseObject = $this 55 | ->getSerializer() 56 | ->deserialize( 57 | $response->getBody()->getContents(), 58 | RegisterWebhookResponse::class, 59 | 'json' 60 | ); 61 | 62 | return $responseObject; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /test/Integration/Api/AuthorizationTest.php: -------------------------------------------------------------------------------- 1 | vipps->authorization('test_subscription_key'); 24 | 25 | // Mock response. 26 | $this->mockResponse($this->getResponse([ 27 | 'access_token' => 'test_access_token', 28 | 'token_type' => 'test_token_type', 29 | 'expires_in' => 123, 30 | 'ext_expires_in' => 321, 31 | 'expires_on' => 1765432100, 32 | 'not_before' => 1765432100, 33 | 'resource' => 'test_resource', 34 | ])); 35 | 36 | // Do request. 37 | $response = $api->getToken('test_client_secret'); 38 | 39 | // Assert response. 40 | $this->assertEquals('test_access_token', $response->getAccessToken()); 41 | $this->assertEquals('test_token_type', $response->getTokenType()); 42 | $this->assertEquals(123, $response->getExpiresIn()); 43 | $this->assertEquals(321, $response->getExtExpiresIn()); 44 | $this->assertInstanceOf(\DateTimeInterface::class, $response->getExpiresOn()); 45 | $this->assertInstanceOf(\DateTimeInterface::class, $response->getNotBefore()); 46 | $this->assertEquals('test_resource', $response->getResource()); 47 | } 48 | 49 | /** 50 | * @covers \zaporylie\Vipps\Api\Authorization::getToken() 51 | * @covers \zaporylie\Vipps\Resource\ResourceBase::makeCall() 52 | */ 53 | public function testInvalidGetToken() 54 | { 55 | $api = $this->vipps->authorization('test_subscription_key'); 56 | $this->mockResponse(parent::getErrorResponse()); 57 | $this->expectException(VippsException::class); 58 | $this->expectExceptionCode(400); 59 | $api->getToken('test_client_secret'); 60 | } 61 | 62 | /** 63 | * @covers \zaporylie\Vipps\Api\Authorization::getToken() 64 | * @covers \zaporylie\Vipps\Resource\ResourceBase::makeCall() 65 | */ 66 | public function testServerError() 67 | { 68 | $api = $this->vipps->authorization('test_subscription_key'); 69 | $this->mockResponse(parent::getErrorResponse(500, 'Error')); 70 | $this->expectException(VippsException::class); 71 | $this->expectExceptionCode(500); 72 | $this->expectExceptionMessage('Error'); 73 | $api->getToken('test_client_secret'); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /test/Integration/IntegrationTestBase.php: -------------------------------------------------------------------------------- 1 | httpClient = $this->getMockBuilder(ClientInterface::class) 42 | ->disableOriginalConstructor() 43 | ->disableOriginalClone() 44 | ->disableArgumentCloning() 45 | ->disallowMockingUnknownTypes() 46 | ->getMock(); 47 | 48 | 49 | $this->client = new Client('test_client_id', [ 50 | 'http_client' => $this->httpClient, 51 | 'token_storage' => new TestTokenStorage(), 52 | ]); 53 | 54 | $this->vipps = new Vipps($this->client); 55 | } 56 | 57 | /** 58 | * @param \GuzzleHttp\Psr7\Response $response 59 | */ 60 | protected function mockResponse(Response $response) 61 | { 62 | $this->httpClient 63 | ->expects($this->any()) 64 | ->method('sendRequest') 65 | ->will($this->returnValue($response)); 66 | } 67 | 68 | /** 69 | * @param array $content 70 | * 71 | * @return \GuzzleHttp\Psr7\Response 72 | */ 73 | public static function getResponse(array $content = []) 74 | { 75 | return new Response(200, [], \GuzzleHttp\Psr7\Utils::streamFor(json_encode($content))); 76 | } 77 | 78 | /** 79 | * @return \GuzzleHttp\Psr7\Response 80 | */ 81 | public static function getErrorResponse($error_code = 400, $error_message = null) 82 | { 83 | if (!isset($error_message)) { 84 | $error_message = [ 85 | 'error_code' => 'test_access_token', 86 | 'error_message' => 'test_token_type', 87 | ]; 88 | } 89 | return new Response($error_code, [], \GuzzleHttp\Psr7\Utils::streamFor(json_encode($error_message))); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /test/Unit/Api/ApiBaseTest.php: -------------------------------------------------------------------------------- 1 | apiBase = $this->getMockForAbstractClass(ApiBase::class, [ 28 | new Vipps(new Client('test')), 29 | 'test_subscription_key' 30 | ]); 31 | } 32 | 33 | /** 34 | * @covers \zaporylie\Vipps\Api\ApiBase::getSubscriptionKey() 35 | * @covers \zaporylie\Vipps\Api\ApiBase::setSubscriptionKey() 36 | * @covers \zaporylie\Vipps\Api\ApiBase::__construct() 37 | */ 38 | public function testSubscriptionKey() 39 | { 40 | $this->assertEquals('test_subscription_key', $this->apiBase->getSubscriptionKey()); 41 | $this->assertInstanceOf(ApiBase::class, $this->apiBase->setSubscriptionKey(null)); 42 | $this->expectException(InvalidArgumentException::class); 43 | $this->apiBase->getSubscriptionKey(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /test/Unit/Authentication/TestTokenStorage.php: -------------------------------------------------------------------------------- 1 | getProperty('accessToken'); 19 | $accessToken->setAccessible(true); 20 | $accessToken->setValue($token, 'test_access_token'); 21 | 22 | // Set access token value. 23 | $tokenType = $reflectionClass->getProperty('tokenType'); 24 | $tokenType->setAccessible(true); 25 | $tokenType->setValue($token, 'test_token_type'); 26 | 27 | return $token; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /test/Unit/Authentication/TokenMemoryCacheStorageTest.php: -------------------------------------------------------------------------------- 1 | serializer = SerializerBuilder::create()->build(); 34 | $this->token = new TokenMemoryCacheStorage(); 35 | } 36 | 37 | /** 38 | * @param string $time 39 | * 40 | * @return \zaporylie\Vipps\Model\Authorization\ResponseGetToken 41 | */ 42 | protected function getToken($time = 'now') 43 | { 44 | return $this->serializer->deserialize( 45 | json_encode([ 46 | 'access_token' => 'test_access_token', 47 | 'token_type' => 'test_token_type', 48 | 'resource' => 'test_resource', 49 | 'expires_in' => 123, 50 | 'ext_expires_in' => 123, 51 | 'expires_on' => (new \DateTime($time))->format('U'), 52 | 'not_before' => (new \DateTime($time))->format('U'), 53 | ]), 54 | ResponseGetToken::class, 55 | 'json' 56 | ); 57 | } 58 | 59 | /** 60 | * @covers \zaporylie\Vipps\Authentication\TokenMemoryCacheStorage 61 | */ 62 | public function testToken() 63 | { 64 | // Test setter. 65 | $this->assertInstanceOf(TokenStorageInterface::class, $this->token->set($token = $this->getToken())); 66 | 67 | // Test getter. 68 | $this->assertEquals($token, $this->token->get()); 69 | 70 | // Test expiration. 71 | sleep(1); 72 | $this->assertFalse($this->token->has()); 73 | 74 | // Test missing. 75 | $this->assertFalse($this->token->has()); 76 | 77 | // Test clear. 78 | $this->token->set($this->getToken()); 79 | $this->assertNotNull($this->token->get()); 80 | $this->assertInstanceOf(TokenStorageInterface::class, $this->token->clear()); 81 | $this->expectException(InvalidArgumentException::class); 82 | $this->token->get(); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /test/Unit/EndpointTest.php: -------------------------------------------------------------------------------- 1 | assertInstanceOf(EndpointInterface::class, Endpoint::test()); 28 | $this->assertInstanceOf(EndpointInterface::class, Endpoint::live()); 29 | $this->expectException(UndefinedMemberException::class); 30 | Endpoint::foo(); 31 | } 32 | 33 | public function testGetters() 34 | { 35 | $endpoint = Endpoint::test(); 36 | $this->assertNotEmpty($endpoint->getScheme()); 37 | $this->assertNotEmpty($endpoint->getHost()); 38 | $this->assertNotEmpty($endpoint->getPort()); 39 | $this->assertNotNull($endpoint->getPath()); 40 | $this->assertInstanceOf(UriInterface::class, $endpoint->getUri()); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /test/Unit/Model/Error/PaymentErrorTest.php: -------------------------------------------------------------------------------- 1 | build(); 26 | $this->response = $serializer->deserialize( 27 | json_encode([ 28 | 'errorGroup' => 'test_error_group', 29 | 'errorCode' => 'test_error_code', 30 | 'errorMessage' => 'test_error_message', 31 | ]), 32 | PaymentError::class, 33 | 'json' 34 | ); 35 | } 36 | 37 | /** 38 | * @covers \zaporylie\Vipps\Model\Error\PaymentError::getErrorGroup() 39 | */ 40 | public function testGetErrorGroup() 41 | { 42 | $this->assertEquals('test_error_group', $this->response->getErrorGroup()); 43 | } 44 | 45 | /** 46 | * @covers \zaporylie\Vipps\Model\Error\PaymentError::getErrorMessage() 47 | */ 48 | public function testGetErrorMessage() 49 | { 50 | $this->assertEquals('test_error_message', $this->response->getErrorMessage()); 51 | } 52 | 53 | /** 54 | * @covers \zaporylie\Vipps\Model\Error\PaymentError::getErrorCode() 55 | */ 56 | public function testGetErrorCode() 57 | { 58 | $this->assertEquals('test_error_code', $this->response->getErrorCode()); 59 | } 60 | 61 | /** 62 | * @covers \zaporylie\Vipps\Model\Error\PaymentError::getCode() 63 | */ 64 | public function testGetCode() 65 | { 66 | $this->assertEquals('test_error_code', $this->response->getCode()); 67 | } 68 | 69 | /** 70 | * @covers \zaporylie\Vipps\Model\Error\PaymentError::getMessage() 71 | */ 72 | public function testGetMessage() 73 | { 74 | $this->assertEquals('test_error_message', $this->response->getMessage()); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /test/Unit/Model/ModelTestBase.php: -------------------------------------------------------------------------------- 1 | client = $this->createMock(Client::class); 35 | $this->client 36 | ->expects($this->any()) 37 | ->method('getClientId') 38 | ->willReturn('foo'); 39 | 40 | $this->client 41 | ->expects($this->any()) 42 | ->method('getTokenStorage') 43 | ->will($this->returnValue($token)); 44 | 45 | 46 | // Get Vipps. 47 | $this->vipps = new Vipps($this->client); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /test/Unit/Resource/Authorization/GetTokenTest.php: -------------------------------------------------------------------------------- 1 | resource = $this->getMockBuilder(GetToken::class) 23 | ->setConstructorArgs([$this->vipps, 'test_subscription_key', 'test_client_secret']) 24 | ->disallowMockingUnknownTypes() 25 | ->setMethods(['makeCall']) 26 | ->getMock(); 27 | 28 | $this->resource 29 | ->expects($this->any()) 30 | ->method('makeCall') 31 | ->will($this->returnValue(new Response(200, [], \GuzzleHttp\Psr7\Utils::streamFor(json_encode([]))))); 32 | } 33 | 34 | /** 35 | * @covers \zaporylie\Vipps\Resource\Authorization\GetToken::__construct 36 | * @covers \zaporylie\Vipps\Resource\Authorization\GetToken::getHeaders() 37 | */ 38 | public function testHeaders() 39 | { 40 | $headers = $this->resource->getHeaders(); 41 | $this->assertArrayHasKey('client_id', $headers); 42 | $this->assertEquals('test_client_id', $headers['client_id']); 43 | $this->assertArrayHasKey('client_secret', $headers); 44 | $this->assertEquals('test_client_secret', $headers['client_secret']); 45 | } 46 | 47 | /** 48 | * @covers \zaporylie\Vipps\Resource\Authorization\GetToken::getBody() 49 | */ 50 | public function testBody() 51 | { 52 | $this->assertEmpty($this->resource->getBody()); 53 | } 54 | 55 | /** 56 | * @covers \zaporylie\Vipps\Resource\Authorization\GetToken::getMethod() 57 | */ 58 | public function testMethod() 59 | { 60 | $this->assertEquals(HttpMethod::POST, $this->resource->getMethod()); 61 | } 62 | 63 | /** 64 | * @covers \zaporylie\Vipps\Resource\Authorization\GetToken::getPath() 65 | */ 66 | public function testPath() 67 | { 68 | $this->assertEquals('/accesstoken/get', $this->resource->getPath()); 69 | } 70 | 71 | /** 72 | * @covers \zaporylie\Vipps\Resource\Authorization\GetToken::call() 73 | */ 74 | public function testCall() 75 | { 76 | $this->assertInstanceOf(ResponseGetToken::class, $response = $this->resource->call()); 77 | $this->assertEquals(new ResponseGetToken(), $response); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /test/Unit/Resource/AuthorizedResourceBaseTest.php: -------------------------------------------------------------------------------- 1 | getMockForAbstractClass(AuthorizedResourceBase::class, [ 17 | $this->vipps, 18 | 'test_subscription_key' 19 | ]); 20 | $this->assertArrayHasKey('Authorization', $authorized->getHeaders()); 21 | $this->assertEquals('test_token_type test_access_token', $authorized->getHeaders()['Authorization']); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test/Unit/Resource/RequestIdFactoryTest.php: -------------------------------------------------------------------------------- 1 | assertLessThan(30, strlen($request_id)); 18 | $this->assertNotEmpty($request_id); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/Unit/Resource/ResourceTestBase.php: -------------------------------------------------------------------------------- 1 | httpClient = $this->createMock(ClientInterface::class); 37 | $this->client = new Client('test_client_id', [ 38 | 'http_client' => $this->httpClient, 39 | 'token_storage' => new TestTokenStorage(), 40 | ]); 41 | $this->vipps = new Vipps($this->client); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /test/Unit/VippsTest.php: -------------------------------------------------------------------------------- 1 | client = $this->createMock(ClientInterface::class); 32 | $this->vipps = new Vipps($this->client); 33 | } 34 | 35 | /** 36 | * @covers \zaporylie\Vipps\Vipps::getClient() 37 | */ 38 | public function testClient() 39 | { 40 | $this->assertEquals($this->client, $this->vipps->getClient()); 41 | } 42 | 43 | /** 44 | * @covers \zaporylie\Vipps\Vipps::payment() 45 | */ 46 | public function testPayment() 47 | { 48 | $this->assertInstanceOf( 49 | Payment::class, 50 | $payment = $this->vipps->payment('test_subscription_key', 'test_merchant_serial_key') 51 | ); 52 | $this->assertEquals($payment->getSubscriptionKey(), 'test_subscription_key'); 53 | $this->assertEquals($payment->getMerchantSerialNumber(), 'test_merchant_serial_key'); 54 | $this->assertInstanceOf( 55 | Payment::class, 56 | $payment = $this->vipps->payment('test_subscription_key', 'test_merchant_serial_key', 'test_path') 57 | ); 58 | $this->assertEquals($payment->getCustomPath(), 'test_path'); 59 | } 60 | 61 | /** 62 | * @covers \zaporylie\Vipps\Vipps::authorization() 63 | */ 64 | public function testAuthorization() 65 | { 66 | $this->assertInstanceOf(Authorization::class, $this->vipps->authorization('test_subscription_key')); 67 | } 68 | 69 | /** 70 | * @covers \zaporylie\Vipps\Vipps::__construct() 71 | */ 72 | public function testConstruct() 73 | { 74 | $this->assertEquals($this->client, $this->vipps->getClient()); 75 | } 76 | } 77 | --------------------------------------------------------------------------------