From 8e2995284827c3eae82295ba7c9b636381548245 Mon Sep 17 00:00:00 2001 From: Douglas Date: Mon, 23 Sep 2024 09:42:48 -0300 Subject: [PATCH] Delete packages/sdk directory SDK now is add by composer as composer dependencie --- packages/sdk/CHANGELOG.md | 154 -- packages/sdk/README.md | 298 --- packages/sdk/bin/publish-tag-release.sh | 101 - packages/sdk/composer.json | 44 - packages/sdk/composer.lock | 1830 ----------------- packages/sdk/examples/Multipayment.php | 45 - .../sdk/examples/createSellerFunnelBase.php | 25 - packages/sdk/examples/datadog_event.php | 32 - .../sdk/examples/groupedPaymentMethods.php | 20 - packages/sdk/examples/merchantOrder.php | 17 - .../sdk/examples/monitoring_register_log.php | 35 - packages/sdk/examples/notification.php | 20 - packages/sdk/examples/payment.php | 33 - packages/sdk/examples/paymentMethods.php | 19 - packages/sdk/examples/payment_3ds.php | 36 - packages/sdk/examples/preference.php | 36 - .../sdk/examples/updateSellerFunnelBase.php | 31 - packages/sdk/phpunit.xml | 21 - .../sdk/src/Common/AbstractCollection.php | 84 - packages/sdk/src/Common/AbstractEntity.php | 301 --- packages/sdk/src/Common/Config.php | 80 - packages/sdk/src/Common/Constants.php | 19 - packages/sdk/src/Common/Manager.php | 238 --- .../Identification/CreateSellerFunnelBase.php | 110 - .../ResponseCreateSellerFunnelBase.php | 37 - .../Identification/UpdateSellerFunnelBase.php | 132 -- .../src/Entity/MerchantOrder/Collector.php | 32 - .../Entity/MerchantOrder/MerchantOrder.php | 277 --- .../src/Entity/Monitoring/DatadogEvent.php | 123 -- .../sdk/src/Entity/Monitoring/Platform.php | 38 - .../Entity/Monitoring/RegisterErrorLog.php | 141 -- .../src/Entity/Notification/Notification.php | 217 -- .../Entity/Notification/PaymentDetails.php | 92 - .../Notification/PaymentDetailsList.php | 26 - .../Entity/Notification/PaymentMethodInfo.php | 62 - .../sdk/src/Entity/Notification/Refund.php | 38 - .../src/Entity/Notification/RefundList.php | 40 - .../Entity/Notification/RefundNotifying.php | 32 - .../Notification/RefundNotifyingList.php | 26 - .../sdk/src/Entity/Payment/AdditionalInfo.php | 83 - .../Entity/Payment/AdditionalInfoAddress.php | 68 - .../Entity/Payment/AdditionalInfoPayer.php | 113 - packages/sdk/src/Entity/Payment/Address.php | 50 - .../src/Entity/Payment/ApplicationData.php | 26 - packages/sdk/src/Entity/Payment/BankInfo.php | 20 - .../sdk/src/Entity/Payment/Identification.php | 26 - packages/sdk/src/Entity/Payment/Item.php | 56 - packages/sdk/src/Entity/Payment/ItemList.php | 26 - .../sdk/src/Entity/Payment/Multipayment.php | 31 - .../sdk/src/Entity/Payment/MultipaymentV2.php | 31 - .../src/Entity/Payment/MultipaymentV21.php | 31 - packages/sdk/src/Entity/Payment/Payer.php | 88 - packages/sdk/src/Entity/Payment/Payment.php | 391 ---- packages/sdk/src/Entity/Payment/PaymentV2.php | 19 - .../sdk/src/Entity/Payment/PaymentV21.php | 19 - packages/sdk/src/Entity/Payment/Phone.php | 26 - .../src/Entity/Payment/PointOfInteraction.php | 57 - .../src/Entity/Payment/ReceiverAddress.php | 56 - packages/sdk/src/Entity/Payment/Seller.php | 136 -- packages/sdk/src/Entity/Payment/Shipments.php | 75 - packages/sdk/src/Entity/Payment/Tracking.php | 26 - .../src/Entity/Payment/TransactionData.php | 42 - .../src/Entity/Payment/TransactionDetails.php | 50 - .../src/Entity/Payment/TransactionInfo.php | 38 - .../Entity/Payment/TransactionInfoList.php | 26 - .../PaymentMethods/FinancialInstitution.php | 26 - .../FinancialInstitutionList.php | 26 - .../Entity/PaymentMethods/PaymentMethod.php | 110 - .../Entity/PaymentMethods/PaymentMethods.php | 162 -- .../PaymentMethods/PaymentMethodsList.php | 26 - .../src/Entity/PaymentMethods/Platform.php | 38 - .../sdk/src/Entity/Preference/Address.php | 50 - .../sdk/src/Entity/Preference/BackUrl.php | 32 - .../Entity/Preference/DifferentialPricing.php | 20 - .../Preference/ExcludedPaymentMethod.php | 20 - .../Preference/ExcludedPaymentMethodList.php | 26 - .../Entity/Preference/ExcludedPaymentType.php | 20 - .../Preference/ExcludedPaymentTypeList.php | 26 - .../sdk/src/Entity/Preference/FreeMethod.php | 20 - .../src/Entity/Preference/FreeMethodList.php | 26 - packages/sdk/src/Entity/Preference/Item.php | 62 - .../sdk/src/Entity/Preference/ItemList.php | 26 - packages/sdk/src/Entity/Preference/Payer.php | 94 - .../Entity/Preference/PayerIdentification.php | 26 - .../src/Entity/Preference/PaymentMethod.php | 57 - packages/sdk/src/Entity/Preference/Phone.php | 26 - .../sdk/src/Entity/Preference/Preference.php | 259 --- .../src/Entity/Preference/ReceiverAddress.php | 56 - .../sdk/src/Entity/Preference/Shipment.php | 75 - packages/sdk/src/Entity/Preference/Track.php | 26 - .../sdk/src/Entity/Preference/TrackList.php | 26 - packages/sdk/src/HttpClient/HttpClient.php | 96 - .../src/HttpClient/HttpClientInterface.php | 60 - .../HttpClient/Requester/CurlRequester.php | 211 -- .../Requester/RequesterInterface.php | 27 - packages/sdk/src/HttpClient/Response.php | 108 - .../sdk/src/Interfaces/EntityInterface.php | 64 - .../Interfaces/RequesterEntityInterface.php | 55 - packages/sdk/src/Sdk.php | 212 -- packages/sdk/tests/integration/CardToken.php | 147 -- packages/sdk/tests/integration/ConfigKeys.php | 11 - .../tests/integration/DatadogEventTest.php | 52 - .../tests/integration/MerchantOrderTest.php | 37 - .../tests/integration/MultipaymentTest.php | 301 --- .../tests/integration/NotificationTest.php | 82 - .../tests/integration/PaymentMethodsTest.php | 47 - .../sdk/tests/integration/PaymentTest.php | 320 --- .../sdk/tests/integration/PreferenceTest.php | 132 -- .../tests/integration/RegisterErrorLog.php | 56 - .../integration/SellerFunnelBaseTest.php | 84 - packages/sdk/tests/unit/Common/ConfigTest.php | 37 - .../sdk/tests/unit/Common/ManagerTest.php | 206 -- .../CreateSellerFunnelBaseTest.php | 93 - .../UpdateSellerFunnelBaseTest.php | 87 - .../MerchantOrder/MerchantOrderTest.php | 109 - .../Entity/Monitoring/DatadogEventTest.php | 118 -- .../Monitoring/RegisterErrorLogTest.php | 106 - .../Entity/Notification/NotificationTest.php | 109 - .../tests/unit/Entity/Payment/PaymentTest.php | 204 -- .../PaymentMethods/PaymentMethodsTest.php | 149 -- .../unit/Entity/Preference/PreferenceTest.php | 180 -- .../tests/unit/HttpClient/HttpClientTest.php | 86 - .../Requester/CurlRequesterTest.php | 136 -- .../unit/Mock/CreateSellerFunnelBaseMock.php | 15 - .../sdk/tests/unit/Mock/CurlRequestMock.php | 11 - .../sdk/tests/unit/Mock/DatadogEventMock.php | 25 - .../sdk/tests/unit/Mock/MerchantOrderMock.php | 141 -- .../sdk/tests/unit/Mock/NotificationMock.php | 81 - .../tests/unit/Mock/PaymentMethodsMock.php | 55 - packages/sdk/tests/unit/Mock/PaymentMock.php | 296 --- .../sdk/tests/unit/Mock/PreferenceMock.php | 185 -- .../tests/unit/Mock/RegisterErrorLogMock.php | 26 - .../tests/unit/Mock/SellerFunnelBaseMock.php | 30 - packages/sdk/tests/unit/SdkTest.php | 145 -- 134 files changed, 12645 deletions(-) delete mode 100644 packages/sdk/CHANGELOG.md delete mode 100644 packages/sdk/README.md delete mode 100755 packages/sdk/bin/publish-tag-release.sh delete mode 100644 packages/sdk/composer.json delete mode 100644 packages/sdk/composer.lock delete mode 100644 packages/sdk/examples/Multipayment.php delete mode 100644 packages/sdk/examples/createSellerFunnelBase.php delete mode 100644 packages/sdk/examples/datadog_event.php delete mode 100644 packages/sdk/examples/groupedPaymentMethods.php delete mode 100644 packages/sdk/examples/merchantOrder.php delete mode 100644 packages/sdk/examples/monitoring_register_log.php delete mode 100644 packages/sdk/examples/notification.php delete mode 100644 packages/sdk/examples/payment.php delete mode 100644 packages/sdk/examples/paymentMethods.php delete mode 100644 packages/sdk/examples/payment_3ds.php delete mode 100644 packages/sdk/examples/preference.php delete mode 100644 packages/sdk/examples/updateSellerFunnelBase.php delete mode 100644 packages/sdk/phpunit.xml delete mode 100644 packages/sdk/src/Common/AbstractCollection.php delete mode 100644 packages/sdk/src/Common/AbstractEntity.php delete mode 100644 packages/sdk/src/Common/Config.php delete mode 100644 packages/sdk/src/Common/Constants.php delete mode 100644 packages/sdk/src/Common/Manager.php delete mode 100644 packages/sdk/src/Entity/Identification/CreateSellerFunnelBase.php delete mode 100644 packages/sdk/src/Entity/Identification/ResponseCreateSellerFunnelBase.php delete mode 100644 packages/sdk/src/Entity/Identification/UpdateSellerFunnelBase.php delete mode 100644 packages/sdk/src/Entity/MerchantOrder/Collector.php delete mode 100644 packages/sdk/src/Entity/MerchantOrder/MerchantOrder.php delete mode 100644 packages/sdk/src/Entity/Monitoring/DatadogEvent.php delete mode 100644 packages/sdk/src/Entity/Monitoring/Platform.php delete mode 100644 packages/sdk/src/Entity/Monitoring/RegisterErrorLog.php delete mode 100644 packages/sdk/src/Entity/Notification/Notification.php delete mode 100644 packages/sdk/src/Entity/Notification/PaymentDetails.php delete mode 100644 packages/sdk/src/Entity/Notification/PaymentDetailsList.php delete mode 100644 packages/sdk/src/Entity/Notification/PaymentMethodInfo.php delete mode 100644 packages/sdk/src/Entity/Notification/Refund.php delete mode 100644 packages/sdk/src/Entity/Notification/RefundList.php delete mode 100644 packages/sdk/src/Entity/Notification/RefundNotifying.php delete mode 100644 packages/sdk/src/Entity/Notification/RefundNotifyingList.php delete mode 100644 packages/sdk/src/Entity/Payment/AdditionalInfo.php delete mode 100644 packages/sdk/src/Entity/Payment/AdditionalInfoAddress.php delete mode 100644 packages/sdk/src/Entity/Payment/AdditionalInfoPayer.php delete mode 100644 packages/sdk/src/Entity/Payment/Address.php delete mode 100644 packages/sdk/src/Entity/Payment/ApplicationData.php delete mode 100644 packages/sdk/src/Entity/Payment/BankInfo.php delete mode 100644 packages/sdk/src/Entity/Payment/Identification.php delete mode 100644 packages/sdk/src/Entity/Payment/Item.php delete mode 100644 packages/sdk/src/Entity/Payment/ItemList.php delete mode 100644 packages/sdk/src/Entity/Payment/Multipayment.php delete mode 100644 packages/sdk/src/Entity/Payment/MultipaymentV2.php delete mode 100644 packages/sdk/src/Entity/Payment/MultipaymentV21.php delete mode 100644 packages/sdk/src/Entity/Payment/Payer.php delete mode 100644 packages/sdk/src/Entity/Payment/Payment.php delete mode 100644 packages/sdk/src/Entity/Payment/PaymentV2.php delete mode 100644 packages/sdk/src/Entity/Payment/PaymentV21.php delete mode 100644 packages/sdk/src/Entity/Payment/Phone.php delete mode 100644 packages/sdk/src/Entity/Payment/PointOfInteraction.php delete mode 100644 packages/sdk/src/Entity/Payment/ReceiverAddress.php delete mode 100644 packages/sdk/src/Entity/Payment/Seller.php delete mode 100644 packages/sdk/src/Entity/Payment/Shipments.php delete mode 100644 packages/sdk/src/Entity/Payment/Tracking.php delete mode 100644 packages/sdk/src/Entity/Payment/TransactionData.php delete mode 100644 packages/sdk/src/Entity/Payment/TransactionDetails.php delete mode 100644 packages/sdk/src/Entity/Payment/TransactionInfo.php delete mode 100644 packages/sdk/src/Entity/Payment/TransactionInfoList.php delete mode 100644 packages/sdk/src/Entity/PaymentMethods/FinancialInstitution.php delete mode 100644 packages/sdk/src/Entity/PaymentMethods/FinancialInstitutionList.php delete mode 100644 packages/sdk/src/Entity/PaymentMethods/PaymentMethod.php delete mode 100644 packages/sdk/src/Entity/PaymentMethods/PaymentMethods.php delete mode 100644 packages/sdk/src/Entity/PaymentMethods/PaymentMethodsList.php delete mode 100644 packages/sdk/src/Entity/PaymentMethods/Platform.php delete mode 100644 packages/sdk/src/Entity/Preference/Address.php delete mode 100644 packages/sdk/src/Entity/Preference/BackUrl.php delete mode 100644 packages/sdk/src/Entity/Preference/DifferentialPricing.php delete mode 100644 packages/sdk/src/Entity/Preference/ExcludedPaymentMethod.php delete mode 100644 packages/sdk/src/Entity/Preference/ExcludedPaymentMethodList.php delete mode 100644 packages/sdk/src/Entity/Preference/ExcludedPaymentType.php delete mode 100644 packages/sdk/src/Entity/Preference/ExcludedPaymentTypeList.php delete mode 100644 packages/sdk/src/Entity/Preference/FreeMethod.php delete mode 100644 packages/sdk/src/Entity/Preference/FreeMethodList.php delete mode 100644 packages/sdk/src/Entity/Preference/Item.php delete mode 100644 packages/sdk/src/Entity/Preference/ItemList.php delete mode 100644 packages/sdk/src/Entity/Preference/Payer.php delete mode 100644 packages/sdk/src/Entity/Preference/PayerIdentification.php delete mode 100644 packages/sdk/src/Entity/Preference/PaymentMethod.php delete mode 100644 packages/sdk/src/Entity/Preference/Phone.php delete mode 100644 packages/sdk/src/Entity/Preference/Preference.php delete mode 100644 packages/sdk/src/Entity/Preference/ReceiverAddress.php delete mode 100644 packages/sdk/src/Entity/Preference/Shipment.php delete mode 100644 packages/sdk/src/Entity/Preference/Track.php delete mode 100644 packages/sdk/src/Entity/Preference/TrackList.php delete mode 100644 packages/sdk/src/HttpClient/HttpClient.php delete mode 100644 packages/sdk/src/HttpClient/HttpClientInterface.php delete mode 100644 packages/sdk/src/HttpClient/Requester/CurlRequester.php delete mode 100644 packages/sdk/src/HttpClient/Requester/RequesterInterface.php delete mode 100644 packages/sdk/src/HttpClient/Response.php delete mode 100644 packages/sdk/src/Interfaces/EntityInterface.php delete mode 100644 packages/sdk/src/Interfaces/RequesterEntityInterface.php delete mode 100644 packages/sdk/src/Sdk.php delete mode 100644 packages/sdk/tests/integration/CardToken.php delete mode 100644 packages/sdk/tests/integration/ConfigKeys.php delete mode 100644 packages/sdk/tests/integration/DatadogEventTest.php delete mode 100644 packages/sdk/tests/integration/MerchantOrderTest.php delete mode 100644 packages/sdk/tests/integration/MultipaymentTest.php delete mode 100644 packages/sdk/tests/integration/NotificationTest.php delete mode 100644 packages/sdk/tests/integration/PaymentMethodsTest.php delete mode 100644 packages/sdk/tests/integration/PaymentTest.php delete mode 100644 packages/sdk/tests/integration/PreferenceTest.php delete mode 100644 packages/sdk/tests/integration/RegisterErrorLog.php delete mode 100644 packages/sdk/tests/integration/SellerFunnelBaseTest.php delete mode 100644 packages/sdk/tests/unit/Common/ConfigTest.php delete mode 100644 packages/sdk/tests/unit/Common/ManagerTest.php delete mode 100644 packages/sdk/tests/unit/Entity/Identification/CreateSellerFunnelBaseTest.php delete mode 100644 packages/sdk/tests/unit/Entity/Identification/UpdateSellerFunnelBaseTest.php delete mode 100644 packages/sdk/tests/unit/Entity/MerchantOrder/MerchantOrderTest.php delete mode 100644 packages/sdk/tests/unit/Entity/Monitoring/DatadogEventTest.php delete mode 100644 packages/sdk/tests/unit/Entity/Monitoring/RegisterErrorLogTest.php delete mode 100644 packages/sdk/tests/unit/Entity/Notification/NotificationTest.php delete mode 100644 packages/sdk/tests/unit/Entity/Payment/PaymentTest.php delete mode 100644 packages/sdk/tests/unit/Entity/PaymentMethods/PaymentMethodsTest.php delete mode 100644 packages/sdk/tests/unit/Entity/Preference/PreferenceTest.php delete mode 100644 packages/sdk/tests/unit/HttpClient/HttpClientTest.php delete mode 100644 packages/sdk/tests/unit/HttpClient/Requester/CurlRequesterTest.php delete mode 100644 packages/sdk/tests/unit/Mock/CreateSellerFunnelBaseMock.php delete mode 100644 packages/sdk/tests/unit/Mock/CurlRequestMock.php delete mode 100644 packages/sdk/tests/unit/Mock/DatadogEventMock.php delete mode 100644 packages/sdk/tests/unit/Mock/MerchantOrderMock.php delete mode 100644 packages/sdk/tests/unit/Mock/NotificationMock.php delete mode 100644 packages/sdk/tests/unit/Mock/PaymentMethodsMock.php delete mode 100644 packages/sdk/tests/unit/Mock/PaymentMock.php delete mode 100644 packages/sdk/tests/unit/Mock/PreferenceMock.php delete mode 100644 packages/sdk/tests/unit/Mock/RegisterErrorLogMock.php delete mode 100644 packages/sdk/tests/unit/Mock/SellerFunnelBaseMock.php delete mode 100644 packages/sdk/tests/unit/SdkTest.php diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md deleted file mode 100644 index 48d4575ff..000000000 --- a/packages/sdk/CHANGELOG.md +++ /dev/null @@ -1,154 +0,0 @@ -# Changelog - -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 -- Integration tests for melidataError scenario -### Changed -- Change the platform_ids used in integrated tests with the Core P&P platform_id (`ppcoreinternal`) - -## V1.9.1 -### Changed -- Changed second credit card informations in `CardToken` and `MultipaymentTest` from "amex" to "visa" - -## V1.9.0 -### Added -- Complementary test scenarios for multipayment with different payments on response -- New environment variable needed for 3DS validation layer e2e tests - -## V1.8.0 -### Added -- added 3DS validation layer. - -## V1.7.1 -### Added -- adjustment to the visibility of the customHeader attribute in payment - -## V1.7.0 -### Added -- adding custom header in payments - -## V1.6.0 -### Added -- Add new payments /v2.1 to Remedies - -## V1.5.7 -### Added -- Integration tests for notification scenario - -## V1.5.6 -### Added -- Integration tests for preference scenario - -## V1.5.5 -### Added -- Integration tests for multipayment scenario -### Changed -- Modify composer.json in autoload-dev to load all class in /tests - -## V1.5.4 -### Added -- Adds a step to the script that runs via GitHub Actions to create a version tag for the internal repository - -## V1.5.3 -### Added -- Adds to the autoload-dev of the composer.json file the necessary package to run the integration tests - -## V1.5.2 -### Changed -- Add Docs for Asgard Services Integration - -## V1.5.1 -### Added -- Add Tests of integration on Payment diff --git a/packages/sdk/README.md b/packages/sdk/README.md deleted file mode 100644 index 010e421b6..000000000 --- a/packages/sdk/README.md +++ /dev/null @@ -1,298 +0,0 @@ -# Introdução - -O objetivo desta SDK é proporcionar agilidade no processo de desenvolvimento e comunicação com as APIs de pagamento, preferências e notificações. - -## Instalação - -Instale a biblioteca utilizando o seguinte comando: - -`composer require mp-plugins/php-sdk` - -Com uma versão específica: - -`composer require mp-plugins/php-sdk 1.4.0` - -## Consultando versões da SDK - -Para consultar as versões disponíveis basta acesssar o seguinte [link](https://github.com/mercadopago/pp-php-sdk/tags). - -## Configuração - -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(); - -``` -## Obtendo pagamento - -```php -getPaymentInstance(); - - $payment->read(array("id" => 'payment_id')); -``` - -## Criando uma preferência - -```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(); - -``` - -## Consultando uma notificação - -O parâmetro para consulta deve seguir o modelo abaixo: - -`P-{idPayment}` - -```php -getNotificationInstance(); - - $notification->read(array("id" => "P-1316643861")); - -``` - -## Registrando um evento no Datadog - -```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")); - -``` - -## Registrando um log de erro - -```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'); - -``` - -## Obtendo métodos de pagamento agrupados - -Exemplo de requisição agrupando os meios de pagamento pelo campo id: - -```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' ); - - $merchantOrder = $sdk->getMerchantOrderInstance(); - - debug(json_encode($merchantOrder->getMerchantOrders())); - -``` - -## Criando um novo id de integração para funil - -```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 - -``` - -## Atualizando um id de integração para funil - -```php -"; - 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 - -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/bin/publish-tag-release.sh b/packages/sdk/bin/publish-tag-release.sh deleted file mode 100755 index 3b3c9b33b..000000000 --- a/packages/sdk/bin/publish-tag-release.sh +++ /dev/null @@ -1,101 +0,0 @@ -#!/usr/bin/env bash -SOURCE_DIRECTORY=$(pwd) - -# Verify that there (potentially) some access to the destination repository -# and set up git (with GIT_CMD variable) and GIT_CMD_REPOSITORY -if [ -n "${SSH_SDK_DEPLOY_KEY:=}" ]; then - echo "[+] Using SSH_SDK_DEPLOY_KEY" - - mkdir -p "$HOME/.ssh" - DEPLOY_KEY_FILE="$HOME/.ssh/deploy_key" - echo "${SSH_SDK_DEPLOY_KEY}" >"$DEPLOY_KEY_FILE" - chmod 600 "$DEPLOY_KEY_FILE" - - SSH_KNOWN_HOSTS_FILE="$HOME/.ssh/known_hosts" - ssh-keyscan -H "github.com" >"$SSH_KNOWN_HOSTS_FILE" - - git config --global user.name "$GIT_USER_NAME" - git config --global user.email "$GIT_USER_EMAIL" - - export GIT_SSH_COMMAND="ssh -i "$DEPLOY_KEY_FILE" -o UserKnownHostsFile=$SSH_KNOWN_HOSTS_FILE" - - GIT_CMD_REPOSITORY="git@github.com:$DESTINATION_REPOSITORY_USERNAME/$DESTINATION_REPOSITORY_NAME.git" -else - echo "::error::SSH_SDK_DEPLOY_KEY is empty." - exit 1 -fi - -cd "$SOURCE_DIRECTORY" -### Preparing release folder -rm -rf .git .github .gitmodules .fury .pre-commit-config.yaml bin/publish-tag-release.sh - -CLONE_DIR=$(mktemp -d) - -echo "[+] Git version" -git --version - -echo "[+] Cloning destination git repository $DESTINATION_REPOSITORY_NAME" -{ - git clone --single-branch --depth 1 "$GIT_CMD_REPOSITORY" "$CLONE_DIR" -} || { - echo "::error::Could not clone the destination repository. Command:" - echo "::error::git clone --single-branch $GIT_CMD_REPOSITORY $CLONE_DIR" - echo "::error::(Note that if they exist USER_NAME and API_TOKEN is redacted by GitHub)" - echo "::error::Please verify that the target repository exist AND that it contains the destination branch name, and is accesible by the SSH_DEPLOY_KEY" - exit 1 -} -ls -la "$CLONE_DIR" - -echo "[+] List contents of $SOURCE_DIRECTORY" -ls "$SOURCE_DIRECTORY" - -cd "$CLONE_DIR" -echo "[+] Removing contents of public repository folder" -find . -maxdepth 1 -not -name ".git" -exec rm -r {} + - -cd "$SOURCE_DIRECTORY" - -echo "[+] Copying contents of source repository folder $SOURCE_DIRECTORY to folder $CLONE_DIR in git repo $DESTINATION_REPOSITORY_NAME" -cp -Ra "$SOURCE_DIRECTORY"/. "$CLONE_DIR/" -cd "$CLONE_DIR" - -TAG_VERSION=$(cat composer.json | jq -r '.version') -TARGET_BRANCH="release/$TAG_VERSION" -git checkout -b $TARGET_BRANCH - -echo "[+] Files that will be pushed" -ls -la - -echo "[+] Set directory is safe ($CLONE_DIR)" -git config --global --add safe.directory "$CLONE_DIR" - -echo "[+] git add" -git add . - -echo "[+] git status:" -git status - -echo "[+] git commit:" -git commit -m "Release v$TAG_VERSION" - -echo "[+] Pushing git commit" -# --set-upstream: sets the branch when pushing to a branch that does not exist -git push "${GIT_CMD_REPOSITORY}" --set-upstream "$TARGET_BRANCH" - -echo "[+] git checkout master:" -git checkout master - -echo "[+] git pull origin master:" -git pull origin master - -echo "[+] git merge branch $TARGET_BRANCH with master:" -git merge "$TARGET_BRANCH" - -echo "[+] git push origin master:" -git push origin master - -echo "[+] git tag:" -git tag "v$TAG_VERSION" master - -echo "[+] git push origin v$TAG_VERSION:" -git push origin "v$TAG_VERSION" \ No newline at end of file diff --git a/packages/sdk/composer.json b/packages/sdk/composer.json deleted file mode 100644 index 732d85af5..000000000 --- a/packages/sdk/composer.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "name": "mp-plugins/php-sdk", - "description": "Mercado Pago Plugins PHP-SDK", - "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", - "integration-test": "./vendor/bin/phpunit --testsuite pp-php-sdk-integration" - }, - "autoload": { - "psr-4": { - "MercadoPago\\PP\\Sdk\\": [ - "src" - ] - } - }, - "autoload-dev": { - "psr-4": { - "MercadoPago\\PP\\Sdk\\Tests\\Unit\\": [ - "tests/unit" - ], - "MercadoPago\\PP\\Sdk\\Tests\\Integration\\": [ - "tests/integration" - ] - } - }, - "require": { - "php": ">=7", - "ext-json": "*" - }, - "require-dev": { - "phpunit/phpunit": "9.5.27", - "squizlabs/php_codesniffer": "3.7.2" - }, - "license": "proprietary", - "authors": [ - { - "name": "Mercado Pago SMB", - "email": "pp_smb@mercadolivre.com" - } - ], - "minimum-stability": "stable" -} diff --git a/packages/sdk/composer.lock b/packages/sdk/composer.lock deleted file mode 100644 index e7bbc9c64..000000000 --- a/packages/sdk/composer.lock +++ /dev/null @@ -1,1830 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", - "This file is @generated automatically" - ], - "content-hash": "8c432eac2a4431d0a5d89ceaec1b261b", - "packages": [], - "packages-dev": [ - { - "name": "doctrine/instantiator", - "version": "1.5.0", - "source": { - "type": "git", - "url": "https://github.com/doctrine/instantiator.git", - "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/0a0fa9780f5d4e507415a065172d26a98d02047b", - "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b", - "shasum": "" - }, - "require": { - "php": "^7.1 || ^8.0" - }, - "require-dev": { - "doctrine/coding-standard": "^9 || ^11", - "ext-pdo": "*", - "ext-phar": "*", - "phpbench/phpbench": "^0.16 || ^1", - "phpstan/phpstan": "^1.4", - "phpstan/phpstan-phpunit": "^1", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "vimeo/psalm": "^4.30 || ^5.4" - }, - "type": "library", - "autoload": { - "psr-4": { - "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "https://ocramius.github.io/" - } - ], - "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://www.doctrine-project.org/projects/instantiator.html", - "keywords": [ - "constructor", - "instantiate" - ], - "support": { - "issues": "https://github.com/doctrine/instantiator/issues", - "source": "https://github.com/doctrine/instantiator/tree/1.5.0" - }, - "funding": [ - { - "url": "https://www.doctrine-project.org/sponsorship.html", - "type": "custom" - }, - { - "url": "https://www.patreon.com/phpdoctrine", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", - "type": "tidelift" - } - ], - "time": "2022-12-30T00:15:36+00:00" - }, - { - "name": "myclabs/deep-copy", - "version": "1.11.1", - "source": { - "type": "git", - "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", - "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", - "shasum": "" - }, - "require": { - "php": "^7.1 || ^8.0" - }, - "conflict": { - "doctrine/collections": "<1.6.8", - "doctrine/common": "<2.13.3 || >=3,<3.2.2" - }, - "require-dev": { - "doctrine/collections": "^1.6.8", - "doctrine/common": "^2.13.3 || ^3.2.2", - "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" - }, - "type": "library", - "autoload": { - "files": [ - "src/DeepCopy/deep_copy.php" - ], - "psr-4": { - "DeepCopy\\": "src/DeepCopy/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Create deep copies (clones) of your objects", - "keywords": [ - "clone", - "copy", - "duplicate", - "object", - "object graph" - ], - "support": { - "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1" - }, - "funding": [ - { - "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", - "type": "tidelift" - } - ], - "time": "2023-03-08T13:26:56+00:00" - }, - { - "name": "nikic/php-parser", - "version": "v4.19.1", - "source": { - "type": "git", - "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "4e1b88d21c69391150ace211e9eaf05810858d0b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/4e1b88d21c69391150ace211e9eaf05810858d0b", - "reference": "4e1b88d21c69391150ace211e9eaf05810858d0b", - "shasum": "" - }, - "require": { - "ext-tokenizer": "*", - "php": ">=7.1" - }, - "require-dev": { - "ircmaxell/php-yacc": "^0.0.7", - "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0" - }, - "bin": [ - "bin/php-parse" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.9-dev" - } - }, - "autoload": { - "psr-4": { - "PhpParser\\": "lib/PhpParser" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Nikita Popov" - } - ], - "description": "A PHP parser written in PHP", - "keywords": [ - "parser", - "php" - ], - "support": { - "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.19.1" - }, - "time": "2024-03-17T08:10:35+00:00" - }, - { - "name": "phar-io/manifest", - "version": "2.0.4", - "source": { - "type": "git", - "url": "https://github.com/phar-io/manifest.git", - "reference": "54750ef60c58e43759730615a392c31c80e23176" - }, - "dist": { - "type": "zip", - "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", - "php": "^7.2 || ^8.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" - }, - { - "name": "Sebastian Heuer", - "email": "sebastian@phpeople.de", - "role": "Developer" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "Developer" - } - ], - "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.4" - }, - "funding": [ - { - "url": "https://github.com/theseer", - "type": "github" - } - ], - "time": "2024-03-03T12:33:53+00:00" - }, - { - "name": "phar-io/version", - "version": "3.2.1", - "source": { - "type": "git", - "url": "https://github.com/phar-io/version.git", - "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74", - "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" - }, - { - "name": "Sebastian Heuer", - "email": "sebastian@phpeople.de", - "role": "Developer" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "Developer" - } - ], - "description": "Library for handling version information and constraints", - "support": { - "issues": "https://github.com/phar-io/version/issues", - "source": "https://github.com/phar-io/version/tree/3.2.1" - }, - "time": "2022-02-21T01:04:05+00:00" - }, - { - "name": "phpunit/php-code-coverage", - "version": "9.2.31", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "48c34b5d8d983006bd2adc2d0de92963b9155965" - }, - "dist": { - "type": "zip", - "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.18 || ^5.0", - "php": ">=7.3", - "phpunit/php-file-iterator": "^3.0.3", - "phpunit/php-text-template": "^2.0.2", - "sebastian/code-unit-reverse-lookup": "^2.0.2", - "sebastian/complexity": "^2.0", - "sebastian/environment": "^5.1.2", - "sebastian/lines-of-code": "^1.0.3", - "sebastian/version": "^3.0.1", - "theseer/tokenizer": "^1.2.0" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" - }, - "suggest": { - "ext-pcov": "PHP extension that provides line coverage", - "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "9.2-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", - "homepage": "https://github.com/sebastianbergmann/php-code-coverage", - "keywords": [ - "coverage", - "testing", - "xunit" - ], - "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.31" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2024-03-02T06:37:42+00:00" - }, - { - "name": "phpunit/php-file-iterator", - "version": "3.0.6", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", - "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "FilterIterator implementation that filters files based on a list of suffixes.", - "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", - "keywords": [ - "filesystem", - "iterator" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", - "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.6" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2021-12-02T12:48:52+00:00" - }, - { - "name": "phpunit/php-invoker", - "version": "3.1.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-invoker.git", - "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/5a10147d0aaf65b58940a0b72f71c9ac0423cc67", - "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "ext-pcntl": "*", - "phpunit/phpunit": "^9.3" - }, - "suggest": { - "ext-pcntl": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.1-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Invoke callables with a timeout", - "homepage": "https://github.com/sebastianbergmann/php-invoker/", - "keywords": [ - "process" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/php-invoker/issues", - "source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-09-28T05:58:55+00:00" - }, - { - "name": "phpunit/php-text-template", - "version": "2.0.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", - "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Simple template engine.", - "homepage": "https://github.com/sebastianbergmann/php-text-template/", - "keywords": [ - "template" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/php-text-template/issues", - "source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.4" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-10-26T05:33:50+00:00" - }, - { - "name": "phpunit/php-timer", - "version": "5.0.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", - "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Utility class for timing", - "homepage": "https://github.com/sebastianbergmann/php-timer/", - "keywords": [ - "timer" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/php-timer/issues", - "source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.3" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-10-26T13:16:10+00:00" - }, - { - "name": "phpunit/phpunit", - "version": "9.5.27", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "a2bc7ffdca99f92d959b3f2270529334030bba38" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a2bc7ffdca99f92d959b3f2270529334030bba38", - "reference": "a2bc7ffdca99f92d959b3f2270529334030bba38", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.3.1", - "ext-dom": "*", - "ext-json": "*", - "ext-libxml": "*", - "ext-mbstring": "*", - "ext-xml": "*", - "ext-xmlwriter": "*", - "myclabs/deep-copy": "^1.10.1", - "phar-io/manifest": "^2.0.3", - "phar-io/version": "^3.0.2", - "php": ">=7.3", - "phpunit/php-code-coverage": "^9.2.13", - "phpunit/php-file-iterator": "^3.0.5", - "phpunit/php-invoker": "^3.1.1", - "phpunit/php-text-template": "^2.0.3", - "phpunit/php-timer": "^5.0.2", - "sebastian/cli-parser": "^1.0.1", - "sebastian/code-unit": "^1.0.6", - "sebastian/comparator": "^4.0.8", - "sebastian/diff": "^4.0.3", - "sebastian/environment": "^5.1.3", - "sebastian/exporter": "^4.0.5", - "sebastian/global-state": "^5.0.1", - "sebastian/object-enumerator": "^4.0.3", - "sebastian/resource-operations": "^3.0.3", - "sebastian/type": "^3.2", - "sebastian/version": "^3.0.2" - }, - "suggest": { - "ext-soap": "*", - "ext-xdebug": "*" - }, - "bin": [ - "phpunit" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "9.5-dev" - } - }, - "autoload": { - "files": [ - "src/Framework/Assert/Functions.php" - ], - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "The PHP Unit Testing framework.", - "homepage": "https://phpunit.de/", - "keywords": [ - "phpunit", - "testing", - "xunit" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.27" - }, - "funding": [ - { - "url": "https://phpunit.de/sponsors.html", - "type": "custom" - }, - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", - "type": "tidelift" - } - ], - "time": "2022-12-09T07:31:23+00:00" - }, - { - "name": "sebastian/cli-parser", - "version": "1.0.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/cli-parser.git", - "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/2b56bea83a09de3ac06bb18b92f068e60cc6f50b", - "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Library for parsing CLI options", - "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.2" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2024-03-02T06:27:43+00:00" - }, - { - "name": "sebastian/code-unit", - "version": "1.0.8", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/code-unit.git", - "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/1fc9f64c0927627ef78ba436c9b17d967e68e120", - "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Collection of value objects that represent the PHP code units", - "homepage": "https://github.com/sebastianbergmann/code-unit", - "support": { - "issues": "https://github.com/sebastianbergmann/code-unit/issues", - "source": "https://github.com/sebastianbergmann/code-unit/tree/1.0.8" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-10-26T13:08:54+00:00" - }, - { - "name": "sebastian/code-unit-reverse-lookup", - "version": "2.0.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", - "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Looks up which function or method a line of code belongs to", - "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", - "support": { - "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", - "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/2.0.3" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-09-28T05:30:19+00:00" - }, - { - "name": "sebastian/comparator", - "version": "4.0.8", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "fa0f136dd2334583309d32b62544682ee972b51a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/fa0f136dd2334583309d32b62544682ee972b51a", - "reference": "fa0f136dd2334583309d32b62544682ee972b51a", - "shasum": "" - }, - "require": { - "php": ">=7.3", - "sebastian/diff": "^4.0", - "sebastian/exporter": "^4.0" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - } - ], - "description": "Provides the functionality to compare PHP values for equality", - "homepage": "https://github.com/sebastianbergmann/comparator", - "keywords": [ - "comparator", - "compare", - "equality" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/comparator/issues", - "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.8" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2022-09-14T12:41:17+00:00" - }, - { - "name": "sebastian/complexity", - "version": "2.0.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/complexity.git", - "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/25f207c40d62b8b7aa32f5ab026c53561964053a", - "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a", - "shasum": "" - }, - "require": { - "nikic/php-parser": "^4.18 || ^5.0", - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Library for calculating the complexity of PHP code units", - "homepage": "https://github.com/sebastianbergmann/complexity", - "support": { - "issues": "https://github.com/sebastianbergmann/complexity/issues", - "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.3" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2023-12-22T06:19:30+00:00" - }, - { - "name": "sebastian/diff", - "version": "4.0.6", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/ba01945089c3a293b01ba9badc29ad55b106b0bc", - "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.3", - "symfony/process": "^4.2 || ^5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Kore Nordmann", - "email": "mail@kore-nordmann.de" - } - ], - "description": "Diff implementation", - "homepage": "https://github.com/sebastianbergmann/diff", - "keywords": [ - "diff", - "udiff", - "unidiff", - "unified diff" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/diff/issues", - "source": "https://github.com/sebastianbergmann/diff/tree/4.0.6" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2024-03-02T06:30:58+00:00" - }, - { - "name": "sebastian/environment", - "version": "5.1.5", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", - "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" - }, - "suggest": { - "ext-posix": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.1-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides functionality to handle HHVM/PHP environments", - "homepage": "http://www.github.com/sebastianbergmann/environment", - "keywords": [ - "Xdebug", - "environment", - "hhvm" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/environment/issues", - "source": "https://github.com/sebastianbergmann/environment/tree/5.1.5" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2023-02-03T06:03:51+00:00" - }, - { - "name": "sebastian/exporter", - "version": "4.0.6", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "78c00df8f170e02473b682df15bfcdacc3d32d72" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/78c00df8f170e02473b682df15bfcdacc3d32d72", - "reference": "78c00df8f170e02473b682df15bfcdacc3d32d72", - "shasum": "" - }, - "require": { - "php": ">=7.3", - "sebastian/recursion-context": "^4.0" - }, - "require-dev": { - "ext-mbstring": "*", - "phpunit/phpunit": "^9.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" - } - ], - "description": "Provides the functionality to export PHP variables for visualization", - "homepage": "https://www.github.com/sebastianbergmann/exporter", - "keywords": [ - "export", - "exporter" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/exporter/issues", - "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.6" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2024-03-02T06:33:00+00:00" - }, - { - "name": "sebastian/global-state", - "version": "5.0.7", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9", - "reference": "bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9", - "shasum": "" - }, - "require": { - "php": ">=7.3", - "sebastian/object-reflector": "^2.0", - "sebastian/recursion-context": "^4.0" - }, - "require-dev": { - "ext-dom": "*", - "phpunit/phpunit": "^9.3" - }, - "suggest": { - "ext-uopz": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Snapshotting of global state", - "homepage": "http://www.github.com/sebastianbergmann/global-state", - "keywords": [ - "global state" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/global-state/issues", - "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.7" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2024-03-02T06:35:11+00:00" - }, - { - "name": "sebastian/lines-of-code", - "version": "1.0.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/lines-of-code.git", - "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/e1e4a170560925c26d424b6a03aed157e7dcc5c5", - "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5", - "shasum": "" - }, - "require": { - "nikic/php-parser": "^4.18 || ^5.0", - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Library for counting the lines of code in PHP source code", - "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.4" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2023-12-22T06:20:34+00:00" - }, - { - "name": "sebastian/object-enumerator", - "version": "4.0.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "5c9eeac41b290a3712d88851518825ad78f45c71" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71", - "reference": "5c9eeac41b290a3712d88851518825ad78f45c71", - "shasum": "" - }, - "require": { - "php": ">=7.3", - "sebastian/object-reflector": "^2.0", - "sebastian/recursion-context": "^4.0" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Traverses array structures and object graphs to enumerate all referenced objects", - "homepage": "https://github.com/sebastianbergmann/object-enumerator/", - "support": { - "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", - "source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.4" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-10-26T13:12:34+00:00" - }, - { - "name": "sebastian/object-reflector", - "version": "2.0.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/object-reflector.git", - "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", - "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Allows reflection of object attributes, including inherited and non-public ones", - "homepage": "https://github.com/sebastianbergmann/object-reflector/", - "support": { - "issues": "https://github.com/sebastianbergmann/object-reflector/issues", - "source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.4" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-10-26T13:14:26+00:00" - }, - { - "name": "sebastian/recursion-context", - "version": "4.0.5", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1", - "reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - } - ], - "description": "Provides functionality to recursively process PHP variables", - "homepage": "https://github.com/sebastianbergmann/recursion-context", - "support": { - "issues": "https://github.com/sebastianbergmann/recursion-context/issues", - "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.5" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2023-02-03T06:07:39+00:00" - }, - { - "name": "sebastian/resource-operations", - "version": "3.0.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/05d5692a7993ecccd56a03e40cd7e5b09b1d404e", - "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "3.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides a list of PHP built-in functions that operate on resources", - "homepage": "https://www.github.com/sebastianbergmann/resource-operations", - "support": { - "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.4" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2024-03-14T16:00:52+00:00" - }, - { - "name": "sebastian/type", - "version": "3.2.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/type.git", - "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", - "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.2-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Collection of value objects that represent the types of the PHP type system", - "homepage": "https://github.com/sebastianbergmann/type", - "support": { - "issues": "https://github.com/sebastianbergmann/type/issues", - "source": "https://github.com/sebastianbergmann/type/tree/3.2.1" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2023-02-03T06:13:03+00:00" - }, - { - "name": "sebastian/version", - "version": "3.0.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/version.git", - "reference": "c6c1022351a901512170118436c764e473f6de8c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c", - "reference": "c6c1022351a901512170118436c764e473f6de8c", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Library that helps with managing the version number of Git-hosted PHP projects", - "homepage": "https://github.com/sebastianbergmann/version", - "support": { - "issues": "https://github.com/sebastianbergmann/version/issues", - "source": "https://github.com/sebastianbergmann/version/tree/3.0.2" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-09-28T06:39:44+00:00" - }, - { - "name": "squizlabs/php_codesniffer", - "version": "3.7.2", - "source": { - "type": "git", - "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/ed8e00df0a83aa96acf703f8c2979ff33341f879", - "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879", - "shasum": "" - }, - "require": { - "ext-simplexml": "*", - "ext-tokenizer": "*", - "ext-xmlwriter": "*", - "php": ">=5.4.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" - }, - "bin": [ - "bin/phpcs", - "bin/phpcbf" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.x-dev" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Greg Sherwood", - "role": "lead" - } - ], - "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", - "keywords": [ - "phpcs", - "standards", - "static analysis" - ], - "support": { - "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", - "source": "https://github.com/squizlabs/PHP_CodeSniffer", - "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" - }, - "funding": [ - { - "url": "https://github.com/PHPCSStandards", - "type": "github" - }, - { - "url": "https://github.com/jrfnl", - "type": "github" - }, - { - "url": "https://opencollective.com/php_codesniffer", - "type": "open_collective" - } - ], - "time": "2023-02-22T23:07:41+00:00" - }, - { - "name": "theseer/tokenizer", - "version": "1.2.3", - "source": { - "type": "git", - "url": "https://github.com/theseer/tokenizer.git", - "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", - "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-tokenizer": "*", - "ext-xmlwriter": "*", - "php": "^7.2 || ^8.0" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" - } - ], - "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.3" - }, - "funding": [ - { - "url": "https://github.com/theseer", - "type": "github" - } - ], - "time": "2024-03-03T12:36:25+00:00" - } - ], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": { - "php": ">=7", - "ext-json": "*" - }, - "platform-dev": [], - "plugin-api-version": "2.1.0" -} diff --git a/packages/sdk/examples/Multipayment.php b/packages/sdk/examples/Multipayment.php deleted file mode 100644 index 00b8ac6b9..000000000 --- a/packages/sdk/examples/Multipayment.php +++ /dev/null @@ -1,45 +0,0 @@ -"; - print_r($value); - echo ""; - } - - $sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey' ); - - //Payment with two Cards - $multipayment = $sdk->getMultipaymentInstance(); - - //For each new call it will be necessary to create a card token - $transaction_info = ["transaction_info" => - - [ - "transaction_amount" => 50, - "installments" => 1, - "token" => "732057aed78e3a571eaacdffe7a388d5", - "payment_method_id" => "master" - ], - [ - "transaction_amount" => 40, - "installments" => 1, - "token" => "eb01f5336d50f365f0f449ee117dfa46", - "payment_method_id" => "amex" - ] - ]; - - $multipayment->payment_method_id = "pp_multiple_payments"; - $multipayment->transaction_info = $transaction_info; - $multipayment->transaction_amount = 90; - $multipayment->date_of_expiration = "2024-03-30T20:10:00.000+0000"; - $multipayment->description = "Ergonomic Silk Shirt"; - - $multipayment->payer->email = "test_user_98934401@testuser.com"; - - debug(json_encode($multipayment->save())); - ?> - \ No newline at end of file diff --git a/packages/sdk/examples/createSellerFunnelBase.php b/packages/sdk/examples/createSellerFunnelBase.php deleted file mode 100644 index 8ab7daf49..000000000 --- a/packages/sdk/examples/createSellerFunnelBase.php +++ /dev/null @@ -1,25 +0,0 @@ -"; - 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 deleted file mode 100644 index 34ba6cf14..000000000 --- a/packages/sdk/examples/datadog_event.php +++ /dev/null @@ -1,32 +0,0 @@ -"; - 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 deleted file mode 100644 index 676f9ee14..000000000 --- a/packages/sdk/examples/groupedPaymentMethods.php +++ /dev/null @@ -1,20 +0,0 @@ -"; - 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/merchantOrder.php b/packages/sdk/examples/merchantOrder.php deleted file mode 100644 index 0dd8393e9..000000000 --- a/packages/sdk/examples/merchantOrder.php +++ /dev/null @@ -1,17 +0,0 @@ -"; - 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 deleted file mode 100644 index 99034550b..000000000 --- a/packages/sdk/examples/monitoring_register_log.php +++ /dev/null @@ -1,35 +0,0 @@ -"; - 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 deleted file mode 100644 index caffd29f2..000000000 --- a/packages/sdk/examples/notification.php +++ /dev/null @@ -1,20 +0,0 @@ -"; - print_r($value); - echo ""; - } - - $sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey' ); - - $notification = $sdk->getNotificationInstance(); - - debug(json_encode($notification->read(array("id" => "P-1316643861")))); - - ?> - \ No newline at end of file diff --git a/packages/sdk/examples/payment.php b/packages/sdk/examples/payment.php deleted file mode 100644 index 2acbcf6c0..000000000 --- a/packages/sdk/examples/payment.php +++ /dev/null @@ -1,33 +0,0 @@ -"; - print_r($value); - echo ""; - } - - $sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey' ); - - $payment = $sdk->getPaymentInstance(); - - //For each new call it will be necessary to create a card token - $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"; - - 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 deleted file mode 100644 index 61197d690..000000000 --- a/packages/sdk/examples/paymentMethods.php +++ /dev/null @@ -1,19 +0,0 @@ -"; - 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 deleted file mode 100644 index 9447f64ea..000000000 --- a/packages/sdk/examples/payment_3ds.php +++ /dev/null @@ -1,36 +0,0 @@ -"; - print_r($value); - echo ""; - } - - $sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey' ); - - $payment = $sdk->getPaymentInstance(); - - //For each new call it will be necessary to create a card token - $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"; - - // Possible values for 3DS are: "optional", "not_supported" or "mandatory" - $payment->three_d_secure_mode = Constants::THREE_DS_MODE_OPTIONAL; - - try { - debug(json_encode($payment->validateThreeDSecureMode())); - } catch (Exception $e) { - echo 'Error: ', $e->getMessage(); - } - - ?> \ No newline at end of file diff --git a/packages/sdk/examples/preference.php b/packages/sdk/examples/preference.php deleted file mode 100644 index ad715b226..000000000 --- a/packages/sdk/examples/preference.php +++ /dev/null @@ -1,36 +0,0 @@ -"; - print_r($value); - echo ""; - } - - $sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey' ); - - $preference = $sdk->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"; - - debug(json_encode($preference->save())); - - ?> - \ No newline at end of file diff --git a/packages/sdk/examples/updateSellerFunnelBase.php b/packages/sdk/examples/updateSellerFunnelBase.php deleted file mode 100644 index 2d6f834ba..000000000 --- a/packages/sdk/examples/updateSellerFunnelBase.php +++ /dev/null @@ -1,31 +0,0 @@ -"; - 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/phpunit.xml b/packages/sdk/phpunit.xml deleted file mode 100644 index 5b7eed985..000000000 --- a/packages/sdk/phpunit.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - ./tests/unit/ - - - ./tests/integration/ - - - - - src - - - \ No newline at end of file diff --git a/packages/sdk/src/Common/AbstractCollection.php b/packages/sdk/src/Common/AbstractCollection.php deleted file mode 100644 index cfbd09741..000000000 --- a/packages/sdk/src/Common/AbstractCollection.php +++ /dev/null @@ -1,84 +0,0 @@ -manager = $manager; - } - - /** - * Add entity to collection - * - * @param AbstractEntity $entity - * @param string|null $key - */ - public function addEntity(AbstractEntity $entity, string $key = null) - { - if (is_null($key)) { - $this->collection[] = $entity; - } else { - $this->collection[$key] = $entity; - } - } - - /** - * Add multiple entities to collection - * - * @param $entities - */ - public function setEntity($entities) - { - if (is_array($entities) || is_object($entities)) { - foreach ($entities as $value) { - $this->add($value); - } - } - } - - /** - * @inheritDoc - */ - public function getIterator(): \Traversable - { - return new \ArrayIterator($this->collection); - } - - /** - * @return int|null - */ - public function count(): int - { - return count($this->collection); - } - - /** - * @return array - */ - public function jsonSerialize(): array - { - return $this->collection; - } -} diff --git a/packages/sdk/src/Common/AbstractEntity.php b/packages/sdk/src/Common/AbstractEntity.php deleted file mode 100644 index 70ddceca2..000000000 --- a/packages/sdk/src/Common/AbstractEntity.php +++ /dev/null @@ -1,301 +0,0 @@ -manager = $manager; - $this->setExcludedProperties(); - } - - /** - * @param string $name - * - * @return mixed - */ - public function __get(string $name) - { - return $this->{$name}; - } - - /** - * @param string $name - * @param mixed $value - */ - public function __set(string $name, $value) - { - if (!property_exists($this, $name)) { - return; - } - - if (is_subclass_of($this->{$name}, AbstractEntity::class) || - is_subclass_of($this->{$name}, AbstractCollection::class) - ) { - $this->{$name}->setEntity($value); - } else { - $this->{$name} = $value; - } - } - - /** - * @param string $name - * - * @return bool - */ - public function __isset(string $name) - { - return isset($this->{$name}); - } - - /** - * @param string $name - */ - public function __unset(string $name) - { - unset($this->{$name}); - } - - - /** - * Set values for an entity's attributes. - * - * @param $data - */ - public function setEntity($data) - { - if (is_array($data) || is_object($data)) { - foreach ($data as $key => $value) { - $this->__set($key, $value); - } - } - } - - /** - * @codeCoverageIgnore - * Get the properties of the given object. - * - * @return array - */ - public function getProperties(): array - { - return get_object_vars($this); - } - - /** - * Get an array from an object. - * - * @return array - */ - public function toArray(): array - { - $data = []; - $properties = $this->getProperties(); - $excludedPropertiesCount = count($this->excluded_properties); - - foreach ($properties as $property => $value) { - if ($property === 'manager' || $property === 'excluded_properties') { - continue; - } - - if ($excludedPropertiesCount !== 0 && in_array($property, $this->excluded_properties)) { - continue; - } - - if ($value instanceof self) { - $data[$property] = $value->toArray(); - continue; - } - - if (($value instanceof \IteratorAggregate) || (is_array($value) && count($value))) { - foreach ($value as $index => $item) { - if ($item instanceof self) { - $data[$property][$index] = $item->toArray(); - } else { - $data[$property][$index] = $item; - } - } - continue; - } - - $data[$property] = $this->$property; - } - - return $data; - } - - /** - * Read method (GET). - * - * @param array $params - * @param array $queryStrings - * @param bool $shouldTheExpectedResponseBeMappedOntoTheEntity - * - * @return mixed - * @throws \Exception - */ - public function read( - array $params = [], - array $queryStrings = [], - bool $shouldTheExpectedResponseBeMappedOntoTheEntity = true - ) { - $method = 'get'; - $class = get_called_class(); - $entity = new $class($this->manager); - - $customHeaders = $this->getHeaders()['read']; - $header = $this->manager->getHeader($customHeaders); - - $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, - $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); - } - - /** - * Save method (POST). - * - * @return mixed - * @throws \Exception - */ - public function save() - { - $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->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 - */ - public function jsonSerialize(): array - { - return $this->toArray(); - } - - /** - * Exclude properties from entity building. - * - * @return void - */ - public function setExcludedProperties() - { - $this->excluded_properties = []; - } - - /** - * Obfuscate Authorization Header. - * - * @return void - */ - public function obfuscateAuthorizationHeader(array $headers) - { - Sdk::$cache['last_headers'] = preg_replace('/(Authorization:) (.*)/i', '$1 xxx', $headers); - } - - /** - * Get last Headers. - * - * @return array - */ - public function getLastHeaders(): array - { - if (isset(Sdk::$cache['last_headers'])) { - return Sdk::$cache['last_headers']; - } - return []; - } -} diff --git a/packages/sdk/src/Common/Config.php b/packages/sdk/src/Common/Config.php deleted file mode 100644 index 6d62ca82a..000000000 --- a/packages/sdk/src/Common/Config.php +++ /dev/null @@ -1,80 +0,0 @@ -access_token = $access_token; - $this->platform_id = $platform_id; - $this->product_id = $product_id; - $this->integrator_id = $integrator_id; - $this->public_key = $public_key; - } - - /** - * @param string $name - * - * @return mixed - */ - public function __get(string $name) - { - return $this->{$name}; - } - - /** - * @param string $name - * @param string $value - */ - public function __set(string $name, string $value) - { - if (property_exists($this, $name)) { - $this->{$name} = $value; - } - } -} diff --git a/packages/sdk/src/Common/Constants.php b/packages/sdk/src/Common/Constants.php deleted file mode 100644 index bf63d96c8..000000000 --- a/packages/sdk/src/Common/Constants.php +++ /dev/null @@ -1,19 +0,0 @@ -client = $client; - $this->config = $config; - } - - /** - * Unifies method call that makes request to any HTTP method. - * - * @param object|AbstractEntity|null $entity - * @param string $uri - * @param string $method - * @param array $headers - * - * @return mixed - */ - public function execute(AbstractEntity $entity, string $uri, string $method = 'get', array $headers = []) - { - if ($method == 'get') { - return $this->client->{$method}($uri, $headers); - } - - $body = json_encode($entity); - return $this->client->{$method}($uri, $headers, $body); - } - - /** - * Get entity uri by performing assignments based on params. - * - * @param AbstractEntity|null $entity - * @param string $method - * @param array $params - * - * @return mixed - * @throws \Exception - */ - public function getEntityUri(AbstractEntity $entity, string $method, array $params = [], array $queryStrings = []) - { - if (method_exists($entity, 'getUris')) { - $uri = $entity->getUris()[$method]; - $matches = []; - preg_match_all('/\\:\\w+/', $uri, $matches); - - foreach ($matches[0] as $match) { - $key = substr($match, 1); - - if (array_key_exists($key, $params)) { - $uri = str_replace($match, $params[$key], $uri); - } elseif (property_exists($entity, $key) && !is_null($entity->{$key})) { - $uri = str_replace($match, $entity->{$key}, $uri); - } else { - $uri = str_replace($match, '', $uri); - } - } - if (count($queryStrings) > 0) { - $uri = $uri . '?' . http_build_query($queryStrings); - } - - return $uri; - } else { - throw new \Exception('Method not available for ' . get_class($entity) . ' entity'); - } - } - - /** - * Get default header - * - * @return array - */ - 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') - ]; - } - - /** - * 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 - * - * @return array - */ - public function getHeader(array $customHeaders = []): array - { - $defaultHeaders = $this->getDefaultHeader(); - 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; - } - - /** - * Handle response - * - * @param Response $response - * @param string $method - * @param AbstractEntity|null $entity - * - * @return mixed - * @throws \Exception - */ - public function handleResponse(Response $response, string $method, AbstractEntity $entity = null) - { - if ($response->getStatus() == '200' || $response->getStatus() == '201') { - if ($entity && $method == 'get') { - $entity->setEntity($response->getData()); - return $entity; - } - return $response->getData(); - } 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"); - } - } - - /** - * 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 deleted file mode 100644 index ff00cafe1..000000000 --- a/packages/sdk/src/Entity/Identification/CreateSellerFunnelBase.php +++ /dev/null @@ -1,110 +0,0 @@ - [] - ]; - } - - /** - * 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 deleted file mode 100644 index 4b3a95daf..000000000 --- a/packages/sdk/src/Entity/Identification/ResponseCreateSellerFunnelBase.php +++ /dev/null @@ -1,37 +0,0 @@ -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 deleted file mode 100644 index 3bac5cf51..000000000 --- a/packages/sdk/src/Entity/Identification/UpdateSellerFunnelBase.php +++ /dev/null @@ -1,132 +0,0 @@ -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 deleted file mode 100644 index f91bcdd92..000000000 --- a/packages/sdk/src/Entity/MerchantOrder/Collector.php +++ /dev/null @@ -1,32 +0,0 @@ -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 deleted file mode 100644 index fa94e8e9b..000000000 --- a/packages/sdk/src/Entity/Monitoring/DatadogEvent.php +++ /dev/null @@ -1,123 +0,0 @@ -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 deleted file mode 100644 index 2c0ec2530..000000000 --- a/packages/sdk/src/Entity/Monitoring/Platform.php +++ /dev/null @@ -1,38 +0,0 @@ - [ - '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 deleted file mode 100644 index 828c61473..000000000 --- a/packages/sdk/src/Entity/Notification/Notification.php +++ /dev/null @@ -1,217 +0,0 @@ -payments_details = new PaymentDetailsList($manager); - $this->refunds_notifying = new RefundNotifyingList($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( - 'get' => '/v1/asgard/notification/:id', - ); - } - - /** - * Retrieves a notification from the Asgard Transaction service. - * - * Upon invoking this method, a request is made to the Asgard Transaction service - * using the provided notification 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 notifications. - * - * @param array $params Associative array containing the parameters for the read operation. - * It expects an "id" key with the notification ID as its value. - * Example: $notification->read(['id' => 'P-1316643861']) - * - * @return mixed The result of the read operation, typically an instance of - * this Notification 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/Notification/PaymentDetails.php b/packages/sdk/src/Entity/Notification/PaymentDetails.php deleted file mode 100644 index ccf5f47da..000000000 --- a/packages/sdk/src/Entity/Notification/PaymentDetails.php +++ /dev/null @@ -1,92 +0,0 @@ -refunds = new RefundList($manager); - } -} diff --git a/packages/sdk/src/Entity/Notification/PaymentDetailsList.php b/packages/sdk/src/Entity/Notification/PaymentDetailsList.php deleted file mode 100644 index 55d6628fa..000000000 --- a/packages/sdk/src/Entity/Notification/PaymentDetailsList.php +++ /dev/null @@ -1,26 +0,0 @@ -manager); - $item->setEntity($entity); - parent::addEntity($item, $key); - } -} diff --git a/packages/sdk/src/Entity/Notification/PaymentMethodInfo.php b/packages/sdk/src/Entity/Notification/PaymentMethodInfo.php deleted file mode 100644 index 05a78f2d7..000000000 --- a/packages/sdk/src/Entity/Notification/PaymentMethodInfo.php +++ /dev/null @@ -1,62 +0,0 @@ -manager); - $refund->setEntity($entity); - parent::addEntity($refund, $key); - } - - /** - * Add multiple entities to collection - * - * @param $entities - */ - public function setEntity($entities) - { - if (is_array($entities) || is_object($entities)) { - foreach ($entities as $value) { - $this->add($value, $value["id"]); - } - } - } -} diff --git a/packages/sdk/src/Entity/Notification/RefundNotifying.php b/packages/sdk/src/Entity/Notification/RefundNotifying.php deleted file mode 100644 index f1b9df1c8..000000000 --- a/packages/sdk/src/Entity/Notification/RefundNotifying.php +++ /dev/null @@ -1,32 +0,0 @@ -manager); - $item->setEntity($entity); - parent::addEntity($item, $key); - } -} diff --git a/packages/sdk/src/Entity/Payment/AdditionalInfo.php b/packages/sdk/src/Entity/Payment/AdditionalInfo.php deleted file mode 100644 index c7f3a59f8..000000000 --- a/packages/sdk/src/Entity/Payment/AdditionalInfo.php +++ /dev/null @@ -1,83 +0,0 @@ -items = new ItemList($manager); - $this->payer = new AdditionalInfoPayer($manager); - $this->seller = new Seller($manager); - $this->shipments = new Shipments($manager); - } -} diff --git a/packages/sdk/src/Entity/Payment/AdditionalInfoAddress.php b/packages/sdk/src/Entity/Payment/AdditionalInfoAddress.php deleted file mode 100644 index 6e81d0fe2..000000000 --- a/packages/sdk/src/Entity/Payment/AdditionalInfoAddress.php +++ /dev/null @@ -1,68 +0,0 @@ -address = new AdditionalInfoAddress($manager); - $this->phone = new Phone($manager); - $this->mobile = new Phone($manager); - $this->identification = new Identification($manager); - } -} diff --git a/packages/sdk/src/Entity/Payment/Address.php b/packages/sdk/src/Entity/Payment/Address.php deleted file mode 100644 index d82bc7b5e..000000000 --- a/packages/sdk/src/Entity/Payment/Address.php +++ /dev/null @@ -1,50 +0,0 @@ -manager); - $item->setEntity($entity); - parent::addEntity($item, $key); - } -} diff --git a/packages/sdk/src/Entity/Payment/Multipayment.php b/packages/sdk/src/Entity/Payment/Multipayment.php deleted file mode 100644 index 0c4af468e..000000000 --- a/packages/sdk/src/Entity/Payment/Multipayment.php +++ /dev/null @@ -1,31 +0,0 @@ -transaction_info = new TransactionInfoList($manager); - } -} diff --git a/packages/sdk/src/Entity/Payment/MultipaymentV2.php b/packages/sdk/src/Entity/Payment/MultipaymentV2.php deleted file mode 100644 index 9d9df53bf..000000000 --- a/packages/sdk/src/Entity/Payment/MultipaymentV2.php +++ /dev/null @@ -1,31 +0,0 @@ -transaction_info = new TransactionInfoList($manager); - } -} diff --git a/packages/sdk/src/Entity/Payment/MultipaymentV21.php b/packages/sdk/src/Entity/Payment/MultipaymentV21.php deleted file mode 100644 index bc0c96448..000000000 --- a/packages/sdk/src/Entity/Payment/MultipaymentV21.php +++ /dev/null @@ -1,31 +0,0 @@ -transaction_info = new TransactionInfoList($manager); - } -} diff --git a/packages/sdk/src/Entity/Payment/Payer.php b/packages/sdk/src/Entity/Payment/Payer.php deleted file mode 100644 index dde114d81..000000000 --- a/packages/sdk/src/Entity/Payment/Payer.php +++ /dev/null @@ -1,88 +0,0 @@ -identification = new Identification($manager); - $this->address = new Address($manager); - $this->phone = new Phone($manager); - } -} diff --git a/packages/sdk/src/Entity/Payment/Payment.php b/packages/sdk/src/Entity/Payment/Payment.php deleted file mode 100644 index 6e8e62580..000000000 --- a/packages/sdk/src/Entity/Payment/Payment.php +++ /dev/null @@ -1,391 +0,0 @@ -payer = new Payer($manager); - $this->additional_info = new AdditionalInfo($manager); - $this->transaction_details = new TransactionDetails($manager); - $this->point_of_interaction = new PointOfInteraction($manager); - } - - /** - * Exclude properties from entity building. - * - * @return void - */ - public function setExcludedProperties() - { - $this->excluded_properties = ['session_id']; - } - - /** - * Get and set custom headers for entity. - * - * @return array - */ - public function getHeaders(): array - { - return [ - 'read' => [], - 'save' => isset($this->customHeader) - ? array_merge(['x-meli-session-id: ' . $this->session_id], $this->customHeader) - : ['x-meli-session-id: ' . $this->session_id], - ]; - } - /** - * 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( - 'post' => '/v1/asgard/payments', - 'get' => '/v1/payments/:id' - ); - } - - /** - * Addition of the 3DS validation layer. Possible values are as follows: - * - not_supported: 3DS should not be used (it is the default value). - * - optional: 3DS may or may not be required, depending on the risk profile of the operation. - * - mandatory: 3DS must be required, depending on the risk profile of the operation. - */ - - public function validateThreeDSecureMode() - { - - $validation = Constants::THREE_DS_VALID_OPTIONS; - if (in_array(strtolower($this->three_d_secure_mode), $validation)) { - return $this->save(); - } - - throw new Exception("Invalid value for field three_d_secure_mode"); - } - - /** - * Creates a payment using the Asgard Transaction service API. - * - * To execute this method, it is essential to provide the payment request payload. The payload includes - * properties such as 'paymentMethodId', 'description', 'transactionAmount', among others. - * The method returns details of the created payment, including fields like 'id', 'status', - * 'applicationId', 'dateCreated', etc. - * - * Internally, this method makes a call to the Asgard Transaction API, supplying the required parameters: - * Payment creation payload, Platform Identifier, and Access Token. - * - * Note: This method is inherited from the parent class but specialized for payments. - * - * @return mixed The result of the save operation, typically an instance of this Payment - * class populated with the created data. - * @throws \Exception Throws an exception if something goes wrong during the save operation. - */ - 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 deleted file mode 100644 index 38fe412c9..000000000 --- a/packages/sdk/src/Entity/Payment/PaymentV2.php +++ /dev/null @@ -1,19 +0,0 @@ - '/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 deleted file mode 100644 index ff79daee4..000000000 --- a/packages/sdk/src/Entity/Payment/PaymentV21.php +++ /dev/null @@ -1,19 +0,0 @@ - '/ppcore/prod/transaction/v21/payments', - 'get' => '/v1/payments/:id' - ); - } -} diff --git a/packages/sdk/src/Entity/Payment/Phone.php b/packages/sdk/src/Entity/Payment/Phone.php deleted file mode 100644 index cf7725423..000000000 --- a/packages/sdk/src/Entity/Payment/Phone.php +++ /dev/null @@ -1,26 +0,0 @@ -application_data = new ApplicationData($manager); - $this->transaction_data = new TransactionData($manager); - } -} diff --git a/packages/sdk/src/Entity/Payment/ReceiverAddress.php b/packages/sdk/src/Entity/Payment/ReceiverAddress.php deleted file mode 100644 index 216ec2206..000000000 --- a/packages/sdk/src/Entity/Payment/ReceiverAddress.php +++ /dev/null @@ -1,56 +0,0 @@ -identification = new Identification($manager); - $this->phone = new Phone($manager); - $this->address = new AdditionalInfoAddress($manager); - } -} diff --git a/packages/sdk/src/Entity/Payment/Shipments.php b/packages/sdk/src/Entity/Payment/Shipments.php deleted file mode 100644 index 8a90d6ecf..000000000 --- a/packages/sdk/src/Entity/Payment/Shipments.php +++ /dev/null @@ -1,75 +0,0 @@ -tracking = new Tracking($manager); - $this->receiver_address = new AdditionalInfoAddress($manager); - } -} diff --git a/packages/sdk/src/Entity/Payment/Tracking.php b/packages/sdk/src/Entity/Payment/Tracking.php deleted file mode 100644 index d6bcf2468..000000000 --- a/packages/sdk/src/Entity/Payment/Tracking.php +++ /dev/null @@ -1,26 +0,0 @@ -bank_info = new BankInfo($manager); - } -} diff --git a/packages/sdk/src/Entity/Payment/TransactionDetails.php b/packages/sdk/src/Entity/Payment/TransactionDetails.php deleted file mode 100644 index 702be5671..000000000 --- a/packages/sdk/src/Entity/Payment/TransactionDetails.php +++ /dev/null @@ -1,50 +0,0 @@ -manager); - $transactionInfo->setEntity($entity); - parent::addEntity($transactionInfo, $key); - } -} diff --git a/packages/sdk/src/Entity/PaymentMethods/FinancialInstitution.php b/packages/sdk/src/Entity/PaymentMethods/FinancialInstitution.php deleted file mode 100644 index a1a3adbc7..000000000 --- a/packages/sdk/src/Entity/PaymentMethods/FinancialInstitution.php +++ /dev/null @@ -1,26 +0,0 @@ -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 deleted file mode 100644 index 0f562e463..000000000 --- a/packages/sdk/src/Entity/PaymentMethods/PaymentMethod.php +++ /dev/null @@ -1,110 +0,0 @@ -financial_institutions = new FinancialInstitutionList($manager) && []; - } -} diff --git a/packages/sdk/src/Entity/PaymentMethods/PaymentMethods.php b/packages/sdk/src/Entity/PaymentMethods/PaymentMethods.php deleted file mode 100644 index 50d4b940a..000000000 --- a/packages/sdk/src/Entity/PaymentMethods/PaymentMethods.php +++ /dev/null @@ -1,162 +0,0 @@ -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 deleted file mode 100644 index d878d11ff..000000000 --- a/packages/sdk/src/Entity/PaymentMethods/PaymentMethodsList.php +++ /dev/null @@ -1,26 +0,0 @@ -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 deleted file mode 100644 index 2c0ec2530..000000000 --- a/packages/sdk/src/Entity/PaymentMethods/Platform.php +++ /dev/null @@ -1,38 +0,0 @@ -manager); - $excludedPaymentMethod->setEntity($entity); - parent::addEntity($excludedPaymentMethod, $key); - } -} diff --git a/packages/sdk/src/Entity/Preference/ExcludedPaymentType.php b/packages/sdk/src/Entity/Preference/ExcludedPaymentType.php deleted file mode 100644 index 9dcf39683..000000000 --- a/packages/sdk/src/Entity/Preference/ExcludedPaymentType.php +++ /dev/null @@ -1,20 +0,0 @@ -manager); - $excludedPaymentType->setEntity($entity); - parent::addEntity($excludedPaymentType, $key); - } -} diff --git a/packages/sdk/src/Entity/Preference/FreeMethod.php b/packages/sdk/src/Entity/Preference/FreeMethod.php deleted file mode 100644 index 6dbb8b895..000000000 --- a/packages/sdk/src/Entity/Preference/FreeMethod.php +++ /dev/null @@ -1,20 +0,0 @@ -manager); - $freeMethod->setEntity($entity); - parent::addEntity($freeMethod, $key); - } -} diff --git a/packages/sdk/src/Entity/Preference/Item.php b/packages/sdk/src/Entity/Preference/Item.php deleted file mode 100644 index 2fcbce7ff..000000000 --- a/packages/sdk/src/Entity/Preference/Item.php +++ /dev/null @@ -1,62 +0,0 @@ -manager); - $item->setEntity($entity); - parent::addEntity($item, $key); - } -} diff --git a/packages/sdk/src/Entity/Preference/Payer.php b/packages/sdk/src/Entity/Preference/Payer.php deleted file mode 100644 index 2cb424988..000000000 --- a/packages/sdk/src/Entity/Preference/Payer.php +++ /dev/null @@ -1,94 +0,0 @@ -address = new Address($manager); - $this->identification = new PayerIdentification($manager); - $this->phone = new Phone($manager); - } -} diff --git a/packages/sdk/src/Entity/Preference/PayerIdentification.php b/packages/sdk/src/Entity/Preference/PayerIdentification.php deleted file mode 100644 index c256a1391..000000000 --- a/packages/sdk/src/Entity/Preference/PayerIdentification.php +++ /dev/null @@ -1,26 +0,0 @@ -excluded_payment_methods = new ExcludedPaymentMethodList($manager); - $this->excluded_payment_types = new ExcludedPaymentTypeList($manager); - } -} diff --git a/packages/sdk/src/Entity/Preference/Phone.php b/packages/sdk/src/Entity/Preference/Phone.php deleted file mode 100644 index ba306369c..000000000 --- a/packages/sdk/src/Entity/Preference/Phone.php +++ /dev/null @@ -1,26 +0,0 @@ -additional_info = new AdditionalInfo($manager); - $this->back_urls = new BackUrl($manager); - $this->items = new ItemList($manager); - $this->payer = new Payer($manager); - $this->payment_methods = new PaymentMethod($manager); - $this->shipments = new Shipment($manager); - $this->tracks = new TrackList($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' => '/v1/asgard/preferences', - 'get' => '/checkout/preferences/:id' - ); - } - - /** - * Creates a preference for Checkout Pro via the asgard-transaction service. - * - * This method is used to set the preferences for a checkout before redirecting the user to - * the MercadoPago payment interface. To make the call to the asgard-transaction, this method - * requires the request payload for a preference, which includes details such as: - * 'additionalInfo', 'autoReturn', 'binaryMode', 'expirationDateFrom', 'expirationDateTo', 'items'. - * - * Once the preference is successfully created, the method returns an object that encapsulates - * all the details of the created preference, including: 'id', 'dateCreated', 'items', 'totalAmount'. - * - * In addition to these properties, the returned object contains other fields that provide - * additional information about the preference, such as: 'expirationDateFrom', 'notificationUrl', among others. - * - * Note: This method is inherited from the parent class but specialized for preferences. - * - * @return mixed The result of the preference creation, typically an instance of a Preference class - * populated with the created details. - * - * @throws \Exception Throws an exception if something goes wrong during the preference creation. - */ - 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/Entity/Preference/ReceiverAddress.php b/packages/sdk/src/Entity/Preference/ReceiverAddress.php deleted file mode 100644 index 69b09e8cb..000000000 --- a/packages/sdk/src/Entity/Preference/ReceiverAddress.php +++ /dev/null @@ -1,56 +0,0 @@ -free_methods = new FreeMethodList($manager); - $this->receiver_address = new ReceiverAddress($manager); - } -} diff --git a/packages/sdk/src/Entity/Preference/Track.php b/packages/sdk/src/Entity/Preference/Track.php deleted file mode 100644 index 34513d62b..000000000 --- a/packages/sdk/src/Entity/Preference/Track.php +++ /dev/null @@ -1,26 +0,0 @@ -manager); - $track->setEntity($entity); - parent::addEntity($track, $key); - } -} diff --git a/packages/sdk/src/HttpClient/HttpClient.php b/packages/sdk/src/HttpClient/HttpClient.php deleted file mode 100644 index c189800ea..000000000 --- a/packages/sdk/src/HttpClient/HttpClient.php +++ /dev/null @@ -1,96 +0,0 @@ -baseUrl = $baseUrl; - $this->requester = $requester; - } - - public function get(string $uri, array $headers = []): Response - { - return $this->send('GET', $uri, $headers, null); - } - - public function put(string $uri, array $headers = [], $body = null): Response - { - return $this->send('PUT', $uri, $headers, $body); - } - - public function post(string $uri, array $headers = [], $body = null): Response - { - return $this->send('POST', $uri, $headers, $body); - } - - public function send(string $method, string $uri, array $headers = [], $body = null): Response - { - if (null !== $body && !is_string($body) && - !is_subclass_of($body, AbstractEntity::class) && !is_subclass_of($body, AbstractCollection::class) - ) { - throw new \Exception( - sprintf( - '%s::send(): Argument #4 ($body) must be of type string|%s|%snull, %s given', - self::class, - AbstractEntity::class, - AbstractCollection::class, - gettype($body) - ) - ); - } - - return $this->sendRequest( - self::createRequest($method, $uri, $headers, $body) - ); - } - - /** - * @param string|AbstractEntity|AbstractCollection|null $body - * - * @return resource - */ - private function createRequest(string $method, string $uri, array $headers = [], $body = null) - { - $url = $this->baseUrl . $uri; - return $this->requester->createRequest($method, $url, $headers, $body); - } - - /** - * @param resource $request - */ - public function sendRequest($request): Response - { - return $this->requester->sendRequest($request); - } -} diff --git a/packages/sdk/src/HttpClient/HttpClientInterface.php b/packages/sdk/src/HttpClient/HttpClientInterface.php deleted file mode 100644 index ff56c6e9c..000000000 --- a/packages/sdk/src/HttpClient/HttpClientInterface.php +++ /dev/null @@ -1,60 +0,0 @@ - $v) { - if ('content-type' === $h) { - $default_content_type = false; - $json_content = 'application/json' === $v; - $form_content = 'application/x-www-form-urlencoded' === $v; - break; - } - } - } - if ($default_content_type) { - $headers[] = 'content-type: application/json'; - } - - $connect = $this->curlInit(); - $this->setOption($connect, CURLOPT_USERAGENT, 'platform:v1-whitelabel,type:mp_sdk'); - $this->setOption($connect, CURLOPT_RETURNTRANSFER, true); - - // @TODO define CAINFO when implementing SDK - // $this->setOption($connect, CURLOPT_SSL_VERIFYPEER, true); - // $this->setOption( $connect, CURLOPT_CAINFO, $GLOBALS['LIB_LOCATION'] . '/cacert.pem' ); - - $this->setOption($connect, CURLOPT_CUSTOMREQUEST, $method); - $this->setOption($connect, CURLOPT_HTTPHEADER, $headers); - $this->setOption($connect, CURLOPT_URL, $uri); - - if (isset($body)) { - if ($json_content) { - if (is_string($body)) { - json_decode($body, true); - } else { - $body = json_encode($body); - } - if (function_exists('json_last_error')) { - $json_error = json_last_error(); - if (JSON_ERROR_NONE !== $json_error) { - throw new \Exception("JSON Error [{$json_error}] - Data: " . $body); - } - } - } elseif ($form_content) { - $body = self::buildFormData($body); - } - $this->setOption($connect, CURLOPT_POSTFIELDS, $body); - } - - return $connect; - } - - /** - * @param resource $request - * - * @throws \Exception - */ - 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)); - } - - $info = $this->curlGetInfo($request); - $api_http_code = $info['http_code']; - - // @TODO: call logging service when ready - - 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; - } - - /** - * Build query - * - * @param array|object $params Params. - * - * @return string - */ - public static function buildFormData(array $params): string - { - if (function_exists('http_build_query')) { - return http_build_query($params, '', '&'); - } else { - $elements = []; - - foreach ($params as $name => $value) { - $elements[] = "{$name}=" . rawurldecode($value); - } - - return implode('&', $elements); - } - } - - /** - * @codeCoverageIgnore - * - * @return resource - */ - protected function curlInit() - { - return curl_init(); - } - - /** - * @codeCoverageIgnore - */ - protected function curlClose($request) - { - curl_close($request); - } - - /** - * @codeCoverageIgnore - */ - protected function setOption($connect, $option, $value) - { - curl_setopt($connect, $option, $value); - } - - /** - * @codeCoverageIgnore - */ - protected function curlExec($request) - { - return curl_exec($request); - } - - /** - * @codeCoverageIgnore - */ - protected function curlErrno($request): int - { - return curl_errno($request); - } - - /** - * @codeCoverageIgnore - */ - protected function curlError($request): string - { - return curl_error($request); - } - - /** - * @codeCoverageIgnore - */ - protected function curlGetInfo($request) - { - return curl_getinfo($request); - } -} diff --git a/packages/sdk/src/HttpClient/Requester/RequesterInterface.php b/packages/sdk/src/HttpClient/Requester/RequesterInterface.php deleted file mode 100644 index 2647bfefd..000000000 --- a/packages/sdk/src/HttpClient/Requester/RequesterInterface.php +++ /dev/null @@ -1,27 +0,0 @@ -status; - } - - /** - * Set the status of response - * - * @param int|null $status - * - * @return void - **/ - public function setStatus(int $status) - { - $this->status = $status; - } - - /** - * Return the data of response - * - * @return object|null - **/ - public function getData() - { - return $this->data; - } - - /** - * Set the data of response - * - * @param object $data - * - * @return void - **/ - 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/EntityInterface.php b/packages/sdk/src/Interfaces/EntityInterface.php deleted file mode 100644 index 2099fda98..000000000 --- a/packages/sdk/src/Interfaces/EntityInterface.php +++ /dev/null @@ -1,64 +0,0 @@ -requester = new CurlRequester(); - $this->config = new Config(); - $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); - } - } - } - - /** - * @param string $entityName - * @param string $baseUrl - * - * @return AbstractEntity - */ - public function getEntityInstance(string $entityName, string $baseUrl) - { - $client = new HttpClient($baseUrl, $this->requester); - $manager = new Manager($client, $this->config); - return new $entityName($manager); - } - - /** - * @return Preference - */ - public function getPreferenceInstance() - { - return $this->getEntityInstance('MercadoPago\PP\Sdk\Entity\Preference\Preference', Constants::BASEURL_MP); - } - - /** - * @return Notification - */ - public function getNotificationInstance() - { - return $this->getEntityInstance('MercadoPago\PP\Sdk\Entity\Notification\Notification', Constants::BASEURL_MP); - } - - /** - * @return Payment - */ - public function getPaymentInstance() - { - return $this->getEntityInstance('MercadoPago\PP\Sdk\Entity\Payment\Payment', Constants::BASEURL_MP); - } - - /** - * @return PaymentV2 - */ - public function getPaymentV2Instance() - { - return $this->getEntityInstance('MercadoPago\PP\Sdk\Entity\Payment\PaymentV2', Constants::BASEURL_MP); - } - - /** - * @return PaymentV21 - */ - public function getPaymentV21Instance() - { - return $this->getEntityInstance('MercadoPago\PP\Sdk\Entity\Payment\PaymentV21', Constants::BASEURL_MP); - } - - /** - * @return Multipayment - */ - public function getMultipaymentInstance() - { - return $this->getEntityInstance('MercadoPago\PP\Sdk\Entity\Payment\Multipayment', Constants::BASEURL_MP); - } - - /** - * @return MultipaymentV2 - */ - public function getMultipaymentV2Instance() - { - return $this->getEntityInstance('MercadoPago\PP\Sdk\Entity\Payment\MultipaymentV2', Constants::BASEURL_MP); - } - - /** - * @return MultipaymentV21 - */ - 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/CardToken.php b/packages/sdk/tests/integration/CardToken.php deleted file mode 100644 index 0e060e2f2..000000000 --- a/packages/sdk/tests/integration/CardToken.php +++ /dev/null @@ -1,147 +0,0 @@ -loadConfigs(); - $publicKey = $envVars['PUBLIC_KEY'] ?? null; - $url = "https://api.mercadopago.com/v1/card_tokens?public_key=".$publicKey; - - $year = date("Y") + 1; - - $data = [ - "card_number" => "5031433215406351", - "expiration_year" => $year, - "expiration_month" => 11, - "security_code" => "123", - "site_id" => "MLB", - "cardholder" => [ - "identification" => [ - "type" => "CPF", - "number" => "12345678909" - ], - "name" => $statusCardToken - ] - ]; - $payload = json_encode($data); - - $ch = curl_init(); - - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); - curl_setopt($ch, CURLOPT_HTTPHEADER, [ - 'Content-Type: application/json', - 'Content-Length: ' . strlen($payload) - ]); - - $output = curl_exec($ch); - - if (curl_errno($ch)) { - $this->fail('cURL error: ' . curl_error($ch)); - } - - curl_close($ch); - - return json_decode($output)->id; - } - - public function generateCardTokenVisa($statusCardToken) - { - $configKeys = new ConfigKeys(); - $envVars = $configKeys->loadConfigs(); - $publicKey = $envVars['PUBLIC_KEY'] ?? null; - $url = "https://api.mercadopago.com/v1/card_tokens?public_key=".$publicKey; - - $year = date("Y") + 1; - - $data = [ - "card_number" => "4235647728025682", - "expiration_year" => $year, - "expiration_month" => 11, - "security_code" => "123", - "site_id" => "MLB", - "cardholder" => [ - "identification" => [ - "type" => "CPF", - "number" => "12345678909" - ], - "name" => $statusCardToken - ] - ]; - $payload = json_encode($data); - - $ch = curl_init(); - - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); - curl_setopt($ch, CURLOPT_HTTPHEADER, [ - 'Content-Type: application/json', - 'Content-Length: ' . strlen($payload) - ]); - - $output = curl_exec($ch); - - if (curl_errno($ch)) { - $this->fail('cURL error: ' . curl_error($ch)); - } - - curl_close($ch); - - return json_decode($output)->id; - } - - public function generateCardTokenMaster3DS($statusCardToken) - { - $configKeys = new ConfigKeys(); - $envVars = $configKeys->loadConfigs(); - $publicKey = $envVars['PUBLIC_KEY_3DS'] ?? null; - $url = "https://api.mercadopago.com/v1/card_tokens?public_key=".$publicKey; - - $year = date("Y") + 1; - - $data = [ - "card_number" => "5031433215406351", - "expiration_year" => $year, - "expiration_month" => 11, - "security_code" => "123", - "site_id" => "MLB", - "cardholder" => [ - "identification" => [ - "type" => "CPF", - "number" => "12345678909" - ], - "name" => $statusCardToken - ] - ]; - $payload = json_encode($data); - - $ch = curl_init(); - - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); - curl_setopt($ch, CURLOPT_HTTPHEADER, [ - 'Content-Type: application/json', - 'Content-Length: ' . strlen($payload) - ]); - - $output = curl_exec($ch); - - if (curl_errno($ch)) { - $this->fail('cURL error: ' . curl_error($ch)); - } - - curl_close($ch); - - return json_decode($output)->id; - } -} diff --git a/packages/sdk/tests/integration/ConfigKeys.php b/packages/sdk/tests/integration/ConfigKeys.php deleted file mode 100644 index 4a9893d3a..000000000 --- a/packages/sdk/tests/integration/ConfigKeys.php +++ /dev/null @@ -1,11 +0,0 @@ -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/MerchantOrderTest.php b/packages/sdk/tests/integration/MerchantOrderTest.php deleted file mode 100644 index 031f425ac..000000000 --- a/packages/sdk/tests/integration/MerchantOrderTest.php +++ /dev/null @@ -1,37 +0,0 @@ -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 deleted file mode 100644 index de0d04f58..000000000 --- a/packages/sdk/tests/integration/MultipaymentTest.php +++ /dev/null @@ -1,301 +0,0 @@ -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 = (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"; - - return $multipayment; - } - 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 = (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"; - - return $multipayment; - } - 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"; - $multipayment->payer->email = "test_user_98934401@testuser.com"; - $multipayment->payment_method_id = "pp_multiple_payments"; - - return $multipayment; - } - - public function testMultipaymentV1Success() - { - $multipayment = $this->loadMultipaymentV1(); - - $cardToken = new CardToken(); - $firstIdCardToken = $cardToken->generateCardTokenMaster("APRO"); - $secondIdCardToken = $cardToken->generateCardTokenVisa("APRO"); - - $transaction_info = ["transaction_info" => - [ - "transaction_amount" => 50, - "installments" => 1, - "token" => $firstIdCardToken, - "payment_method_id" => "master" - ], - [ - "transaction_amount" => 40, - "installments" => 1, - "token" => $secondIdCardToken, - "payment_method_id" => "visa" - ] - ]; - $multipayment->transaction_info = $transaction_info; - - $response = json_decode(json_encode($multipayment->save())); - - $this->assertEquals($response->status, 'approved'); - $this->assertEquals($response->payment_method_id, 'pp_multiple_payments'); - $this->assertEquals($response->payment_type_id, 'pp_multiple_payments'); - $this->assertEquals($response->transaction_info[0]->payment_method_id, 'master'); - $this->assertEquals($response->transaction_info[1]->payment_method_id, 'visa'); - $this->assertEquals($response->transaction_info[0]->status, 'approved'); - $this->assertEquals($response->transaction_info[1]->status, 'approved'); - $this->assertEquals($response->transaction_info[0]->status_detail, "accredited"); - $this->assertEquals($response->transaction_info[1]->status_detail, "accredited"); - $this->assertNotEquals($response->transaction_info[0]->id, $response->transaction_info[1]->id); - } - - public function testMultipaymentV1Rejected() - { - $multipayment = $this->loadMultipaymentV1(); - - $cardToken = new CardToken(); - $firstIdCardToken = $cardToken->generateCardTokenMaster("APRO"); - $secondIdCardToken = $cardToken->generateCardTokenVisa("OTHE"); - - $transaction_info = ["transaction_info" => - [ - "transaction_amount" => 50, - "installments" => 1, - "token" => $firstIdCardToken, - "payment_method_id" => "master" - ], - [ - "transaction_amount" => 40, - "installments" => 1, - "token" => $secondIdCardToken, - "payment_method_id" => "visa" - ] - ]; - $multipayment->transaction_info = $transaction_info; - - $response = null; - try { - $response = json_decode(json_encode($multipayment->save())); - } catch (\Exception $e) { - $response = $e->getMessage(); - } - $this->assertEquals($response, "No message for Multipayment scenario in v1!"); - } - - - public function testMultipaymentV2Success() - { - $multipayment = $this->loadMultipaymentV2(); - - $cardToken = new CardToken(); - $firstIdCardToken = $cardToken->generateCardTokenMaster("APRO"); - $secondIdCardToken = $cardToken->generateCardTokenVisa("APRO"); - - $transaction_info = ["transaction_info" => - [ - "transaction_amount" => 50, - "installments" => 1, - "token" => $firstIdCardToken, - "payment_method_id" => "master" - ], - [ - "transaction_amount" => 40, - "installments" => 1, - "token" => $secondIdCardToken, - "payment_method_id" => "visa" - ] - ]; - $multipayment->transaction_info = $transaction_info; - - $response = json_decode(json_encode($multipayment->save())); - - $this->assertEquals($response->status, 'approved'); - $this->assertEquals($response->payment_method_id, 'pp_multiple_payments'); - $this->assertEquals($response->payment_type_id, 'pp_multiple_payments'); - $this->assertEquals($response->transaction_info[0]->payment_method_id, 'master'); - $this->assertEquals($response->transaction_info[1]->payment_method_id, 'visa'); - $this->assertEquals($response->transaction_info[0]->status, 'approved'); - $this->assertEquals($response->transaction_info[1]->status, 'approved'); - $this->assertEquals($response->transaction_info[0]->status_detail, "accredited"); - $this->assertEquals($response->transaction_info[1]->status_detail, "accredited"); - $this->assertNotEquals($response->transaction_info[0]->id, $response->transaction_info[1]->id); - } - - public function testMultipaymentV2Rejected() - { - $multipayment = $this->loadMultipaymentV2(); - - $cardToken = new CardToken(); - $firstIdCardToken = $cardToken->generateCardTokenMaster("APRO"); - $secondIdCardToken = $cardToken->generateCardTokenVisa("OTHE"); - - $transaction_info = ["transaction_info" => - [ - "transaction_amount" => 50, - "installments" => 1, - "token" => $firstIdCardToken, - "payment_method_id" => "master" - ], - [ - "transaction_amount" => 40, - "installments" => 1, - "token" => $secondIdCardToken, - "payment_method_id" => "visa" - ] - ]; - $multipayment->transaction_info = $transaction_info; - - $response = null; - try { - $response = json_decode(json_encode($multipayment->save())); - } catch (\Exception $e) { - $response = $e->getMessage(); - } - $this->assertStringContainsString("No message for Multipayment scenario in v1!", $response); - } - - public function testMultipaymentV21Success() - { - $multipayment = $this->loadMultipaymentV21(); - - $cardToken = new CardToken(); - $firstIdCardToken = $cardToken->generateCardTokenMaster("APRO"); - $secondIdCardToken = $cardToken->generateCardTokenVisa("APRO"); - - $transaction_info = ["transaction_info" => - [ - "transaction_amount" => 50, - "installments" => 1, - "token" => $firstIdCardToken, - "payment_method_id" => "master" - ], - [ - "transaction_amount" => 40, - "installments" => 1, - "token" => $secondIdCardToken, - "payment_method_id" => "visa" - ] - ]; - $multipayment->transaction_info = $transaction_info; - - $response = json_decode(json_encode($multipayment->save())); - - $this->assertEquals($response->status, 'approved'); - $this->assertEquals($response->payment_method_id, 'pp_multiple_payments'); - $this->assertEquals($response->payment_type_id, 'pp_multiple_payments'); - $this->assertEquals($response->transaction_info[0]->payment_method_id, 'master'); - $this->assertEquals($response->transaction_info[1]->payment_method_id, 'visa'); - $this->assertEquals($response->transaction_info[0]->status, 'approved'); - $this->assertEquals($response->transaction_info[1]->status, 'approved'); - $this->assertEquals($response->transaction_info[0]->status_detail, "accredited"); - $this->assertEquals($response->transaction_info[1]->status_detail, "accredited"); - $this->assertNotEquals($response->transaction_info[0]->id, $response->transaction_info[1]->id); - } - - public function testMultipaymentV21Rejected() - { - $multipayment = $this->loadMultipaymentV21(); - - $cardToken = new CardToken(); - $firstIdCardToken = $cardToken->generateCardTokenMaster("APRO"); - $secondIdCardToken = $cardToken->generateCardTokenVisa("OTHE"); - - $transaction_info = ["transaction_info" => - [ - "transaction_amount" => 50, - "installments" => 1, - "token" => $firstIdCardToken, - "payment_method_id" => "master" - ], - [ - "transaction_amount" => 40, - "installments" => 1, - "token" => $secondIdCardToken, - "payment_method_id" => "visa" - ] - ]; - $multipayment->transaction_info = $transaction_info; - - try { - $response = json_decode(json_encode($multipayment->save())); - } catch (\Exception $e) { - $response = $e->getMessage(); - } - $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 deleted file mode 100644 index 265186708..000000000 --- a/packages/sdk/tests/integration/NotificationTest.php +++ /dev/null @@ -1,82 +0,0 @@ -loadConfigs(); - $accessToken = $envVars['ACCESS_TOKEN'] ?? null; - $publicKey = $envVars['PUBLIC_KEY'] ?? null; - $sdk = new Sdk( - $accessToken, - 'ppcoreinternal', - 'ppcoreinternal', - '', - $publicKey - ); - - return $sdk; - } - - private function createPayment($cardHolder) - { - - $configKeys = new ConfigKeys(); - $envVars = $configKeys->loadConfigs(); - $notificationUrl = $envVars['NOTIFICATION_URL'] ?? null; - - $sdk = $this->loadSdk(); - $payment = $sdk->getPaymentInstance(); - - $payment->transaction_amount = 230; - $payment->description = "Ergonomic Silk Shirt"; - $payment->payer->first_name = "Daniel"; - $payment->payer->last_name = "Lima"; - $payment->payer->identification->type = "CPF"; - $payment->payer->identification->number = "097.588.560-06"; - $payment->point_of_interaction->type = "CHECKOUT"; - $payment->payer->email = "test_user_98934401@testuser.com"; - $payment->notification_url = $notificationUrl; - $cardToken = new CardToken(); - $idToken = $cardToken->generateCardTokenMaster($cardHolder); - $payment->token = $idToken; - $payment->installments = 1; - $payment->payment_method_id = "master"; - return json_decode(json_encode($payment->save())); - } - - public function testNotificationAprooved() - { - $sdk = $this->loadSdk(); - $notification = $sdk->getNotificationInstance(); - $payment = $this->createPayment("APRO"); - $response = json_decode(json_encode($notification->read(array("id" => "P-".$payment->id)))); - $this->assertEquals($response->status, 'approved'); - } - - public function testNotificationRejected() - { - $sdk = $this->loadSdk(); - $notification = $sdk->getNotificationInstance(); - $payment = $this->createPayment("CALL"); - $response = json_decode(json_encode($notification->read(array("id" => "P-".$payment->id)))); - $this->assertEquals($response->status, 'rejected'); - } - - public function testNotificationNotFound() - { - $sdk = $this->loadSdk(); - $notification = $sdk->getNotificationInstance(); - $this->expectException(\Exception::class); - $this->expectExceptionMessage('1003 - KVS getValue not found'); - $notification->read(array("id" => "P-123456")); - } - -} \ No newline at end of file diff --git a/packages/sdk/tests/integration/PaymentMethodsTest.php b/packages/sdk/tests/integration/PaymentMethodsTest.php deleted file mode 100644 index e82d74a5d..000000000 --- a/packages/sdk/tests/integration/PaymentMethodsTest.php +++ /dev/null @@ -1,47 +0,0 @@ -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 deleted file mode 100644 index c82fc6332..000000000 --- a/packages/sdk/tests/integration/PaymentTest.php +++ /dev/null @@ -1,320 +0,0 @@ -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; - } - - 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"; - $payment->payer->last_name = "Lima"; - $payment->payer->identification->type = "CPF"; - $payment->payer->identification->number = "097.588.560-06"; - $payment->point_of_interaction->type = "CHECKOUT"; - - $payment->payer->email = "test_user_98934401@testuser.com"; - - return $payment; - } - - private function loadPaymentV21() - { - $payment = $this->loadPaymentSdkV21(); - $payment->transaction_amount = 230; - $payment->description = "Ergonomic Silk Shirt"; - $payment->payer->first_name = "Daniel"; - $payment->payer->last_name = "Lima"; - $payment->payer->identification->type = "CPF"; - $payment->payer->identification->number = "097.588.560-06"; - $payment->point_of_interaction->type = "CHECKOUT"; - - $payment->payer->email = "test_user_98934401@testuser.com"; - - return $payment; - } - - 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 - ); - $notificationUrl = $envVars['NOTIFICATION_URL'] ?? null; - $payment = $sdk->getPaymentInstance(); - $payment->notification_url = $notificationUrl; - - $payment->transaction_amount = 230; - $payment->description = "Ergonomic Silk Shirt"; - $payment->installments = 3; - $payment->payment_method_id = "master"; - $payment->payer->email = "test_user_98934401@testuser.com"; - $payment->three_d_secure_mode = "optional"; - - return $payment; - } - - - public function testPaymentSuccessCreditCard() - { - $payment = $this->loadPayment(); - - $cardToken = new CardToken(); - $idToken = $cardToken->generateCardTokenMaster("APRO"); - - $payment->token = $idToken; - $payment->installments = 1; - $payment->payment_method_id = "master"; - - $response = json_decode(json_encode($payment->save())); - - $this->assertEquals($response->status, 'approved'); - $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, "accredited"); - } - - public function testPaymentRejectedCreditCard() - { - $payment = $this->loadPayment(); - - $cardToken = new CardToken(); - $idToken = $cardToken->generateCardTokenMaster("OTHE"); - - $payment->token = $idToken; - $payment->installments = 1; - $payment->payment_method_id = "master"; - - $response = json_decode(json_encode($payment->save())); - - $this->assertEquals($response->status, 'rejected'); - $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_bad_filled_other"); - } - - public function testPaymentV21SuccessCreditCard() - { - $payment = $this->loadPaymentV21(); - - $cardToken = new CardToken(); - $idToken = $cardToken->generateCardTokenMaster("APRO"); - - $payment->token = $idToken; - $payment->installments = 1; - $payment->payment_method_id = "master"; - - $response = json_decode(json_encode($payment->save())); - - $this->assertEquals($response->status, 'approved'); - $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, "accredited"); - } - - public function testPaymentV21RejectedCreditCard() - { - $payment = $this->loadPaymentV21(); - - $cardToken = new CardToken(); - $idToken = $cardToken->generateCardTokenMaster("OTHE"); - - $payment->token = $idToken; - $payment->installments = 1; - $payment->payment_method_id = "master"; - - $response = json_decode(json_encode($payment->save())); - - $this->assertEquals($response->status, 'rejected'); - $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_bad_filled_other"); - } - - 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())); - - $this->assertEquals($response->status, 'pending'); - $this->assertEquals($response->payment_method_id, 'bolbradesco'); - $this->assertEquals($response->payment_type_id, 'ticket'); - $this->assertEquals($response->status_detail, "pending_waiting_payment"); - } - - public function testPaymentSuccessPix() - { - $payment = $this->loadPayment(); - - $payment->payment_method_id = "pix"; - - $response = json_decode(json_encode($payment->save())); - - $this->assertEquals($response->status, 'pending'); - $this->assertEquals($response->payment_method_id, 'pix'); - $this->assertEquals($response->payment_type_id, 'bank_transfer'); - $this->assertEquals($response->status_detail, "pending_waiting_transfer"); - } - - public function testPaymentSuccessCreditCard3DS() - { - $payment = $this->loadPayment3DS(); - - $cardToken = new CardToken(); - $idToken = $cardToken->generateCardTokenMaster3DS("APRO"); - - $payment->token = $idToken; - $payment->installments = 3; - $payment->payment_method_id = "master"; - - $response = json_decode(json_encode($payment->save())); - - $this->assertEquals($response->status, 'approved'); - $this->assertEquals($response->payment_method_id, 'master'); - $this->assertEquals($response->payment_type_id, 'credit_card'); - $this->assertEquals($response->installments, 3); - $this->assertEquals($response->status_detail, "accredited"); - } - - public function testPaymentRejectedCreditCard3DS() - { - $payment = $this->loadPayment3DS(); - - $cardToken = new CardToken(); - $idToken = $cardToken->generateCardTokenMaster3DS("OTHE"); - - $payment->token = $idToken; - $payment->installments = 1; - $payment->payment_method_id = "master"; - - $response = json_decode(json_encode($payment->save())); - - $this->assertEquals($response->status, 'rejected'); - $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_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 deleted file mode 100644 index 8a7a997ad..000000000 --- a/packages/sdk/tests/integration/PreferenceTest.php +++ /dev/null @@ -1,132 +0,0 @@ -loadConfigs(); - $accessToken = $envVars['ACCESS_TOKEN'] ?? null; - $publicKey = $envVars['PUBLIC_KEY'] ?? null; - $sdk = new Sdk( - $accessToken, - 'ppcoreinternal', - 'ppcoreinternal', - '', - $publicKey - ); - return $sdk->getPreferenceInstance(); - } - - private function loadPreference() - { - $configKeys = new ConfigKeys(); - $envVars = $configKeys->loadConfigs(); - $preference = $this->loadPreferenceSdk(); - $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 - ] - ]; - $notificationUrl = $envVars['NOTIFICATION_URL'] ?? null; - $preference->items = $items; - $preference->notification_url = $notificationUrl; - $preference->external_reference = "external_reference"; - - return $preference; - } - - - public function testPreferenceSucces() - { - $preference = $this->loadPreference(); - $response = json_decode(json_encode($preference->save())); - $this->assertEquals($response->external_reference, "external_reference"); - $this->assertEquals($response->items[0]->unit_price, 10.5); - } - - public function testPreferenceWithoutUnitPrice() - { - $preference = $this->loadPreference(); - - $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" => null - ] - ]; - - $preference->items = $items; - - $this->expectException(\Exception::class); - $this->expectExceptionMessage('items.1.unit_price must be a number'); - - $preference->save(); - } - - public function testPreferenceWithoutQuantity() - { - $preference = $this->loadPreference(); - - $items = ["items" => - [ - "title" => "Dummy Title", - "description" => "Dummy description", - "picture_url" => "http://www.myapp.com/myimage.jpg", - "category_id" => "car_electronics", - "quantity" => null, - "currency_id" => "BRL", - "unit_price" => 10.5 - ] - ]; - - $preference->items = $items; - - $this->expectException(\Exception::class); - $this->expectExceptionMessage('items.1.quantity must be a number'); - - $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 deleted file mode 100644 index 9804effe9..000000000 --- a/packages/sdk/tests/integration/RegisterErrorLog.php +++ /dev/null @@ -1,56 +0,0 @@ -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 deleted file mode 100644 index 19e421bb4..000000000 --- a/packages/sdk/tests/integration/SellerFunnelBaseTest.php +++ /dev/null @@ -1,84 +0,0 @@ -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/ConfigTest.php b/packages/sdk/tests/unit/Common/ConfigTest.php deleted file mode 100644 index a967c82f8..000000000 --- a/packages/sdk/tests/unit/Common/ConfigTest.php +++ /dev/null @@ -1,37 +0,0 @@ -config = new Config(); - } - - function testGetAndSetSuccess() - { - $this->config->__set('access_token', 'XXX'); - - $actual = $this->config->__get('access_token'); - $expected = 'XXX'; - - $this->assertEquals($expected, $actual); - } -} diff --git a/packages/sdk/tests/unit/Common/ManagerTest.php b/packages/sdk/tests/unit/Common/ManagerTest.php deleted file mode 100644 index b64f95aaf..000000000 --- a/packages/sdk/tests/unit/Common/ManagerTest.php +++ /dev/null @@ -1,206 +0,0 @@ -clientMock = $this->getMockBuilder(HttpClient::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->configMock = $this->getMockBuilder(Config::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->preferenceMock = $this->getMockBuilder(Preference::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->responseMock = $this->getMockBuilder(Response::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->manager = new Manager($this->clientMock, $this->configMock); - } - - function testExecuteWithGetMethodSuccess() - { - $header = array('x-product-id' => 'product_id', 'x-integrator-id' => 'integrator_id'); - - $this->clientMock->expects(self::any())->method('get')->willReturn($this->responseMock); - - $actual = $this->manager->execute($this->preferenceMock, '/preference/123', 'get', $header); - - $this->assertEquals($this->responseMock, $actual); - } - - function testExecuteWithPostMethodSuccess() - { - $header = array('x-product-id' => 'product_id', 'x-integrator-id' => 'integrator_id'); - - $this->clientMock->expects(self::any())->method('post')->willReturn($this->responseMock); - - $actual = $this->manager->execute($this->preferenceMock, '/preference', 'post', $header); - - $this->assertEquals($this->responseMock, $actual); - } - - function testGetEntityUriWithoutParamsSuccess() - { - $uris = array('post' => '/preference'); - - $this->preferenceMock->expects(self::any())->method('getUris')->willReturn($uris); - - $actual = $this->manager->getEntityUri($this->preferenceMock, 'post'); - $expected = '/preference'; - - $this->assertEquals($expected, $actual); - } - - function testGetEntityUriWithParamsSuccess() - { - $uris = array('get' => '/preference/:id'); - $params = array('id' => '123'); - - $this->preferenceMock->expects(self::any())->method('getUris')->willReturn($uris); - - $actual = $this->manager->getEntityUri($this->preferenceMock, 'get', $params); - $expected = '/preference/123'; - - $this->assertEquals($expected, $actual); - } - - function testGetEntityUriWithParamsFailure() - { - $uris = array('get' => '/preference/:id'); - $params = array('client_id' => '123'); - - $this->preferenceMock->expects(self::any())->method('getUris')->willReturn($uris); - - $actual = $this->manager->getEntityUri($this->preferenceMock, 'get', $params); - $expected = '/preference/'; - - $this->assertEquals($expected, $actual); - } - - function testGetEntityUriFailure() - { - $entity = new Payer(null); - - $this->expectExceptionMessage('Method not available for MercadoPago\PP\Sdk\Entity\Payment\Payer entity'); - $this->manager->getEntityUri($entity, 'post'); - } - - function testGetDefaultHeaderSuccess() - { - $this->configMock->expects(self::exactly(4))->method('__get')->willReturn('XXX'); - - $actual = $this->manager->getDefaultHeader(); - $this->assertTrue(is_array($actual)); - } - - function testGetHeaderSuccess() - { - $this->configMock->expects(self::exactly(4))->method('__get')->willReturn('XXX'); - - $actual = $this->manager->getHeader(); - $this->assertTrue(is_array($actual)); - } - - function testHandleResponseGetMethodSuccess() - { - $this->responseMock->expects(self::any())->method('getStatus')->willReturn(200); - $this->responseMock->expects(self::any())->method('getData')->willReturn(new stdClass()); - - $actual = $this->manager->handleResponse($this->responseMock, 'get'); - $expected = new stdClass(); - - $this->assertEquals($expected, $actual); - } - - function testHandleResponseFailure() - { - $data = array('message' => 'Error'); - - $this->responseMock->expects(self::any())->method('getStatus')->willReturn(400); - $this->responseMock->expects(self::any())->method('getData')->willReturn($data); - - $this->expectExceptionMessage('Error'); - $this->manager->handleResponse($this->responseMock, 'get'); - } - - function testHandleResponseFailureInternalApiError() - { - $this->responseMock->expects(self::any())->method('getStatus')->willReturn(500); - $this->responseMock->expects(self::any())->method('getData')->willReturn(null); - - $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 deleted file mode 100644 index c2e431837..000000000 --- a/packages/sdk/tests/unit/Entity/Identification/CreateSellerFunnelBaseTest.php +++ /dev/null @@ -1,93 +0,0 @@ -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 deleted file mode 100644 index 92b8cee15..000000000 --- a/packages/sdk/tests/unit/Entity/Identification/UpdateSellerFunnelBaseTest.php +++ /dev/null @@ -1,87 +0,0 @@ -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 deleted file mode 100644 index 58e61a719..000000000 --- a/packages/sdk/tests/unit/Entity/MerchantOrder/MerchantOrderTest.php +++ /dev/null @@ -1,109 +0,0 @@ -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/DatadogEventTest.php b/packages/sdk/tests/unit/Entity/Monitoring/DatadogEventTest.php deleted file mode 100644 index 2be455576..000000000 --- a/packages/sdk/tests/unit/Entity/Monitoring/DatadogEventTest.php +++ /dev/null @@ -1,118 +0,0 @@ -datadogEventMock = DatadogEventMock::COMPLETE_DATADOG_EVENT; - - $this->managerMock = $this->getMockBuilder(Manager::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->responseMock = $this->getMockBuilder(Response::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->datadogEvent = new DatadogEvent($this->managerMock); - $this->datadogEvent->setEntity($this->datadogEventMock); - } - - function testSubclassesTypes() - { - $platform = $this->datadogEvent->__get('platform'); - $details = $this->datadogEvent->__get('details'); - - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Monitoring\Platform", $platform); - $this->assertIsArray($details); - } - - function testGetAndSetSuccess() - { - $this->datadogEvent->__set('value', 'success'); - - $actual = $this->datadogEvent->__get('value'); - $expected = 'success'; - - $this->assertEquals($expected, $actual); - } - - function testGetHeadersSuccess() - { - $actual = $this->datadogEvent->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->datadogEvent->getUris(); - - $this->assertTrue(is_array($actual)); - } - - function testRegisterSuccess() - { - $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/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->datadogEvent->register(array("team" => "core", "event_type"=> "unit_test")); - - $this->assertTrue($actual); - } - - function testJsonSerializeSuccess() - { - $actual = $this->datadogEvent->jsonSerialize(); - $expected = 'success'; - - $this->assertTrue(is_array($actual)); - $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 deleted file mode 100644 index 8e635d811..000000000 --- a/packages/sdk/tests/unit/Entity/Monitoring/RegisterErrorLogTest.php +++ /dev/null @@ -1,106 +0,0 @@ -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/Notification/NotificationTest.php b/packages/sdk/tests/unit/Entity/Notification/NotificationTest.php deleted file mode 100644 index b78299666..000000000 --- a/packages/sdk/tests/unit/Entity/Notification/NotificationTest.php +++ /dev/null @@ -1,109 +0,0 @@ -notificationMock = NotificationMock::COMPLETE_NOTIFICATION; - - $this->managerMock = $this->getMockBuilder(Manager::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->responseMock = $this->getMockBuilder(Response::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->notification = new Notification($this->managerMock); - $this->notification->setEntity($this->notificationMock); - } - - function testGetAndSetSuccess() - { - $this->notification->__set('notification_id', 'XXX'); - - $actual = $this->notification->__get('notification_id'); - $expected = 'XXX'; - - $this->assertEquals($expected, $actual); - } - - function testGetHeadersSuccess() - { - $actual = $this->notification->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->notification->getUris(); - - $this->assertTrue(is_array($actual)); - } - - function testReadSuccess() - { - $this->responseMock->expects(self::any())->method('getStatus')->willReturn(200); - $this->responseMock->expects(self::any())->method('getData')->willReturn($this->notificationMock); - - $this->managerMock->expects(self::any())->method('getEntityUri')->willReturn('/v1/asgard/notification/: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->notificationMock); - - $actual = $this->notification->read(array("id" => "P-25604645467")); - - $this->assertEquals(json_encode($this->responseMock->getData()), json_encode($actual)); - } - - function testJsonSerializeSuccess() - { - $actual = $this->notification->jsonSerialize(); - $expected = 'P-25604645467'; - - $this->assertTrue(is_array($actual)); - $this->assertEquals($expected, $actual['notification_id']); - } -} diff --git a/packages/sdk/tests/unit/Entity/Payment/PaymentTest.php b/packages/sdk/tests/unit/Entity/Payment/PaymentTest.php deleted file mode 100644 index 76bf369e4..000000000 --- a/packages/sdk/tests/unit/Entity/Payment/PaymentTest.php +++ /dev/null @@ -1,204 +0,0 @@ -paymentMock = PaymentMock::COMPLETE_PAYMENT; - - $this->managerMock = $this->getMockBuilder(Manager::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->responseMock = $this->getMockBuilder(Response::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->payment = new Payment($this->managerMock); - $this->payment->setEntity($this->paymentMock); - } - - function testSubclassesTypes() - { - $additionalInfo = $this->payment->__get('additional_info'); - $additionalInfoPayer = $additionalInfo->__get('payer'); - $additionalInfoPayerAddress = $additionalInfoPayer->__get('address'); - $phone = $additionalInfoPayer->__get('phone'); - - $shipments = $additionalInfo->__get('shipments'); - $receiverAddress = $shipments->__get('receiver_address'); - - $items = $additionalInfo->__get('items'); - $item = $items->getIterator()[0]; - - $payer = $this->payment->__get('payer'); - $identification = $payer->__get('identification'); - $payerAddress = $payer->__get('address'); - $phoneAddress = $payer->__get('phone'); - - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Payment\AdditionalInfo", $additionalInfo); - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Payment\AdditionalInfoPayer", $additionalInfoPayer); - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Payment\AdditionalInfoAddress", $additionalInfoPayerAddress); - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Payment\Phone", $phone); - - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Payment\Shipments", $shipments); - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Payment\AdditionalInfoAddress", $receiverAddress); - - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Payment\ItemList", $items); - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Payment\Item", $item); - - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Payment\Payer", $payer); - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Payment\Identification", $identification); - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Payment\Address", $payerAddress); - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Payment\Phone", $phoneAddress); - } - - function testGetAndSetSuccess() - { - $this->payment->__set('external_reference', 'XXX'); - - $actual = $this->payment->__get('external_reference'); - $expected = 'XXX'; - - $this->assertEquals($expected, $actual); - } - - function testGetHeadersSuccess() - { - $actual = $this->payment->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 testSetCustomHeaderSuccess() - { - $this->payment->setCustomHeaders(['x-customer-id: ' . '102030']); - $headers = $this->payment->getHeaders()['save']; - $expectedHeader = 'x-customer-id: 102030'; - - $this->assertContains($expectedHeader, $headers); - } - - function testGetAndSetSessionIdHeaderSuccess() - { - $this->payment->__set('session_id', 'armor.hash.123456'); - - $headers = $this->payment->getHeaders()['save']; - $expectedHeader = 'x-meli-session-id: armor.hash.123456'; - - $property = $this->payment->__get('session_id'); - $expectedProperty = 'armor.hash.123456'; - - $this->assertContains($expectedHeader, $headers); - $this->assertEquals($expectedProperty, $property); - } - - function testGetUriSuccess() - { - $actual = $this->payment->getUris(); - - $this->assertTrue(is_array($actual)); - } - - function testReadSuccess() - { - $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/asgard/payments'); - $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("external_reference" => "WC-105")); - - $this->assertEquals(json_encode($this->responseMock->getData()), json_encode($actual)); - } - - function testRead3DSSuccess() - { - $this->paymentMock = PaymentMock::COMPLETE_PAYMENT_WITH_3DS; - $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/asgard/payments'); - $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("external_reference" => "WC-105")); - - $this->assertEquals(json_encode($this->responseMock->getData()), json_encode($actual)); - } - - function testJsonSerializeSuccess() - { - $actual = $this->payment->jsonSerialize(); - $expected = 'WC-105'; - - $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 deleted file mode 100644 index e9805c221..000000000 --- a/packages/sdk/tests/unit/Entity/PaymentMethods/PaymentMethodsTest.php +++ /dev/null @@ -1,149 +0,0 @@ -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/Entity/Preference/PreferenceTest.php b/packages/sdk/tests/unit/Entity/Preference/PreferenceTest.php deleted file mode 100644 index 206043b08..000000000 --- a/packages/sdk/tests/unit/Entity/Preference/PreferenceTest.php +++ /dev/null @@ -1,180 +0,0 @@ -preferenceMock = PreferenceMock::COMPLETE_PREFERENCE; - - $this->managerMock = $this->getMockBuilder(Manager::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->responseMock = $this->getMockBuilder(Response::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->preference = new Preference($this->managerMock); - $this->preference->setEntity($this->preferenceMock); - } - - function testSubclassesTypes() - { - $backUrl = $this->preference->__get('back_urls'); - $items = $this->preference->__get('items'); - $item = $items->getIterator()[0]; - - $payer = $this->preference->__get('payer'); - $address = $payer->__get('address'); - $payerIdentification = $payer->__get('identification'); - $phone = $payer->__get('phone'); - - $tracks = $this->preference->__get('tracks'); - $track = $tracks->getIterator()[0]; - - $paymentMethod = $this->preference->__get('payment_methods'); - $excludedPaymentMethods = $paymentMethod->__get('excluded_payment_methods'); - $excludedPaymentMethod = $excludedPaymentMethods->getIterator()[0]; - $excludedPaymentTypes = $paymentMethod->__get('excluded_payment_types'); - $excludedPaymentType = $excludedPaymentTypes->getIterator()[0]; - - $shipment = $this->preference->__get('shipments'); - $freeMethods = $shipment->__get('free_methods'); - $freeMethod = $freeMethods->getIterator()[0]; - $receiverAddress = $shipment->__get('receiver_address'); - - $additionalInfo = $this->preference->__get('additional_info'); - $additionalInfoPayer = $additionalInfo->__get('payer'); - $additionalInfoPayerAddress = $additionalInfoPayer->__get('address'); - $phone_additional_info = $additionalInfoPayer->__get('phone'); - - $shipments = $additionalInfo->__get('shipments'); - $receiverAddress_additional_info = $shipments->__get('receiver_address'); - - $items_additional_info = $additionalInfo->__get('items'); - $item_additional_info = $items_additional_info->getIterator()[0]; - - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Preference\BackUrl", $backUrl); - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Preference\Item", $item); - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Preference\ItemList", $items); - - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Preference\Payer", $payer); - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Preference\Address", $address); - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Preference\PayerIdentification", $payerIdentification); - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Preference\Phone", $phone); - - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Preference\PaymentMethod", $paymentMethod); - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Preference\ExcludedPaymentMethod", $excludedPaymentMethod); - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Preference\ExcludedPaymentMethodList", $excludedPaymentMethods); - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Preference\ExcludedPaymentType", $excludedPaymentType); - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Preference\ExcludedPaymentTypeList", $excludedPaymentTypes); - - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Preference\Shipment", $shipment); - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Preference\FreeMethod", $freeMethod); - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Preference\FreeMethodList", $freeMethods); - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Preference\ReceiverAddress", $receiverAddress); - - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Preference\Track", $track); - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Preference\TrackList", $tracks); - - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Payment\AdditionalInfo", $additionalInfo); - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Payment\AdditionalInfoPayer", $additionalInfoPayer); - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Payment\AdditionalInfoAddress", $additionalInfoPayerAddress); - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Payment\Phone", $phone_additional_info); - - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Payment\Shipments", $shipments); - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Payment\AdditionalInfoAddress", $receiverAddress_additional_info); - - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Payment\ItemList", $items_additional_info); - $this->assertInstanceOf("MercadoPago\PP\Sdk\Entity\Payment\Item", $item_additional_info); - } - - function testGetAndSetSuccess() - { - $this->preference->__set('external_reference', 'XXX'); - - $actual = $this->preference->__get('external_reference'); - $expected = 'XXX'; - - $this->assertEquals($expected, $actual); - } - - function testGetHeadersSuccess() - { - $actual = $this->preference->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->preference->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->preferenceMock); - - $this->managerMock->expects(self::any())->method('getEntityUri')->willReturn('/v1/asgard/preferences'); - $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->preference->save(); - - $this->assertTrue($actual); - } - - function testJsonSerializeSuccess() - { - $actual = $this->preference->jsonSerialize(); - $expected = 'WC-XX'; - - $this->assertTrue(is_array($actual)); - $this->assertEquals($expected, $actual['external_reference']); - } -} diff --git a/packages/sdk/tests/unit/HttpClient/HttpClientTest.php b/packages/sdk/tests/unit/HttpClient/HttpClientTest.php deleted file mode 100644 index 1b5f2f86a..000000000 --- a/packages/sdk/tests/unit/HttpClient/HttpClientTest.php +++ /dev/null @@ -1,86 +0,0 @@ -getMockBuilder(RequesterInterface::class) - ->onlyMethods(['createRequest', 'sendRequest']) - ->getMock(); - - $mock->expects(self::any())->method('createRequest')->willReturn($mock); - - $mock->expects(self::any())->method('sendRequest')->willReturn($response); - - return $mock; - } - - function testHttpGetSuccess() - { - // arrange - $mockResponse = new Response(); - $mockResponse->setStatus(200); - $mockResponse->setData(new stdClass()); - - $client = new HttpClient('https://some-url.com', $this->getRequesterInterfaceMock($mockResponse)); - - // act - $response = $client->get('/'); - - // assert - $this->assertEquals($mockResponse, $response); - } - - function testHttpPutSuccess() - { - // arrange - $mockResponse = new Response(); - $mockResponse->setStatus(200); - $mockResponse->setData(new stdClass()); - - $client = new HttpClient('https://some-url.com', $this->getRequesterInterfaceMock($mockResponse)); - - // act - $response = $client->put('/'); - - // assert - $this->assertEquals($mockResponse, $response); - } - - function testHttpPostSuccess() - { - // arrange - $mockResponse = new Response(); - $mockResponse->setStatus(200); - $mockResponse->setData(new stdClass()); - - $client = new HttpClient('https://some-url.com', $this->getRequesterInterfaceMock($mockResponse)); - - // act - $response = $client->post('/'); - - $this->assertEquals($mockResponse, $response); - } - - function testHttpSendBodyError() - { - // arrange - $mockResponse = new Response(); - - $client = new HttpClient('https://some-url.com', $this->getRequesterInterfaceMock($mockResponse)); - - // assert + act - $this->expectException(Exception::class); - $client->send('get', 'https://some-url.com', [], 100); - } -} diff --git a/packages/sdk/tests/unit/HttpClient/Requester/CurlRequesterTest.php b/packages/sdk/tests/unit/HttpClient/Requester/CurlRequesterTest.php deleted file mode 100644 index 0d7c3a96c..000000000 --- a/packages/sdk/tests/unit/HttpClient/Requester/CurlRequesterTest.php +++ /dev/null @@ -1,136 +0,0 @@ - $responseCode - ); - - $mock = $this->getMockBuilder(CurlRequester::class) - ->onlyMethods(['curlInit', 'curlClose', 'setOption', 'curlExec', 'curlErrno', 'curlError', 'curlGetInfo']) - ->getMock(); - - $mock->expects(self::any())->method('curlInit')->willReturn(array()); - - $mock->expects(self::any())->method('curlGetInfo')->willReturn($apiResponse); - - $mock->expects(self::any())->method('curlExec')->willReturn(CurlRequestMock::CURL_EXEC_RESPONSE); - - if ($errno) { - $mock->expects(self::any())->method('curlErrno')->willReturn($errno); - $mock->expects(self::any())->method('curlError')->willReturn($error); - } - - return $mock; - } - - /** - * A single example test. - */ - function testCreateRequestSuccess() - { - $requester = $this->getPartialCurlRequesterMock(200, 0, ''); - - // act - $response = $requester->createRequest('method', 'uri', [], null); - - // assert - $this->assertEquals(array(), $response); - } - - /** - * A single example test. - */ - function testCreateRequestWithJsonArrayBodySuccess() - { - // arrange - $requester = $this->getPartialCurlRequesterMock(200, 0, ''); - - // act - $response = $requester->createRequest('method', 'uri', [], array('test' => 123)); - - // assert - $this->assertEquals(array(), $response); - } - - /** - * A single example test. - */ - function testCreateRequestWithJsonStringBodySuccess() - { - // arrange - $requester = $this->getPartialCurlRequesterMock(200, 0, ''); - - // act - $response = $requester->createRequest('method', 'uri', [], '{"test":"123"}'); - - // assert - $this->assertEquals(array(), $response); - } - - /** - * A single example test. - */ - function testCreateRequestWithFormDataBodySuccess() - { - // arrange - $requester = $this->getPartialCurlRequesterMock(200, 0, ''); - $headers = array( - 'content-type' => 'application/x-www-form-urlencoded' - ); - - // act - $response = $requester->createRequest('method', 'uri', $headers, array('test' => 123)); - - // assert - $this->assertEquals(array(), $response); - } - - /** - * A single example test. - */ - function testSendRequestSuccess() - { - $mockResponse = new Response(); - $mockResponse->setStatus(200); - $mockResponse->setData(json_decode('{"test":"123"}', true)); - $mockResponse->setHeaders([]); - - $requester = $this->getPartialCurlRequesterMock(200, 0, ''); - - // act - $response = $requester->sendRequest('curl_request'); - - // assert - $this->assertEquals($mockResponse, $response); - } - - /** - * A single example test. - */ - function testSendRequestError() - { - $mockResponse = new Response(); - $mockResponse->setStatus(200); - $mockResponse->setData(new stdClass()); - - $requester = $this->getPartialCurlRequesterMock(200, 1, 'some_error'); - - // assert + act - $this->expectException(Exception::class); - $requester->sendRequest(''); - } -} diff --git a/packages/sdk/tests/unit/Mock/CreateSellerFunnelBaseMock.php b/packages/sdk/tests/unit/Mock/CreateSellerFunnelBaseMock.php deleted file mode 100644 index 4d1548d08..000000000 --- a/packages/sdk/tests/unit/Mock/CreateSellerFunnelBaseMock.php +++ /dev/null @@ -1,15 +0,0 @@ - "ppcoreinternal", - "shopUrl" => "http://localhost" - ]; -} diff --git a/packages/sdk/tests/unit/Mock/CurlRequestMock.php b/packages/sdk/tests/unit/Mock/CurlRequestMock.php deleted file mode 100644 index fc18b4180..000000000 --- a/packages/sdk/tests/unit/Mock/CurlRequestMock.php +++ /dev/null @@ -1,11 +0,0 @@ - "success", - "message" => "error message", - "plugin_version" => "1.2.3", - "platform" => [ - "name" => "ppcoreinternal", - "version" => "1.2.3", - "uri" => "/platform_uri", - "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 deleted file mode 100644 index d87ee98ac..000000000 --- a/packages/sdk/tests/unit/Mock/MerchantOrderMock.php +++ /dev/null @@ -1,141 +0,0 @@ - [ - [ - "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/NotificationMock.php b/packages/sdk/tests/unit/Mock/NotificationMock.php deleted file mode 100644 index 85f83d8c5..000000000 --- a/packages/sdk/tests/unit/Mock/NotificationMock.php +++ /dev/null @@ -1,81 +0,0 @@ - "P-25604645467", - "notification_url" => "https://httpbin.org/post", - "status" => "approved", - "transaction_id" => 25604645467, - "transaction_type" => "payment", - "transaction_amount" => 51.99, - "total_pending" => 0, - "total_approved" => 51.99, - "total_paid" => 51.99, - "total_rejected" => 0, - "total_refunded" => 0, - "total_cancelled" => 0, - "total_charged_back" => 0, - "payments_metadata" => [ - "account_name" => "paguemenos01040", - "callback_url" => "https://mercadopago.vtexpayments.com.br/api/pvt/payment-provider/transactions/4ED8296AB28F47C6AF3FFFBA558F2EDD/payments/9A5431CE81A44DBA8C76268BBD7F6781/callback?accountName=paguemenos01040", - "delay_auto_settle" => "1", - "merchant_name" => "paguemenos01040", - "order_id" => "4ED8296AB28F47C6AF3FFFBA558F2EDD", - "original_notification_url" => "https://httpbin.org/post", - "seller_website" => "http://paguemenos.vtexcommercestable.com.br", - "uuid" => "c9b70cc3-dd29-4c28-acb3-94f3632f3dd1", - "vtex_payment_id" => "9A5431CE81A44DBA8C76268BBD7F6781", - "vtex_transaction_id" => "4ED8296AB28F47C6AF3FFFBA558F2EDD" - ], - "payments_details" => [ - [ - "id" => 25604645467, - "status" => "approved", - "status_detail" => "accredited", - "payment_type_id" => "pix", - "payment_method_id" => "pix", - "payment_method_info"=> [ - "barcode_content" => "9A5431CE81A44DBA8C76268BBD7F6781", - "external_resource_url" => "https://mercadopago.vtexpayments.com.br/api/pvt/payment-provider/transactions/4ED8296AB28F47C6AF3FFFBA558F2EDD/payments/9A5431CE81A44DBA8C76268BBD7F6781/callback?accountName=paguemenos01040", - "payment_method_reference_id" => "1129288350", - "date_of_expiration" => "2022-09-20T22:13:32.000+0000", - "installments" => 51.99, - "installment_rate" => 51.99, - "last_four_digits" => "1234", - "installment_amount" => 51.99 - ], - "total_amount" => 51.99, - "paid_amount" => 51.99, - "coupon_amount" => 0, - "shipping_cost" => 0, - "refunds" => [ - "1129288350" => [ - "id" => "1129288350", - "status" => "approved", - "notifying" => true, - "metadata" => [ - "uuid" => "c9b70cc3-dd29-4c28-acb3-94f3632f3dd1", - "order_id" => "4ED8296AB28F47C6AF3FFFBA558F2EDD" - ] - ], - "1129288351" => [ - "id" => "1129288351", - "status" => "approved", - "notifying" => true, - "metadata" => [ - "uuid" => "c9b70cc3-dd29-4c28-acb3-94f3632f3dd2", - "order_id" => "4ED8296AB28F47C6AF3FFFBA558F2EDD" - ] - ] - ] - ] - ] - ]; -} diff --git a/packages/sdk/tests/unit/Mock/PaymentMethodsMock.php b/packages/sdk/tests/unit/Mock/PaymentMethodsMock.php deleted file mode 100644 index 85c74660d..000000000 --- a/packages/sdk/tests/unit/Mock/PaymentMethodsMock.php +++ /dev/null @@ -1,55 +0,0 @@ - "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/PaymentMock.php b/packages/sdk/tests/unit/Mock/PaymentMock.php deleted file mode 100644 index 5d2195a13..000000000 --- a/packages/sdk/tests/unit/Mock/PaymentMock.php +++ /dev/null @@ -1,296 +0,0 @@ - false, - "external_reference" => "WC-105", - "notification_url" => "https://httpbin.org/post", - "statement_descriptor" => "TESTSTORE", - "transaction_amount" => 12, - "installments" => null, - "three_d_secure_mode" => "not_supported", - "description" => "Flying Ninja x 1", - "payment_method_id" => "pix", - "date_of_expiration" => "2022-09-20T22:13:32.000+0000", - "point_of_interaction" => [ - "type" => "OPENPLATFORM" - ], - "payer" => [ - "email" => "test_user_15543629@testuser.com", - "first_name" => "Test", - "last_name" => "Customer", - "identification" => [ - "type" => "CPF", - "number" => "376.624.684-45" - ], - "address" => [ - "street_name" => "Address - BR - BR", - "street_number" => "123", - "neighborhood" => "City", - "city" => "City", - "federal_unit" => "SP", - "zip_code" => "00000-000" - ] - ], - "additional_info" => [ - "ip_address"=> "191.191.191.0", - "referral_url"=> "www.sellertest.com", - "drop_shipping"=> true, - "delivery_promise"=> "2022-09-22", - "contrated_plan"=> "premium", - "items"=> [ - [ - "category_id"=> "others", - "description"=> "bola", - "id"=> "123", - "picture_url"=> "https=>//", - "quantity"=> "1", - "title"=> "Bola de futebol", - "unit_price"=> "20" - ] - ], - "payer"=> [ - "address"=> [ - "street_name"=> "Rua Teste", - "zip_code"=> "00000-000", - "city"=> "São Paulo", - "country"=> "Brasil", - "state"=> "SP", - "number"=> "0", - "complement"=> "A" - ], - "first_name"=> "EncryptedName", - "last_name"=> "Bar", - "phone"=> [ - "area_code"=> "11", - "number"=> "999999999" - ], - "mobile"=> [ - "area_code"=> 11, - "number"=> "" - ], - "identification"=> [ - "type"=> "", - "number"=> 0 - ], - "registration_date"=> "2023-04-11T19=>18=>38.486Z", - "registered_user"=> false, - "device_id"=> "", - "platform_email"=> "", - "register_updated_at"=> "2023-04-11T19=>18=>38.486Z", - "user_email"=> "test@test.com", - "authentication_type"=> "", - "last_purchase"=> "" - ], - "seller"=> [ - "id"=> "", - "registration_date"=> "2023-04-11T19=>18=>38.486Z", - "business_type"=> "dropshipping", - "identification"=> [ - "type"=> "", - "number"=> "0", - ], - "status"=> "active", - "store_id"=> "123", - "user_platform_mail"=> "gmail", - "email"=> "test@test.com", - "phone"=> [ - "area_code"=> "11", - "number"=> "" - ], - "collector"=> "123", - "website"=> "https//", - "platform_url"=> "https//", - "referral_url"=> "", - "register_updated_at"=> "2023-04-11T19=>18=>38.486Z", - "document"=> "123", - "name"=> "Foo", - "hired_plan"=> "plan", - "address"=> [ - "zip_code"=> "00000-000", - "street_name"=> "Rua Teste", - "city"=> "São Paulo", - "country"=> "Brasil", - "state"=> "SP", - "number"=> "0", - "complement"=> "A" - ] - ], - "shipments"=> [ - "receiver_address"=> [ - "apartment"=> "45", - "floor"=> "4", - "street_name"=> "Rua Teste", - "zip_code"=> "00000-000", - "city"=> "São Paulo", - "country"=> "Brasil", - "state"=> "SP", - "number"=> "0", - "complement"=> "A" - ], - "delivery_promise"=> "", - "drop_shipping"=> "", - "local_pickup"=> "", - "express_shipment"=> "", - "safety"=> "", - "shipment_safety"=> false, - "withdrawn"=> false, - "tracking"=> [ - "code"=> "", - "status"=> "" - ], - "shipment_amount"=> 0 - ] - ] - ]; - - const COMPLETE_PAYMENT_WITH_3DS = [ - "binary_mode" => false, - "external_reference" => "WC-105", - "notification_url" => "https://httpbin.org/post", - "statement_descriptor" => "TESTSTORE", - "transaction_amount" => 210, - "installments" => 3, - "three_d_secure_mode" => "optional", - "description" => "Flying Ninja x 1", - "payment_method_id" => "master", - "date_of_expiration" => "2022-09-20T22:13:32.000+0000", - "point_of_interaction" => [ - "type" => "OPENPLATFORM" - ], - "payer" => [ - "email" => "test_user_15543629@testuser.com", - "first_name" => "Test", - "last_name" => "Customer", - "identification" => [ - "type" => "CPF", - "number" => "376.624.684-45" - ], - "address" => [ - "street_name" => "Address - BR - BR", - "street_number" => "123", - "neighborhood" => "City", - "city" => "City", - "federal_unit" => "SP", - "zip_code" => "00000-000" - ] - ], - "additional_info" => [ - "ip_address"=> "191.191.191.0", - "referral_url"=> "www.sellertest.com", - "drop_shipping"=> true, - "delivery_promise"=> "2022-09-22", - "contrated_plan"=> "premium", - "items"=> [ - [ - "category_id"=> "others", - "description"=> "bola", - "id"=> "123", - "picture_url"=> "https=>//", - "quantity"=> "1", - "title"=> "Bola de futebol", - "unit_price"=> "20" - ] - ], - "payer"=> [ - "address"=> [ - "street_name"=> "Rua Teste", - "zip_code"=> "00000-000", - "city"=> "São Paulo", - "country"=> "Brasil", - "state"=> "SP", - "number"=> "0", - "complement"=> "A" - ], - "first_name"=> "EncryptedName", - "last_name"=> "Bar", - "phone"=> [ - "area_code"=> "11", - "number"=> "999999999" - ], - "mobile"=> [ - "area_code"=> 11, - "number"=> "" - ], - "identification"=> [ - "type"=> "", - "number"=> 0 - ], - "registration_date"=> "2023-04-11T19=>18=>38.486Z", - "registered_user"=> false, - "device_id"=> "", - "platform_email"=> "", - "register_updated_at"=> "2023-04-11T19=>18=>38.486Z", - "user_email"=> "test@test.com", - "authentication_type"=> "", - "last_purchase"=> "" - ], - "seller"=> [ - "id"=> "", - "registration_date"=> "2023-04-11T19=>18=>38.486Z", - "business_type"=> "dropshipping", - "identification"=> [ - "type"=> "", - "number"=> "0", - ], - "status"=> "active", - "store_id"=> "123", - "user_platform_mail"=> "gmail", - "email"=> "test@test.com", - "phone"=> [ - "area_code"=> "11", - "number"=> "" - ], - "collector"=> "123", - "website"=> "https//", - "platform_url"=> "https//", - "referral_url"=> "", - "register_updated_at"=> "2023-04-11T19=>18=>38.486Z", - "document"=> "123", - "name"=> "Foo", - "hired_plan"=> "plan", - "address"=> [ - "zip_code"=> "00000-000", - "street_name"=> "Rua Teste", - "city"=> "São Paulo", - "country"=> "Brasil", - "state"=> "SP", - "number"=> "0", - "complement"=> "A" - ] - ], - "shipments"=> [ - "receiver_address"=> [ - "apartment"=> "45", - "floor"=> "4", - "street_name"=> "Rua Teste", - "zip_code"=> "00000-000", - "city"=> "São Paulo", - "country"=> "Brasil", - "state"=> "SP", - "number"=> "0", - "complement"=> "A" - ], - "delivery_promise"=> "", - "drop_shipping"=> "", - "local_pickup"=> "", - "express_shipment"=> "", - "safety"=> "", - "shipment_safety"=> false, - "withdrawn"=> false, - "tracking"=> [ - "code"=> "", - "status"=> "" - ], - "shipment_amount"=> 0 - ] - ] - ]; -} diff --git a/packages/sdk/tests/unit/Mock/PreferenceMock.php b/packages/sdk/tests/unit/Mock/PreferenceMock.php deleted file mode 100644 index 1bb8c4c20..000000000 --- a/packages/sdk/tests/unit/Mock/PreferenceMock.php +++ /dev/null @@ -1,185 +0,0 @@ - "approved", - "back_urls" => [ - "failure" => "http://www.myapp.com/carrinho/?cancel_order=true&order=wc_order&order_id=XX&redirect&_wpnonce=XX", - "pending" => "http://www.myapp.com/finalizar-compra/order-received/XX/?key=wc_order", - "success" => "http://www.myapp.com/finalizar-compra/order-received/XX/?key=wc_order" - ], - "binary_mode" => false, - "differential_pricing" => [ - "id" => "" - ], - "external_reference" => "WC-XX", - "items" => [ - [ - "title" => "Dummy Title", - "description" => "Dummy description", - "picture_url" => "http://www.myapp.com/myimage.jpg", - "category_id" => "car_electronics", - "quantity" => 1, - "currency_id" => "U$", - "unit_price" => 10 - ] - ], - "notification_url" => "https://httpbin.org/post", - "payer" => [ - "address" => [ - "street_name" => "Address - BR - BR", - "street_number" => "123", - "zip_code" => "00000-000" - ], - "email" => "email@testuser.com", - "identification" => [ - "number" => "CPF", - "type" => "376.624.684-45" - ], - "name" => "Amadeu", - "phone" => [ - "area_code" => "", - "number" => "99999999999" - ], - "surname" => "Fontes" - ], - "payment_methods" => [ - "excluded_payment_methods" => [ - [] - ], - "excluded_payment_types" => [ - [] - ], - "installments" => 1 - ], - "shipments" => [ - "free_methods" => [ - [] - ], - "receiver_address" => [] - ], - "statement_descriptor" => "Mercado Pago", - "tracks" => [ - [ - "type" => "google_ad" - ] - ], - "additional_info" => [ - "ip_address"=> "191.191.191.0", - "referral_url"=> "www.sellertest.com", - "drop_shipping"=> true, - "delivery_promise"=> "2022-09-22", - "contrated_plan"=> "premium", - "items"=> [ - [ - "category_id"=> "others", - "description"=> "bola", - "id"=> "123", - "picture_url"=> "https=>//", - "quantity"=> "1", - "title"=> "Bola de futebol", - "unit_price"=> "20" - ] - ], - "payer"=> [ - "address"=> [ - "street_name"=> "Rua Teste", - "zip_code"=> "00000-000", - "city"=> "São Paulo", - "country"=> "Brasil", - "state"=> "SP", - "number"=> "0", - "complement"=> "A" - ], - "first_name"=> "EncryptedName", - "last_name"=> "Bar", - "phone"=> [ - "area_code"=> "11", - "number"=> "999999999" - ], - "mobile"=> [ - "area_code"=> 11, - "number"=> "" - ], - "identification"=> [ - "type"=> "", - "number"=> 0 - ], - "registration_date"=> "2023-04-11T19=>18=>38.486Z", - "registered_user"=> false, - "device_id"=> "", - "platform_email"=> "", - "register_updated_at"=> "2023-04-11T19=>18=>38.486Z", - "user_email"=> "test@test.com", - "authentication_type"=> "", - "last_purchase"=> "" - ], - "seller"=> [ - "id"=> "", - "registration_date"=> "2023-04-11T19=>18=>38.486Z", - "business_type"=> "dropshipping", - "identification"=> [ - "type"=> "", - "number"=> "0", - ], - "status"=> "active", - "store_id"=> "123", - "user_platform_mail"=> "gmail", - "email"=> "test@test.com", - "phone"=> [ - "area_code"=> "11", - "number"=> "" - ], - "collector"=> "123", - "website"=> "https//", - "platform_url"=> "https//", - "referral_url"=> "", - "register_updated_at"=> "2023-04-11T19=>18=>38.486Z", - "document"=> "123", - "name"=> "Foo", - "hired_plan"=> "plan", - "address"=> [ - "zip_code"=> "00000-000", - "street_name"=> "Rua Teste", - "city"=> "São Paulo", - "country"=> "Brasil", - "state"=> "SP", - "number"=> "0", - "complement"=> "A" - ] - ], - "shipments"=> [ - "receiver_address"=> [ - "apartment"=> "45", - "floor"=> "4", - "street_name"=> "Rua Teste", - "zip_code"=> "00000-000", - "city"=> "São Paulo", - "country"=> "Brasil", - "state"=> "SP", - "number"=> "0", - "complement"=> "A" - ], - "delivery_promise"=> "", - "drop_shipping"=> "", - "local_pickup"=> "", - "express_shipment"=> "", - "safety"=> "", - "shipment_safety"=> false, - "withdrawn"=> false, - "tracking"=> [ - "code"=> "", - "status"=> "" - ], - "shipment_amount"=> 0 - ] - ] - ]; -} diff --git a/packages/sdk/tests/unit/Mock/RegisterErrorLogMock.php b/packages/sdk/tests/unit/Mock/RegisterErrorLogMock.php deleted file mode 100644 index b7a51902f..000000000 --- a/packages/sdk/tests/unit/Mock/RegisterErrorLogMock.php +++ /dev/null @@ -1,26 +0,0 @@ - "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 deleted file mode 100644 index 9472f53c3..000000000 --- a/packages/sdk/tests/unit/Mock/SellerFunnelBaseMock.php +++ /dev/null @@ -1,30 +0,0 @@ - "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 deleted file mode 100644 index c27a67fe2..000000000 --- a/packages/sdk/tests/unit/SdkTest.php +++ /dev/null @@ -1,145 +0,0 @@ -configMock = $this->getMockBuilder(Config::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->requesterMock = $this->getMockBuilder(RequesterInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->clientMock = $this->getMockBuilder(HttpClientInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->managerMock = $this->getMockBuilder(Manager::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->sdk = new Sdk('access_token', 'platform_id', 'product_id', 'integrator_id', 'publicKey'); - } - - function testGetPreferenceSuccess() - { - $actual = $this->sdk->getPreferenceInstance(); - - $this->assertInstanceOf('MercadoPago\PP\Sdk\Entity\Preference\Preference', $actual); - } - - function testGetNotificationSuccess() - { - $actual = $this->sdk->getNotificationInstance(); - - $this->assertInstanceOf('MercadoPago\PP\Sdk\Entity\Notification\Notification', $actual); - } - - function testGetPaymentSuccess() - { - $actual = $this->sdk->getPaymentInstance(); - - $this->assertInstanceOf('MercadoPago\PP\Sdk\Entity\Payment\Payment', $actual); - } - - function testGetPaymentV2Success() - { - $actual = $this->sdk->getPaymentV2Instance(); - - $this->assertInstanceOf('MercadoPago\PP\Sdk\Entity\Payment\PaymentV2', $actual); - } - - function testGetPaymentV21Success() - { - $actual = $this->sdk->getPaymentV21Instance(); - - $this->assertInstanceOf('MercadoPago\PP\Sdk\Entity\Payment\PaymentV21', $actual); - } - - function testGetMultipaymentSuccess() - { - $actual = $this->sdk->getMultipaymentInstance(); - - $this->assertInstanceOf('MercadoPago\PP\Sdk\Entity\Payment\Multipayment', $actual); - } - - function testGetMultipaymentV2Success() - { - $actual = $this->sdk->getMultipaymentV2Instance(); - - $this->assertInstanceOf('MercadoPago\PP\Sdk\Entity\Payment\MultipaymentV2', $actual); - } - - function testGetMultipaymentV21Success() - { - $actual = $this->sdk->getMultipaymentV21Instance(); - - $this->assertInstanceOf('MercadoPago\PP\Sdk\Entity\Payment\MultipaymentV21', $actual); - } - - function testGetDatadogEventSuccess() - { - $actual = $this->sdk->getDatadogEventInstance(); - - $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); - } -}