diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md index 8934b3266..48d4575ff 100644 --- a/packages/sdk/CHANGELOG.md +++ b/packages/sdk/CHANGELOG.md @@ -5,6 +5,92 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## V2.10.0 +### Added +- Allow update site_id on seller funnel + +## V2.9.1 +### Changed +- Adjusts the way to obtain response headers + +## V2.9.0 +### Added +- Add forgotten attributes on PHP docs of SellerBaseFunnel + +## V2.8.0 +### Added +- Is possible using empty constructor on Sdk +- Add new fields on seller base funnel: site_id, platform_version, plugin_version and is_disabled + +## V2.7.0 +### Added +- Added `id`, `status`, `payment_type_id` parameters on Payment response + +## V2.6.3 +### Added +- Added `qr_code_base64` and `qr_code` parameter to TransactionData + +## V2.6.2 +### Added +- Added `external_resource_url` parameter to TransactionDetails +### Fixed +- unsetting variables from save method on Payment class to allow payment creation + +## V2.6.1 +### Fixed +- Added `total_paid_amount` and `installment_amount` as properties of TransactionDetails + +## V2.6.0 +### Added +- Added `total_paid_amount` and `installment_amount` parameters to TransactionDetails + +## V2.5.0 +### Added +- Added seller configuration funnel entity to update id + +## V2.4.0 +### Added +- Added seller configuration funnel entity to create new id + +## V2.3.0 +### Added +- Get Payment by ID + +## V2.2.0 +### Added +- Create Merchant Order entity to get one or more merchant orders + +## V2.1.0 +### Added +- Get Preferences Implementation + +## V2.0.1 +### Removed +- Remove forgotten var_dump on request manager class + +## V2.0.0 +### Added +- Adds the `public_key` parameter to the sdk constructor. +- `PaymentMethods` entity to get payment methods using the Core Payment Methods service API +- Create `getPaymentMethods` and `getPaymentMethodsByGroupBy` methods in `PaymentMethods` class +- Integration tests for PaymentMethods scenario +- Adds the possibility of passing query strings in requests +- Create `setHeadersAsKeyAndValueMap`, `isHeadersAsKeyAndValueMap`, and `normalizeHeaders` methods in Manager class + +## V1.12.0 +### Added +- `DatadogEvent` entity to register events in Datadog using the Core Monitor service API +- Integration tests for datadogEvent scenario +- Create saveWithParams method in AbstractEntity and RequesterEntityInterface + +### Changed +- Remove `MelidataError` entity + +## V1.11.0 +### Added +- `RegisterErrorLog` entity to register errors log using the Core Monitor service API +- Integration tests for registerLog scenario + ## V1.10.0 ### Added - `MelidataError` entity to register errors in Melidata using the Core Monitor service API diff --git a/packages/sdk/README.md b/packages/sdk/README.md index effd3e5d3..010e421b6 100644 --- a/packages/sdk/README.md +++ b/packages/sdk/README.md @@ -22,9 +22,9 @@ Para incluir a biblioteca em seu projeto, basta fazer o seguinte: ```php getPaymentInstance(); + + $payment->token = "034215d05985b328683ec816607b2a5d"; + $payment->transaction_amount = 230; + $payment->description = "Ergonomic Silk Shirt"; + $payment->installments = 1; + $payment->payment_method_id = "master"; + $payment->payer->email = "test_user_98934401@testuser.com"; + . + . + . + + $payment->save(); -$sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId' ); +``` +## Obtendo pagamento -$payment = $sdk->getPaymentInstance(); +```php +getPaymentInstance(); + + $payment->read(array("id" => 'payment_id')); +``` -$payment->token = "034215d05985b328683ec816607b2a5d"; -$payment->transaction_amount = 230; -$payment->description = "Ergonomic Silk Shirt"; -$payment->installments = 1; -$payment->payment_method_id = "master"; -$payment->payer->email = "test_user_98934401@testuser.com"; -. -. -. +## Criando uma preferência -$payment->save(); +```php +getPreferenceInstance(); + + $items = ["items" => + [ + "title" => "Dummy Title", + "description" => "Dummy description", + "picture_url" => "http://www.myapp.com/myimage.jpg", + "category_id" => "car_electronics", + "quantity" => 1, + "currency_id" => "BRL", + "unit_price" => 10.5 + ] + ]; + + $preference->items = $items; + $preference->notification_url = "notification_url"; + $preference->external_reference = "external_reference"; + + $preference->save(); ``` -## Criando uma preferência +## Consultando uma notificação + +O parâmetro para consulta deve seguir o modelo abaixo: + +`P-{idPayment}` ```php getNotificationInstance(); + + $notification->read(array("id" => "P-1316643861")); -$sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId' ); +``` -$preference = $sdk->getPreferenceInstance(); +## Registrando um evento no Datadog -$items = ["items" => - [ - "title" => "Dummy Title", - "description" => "Dummy description", - "picture_url" => "http://www.myapp.com/myimage.jpg", - "category_id" => "car_electronics", - "quantity" => 1, - "currency_id" => "BRL", - "unit_price" => 10.5 - ] - ]; +```php +getDatadogEventInstance(); + + $details = [ + "payment_id" => "123456" + ]; + + $datadogEvent->value = "success"; + $datadogEvent->message = "mensagem vinda do teste de integração da SDK de PHP"; + $datadogEvent->plugin_version = "1.0.0"; + $datadogEvent->platform->name = "core"; + $datadogEvent->platform->version = "1.2.0"; + $datadogEvent->platform->uri = "/integration_test"; + $datadogEvent->platform->url = "https://..."; + $datadogEvent->details = $details; + + $datadogEvent->register(array("team" => "core", "event_type"=> "unit_test")); + +``` -$preference->items = $items; -$preference->notification_url = "notification_url"; -$preference->external_reference = "external_reference"; +## Registrando um log de erro -$preference->save(); +```php +getRegisterErrorLogInstance(); + + $registerErrorLog->message = 'Sample error message'; + $registerErrorLog->stacktrace = 'monitoring_regiter_log.php'; + $registerErrorLog->location = 'registerErrorLog'; + $registerErrorLog->platform_version = phpversion(); + $registerErrorLog->module_version = "1.0.0"; + $registerErrorLog->user_agent = 'PHP SDK'; + $registerErrorLog->flow = 'sample-php-sdk'; + $registerErrorLog->runtime_version = phpversion(); + $registerErrorLog->os_version = "10"; + $registerErrorLog->browser_version = "Chrome"; + $registerErrorLog->uri = 'http://localhost'; + $registerErrorLog->url = 'http://localhost'; + $registerErrorLog->details = [ + 'payment_id' => '123456789', + ]; + + $registerErrorLog->save(); + +``` +## Obtendo métodos de pagamento + +```php +getPaymentMethodsInstance(); + + $paymentMethods->getPaymentMethodsByGroupBy('id'); + ``` -## Consultando uma notificação +## Obtendo métodos de pagamento agrupados -O parâmetro para consulta deve seguir o modelo abaixo: +Exemplo de requisição agrupando os meios de pagamento pelo campo id: -`P-{idPayment}` +```php +getPaymentMethodsInstance(); + + $paymentMethods->getPaymentMethodsByGroupBy('id'); + +``` + +## Obtendo todas as Merchant Orders de acordo com o access token ```php "; + print_r($value); + echo ""; + } + + $sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey' ); -$sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId' ); + $merchantOrder = $sdk->getMerchantOrderInstance(); -$notification = $sdk->getNotificationInstance(); + debug(json_encode($merchantOrder->getMerchantOrders())); + +``` + +## Criando um novo id de integração para funil -$notification->read(array("id" => "P-1316643861")); +```php +"; + print_r($value); + echo ""; + } + + $sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey' ); + + $createSellerFunnelBase = $sdk->getCreateSellerFunnelBaseInstance(); + + $createSellerFunnelBase->platform_id = "123"; + $createSellerFunnelBase->shop_url = "http://localhost"; + $createSellerFunnelBase->platform_version = "1.0.0"; + $createSellerFunnelBase->plugin_version = "1.0.0"; + $createSellerFunnelBase->site_id = "MLB"; + + $response = $createSellerFunnelBase->save(); + + $response->id + $response->cpp_token + ``` -## Registrando um erro no Melidata +## Atualizando um id de integração para funil ```php getMelidataErrorInstance(); - -$details = [ - "payment_id" => "123456" -]; - -$melidataError->name = "nome do erro"; -$melidataError->message = "mensagem do erro"; -$melidataError->target = "error_name"; -$melidataError->plugin->version = "error_name"; -$melidataError->platform->name = "error_name"; -$melidataError->platform->version = "error_name"; -$melidataError->platform->uri = "error_name"; -$melidataError->platform->location = "error_name"; -$melidataError->details = $details; - -$melidataError->registerError(); + + use MercadoPago\PP\Sdk\Sdk; + + require_once(__DIR__ . '/vendor/autoload.php'); + + function debug($value){ + echo "
";
+        print_r($value);
+        echo "
"; + } + + $sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey' ); + + $updateSellerFunnelBase = $sdk->getUpdateSellerFunnelBaseInstance(); + + $updateSellerFunnelBase->id = "id"; + $updateSellerFunnelBase->cpp_token = "token"; + $updateSellerFunnelBase->is_added_production_credential = true; + $updateSellerFunnelBase->is_added_test_credential = true; + $updateSellerFunnelBase->product_id = "4das56"; + $updateSellerFunnelBase->cust_id = "123"; + $updateSellerFunnelBase->application_id = "123"; + $updateSellerFunnelBase->plugin_mode = "prod"; + $updateSellerFunnelBase->is_deleted = false; + $updateSellerFunnelBase->accepted_payments = ["bolbradesco", "pix"]; + $updateSellerFunnelBase->is_disabled = false; + + debug(json_encode($updateSellerFunnelBase->update())); ``` ## Executando os testes de Integração -Os testes de integração se encontram em tests/integration, para executa-los é necessário efetuar uma copia do arquivo .env.sample -que está na raiz do projeto e criar um .env também na raiz do projeto, feito isso, você deve popular os valores dentro do .env +Os testes de integração se encontram em tests/integration, para executa-los é necessário efetuar uma copia do arquivo +.env.sample +que está na raiz do projeto e criar um .env também na raiz do projeto, feito isso, você deve popular os valores dentro +do .env -Documentação dos testes integrados: https://mercadolibre.atlassian.net/wiki/spaces/PLU/pages/2280065838/Testes+Integrados+pp-php-sdk \ No newline at end of file +Documentação dos testes +integrados: https://mercadolibre.atlassian.net/wiki/spaces/PLU/pages/2280065838/Testes+Integrados+pp-php-sdk \ No newline at end of file diff --git a/packages/sdk/composer.json b/packages/sdk/composer.json index 3fc24aaf7..732d85af5 100644 --- a/packages/sdk/composer.json +++ b/packages/sdk/composer.json @@ -1,11 +1,12 @@ { "name": "mp-plugins/php-sdk", "description": "Mercado Pago Plugins PHP-SDK", - "version": "1.9.0", + "version": "2.10.0", "type": "library", "scripts": { "lint": "./vendor/bin/phpcs -q --report=checkstyle --standard=PSR2 src", - "test": "./vendor/bin/phpunit --coverage-html coverage --coverage-clover clover.xml --coverage-text --testdox --colors=auto --testsuite pp-php-sdk-unit" + "test": "./vendor/bin/phpunit --coverage-html coverage --coverage-clover clover.xml --coverage-text --testdox --colors=auto --testsuite pp-php-sdk-unit", + "integration-test": "./vendor/bin/phpunit --testsuite pp-php-sdk-integration" }, "autoload": { "psr-4": { diff --git a/packages/sdk/composer.lock b/packages/sdk/composer.lock index c1d578125..e7bbc9c64 100644 --- a/packages/sdk/composer.lock +++ b/packages/sdk/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "4c940e148ff5a1c8952b10d40155151b", + "content-hash": "8c432eac2a4431d0a5d89ceaec1b261b", "packages": [], "packages-dev": [ { @@ -138,21 +138,21 @@ }, { "name": "nikic/php-parser", - "version": "v4.18.0", + "version": "v4.19.1", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999" + "reference": "4e1b88d21c69391150ace211e9eaf05810858d0b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/1bcbb2179f97633e98bbbc87044ee2611c7d7999", - "reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/4e1b88d21c69391150ace211e9eaf05810858d0b", + "reference": "4e1b88d21c69391150ace211e9eaf05810858d0b", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": ">=7.0" + "php": ">=7.1" }, "require-dev": { "ircmaxell/php-yacc": "^0.0.7", @@ -188,26 +188,27 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.18.0" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.19.1" }, - "time": "2023-12-10T21:03:43+00:00" + "time": "2024-03-17T08:10:35+00:00" }, { "name": "phar-io/manifest", - "version": "2.0.3", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/phar-io/manifest.git", - "reference": "97803eca37d319dfa7826cc2437fc020857acb53" + "reference": "54750ef60c58e43759730615a392c31c80e23176" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53", - "reference": "97803eca37d319dfa7826cc2437fc020857acb53", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/54750ef60c58e43759730615a392c31c80e23176", + "reference": "54750ef60c58e43759730615a392c31c80e23176", "shasum": "" }, "require": { "ext-dom": "*", + "ext-libxml": "*", "ext-phar": "*", "ext-xmlwriter": "*", "phar-io/version": "^3.0.1", @@ -248,9 +249,15 @@ "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", "support": { "issues": "https://github.com/phar-io/manifest/issues", - "source": "https://github.com/phar-io/manifest/tree/2.0.3" + "source": "https://github.com/phar-io/manifest/tree/2.0.4" }, - "time": "2021-07-20T11:28:43+00:00" + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2024-03-03T12:33:53+00:00" }, { "name": "phar-io/version", @@ -305,23 +312,23 @@ }, { "name": "phpunit/php-code-coverage", - "version": "9.2.29", + "version": "9.2.31", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "6a3a87ac2bbe33b25042753df8195ba4aa534c76" + "reference": "48c34b5d8d983006bd2adc2d0de92963b9155965" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/6a3a87ac2bbe33b25042753df8195ba4aa534c76", - "reference": "6a3a87ac2bbe33b25042753df8195ba4aa534c76", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/48c34b5d8d983006bd2adc2d0de92963b9155965", + "reference": "48c34b5d8d983006bd2adc2d0de92963b9155965", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.15", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=7.3", "phpunit/php-file-iterator": "^3.0.3", "phpunit/php-text-template": "^2.0.2", @@ -371,7 +378,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.29" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.31" }, "funding": [ { @@ -379,7 +386,7 @@ "type": "github" } ], - "time": "2023-09-19T04:57:46+00:00" + "time": "2024-03-02T06:37:42+00:00" }, { "name": "phpunit/php-file-iterator", @@ -726,16 +733,16 @@ }, { "name": "sebastian/cli-parser", - "version": "1.0.1", + "version": "1.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/cli-parser.git", - "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2" + "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/442e7c7e687e42adc03470c7b668bc4b2402c0b2", - "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/2b56bea83a09de3ac06bb18b92f068e60cc6f50b", + "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b", "shasum": "" }, "require": { @@ -770,7 +777,7 @@ "homepage": "https://github.com/sebastianbergmann/cli-parser", "support": { "issues": "https://github.com/sebastianbergmann/cli-parser/issues", - "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.1" + "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.2" }, "funding": [ { @@ -778,7 +785,7 @@ "type": "github" } ], - "time": "2020-09-28T06:08:49+00:00" + "time": "2024-03-02T06:27:43+00:00" }, { "name": "sebastian/code-unit", @@ -967,20 +974,20 @@ }, { "name": "sebastian/complexity", - "version": "2.0.2", + "version": "2.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/complexity.git", - "reference": "739b35e53379900cc9ac327b2147867b8b6efd88" + "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/739b35e53379900cc9ac327b2147867b8b6efd88", - "reference": "739b35e53379900cc9ac327b2147867b8b6efd88", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/25f207c40d62b8b7aa32f5ab026c53561964053a", + "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a", "shasum": "" }, "require": { - "nikic/php-parser": "^4.7", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=7.3" }, "require-dev": { @@ -1012,7 +1019,7 @@ "homepage": "https://github.com/sebastianbergmann/complexity", "support": { "issues": "https://github.com/sebastianbergmann/complexity/issues", - "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.2" + "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.3" }, "funding": [ { @@ -1020,20 +1027,20 @@ "type": "github" } ], - "time": "2020-10-26T15:52:27+00:00" + "time": "2023-12-22T06:19:30+00:00" }, { "name": "sebastian/diff", - "version": "4.0.5", + "version": "4.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131" + "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/74be17022044ebaaecfdf0c5cd504fc9cd5a7131", - "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/ba01945089c3a293b01ba9badc29ad55b106b0bc", + "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc", "shasum": "" }, "require": { @@ -1078,7 +1085,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/diff/issues", - "source": "https://github.com/sebastianbergmann/diff/tree/4.0.5" + "source": "https://github.com/sebastianbergmann/diff/tree/4.0.6" }, "funding": [ { @@ -1086,7 +1093,7 @@ "type": "github" } ], - "time": "2023-05-07T05:35:17+00:00" + "time": "2024-03-02T06:30:58+00:00" }, { "name": "sebastian/environment", @@ -1153,16 +1160,16 @@ }, { "name": "sebastian/exporter", - "version": "4.0.5", + "version": "4.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d" + "reference": "78c00df8f170e02473b682df15bfcdacc3d32d72" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", - "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/78c00df8f170e02473b682df15bfcdacc3d32d72", + "reference": "78c00df8f170e02473b682df15bfcdacc3d32d72", "shasum": "" }, "require": { @@ -1218,7 +1225,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/exporter/issues", - "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.5" + "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.6" }, "funding": [ { @@ -1226,20 +1233,20 @@ "type": "github" } ], - "time": "2022-09-14T06:03:37+00:00" + "time": "2024-03-02T06:33:00+00:00" }, { "name": "sebastian/global-state", - "version": "5.0.6", + "version": "5.0.7", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "bde739e7565280bda77be70044ac1047bc007e34" + "reference": "bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bde739e7565280bda77be70044ac1047bc007e34", - "reference": "bde739e7565280bda77be70044ac1047bc007e34", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9", + "reference": "bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9", "shasum": "" }, "require": { @@ -1282,7 +1289,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/global-state/issues", - "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.6" + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.7" }, "funding": [ { @@ -1290,24 +1297,24 @@ "type": "github" } ], - "time": "2023-08-02T09:26:13+00:00" + "time": "2024-03-02T06:35:11+00:00" }, { "name": "sebastian/lines-of-code", - "version": "1.0.3", + "version": "1.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/lines-of-code.git", - "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc" + "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/c1c2e997aa3146983ed888ad08b15470a2e22ecc", - "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/e1e4a170560925c26d424b6a03aed157e7dcc5c5", + "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5", "shasum": "" }, "require": { - "nikic/php-parser": "^4.6", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=7.3" }, "require-dev": { @@ -1339,7 +1346,7 @@ "homepage": "https://github.com/sebastianbergmann/lines-of-code", "support": { "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", - "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.3" + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.4" }, "funding": [ { @@ -1347,7 +1354,7 @@ "type": "github" } ], - "time": "2020-11-28T06:42:11+00:00" + "time": "2023-12-22T06:20:34+00:00" }, { "name": "sebastian/object-enumerator", @@ -1526,16 +1533,16 @@ }, { "name": "sebastian/resource-operations", - "version": "3.0.3", + "version": "3.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8" + "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", - "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/05d5692a7993ecccd56a03e40cd7e5b09b1d404e", + "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e", "shasum": "" }, "require": { @@ -1547,7 +1554,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-main": "3.0-dev" } }, "autoload": { @@ -1568,8 +1575,7 @@ "description": "Provides a list of PHP built-in functions that operate on resources", "homepage": "https://www.github.com/sebastianbergmann/resource-operations", "support": { - "issues": "https://github.com/sebastianbergmann/resource-operations/issues", - "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3" + "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.4" }, "funding": [ { @@ -1577,7 +1583,7 @@ "type": "github" } ], - "time": "2020-09-28T06:45:17+00:00" + "time": "2024-03-14T16:00:52+00:00" }, { "name": "sebastian/type", @@ -1761,16 +1767,16 @@ }, { "name": "theseer/tokenizer", - "version": "1.2.2", + "version": "1.2.3", "source": { "type": "git", "url": "https://github.com/theseer/tokenizer.git", - "reference": "b2ad5003ca10d4ee50a12da31de12a5774ba6b96" + "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/b2ad5003ca10d4ee50a12da31de12a5774ba6b96", - "reference": "b2ad5003ca10d4ee50a12da31de12a5774ba6b96", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", + "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", "shasum": "" }, "require": { @@ -1799,7 +1805,7 @@ "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", "support": { "issues": "https://github.com/theseer/tokenizer/issues", - "source": "https://github.com/theseer/tokenizer/tree/1.2.2" + "source": "https://github.com/theseer/tokenizer/tree/1.2.3" }, "funding": [ { @@ -1807,7 +1813,7 @@ "type": "github" } ], - "time": "2023-11-20T00:12:19+00:00" + "time": "2024-03-03T12:36:25+00:00" } ], "aliases": [], @@ -1820,5 +1826,5 @@ "ext-json": "*" }, "platform-dev": [], - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.1.0" } diff --git a/packages/sdk/examples/Multipayment.php b/packages/sdk/examples/Multipayment.php index cc8e8c4b0..00b8ac6b9 100644 --- a/packages/sdk/examples/Multipayment.php +++ b/packages/sdk/examples/Multipayment.php @@ -10,8 +10,8 @@ function debug($value){ echo ""; } - $sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId' ); - + $sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey' ); + //Payment with two Cards $multipayment = $sdk->getMultipaymentInstance(); diff --git a/packages/sdk/examples/createSellerFunnelBase.php b/packages/sdk/examples/createSellerFunnelBase.php new file mode 100644 index 000000000..8ab7daf49 --- /dev/null +++ b/packages/sdk/examples/createSellerFunnelBase.php @@ -0,0 +1,25 @@ +"; + print_r($value); + echo ""; + } + + $sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey' ); + + $createSellerFunnelBase = $sdk->getCreateSellerFunnelBaseInstance(); + + $createSellerFunnelBase->platform_id = "123"; + $createSellerFunnelBase->shop_url = "http://localhost"; + $createSellerFunnelBase->platform_version = "1.0.0"; + $createSellerFunnelBase->plugin_version = "1.0.0"; + $createSellerFunnelBase->site_id = "MLB"; + + debug(json_encode($createSellerFunnelBase->save())); + ?> + \ No newline at end of file diff --git a/packages/sdk/examples/datadog_event.php b/packages/sdk/examples/datadog_event.php new file mode 100644 index 000000000..34ba6cf14 --- /dev/null +++ b/packages/sdk/examples/datadog_event.php @@ -0,0 +1,32 @@ +"; + print_r($value); + echo ""; + } + + $sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey' ); + + $datadogEvent = $sdk->getDatadogEventInstance(); + + $details = [ + "payment_id" => "123456" + ]; + + $datadogEvent->value = "success"; + $datadogEvent->message = "mensagem vinda do teste de integração da SDK de PHP"; + $datadogEvent->plugin_version = "1.0.0"; + $datadogEvent->platform->name = "core"; + $datadogEvent->platform->version = "1.2.0"; + $datadogEvent->platform->uri = "/integration_test"; + $datadogEvent->platform->url = "https://..."; + $datadogEvent->details = $details; + + debug(json_encode($datadogEvent->register(array("team" => "core", "event_type"=> "unit_test")))); + ?> + \ No newline at end of file diff --git a/packages/sdk/examples/groupedPaymentMethods.php b/packages/sdk/examples/groupedPaymentMethods.php new file mode 100644 index 000000000..676f9ee14 --- /dev/null +++ b/packages/sdk/examples/groupedPaymentMethods.php @@ -0,0 +1,20 @@ +"; + print_r($value); + echo ""; + } + + $sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey' ); + + $paymentMethods = $sdk->getPaymentMethodsInstance(); + + debug(json_encode($paymentMethods->getPaymentMethodsByGroupBy('id'))); + + ?> + \ No newline at end of file diff --git a/packages/sdk/examples/melidata_error.php b/packages/sdk/examples/melidata_error.php deleted file mode 100644 index 4fa1a0fd0..000000000 --- a/packages/sdk/examples/melidata_error.php +++ /dev/null @@ -1,33 +0,0 @@ -"; - print_r($value); - echo ""; - } - - $sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId' ); - - $melidataError = $sdk->getMelidataErrorInstance(); - - $details = [ - "payment_id" => "123456" - ]; - - $melidataError->name = "nome do erro"; - $melidataError->message = "mensagem do erro"; - $melidataError->target = "error_name"; - $melidataError->plugin->version = "error_name"; - $melidataError->platform->name = "error_name"; - $melidataError->platform->version = "error_name"; - $melidataError->platform->uri = "error_name"; - $melidataError->platform->location = "error_name"; - $melidataError->details = $details; - - debug(json_encode($melidataError->registerError())); - ?> - \ No newline at end of file diff --git a/packages/sdk/examples/merchantOrder.php b/packages/sdk/examples/merchantOrder.php new file mode 100644 index 000000000..0dd8393e9 --- /dev/null +++ b/packages/sdk/examples/merchantOrder.php @@ -0,0 +1,17 @@ +"; + print_r($value); + echo ""; + } + + $sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey' ); + + $merchantOrder = $sdk->getMerchantOrderInstance(); + + debug(json_encode($merchantOrder->getMerchantOrders())); +?> diff --git a/packages/sdk/examples/monitoring_register_log.php b/packages/sdk/examples/monitoring_register_log.php new file mode 100644 index 000000000..99034550b --- /dev/null +++ b/packages/sdk/examples/monitoring_register_log.php @@ -0,0 +1,35 @@ +"; + print_r($value == "null" ? "Success!" : $value); + echo ""; + } + + $sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey' ); + + $registerErrorLog = $sdk->getRegisterErrorLogInstance(); + + $registerErrorLog->message = 'Sample error message'; + $registerErrorLog->stacktrace = 'monitoring_regiter_log.php'; + $registerErrorLog->location = 'save'; + $registerErrorLog->platform_version = phpversion(); + $registerErrorLog->module_version = "1.0.0"; + $registerErrorLog->user_agent = 'PHP SDK'; + $registerErrorLog->flow = 'sample-php-sdk'; + $registerErrorLog->runtime_version = phpversion(); + $registerErrorLog->os_version = "10"; + $registerErrorLog->browser_version = "Chrome"; + $registerErrorLog->uri = 'http://localhost'; + $registerErrorLog->url = 'http://localhost'; + $registerErrorLog->details = [ + 'payment_id' => '123456789', + ]; + + debug(json_encode($registerErrorLog->save())); +?> \ No newline at end of file diff --git a/packages/sdk/examples/notification.php b/packages/sdk/examples/notification.php index 399992ba5..caffd29f2 100644 --- a/packages/sdk/examples/notification.php +++ b/packages/sdk/examples/notification.php @@ -10,7 +10,7 @@ function debug($value){ echo ""; } - $sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId' ); + $sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey' ); $notification = $sdk->getNotificationInstance(); diff --git a/packages/sdk/examples/payment.php b/packages/sdk/examples/payment.php index 1177857b5..2acbcf6c0 100644 --- a/packages/sdk/examples/payment.php +++ b/packages/sdk/examples/payment.php @@ -10,7 +10,7 @@ function debug($value){ echo ""; } - $sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId' ); + $sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey' ); $payment = $sdk->getPaymentInstance(); @@ -25,5 +25,9 @@ function debug($value){ debug(json_encode($payment->save())); + //Get Payment + debug(json_encode($payment->read(array( + "id" => $payment->id, + )))); ?> \ No newline at end of file diff --git a/packages/sdk/examples/paymentMethods.php b/packages/sdk/examples/paymentMethods.php new file mode 100644 index 000000000..61197d690 --- /dev/null +++ b/packages/sdk/examples/paymentMethods.php @@ -0,0 +1,19 @@ +"; + print_r($value); + echo ""; + } + + $sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey' ); + + $paymentMethods = $sdk->getPaymentMethodsInstance(); + + debug(json_encode($paymentMethods->getPaymentMethodsByGroupBy('id'))); + ?> + \ No newline at end of file diff --git a/packages/sdk/examples/payment_3ds.php b/packages/sdk/examples/payment_3ds.php index d9bda67c5..9447f64ea 100644 --- a/packages/sdk/examples/payment_3ds.php +++ b/packages/sdk/examples/payment_3ds.php @@ -11,7 +11,7 @@ function debug($value){ echo ""; } - $sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId' ); + $sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey' ); $payment = $sdk->getPaymentInstance(); diff --git a/packages/sdk/examples/preference.php b/packages/sdk/examples/preference.php index 93ac2f14a..ad715b226 100644 --- a/packages/sdk/examples/preference.php +++ b/packages/sdk/examples/preference.php @@ -10,7 +10,7 @@ function debug($value){ echo ""; } - $sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId' ); + $sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey' ); $preference = $sdk->getPreferenceInstance(); diff --git a/packages/sdk/examples/updateSellerFunnelBase.php b/packages/sdk/examples/updateSellerFunnelBase.php new file mode 100644 index 000000000..2d6f834ba --- /dev/null +++ b/packages/sdk/examples/updateSellerFunnelBase.php @@ -0,0 +1,31 @@ +"; + print_r($value); + echo ""; + } + + $sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey' ); + + $updateSellerFunnelBase = $sdk->getUpdateSellerFunnelBaseInstance(); + + $updateSellerFunnelBase->id = "id"; + $updateSellerFunnelBase->cpp_token = "token"; + $updateSellerFunnelBase->is_added_production_credential = true; + $updateSellerFunnelBase->is_added_test_credential = true; + $updateSellerFunnelBase->product_id = "4das56"; + $updateSellerFunnelBase->cust_id = "123"; + $updateSellerFunnelBase->application_id = "123"; + $updateSellerFunnelBase->plugin_mode = "prod"; + $updateSellerFunnelBase->is_deleted = false; + $updateSellerFunnelBase->accepted_payments = ["bolbradesco", "pix"]; + $updateSellerFunnelBase->is_disabled = false; + + debug(json_encode($updateSellerFunnelBase->update())); + ?> + \ No newline at end of file diff --git a/packages/sdk/src/Common/AbstractEntity.php b/packages/sdk/src/Common/AbstractEntity.php index 8c17fbf15..70ddceca2 100644 --- a/packages/sdk/src/Common/AbstractEntity.php +++ b/packages/sdk/src/Common/AbstractEntity.php @@ -152,12 +152,17 @@ public function toArray(): array * Read method (GET). * * @param array $params + * @param array $queryStrings + * @param bool $shouldTheExpectedResponseBeMappedOntoTheEntity * * @return mixed * @throws \Exception */ - public function read(array $params = []) - { + public function read( + array $params = [], + array $queryStrings = [], + bool $shouldTheExpectedResponseBeMappedOntoTheEntity = true + ) { $method = 'get'; $class = get_called_class(); $entity = new $class($this->manager); @@ -165,10 +170,33 @@ public function read(array $params = []) $customHeaders = $this->getHeaders()['read']; $header = $this->manager->getHeader($customHeaders); - $uri = $this->manager->getEntityUri($entity, $method, $params); + $uri = $this->manager->getEntityUri($entity, $method, $params, $queryStrings); $response = $this->manager->execute($entity, $uri, $method, $header); $this->obfuscateAuthorizationHeader($header); - return $this->manager->handleResponse($response, $method, $entity); + return $this->manager->handleResponse( + $response, + $method, + $shouldTheExpectedResponseBeMappedOntoTheEntity ? $entity : null + ); + } + + /** + * Save method (PUT). + * + * @return mixed + * @throws \Exception + */ + public function update() + { + $method = 'put'; + + $customHeaders = $this->getHeaders()['update']; + $header = $this->manager->getHeader($customHeaders); + + $uri = $this->manager->getEntityUri($this, $method); + $response = $this->manager->execute($this, $uri, $method, $header); + $this->obfuscateAuthorizationHeader($header); + return $this->manager->handleResponse($response, $method); } /** @@ -190,6 +218,46 @@ public function save() return $this->manager->handleResponse($response, $method); } + /** + * Save method (POST). + * + * @return mixed + * @throws \Exception + */ + public function saveWithResponseHeaders() + { + $method = 'post'; + + $customHeaders = $this->getHeaders()['save']; + $header = $this->manager->getHeader($customHeaders); + + $uri = $this->manager->getEntityUri($this, $method); + $response = $this->manager->execute($this, $uri, $method, $header); + $this->obfuscateAuthorizationHeader($header); + return $this->manager->handleResponseWithHeaders($response); + } + + /** + * Save method with params (POST). + * + * @param array $params + * @param array $queryStrings + * + * @return mixed + * @throws \Exception + */ + public function saveWithParams(array $params = [], array $queryStrings = []) + { + $method = 'post'; + $customHeaders = $this->getHeaders()['save']; + $header = $this->manager->getHeader($customHeaders); + + $uri = $this->manager->getEntityUri($this, $method, $params, $queryStrings); + $response = $this->manager->execute($this, $uri, $method, $header); + $this->obfuscateAuthorizationHeader($header); + return $this->manager->handleResponse($response, $method); + } + /** * @return array */ @@ -215,7 +283,7 @@ public function setExcludedProperties() */ public function obfuscateAuthorizationHeader(array $headers) { - Sdk::$cache['last_headers'] = preg_replace('/(Authorization: Bearer) (.*)/i', '$1 xxx', $headers); + Sdk::$cache['last_headers'] = preg_replace('/(Authorization:) (.*)/i', '$1 xxx', $headers); } /** diff --git a/packages/sdk/src/Common/Config.php b/packages/sdk/src/Common/Config.php index 85b1caff4..6d62ca82a 100644 --- a/packages/sdk/src/Common/Config.php +++ b/packages/sdk/src/Common/Config.php @@ -29,6 +29,11 @@ class Config */ private $integrator_id; + /** + * @var string + */ + private $public_key; + /** * Config constructor. * @@ -36,17 +41,20 @@ class Config * @param string|null $platform_id * @param string|null $product_id * @param string|null $integrator_id + * @param string|null $public_key */ public function __construct( string $access_token = null, string $platform_id = null, string $product_id = null, - string $integrator_id = null + string $integrator_id = null, + string $public_key = null ) { $this->access_token = $access_token; $this->platform_id = $platform_id; $this->product_id = $product_id; $this->integrator_id = $integrator_id; + $this->public_key = $public_key; } /** diff --git a/packages/sdk/src/Common/Manager.php b/packages/sdk/src/Common/Manager.php index fa0302b41..360e0a566 100644 --- a/packages/sdk/src/Common/Manager.php +++ b/packages/sdk/src/Common/Manager.php @@ -64,7 +64,7 @@ public function execute(AbstractEntity $entity, string $uri, string $method = 'g * @return mixed * @throws \Exception */ - public function getEntityUri(AbstractEntity $entity, string $method, array $params = []) + public function getEntityUri(AbstractEntity $entity, string $method, array $params = [], array $queryStrings = []) { if (method_exists($entity, 'getUris')) { $uri = $entity->getUris()[$method]; @@ -82,6 +82,9 @@ public function getEntityUri(AbstractEntity $entity, string $method, array $para $uri = str_replace($match, '', $uri); } } + if (count($queryStrings) > 0) { + $uri = $uri . '?' . http_build_query($queryStrings); + } return $uri; } else { @@ -97,13 +100,27 @@ public function getEntityUri(AbstractEntity $entity, string $method, array $para public function getDefaultHeader(): array { return [ - 'Authorization: Bearer ' . $this->config->__get('access_token'), - 'x-platform-id: ' . $this->config->__get('platform_id'), - 'x-product-id: ' . $this->config->__get('product_id'), - 'x-integrator-id: ' . $this->config->__get('integrator_id') + 'Authorization' => 'Bearer ' . $this->config->__get('access_token'), + 'x-platform-id' => $this->config->__get('platform_id'), + 'x-product-id' => $this->config->__get('product_id'), + 'x-integrator-id' => $this->config->__get('integrator_id') ]; } + /** + * Normalize headers + * + * @return array + */ + public function normalizeHeaders(array $unnormalizedHeaders): array + { + $normalizedHeaders = []; + foreach ($unnormalizedHeaders as $key => $value) { + array_push($normalizedHeaders, $key . ': ' . $value); + } + return $normalizedHeaders; + } + /** * Get header * @param array $customHeaders @@ -113,7 +130,54 @@ public function getDefaultHeader(): array public function getHeader(array $customHeaders = []): array { $defaultHeaders = $this->getDefaultHeader(); - return array_merge($defaultHeaders, $customHeaders); + if (count($customHeaders) > 0 && !$this->isHeadersAsKeyAndValueMap($customHeaders)) { + $customHeaders = $this->setHeadersAsKeyAndValueMap($customHeaders); + }; + return $this->normalizeHeaders(array_merge($defaultHeaders, $customHeaders)); + } + + /** + * Get header + * + * If the format of the customHeaders passed is like `array('x-header: 123abc')`, + * the method will convert the customHeaders to + * follow format: `array('x-header' => '123abc')` and return the converted customHeaders. + * + * @param array $customHeaders + * + * @return array + */ + public function setHeadersAsKeyAndValueMap(array $customHeaders = []): array + { + $headersAsKeyAndValueMap = []; + + foreach ($customHeaders as $header) { + [$headerKey, $headerValue] = explode(":", $header); + $headersAsKeyAndValueMap[trim($headerKey)] = trim($headerValue); + } + return $headersAsKeyAndValueMap; + } + + /** + * Checks if the header is in key and value format + * + * If the format of the customHeader passed is like `array('x-header: 123abc')`, the method will return false + * Otherwise, if the format of the customHeader passed is like `array('x-header' => '123abc')`, + * the method will return true + * + * @param array $customHeaders + * + * @return bool + */ + public function isHeadersAsKeyAndValueMap(array $customHeaders = []): bool + { + foreach ($customHeaders as $i => $value) { + if (is_int($i)) { + return false; + } + return true; + } + return false; } /** @@ -141,4 +205,34 @@ public function handleResponse(Response $response, string $method, AbstractEntit throw new \Exception("Internal API Error"); } } + + /** + * Handle response + * + * @param Response $response + * @param string $method + * @param AbstractEntity|null $entity + * + * @return mixed + * @throws \Exception + */ + public function handleResponseWithHeaders(Response $response) + { + if ($response->getStatus() == '200' || $response->getStatus() == '201') { + return $response; + } elseif (intval($response->getStatus()) >= 400 && intval($response->getStatus()) < 500) { + $message = $response->getData()['message'] ?? 'No message for Multipayment scenario in v1!'; + throw new \Exception($message); + } else { + throw new \Exception("Internal API Error"); + } + } + + /** + * Get config + */ + public function getConfig(): Config + { + return $this->config; + } } diff --git a/packages/sdk/src/Entity/Identification/CreateSellerFunnelBase.php b/packages/sdk/src/Entity/Identification/CreateSellerFunnelBase.php new file mode 100644 index 000000000..ff00cafe1 --- /dev/null +++ b/packages/sdk/src/Entity/Identification/CreateSellerFunnelBase.php @@ -0,0 +1,110 @@ + [] + ]; + } + + /** + * Get uris. + * + * @return array + */ + public function getUris(): array + { + return array( + 'post' => '/v1/eplatforms/core/identification/seller-configuration/start-integration', + ); + } + + /** + * When invoking this method, a request is made to the ag-Identification API + * using shop_url and platform_id the api will return a new integration id + * + * @return ResponseCreateSellerFunnelBase return new id and x-cpp-token in header of response. + * + * @throws \Exception Throws an exception if something goes wrong during the save operation. + */ + public function save(array $params = []) + { + $response = parent::saveWithResponseHeaders(); + + return $this->buildResponseSellerFunnelBase($response); + } + + /** + * responsible for parsing the response made by the request and standardizing it into a response class + * + * @param Response $response + */ + private function buildResponseSellerFunnelBase(Response $response) + { + if ($response->getStatus() ==! 201) { + return $response; + } + $responseBody = json_decode(json_encode($response->getData())); + $responseHeader = $response->getHeaders(); + + return new ResponseCreateSellerFunnelBase($responseBody->id, $responseHeader["x-cpp-token"]); + } +} diff --git a/packages/sdk/src/Entity/Identification/ResponseCreateSellerFunnelBase.php b/packages/sdk/src/Entity/Identification/ResponseCreateSellerFunnelBase.php new file mode 100644 index 000000000..4b3a95daf --- /dev/null +++ b/packages/sdk/src/Entity/Identification/ResponseCreateSellerFunnelBase.php @@ -0,0 +1,37 @@ +id = $id; + $this->cpp_token = $cpp_token; + } +} diff --git a/packages/sdk/src/Entity/Identification/UpdateSellerFunnelBase.php b/packages/sdk/src/Entity/Identification/UpdateSellerFunnelBase.php new file mode 100644 index 000000000..3bac5cf51 --- /dev/null +++ b/packages/sdk/src/Entity/Identification/UpdateSellerFunnelBase.php @@ -0,0 +1,132 @@ +excluded_properties = ['cpp_token']; + } + + /** + * Get and set custom headers for entity. + * + * @return array + */ + public function getHeaders(): array + { + return [ + 'update' => ['x-cpp-token: ' . $this->cpp_token], + ]; + } + + /** + * Get uris. + * + * @return array + */ + public function getUris(): array + { + return array( + 'put' => '/v1/eplatforms/core/identification/seller-configuration/update-integration', + ); + } + + /** + * When invoking this method, a request is made to the ag-Identification API + * using shop_url and platform_id the api will return a new integration id + * + * @return mixed return new id and field success in boolean. + * + * @throws \Exception Throws an exception if something goes wrong during the save operation. + */ + public function update(array $params = []) + { + return parent::update(); + } +} diff --git a/packages/sdk/src/Entity/MerchantOrder/Collector.php b/packages/sdk/src/Entity/MerchantOrder/Collector.php new file mode 100644 index 000000000..f91bcdd92 --- /dev/null +++ b/packages/sdk/src/Entity/MerchantOrder/Collector.php @@ -0,0 +1,32 @@ +excluded_properties = []; + } + + /** + * Get and set custom headers for entity. + * + * @return array + */ + public function getHeaders(): array + { + return [ + 'read' => [], + ]; + } + + /** + * Get uris. + * + * @return array + */ + public function getUris(): array + { + return array( + 'get' => '/merchant_orders/:id' + ); + } + + /** + * Returns all Merchant Orders linked to the provided access token + * + * Upon invoking this method, a request is made to the Merchant Orders API. + * Authentication is performed using the seller's access token, which should + * be previously configured in the default headers. + * + * @return MerchantOrder[] List of Merchant Orders linked to the provided access token. + * + * @throws \Exception Throws an exception if something goes wrong during the read operation. + */ + public function getMerchantOrders() + { + $response = parent::read(['id' => ''], [], true); + + $this->elements = $response->elements; + + return $this->elements; + } + + /** + * Returns a Merchant Order by its ID + * + * Upon invoking this method, a request is made to the Merchant Orders API + * using the provided Merchant Order ID. Authentication is performed using + * the seller's access token, which should be previously configured in the default headers. + * + * @param string $id The ID of the Merchant Order to be retrieved. + * + * @return MerchantOrder The Merchant Order linked to the provided access token and ID. + * + * @throws \Exception Throws an exception if something goes wrong during the read operation. + */ + public function getMerchantOrder(string $id = null) + { + $response = parent::read(['id' => $id], [], true); + + $this->setEntity($response); + + return $this; + } +} diff --git a/packages/sdk/src/Entity/Monitoring/DatadogEvent.php b/packages/sdk/src/Entity/Monitoring/DatadogEvent.php new file mode 100644 index 000000000..fa94e8e9b --- /dev/null +++ b/packages/sdk/src/Entity/Monitoring/DatadogEvent.php @@ -0,0 +1,123 @@ +platform = new Platform($manager); + } + + /** + * Exclude properties from entity building. + * + * @return void + */ + public function setExcludedProperties() + { + $this->excluded_properties = []; + } + + /** + * Get and set custom headers for entity. + * + * @return array + */ + public function getHeaders(): array + { + return [ + 'read' => [], + 'save' => [], + ]; + } + + /** + * Get uris. + * + * @return array + */ + public function getUris(): array + { + return array( + 'post' => '/ppcore/prod/monitor/v1/event/datadog/:team/:event_type', + ); + } + + /** + * Register events on Datadog using the Core Monitor service API. + * + * Once called, it receives a payload with event data and records this event + * in the metric: ppcore.event.. + * + * To execute this method, it is essential to provide the datadog_event request payload. + * + * The 'details' field receives a map where the key and value are of type string with additional + * information that needs to be tagged in Datadog according to the needs of the plugin/platform. + * This information will be tagged and made available to use in Datadog dashboards. + * + * Note: This method is inherited from the parent class but specialized for datadog_event. + * + * @param array $params Associative array containing the parameters for the register operation. + * It expects: + * - A team' key which receives the name of the team responsible for the registration. + * The available values ​​to be set in the team are: 'long', 'smb', 'big' and 'core'; + * - A 'event_type' key with the type of event that will be registered in Datadog. + * The event_type accept only the alphanumeric, underscore and the '-' characters. + * + * Example: $datadogEvent->register(array("team" => "core", "event_type" => "mp_card_form")) + * @throws \Exception Throws an exception if something goes wrong during the register operation. + */ + public function register(array $params = []) + { + return parent::saveWithParams($params); + } +} diff --git a/packages/sdk/src/Entity/Monitoring/Platform.php b/packages/sdk/src/Entity/Monitoring/Platform.php new file mode 100644 index 000000000..2c0ec2530 --- /dev/null +++ b/packages/sdk/src/Entity/Monitoring/Platform.php @@ -0,0 +1,38 @@ + [ + 'x-flow:' . (isset($this->flow) ? $this->flow : "not identified"), + ] + ]; + } + + /** + * Get uris. + * + * @return array + */ + public function getUris(): array + { + return array( + 'post' => '/ppcore/prod/monitor/v1/event/error', + ); + } + + /** + * @return void The save operation is non-blocking, + * so its response is empty returning status code 200 + */ + public function save() + { + return parent::save(); + } +} diff --git a/packages/sdk/src/Entity/Notification/Notification.php b/packages/sdk/src/Entity/Notification/Notification.php index 27a1bd5f1..828c61473 100644 --- a/packages/sdk/src/Entity/Notification/Notification.php +++ b/packages/sdk/src/Entity/Notification/Notification.php @@ -207,8 +207,11 @@ public function getUris(): array * * @throws \Exception Throws an exception if something goes wrong during the read operation. */ - public function read(array $params = []) - { - return parent::read($params); + public function read( + array $params = [], + array $queryStrings = [], + bool $shouldTheExpectedResponseBeMappedOntoTheEntity = true + ) { + return parent::read($params, $queryStrings, true); } } diff --git a/packages/sdk/src/Entity/Payment/Payment.php b/packages/sdk/src/Entity/Payment/Payment.php index f4a8e4041..6e8e62580 100644 --- a/packages/sdk/src/Entity/Payment/Payment.php +++ b/packages/sdk/src/Entity/Payment/Payment.php @@ -16,10 +16,13 @@ * taken during a payment transaction. Its main responsibility is to ensure a secure intermediation * between P&P and MercadoPago during payment creation. * + * @property int $id + * @property string $status * @property string $date_of_expiration * @property string $operation_type * @property string $issuer_id * @property string $payment_method_id + * @property string $payment_type_id * @property string $description * @property string $sponsor_id * @property string $counter_currency @@ -57,6 +60,16 @@ */ class Payment extends AbstractEntity implements RequesterEntityInterface { + /** + * @var int + */ + protected $id; + + /** + * @var string + */ + protected $status; + /** * @var string */ @@ -77,6 +90,11 @@ class Payment extends AbstractEntity implements RequesterEntityInterface */ protected $payment_method_id; + /** + * @var string + */ + protected $payment_type_id; + /** * @var string */ @@ -293,6 +311,7 @@ public function getUris(): array { return array( 'post' => '/v1/asgard/payments', + 'get' => '/v1/payments/:id' ); } @@ -333,6 +352,40 @@ public function validateThreeDSecureMode() */ public function save() { + unset($this->id); + unset($this->status); + unset($this->payment_type_id); + unset($this->transaction_details->total_paid_amount); + unset($this->transaction_details->installment_amount); + unset($this->transaction_details->external_resource_url); + unset($this->point_of_interaction->transaction_data->qr_code_base64); + unset($this->point_of_interaction->transaction_data->qr_code); return parent::save(); } + + /** + * Retrieves a Payment from the v1/payments API. + * + * Upon invoking this method, a request is made to the Payments API + * using the provided Payment ID. Authentication is performed using + * the seller's access token, which should be previously configured in the default headers. + * + * Note: This method is inherited from the parent class but specialized for Payment + * + * @param array $params Associative array containing the parameters for the read operation. + * It expects an "id" key with the Payment ID as its value. + * Example: $payment->read(['id' => '123456789']) + * + * @return mixed The result of the read operation, typically an instance of + * this Payment class populated with the retrieved data. + * + * @throws \Exception Throws an exception if something goes wrong during the read operation. + */ + public function read( + array $params = [], + array $queryStrings = [], + bool $shouldTheExpectedResponseBeMappedOntoTheEntity = true + ) { + return parent::read($params, $queryStrings, true); + } } diff --git a/packages/sdk/src/Entity/Payment/PaymentV2.php b/packages/sdk/src/Entity/Payment/PaymentV2.php index bc969f6ea..38fe412c9 100644 --- a/packages/sdk/src/Entity/Payment/PaymentV2.php +++ b/packages/sdk/src/Entity/Payment/PaymentV2.php @@ -13,6 +13,7 @@ public function getUris(): array { return array( 'post' => '/v2/asgard/payments', + 'get' => '/v1/payments/:id' ); } } diff --git a/packages/sdk/src/Entity/Payment/PaymentV21.php b/packages/sdk/src/Entity/Payment/PaymentV21.php index 4f018beb6..ff79daee4 100644 --- a/packages/sdk/src/Entity/Payment/PaymentV21.php +++ b/packages/sdk/src/Entity/Payment/PaymentV21.php @@ -13,6 +13,7 @@ public function getUris(): array { return array( 'post' => '/ppcore/prod/transaction/v21/payments', + 'get' => '/v1/payments/:id' ); } } diff --git a/packages/sdk/src/Entity/Payment/TransactionData.php b/packages/sdk/src/Entity/Payment/TransactionData.php index 9fc4c0398..ebfaf112b 100644 --- a/packages/sdk/src/Entity/Payment/TransactionData.php +++ b/packages/sdk/src/Entity/Payment/TransactionData.php @@ -19,6 +19,16 @@ class TransactionData extends AbstractEntity */ protected $bank_info; + /** + * @var string + */ + protected $qr_code_base64; + + /** + * @var string + */ + protected $qr_code; + /** * TransactionData constructor. * diff --git a/packages/sdk/src/Entity/Payment/TransactionDetails.php b/packages/sdk/src/Entity/Payment/TransactionDetails.php index 07968a9b0..702be5671 100644 --- a/packages/sdk/src/Entity/Payment/TransactionDetails.php +++ b/packages/sdk/src/Entity/Payment/TransactionDetails.php @@ -10,6 +10,9 @@ * @property string $financial_institution * @property string $bank_transfer_id * @property string $transaction_id + * @property double $total_paid_amount + * @property double $installment_amount + * @property string $external_resource_url * * @package MercadoPago\PP\Sdk\Entity\Payment */ @@ -29,4 +32,19 @@ class TransactionDetails extends AbstractEntity * @var string */ protected $transaction_id; + + /** + * @var double + */ + protected $total_paid_amount; + + /** + * @var double + */ + protected $installment_amount; + + /** + * @var string + */ + protected $external_resource_url; } diff --git a/packages/sdk/src/Entity/PaymentMethods/FinancialInstitution.php b/packages/sdk/src/Entity/PaymentMethods/FinancialInstitution.php new file mode 100644 index 000000000..a1a3adbc7 --- /dev/null +++ b/packages/sdk/src/Entity/PaymentMethods/FinancialInstitution.php @@ -0,0 +1,26 @@ +manager); + $item->setEntity($entity); + parent::addEntity($item, $key); + } +} diff --git a/packages/sdk/src/Entity/PaymentMethods/PaymentMethod.php b/packages/sdk/src/Entity/PaymentMethods/PaymentMethod.php new file mode 100644 index 000000000..0f562e463 --- /dev/null +++ b/packages/sdk/src/Entity/PaymentMethods/PaymentMethod.php @@ -0,0 +1,110 @@ +financial_institutions = new FinancialInstitutionList($manager) && []; + } +} diff --git a/packages/sdk/src/Entity/PaymentMethods/PaymentMethods.php b/packages/sdk/src/Entity/PaymentMethods/PaymentMethods.php new file mode 100644 index 000000000..50d4b940a --- /dev/null +++ b/packages/sdk/src/Entity/PaymentMethods/PaymentMethods.php @@ -0,0 +1,162 @@ +payment_methods = new PaymentMethodsList($manager); + } + + /** + * Exclude properties from entity building. + * + * @return void + */ + public function setExcludedProperties() + { + $this->excluded_properties = []; + } + + /** + * Get and set custom headers for entity. + * + * @return array + */ + public function getHeaders(): array + { + return [ + 'read' => isset($this->customHeader) ? $this->customHeader : [], + 'save' => [], + ]; + } + + /** + * Set custom headers for entity. + * + * @return array + */ + public function setCustomHeaders(array $customHeader = []) + { + return $this->customHeader = $customHeader; + } + + /** + * Get uris. + * + * @return array + */ + public function getUris(): array + { + return array( + 'get' => '/ppcore/prod/payment-methods/v1/payment-methods', + ); + } + + /** + * Returns all available {@link PaymentMethod} for a given seller. + * + * The available payment methods can include options such as credit card, boleto, bank transfer, among others. + * When making a request to fetch the payment methods, the returned object will include a list of methods + * containing detailed information about each one. + * + * Some of the included information fields are: {`name`}, {`id`}, {`payment_type_id`}, + * {`thumbnail`}, {`status`}, among others. + * + * it is necessary to send the `Authorization` header (via setCustomHeaders), + * with the public key of seller used on the app + * Example: $paymentMethods -> setCustomHeaders(array('Authorization' => $publicKey)); + * + * @return PaymentMethodsList the list with the payment methods + */ + public function getPaymentMethods() : PaymentMethodsList + { + $publicKey = $this->manager->getConfig()->__get('public_key'); + $this->setCustomHeaders(['Authorization' => $publicKey]); + $response = parent::read([], [], false); + foreach ($response as $value) { + $this->payment_methods->add($value); + } + return $this->payment_methods; + } + + /** + * Returns all available payment methods for a given seller grouped by + * one of the parameters of the response object {@link PaymentMethod}. + * + * The available payment methods can include options such as credit card, boleto, bank transfer, among others. + * When making a request to fetch the payment methods, the returned object will include a list of methods + * containing detailed information about each one. + * + * Some of the included information fields are: {`name`}, {`id`}, {`payment_type_id`}, + * {`thumbnail`}, {`status`}, among others. + * + * it is necessary to send the `Authorization` header (via setCustomHeaders), + * with the public key of seller used on the app + * Example: $paymentMethods -> setCustomHeaders(array('Authorization' => $publicKey)); + * + * @param string $groupBy the field name used to group the response result + * + * @return array: an object having as key the attribute chosen in group_by + * and as value a list of payment_method related to the grouping + */ + public function getPaymentMethodsByGroupBy(string $groupBy) + { + $publicKey = $this->manager->getConfig()->__get('public_key'); + $this->setCustomHeaders(['Authorization' => $publicKey]); + $queryStrings = array('group_by' => $groupBy); + $response = parent::read([], $queryStrings, false); + $this->grouped_payment_methods = $response; + foreach ($response as $key => $value) { + $this->grouped_payment_methods[$key] = $value; + } + return $this->grouped_payment_methods; + } +} diff --git a/packages/sdk/src/Entity/PaymentMethods/PaymentMethodsList.php b/packages/sdk/src/Entity/PaymentMethods/PaymentMethodsList.php new file mode 100644 index 000000000..d878d11ff --- /dev/null +++ b/packages/sdk/src/Entity/PaymentMethods/PaymentMethodsList.php @@ -0,0 +1,26 @@ +manager); + $item->setEntity($entity); + parent::addEntity($item, $key); + } +} diff --git a/packages/sdk/src/Entity/PaymentMethods/Platform.php b/packages/sdk/src/Entity/PaymentMethods/Platform.php new file mode 100644 index 000000000..2c0ec2530 --- /dev/null +++ b/packages/sdk/src/Entity/PaymentMethods/Platform.php @@ -0,0 +1,38 @@ + '/v1/asgard/preferences', + 'get' => '/checkout/preferences/:id' ); } @@ -229,4 +230,30 @@ public function save() { return parent::save(); } + + /** + * Retrieves a Preference from the Checkout/Preferences API. + * + * Upon invoking this method, a request is made to the Preferences API + * using the provided preference ID. Authentication is performed using + * the seller's access token, which should be previously configured in the default headers. + * + * Note: This method is inherited from the parent class but specialized for Preferences + * + * @param array $params Associative array containing the parameters for the read operation. + * It expects an "id" key with the Preference ID as its value. + * Example: $preference->read(['id' => '1093365129-96510955-ab0f-4dda-b1c1-40fcd1c3768d']) + * + * @return mixed The result of the read operation, typically an instance of + * this Preference class populated with the retrieved data. + * + * @throws \Exception Throws an exception if something goes wrong during the read operation. + */ + public function read( + array $params = [], + array $queryStrings = [], + bool $shouldTheExpectedResponseBeMappedOntoTheEntity = true + ) { + return parent::read($params, $queryStrings, true); + } } diff --git a/packages/sdk/src/HttpClient/Requester/CurlRequester.php b/packages/sdk/src/HttpClient/Requester/CurlRequester.php index 90d36e430..a1ea1da8e 100644 --- a/packages/sdk/src/HttpClient/Requester/CurlRequester.php +++ b/packages/sdk/src/HttpClient/Requester/CurlRequester.php @@ -96,9 +96,20 @@ public function createRequest(string $method, string $uri, array $headers = [], */ public function sendRequest($request): Response { + $headers = []; + $this->setOption($request, CURLOPT_HEADERFUNCTION, function ($curl, $header) use (&$headers) { + $len = strlen($header); + $header = explode(':', $header, 2); + if (count($header) < 2) { + return $len; + } + $headers[strtolower(trim($header[0]))] = trim($header[1]); + return $len; + }); + $response = new Response(); $api_result = $this->curlExec($request); - + if ($this->curlErrno($request)) { throw new \Exception($this->curlError($request)); } @@ -111,10 +122,10 @@ public function sendRequest($request): Response if (null !== $api_http_code && null !== $api_result) { $response->setStatus($api_http_code); $response->setData(json_decode($api_result, true)); + $response->setHeaders($headers); } $this->curlClose($request); - return $response; } diff --git a/packages/sdk/src/HttpClient/Response.php b/packages/sdk/src/HttpClient/Response.php index 516cedda7..a8341c878 100644 --- a/packages/sdk/src/HttpClient/Response.php +++ b/packages/sdk/src/HttpClient/Response.php @@ -26,6 +26,13 @@ class Response **/ private $data; + /** + * Response data + * + * @var array + **/ + private $headers; + /** * Response constructor. */ @@ -76,4 +83,26 @@ public function setData($data) { $this->data = $data; } + + /** + * Return the data of response + * + * @return array + **/ + public function getHeaders() + { + return $this->headers; + } + + /** + * Set the data of response + * + * @param array $headers + * + * @return void + **/ + public function setHeaders(array $headers) + { + $this->headers = $headers; + } } diff --git a/packages/sdk/src/Interfaces/RequesterEntityInterface.php b/packages/sdk/src/Interfaces/RequesterEntityInterface.php index ddb7ad073..3704e6572 100644 --- a/packages/sdk/src/Interfaces/RequesterEntityInterface.php +++ b/packages/sdk/src/Interfaces/RequesterEntityInterface.php @@ -22,11 +22,17 @@ public function getUris(): array; * Read method (GET). * * @param array $params + * @param array $queryStrings + * @param bool $shouldTheExpectedResponseBeMappedOntoTheEntity * * @return mixed * @throws \Exception */ - public function read(array $params = []); + public function read( + array $params = [], + array $queryStrings = [], + bool $shouldTheExpectedResponseBeMappedOntoTheEntity = true + ); /** * Save method (POST). @@ -35,4 +41,15 @@ public function read(array $params = []); * @throws \Exception */ public function save(); + + /** + * Save method with params (POST). + * + * @param array $params + * @param array $queryStrings + * + * @return mixed + * @throws \Exception + */ + public function saveWithParams(array $params = [], array $queryStrings = []); } diff --git a/packages/sdk/src/Sdk.php b/packages/sdk/src/Sdk.php index b10656ef6..8ccb10335 100644 --- a/packages/sdk/src/Sdk.php +++ b/packages/sdk/src/Sdk.php @@ -6,6 +6,9 @@ use MercadoPago\PP\Sdk\Common\Config; use MercadoPago\PP\Sdk\Common\Constants; use MercadoPago\PP\Sdk\Common\Manager; +use MercadoPago\PP\Sdk\Entity\Identification\CreateSellerFunnelBase; +use MercadoPago\PP\Sdk\Entity\Identification\UpdateSellerFunnelBase; +use MercadoPago\PP\Sdk\Entity\Monitoring\DatadogEvent; use MercadoPago\PP\Sdk\Entity\Notification\Notification; use MercadoPago\PP\Sdk\Entity\Payment\Multipayment; use MercadoPago\PP\Sdk\Entity\Payment\MultipaymentV2; @@ -14,6 +17,8 @@ use MercadoPago\PP\Sdk\Entity\Payment\PaymentV2; use MercadoPago\PP\Sdk\Entity\Payment\PaymentV21; use MercadoPago\PP\Sdk\Entity\Preference\Preference; +use MercadoPago\PP\Sdk\Entity\PaymentMethods\PaymentMethods; +use MercadoPago\PP\Sdk\Entity\MerchantOrder\MerchantOrder; use MercadoPago\PP\Sdk\HttpClient\HttpClient; use MercadoPago\PP\Sdk\HttpClient\Requester\CurlRequester; use MercadoPago\PP\Sdk\HttpClient\Requester\RequesterInterface; @@ -42,19 +47,30 @@ class Sdk * @param String $platform_id * @param String $product_id * @param String $integrator_id + * @param String $public_key */ public function __construct( - string $access_token, - string $platform_id, - string $product_id, - string $integrator_id + string $access_token = null, + string $platform_id = null, + string $product_id = null, + string $integrator_id = null, + string $public_key = null ) { $this->requester = new CurlRequester(); $this->config = new Config(); - $this->config->__set('access_token', $access_token); - $this->config->__set('platform_id', $platform_id); - $this->config->__set('product_id', $product_id); - $this->config->__set('integrator_id', $integrator_id); + $parameters = [ + 'access_token' => $access_token, + 'platform_id' => $platform_id, + 'product_id' => $product_id, + 'integrator_id' => $integrator_id, + 'public_key' => $public_key + ]; + + foreach ($parameters as $key => $value) { + if (!empty($value) && isset($value)) { + $this->config->__set($key, $value); + } + } } /** @@ -133,4 +149,64 @@ public function getMultipaymentV21Instance() { return $this->getEntityInstance('MercadoPago\PP\Sdk\Entity\Payment\MultipaymentV21', Constants::BASEURL_MP); } + + /** + * @return DatadogEvent + */ + public function getDatadogEventInstance() + { + return $this->getEntityInstance('MercadoPago\PP\Sdk\Entity\Monitoring\DatadogEvent', Constants::BASEURL_MP); + } + + /** + * @return RegisterErrorLog + */ + public function getRegisterErrorLogInstance() + { + return $this->getEntityInstance('MercadoPago\PP\Sdk\Entity\Monitoring\RegisterErrorLog', Constants::BASEURL_MP); + } + + /** + * @return PaymentMethods + */ + public function getPaymentMethodsInstance() + { + return $this->getEntityInstance( + 'MercadoPago\PP\Sdk\Entity\PaymentMethods\PaymentMethods', + Constants::BASEURL_MP + ); + } + + /** + * @return MerchantOrder + */ + public function getMerchantOrderInstance() + { + return $this->getEntityInstance( + 'MercadoPago\PP\Sdk\Entity\MerchantOrder\MerchantOrder', + Constants::BASEURL_MP + ); + } + + /** + * @return CreateSellerFunnelBase + */ + public function getCreateSellerFunnelBaseInstance() + { + return $this->getEntityInstance( + 'MercadoPago\PP\Sdk\Entity\Identification\CreateSellerFunnelBase', + Constants::BASEURL_MP + ); + } + + /** + * @return UpdateSellerFunnelBase + */ + public function getUpdateSellerFunnelBaseInstance() + { + return $this->getEntityInstance( + 'MercadoPago\PP\Sdk\Entity\Identification\UpdateSellerFunnelBase', + Constants::BASEURL_MP + ); + } } diff --git a/packages/sdk/tests/integration/DatadogEventTest.php b/packages/sdk/tests/integration/DatadogEventTest.php new file mode 100644 index 000000000..c52dd31eb --- /dev/null +++ b/packages/sdk/tests/integration/DatadogEventTest.php @@ -0,0 +1,52 @@ +loadConfigs(); + $accessToken = $envVars['ACCESS_TOKEN'] ?? null; + $publicKey = $envVars['PUBLIC_KEY'] ?? null; + $sdk = new Sdk( + $accessToken, + 'ppcoreinternal', + 'ppcoreinternal', + '', + $publicKey + ); + + $datadogEvent = $sdk->getDatadogEventInstance(); + + $details = [ + "payment_id" => "123456" + ]; + + $datadogEvent->value = "success"; + $datadogEvent->message = "mensagem vinda do teste de integração da SDK de PHP"; + $datadogEvent->plugin_version = "1.0.0"; + $datadogEvent->platform->name = "core"; + $datadogEvent->platform->version = "1.2.0"; + $datadogEvent->platform->uri = "/integration_test"; + $datadogEvent->platform->url = "https://..."; + $datadogEvent->details = $details; + + return $datadogEvent; + } + + public function testDatadogRegisteredWithSuccess() + { + $datadogEvent = $this->loadDatadogEvent(); + + $response = json_decode(json_encode($datadogEvent->register(array("team" => "core", "event_type" => "integration_test")))); + + $this->assertEquals($response->code, 'success'); + $this->assertEquals($response->message, 'Event registered successfully'); + $this->assertEquals($response->status, '200'); + } +} diff --git a/packages/sdk/tests/integration/MelidataErrorTest.php b/packages/sdk/tests/integration/MelidataErrorTest.php deleted file mode 100644 index 3289ae958..000000000 --- a/packages/sdk/tests/integration/MelidataErrorTest.php +++ /dev/null @@ -1,52 +0,0 @@ -loadConfigs(); - $accessToken = $envVars['ACCESS_TOKEN'] ?? null; - $sdk = new Sdk( - $accessToken, - 'ppcoreinternal', - 'ppcoreinternal', - '' - ); - - $melidataError = $sdk->getMelidataErrorInstance(); - - $details = [ - "payment_id" => "123456" - ]; - - $melidataError->name = "nome do erro"; - $melidataError->message = "mensagem do erro"; - $melidataError->target = "error_name"; - $melidataError->plugin->version = "error_name"; - $melidataError->platform->name = "error_name"; - $melidataError->platform->version = "error_name"; - $melidataError->platform->uri = "error_name"; - $melidataError->platform->location = "error_name"; - $melidataError->details = $details; - - return $melidataError; - } - - - public function testMelidataErrorRegisteredWithSuccess() - { - $melidataError = $this->loadMelidataError(); - - $response = json_decode(json_encode($melidataError->registerError())); - - $this->assertEquals($response->code, 'created'); - $this->assertEquals($response->message, 'created'); - $this->assertEquals($response->status, '201'); - } -} diff --git a/packages/sdk/tests/integration/MerchantOrderTest.php b/packages/sdk/tests/integration/MerchantOrderTest.php new file mode 100644 index 000000000..031f425ac --- /dev/null +++ b/packages/sdk/tests/integration/MerchantOrderTest.php @@ -0,0 +1,37 @@ +loadConfigs(); + $accessToken = $envVars['ACCESS_TOKEN'] ?? null; + $publicKey = $envVars['PUBLIC_KEY'] ?? null; + $sdk = new Sdk( + $accessToken, + 'ppcoreinternal', + 'ppcoreinternal', + '', + $publicKey + ); + + return $sdk; + } + + public function testGetMerchantOrders() + { + $sdk = $this->loadSdk(); + $merchantOrder = $sdk->getMerchantOrderInstance(); + $response = $merchantOrder->getMerchantOrders(); + + $this->assertNotNull($response[0]["id"]); + $this->assertNotEmpty($response[0]["status"]); + } +} + diff --git a/packages/sdk/tests/integration/MultipaymentTest.php b/packages/sdk/tests/integration/MultipaymentTest.php index 162f4428d..de0d04f58 100644 --- a/packages/sdk/tests/integration/MultipaymentTest.php +++ b/packages/sdk/tests/integration/MultipaymentTest.php @@ -12,17 +12,21 @@ private function loadMultipaymentV1() $configKeys = new ConfigKeys(); $envVars = $configKeys->loadConfigs(); $accessToken = $envVars['ACCESS_TOKEN'] ?? null; + $publicKey = $envVars['PUBLIC_KEY'] ?? null; $sdk = new Sdk( $accessToken, 'ppcoreinternal', 'ppcoreinternal', - '' + '', + $publicKey ); + $notificationUrl = $envVars['NOTIFICATION_URL'] ?? null; $multipayment = $sdk->getMultipaymentInstance(); + $multipayment->notification_url = $notificationUrl; $multipayment->transaction_amount = 90; - $multipayment->date_of_expiration = "2024-03-30T20:10:00.000+0000"; + $multipayment->date_of_expiration = (date('Y') + 1)."-03-30T20:10:00.000+0000"; $multipayment->description = "Ergonomic Silk Shirt"; $multipayment->payer->email = "test_user_98934401@testuser.com"; $multipayment->payment_method_id = "pp_multiple_payments"; @@ -34,17 +38,21 @@ private function loadMultipaymentV2() $configKeys = new ConfigKeys(); $envVars = $configKeys->loadConfigs(); $accessToken = $envVars['ACCESS_TOKEN'] ?? null; + $publicKey = $envVars['PUBLIC_KEY'] ?? null; $sdk = new Sdk( $accessToken, 'ppcoreinternal', 'ppcoreinternal', - '' + '', + $publicKey ); + $notificationUrl = $envVars['NOTIFICATION_URL'] ?? null; $multipayment = $sdk->getMultipaymentV2Instance(); + $multipayment->notification_url = $notificationUrl; $multipayment->transaction_amount = 90; - $multipayment->date_of_expiration = "2024-03-30T20:10:00.000+0000"; + $multipayment->date_of_expiration = (date('Y') + 1)."-03-30T20:10:00.000+0000"; $multipayment->description = "Ergonomic Silk Shirt"; $multipayment->payer->email = "test_user_98934401@testuser.com"; $multipayment->payment_method_id = "pp_multiple_payments"; @@ -56,15 +64,19 @@ private function loadMultipaymentV21() $configKeys = new ConfigKeys(); $envVars = $configKeys->loadConfigs(); $accessToken = $envVars['ACCESS_TOKEN'] ?? null; + $publicKey = $envVars['PUBLIC_KEY'] ?? null; $sdk = new Sdk( $accessToken, 'ppcoreinternal', 'ppcoreinternal', - '' + '', + $publicKey ); + $notificationUrl = $envVars['NOTIFICATION_URL'] ?? null; $multipayment = $sdk->getMultipaymentV21Instance(); + $multipayment->notification_url = $notificationUrl; $multipayment->transaction_amount = 90; $multipayment->date_of_expiration = (date('Y') + 1)."-03-30T20:10:00.000+0000"; $multipayment->description = "Ergonomic Silk Shirt"; @@ -214,7 +226,7 @@ public function testMultipaymentV2Rejected() } catch (\Exception $e) { $response = $e->getMessage(); } - $this->assertStringContainsString("Your payment was declined", $response); + $this->assertStringContainsString("No message for Multipayment scenario in v1!", $response); } public function testMultipaymentV21Success() @@ -284,6 +296,6 @@ public function testMultipaymentV21Rejected() } catch (\Exception $e) { $response = $e->getMessage(); } - $this->assertStringContainsString("Payment with the second card was declined due to an error. We recommend paying with another card or contacting the bank. Do not worry if any fees were charged on the first payment method, they will be refunded automatically.", $response); + $this->assertStringContainsString("You entered one or more details from the second card incorrectly. Please enter them as they appear on the card. Do not worry if any fees were charged on the first payment method, they will be refunded automatically.", $response); } } diff --git a/packages/sdk/tests/integration/NotificationTest.php b/packages/sdk/tests/integration/NotificationTest.php index ba8288f1b..265186708 100644 --- a/packages/sdk/tests/integration/NotificationTest.php +++ b/packages/sdk/tests/integration/NotificationTest.php @@ -13,11 +13,13 @@ private function loadSdk() $configKeys = new ConfigKeys(); $envVars = $configKeys->loadConfigs(); $accessToken = $envVars['ACCESS_TOKEN'] ?? null; + $publicKey = $envVars['PUBLIC_KEY'] ?? null; $sdk = new Sdk( $accessToken, 'ppcoreinternal', 'ppcoreinternal', - '' + '', + $publicKey ); return $sdk; @@ -29,7 +31,7 @@ private function createPayment($cardHolder) $configKeys = new ConfigKeys(); $envVars = $configKeys->loadConfigs(); $notificationUrl = $envVars['NOTIFICATION_URL'] ?? null; - + $sdk = $this->loadSdk(); $payment = $sdk->getPaymentInstance(); diff --git a/packages/sdk/tests/integration/PaymentMethodsTest.php b/packages/sdk/tests/integration/PaymentMethodsTest.php new file mode 100644 index 000000000..e82d74a5d --- /dev/null +++ b/packages/sdk/tests/integration/PaymentMethodsTest.php @@ -0,0 +1,47 @@ +loadConfigs(); + $accessToken = $envVars['ACCESS_TOKEN'] ?? null; + $publicKey = $envVars['PUBLIC_KEY'] ?? null; + $sdk = new Sdk( + $accessToken, + 'ppcoreinternal', + 'ppcoreinternal', + '', + $publicKey + ); + + return $sdk; + } + + public function testGetPaymentMethods() + { + $sdk = $this->loadSdk(); + $paymentMethods = $sdk->getPaymentMethodsInstance(); + $response = $paymentMethods->getPaymentMethods()->jsonSerialize(); + $this->assertTrue(count($response) > 0); + $this->assertNotEmpty($response[0]->id); + $this->assertNotNull($response[0]->secure_thumbnail); + $this->assertEquals($response, $paymentMethods->payment_methods->jsonSerialize()); + } + + public function testGetPaymentMethodsByGroupBy() + { + $sdk = $this->loadSdk(); + $paymentMethods = $sdk->getPaymentMethodsInstance(); + $response = $paymentMethods->getPaymentMethodsByGroupBy('id'); + $this->assertTrue(array_key_exists('visa', $response)); + $this->assertEquals($response, $paymentMethods->grouped_payment_methods); + } +} + diff --git a/packages/sdk/tests/integration/PaymentTest.php b/packages/sdk/tests/integration/PaymentTest.php index ca392476d..c82fc6332 100644 --- a/packages/sdk/tests/integration/PaymentTest.php +++ b/packages/sdk/tests/integration/PaymentTest.php @@ -7,20 +7,46 @@ class PaymentTest extends TestCase { - private function loadPayment() - { + + private function loadPaymentSdk() { $configKeys = new ConfigKeys(); $envVars = $configKeys->loadConfigs(); $accessToken = $envVars['ACCESS_TOKEN'] ?? null; + $publicKey = $envVars['PUBLIC_KEY'] ?? null; $sdk = new Sdk( $accessToken, 'ppcoreinternal', 'ppcoreinternal', - '' + '', + $publicKey ); + $notificationUrl = $envVars['NOTIFICATION_URL'] ?? null; + $payment = $sdk->getPaymentInstance(); + $payment->notification_url = $notificationUrl; + return $payment; + } - $payment = $sdk->getPaymentInstance(); + private function loadPaymentSdkV21() { + $configKeys = new ConfigKeys(); + $envVars = $configKeys->loadConfigs(); + $accessToken = $envVars['ACCESS_TOKEN'] ?? null; + $publicKey = $envVars['PUBLIC_KEY'] ?? null; + $sdk = new Sdk( + $accessToken, + 'ppcoreinternal', + 'ppcoreinternal', + '', + $publicKey + ); + $notificationUrl = $envVars['NOTIFICATION_URL'] ?? null; + $payment = $sdk->getPaymentV21Instance(); + $payment->notification_url = $notificationUrl; + return $payment; + } + private function loadPayment() + { + $payment = $this->loadPaymentSdk(); $payment->transaction_amount = 230; $payment->description = "Ergonomic Silk Shirt"; $payment->payer->first_name = "Daniel"; @@ -36,18 +62,7 @@ private function loadPayment() private function loadPaymentV21() { - $configKeys = new ConfigKeys(); - $envVars = $configKeys->loadConfigs(); - $accessToken = $envVars['ACCESS_TOKEN'] ?? null; - $sdk = new Sdk( - $accessToken, - 'ppcoreinternal', - 'ppcoreinternal', - '' - ); - - $payment = $sdk->getPaymentV2Instance(); - + $payment = $this->loadPaymentSdkV21(); $payment->transaction_amount = 230; $payment->description = "Ergonomic Silk Shirt"; $payment->payer->first_name = "Daniel"; @@ -66,14 +81,17 @@ private function loadPayment3DS() $configKeys = new ConfigKeys(); $envVars = $configKeys->loadConfigs(); $accessToken = $envVars['ACCESS_TOKEN_3DS'] ?? null; + $publicKey = $envVars['PUBLIC_KEY'] ?? null; $sdk = new Sdk( $accessToken, 'ppcoreinternal', 'ppcoreinternal', - '' + '', + $publicKey ); - - $payment = $sdk->getPaymentInstance(); + $notificationUrl = $envVars['NOTIFICATION_URL'] ?? null; + $payment = $sdk->getPaymentInstance(); + $payment->notification_url = $notificationUrl; $payment->transaction_amount = 230; $payment->description = "Ergonomic Silk Shirt"; @@ -123,7 +141,7 @@ public function testPaymentRejectedCreditCard() $this->assertEquals($response->payment_method_id, 'master'); $this->assertEquals($response->payment_type_id, 'credit_card'); $this->assertEquals($response->installments, 1); - $this->assertEquals($response->status_detail, "cc_rejected_other_reason"); + $this->assertEquals($response->status_detail, "cc_rejected_bad_filled_other"); } public function testPaymentV21SuccessCreditCard() @@ -163,7 +181,7 @@ public function testPaymentV21RejectedCreditCard() $this->assertEquals($response->payment_method_id, 'master'); $this->assertEquals($response->payment_type_id, 'credit_card'); $this->assertEquals($response->installments, 1); - $this->assertEquals($response->status_detail, "cc_rejected_other_reason"); + $this->assertEquals($response->status_detail, "cc_rejected_bad_filled_other"); } public function testPaymentSuccessBoleto() @@ -171,6 +189,12 @@ public function testPaymentSuccessBoleto() $payment = $this->loadPayment(); $payment->payment_method_id = "bolbradesco"; + $payment->payer->address->zip_code = "000"; + $payment->payer->address->street_name = "rua teste"; + $payment->payer->address->street_number = "123"; + $payment->payer->address->neighborhood = "neighborhood"; + $payment->payer->address->city = "city"; + $payment->payer->address->federal_unit = "federal_unit"; $response = json_decode(json_encode($payment->save())); @@ -231,6 +255,66 @@ public function testPaymentRejectedCreditCard3DS() $this->assertEquals($response->payment_method_id, 'master'); $this->assertEquals($response->payment_type_id, 'credit_card'); $this->assertEquals($response->installments, 1); - $this->assertEquals($response->status_detail, "cc_rejected_other_reason"); + $this->assertEquals($response->status_detail, "cc_rejected_bad_filled_other"); + } + + public function testGetPaymentSuccess() + { + $payment = $this->loadPayment(); + $payment->payment_method_id = "pix"; + $response = json_decode(json_encode($payment->save())); + + $paymentInstance = $this->loadPaymentSdk(); + $responseRead = json_decode(json_encode($paymentInstance->read(array( + "id" => $response->id, + )))); + + $this->assertEquals($responseRead->id, $response->id); + $this->assertEquals($responseRead->status, $response->status); + $this->assertEquals($responseRead->payment_type_id, $response->payment_type_id); + $this->assertEquals($responseRead->payment_method_id, $response->payment_method_id); + $this->assertEquals($responseRead->transaction_details->total_paid_amount, $response->transaction_details->total_paid_amount); + $this->assertEquals($responseRead->transaction_details->installment_amount, $response->transaction_details->installment_amount); + $this->assertEquals($responseRead->point_of_interaction->transaction_data->qr_code_base64, $response->point_of_interaction->transaction_data->qr_code_base64); + $this->assertEquals($responseRead->point_of_interaction->transaction_data->qr_code, $response->point_of_interaction->transaction_data->qr_code); + } + + public function testGetPaymentNotFound() + { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Payment not found'); + $paymentInstance = $this->loadPaymentSdk(); + $responseRead = json_decode(json_encode($paymentInstance->read(array( + "id" => "123", + )))); + } + + public function testGetPaymentSuccessV21() + { + $payment = $this->loadPayment(); + $payment->payment_method_id = "pix"; + $response = json_decode(json_encode($payment->save())); + + $paymentInstance = $this->loadPaymentSdkV21(); + $responseRead = json_decode(json_encode($paymentInstance->read(array( + "id" => $response->id, + )))); + + $this->assertEquals($responseRead->id, $response->id); + $this->assertEquals($responseRead->status, $response->status); + $this->assertEquals($responseRead->payment_type_id, $response->payment_type_id); + $this->assertEquals($responseRead->payment_method_id, $response->payment_method_id); + $this->assertEquals($responseRead->transaction_details->total_paid_amount, $response->transaction_details->total_paid_amount); + $this->assertEquals($responseRead->transaction_details->installment_amount, $response->transaction_details->installment_amount); + } + + public function testGetPaymentNotFoundV21() + { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Payment not found'); + $paymentInstance = $this->loadPaymentSdkV21(); + $responseRead = json_decode(json_encode($paymentInstance->read(array( + "id" => "123", + )))); } } diff --git a/packages/sdk/tests/integration/PreferenceTest.php b/packages/sdk/tests/integration/PreferenceTest.php index 7daa7e9ac..8a7a997ad 100644 --- a/packages/sdk/tests/integration/PreferenceTest.php +++ b/packages/sdk/tests/integration/PreferenceTest.php @@ -7,20 +7,27 @@ class PreferenceTest extends TestCase { - private function loadPreference() - { + + private function loadPreferenceSdk() { $configKeys = new ConfigKeys(); $envVars = $configKeys->loadConfigs(); $accessToken = $envVars['ACCESS_TOKEN'] ?? null; + $publicKey = $envVars['PUBLIC_KEY'] ?? null; $sdk = new Sdk( $accessToken, 'ppcoreinternal', 'ppcoreinternal', - '' + '', + $publicKey ); + return $sdk->getPreferenceInstance(); + } - $preference = $sdk->getPreferenceInstance(); - + private function loadPreference() + { + $configKeys = new ConfigKeys(); + $envVars = $configKeys->loadConfigs(); + $preference = $this->loadPreferenceSdk(); $items = ["items" => [ "title" => "Dummy Title", @@ -96,4 +103,30 @@ public function testPreferenceWithoutQuantity() $preference->save(); } + + public function testGetPreferenceSucces() + { + $preferenceSdkInstance = $this->loadPreferenceSdk(); + $preference = $this->loadPreference(); + $responseSave = json_decode(json_encode($preference->save())); + + $responseRead = json_decode(json_encode($preferenceSdkInstance->read(array( + "id" => $responseSave->id, + )))); + + $this->assertEquals($responseRead->items[0]->unit_price, $responseSave->items[0]->unit_price); + $this->assertEquals($responseRead->external_reference, $responseSave->external_reference); + } + + public function testGetPreferenceNotFound() + { + $preferenceSdkInstance = $this->loadPreferenceSdk(); + + $this->expectException(\Exception::class); + $this->expectExceptionMessage('The preference with identifier 123 was not found'); + + $responseRead = json_decode(json_encode($preferenceSdkInstance->read(array( + "id" => "123", + )))); + } } \ No newline at end of file diff --git a/packages/sdk/tests/integration/RegisterErrorLog.php b/packages/sdk/tests/integration/RegisterErrorLog.php new file mode 100644 index 000000000..9804effe9 --- /dev/null +++ b/packages/sdk/tests/integration/RegisterErrorLog.php @@ -0,0 +1,56 @@ +loadConfigs(); + $accessToken = $envVars['ACCESS_TOKEN'] ?? null; + $publicKey = $envVars['PUBLIC_KEY'] ?? null; + $sdk = new Sdk( + $accessToken, + 'ppcoreinternal', + 'ppcoreinternal', + '', + $publicKey + ); + + $registerErrorLog = $sdk->getRegisterErrorLogInstance(); + + $registerErrorLog->message = 'Sample error message'; + $registerErrorLog->stacktrace = 'monitoring_regiter_log.php'; + $registerErrorLog->location = 'save'; + $registerErrorLog->platform_version = phpversion(); + $registerErrorLog->module_version = "1.0.0"; + $registerErrorLog->user_agent = 'PHP SDK'; + $registerErrorLog->flow = 'sample-php-sdk'; + $registerErrorLog->runtime_version = phpversion(); + $registerErrorLog->os_version = "10"; + $registerErrorLog->browser_version = "Chrome"; + $registerErrorLog->uri = 'http://localhost'; + $registerErrorLog->url = 'http://localhost'; + $registerErrorLog->details = [ + 'payment_id' => '123456789', + ]; + + return $registerErrorLog; + } + + + public function testRegisterErrorLogWithSuccess() + { + $registerErrorLog = $this->loadRegisterErrorLog(); + + $response = json_decode(json_encode($registerErrorLog->save())); + + $this->assertEquals($response->code, 'created'); + $this->assertEquals($response->message, 'created'); + $this->assertEquals($response->status, '201'); + } +} diff --git a/packages/sdk/tests/integration/SellerFunnelBaseTest.php b/packages/sdk/tests/integration/SellerFunnelBaseTest.php new file mode 100644 index 000000000..19e421bb4 --- /dev/null +++ b/packages/sdk/tests/integration/SellerFunnelBaseTest.php @@ -0,0 +1,84 @@ +getCreateSellerFunnelBaseInstance(); + } + + private function loadSdkUpdateSellerFunnelBase() + { + $sdk = new Sdk(null, 'ppcoreinternal', 'product_id'); + return $sdk->getUpdateSellerFunnelBaseInstance(); + } + + + private function loadCreateSellerFunnelBase() + { + + $createSellerFunnelBase = $this->loadSdkCreateSellerFunnelBase(); + + $createSellerFunnelBase->platform_id = "123"; + $createSellerFunnelBase->shop_url = "http://localhost"; + $createSellerFunnelBase->platform_version = "1.0.0"; + $createSellerFunnelBase->plugin_version = "1.0.0"; + $createSellerFunnelBase->site_id = "MLB"; + + return $createSellerFunnelBase; + } + + private function loadUpdateSellerFunnelBase() + { + $updateSellerFunnelBase = $this->loadSdkUpdateSellerFunnelBase(); + + $updateSellerFunnelBase->id = "id"; + $updateSellerFunnelBase->is_added_production_credential = true; + $updateSellerFunnelBase->is_added_test_credential = true; + $updateSellerFunnelBase->product_id = "4das56"; + $updateSellerFunnelBase->cust_id = "123"; + $updateSellerFunnelBase->application_id = "123"; + $updateSellerFunnelBase->plugin_mode = "prod"; + $updateSellerFunnelBase->is_deleted = false; + $updateSellerFunnelBase->accepted_payments = ["bolbradesco", "pix"]; + $updateSellerFunnelBase->is_disabled = false; + + return $updateSellerFunnelBase; + } + + public function testCreateSellerFunnelBaseWithSuccess() + { + $createSellerFunnelBase = $this->loadCreateSellerFunnelBase(); + + $response = $createSellerFunnelBase->save(); + + $this->assertNotNull($response->id); + $this->assertNotNull($response->cpp_token); + } + + public function testUpdateSellerFunnelBaseWithSuccess() + { + $createSellerFunnelBase = $this->loadCreateSellerFunnelBase(); + + $updateSellerFunnelBase = $this->loadUpdateSellerFunnelBase(); + + $responseCreate = $createSellerFunnelBase->save(); + + $updateSellerFunnelBase->id = $responseCreate->id; + $updateSellerFunnelBase->cpp_token = $responseCreate->cpp_token; + + $responseUpdate = json_decode(json_encode($updateSellerFunnelBase->update())); + + $this->assertNotNull($responseCreate->id); + $this->assertNotNull($responseUpdate->id); + $this->assertEquals($responseCreate->id, $responseUpdate->id); + $this->assertTrue($responseUpdate->success_update); + } +} diff --git a/packages/sdk/tests/unit/Common/ManagerTest.php b/packages/sdk/tests/unit/Common/ManagerTest.php index d8ad7ebc0..b64f95aaf 100644 --- a/packages/sdk/tests/unit/Common/ManagerTest.php +++ b/packages/sdk/tests/unit/Common/ManagerTest.php @@ -182,4 +182,25 @@ function testHandleResponseFailureInternalApiError() $this->expectExceptionMessage('Internal API Error'); $this->manager->handleResponse($this->responseMock, 'get'); } + + function testIsHeadersAsKeyAndValueMapTrue() + { + $customHeaders = ['x-header' => 'abc123']; + $actual = $this->manager->isHeadersAsKeyAndValueMap($customHeaders); + $this->assertTrue($actual); + } + + function testIsHeadersAsKeyAndValueMapFalse() + { + $customHeaders = ['x-header: abc123']; + $actual = $this->manager->isHeadersAsKeyAndValueMap($customHeaders); + $this->assertFalse($actual); + } + + function testSetHeadersAsKeyAndValueMap() + { + $customHeaders = ['x-header: abc123']; + $actual = $this->manager->setHeadersAsKeyAndValueMap($customHeaders); + $this->assertEquals(['x-header' => 'abc123'], $actual); + } } diff --git a/packages/sdk/tests/unit/Entity/Identification/CreateSellerFunnelBaseTest.php b/packages/sdk/tests/unit/Entity/Identification/CreateSellerFunnelBaseTest.php new file mode 100644 index 000000000..c2e431837 --- /dev/null +++ b/packages/sdk/tests/unit/Entity/Identification/CreateSellerFunnelBaseTest.php @@ -0,0 +1,93 @@ +createSellerFunnelBaseMock = CreateSellerFunnelBaseMock::COMPLETE_CREATE_SELLER_BASE; + + $this->managerMock = $this->getMockBuilder(Manager::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->responseMock = $this->getMockBuilder(Response::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->createSellerFunnelBase = new CreateSellerFunnelBase($this->managerMock); + $this->createSellerFunnelBase->setEntity($this->createSellerFunnelBaseMock); + } + + function testGetHeadersSuccess() + { + $actual = $this->createSellerFunnelBase->getHeaders(); + + $this->assertTrue(is_array($actual)); + $this->assertArrayHasKey('save', $actual); + $this->assertTrue(is_array($actual['save'])); + } + + function testGetUriSuccess() + { + $actual = $this->createSellerFunnelBase->getUris(); + + $this->assertTrue(is_array($actual)); + } + + function testSaveSuccess() + { + $response = new Response(); + $response->setData(json_decode('{"id": "123"}')); + $response->setHeaders(['x-cpp-token' => '1235']); + $response->setStatus(201); + + $this->responseMock->expects(self::any())->method('getStatus')->willReturn($response->getStatus()); + $this->responseMock->expects(self::any())->method('getData')->willReturn($response->getData()); + $this->responseMock->expects(self::any())->method('getHeaders')->willReturn($response->getHeaders()); + + $this->managerMock->expects(self::any())->method('getEntityUri')->willReturn('/v1/eplatforms/core/identification/seller-configuration/start-integration'); + $this->managerMock->expects(self::any())->method('execute')->willReturn($this->responseMock); + $this->managerMock->expects(self::any())->method('handleResponseWithHeaders')->willReturn($response); + + $actual = $this->createSellerFunnelBase->save(); + + $this->assertNotNull($actual); + } +} diff --git a/packages/sdk/tests/unit/Entity/Identification/UpdateSellerFunnelBaseTest.php b/packages/sdk/tests/unit/Entity/Identification/UpdateSellerFunnelBaseTest.php new file mode 100644 index 000000000..92b8cee15 --- /dev/null +++ b/packages/sdk/tests/unit/Entity/Identification/UpdateSellerFunnelBaseTest.php @@ -0,0 +1,87 @@ +updateSellerFunnelBaseMock = SellerFunnelBaseMock::COMPLETE_UPDATE_SELLER_BASE; + + $this->managerMock = $this->getMockBuilder(Manager::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->responseMock = $this->getMockBuilder(Response::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->updateSellerFunnelBase = new UpdateSellerFunnelBase($this->managerMock); + $this->updateSellerFunnelBase->setEntity($this->updateSellerFunnelBaseMock); + } + + function testGetHeadersSuccess() + { + $actual = $this->updateSellerFunnelBase->getHeaders(); + + $this->assertTrue(is_array($actual)); + $this->assertArrayHasKey('update', $actual); + $this->assertTrue(is_array($actual['update'])); + } + + function testGetUriSuccess() + { + $actual = $this->updateSellerFunnelBase->getUris(); + + $this->assertTrue(is_array($actual)); + } + + function testSaveSuccess() + { + $this->responseMock->expects(self::any())->method('getStatus')->willReturn(201); + $this->responseMock->expects(self::any())->method('getData')->willReturn($this->updateSellerFunnelBaseMock); + + $this->managerMock->expects(self::any())->method('getEntityUri')->willReturn('/v1/eplatforms/core/identification/seller-configuration/update-integration'); + $this->managerMock->expects(self::any())->method('execute')->willReturn($this->responseMock); + $this->managerMock->expects(self::any())->method('handleResponse')->willReturn(true); + + $actual = $this->updateSellerFunnelBase->update(); + + $this->assertTrue($actual); + } +} diff --git a/packages/sdk/tests/unit/Entity/MerchantOrder/MerchantOrderTest.php b/packages/sdk/tests/unit/Entity/MerchantOrder/MerchantOrderTest.php new file mode 100644 index 000000000..58e61a719 --- /dev/null +++ b/packages/sdk/tests/unit/Entity/MerchantOrder/MerchantOrderTest.php @@ -0,0 +1,109 @@ +managerMock = $this->getMockBuilder(Manager::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->responseMock = $this->getMockBuilder(Response::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->merchantOrder = new MerchantOrder($this->managerMock); + } + + function testGetAndSetSuccess() + { + $this->merchantOrder->__set('elements', MerchantOrderMock::MERCHANT_ORDERS["elements"]); + + $actual = $this->merchantOrder->__get('elements')["0"]["id"]; + $expected = 1234567891; + + $this->assertEquals($expected, $actual); + } + + function testGetHeadersSuccess() + { + $actual = $this->merchantOrder->getHeaders(); + + $this->assertTrue(is_array($actual)); + $this->assertArrayHasKey('read', $actual); + $this->assertTrue(is_array($actual['read'])); + } + + function testGetUriSuccess() + { + $actual = $this->merchantOrder->getUris(); + + $this->assertTrue(is_array($actual)); + } + + function testGetMerchantOrdersSuccess() + { + $this->merchantOrder->elements = MerchantOrderMock::MERCHANT_ORDERS["elements"]; + + $this->responseMock->expects(self::any())->method('getStatus')->willReturn(200); + $this->responseMock->expects(self::any())->method('getData')->willReturn($this->merchantOrder); + + $this->managerMock->expects(self::any())->method('getEntityUri')->willReturn('/merchant_orders/'); + $this->managerMock->expects(self::any())->method('getHeader')->willReturn([]); + $this->managerMock->expects(self::any())->method('execute')->willReturn($this->responseMock); + $this->managerMock->expects(self::any())->method('handleResponse')->willReturn($this->merchantOrder); + + $actual = $this->merchantOrder->getMerchantOrders(); + $expectedData = $this->responseMock->getData(); + + $this->assertEquals($expectedData->elements[0]["id"], $actual[0]["id"]); + } + + function testGetMerchantOrderSuccess() + { + $this->responseMock->expects(self::any())->method('getStatus')->willReturn(200); + $this->responseMock->expects(self::any())->method('getData')->willReturn(MerchantOrderMock::MERCHANT_ORDER); + + $this->managerMock->expects(self::any())->method('getEntityUri')->willReturn('/merchant_orders/123'); + $this->managerMock->expects(self::any())->method('getHeader')->willReturn([]); + $this->managerMock->expects(self::any())->method('execute')->willReturn($this->responseMock); + $this->managerMock->expects(self::any())->method('handleResponse')->willReturn(MerchantOrderMock::MERCHANT_ORDER); + + $actual = $this->merchantOrder->getMerchantOrder('123'); + $dataExpected = $this->responseMock->getData(); + + $this->assertEquals($dataExpected["id"], $actual->id); + } +} diff --git a/packages/sdk/tests/unit/Entity/Monitoring/MelidataErrorTest.php b/packages/sdk/tests/unit/Entity/Monitoring/DatadogEventTest.php similarity index 61% rename from packages/sdk/tests/unit/Entity/Monitoring/MelidataErrorTest.php rename to packages/sdk/tests/unit/Entity/Monitoring/DatadogEventTest.php index 6ccbd2bdc..2be455576 100644 --- a/packages/sdk/tests/unit/Entity/Monitoring/MelidataErrorTest.php +++ b/packages/sdk/tests/unit/Entity/Monitoring/DatadogEventTest.php @@ -4,27 +4,27 @@ use MercadoPago\PP\Sdk\HttpClient\Response; use MercadoPago\PP\Sdk\Common\Manager; -use MercadoPago\PP\Sdk\Entity\Monitoring\MelidataError; -use MercadoPago\PP\Sdk\Tests\Unit\Mock\MelidataErrorMock; +use MercadoPago\PP\Sdk\Entity\Monitoring\DatadogEvent; +use MercadoPago\PP\Sdk\Tests\Unit\Mock\DatadogEventMock; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; /** - * Class MelidataErrorTest + * Class DatadogEventTest * * @package MercadoPago\PP\Sdk\Tests\Entity\Monitoring */ -class MelidataErrorTest extends TestCase +class DatadogEventTest extends TestCase { /** - * @var MelidataError + * @var DatadogEvent */ - private $melidataError; + private $datadogEvent; /** * @var array */ - private $melidataErrorMock; + private $datadogEventMock; /** * @var MockObject @@ -41,7 +41,7 @@ class MelidataErrorTest extends TestCase */ protected function setUp(): void { - $this->melidataErrorMock = MelidataErrorMock::COMPLETE_MELIDATA_ERROR; + $this->datadogEventMock = DatadogEventMock::COMPLETE_DATADOG_EVENT; $this->managerMock = $this->getMockBuilder(Manager::class) ->disableOriginalConstructor() @@ -51,34 +51,32 @@ protected function setUp(): void ->disableOriginalConstructor() ->getMock(); - $this->melidataError = new MelidataError($this->managerMock); - $this->melidataError->setEntity($this->melidataErrorMock); + $this->datadogEvent = new DatadogEvent($this->managerMock); + $this->datadogEvent->setEntity($this->datadogEventMock); } function testSubclassesTypes() { - $plugin = $this->melidataError->__get('plugin'); - $platform = $this->melidataError->__get('platform'); - $details = $this->melidataError->__get('details'); + $platform = $this->datadogEvent->__get('platform'); + $details = $this->datadogEvent->__get('details'); - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Monitoring\Plugin", $plugin); $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Monitoring\Platform", $platform); $this->assertIsArray($details); } function testGetAndSetSuccess() { - $this->melidataError->__set('target', 'XXX'); + $this->datadogEvent->__set('value', 'success'); - $actual = $this->melidataError->__get('target'); - $expected = 'XXX'; + $actual = $this->datadogEvent->__get('value'); + $expected = 'success'; $this->assertEquals($expected, $actual); } function testGetHeadersSuccess() { - $actual = $this->melidataError->getHeaders(); + $actual = $this->datadogEvent->getHeaders(); $this->assertTrue(is_array($actual)); $this->assertArrayHasKey('read', $actual); @@ -89,32 +87,32 @@ function testGetHeadersSuccess() function testGetUriSuccess() { - $actual = $this->melidataError->getUris(); + $actual = $this->datadogEvent->getUris(); $this->assertTrue(is_array($actual)); } - function testSaveSuccess() + function testRegisterSuccess() { - $this->responseMock->expects(self::any())->method('getStatus')->willReturn(201); - $this->responseMock->expects(self::any())->method('getData')->willReturn($this->melidataErrorMock); + $this->responseMock->expects(self::any())->method('getStatus')->willReturn(200); + $this->responseMock->expects(self::any())->method('getData')->willReturn($this->datadogEventMock); - $this->managerMock->expects(self::any())->method('getEntityUri')->willReturn('/ppcore/prod/monitor/v1/melidata/errors'); + $this->managerMock->expects(self::any())->method('getEntityUri')->willReturn('/ppcore/prod/monitor/v1/event/datadog/core/unit_test'); $this->managerMock->expects(self::any())->method('getHeader')->willReturn([]); $this->managerMock->expects(self::any())->method('execute')->willReturn($this->responseMock); $this->managerMock->expects(self::any())->method('handleResponse')->willReturn(true); - $actual = $this->melidataError->registerError(); + $actual = $this->datadogEvent->register(array("team" => "core", "event_type"=> "unit_test")); $this->assertTrue($actual); } function testJsonSerializeSuccess() { - $actual = $this->melidataError->jsonSerialize(); - $expected = 'error target'; + $actual = $this->datadogEvent->jsonSerialize(); + $expected = 'success'; $this->assertTrue(is_array($actual)); - $this->assertEquals($expected, $actual['target']); + $this->assertEquals($expected, $actual['value']); } } diff --git a/packages/sdk/tests/unit/Entity/Monitoring/RegisterErrorLogTest.php b/packages/sdk/tests/unit/Entity/Monitoring/RegisterErrorLogTest.php new file mode 100644 index 000000000..8e635d811 --- /dev/null +++ b/packages/sdk/tests/unit/Entity/Monitoring/RegisterErrorLogTest.php @@ -0,0 +1,106 @@ +registerErrorLogMock = RegisterErrorLogMock::COMPLETE_REGISTER_ERROR_LOG; + + $this->managerMock = $this->getMockBuilder(Manager::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->responseMock = $this->getMockBuilder(Response::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->registerErrorLog = new RegisterErrorLog($this->managerMock); + $this->registerErrorLog->setEntity($this->registerErrorLogMock); + } + + function testGetAndSetSuccess() + { + $this->registerErrorLog->__set('uri', 'XXX'); + + $actual = $this->registerErrorLog->__get('uri'); + $expected = 'XXX'; + + $this->assertEquals($expected, $actual); + } + + function testGetHeadersSuccess() + { + $actual = $this->registerErrorLog->getHeaders(); + + $this->assertTrue(is_array($actual)); + $this->assertArrayHasKey('save', $actual); + $this->assertTrue(is_array($actual['save'])); + } + + function testGetUriSuccess() + { + $actual = $this->registerErrorLog->getUris(); + + $this->assertTrue(is_array($actual)); + } + + function testSaveSuccess() + { + $this->responseMock->expects(self::any())->method('getStatus')->willReturn(201); + $this->responseMock->expects(self::any())->method('getData')->willReturn($this->registerErrorLogMock); + + $this->managerMock->expects(self::any())->method('getEntityUri')->willReturn('/ppcore/prod/monitor/v1/event/error'); + $this->managerMock->expects(self::any())->method('getHeader')->willReturn(['x-flow:not identified']); + $this->managerMock->expects(self::any())->method('execute')->willReturn($this->responseMock); + $this->managerMock->expects(self::any())->method('handleResponse')->willReturn(true); + + $actual = $this->registerErrorLog->save(); + + $this->assertTrue($actual); + } + + function testJsonSerializeSuccess() + { + $actual = $this->registerErrorLog->jsonSerialize(); + $expected = '/checkout'; + + $this->assertTrue(is_array($actual)); + $this->assertEquals($expected, $actual['uri']); + } +} diff --git a/packages/sdk/tests/unit/Entity/Payment/PaymentTest.php b/packages/sdk/tests/unit/Entity/Payment/PaymentTest.php index 574853b61..76bf369e4 100644 --- a/packages/sdk/tests/unit/Entity/Payment/PaymentTest.php +++ b/packages/sdk/tests/unit/Entity/Payment/PaymentTest.php @@ -182,4 +182,23 @@ function testJsonSerializeSuccess() $this->assertTrue(is_array($actual)); $this->assertEquals($expected, $actual['external_reference']); } + + function testReadPaymentSuccess() + { + $this->paymentMock = PaymentMock::COMPLETE_PAYMENT; + $this->payment->setEntity($this->paymentMock); + + $this->responseMock->expects(self::any())->method('getStatus')->willReturn(200); + $this->responseMock->expects(self::any())->method('getData')->willReturn($this->paymentMock); + + $this->managerMock->expects(self::any())->method('getEntityUri')->willReturn('/v1/payments/:id'); + $this->managerMock->expects(self::any())->method('getHeader')->willReturn([]); + $this->managerMock->expects(self::any())->method('execute')->willReturn($this->responseMock); + $this->managerMock->expects(self::any())->method('handleResponse')->willReturn($this->paymentMock); + + $actual = $this->payment->read(array("id" => "25604645467")); + + $this->assertEquals(json_encode($this->responseMock->getData()), json_encode($actual)); + } + } diff --git a/packages/sdk/tests/unit/Entity/PaymentMethods/PaymentMethodsTest.php b/packages/sdk/tests/unit/Entity/PaymentMethods/PaymentMethodsTest.php new file mode 100644 index 000000000..e9805c221 --- /dev/null +++ b/packages/sdk/tests/unit/Entity/PaymentMethods/PaymentMethodsTest.php @@ -0,0 +1,149 @@ +paymentMethodsMock = PaymentMethodsMock::PAYMENT_METHODS; + + $this->managerMock = $this->getMockBuilder(Manager::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->responseMock = $this->getMockBuilder(Response::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->paymentMethods = new PaymentMethods($this->managerMock); + $this->paymentMethodsMock = PaymentMethodsMock::PAYMENT_METHODS; + $this->groupedPaymentMethodsMock = PaymentMethodsMock::GROUPED_PAYMENT_METHODS_BY_ID; + } + + function testGetAndSetSuccess() + { + $this->paymentMethods->__set('payment_methods', $this->paymentMethodsMock); + + $actual = $this->paymentMethods->__get('payment_methods')->jsonSerialize()[0]->id; + $expected = 'visa'; + + $this->assertEquals($expected, $actual); + } + + function testGetHeadersSuccess() + { + $actual = $this->paymentMethods->getHeaders(); + + $this->assertTrue(is_array($actual)); + $this->assertArrayHasKey('read', $actual); + $this->assertArrayHasKey('save', $actual); + $this->assertTrue(is_array($actual['read'])); + $this->assertTrue(is_array($actual['save'])); + } + + function testGetUriSuccess() + { + $actual = $this->paymentMethods->getUris(); + + $this->assertTrue(is_array($actual)); + } + + function testGetPaymentMethodsSuccess() + { + $this->responseMock->expects(self::any())->method('getStatus')->willReturn(200); + $this->responseMock->expects(self::any())->method('getData')->willReturn($this->paymentMethodsMock); + + $this->managerMock->expects(self::any())->method('getEntityUri')->willReturn('/ppcore/prod/payment-methods/v1/payment-methods'); + $this->managerMock->expects(self::any())->method('getHeader')->willReturn([]); + $this->managerMock->expects(self::any())->method('execute')->willReturn($this->responseMock); + $this->managerMock->expects(self::any())->method('handleResponse')->willReturn($this->paymentMethodsMock); + + $actual = $this->paymentMethods->getPaymentMethods(); + $dataExpected = $this->responseMock->getData(); + + $this->assertEquals(count($dataExpected), count($actual)); + $this->assertEquals(json_decode(json_encode($dataExpected)), json_decode(json_encode($actual))); + $this->assertEquals($dataExpected[0]["id"] == "visa", $actual->jsonSerialize()[0]->id == "visa"); + } + + function testGetPaymentMethodsByGroupBySuccess() + { + $this->responseMock->expects(self::any())->method('getStatus')->willReturn(200); + $this->responseMock->expects(self::any())->method('getData')->willReturn($this->groupedPaymentMethodsMock); + + $this->managerMock->expects(self::any())->method('getEntityUri')->willReturn('/ppcore/prod/payment-methods/v1/payment-methods'); + $this->managerMock->expects(self::any())->method('getHeader')->willReturn([]); + $this->managerMock->expects(self::any())->method('execute')->willReturn($this->responseMock); + $this->managerMock->expects(self::any())->method('handleResponse')->willReturn($this->groupedPaymentMethodsMock); + + $actual = $this->paymentMethods->getPaymentMethodsByGroupBy('id'); + $dataExpected = $this->responseMock->getData(); + + $this->assertEquals(json_decode(json_encode($dataExpected)), json_decode(json_encode($actual))); + $this->assertEquals($dataExpected["visa"], $actual['visa']); + } + + function testSetCustomHeaderSuccess() + { + $this->paymentMethods->setCustomHeaders(['Authorization: ' . 'xxx']); + $headers = $this->paymentMethods->getHeaders()['read']; + $expectedHeader = 'Authorization: xxx'; + + $this->assertContains($expectedHeader, $headers); + } + + function testJsonSerializeSuccess() + { + $this->paymentMethods->__set('payment_methods', $this->paymentMethodsMock); + $actual = $this->paymentMethods->jsonSerialize(); + $expected = 'visa'; + + $this->assertTrue(is_array($actual)); + $this->assertEquals($expected, $actual['payment_methods'][0]['id']); + } +} diff --git a/packages/sdk/tests/unit/HttpClient/Requester/CurlRequesterTest.php b/packages/sdk/tests/unit/HttpClient/Requester/CurlRequesterTest.php index cd19b43f2..0d7c3a96c 100644 --- a/packages/sdk/tests/unit/HttpClient/Requester/CurlRequesterTest.php +++ b/packages/sdk/tests/unit/HttpClient/Requester/CurlRequesterTest.php @@ -3,6 +3,7 @@ use MercadoPago\PP\Sdk\HttpClient\Response; use MercadoPago\PP\Sdk\HttpClient\Requester\CurlRequester; use PHPUnit\Framework\TestCase; +use MercadoPago\PP\Sdk\Tests\Unit\Mock\CurlRequestMock; /** * Class CurlRequesterTest @@ -26,7 +27,7 @@ function getPartialCurlRequesterMock($responseCode, $errno, $error) $mock->expects(self::any())->method('curlGetInfo')->willReturn($apiResponse); - $mock->expects(self::any())->method('curlExec')->willReturn(json_encode('{"test":"123"}')); + $mock->expects(self::any())->method('curlExec')->willReturn(CurlRequestMock::CURL_EXEC_RESPONSE); if ($errno) { $mock->expects(self::any())->method('curlErrno')->willReturn($errno); @@ -105,7 +106,8 @@ function testSendRequestSuccess() { $mockResponse = new Response(); $mockResponse->setStatus(200); - $mockResponse->setData('{"test":"123"}'); + $mockResponse->setData(json_decode('{"test":"123"}', true)); + $mockResponse->setHeaders([]); $requester = $this->getPartialCurlRequesterMock(200, 0, ''); diff --git a/packages/sdk/tests/unit/Mock/CreateSellerFunnelBaseMock.php b/packages/sdk/tests/unit/Mock/CreateSellerFunnelBaseMock.php new file mode 100644 index 000000000..4d1548d08 --- /dev/null +++ b/packages/sdk/tests/unit/Mock/CreateSellerFunnelBaseMock.php @@ -0,0 +1,15 @@ + "ppcoreinternal", + "shopUrl" => "http://localhost" + ]; +} diff --git a/packages/sdk/tests/unit/Mock/CurlRequestMock.php b/packages/sdk/tests/unit/Mock/CurlRequestMock.php new file mode 100644 index 000000000..fc18b4180 --- /dev/null +++ b/packages/sdk/tests/unit/Mock/CurlRequestMock.php @@ -0,0 +1,11 @@ + "error name", + const COMPLETE_DATADOG_EVENT = [ + "value" => "success", "message" => "error message", - "target" => "error target", - "plugin" => [ - "version" => "123", - ], + "plugin_version" => "1.2.3", "platform" => [ "name" => "ppcoreinternal", "version" => "1.2.3", "uri" => "/platform_uri", - "location" => "platform_location", + "url" => "https://platform_url...", ], "details" => [ "payment_id" => "123456", diff --git a/packages/sdk/tests/unit/Mock/MerchantOrderMock.php b/packages/sdk/tests/unit/Mock/MerchantOrderMock.php new file mode 100644 index 000000000..d87ee98ac --- /dev/null +++ b/packages/sdk/tests/unit/Mock/MerchantOrderMock.php @@ -0,0 +1,141 @@ + [ + [ + "id" => 1234567891, + "status" => "opened", + "external_reference" => "Order_1234567891", + "preference_id" => "123465789-12346578-1234-1234-1234-123456789123", + "payments" => [], + "shipments" => [], + "payouts" => [], + "collector" => [ + "id" => 123465789, + "email" => "", + "nickname" => "TETE4642489" + ], + "marketplace" => "NONE", + "notification_url" => "https://webhook.com", + "date_created" => "2021-09-08T19:30:26.637+00:00", + "last_updated" => "2022-10-06T06:18:44.821-04:00", + "sanitized_version" => 1, + "sponsor_id" => null, + "shipping_cost" => 0, + "total_amount" => 18.37, + "site_id" => "MLB", + "paid_amount" => 0, + "refunded_amount" => 0, + "payer" => null, + "items" => [ + "id" => "40", + "category_id" => "art", + "currency_id" => "BRL", + "description" => "camiseta branca", + "picture_url" => "https://site/img.jpg", + "picture_id" => "123", + "title" => "Camiseta", + "quantity" => 1, + "unit_price" => 18.37 + ], + "cancelled" => false, + "additional_info" => "", + "application_id" => null, + "is_test" => false, + "order_status" => "payment_required" + ], + [ + "id" => 1234567892, + "status" => "opened", + "external_reference" => "Order_1234567891", + "preference_id" => "123465789-12346578-1234-1234-1234-123456789123", + "payments" => [], + "shipments" => [], + "payouts" => [], + "collector" => [ + "id" => 123465789, + "email" => "", + "nickname" => "TETE4642489" + ], + "marketplace" => "NONE", + "notification_url" => "https://webhook.com", + "date_created" => "2021-09-08T19:30:26.637+00:00", + "last_updated" => "2022-10-06T06:18:44.821-04:00", + "sanitized_version" => 1, + "sponsor_id" => null, + "shipping_cost" => 0, + "total_amount" => 18.37, + "site_id" => "MLB", + "paid_amount" => 0, + "refunded_amount" => 0, + "payer" => null, + "items" => [ + "id" => "40", + "category_id" => "art", + "currency_id" => "BRL", + "description" => "camiseta cinza", + "picture_url" => "https://site/img.jpg", + "picture_id" => "123", + "title" => "Camiseta", + "quantity" => 1, + "unit_price" => 18.37 + ], + "cancelled" => false, + "additional_info" => "", + "application_id" => null, + "is_test" => false, + "order_status" => "payment_required" + ] + ] + ]; + + const MERCHANT_ORDER = [ + "id" => 1234567891, + "status" => "opened", + "external_reference" => "Order_1234567891", + "preference_id" => "123465789-12346578-1234-1234-1234-123456789123", + "payments" => [], + "shipments" => [], + "payouts" => [], + "collector" => [ + "id" => 123465789, + "email" => "", + "nickname" => "TETE4642489" + ], + "marketplace" => "NONE", + "notification_url" => "https://webhook.com", + "date_created" => "2021-09-08T19:30:26.637+00:00", + "last_updated" => "2022-10-06T06:18:44.821-04:00", + "sanitized_version" => 1, + "sponsor_id" => null, + "shipping_cost" => 0, + "total_amount" => 18.37, + "site_id" => "MLB", + "paid_amount" => 0, + "refunded_amount" => 0, + "payer" => null, + "items" => [ + "id" => "40", + "category_id" => "art", + "currency_id" => "BRL", + "description" => "camiseta branca", + "picture_url" => "https://site/img.jpg", + "picture_id" => "123", + "title" => "Camiseta", + "quantity" => 1, + "unit_price" => 18.37 + ], + "cancelled" => false, + "additional_info" => "", + "application_id" => null, + "is_test" => false, + "order_status" => "payment_required" + ]; +} diff --git a/packages/sdk/tests/unit/Mock/PaymentMethodsMock.php b/packages/sdk/tests/unit/Mock/PaymentMethodsMock.php new file mode 100644 index 000000000..85c74660d --- /dev/null +++ b/packages/sdk/tests/unit/Mock/PaymentMethodsMock.php @@ -0,0 +1,55 @@ + "visa", + "settings" => [], + "financial_institutions" => [], + "thumbnail" => "https://url_thumbnail_visa", + "deferred_capture" => "supported", + "secure_thumbnail" => "https://url_secure_thumbnail_visa", + "processing_modes" => ["aggregator"], + "name" => "Visa", + "additional_info_needed" => ["cardholder_name", "cardholder_identification_type", "cardholder_identification_number"], + "payment_type_id" => "credit_card", + "accreditation_time" => 2880, + "min_allowed_amount" => 0.5, + "max_allowed_amount" => 60000, + "status" => "active" + ]; + + const PAYMENT_METHOD_PIX = [ + "id" => "pix", + "settings" => [], + "financial_institutions" => [ + [ + "description" => "PIX", + "id" => "1", + ] + ], + "thumbnail" => "https://url_thumbnail_pix", + "deferred_capture" => "supported", + "secure_thumbnail" => "https://url_secure_thumbnail_pix", + "processing_modes" => ["aggregator"], + "name" => "pix", + "additional_info_needed" => null, + "payment_type_id" => "bank_transfer", + "accreditation_time" => 0, + "min_allowed_amount" => 0.01, + "max_allowed_amount" => 9999999, + "status" => "active" + ]; + +const PAYMENT_METHODS = [PaymentMethodsMock::PAYMENT_METHOD_VISA, PaymentMethodsMock::PAYMENT_METHOD_PIX]; + +const GROUPED_PAYMENT_METHODS_BY_ID = [ + "visa" => PaymentMethodsMock::PAYMENT_METHOD_VISA, + "pix" => PaymentMethodsMock::PAYMENT_METHOD_PIX + ]; +} diff --git a/packages/sdk/tests/unit/Mock/RegisterErrorLogMock.php b/packages/sdk/tests/unit/Mock/RegisterErrorLogMock.php new file mode 100644 index 000000000..b7a51902f --- /dev/null +++ b/packages/sdk/tests/unit/Mock/RegisterErrorLogMock.php @@ -0,0 +1,26 @@ + "Error to send payment", + "stacktrace" => "test.go", + "uri" => "/checkout", + "url" => "https=>//", + "location" => "/main=>83", + "platform_version" => "1.2.3", + "module_version" => "9.5.0", + "runtime_version" => "PHP 7.0", + "os_version" => "ubuntu bionic", + "browser_version" => "50.80.3", + "details" => [ + "payment_id" => "123" + ] + ]; +} diff --git a/packages/sdk/tests/unit/Mock/SellerFunnelBaseMock.php b/packages/sdk/tests/unit/Mock/SellerFunnelBaseMock.php new file mode 100644 index 000000000..9472f53c3 --- /dev/null +++ b/packages/sdk/tests/unit/Mock/SellerFunnelBaseMock.php @@ -0,0 +1,30 @@ + "ppcoreinternal", + "shopUrl" => "http://localhost" + ]; + + const COMPLETE_UPDATE_SELLER_BASE = [ + "id" => "d06e1a4510ab404d34af3f738834a617", + "is_added_production_credential" => true, + "is_added_test_credential" => true, + "productId" => "4das56", + "custId" => "123", + "applicationId" => "123", + "pluginMode" => "prod", + "isDeleted" => false, + "acceptedPayments" => [ + "bolbradesco", + "pix" + ] + ]; +} diff --git a/packages/sdk/tests/unit/SdkTest.php b/packages/sdk/tests/unit/SdkTest.php index d9f1b2d42..c27a67fe2 100644 --- a/packages/sdk/tests/unit/SdkTest.php +++ b/packages/sdk/tests/unit/SdkTest.php @@ -63,7 +63,7 @@ protected function setUp(): void ->disableOriginalConstructor() ->getMock(); - $this->sdk = new Sdk('access_token', 'platform_id', 'product_id', 'integrator_id'); + $this->sdk = new Sdk('access_token', 'platform_id', 'product_id', 'integrator_id', 'publicKey'); } function testGetPreferenceSuccess() @@ -122,10 +122,24 @@ function testGetMultipaymentV21Success() $this->assertInstanceOf('MercadoPago\PP\Sdk\Entity\Payment\MultipaymentV21', $actual); } - function testGetMelidataErrorSuccess() + function testGetDatadogEventSuccess() { - $actual = $this->sdk->getMelidataErrorInstance(); + $actual = $this->sdk->getDatadogEventInstance(); - $this->assertInstanceOf('MercadoPago\PP\Sdk\Entity\Monitoring\MelidataError', $actual); + $this->assertInstanceOf('MercadoPago\PP\Sdk\Entity\Monitoring\DatadogEvent', $actual); + } + + function testGetRegisterErrorLogSuccess() + { + $actual = $this->sdk->getRegisterErrorLogInstance(); + + $this->assertInstanceOf('MercadoPago\PP\Sdk\Entity\Monitoring\RegisterErrorLog', $actual); + } + + function testGetMerchantOrderSuccess() + { + $actual = $this->sdk->getMerchantOrderInstance(); + + $this->assertInstanceOf('MercadoPago\PP\Sdk\Entity\MerchantOrder\MerchantOrder', $actual); } } diff --git a/packages/sdk/vendor/autoload.php b/packages/sdk/vendor/autoload.php deleted file mode 100644 index 01ccfc7cb..000000000 --- a/packages/sdk/vendor/autoload.php +++ /dev/null @@ -1,25 +0,0 @@ - - * Jordi Boggiano - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer\Autoload; - -/** - * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. - * - * $loader = new \Composer\Autoload\ClassLoader(); - * - * // register classes with namespaces - * $loader->add('Symfony\Component', __DIR__.'/component'); - * $loader->add('Symfony', __DIR__.'/framework'); - * - * // activate the autoloader - * $loader->register(); - * - * // to enable searching the include path (eg. for PEAR packages) - * $loader->setUseIncludePath(true); - * - * In this example, if you try to use a class in the Symfony\Component - * namespace or one of its children (Symfony\Component\Console for instance), - * the autoloader will first look for the class under the component/ - * directory, and it will then fallback to the framework/ directory if not - * found before giving up. - * - * This class is loosely based on the Symfony UniversalClassLoader. - * - * @author Fabien Potencier - * @author Jordi Boggiano - * @see https://www.php-fig.org/psr/psr-0/ - * @see https://www.php-fig.org/psr/psr-4/ - */ -class ClassLoader -{ - /** @var \Closure(string):void */ - private static $includeFile; - - /** @var ?string */ - private $vendorDir; - - // PSR-4 - /** - * @var array[] - * @psalm-var array> - */ - private $prefixLengthsPsr4 = array(); - /** - * @var array[] - * @psalm-var array> - */ - private $prefixDirsPsr4 = array(); - /** - * @var array[] - * @psalm-var array - */ - private $fallbackDirsPsr4 = array(); - - // PSR-0 - /** - * @var array[] - * @psalm-var array> - */ - private $prefixesPsr0 = array(); - /** - * @var array[] - * @psalm-var array - */ - private $fallbackDirsPsr0 = array(); - - /** @var bool */ - private $useIncludePath = false; - - /** - * @var string[] - * @psalm-var array - */ - private $classMap = array(); - - /** @var bool */ - private $classMapAuthoritative = false; - - /** - * @var bool[] - * @psalm-var array - */ - private $missingClasses = array(); - - /** @var ?string */ - private $apcuPrefix; - - /** - * @var self[] - */ - private static $registeredLoaders = array(); - - /** - * @param ?string $vendorDir - */ - public function __construct($vendorDir = null) - { - $this->vendorDir = $vendorDir; - self::initializeIncludeClosure(); - } - - /** - * @return string[] - */ - public function getPrefixes() - { - if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); - } - - return array(); - } - - /** - * @return array[] - * @psalm-return array> - */ - public function getPrefixesPsr4() - { - return $this->prefixDirsPsr4; - } - - /** - * @return array[] - * @psalm-return array - */ - public function getFallbackDirs() - { - return $this->fallbackDirsPsr0; - } - - /** - * @return array[] - * @psalm-return array - */ - public function getFallbackDirsPsr4() - { - return $this->fallbackDirsPsr4; - } - - /** - * @return string[] Array of classname => path - * @psalm-return array - */ - public function getClassMap() - { - return $this->classMap; - } - - /** - * @param string[] $classMap Class to filename map - * @psalm-param array $classMap - * - * @return void - */ - public function addClassMap(array $classMap) - { - if ($this->classMap) { - $this->classMap = array_merge($this->classMap, $classMap); - } else { - $this->classMap = $classMap; - } - } - - /** - * Registers a set of PSR-0 directories for a given prefix, either - * appending or prepending to the ones previously set for this prefix. - * - * @param string $prefix The prefix - * @param string[]|string $paths The PSR-0 root directories - * @param bool $prepend Whether to prepend the directories - * - * @return void - */ - public function add($prefix, $paths, $prepend = false) - { - if (!$prefix) { - if ($prepend) { - $this->fallbackDirsPsr0 = array_merge( - (array) $paths, - $this->fallbackDirsPsr0 - ); - } else { - $this->fallbackDirsPsr0 = array_merge( - $this->fallbackDirsPsr0, - (array) $paths - ); - } - - return; - } - - $first = $prefix[0]; - if (!isset($this->prefixesPsr0[$first][$prefix])) { - $this->prefixesPsr0[$first][$prefix] = (array) $paths; - - return; - } - if ($prepend) { - $this->prefixesPsr0[$first][$prefix] = array_merge( - (array) $paths, - $this->prefixesPsr0[$first][$prefix] - ); - } else { - $this->prefixesPsr0[$first][$prefix] = array_merge( - $this->prefixesPsr0[$first][$prefix], - (array) $paths - ); - } - } - - /** - * Registers a set of PSR-4 directories for a given namespace, either - * appending or prepending to the ones previously set for this namespace. - * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param string[]|string $paths The PSR-4 base directories - * @param bool $prepend Whether to prepend the directories - * - * @throws \InvalidArgumentException - * - * @return void - */ - public function addPsr4($prefix, $paths, $prepend = false) - { - if (!$prefix) { - // Register directories for the root namespace. - if ($prepend) { - $this->fallbackDirsPsr4 = array_merge( - (array) $paths, - $this->fallbackDirsPsr4 - ); - } else { - $this->fallbackDirsPsr4 = array_merge( - $this->fallbackDirsPsr4, - (array) $paths - ); - } - } elseif (!isset($this->prefixDirsPsr4[$prefix])) { - // Register directories for a new namespace. - $length = strlen($prefix); - if ('\\' !== $prefix[$length - 1]) { - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); - } - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = (array) $paths; - } elseif ($prepend) { - // Prepend directories for an already registered namespace. - $this->prefixDirsPsr4[$prefix] = array_merge( - (array) $paths, - $this->prefixDirsPsr4[$prefix] - ); - } else { - // Append directories for an already registered namespace. - $this->prefixDirsPsr4[$prefix] = array_merge( - $this->prefixDirsPsr4[$prefix], - (array) $paths - ); - } - } - - /** - * Registers a set of PSR-0 directories for a given prefix, - * replacing any others previously set for this prefix. - * - * @param string $prefix The prefix - * @param string[]|string $paths The PSR-0 base directories - * - * @return void - */ - public function set($prefix, $paths) - { - if (!$prefix) { - $this->fallbackDirsPsr0 = (array) $paths; - } else { - $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; - } - } - - /** - * Registers a set of PSR-4 directories for a given namespace, - * replacing any others previously set for this namespace. - * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param string[]|string $paths The PSR-4 base directories - * - * @throws \InvalidArgumentException - * - * @return void - */ - public function setPsr4($prefix, $paths) - { - if (!$prefix) { - $this->fallbackDirsPsr4 = (array) $paths; - } else { - $length = strlen($prefix); - if ('\\' !== $prefix[$length - 1]) { - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); - } - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = (array) $paths; - } - } - - /** - * Turns on searching the include path for class files. - * - * @param bool $useIncludePath - * - * @return void - */ - public function setUseIncludePath($useIncludePath) - { - $this->useIncludePath = $useIncludePath; - } - - /** - * Can be used to check if the autoloader uses the include path to check - * for classes. - * - * @return bool - */ - public function getUseIncludePath() - { - return $this->useIncludePath; - } - - /** - * Turns off searching the prefix and fallback directories for classes - * that have not been registered with the class map. - * - * @param bool $classMapAuthoritative - * - * @return void - */ - public function setClassMapAuthoritative($classMapAuthoritative) - { - $this->classMapAuthoritative = $classMapAuthoritative; - } - - /** - * Should class lookup fail if not found in the current class map? - * - * @return bool - */ - public function isClassMapAuthoritative() - { - return $this->classMapAuthoritative; - } - - /** - * APCu prefix to use to cache found/not-found classes, if the extension is enabled. - * - * @param string|null $apcuPrefix - * - * @return void - */ - public function setApcuPrefix($apcuPrefix) - { - $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; - } - - /** - * The APCu prefix in use, or null if APCu caching is not enabled. - * - * @return string|null - */ - public function getApcuPrefix() - { - return $this->apcuPrefix; - } - - /** - * Registers this instance as an autoloader. - * - * @param bool $prepend Whether to prepend the autoloader or not - * - * @return void - */ - public function register($prepend = false) - { - spl_autoload_register(array($this, 'loadClass'), true, $prepend); - - if (null === $this->vendorDir) { - return; - } - - if ($prepend) { - self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders; - } else { - unset(self::$registeredLoaders[$this->vendorDir]); - self::$registeredLoaders[$this->vendorDir] = $this; - } - } - - /** - * Unregisters this instance as an autoloader. - * - * @return void - */ - public function unregister() - { - spl_autoload_unregister(array($this, 'loadClass')); - - if (null !== $this->vendorDir) { - unset(self::$registeredLoaders[$this->vendorDir]); - } - } - - /** - * Loads the given class or interface. - * - * @param string $class The name of the class - * @return true|null True if loaded, null otherwise - */ - public function loadClass($class) - { - if ($file = $this->findFile($class)) { - $includeFile = self::$includeFile; - $includeFile($file); - - return true; - } - - return null; - } - - /** - * Finds the path to the file where the class is defined. - * - * @param string $class The name of the class - * - * @return string|false The path if found, false otherwise - */ - public function findFile($class) - { - // class map lookup - if (isset($this->classMap[$class])) { - return $this->classMap[$class]; - } - if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { - return false; - } - if (null !== $this->apcuPrefix) { - $file = apcu_fetch($this->apcuPrefix.$class, $hit); - if ($hit) { - return $file; - } - } - - $file = $this->findFileWithExtension($class, '.php'); - - // Search for Hack files if we are running on HHVM - if (false === $file && defined('HHVM_VERSION')) { - $file = $this->findFileWithExtension($class, '.hh'); - } - - if (null !== $this->apcuPrefix) { - apcu_add($this->apcuPrefix.$class, $file); - } - - if (false === $file) { - // Remember that this class does not exist. - $this->missingClasses[$class] = true; - } - - return $file; - } - - /** - * Returns the currently registered loaders indexed by their corresponding vendor directories. - * - * @return self[] - */ - public static function getRegisteredLoaders() - { - return self::$registeredLoaders; - } - - /** - * @param string $class - * @param string $ext - * @return string|false - */ - private function findFileWithExtension($class, $ext) - { - // PSR-4 lookup - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; - - $first = $class[0]; - if (isset($this->prefixLengthsPsr4[$first])) { - $subPath = $class; - while (false !== $lastPos = strrpos($subPath, '\\')) { - $subPath = substr($subPath, 0, $lastPos); - $search = $subPath . '\\'; - if (isset($this->prefixDirsPsr4[$search])) { - $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); - foreach ($this->prefixDirsPsr4[$search] as $dir) { - if (file_exists($file = $dir . $pathEnd)) { - return $file; - } - } - } - } - } - - // PSR-4 fallback dirs - foreach ($this->fallbackDirsPsr4 as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { - return $file; - } - } - - // PSR-0 lookup - if (false !== $pos = strrpos($class, '\\')) { - // namespaced class name - $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) - . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); - } else { - // PEAR-like class name - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; - } - - if (isset($this->prefixesPsr0[$first])) { - foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { - if (0 === strpos($class, $prefix)) { - foreach ($dirs as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { - return $file; - } - } - } - } - } - - // PSR-0 fallback dirs - foreach ($this->fallbackDirsPsr0 as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { - return $file; - } - } - - // PSR-0 include paths. - if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { - return $file; - } - - return false; - } - - /** - * @return void - */ - private static function initializeIncludeClosure() - { - if (self::$includeFile !== null) { - return; - } - - /** - * Scope isolated include. - * - * Prevents access to $this/self from included files. - * - * @param string $file - * @return void - */ - self::$includeFile = \Closure::bind(static function($file) { - include $file; - }, null, null); - } -} diff --git a/packages/sdk/vendor/composer/InstalledVersions.php b/packages/sdk/vendor/composer/InstalledVersions.php deleted file mode 100644 index 51e734a77..000000000 --- a/packages/sdk/vendor/composer/InstalledVersions.php +++ /dev/null @@ -1,359 +0,0 @@ - - * Jordi Boggiano - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer; - -use Composer\Autoload\ClassLoader; -use Composer\Semver\VersionParser; - -/** - * This class is copied in every Composer installed project and available to all - * - * See also https://getcomposer.org/doc/07-runtime.md#installed-versions - * - * To require its presence, you can require `composer-runtime-api ^2.0` - * - * @final - */ -class InstalledVersions -{ - /** - * @var mixed[]|null - * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array}|array{}|null - */ - private static $installed; - - /** - * @var bool|null - */ - private static $canGetVendors; - - /** - * @var array[] - * @psalm-var array}> - */ - private static $installedByVendor = array(); - - /** - * Returns a list of all package names which are present, either by being installed, replaced or provided - * - * @return string[] - * @psalm-return list - */ - public static function getInstalledPackages() - { - $packages = array(); - foreach (self::getInstalled() as $installed) { - $packages[] = array_keys($installed['versions']); - } - - if (1 === \count($packages)) { - return $packages[0]; - } - - return array_keys(array_flip(\call_user_func_array('array_merge', $packages))); - } - - /** - * Returns a list of all package names with a specific type e.g. 'library' - * - * @param string $type - * @return string[] - * @psalm-return list - */ - public static function getInstalledPackagesByType($type) - { - $packagesByType = array(); - - foreach (self::getInstalled() as $installed) { - foreach ($installed['versions'] as $name => $package) { - if (isset($package['type']) && $package['type'] === $type) { - $packagesByType[] = $name; - } - } - } - - return $packagesByType; - } - - /** - * Checks whether the given package is installed - * - * This also returns true if the package name is provided or replaced by another package - * - * @param string $packageName - * @param bool $includeDevRequirements - * @return bool - */ - public static function isInstalled($packageName, $includeDevRequirements = true) - { - foreach (self::getInstalled() as $installed) { - if (isset($installed['versions'][$packageName])) { - return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false; - } - } - - return false; - } - - /** - * Checks whether the given package satisfies a version constraint - * - * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call: - * - * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3') - * - * @param VersionParser $parser Install composer/semver to have access to this class and functionality - * @param string $packageName - * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package - * @return bool - */ - public static function satisfies(VersionParser $parser, $packageName, $constraint) - { - $constraint = $parser->parseConstraints((string) $constraint); - $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); - - return $provided->matches($constraint); - } - - /** - * Returns a version constraint representing all the range(s) which are installed for a given package - * - * It is easier to use this via isInstalled() with the $constraint argument if you need to check - * whether a given version of a package is installed, and not just whether it exists - * - * @param string $packageName - * @return string Version constraint usable with composer/semver - */ - public static function getVersionRanges($packageName) - { - foreach (self::getInstalled() as $installed) { - if (!isset($installed['versions'][$packageName])) { - continue; - } - - $ranges = array(); - if (isset($installed['versions'][$packageName]['pretty_version'])) { - $ranges[] = $installed['versions'][$packageName]['pretty_version']; - } - if (array_key_exists('aliases', $installed['versions'][$packageName])) { - $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']); - } - if (array_key_exists('replaced', $installed['versions'][$packageName])) { - $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']); - } - if (array_key_exists('provided', $installed['versions'][$packageName])) { - $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']); - } - - return implode(' || ', $ranges); - } - - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); - } - - /** - * @param string $packageName - * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present - */ - public static function getVersion($packageName) - { - foreach (self::getInstalled() as $installed) { - if (!isset($installed['versions'][$packageName])) { - continue; - } - - if (!isset($installed['versions'][$packageName]['version'])) { - return null; - } - - return $installed['versions'][$packageName]['version']; - } - - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); - } - - /** - * @param string $packageName - * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present - */ - public static function getPrettyVersion($packageName) - { - foreach (self::getInstalled() as $installed) { - if (!isset($installed['versions'][$packageName])) { - continue; - } - - if (!isset($installed['versions'][$packageName]['pretty_version'])) { - return null; - } - - return $installed['versions'][$packageName]['pretty_version']; - } - - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); - } - - /** - * @param string $packageName - * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference - */ - public static function getReference($packageName) - { - foreach (self::getInstalled() as $installed) { - if (!isset($installed['versions'][$packageName])) { - continue; - } - - if (!isset($installed['versions'][$packageName]['reference'])) { - return null; - } - - return $installed['versions'][$packageName]['reference']; - } - - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); - } - - /** - * @param string $packageName - * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path. - */ - public static function getInstallPath($packageName) - { - foreach (self::getInstalled() as $installed) { - if (!isset($installed['versions'][$packageName])) { - continue; - } - - return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null; - } - - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); - } - - /** - * @return array - * @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool} - */ - public static function getRootPackage() - { - $installed = self::getInstalled(); - - return $installed[0]['root']; - } - - /** - * Returns the raw installed.php data for custom implementations - * - * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect. - * @return array[] - * @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} - */ - public static function getRawData() - { - @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED); - - if (null === self::$installed) { - // only require the installed.php file if this file is loaded from its dumped location, - // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 - if (substr(__DIR__, -8, 1) !== 'C') { - self::$installed = include __DIR__ . '/installed.php'; - } else { - self::$installed = array(); - } - } - - return self::$installed; - } - - /** - * Returns the raw data of all installed.php which are currently loaded for custom implementations - * - * @return array[] - * @psalm-return list}> - */ - public static function getAllRawData() - { - return self::getInstalled(); - } - - /** - * Lets you reload the static array from another file - * - * This is only useful for complex integrations in which a project needs to use - * this class but then also needs to execute another project's autoloader in process, - * and wants to ensure both projects have access to their version of installed.php. - * - * A typical case would be PHPUnit, where it would need to make sure it reads all - * the data it needs from this class, then call reload() with - * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure - * the project in which it runs can then also use this class safely, without - * interference between PHPUnit's dependencies and the project's dependencies. - * - * @param array[] $data A vendor/composer/installed.php data set - * @return void - * - * @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $data - */ - public static function reload($data) - { - self::$installed = $data; - self::$installedByVendor = array(); - } - - /** - * @return array[] - * @psalm-return list}> - */ - private static function getInstalled() - { - if (null === self::$canGetVendors) { - self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders'); - } - - $installed = array(); - - if (self::$canGetVendors) { - foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { - if (isset(self::$installedByVendor[$vendorDir])) { - $installed[] = self::$installedByVendor[$vendorDir]; - } elseif (is_file($vendorDir.'/composer/installed.php')) { - /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ - $required = require $vendorDir.'/composer/installed.php'; - $installed[] = self::$installedByVendor[$vendorDir] = $required; - if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { - self::$installed = $installed[count($installed) - 1]; - } - } - } - } - - if (null === self::$installed) { - // only require the installed.php file if this file is loaded from its dumped location, - // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 - if (substr(__DIR__, -8, 1) !== 'C') { - /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ - $required = require __DIR__ . '/installed.php'; - self::$installed = $required; - } else { - self::$installed = array(); - } - } - - if (self::$installed !== array()) { - $installed[] = self::$installed; - } - - return $installed; - } -} diff --git a/packages/sdk/vendor/composer/LICENSE b/packages/sdk/vendor/composer/LICENSE deleted file mode 100644 index f27399a04..000000000 --- a/packages/sdk/vendor/composer/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ - -Copyright (c) Nils Adermann, Jordi Boggiano - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - diff --git a/packages/sdk/vendor/composer/autoload_classmap.php b/packages/sdk/vendor/composer/autoload_classmap.php deleted file mode 100644 index 5aa2e1a85..000000000 --- a/packages/sdk/vendor/composer/autoload_classmap.php +++ /dev/null @@ -1,77 +0,0 @@ - $vendorDir . '/composer/InstalledVersions.php', - 'MercadoPago\\PP\\Sdk\\Common\\AbstractCollection' => $baseDir . '/src/Common/AbstractCollection.php', - 'MercadoPago\\PP\\Sdk\\Common\\AbstractEntity' => $baseDir . '/src/Common/AbstractEntity.php', - 'MercadoPago\\PP\\Sdk\\Common\\Config' => $baseDir . '/src/Common/Config.php', - 'MercadoPago\\PP\\Sdk\\Common\\Constants' => $baseDir . '/src/Common/Constants.php', - 'MercadoPago\\PP\\Sdk\\Common\\Manager' => $baseDir . '/src/Common/Manager.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Notification\\Notification' => $baseDir . '/src/Entity/Notification/Notification.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Notification\\PaymentDetails' => $baseDir . '/src/Entity/Notification/PaymentDetails.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Notification\\PaymentDetailsList' => $baseDir . '/src/Entity/Notification/PaymentDetailsList.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Notification\\PaymentMethodInfo' => $baseDir . '/src/Entity/Notification/PaymentMethodInfo.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Notification\\Refund' => $baseDir . '/src/Entity/Notification/Refund.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Notification\\RefundList' => $baseDir . '/src/Entity/Notification/RefundList.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Notification\\RefundNotifying' => $baseDir . '/src/Entity/Notification/RefundNotifying.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Notification\\RefundNotifyingList' => $baseDir . '/src/Entity/Notification/RefundNotifyingList.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\AdditionalInfo' => $baseDir . '/src/Entity/Payment/AdditionalInfo.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\AdditionalInfoAddress' => $baseDir . '/src/Entity/Payment/AdditionalInfoAddress.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\AdditionalInfoPayer' => $baseDir . '/src/Entity/Payment/AdditionalInfoPayer.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\Address' => $baseDir . '/src/Entity/Payment/Address.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\ApplicationData' => $baseDir . '/src/Entity/Payment/ApplicationData.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\BankInfo' => $baseDir . '/src/Entity/Payment/BankInfo.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\Identification' => $baseDir . '/src/Entity/Payment/Identification.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\Item' => $baseDir . '/src/Entity/Payment/Item.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\ItemList' => $baseDir . '/src/Entity/Payment/ItemList.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\Multipayment' => $baseDir . '/src/Entity/Payment/Multipayment.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\MultipaymentV2' => $baseDir . '/src/Entity/Payment/MultipaymentV2.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\MultipaymentV21' => $baseDir . '/src/Entity/Payment/MultipaymentV21.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\Payer' => $baseDir . '/src/Entity/Payment/Payer.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\Payment' => $baseDir . '/src/Entity/Payment/Payment.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\PaymentV2' => $baseDir . '/src/Entity/Payment/PaymentV2.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\PaymentV21' => $baseDir . '/src/Entity/Payment/PaymentV21.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\Phone' => $baseDir . '/src/Entity/Payment/Phone.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\PointOfInteraction' => $baseDir . '/src/Entity/Payment/PointOfInteraction.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\ReceiverAddress' => $baseDir . '/src/Entity/Payment/ReceiverAddress.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\Seller' => $baseDir . '/src/Entity/Payment/Seller.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\Shipments' => $baseDir . '/src/Entity/Payment/Shipments.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\Tracking' => $baseDir . '/src/Entity/Payment/Tracking.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\TransactionData' => $baseDir . '/src/Entity/Payment/TransactionData.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\TransactionDetails' => $baseDir . '/src/Entity/Payment/TransactionDetails.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\TransactionInfo' => $baseDir . '/src/Entity/Payment/TransactionInfo.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\TransactionInfoList' => $baseDir . '/src/Entity/Payment/TransactionInfoList.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\Address' => $baseDir . '/src/Entity/Preference/Address.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\BackUrl' => $baseDir . '/src/Entity/Preference/BackUrl.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\DifferentialPricing' => $baseDir . '/src/Entity/Preference/DifferentialPricing.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\ExcludedPaymentMethod' => $baseDir . '/src/Entity/Preference/ExcludedPaymentMethod.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\ExcludedPaymentMethodList' => $baseDir . '/src/Entity/Preference/ExcludedPaymentMethodList.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\ExcludedPaymentType' => $baseDir . '/src/Entity/Preference/ExcludedPaymentType.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\ExcludedPaymentTypeList' => $baseDir . '/src/Entity/Preference/ExcludedPaymentTypeList.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\FreeMethod' => $baseDir . '/src/Entity/Preference/FreeMethod.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\FreeMethodList' => $baseDir . '/src/Entity/Preference/FreeMethodList.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\Item' => $baseDir . '/src/Entity/Preference/Item.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\ItemList' => $baseDir . '/src/Entity/Preference/ItemList.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\Payer' => $baseDir . '/src/Entity/Preference/Payer.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\PayerIdentification' => $baseDir . '/src/Entity/Preference/PayerIdentification.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\PaymentMethod' => $baseDir . '/src/Entity/Preference/PaymentMethod.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\Phone' => $baseDir . '/src/Entity/Preference/Phone.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\Preference' => $baseDir . '/src/Entity/Preference/Preference.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\ReceiverAddress' => $baseDir . '/src/Entity/Preference/ReceiverAddress.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\Shipment' => $baseDir . '/src/Entity/Preference/Shipment.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\Track' => $baseDir . '/src/Entity/Preference/Track.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\TrackList' => $baseDir . '/src/Entity/Preference/TrackList.php', - 'MercadoPago\\PP\\Sdk\\HttpClient\\HttpClient' => $baseDir . '/src/HttpClient/HttpClient.php', - 'MercadoPago\\PP\\Sdk\\HttpClient\\HttpClientInterface' => $baseDir . '/src/HttpClient/HttpClientInterface.php', - 'MercadoPago\\PP\\Sdk\\HttpClient\\Requester\\CurlRequester' => $baseDir . '/src/HttpClient/Requester/CurlRequester.php', - 'MercadoPago\\PP\\Sdk\\HttpClient\\Requester\\RequesterInterface' => $baseDir . '/src/HttpClient/Requester/RequesterInterface.php', - 'MercadoPago\\PP\\Sdk\\HttpClient\\Response' => $baseDir . '/src/HttpClient/Response.php', - 'MercadoPago\\PP\\Sdk\\Interfaces\\EntityInterface' => $baseDir . '/src/Interfaces/EntityInterface.php', - 'MercadoPago\\PP\\Sdk\\Interfaces\\RequesterEntityInterface' => $baseDir . '/src/Interfaces/RequesterEntityInterface.php', - 'MercadoPago\\PP\\Sdk\\Sdk' => $baseDir . '/src/Sdk.php', -); diff --git a/packages/sdk/vendor/composer/autoload_namespaces.php b/packages/sdk/vendor/composer/autoload_namespaces.php deleted file mode 100644 index 15a2ff3ad..000000000 --- a/packages/sdk/vendor/composer/autoload_namespaces.php +++ /dev/null @@ -1,9 +0,0 @@ - array($baseDir . '/src'), -); diff --git a/packages/sdk/vendor/composer/autoload_real.php b/packages/sdk/vendor/composer/autoload_real.php deleted file mode 100644 index 6609d7c12..000000000 --- a/packages/sdk/vendor/composer/autoload_real.php +++ /dev/null @@ -1,38 +0,0 @@ -register(true); - - return $loader; - } -} diff --git a/packages/sdk/vendor/composer/autoload_static.php b/packages/sdk/vendor/composer/autoload_static.php deleted file mode 100644 index aa5cb441f..000000000 --- a/packages/sdk/vendor/composer/autoload_static.php +++ /dev/null @@ -1,103 +0,0 @@ - - array ( - 'MercadoPago\\PP\\Sdk\\' => 19, - ), - ); - - public static $prefixDirsPsr4 = array ( - 'MercadoPago\\PP\\Sdk\\' => - array ( - 0 => __DIR__ . '/../..' . '/src', - ), - ); - - public static $classMap = array ( - 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', - 'MercadoPago\\PP\\Sdk\\Common\\AbstractCollection' => __DIR__ . '/../..' . '/src/Common/AbstractCollection.php', - 'MercadoPago\\PP\\Sdk\\Common\\AbstractEntity' => __DIR__ . '/../..' . '/src/Common/AbstractEntity.php', - 'MercadoPago\\PP\\Sdk\\Common\\Config' => __DIR__ . '/../..' . '/src/Common/Config.php', - 'MercadoPago\\PP\\Sdk\\Common\\Constants' => __DIR__ . '/../..' . '/src/Common/Constants.php', - 'MercadoPago\\PP\\Sdk\\Common\\Manager' => __DIR__ . '/../..' . '/src/Common/Manager.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Notification\\Notification' => __DIR__ . '/../..' . '/src/Entity/Notification/Notification.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Notification\\PaymentDetails' => __DIR__ . '/../..' . '/src/Entity/Notification/PaymentDetails.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Notification\\PaymentDetailsList' => __DIR__ . '/../..' . '/src/Entity/Notification/PaymentDetailsList.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Notification\\PaymentMethodInfo' => __DIR__ . '/../..' . '/src/Entity/Notification/PaymentMethodInfo.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Notification\\Refund' => __DIR__ . '/../..' . '/src/Entity/Notification/Refund.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Notification\\RefundList' => __DIR__ . '/../..' . '/src/Entity/Notification/RefundList.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Notification\\RefundNotifying' => __DIR__ . '/../..' . '/src/Entity/Notification/RefundNotifying.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Notification\\RefundNotifyingList' => __DIR__ . '/../..' . '/src/Entity/Notification/RefundNotifyingList.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\AdditionalInfo' => __DIR__ . '/../..' . '/src/Entity/Payment/AdditionalInfo.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\AdditionalInfoAddress' => __DIR__ . '/../..' . '/src/Entity/Payment/AdditionalInfoAddress.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\AdditionalInfoPayer' => __DIR__ . '/../..' . '/src/Entity/Payment/AdditionalInfoPayer.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\Address' => __DIR__ . '/../..' . '/src/Entity/Payment/Address.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\ApplicationData' => __DIR__ . '/../..' . '/src/Entity/Payment/ApplicationData.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\BankInfo' => __DIR__ . '/../..' . '/src/Entity/Payment/BankInfo.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\Identification' => __DIR__ . '/../..' . '/src/Entity/Payment/Identification.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\Item' => __DIR__ . '/../..' . '/src/Entity/Payment/Item.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\ItemList' => __DIR__ . '/../..' . '/src/Entity/Payment/ItemList.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\Multipayment' => __DIR__ . '/../..' . '/src/Entity/Payment/Multipayment.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\MultipaymentV2' => __DIR__ . '/../..' . '/src/Entity/Payment/MultipaymentV2.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\MultipaymentV21' => __DIR__ . '/../..' . '/src/Entity/Payment/MultipaymentV21.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\Payer' => __DIR__ . '/../..' . '/src/Entity/Payment/Payer.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\Payment' => __DIR__ . '/../..' . '/src/Entity/Payment/Payment.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\PaymentV2' => __DIR__ . '/../..' . '/src/Entity/Payment/PaymentV2.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\PaymentV21' => __DIR__ . '/../..' . '/src/Entity/Payment/PaymentV21.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\Phone' => __DIR__ . '/../..' . '/src/Entity/Payment/Phone.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\PointOfInteraction' => __DIR__ . '/../..' . '/src/Entity/Payment/PointOfInteraction.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\ReceiverAddress' => __DIR__ . '/../..' . '/src/Entity/Payment/ReceiverAddress.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\Seller' => __DIR__ . '/../..' . '/src/Entity/Payment/Seller.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\Shipments' => __DIR__ . '/../..' . '/src/Entity/Payment/Shipments.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\Tracking' => __DIR__ . '/../..' . '/src/Entity/Payment/Tracking.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\TransactionData' => __DIR__ . '/../..' . '/src/Entity/Payment/TransactionData.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\TransactionDetails' => __DIR__ . '/../..' . '/src/Entity/Payment/TransactionDetails.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\TransactionInfo' => __DIR__ . '/../..' . '/src/Entity/Payment/TransactionInfo.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Payment\\TransactionInfoList' => __DIR__ . '/../..' . '/src/Entity/Payment/TransactionInfoList.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\Address' => __DIR__ . '/../..' . '/src/Entity/Preference/Address.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\BackUrl' => __DIR__ . '/../..' . '/src/Entity/Preference/BackUrl.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\DifferentialPricing' => __DIR__ . '/../..' . '/src/Entity/Preference/DifferentialPricing.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\ExcludedPaymentMethod' => __DIR__ . '/../..' . '/src/Entity/Preference/ExcludedPaymentMethod.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\ExcludedPaymentMethodList' => __DIR__ . '/../..' . '/src/Entity/Preference/ExcludedPaymentMethodList.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\ExcludedPaymentType' => __DIR__ . '/../..' . '/src/Entity/Preference/ExcludedPaymentType.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\ExcludedPaymentTypeList' => __DIR__ . '/../..' . '/src/Entity/Preference/ExcludedPaymentTypeList.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\FreeMethod' => __DIR__ . '/../..' . '/src/Entity/Preference/FreeMethod.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\FreeMethodList' => __DIR__ . '/../..' . '/src/Entity/Preference/FreeMethodList.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\Item' => __DIR__ . '/../..' . '/src/Entity/Preference/Item.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\ItemList' => __DIR__ . '/../..' . '/src/Entity/Preference/ItemList.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\Payer' => __DIR__ . '/../..' . '/src/Entity/Preference/Payer.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\PayerIdentification' => __DIR__ . '/../..' . '/src/Entity/Preference/PayerIdentification.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\PaymentMethod' => __DIR__ . '/../..' . '/src/Entity/Preference/PaymentMethod.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\Phone' => __DIR__ . '/../..' . '/src/Entity/Preference/Phone.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\Preference' => __DIR__ . '/../..' . '/src/Entity/Preference/Preference.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\ReceiverAddress' => __DIR__ . '/../..' . '/src/Entity/Preference/ReceiverAddress.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\Shipment' => __DIR__ . '/../..' . '/src/Entity/Preference/Shipment.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\Track' => __DIR__ . '/../..' . '/src/Entity/Preference/Track.php', - 'MercadoPago\\PP\\Sdk\\Entity\\Preference\\TrackList' => __DIR__ . '/../..' . '/src/Entity/Preference/TrackList.php', - 'MercadoPago\\PP\\Sdk\\HttpClient\\HttpClient' => __DIR__ . '/../..' . '/src/HttpClient/HttpClient.php', - 'MercadoPago\\PP\\Sdk\\HttpClient\\HttpClientInterface' => __DIR__ . '/../..' . '/src/HttpClient/HttpClientInterface.php', - 'MercadoPago\\PP\\Sdk\\HttpClient\\Requester\\CurlRequester' => __DIR__ . '/../..' . '/src/HttpClient/Requester/CurlRequester.php', - 'MercadoPago\\PP\\Sdk\\HttpClient\\Requester\\RequesterInterface' => __DIR__ . '/../..' . '/src/HttpClient/Requester/RequesterInterface.php', - 'MercadoPago\\PP\\Sdk\\HttpClient\\Response' => __DIR__ . '/../..' . '/src/HttpClient/Response.php', - 'MercadoPago\\PP\\Sdk\\Interfaces\\EntityInterface' => __DIR__ . '/../..' . '/src/Interfaces/EntityInterface.php', - 'MercadoPago\\PP\\Sdk\\Interfaces\\RequesterEntityInterface' => __DIR__ . '/../..' . '/src/Interfaces/RequesterEntityInterface.php', - 'MercadoPago\\PP\\Sdk\\Sdk' => __DIR__ . '/../..' . '/src/Sdk.php', - ); - - public static function getInitializer(ClassLoader $loader) - { - return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit803ba592a00aae6fcb38e9b3874cce62::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit803ba592a00aae6fcb38e9b3874cce62::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInit803ba592a00aae6fcb38e9b3874cce62::$classMap; - - }, null, ClassLoader::class); - } -} diff --git a/packages/sdk/vendor/composer/installed.json b/packages/sdk/vendor/composer/installed.json deleted file mode 100644 index f20a6c47c..000000000 --- a/packages/sdk/vendor/composer/installed.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "packages": [], - "dev": false, - "dev-package-names": [] -} diff --git a/packages/sdk/vendor/composer/installed.php b/packages/sdk/vendor/composer/installed.php deleted file mode 100644 index 0b5010048..000000000 --- a/packages/sdk/vendor/composer/installed.php +++ /dev/null @@ -1,23 +0,0 @@ - array( - 'name' => 'mp-plugins/php-sdk', - 'pretty_version' => '1.9.0', - 'version' => '1.9.0.0', - 'reference' => NULL, - 'type' => 'library', - 'install_path' => __DIR__ . '/../../', - 'aliases' => array(), - 'dev' => false, - ), - 'versions' => array( - 'mp-plugins/php-sdk' => array( - 'pretty_version' => '1.9.0', - 'version' => '1.9.0.0', - 'reference' => NULL, - 'type' => 'library', - 'install_path' => __DIR__ . '/../../', - 'aliases' => array(), - 'dev_requirement' => false, - ), - ), -); diff --git a/packages/sdk/vendor/composer/platform_check.php b/packages/sdk/vendor/composer/platform_check.php deleted file mode 100644 index f79e574be..000000000 --- a/packages/sdk/vendor/composer/platform_check.php +++ /dev/null @@ -1,26 +0,0 @@ -= 70000)) { - $issues[] = 'Your Composer dependencies require a PHP version ">= 7.0.0". You are running ' . PHP_VERSION . '.'; -} - -if ($issues) { - if (!headers_sent()) { - header('HTTP/1.1 500 Internal Server Error'); - } - if (!ini_get('display_errors')) { - if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { - fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL); - } elseif (!headers_sent()) { - echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL; - } - } - trigger_error( - 'Composer detected issues in your platform: ' . implode(' ', $issues), - E_USER_ERROR - ); -}