Añadiendo los plugins base payments y cms_api
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: composer
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: daily
|
||||
time: "09:00"
|
||||
timezone: Europe/Madrid
|
||||
open-pull-requests-limit: 10
|
||||
commit-message:
|
||||
prefix: "[Dep][compose] "
|
||||
#ignore:
|
||||
#- dependency-name: "django"
|
||||
# For django, ignore all updates for version 3.2.x and 4.x
|
||||
#versions: [ "3.2", "4" ]
|
||||
labels:
|
||||
- dependabot
|
||||
reviewers:
|
||||
- "aplazame/squad_plugins-reviewers"
|
||||
162
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/aplazame/aplazame-api-sdk/CHANGELOG.md
vendored
Normal file
162
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/aplazame/aplazame-api-sdk/CHANGELOG.md
vendored
Normal file
@@ -0,0 +1,162 @@
|
||||
# Change Log
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## [Unreleased]
|
||||
### Added
|
||||
|
||||
### Changed
|
||||
|
||||
### Deprecated
|
||||
|
||||
### Removed
|
||||
|
||||
### Fixed
|
||||
|
||||
### Security
|
||||
|
||||
## [0.3.6] - 2023-11-28
|
||||
### Added
|
||||
- PHP 8.1 compatibility.
|
||||
|
||||
### Changed
|
||||
|
||||
### Deprecated
|
||||
|
||||
### Removed
|
||||
|
||||
### Fixed
|
||||
|
||||
## [0.3.5] - 2023-10-11
|
||||
### Added
|
||||
|
||||
### Changed
|
||||
- API version at checkout header.
|
||||
|
||||
### Deprecated
|
||||
|
||||
### Removed
|
||||
|
||||
### Fixed
|
||||
|
||||
## [0.3.4] - 2021-06-22
|
||||
### Added
|
||||
- English API documentation links.
|
||||
|
||||
### Changed
|
||||
|
||||
### Deprecated
|
||||
|
||||
### Removed
|
||||
|
||||
### Fixed
|
||||
|
||||
## [0.3.3] - 2021-06-22
|
||||
### Added
|
||||
|
||||
### Changed
|
||||
- URL redirects.
|
||||
|
||||
### Deprecated
|
||||
|
||||
### Removed
|
||||
|
||||
### Fixed
|
||||
- Documentation links.
|
||||
|
||||
## [0.3.2] - 2020-10-16
|
||||
### Added
|
||||
|
||||
### Changed
|
||||
- [Examples] Checkout creation real examples changed for non-real ones
|
||||
|
||||
### Deprecated
|
||||
|
||||
### Removed
|
||||
|
||||
### Fixed
|
||||
|
||||
## [0.3.1] - 2019-10-01
|
||||
### Added
|
||||
|
||||
### Changed
|
||||
|
||||
### Deprecated
|
||||
|
||||
### Removed
|
||||
|
||||
### Fixed
|
||||
- [Api] Request now allow to provide "objects" as payload
|
||||
|
||||
## [0.3.0] - 2019-08-29
|
||||
### Added
|
||||
- Added examples (/examples) for the server to server checkout integration
|
||||
|
||||
### Changed
|
||||
- Use native PHP 5.5 JsonSerializable on Date and Decimal serializer
|
||||
|
||||
### Deprecated
|
||||
|
||||
### Removed
|
||||
- Drop support for PHP version lower than 5.6
|
||||
- Remove custom JsonSerializer in favor on builtin JsonSerializable interface
|
||||
|
||||
### Fixed
|
||||
|
||||
## [0.2.2] - 2017-11-22
|
||||
### Added
|
||||
|
||||
### Changed
|
||||
|
||||
### Deprecated
|
||||
|
||||
### Removed
|
||||
|
||||
### Fixed
|
||||
- [Serializer] Fix serialization of empty objects.
|
||||
|
||||
## [0.2.1] - 2016-11-23
|
||||
### Added
|
||||
|
||||
### Changed
|
||||
|
||||
### Deprecated
|
||||
|
||||
### Removed
|
||||
|
||||
### Fixed
|
||||
- [Api] path is appended twice to API base URI.
|
||||
|
||||
### Security
|
||||
|
||||
## [0.2.0] - 2016-11-23
|
||||
### Added
|
||||
- [Api] Add `getHttpStatusCode` to `ApiClientException` and `ApiServerException`. This method returns the response HTTP status code.
|
||||
- [Serializer] New component focused only in assist the conversion of PHP types to JSON compatible types.
|
||||
|
||||
### Changed
|
||||
- [BusinessModel] This component has been replaced by [Serializer]
|
||||
- [Api] Change in `ApiClientException` and `ApiServerException` constructor signature.
|
||||
|
||||
### Deprecated
|
||||
|
||||
### Removed
|
||||
- [BusinessModel] This component has been replaced by [Serializer]
|
||||
|
||||
### Fixed
|
||||
|
||||
### Security
|
||||
|
||||
## [0.1.0] - 2016-07-07
|
||||
### Added
|
||||
- API Client
|
||||
- Business models
|
||||
|
||||
[Unreleased]: https://github.com/aplazame/php-sdk/compare/v0.3.0...HEAD
|
||||
[0.3.0]: https://github.com/aplazame/php-sdk/compare/v0.2.2...v0.3.0
|
||||
[0.2.2]: https://github.com/aplazame/php-sdk/compare/v0.2.1...v0.2.2
|
||||
[0.2.1]: https://github.com/aplazame/php-sdk/compare/v0.2.0...v0.2.1
|
||||
[0.2.0]: https://github.com/aplazame/php-sdk/compare/v0.1.0...v0.2.0
|
||||
[0.1.0]: https://github.com/aplazame/php-sdk/commit/cd32febb1dfb0afd3a4916204a2efd07a60a4b5f
|
||||
19
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/aplazame/aplazame-api-sdk/CODEOWNERS
vendored
Normal file
19
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/aplazame/aplazame-api-sdk/CODEOWNERS
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
# This is a comment.
|
||||
# Each line is a file pattern followed by one or more owners.
|
||||
|
||||
# These owners will be the default owners for everything in
|
||||
# the repo. Unless a later match takes precedence,
|
||||
# review when someone opens a pull request.
|
||||
# owner(s) will be requested for a review.
|
||||
Jenkinsfile @aplazame/squad_devops-reviewers
|
||||
DockerFile @aplazame/squad_devops-reviewers
|
||||
CODEOWNERS @aplazame/squad_devops-reviewers
|
||||
jenkins/ @aplazame/squad_devops-reviewers
|
||||
docker/DockerFile @aplazame/squad_devops-reviewers
|
||||
Makefile @aplazame/squad_devops-reviewers
|
||||
makefile @aplazame/squad_devops-reviewers
|
||||
node.yaml @aplazame/squad_devops-reviewers
|
||||
deploy.yaml @aplazame/squad_devops-reviewers
|
||||
build_dependencies.yaml @aplazame/squad_devops-reviewers
|
||||
build.yaml @aplazame/squad_devops-reviewers
|
||||
Dockerfile @aplazame/squad_devops-reviewers
|
||||
29
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/aplazame/aplazame-api-sdk/LICENSE
vendored
Normal file
29
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/aplazame/aplazame-api-sdk/LICENSE
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2023, Aplazame
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
31
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/aplazame/aplazame-api-sdk/README.md
vendored
Normal file
31
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/aplazame/aplazame-api-sdk/README.md
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
# Aplazame PHP SDK
|
||||
|
||||
[](https://aplazame.com)
|
||||
|
||||
[Aplazame](https://aplazame.com), a consumer credit company, offers a payment system that can be
|
||||
used by online buyers to receive funding for their purchases.
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
You can use [Composer](https://getcomposer.org):
|
||||
|
||||
```bash
|
||||
composer require aplazame/aplazame-api-sdk
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
|
||||
This SDK assists you to complete the steps from the integration guide https://aplazame.com/en/docs/api/
|
||||
|
||||
Explore the examples folder for to learn how to:
|
||||
1. Create an Aplazame's checkout [examples/step1_checkout_create.php](examples/step1_checkout_create.php)
|
||||
2. Start the checkout browser flow [examples/step2_checkout_start.php](examples/step2_checkout_start.php)
|
||||
3. Receive and confirm the payment statuses [examples/step3_checkout_confirm.php](examples/step3_checkout_confirm.php)
|
||||
|
||||
|
||||
## Documentation
|
||||
|
||||
Documentation is available at https://aplazame.com/en/docs/api/ or https://aplazame.com/integraciones/api/
|
||||
26
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/aplazame/aplazame-api-sdk/composer.json
vendored
Normal file
26
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/aplazame/aplazame-api-sdk/composer.json
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "aplazame/aplazame-api-sdk",
|
||||
"description": "Aplazame API SDK",
|
||||
"keywords": [
|
||||
"aplazame"
|
||||
],
|
||||
"license": "GPL-3.0",
|
||||
"require": {
|
||||
"php": ">= 5.6.0",
|
||||
"ext-json": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "1.11.*",
|
||||
"phpunit/phpunit": "*"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Aplazame\\": "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Aplazame\\": "test/"
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
@@ -0,0 +1,213 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file provides an example about how to complete the step 01 of Aplazame's
|
||||
* integration as described in:
|
||||
* - https://aplazame.com/en/docs/api/
|
||||
* - https://aplazame.com/integraciones/api/
|
||||
*
|
||||
* It contains three steps:
|
||||
*
|
||||
* 1. Create an Aplazame\Api\Client with your Aplazame API credentials
|
||||
* 2. Create the checkout payload.
|
||||
* 3. Send the payload to Aplazame and retrieve the generated ID by Aplazame.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Aplazame's private key.
|
||||
* You can find your keys on your Aplazame's control panel (https://vendors.aplazame.com/)
|
||||
*/
|
||||
$privateKey = '<aplazame private API key>';
|
||||
|
||||
/*
|
||||
* Enable test mode (`Aplazame\Api\Client::ENVIRONMENT_SANDBOX`) or
|
||||
* production mode (`Aplazame\Api\Client::ENVIRONMENT_PRODUCTION`)
|
||||
*/
|
||||
$environment = Aplazame\Api\Client::ENVIRONMENT_SANDBOX;
|
||||
|
||||
/*
|
||||
* Aplazame Client setup
|
||||
*/
|
||||
$apiBaseUri = 'https://api.aplazame.com';
|
||||
$aplazameApiClient = new Aplazame\Api\Client($apiBaseUri, $environment, $privateKey);
|
||||
|
||||
|
||||
/**
|
||||
* Create checkout payload as described in https://aplazame.com/en/docs/api/checkout-creation/ or https://aplazame.com/integraciones/api/checkout-creation/
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
function createCheckoutPayload() {
|
||||
/*
|
||||
* Merchant model
|
||||
*/
|
||||
$merchant = new stdClass();
|
||||
$merchant->notification_url = 'https://merchant.com/order/step3_checkout_confirm.php'; // url where you will receive Aplazame webhook events as described in https://aplazame.com/en/docs/api/checkout-confirmation/ or https://aplazame.com/integraciones/api/checkout-confirmation/
|
||||
$merchant->success_url = "/success"; // url that the customer is sent to after confirming their order.
|
||||
$merchant->pending_url = "/pending"; // url that the customer is sent to if the order status is pending.
|
||||
$merchant->error_url = "/error"; // url that the customer is sent to if there is an error in the checkout.
|
||||
$merchant->dismiss_url = "/checkout"; // url that the customer is sent to if the customer chooses to back to the e-commerce, by default is /.
|
||||
$merchant->ko_url = "/ko"; // url that the customer is sent to if Aplazame refuses the order.
|
||||
|
||||
/*
|
||||
* Article model
|
||||
*/
|
||||
$article = new stdClass();
|
||||
$article->id = '89793238462643383279'; // The article ID.
|
||||
$article->name = 'Reloj en oro blanco de 18 quilates y diamantes'; // Article name.
|
||||
$article->url = 'http://shop.example.com/product.html'; // Article url.
|
||||
$article->image_url = 'http://shop.example.com/product_image.png'; // Article image url.
|
||||
$article->quantity = 2; // Article quantity.
|
||||
$article->price = Aplazame\Serializer\Decimal::fromFloat(4020.00); // Article price (tax is not included). (4,020.00 €)
|
||||
$article->description = 'Movimiento de cuarzo de alta precisión'; // Article description.
|
||||
$article->tax_rate = Aplazame\Serializer\Decimal::fromFloat(21.00); // Article tax rate. (21.00%)
|
||||
$article->discount = Aplazame\Serializer\Decimal::fromFloat(5.00); // The discount amount of the article. (5.00 €)
|
||||
|
||||
// ... rest of articles in the shopping cart.
|
||||
|
||||
/*
|
||||
* Articles collection
|
||||
*/
|
||||
$articles = array( $article, );
|
||||
|
||||
/*
|
||||
* Order model
|
||||
*/
|
||||
$order = new stdClass();
|
||||
$order->id = '28475648233786783165'; // Your order ID.
|
||||
$order->currency = 'EUR'; // Currency code of the order.
|
||||
$order->tax_rate = Aplazame\Serializer\Decimal::fromFloat(21.00); // Order tax rate. (21.00%)
|
||||
$order->total_amount = Aplazame\Serializer\Decimal::fromFloat(4620.00); // Order total amount. (4,620.00 €)
|
||||
$order->articles = $articles; // Articles in cart.
|
||||
$order->discount = Aplazame\Serializer\Decimal::fromFloat(160.00); // The discount amount of the order. (160.00 €)
|
||||
$order->cart_discount = Aplazame\Serializer\Decimal::fromFloat(0.50); // The discount amount of the cart. (0.50 €)
|
||||
|
||||
/*
|
||||
* Customer address model
|
||||
*/
|
||||
$customerAddress = new stdClass();
|
||||
$customerAddress->first_name = 'John'; // Address first name.
|
||||
$customerAddress->last_name = 'Coltrane'; // Address last name.
|
||||
$customerAddress->street = 'Plaza del Valle Boreal nº10'; // Address street.
|
||||
$customerAddress->city = 'Madrid'; // Address city.
|
||||
$customerAddress->state = 'Madrid'; // Address state.
|
||||
$customerAddress->country = 'ES'; // Address country code.
|
||||
$customerAddress->postcode = '28080'; // Address postcode.
|
||||
$customerAddress->phone = '601234567'; // Address phone number.
|
||||
$customerAddress->address_addition = 'Cerca de la plaza Pontífice Sulyvahn'; // Address addition.
|
||||
|
||||
/*
|
||||
* Customer model
|
||||
*/
|
||||
$customer = new stdClass();
|
||||
$customer->id = '1618'; // Customer ID.
|
||||
$customer->email = 'customer@address.com'; // The customer email.
|
||||
$customer->type = 'e'; // Customer type, the choices are g:guest, n:new, e:existing.
|
||||
$customer->gender = 0; // Customer gender, the choices are 0: not known, 1: male, 2:female, 3: not applicable.
|
||||
$customer->first_name = 'John'; // Customer first name.
|
||||
$customer->last_name = 'Coltrane'; // Customer last name.
|
||||
$customer->birthday = Aplazame\Serializer\Date::fromDateTime(new DateTime('1990-08-21 13:56:45')); // Customer birthday.
|
||||
$customer->language = 'es'; // Customer language preferences.
|
||||
$customer->date_joined = Aplazame\Serializer\Date::fromDateTime(new DateTime('2014-08-21 13:56:45')); // A datetime designating when the customer account was created.
|
||||
$customer->last_login = Aplazame\Serializer\Date::fromDateTime(new DateTime('2020-08-27 19:57:56')); // A datetime of the customer last login.
|
||||
$customer->address = $customerAddress; // Customer address.
|
||||
|
||||
/*
|
||||
* Billing address model
|
||||
*/
|
||||
$billingAddress = new stdClass();
|
||||
$billingAddress->first_name = 'Bill'; // Billing first name.
|
||||
$billingAddress->last_name = 'Evans'; // Billing last name.
|
||||
$billingAddress->street = 'Calle Central Yharnam 92'; // Billing street.
|
||||
$billingAddress->city = 'Madrid'; // Billing city.
|
||||
$billingAddress->state = 'Madrid'; // Billing state.
|
||||
$billingAddress->country = 'ES'; // Billing country code.
|
||||
$billingAddress->postcode = '28080'; // Billing postcode.
|
||||
$billingAddress->phone = '601765432'; // Billing phone number.
|
||||
$billingAddress->address_addition = 'Cerca del Gran Puente'; // Billing address addition.
|
||||
|
||||
/*
|
||||
* Shipping info model
|
||||
*/
|
||||
$shippingInfo = new stdClass();
|
||||
$shippingInfo->first_name = 'Django'; // Shipping first name.
|
||||
$shippingInfo->last_name = 'Reinhard'; // Shipping last name.
|
||||
$shippingInfo->street = 'Plaza del Valle Boreal nº10'; // Shipping street.
|
||||
$shippingInfo->city = 'Madrid'; // Shipping city.
|
||||
$shippingInfo->state = 'Madrid'; // Shipping state.
|
||||
$shippingInfo->country = 'ES'; // Shipping country code.
|
||||
$shippingInfo->postcode = '28080'; // Shipping postcode.
|
||||
$shippingInfo->name = 'Planet Express'; // Shipping name.
|
||||
$shippingInfo->price = Aplazame\Serializer\Decimal::fromFloat(5.00); // Shipping price (tax is not included). (5.00 €)
|
||||
$shippingInfo->phone = '601234567'; // Shipping phone number.
|
||||
$shippingInfo->address_addition = 'Cerca de la plaza Pontífice Sulyvahn'; // Shipping address addition.
|
||||
$shippingInfo->tax_rate = Aplazame\Serializer\Decimal::fromFloat(21.00); // Shipping tax rate. (21.00%)
|
||||
$shippingInfo->discount = Aplazame\Serializer\Decimal::fromFloat(1.00); // The discount amount of the shipping. (1.00 €)
|
||||
|
||||
/*
|
||||
* Checkout model
|
||||
*/
|
||||
$checkout = new stdClass();
|
||||
$checkout->toc = true;
|
||||
$checkout->merchant = $merchant;
|
||||
$checkout->order = $order;
|
||||
$checkout->customer = $customer;
|
||||
$checkout->billing = $billingAddress;
|
||||
$checkout->shipping = $shippingInfo;
|
||||
|
||||
return $checkout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the checkout payload generated by createCheckoutPayload to Aplazame and returns the Aplazame Checkout ID
|
||||
*
|
||||
* @param \Aplazame\Api\Client $aplazameApiClient A configured client with the api key and environment
|
||||
* @param array|object $payload Checkout Parameters as described in https://aplazame.com/en/docs/api/checkout-creation/ or https://aplazame.com/integraciones/api/checkout-creation/
|
||||
*
|
||||
* @return string Aplazame checkout ID
|
||||
*
|
||||
* @throws \Aplazame\Api\ApiClientException Payload contains invalid data
|
||||
* @throws \Aplazame\Api\ApiServerException An error has occur on Aplazame's servers
|
||||
* @throws \Aplazame\Api\ApiCommunicationException A network error has occurred while sending the request or receiving the response.
|
||||
* @throws \Aplazame\Api\DeserializeException Deserialization exception (unusual to happen but it could)
|
||||
*/
|
||||
function createAplazameCheckout(Aplazame\Api\Client $aplazameApiClient, $payload)
|
||||
{
|
||||
try {
|
||||
return $aplazameApiClient->request('POST','/checkout', $payload, 3)['id'];
|
||||
} catch (Aplazame\Api\ApiCommunicationException $apiCommunicationException) {
|
||||
// A network error has occurred while sending the request or receiving the response.
|
||||
|
||||
// Retry
|
||||
throw $apiCommunicationException;
|
||||
} catch (Aplazame\Api\DeserializeException $deserializationException) {
|
||||
// Nobody knows when this happen, may an HTTP Proxy on our side or on your side started to return HTML responses with errors.
|
||||
|
||||
// Retry
|
||||
throw $deserializationException;
|
||||
} catch (Aplazame\Api\ApiServerException $apiServerException) {
|
||||
// Our server has crashed. We promise to fix it ASAP.
|
||||
|
||||
echo 'HTTP Status code', $apiServerException->getHttpStatusCode(), PHP_EOL;
|
||||
echo 'Error type', $apiServerException->getType(), PHP_EOL;
|
||||
echo 'Error message', $apiServerException->getMessage(), PHP_EOL;
|
||||
|
||||
$rawErrorWithErrorDetails = $apiServerException->getError();
|
||||
|
||||
throw $apiServerException;
|
||||
} catch (Aplazame\Api\ApiClientException $apiClientException) {
|
||||
// Your client has sent an invalid request. Please check your code.
|
||||
|
||||
echo 'HTTP Status code', $apiClientException->getHttpStatusCode(), PHP_EOL;
|
||||
echo 'Error type', $apiClientException->getType(), PHP_EOL;
|
||||
echo 'Error message', $apiClientException->getMessage(), PHP_EOL;
|
||||
|
||||
$rawErrorWithErrorDetails = $apiClientException->getError();
|
||||
|
||||
throw $apiClientException;
|
||||
}
|
||||
}
|
||||
|
||||
$aplazameCheckoutId = createAplazameCheckout($aplazameApiClient, createCheckoutPayload());
|
||||
|
||||
echo 'Aplazame Checkout ID: ', $aplazameCheckoutId;
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file provides an example about how to start Aplazame checkout
|
||||
*
|
||||
* NOTE: Contents of this file are displayed on customer browser. USE THE PUBLIC KEY (not the private key)
|
||||
*/
|
||||
|
||||
/*
|
||||
* Aplazame's PUBLIC key.
|
||||
* You can find your keys on your Aplazame's control panel (https://vendors.aplazame.com/)
|
||||
*/
|
||||
$publicKey = '<aplazame PUBLIC API key>';
|
||||
|
||||
/*
|
||||
* Enable test mode (`Aplazame\Api\Client::ENVIRONMENT_SANDBOX`) or
|
||||
* production mode (`Aplazame\Api\Client::ENVIRONMENT_PRODUCTION`)
|
||||
*/
|
||||
$environment = Aplazame\Api\Client::ENVIRONMENT_SANDBOX;
|
||||
|
||||
/*
|
||||
* Use the ID generated by Aplazame at step1
|
||||
*/
|
||||
$aplazameCheckoutId = '<checkout id from step1>'
|
||||
?>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<script
|
||||
src="https://aplazame.com/static/aplazame.js"
|
||||
data-aplazame="<?php echo $publicKey; ?>"
|
||||
data-sandbox="<?php echo ($environment === Aplazame\Api\Client::ENVIRONMENT_SANDBOX) ? 'true' : 'false'; ?>"
|
||||
></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>
|
||||
Aplazame checkout
|
||||
</h1>
|
||||
|
||||
<!-- This fragment is for to assist you about to debug issues. Don't deploy to production! -->
|
||||
<script>
|
||||
var display_error = function (event) {
|
||||
var error_container = document.getElementById("error_container");
|
||||
console.error(event);
|
||||
error_container.innerHTML = event.message
|
||||
};
|
||||
|
||||
window.addEventListener('error', display_error);
|
||||
</script>
|
||||
|
||||
<div id="error_container" style="color: red;"></div>
|
||||
<!-- End fragment -->
|
||||
|
||||
<script>
|
||||
aplazame.checkout("<?php echo $aplazameCheckoutId; ?>")
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file provides an example about how to complete the step 03 of Aplazame's integration as described in:
|
||||
* - https://aplazame.com/en/docs/api/
|
||||
* - https://aplazame.com/integraciones/api/
|
||||
*
|
||||
* This file is split in two main sections:
|
||||
*
|
||||
* A. Basic settings:
|
||||
*
|
||||
* - Aplazame's private key
|
||||
* - Test mode
|
||||
* - Failed callback
|
||||
* - Accepted callback
|
||||
* - Pending callback. Please read the notes of this callback and check if some scenario may apply to your integration.
|
||||
*
|
||||
* B. Aplazame's checkout checks and confirmation logic.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Aplazame's private key.
|
||||
* You can find your keys on your Aplazame's control panel (https://vendors.aplazame.com/)
|
||||
*/
|
||||
$privateKey = "<aplazame private API key>";
|
||||
|
||||
/*
|
||||
* Enable test mode (`Aplazame\Api\Client::ENVIRONMENT_SANDBOX`) or
|
||||
* production mode (`Aplazame\Api\Client::ENVIRONMENT_PRODUCTION`)
|
||||
*/
|
||||
$environment = Aplazame\Api\Client::ENVIRONMENT_SANDBOX;
|
||||
|
||||
/**
|
||||
* Aplazame's payment has been REJECTED by Aplazame.
|
||||
*
|
||||
* Apply here your own logic to reject the order and return cart items to the inventory stock.
|
||||
*
|
||||
* @param string $order_id This is the same value as you filled in `order.id` when the checkout was created.
|
||||
*
|
||||
* @return bool `true` is the regular value. You can return `false` if something strange has happen, anyway for Aplazame
|
||||
* the order is already declined.
|
||||
*/
|
||||
function setOrderPaymentStatusFailed($order_id)
|
||||
{
|
||||
throw new BadMethodCallException(
|
||||
'You have to customize this function with your own logic when the payment is declined'
|
||||
);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Aplazame's payment has been ACCEPTED by Aplazame but we need your system to confirm the order.
|
||||
*
|
||||
* Apply here your own logic to set the order as paid and then proceed with the delivery of the order items.
|
||||
*
|
||||
* @param string $order_id This is the same value as you filled in `order.id` when the checkout was created.
|
||||
*
|
||||
* @return bool `true` is the regular value. You can return `false` if you don't want to proceed with this order.
|
||||
*/
|
||||
function setOrderPaymentStatusAsPaid($order_id)
|
||||
{
|
||||
throw new BadMethodCallException(
|
||||
'You have to customize this function with your own logic when the payment is accepted'
|
||||
);
|
||||
|
||||
/*
|
||||
* Most shops always return "true" here but some scenarios may apply to your checkout process:
|
||||
*
|
||||
* - Cart item has been sold to a different customer.
|
||||
* - Any other undefined reason to reject this order.
|
||||
*
|
||||
* If any of these scenarios apply to your checkout process, then you should to return `false` here.
|
||||
*/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Aplazame's payment is PENDING.
|
||||
*
|
||||
* Apply here your own logic for to set the order as pending payment.
|
||||
*
|
||||
* This callback is called only for specific orders (not for every order). Regular callbacks (Failed and Accepted) will be
|
||||
* called once the pending state has been resolved.
|
||||
*
|
||||
* @param string $order_id This is the same value as you filled in `order.id` when the checkout was created.
|
||||
*
|
||||
* @return bool `true` is the default value. You can return `false` if you don't want to proceed with this order.
|
||||
*/
|
||||
function setOrderPaymentStatusAsPending($order_id)
|
||||
{
|
||||
/*
|
||||
* Most shops does not need to do nothing here but there are some scenarios may affect you:
|
||||
*
|
||||
* - Items in the order are saved from the stock (i.e. another customer could purchase the same item)
|
||||
* - You don't want to place on hold specific orders
|
||||
*
|
||||
* If any of these scenarios apply to your checkout process, then you have to return `false` here.
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* This section is a more specific Aplazame flow as described in https://aplazame.com/en/docs/api/checkout-confirmation/ or https://aplazame.com/integraciones/api/checkout-confirmation/
|
||||
*
|
||||
* Feel free to adjust to the specific requirements of your checkout process. The following snippet is provided as a quick start.
|
||||
*/
|
||||
function response($status)
|
||||
{
|
||||
header('Content-Type: application/json');
|
||||
|
||||
echo json_encode(array('status' => $status));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function confirm($payload, $sandbox)
|
||||
{
|
||||
if (!$payload) {
|
||||
return response('Payload is malformed');
|
||||
}
|
||||
if (!isset($payload['sandbox']) || $payload['sandbox'] !== $sandbox) {
|
||||
return response('"sandbox" not provided');
|
||||
}
|
||||
if (!isset($payload['mid'])) {
|
||||
return response('"mid" not provided');
|
||||
}
|
||||
$mid = $payload['mid'];
|
||||
|
||||
switch ($payload['status']) {
|
||||
case 'pending':
|
||||
switch ($payload['status_reason']) {
|
||||
case 'challenge_required':
|
||||
if (!setOrderPaymentStatusAsPending($mid)) {
|
||||
return response('ko');
|
||||
}
|
||||
break;
|
||||
case 'confirmation_required':
|
||||
if (!setOrderPaymentStatusAsPaid($mid)) {
|
||||
return response('ko');
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'ko':
|
||||
setOrderPaymentStatusFailed($mid);
|
||||
break;
|
||||
}
|
||||
|
||||
return response('ok');
|
||||
}
|
||||
|
||||
if ($_GET['access_token'] !== $privateKey) {
|
||||
return response(403);
|
||||
}
|
||||
|
||||
confirm(
|
||||
json_decode(file_get_contents('php://input'), true),
|
||||
$environment === Aplazame\Api\Client::ENVIRONMENT_SANDBOX
|
||||
);
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace Aplazame\Api;
|
||||
|
||||
use Aplazame\Http\ResponseInterface;
|
||||
use LogicException;
|
||||
|
||||
/**
|
||||
* Exception thrown for HTTP 4xx client errors.
|
||||
*/
|
||||
class ApiClientException extends LogicException implements AplazameExceptionInterface
|
||||
{
|
||||
/**
|
||||
* @param ResponseInterface $response
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function fromResponse(ResponseInterface $response)
|
||||
{
|
||||
$responseBody = (string) $response->getBody();
|
||||
if (empty($responseBody)) {
|
||||
return new self($response->getStatusCode(), $response->getReasonPhrase());
|
||||
}
|
||||
|
||||
$decodedBody = json_decode($responseBody, true);
|
||||
if (!isset($decodedBody['error'])) {
|
||||
return new self($response->getStatusCode(), $response->getReasonPhrase());
|
||||
}
|
||||
|
||||
$error = $decodedBody['error'];
|
||||
|
||||
return new self($response->getStatusCode(), $error['message'], $error['type'], $error);
|
||||
}
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $error;
|
||||
|
||||
/**
|
||||
* @param string $statusCode
|
||||
* @param string $message
|
||||
* @param string $type
|
||||
* @param array $error
|
||||
*/
|
||||
public function __construct($statusCode, $message, $type = '', array $error = array())
|
||||
{
|
||||
parent::__construct($message, $statusCode);
|
||||
|
||||
$this->type = $type;
|
||||
$this->error = $error;
|
||||
}
|
||||
|
||||
public function getHttpStatusCode()
|
||||
{
|
||||
return $this->getCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getError()
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Aplazame\Api;
|
||||
|
||||
use Exception;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Exception thrown when there is communication possible with the API.
|
||||
*/
|
||||
class ApiCommunicationException extends RuntimeException implements AplazameExceptionInterface
|
||||
{
|
||||
/**
|
||||
* @param Exception $exception
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function fromException(Exception $exception)
|
||||
{
|
||||
return new self($exception->getMessage(), $exception->getCode(), $exception);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace Aplazame\Api;
|
||||
|
||||
use Aplazame\Http\Request;
|
||||
use DomainException;
|
||||
|
||||
class ApiRequest extends Request
|
||||
{
|
||||
const SDK_VERSION = '0.3.6';
|
||||
const FORMAT_JSON = 'json';
|
||||
|
||||
/**
|
||||
* @param string $accessToken
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function createAuthorizationHeader($accessToken)
|
||||
{
|
||||
return 'Bearer ' . $accessToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $useSandbox
|
||||
* @param int $apiVersion
|
||||
* @param string $format
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function createAcceptHeader($useSandbox, $apiVersion, $format)
|
||||
{
|
||||
$header = 'application/vnd.aplazame';
|
||||
if ($useSandbox) {
|
||||
$header .= '.sandbox';
|
||||
}
|
||||
$header .= sprintf('.v%d+%s', $apiVersion, $format);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $useSandbox
|
||||
* @param int $apiVersion The API version of the request.
|
||||
* @param string $accessToken The Access Token of the request (Public API key or Private API key)
|
||||
* @param string $method The HTTP method of the request.
|
||||
* @param string $uri The URI of the request.
|
||||
* @param mixed $data The data of the request.
|
||||
*/
|
||||
public function __construct(
|
||||
$useSandbox,
|
||||
$apiVersion,
|
||||
$accessToken,
|
||||
$method,
|
||||
$uri,
|
||||
$data = null
|
||||
) {
|
||||
$headers = array(
|
||||
'Accept' => array(self::createAcceptHeader($useSandbox, $apiVersion, self::FORMAT_JSON)),
|
||||
'Authorization' => array(self::createAuthorizationHeader($accessToken)),
|
||||
'User-Agent' => array(
|
||||
'Aplazame/' . self::SDK_VERSION,
|
||||
'PHP/' . PHP_VERSION,
|
||||
),
|
||||
);
|
||||
|
||||
if ($data && !is_string($data)) {
|
||||
$data = json_encode($data);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
throw new DomainException(json_last_error_msg(), json_last_error());
|
||||
}
|
||||
$headers['Content-Type'] = array('application/json');
|
||||
}
|
||||
|
||||
parent::__construct($method, $uri, $headers, $data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace Aplazame\Api;
|
||||
|
||||
use Aplazame\Http\ResponseInterface;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Exception thrown for HTTP 5xx client errors.
|
||||
*/
|
||||
class ApiServerException extends RuntimeException implements AplazameExceptionInterface
|
||||
{
|
||||
/**
|
||||
* @param ResponseInterface $response
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function fromResponse(ResponseInterface $response)
|
||||
{
|
||||
$responseBody = (string) $response->getBody();
|
||||
if (empty($responseBody)) {
|
||||
return new self($response->getStatusCode(), $response->getReasonPhrase());
|
||||
}
|
||||
|
||||
$decodedBody = json_decode($responseBody, true);
|
||||
if (!isset($decodedBody['error'])) {
|
||||
return new self($response->getStatusCode(), $response->getReasonPhrase());
|
||||
}
|
||||
|
||||
$error = $decodedBody['error'];
|
||||
|
||||
return new self($response->getStatusCode(), $error['message'], $error['type'], $error);
|
||||
}
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $error;
|
||||
|
||||
/**
|
||||
* @param string $statusCode
|
||||
* @param string $message
|
||||
* @param string $type
|
||||
* @param array $error
|
||||
*/
|
||||
public function __construct($statusCode, $message, $type = '', array $error = array())
|
||||
{
|
||||
parent::__construct($message, $statusCode);
|
||||
|
||||
$this->type = $type;
|
||||
$this->error = $error;
|
||||
}
|
||||
|
||||
public function getHttpStatusCode()
|
||||
{
|
||||
return $this->getCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getError()
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Aplazame\Api;
|
||||
|
||||
/**
|
||||
* Common interface for custom exceptions.
|
||||
*/
|
||||
interface AplazameExceptionInterface
|
||||
{
|
||||
}
|
||||
204
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/aplazame/aplazame-api-sdk/src/Api/Client.php
vendored
Normal file
204
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/aplazame/aplazame-api-sdk/src/Api/Client.php
vendored
Normal file
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
|
||||
namespace Aplazame\Api;
|
||||
|
||||
use Aplazame\Http\ClientInterface;
|
||||
use Aplazame\Http\CurlClient;
|
||||
use RuntimeException;
|
||||
|
||||
class Client
|
||||
{
|
||||
const ENVIRONMENT_PRODUCTION = 'production';
|
||||
const ENVIRONMENT_SANDBOX = 'sandbox';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $apiBaseUri;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $useSandbox;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $accessToken;
|
||||
|
||||
/**
|
||||
* @var ClientInterface
|
||||
*/
|
||||
private $httpClient;
|
||||
|
||||
/**
|
||||
* @param string $apiBaseUri The API base URI.
|
||||
* @param string $environment Destination of the request.
|
||||
* @param string $accessToken The Access Token of the request (Public API key or Private API key)
|
||||
* @param ClientInterface|null $httpClient
|
||||
*/
|
||||
public function __construct(
|
||||
$apiBaseUri,
|
||||
$environment,
|
||||
$accessToken,
|
||||
ClientInterface $httpClient = null
|
||||
) {
|
||||
$this->apiBaseUri = $apiBaseUri;
|
||||
$this->useSandbox = ($environment === self::ENVIRONMENT_SANDBOX) ? true : false;
|
||||
$this->accessToken = $accessToken;
|
||||
$this->httpClient = $httpClient ? $httpClient : new CurlClient();
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a DELETE request.
|
||||
*
|
||||
* @param string $path The path of the request.
|
||||
*
|
||||
* @return array The data of the response.
|
||||
*
|
||||
* @throws ApiCommunicationException if an I/O error occurs.
|
||||
* @throws DeserializeException if response cannot be deserialized.
|
||||
* @throws ApiServerException if server was not able to respond.
|
||||
* @throws ApiClientException if request is invalid.
|
||||
*/
|
||||
public function delete($path)
|
||||
{
|
||||
return $this->request('DELETE', $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a GET request.
|
||||
*
|
||||
* @param string $path The path of the request.
|
||||
* @param array $query The filters of the request.
|
||||
*
|
||||
* @return array The data of the response.
|
||||
*
|
||||
* @throws ApiCommunicationException if an I/O error occurs.
|
||||
* @throws DeserializeException if response cannot be deserialized.
|
||||
* @throws ApiServerException if server was not able to respond.
|
||||
* @throws ApiClientException if request is invalid.
|
||||
*/
|
||||
public function get($path, array $query = array())
|
||||
{
|
||||
if (!empty($query)) {
|
||||
$query = http_build_query($query);
|
||||
$path .= '?' . $query;
|
||||
}
|
||||
|
||||
return $this->request('GET', $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a POST request.
|
||||
*
|
||||
* @param string $path The path of the request.
|
||||
* @param array|object $data The data of the request.
|
||||
*
|
||||
* @return array The data of the response.
|
||||
*
|
||||
* @throws ApiCommunicationException if an I/O error occurs.
|
||||
* @throws DeserializeException if response cannot be deserialized.
|
||||
* @throws ApiServerException if server was not able to respond.
|
||||
* @throws ApiClientException if request is invalid.
|
||||
*/
|
||||
public function patch($path, $data)
|
||||
{
|
||||
return $this->request('PATCH', $path, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a POST request.
|
||||
*
|
||||
* @param string $path The path of the request.
|
||||
* @param array|object $data The data of the request.
|
||||
*
|
||||
* @return array The data of the response.
|
||||
*
|
||||
* @throws ApiCommunicationException if an I/O error occurs.
|
||||
* @throws DeserializeException if response cannot be deserialized.
|
||||
* @throws ApiServerException if an I/O error occurs.
|
||||
* @throws ApiClientException if request is invalid.
|
||||
*/
|
||||
public function post($path, $data)
|
||||
{
|
||||
return $this->request('POST', $path, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a PUT request.
|
||||
*
|
||||
* @param string $path The path of the request.
|
||||
* @param array|object $data The data of the request.
|
||||
*
|
||||
* @return array The data of the response.
|
||||
*
|
||||
* @throws ApiCommunicationException if an I/O error occurs.
|
||||
* @throws DeserializeException if response cannot be deserialized.
|
||||
* @throws ApiServerException if server was not able to respond.
|
||||
* @throws ApiClientException if request is invalid.
|
||||
*/
|
||||
public function put($path, $data)
|
||||
{
|
||||
return $this->request('PUT', $path, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $method The HTTP method of the request.
|
||||
* @param string $path The path of the request.
|
||||
* @param array|object|null $data The data of the request.
|
||||
* @param int $apiVersion The API version of the request.
|
||||
*
|
||||
* @return array The data of the response.
|
||||
*
|
||||
* @throws ApiCommunicationException if an I/O error occurs.
|
||||
* @throws DeserializeException if response cannot be deserialized.
|
||||
* @throws ApiServerException if server was not able to respond.
|
||||
* @throws ApiClientException if request is invalid.
|
||||
*/
|
||||
public function request($method, $path, $data = null, $apiVersion = 1)
|
||||
{
|
||||
$uri = $this->apiBaseUri . '/' . ltrim($path, '/');
|
||||
|
||||
$request = new ApiRequest($this->useSandbox, $apiVersion, $this->accessToken, $method, $uri, $data);
|
||||
try {
|
||||
$response = $this->httpClient->send($request);
|
||||
} catch (RuntimeException $e) {
|
||||
throw ApiCommunicationException::fromException($e);
|
||||
}
|
||||
|
||||
if ($response->getStatusCode() >= 500) {
|
||||
throw ApiServerException::fromResponse($response);
|
||||
}
|
||||
|
||||
if ($response->getStatusCode() >= 400) {
|
||||
throw ApiClientException::fromResponse($response);
|
||||
}
|
||||
|
||||
$payload = $this->decodeResponseBody((string) $response->getBody());
|
||||
|
||||
return $payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $responseBody The HTTP response body.
|
||||
*
|
||||
* @return array Decoded payload.
|
||||
*
|
||||
* @throws DeserializeException if response cannot be deserialized.
|
||||
*/
|
||||
protected function decodeResponseBody($responseBody)
|
||||
{
|
||||
// Response body is empty for HTTP 204 and 304 status code.
|
||||
if (empty($responseBody)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$responseBody = json_decode($responseBody, true);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
throw new DeserializeException('Unable to deserialize JSON data: ' . json_last_error_msg(), json_last_error());
|
||||
}
|
||||
|
||||
return $responseBody;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Aplazame\Api;
|
||||
|
||||
use UnexpectedValueException;
|
||||
|
||||
/**
|
||||
* This exception is thrown when the data cannot be deserialized/unmarshalled.
|
||||
*/
|
||||
class DeserializeException extends UnexpectedValueException implements AplazameExceptionInterface
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Aplazame\Http;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
interface ClientInterface
|
||||
{
|
||||
/**
|
||||
* @param RequestInterface $request
|
||||
*
|
||||
* @return ResponseInterface
|
||||
*
|
||||
* @throws RuntimeException If requests cannot be performed due network issues.
|
||||
*/
|
||||
public function send(RequestInterface $request);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace Aplazame\Http;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class CurlClient implements ClientInterface
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
if (!function_exists('curl_init')) {
|
||||
throw new \LogicException('cURL extension is not loaded');
|
||||
}
|
||||
}
|
||||
|
||||
public function send(RequestInterface $request)
|
||||
{
|
||||
$rawHeaders = array();
|
||||
foreach ($request->getHeaders() as $header => $value) {
|
||||
$rawHeaders[] = sprintf('%s:%s', $header, implode(', ', $value));
|
||||
}
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $request->getUri());
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $request->getMethod());
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $rawHeaders);
|
||||
|
||||
$body = $request->getBody();
|
||||
if (!empty($body)) {
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
|
||||
}
|
||||
|
||||
$responseBody = curl_exec($ch);
|
||||
|
||||
if (false === $responseBody) {
|
||||
$message = curl_error($ch);
|
||||
$code = curl_errno($ch);
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
throw new RuntimeException($message, $code);
|
||||
}
|
||||
|
||||
$response = new Response(
|
||||
curl_getinfo($ch, CURLINFO_HTTP_CODE),
|
||||
$responseBody
|
||||
);
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace Aplazame\Http;
|
||||
|
||||
class Request implements RequestInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $method;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $uri;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $headers;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $body;
|
||||
|
||||
/**
|
||||
* @param string $method The HTTP method of the request.
|
||||
* @param string $uri The URI of the request.
|
||||
* @param array $headers The headers of the request.
|
||||
* @param string $body The body of the message.
|
||||
*/
|
||||
public function __construct($method, $uri, array $headers = array(), $body = '')
|
||||
{
|
||||
$this->method = strtoupper($method);
|
||||
$this->uri = $uri;
|
||||
$this->headers = $headers;
|
||||
$this->body = $body;
|
||||
}
|
||||
|
||||
public function getMethod()
|
||||
{
|
||||
return $this->method;
|
||||
}
|
||||
|
||||
public function getHeaders()
|
||||
{
|
||||
return $this->headers;
|
||||
}
|
||||
|
||||
public function getUri()
|
||||
{
|
||||
return $this->uri;
|
||||
}
|
||||
|
||||
public function getBody()
|
||||
{
|
||||
return $this->body;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace Aplazame\Http;
|
||||
|
||||
interface RequestInterface
|
||||
{
|
||||
/**
|
||||
* Retrieves the HTTP method of the request.
|
||||
*
|
||||
* @return string Returns the request method. The return value must use uppercase letters.
|
||||
*/
|
||||
public function getMethod();
|
||||
|
||||
/**
|
||||
* Retrieves all message header values.
|
||||
*
|
||||
* The keys represent the header name as it will be sent over the wire, and
|
||||
* each value is an array of strings associated with the header.
|
||||
*
|
||||
* // Represent the headers as a string
|
||||
* foreach ($message->getHeaders() as $name => $values) {
|
||||
* echo $name . ": " . implode(", ", $values);
|
||||
* }
|
||||
*
|
||||
* // Emit headers iteratively:
|
||||
* foreach ($message->getHeaders() as $name => $values) {
|
||||
* foreach ($values as $value) {
|
||||
* header(sprintf('%s: %s', $name, $value), false);
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* While header names are not case-sensitive, getHeaders() will preserve the
|
||||
* exact case in which headers were originally specified.
|
||||
*
|
||||
* @return array Returns an associative array of the message's headers. Each
|
||||
* key MUST be a header name, and each value MUST be an array of strings
|
||||
* for that header.
|
||||
*/
|
||||
public function getHeaders();
|
||||
|
||||
/**
|
||||
* Retrieves the URI instance.
|
||||
*
|
||||
* @link http://tools.ietf.org/html/rfc3986#section-4.3
|
||||
*
|
||||
* @return string Returns the URI of the request.
|
||||
*/
|
||||
public function getUri();
|
||||
|
||||
/**
|
||||
* Gets the body of the message.
|
||||
*
|
||||
* @return string Returns the body of the request.
|
||||
*/
|
||||
public function getBody();
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
namespace Aplazame\Http;
|
||||
|
||||
class Response implements ResponseInterface
|
||||
{
|
||||
/** @var array Map of standard HTTP status code/reason phrases */
|
||||
private static $phrases = array(
|
||||
100 => 'Continue',
|
||||
101 => 'Switching Protocols',
|
||||
102 => 'Processing',
|
||||
200 => 'OK',
|
||||
201 => 'Created',
|
||||
202 => 'Accepted',
|
||||
203 => 'Non-Authoritative Information',
|
||||
204 => 'No Content',
|
||||
205 => 'Reset Content',
|
||||
206 => 'Partial Content',
|
||||
207 => 'Multi-status',
|
||||
208 => 'Already Reported',
|
||||
300 => 'Multiple Choices',
|
||||
301 => 'Moved Permanently',
|
||||
302 => 'Found',
|
||||
303 => 'See Other',
|
||||
304 => 'Not Modified',
|
||||
305 => 'Use Proxy',
|
||||
306 => 'Switch Proxy',
|
||||
307 => 'Temporary Redirect',
|
||||
400 => 'Bad Request',
|
||||
401 => 'Unauthorized',
|
||||
402 => 'Payment Required',
|
||||
403 => 'Forbidden',
|
||||
404 => 'Not Found',
|
||||
405 => 'Method Not Allowed',
|
||||
406 => 'Not Acceptable',
|
||||
407 => 'Proxy Authentication Required',
|
||||
408 => 'Request Time-out',
|
||||
409 => 'Conflict',
|
||||
410 => 'Gone',
|
||||
411 => 'Length Required',
|
||||
412 => 'Precondition Failed',
|
||||
413 => 'Request Entity Too Large',
|
||||
414 => 'Request-URI Too Large',
|
||||
415 => 'Unsupported Media Type',
|
||||
416 => 'Requested range not satisfiable',
|
||||
417 => 'Expectation Failed',
|
||||
418 => "'I'm a teapot'",
|
||||
422 => 'Unprocessable Entity',
|
||||
423 => 'Locked',
|
||||
424 => 'Failed Dependency',
|
||||
425 => 'Unordered Collection',
|
||||
426 => 'Upgrade Required',
|
||||
428 => 'Precondition Required',
|
||||
429 => 'Too Many Requests',
|
||||
431 => 'Request Header Fields Too Large',
|
||||
451 => 'Unavailable For Legal Reasons',
|
||||
500 => 'Internal Server Error',
|
||||
501 => 'Not Implemented',
|
||||
502 => 'Bad Gateway',
|
||||
503 => 'Service Unavailable',
|
||||
504 => 'Gateway Time-out',
|
||||
505 => 'HTTP Version not supported',
|
||||
506 => 'Variant Also Negotiates',
|
||||
507 => 'Insufficient Storage',
|
||||
508 => 'Loop Detected',
|
||||
511 => 'Network Authentication Required',
|
||||
);
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $statusCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $reasonPhrase = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $body;
|
||||
|
||||
/**
|
||||
* @param int $statusCode
|
||||
* @param string $body
|
||||
*/
|
||||
public function __construct($statusCode, $body)
|
||||
{
|
||||
$this->statusCode = $statusCode;
|
||||
$this->body = $body;
|
||||
|
||||
if (isset(self::$phrases[$this->statusCode])) {
|
||||
$this->reasonPhrase = self::$phrases[$statusCode];
|
||||
} else {
|
||||
$this->reasonPhrase = '';
|
||||
}
|
||||
}
|
||||
|
||||
public function getStatusCode()
|
||||
{
|
||||
return $this->statusCode;
|
||||
}
|
||||
|
||||
public function getReasonPhrase()
|
||||
{
|
||||
return $this->reasonPhrase;
|
||||
}
|
||||
|
||||
public function getBody()
|
||||
{
|
||||
return $this->body;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Aplazame\Http;
|
||||
|
||||
/**
|
||||
* Representation of an outgoing, server-side response.
|
||||
*/
|
||||
interface ResponseInterface
|
||||
{
|
||||
/**
|
||||
* Gets the response status code.
|
||||
*
|
||||
* The status code is a 3-digit integer result code of the server's attempt
|
||||
* to understand and satisfy the request.
|
||||
*
|
||||
* @return int Status code.
|
||||
*/
|
||||
public function getStatusCode();
|
||||
|
||||
/**
|
||||
* Gets the response reason phrase associated with the status code.
|
||||
*
|
||||
* Because a reason phrase is not a required element in a response
|
||||
* status line, the reason phrase value MAY be null. Implementations MAY
|
||||
* choose to return the default RFC 7231 recommended reason phrase (or those
|
||||
* listed in the IANA HTTP Status Code Registry) for the response's
|
||||
* status code.
|
||||
*
|
||||
* @link http://tools.ietf.org/html/rfc7231#section-6
|
||||
* @link http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
|
||||
*
|
||||
* @return string Reason phrase; must return an empty string if none present.
|
||||
*/
|
||||
public function getReasonPhrase();
|
||||
|
||||
/**
|
||||
* Gets the body of the message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBody();
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Aplazame\Serializer;
|
||||
|
||||
use DateTime;
|
||||
|
||||
/**
|
||||
* DateTime Type.
|
||||
*/
|
||||
class Date implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* @param DateTime $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function fromDateTime($value)
|
||||
{
|
||||
return new self($value->format(DateTime::ISO8601));
|
||||
}
|
||||
|
||||
/**
|
||||
* @var null|string
|
||||
*/
|
||||
public $value;
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*/
|
||||
public function __construct($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTime
|
||||
*/
|
||||
public function asDateTime()
|
||||
{
|
||||
$dateTime = DateTime::createFromFormat(DateTime::ISO8601, $this->value);
|
||||
|
||||
return $dateTime;
|
||||
}
|
||||
|
||||
public function jsonSerialize():mixed
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Aplazame\Serializer;
|
||||
|
||||
/**
|
||||
* Decimal Type.
|
||||
*/
|
||||
class Decimal implements \JsonSerializable
|
||||
{
|
||||
public static function fromFloat($value)
|
||||
{
|
||||
return new self((int) number_format($value, 2, '', ''));
|
||||
}
|
||||
|
||||
/**
|
||||
* @var null|int
|
||||
*/
|
||||
public $value;
|
||||
|
||||
/**
|
||||
* @param int $value
|
||||
*/
|
||||
public function __construct($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function asFloat()
|
||||
{
|
||||
return $this->value / 100;
|
||||
}
|
||||
|
||||
public function jsonSerialize():mixed
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
}
|
||||
25
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/autoload.php
vendored
Normal file
25
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/autoload.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
// autoload.php @generated by Composer
|
||||
|
||||
if (PHP_VERSION_ID < 50600) {
|
||||
if (!headers_sent()) {
|
||||
header('HTTP/1.1 500 Internal Server Error');
|
||||
}
|
||||
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
|
||||
if (!ini_get('display_errors')) {
|
||||
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
|
||||
fwrite(STDERR, $err);
|
||||
} elseif (!headers_sent()) {
|
||||
echo $err;
|
||||
}
|
||||
}
|
||||
trigger_error(
|
||||
$err,
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInitd7596b5697fd1b453367d94ecd0f0b70::getLoader();
|
||||
581
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/composer/ClassLoader.php
vendored
Normal file
581
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/composer/ClassLoader.php
vendored
Normal file
@@ -0,0 +1,581 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
/**
|
||||
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
|
||||
*
|
||||
* $loader = new \Composer\Autoload\ClassLoader();
|
||||
*
|
||||
* // register classes with namespaces
|
||||
* $loader->add('Symfony\Component', __DIR__.'/component');
|
||||
* $loader->add('Symfony', __DIR__.'/framework');
|
||||
*
|
||||
* // activate the autoloader
|
||||
* $loader->register();
|
||||
*
|
||||
* // to enable searching the include path (eg. for PEAR packages)
|
||||
* $loader->setUseIncludePath(true);
|
||||
*
|
||||
* In this example, if you try to use a class in the Symfony\Component
|
||||
* namespace or one of its children (Symfony\Component\Console for instance),
|
||||
* the autoloader will first look for the class under the component/
|
||||
* directory, and it will then fallback to the framework/ directory if not
|
||||
* found before giving up.
|
||||
*
|
||||
* This class is loosely based on the Symfony UniversalClassLoader.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @see https://www.php-fig.org/psr/psr-0/
|
||||
* @see https://www.php-fig.org/psr/psr-4/
|
||||
*/
|
||||
class ClassLoader
|
||||
{
|
||||
/** @var \Closure(string):void */
|
||||
private static $includeFile;
|
||||
|
||||
/** @var ?string */
|
||||
private $vendorDir;
|
||||
|
||||
// PSR-4
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array<string, int>>
|
||||
*/
|
||||
private $prefixLengthsPsr4 = array();
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array<int, string>>
|
||||
*/
|
||||
private $prefixDirsPsr4 = array();
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, string>
|
||||
*/
|
||||
private $fallbackDirsPsr4 = array();
|
||||
|
||||
// PSR-0
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array<string, string[]>>
|
||||
*/
|
||||
private $prefixesPsr0 = array();
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, string>
|
||||
*/
|
||||
private $fallbackDirsPsr0 = array();
|
||||
|
||||
/** @var bool */
|
||||
private $useIncludePath = false;
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
* @psalm-var array<string, string>
|
||||
*/
|
||||
private $classMap = array();
|
||||
|
||||
/** @var bool */
|
||||
private $classMapAuthoritative = false;
|
||||
|
||||
/**
|
||||
* @var bool[]
|
||||
* @psalm-var array<string, bool>
|
||||
*/
|
||||
private $missingClasses = array();
|
||||
|
||||
/** @var ?string */
|
||||
private $apcuPrefix;
|
||||
|
||||
/**
|
||||
* @var self[]
|
||||
*/
|
||||
private static $registeredLoaders = array();
|
||||
|
||||
/**
|
||||
* @param ?string $vendorDir
|
||||
*/
|
||||
public function __construct($vendorDir = null)
|
||||
{
|
||||
$this->vendorDir = $vendorDir;
|
||||
self::initializeIncludeClosure();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getPrefixes()
|
||||
{
|
||||
if (!empty($this->prefixesPsr0)) {
|
||||
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
* @psalm-return array<string, array<int, string>>
|
||||
*/
|
||||
public function getPrefixesPsr4()
|
||||
{
|
||||
return $this->prefixDirsPsr4;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
* @psalm-return array<string, string>
|
||||
*/
|
||||
public function getFallbackDirs()
|
||||
{
|
||||
return $this->fallbackDirsPsr0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
* @psalm-return array<string, string>
|
||||
*/
|
||||
public function getFallbackDirsPsr4()
|
||||
{
|
||||
return $this->fallbackDirsPsr4;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[] Array of classname => path
|
||||
* @psalm-return array<string, string>
|
||||
*/
|
||||
public function getClassMap()
|
||||
{
|
||||
return $this->classMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $classMap Class to filename map
|
||||
* @psalm-param array<string, string> $classMap
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addClassMap(array $classMap)
|
||||
{
|
||||
if ($this->classMap) {
|
||||
$this->classMap = array_merge($this->classMap, $classMap);
|
||||
} else {
|
||||
$this->classMap = $classMap;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-0 directories for a given prefix, either
|
||||
* appending or prepending to the ones previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param string[]|string $paths The PSR-0 root directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add($prefix, $paths, $prepend = false)
|
||||
{
|
||||
if (!$prefix) {
|
||||
if ($prepend) {
|
||||
$this->fallbackDirsPsr0 = array_merge(
|
||||
(array) $paths,
|
||||
$this->fallbackDirsPsr0
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirsPsr0 = array_merge(
|
||||
$this->fallbackDirsPsr0,
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$first = $prefix[0];
|
||||
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
||||
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
|
||||
|
||||
return;
|
||||
}
|
||||
if ($prepend) {
|
||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||
(array) $paths,
|
||||
$this->prefixesPsr0[$first][$prefix]
|
||||
);
|
||||
} else {
|
||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||
$this->prefixesPsr0[$first][$prefix],
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-4 directories for a given namespace, either
|
||||
* appending or prepending to the ones previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param string[]|string $paths The PSR-4 base directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addPsr4($prefix, $paths, $prepend = false)
|
||||
{
|
||||
if (!$prefix) {
|
||||
// Register directories for the root namespace.
|
||||
if ($prepend) {
|
||||
$this->fallbackDirsPsr4 = array_merge(
|
||||
(array) $paths,
|
||||
$this->fallbackDirsPsr4
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirsPsr4 = array_merge(
|
||||
$this->fallbackDirsPsr4,
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
||||
// Register directories for a new namespace.
|
||||
$length = strlen($prefix);
|
||||
if ('\\' !== $prefix[$length - 1]) {
|
||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||
}
|
||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||
} elseif ($prepend) {
|
||||
// Prepend directories for an already registered namespace.
|
||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||
(array) $paths,
|
||||
$this->prefixDirsPsr4[$prefix]
|
||||
);
|
||||
} else {
|
||||
// Append directories for an already registered namespace.
|
||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||
$this->prefixDirsPsr4[$prefix],
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-0 directories for a given prefix,
|
||||
* replacing any others previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param string[]|string $paths The PSR-0 base directories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function set($prefix, $paths)
|
||||
{
|
||||
if (!$prefix) {
|
||||
$this->fallbackDirsPsr0 = (array) $paths;
|
||||
} else {
|
||||
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-4 directories for a given namespace,
|
||||
* replacing any others previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param string[]|string $paths The PSR-4 base directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setPsr4($prefix, $paths)
|
||||
{
|
||||
if (!$prefix) {
|
||||
$this->fallbackDirsPsr4 = (array) $paths;
|
||||
} else {
|
||||
$length = strlen($prefix);
|
||||
if ('\\' !== $prefix[$length - 1]) {
|
||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||
}
|
||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns on searching the include path for class files.
|
||||
*
|
||||
* @param bool $useIncludePath
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setUseIncludePath($useIncludePath)
|
||||
{
|
||||
$this->useIncludePath = $useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used to check if the autoloader uses the include path to check
|
||||
* for classes.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getUseIncludePath()
|
||||
{
|
||||
return $this->useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns off searching the prefix and fallback directories for classes
|
||||
* that have not been registered with the class map.
|
||||
*
|
||||
* @param bool $classMapAuthoritative
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setClassMapAuthoritative($classMapAuthoritative)
|
||||
{
|
||||
$this->classMapAuthoritative = $classMapAuthoritative;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should class lookup fail if not found in the current class map?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isClassMapAuthoritative()
|
||||
{
|
||||
return $this->classMapAuthoritative;
|
||||
}
|
||||
|
||||
/**
|
||||
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
|
||||
*
|
||||
* @param string|null $apcuPrefix
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setApcuPrefix($apcuPrefix)
|
||||
{
|
||||
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The APCu prefix in use, or null if APCu caching is not enabled.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getApcuPrefix()
|
||||
{
|
||||
return $this->apcuPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers this instance as an autoloader.
|
||||
*
|
||||
* @param bool $prepend Whether to prepend the autoloader or not
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register($prepend = false)
|
||||
{
|
||||
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
||||
|
||||
if (null === $this->vendorDir) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($prepend) {
|
||||
self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
|
||||
} else {
|
||||
unset(self::$registeredLoaders[$this->vendorDir]);
|
||||
self::$registeredLoaders[$this->vendorDir] = $this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters this instance as an autoloader.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unregister()
|
||||
{
|
||||
spl_autoload_unregister(array($this, 'loadClass'));
|
||||
|
||||
if (null !== $this->vendorDir) {
|
||||
unset(self::$registeredLoaders[$this->vendorDir]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the given class or interface.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
* @return true|null True if loaded, null otherwise
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
if ($file = $this->findFile($class)) {
|
||||
(self::$includeFile)($file);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the path to the file where the class is defined.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
*
|
||||
* @return string|false The path if found, false otherwise
|
||||
*/
|
||||
public function findFile($class)
|
||||
{
|
||||
// class map lookup
|
||||
if (isset($this->classMap[$class])) {
|
||||
return $this->classMap[$class];
|
||||
}
|
||||
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
|
||||
return false;
|
||||
}
|
||||
if (null !== $this->apcuPrefix) {
|
||||
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
|
||||
if ($hit) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
$file = $this->findFileWithExtension($class, '.php');
|
||||
|
||||
// Search for Hack files if we are running on HHVM
|
||||
if (false === $file && defined('HHVM_VERSION')) {
|
||||
$file = $this->findFileWithExtension($class, '.hh');
|
||||
}
|
||||
|
||||
if (null !== $this->apcuPrefix) {
|
||||
apcu_add($this->apcuPrefix.$class, $file);
|
||||
}
|
||||
|
||||
if (false === $file) {
|
||||
// Remember that this class does not exist.
|
||||
$this->missingClasses[$class] = true;
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the currently registered loaders indexed by their corresponding vendor directories.
|
||||
*
|
||||
* @return self[]
|
||||
*/
|
||||
public static function getRegisteredLoaders()
|
||||
{
|
||||
return self::$registeredLoaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
* @param string $ext
|
||||
* @return string|false
|
||||
*/
|
||||
private function findFileWithExtension($class, $ext)
|
||||
{
|
||||
// PSR-4 lookup
|
||||
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
|
||||
|
||||
$first = $class[0];
|
||||
if (isset($this->prefixLengthsPsr4[$first])) {
|
||||
$subPath = $class;
|
||||
while (false !== $lastPos = strrpos($subPath, '\\')) {
|
||||
$subPath = substr($subPath, 0, $lastPos);
|
||||
$search = $subPath . '\\';
|
||||
if (isset($this->prefixDirsPsr4[$search])) {
|
||||
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
|
||||
foreach ($this->prefixDirsPsr4[$search] as $dir) {
|
||||
if (file_exists($file = $dir . $pathEnd)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-4 fallback dirs
|
||||
foreach ($this->fallbackDirsPsr4 as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 lookup
|
||||
if (false !== $pos = strrpos($class, '\\')) {
|
||||
// namespaced class name
|
||||
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
|
||||
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
|
||||
} else {
|
||||
// PEAR-like class name
|
||||
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
|
||||
}
|
||||
|
||||
if (isset($this->prefixesPsr0[$first])) {
|
||||
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
|
||||
if (0 === strpos($class, $prefix)) {
|
||||
foreach ($dirs as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 fallback dirs
|
||||
foreach ($this->fallbackDirsPsr0 as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 include paths.
|
||||
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static function initializeIncludeClosure(): void
|
||||
{
|
||||
if (self::$includeFile !== null) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope isolated include.
|
||||
*
|
||||
* Prevents access to $this/self from included files.
|
||||
*
|
||||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
self::$includeFile = static function($file) {
|
||||
include $file;
|
||||
};
|
||||
}
|
||||
}
|
||||
352
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/composer/InstalledVersions.php
vendored
Normal file
352
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/composer/InstalledVersions.php
vendored
Normal file
@@ -0,0 +1,352 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer;
|
||||
|
||||
use Composer\Autoload\ClassLoader;
|
||||
use Composer\Semver\VersionParser;
|
||||
|
||||
/**
|
||||
* This class is copied in every Composer installed project and available to all
|
||||
*
|
||||
* See also https://getcomposer.org/doc/07-runtime.md#installed-versions
|
||||
*
|
||||
* To require its presence, you can require `composer-runtime-api ^2.0`
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class InstalledVersions
|
||||
{
|
||||
/**
|
||||
* @var mixed[]|null
|
||||
* @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null
|
||||
*/
|
||||
private static $installed;
|
||||
|
||||
/**
|
||||
* @var bool|null
|
||||
*/
|
||||
private static $canGetVendors;
|
||||
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
||||
*/
|
||||
private static $installedByVendor = array();
|
||||
|
||||
/**
|
||||
* Returns a list of all package names which are present, either by being installed, replaced or provided
|
||||
*
|
||||
* @return string[]
|
||||
* @psalm-return list<string>
|
||||
*/
|
||||
public static function getInstalledPackages()
|
||||
{
|
||||
$packages = array();
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
$packages[] = array_keys($installed['versions']);
|
||||
}
|
||||
|
||||
if (1 === \count($packages)) {
|
||||
return $packages[0];
|
||||
}
|
||||
|
||||
return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all package names with a specific type e.g. 'library'
|
||||
*
|
||||
* @param string $type
|
||||
* @return string[]
|
||||
* @psalm-return list<string>
|
||||
*/
|
||||
public static function getInstalledPackagesByType($type)
|
||||
{
|
||||
$packagesByType = array();
|
||||
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
foreach ($installed['versions'] as $name => $package) {
|
||||
if (isset($package['type']) && $package['type'] === $type) {
|
||||
$packagesByType[] = $name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $packagesByType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the given package is installed
|
||||
*
|
||||
* This also returns true if the package name is provided or replaced by another package
|
||||
*
|
||||
* @param string $packageName
|
||||
* @param bool $includeDevRequirements
|
||||
* @return bool
|
||||
*/
|
||||
public static function isInstalled($packageName, $includeDevRequirements = true)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (isset($installed['versions'][$packageName])) {
|
||||
return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the given package satisfies a version constraint
|
||||
*
|
||||
* e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
|
||||
*
|
||||
* Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
|
||||
*
|
||||
* @param VersionParser $parser Install composer/semver to have access to this class and functionality
|
||||
* @param string $packageName
|
||||
* @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
|
||||
* @return bool
|
||||
*/
|
||||
public static function satisfies(VersionParser $parser, $packageName, $constraint)
|
||||
{
|
||||
$constraint = $parser->parseConstraints($constraint);
|
||||
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
|
||||
|
||||
return $provided->matches($constraint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a version constraint representing all the range(s) which are installed for a given package
|
||||
*
|
||||
* It is easier to use this via isInstalled() with the $constraint argument if you need to check
|
||||
* whether a given version of a package is installed, and not just whether it exists
|
||||
*
|
||||
* @param string $packageName
|
||||
* @return string Version constraint usable with composer/semver
|
||||
*/
|
||||
public static function getVersionRanges($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$ranges = array();
|
||||
if (isset($installed['versions'][$packageName]['pretty_version'])) {
|
||||
$ranges[] = $installed['versions'][$packageName]['pretty_version'];
|
||||
}
|
||||
if (array_key_exists('aliases', $installed['versions'][$packageName])) {
|
||||
$ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
|
||||
}
|
||||
if (array_key_exists('replaced', $installed['versions'][$packageName])) {
|
||||
$ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
|
||||
}
|
||||
if (array_key_exists('provided', $installed['versions'][$packageName])) {
|
||||
$ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
|
||||
}
|
||||
|
||||
return implode(' || ', $ranges);
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $packageName
|
||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
|
||||
*/
|
||||
public static function getVersion($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($installed['versions'][$packageName]['version'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $installed['versions'][$packageName]['version'];
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $packageName
|
||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
|
||||
*/
|
||||
public static function getPrettyVersion($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($installed['versions'][$packageName]['pretty_version'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $installed['versions'][$packageName]['pretty_version'];
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $packageName
|
||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
|
||||
*/
|
||||
public static function getReference($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($installed['versions'][$packageName]['reference'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $installed['versions'][$packageName]['reference'];
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $packageName
|
||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
|
||||
*/
|
||||
public static function getInstallPath($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}
|
||||
*/
|
||||
public static function getRootPackage()
|
||||
{
|
||||
$installed = self::getInstalled();
|
||||
|
||||
return $installed[0]['root'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the raw installed.php data for custom implementations
|
||||
*
|
||||
* @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
|
||||
* @return array[]
|
||||
* @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}
|
||||
*/
|
||||
public static function getRawData()
|
||||
{
|
||||
@trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
|
||||
|
||||
if (null === self::$installed) {
|
||||
// only require the installed.php file if this file is loaded from its dumped location,
|
||||
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
||||
if (substr(__DIR__, -8, 1) !== 'C') {
|
||||
self::$installed = include __DIR__ . '/installed.php';
|
||||
} else {
|
||||
self::$installed = array();
|
||||
}
|
||||
}
|
||||
|
||||
return self::$installed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the raw data of all installed.php which are currently loaded for custom implementations
|
||||
*
|
||||
* @return array[]
|
||||
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
||||
*/
|
||||
public static function getAllRawData()
|
||||
{
|
||||
return self::getInstalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Lets you reload the static array from another file
|
||||
*
|
||||
* This is only useful for complex integrations in which a project needs to use
|
||||
* this class but then also needs to execute another project's autoloader in process,
|
||||
* and wants to ensure both projects have access to their version of installed.php.
|
||||
*
|
||||
* A typical case would be PHPUnit, where it would need to make sure it reads all
|
||||
* the data it needs from this class, then call reload() with
|
||||
* `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
|
||||
* the project in which it runs can then also use this class safely, without
|
||||
* interference between PHPUnit's dependencies and the project's dependencies.
|
||||
*
|
||||
* @param array[] $data A vendor/composer/installed.php data set
|
||||
* @return void
|
||||
*
|
||||
* @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $data
|
||||
*/
|
||||
public static function reload($data)
|
||||
{
|
||||
self::$installed = $data;
|
||||
self::$installedByVendor = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
||||
*/
|
||||
private static function getInstalled()
|
||||
{
|
||||
if (null === self::$canGetVendors) {
|
||||
self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
|
||||
}
|
||||
|
||||
$installed = array();
|
||||
|
||||
if (self::$canGetVendors) {
|
||||
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
|
||||
if (isset(self::$installedByVendor[$vendorDir])) {
|
||||
$installed[] = self::$installedByVendor[$vendorDir];
|
||||
} elseif (is_file($vendorDir.'/composer/installed.php')) {
|
||||
$installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
|
||||
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
|
||||
self::$installed = $installed[count($installed) - 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (null === self::$installed) {
|
||||
// only require the installed.php file if this file is loaded from its dumped location,
|
||||
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
||||
if (substr(__DIR__, -8, 1) !== 'C') {
|
||||
self::$installed = require __DIR__ . '/installed.php';
|
||||
} else {
|
||||
self::$installed = array();
|
||||
}
|
||||
}
|
||||
$installed[] = self::$installed;
|
||||
|
||||
return $installed;
|
||||
}
|
||||
}
|
||||
21
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/composer/LICENSE
vendored
Normal file
21
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/composer/LICENSE
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
Copyright (c) Nils Adermann, Jordi Boggiano
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
10
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/composer/autoload_classmap.php
vendored
Normal file
10
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/composer/autoload_classmap.php
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
// autoload_classmap.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
|
||||
);
|
||||
9
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/composer/autoload_namespaces.php
vendored
Normal file
9
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/composer/autoload_namespaces.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
// autoload_namespaces.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
);
|
||||
10
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/composer/autoload_psr4.php
vendored
Normal file
10
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/composer/autoload_psr4.php
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
// autoload_psr4.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'Aplazame\\' => array($vendorDir . '/aplazame/aplazame-api-sdk/src'),
|
||||
);
|
||||
38
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/composer/autoload_real.php
vendored
Normal file
38
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/composer/autoload_real.php
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInitd7596b5697fd1b453367d94ecd0f0b70
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
public static function loadClassLoader($class)
|
||||
{
|
||||
if ('Composer\Autoload\ClassLoader' === $class) {
|
||||
require __DIR__ . '/ClassLoader.php';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Composer\Autoload\ClassLoader
|
||||
*/
|
||||
public static function getLoader()
|
||||
{
|
||||
if (null !== self::$loader) {
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
require __DIR__ . '/platform_check.php';
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitd7596b5697fd1b453367d94ecd0f0b70', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitd7596b5697fd1b453367d94ecd0f0b70', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitd7596b5697fd1b453367d94ecd0f0b70::getInitializer($loader));
|
||||
|
||||
$loader->register(true);
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
36
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/composer/autoload_static.php
vendored
Normal file
36
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/composer/autoload_static.php
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
// autoload_static.php @generated by Composer
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInitd7596b5697fd1b453367d94ecd0f0b70
|
||||
{
|
||||
public static $prefixLengthsPsr4 = array (
|
||||
'A' =>
|
||||
array (
|
||||
'Aplazame\\' => 9,
|
||||
),
|
||||
);
|
||||
|
||||
public static $prefixDirsPsr4 = array (
|
||||
'Aplazame\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/aplazame/aplazame-api-sdk/src',
|
||||
),
|
||||
);
|
||||
|
||||
public static $classMap = array (
|
||||
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
|
||||
);
|
||||
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitd7596b5697fd1b453367d94ecd0f0b70::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitd7596b5697fd1b453367d94ecd0f0b70::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitd7596b5697fd1b453367d94ecd0f0b70::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
}
|
||||
51
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/composer/installed.json
vendored
Normal file
51
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/composer/installed.json
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"packages": [
|
||||
{
|
||||
"name": "aplazame/aplazame-api-sdk",
|
||||
"version": "v0.3.6",
|
||||
"version_normalized": "0.3.6.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/aplazame/php-sdk.git",
|
||||
"reference": "a8da64706478b1ebb3f6ccfa6677710121846771"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/aplazame/php-sdk/zipball/a8da64706478b1ebb3f6ccfa6677710121846771",
|
||||
"reference": "a8da64706478b1ebb3f6ccfa6677710121846771",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-json": "*",
|
||||
"php": ">= 5.6.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "1.11.*",
|
||||
"phpunit/phpunit": "*"
|
||||
},
|
||||
"time": "2023-11-28T15:06:00+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Aplazame\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"GPL-3.0"
|
||||
],
|
||||
"description": "Aplazame API SDK",
|
||||
"keywords": [
|
||||
"aplazame"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/aplazame/php-sdk/issues",
|
||||
"source": "https://github.com/aplazame/php-sdk/tree/v0.3.6"
|
||||
},
|
||||
"install-path": "../aplazame/aplazame-api-sdk"
|
||||
}
|
||||
],
|
||||
"dev": true,
|
||||
"dev-package-names": []
|
||||
}
|
||||
32
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/composer/installed.php
vendored
Normal file
32
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/composer/installed.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php return array(
|
||||
'root' => array(
|
||||
'name' => '__root__',
|
||||
'pretty_version' => '1.0.0+no-version-set',
|
||||
'version' => '1.0.0.0',
|
||||
'reference' => NULL,
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
'dev' => true,
|
||||
),
|
||||
'versions' => array(
|
||||
'__root__' => array(
|
||||
'pretty_version' => '1.0.0+no-version-set',
|
||||
'version' => '1.0.0.0',
|
||||
'reference' => NULL,
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'aplazame/aplazame-api-sdk' => array(
|
||||
'pretty_version' => 'v0.3.6',
|
||||
'version' => '0.3.6.0',
|
||||
'reference' => 'a8da64706478b1ebb3f6ccfa6677710121846771',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../aplazame/aplazame-api-sdk',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
),
|
||||
);
|
||||
26
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/composer/platform_check.php
vendored
Normal file
26
cms/lib/plugins/payments/classes/vendor/vendor-aplazame/composer/platform_check.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
// platform_check.php @generated by Composer
|
||||
|
||||
$issues = array();
|
||||
|
||||
if (!(PHP_VERSION_ID >= 50600)) {
|
||||
$issues[] = 'Your Composer dependencies require a PHP version ">= 5.6.0". You are running ' . PHP_VERSION . '.';
|
||||
}
|
||||
|
||||
if ($issues) {
|
||||
if (!headers_sent()) {
|
||||
header('HTTP/1.1 500 Internal Server Error');
|
||||
}
|
||||
if (!ini_get('display_errors')) {
|
||||
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
|
||||
fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
|
||||
} elseif (!headers_sent()) {
|
||||
echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
|
||||
}
|
||||
}
|
||||
trigger_error(
|
||||
'Composer detected issues in your platform: ' . implode(' ', $issues),
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user