diff --git a/.gitattributes b/.gitattributes index 9ba0826c..338b15ad 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8,4 +8,4 @@ Makefile export-ignore /php_env export-ignore phpunit.xml export-ignore -.php_cs export-ignore +.php-cs-fixer.php export-ignore diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 1738b386..79e38204 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - php-version: ["7.3", "7.4", "8.0"] + php-version: ["7.3", "7.4", "8.0", "8.1", "8.2"] os: [ubuntu-latest] experimental: [false] composer-options: [''] diff --git a/.gitignore b/.gitignore index 8df94255..37f526df 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,6 @@ composer.lock .* !.github -!.php_cs +!.php-cs-fixer.php !.gitignore !.gitattributes diff --git a/.php_cs b/.php-cs-fixer.php similarity index 50% rename from .php_cs rename to .php-cs-fixer.php index 0c58b541..40de0768 100644 --- a/.php_cs +++ b/.php-cs-fixer.php @@ -1,17 +1,18 @@ in(__DIR__.'/MangoPay') ->in(__DIR__.'/tests') ; -$config = new PhpCsFixer\Config(); - -return $config->setRules([ +return (new PhpCsFixer\Config()) + ->setRules([ '@PSR12' => true, 'fully_qualified_strict_types' => true, 'array_syntax' => ['syntax' => 'short'], - 'visibility_required' => ['property', 'method'],// 'const' is removed for old PHP compat + 'visibility_required' => [ + 'elements' => ['property', 'method'], // 'const' is removed for old PHP compat + ], ]) ->setFinder($finder) ; diff --git a/Makefile b/Makefile index fa8f28da..277574a9 100644 --- a/Makefile +++ b/Makefile @@ -36,3 +36,21 @@ docker-test-php-80: ## Test on PHP 8.0 --user $(shell id -u):$(shell id -g) \ php-test-env:8.0 \ /bin/bash -c "composer update -no --no-progress --no-suggest --ignore-platform-reqs && vendor/bin/phpunit tests" + +.PHONY: docker-test-php-81 +docker-test-php-81: ## Test on PHP 8.1 + docker build -t php-test-env:8.1 php_env/PHP_8.1 + docker run -it -v "${PWD}":/usr/src/mangopay2-php-sdk \ + -w /usr/src/mangopay2-php-sdk \ + --user $(shell id -u):$(shell id -g) \ + php-test-env:8.1 \ + /bin/bash -c "composer update -no --no-progress --no-suggest --ignore-platform-reqs && vendor/bin/phpunit tests" + +.PHONY: docker-test-php-82 +docker-test-php-82: ## Test on PHP 8.2 + docker build -t php-test-env:8.2 php_env/PHP_8.2 + docker run -it -v "${PWD}":/usr/src/mangopay2-php-sdk \ + -w /usr/src/mangopay2-php-sdk \ + --user $(shell id -u):$(shell id -g) \ + php-test-env:8.2 \ + /bin/bash -c "composer update -no --no-progress --no-suggest --ignore-platform-reqs && vendor/bin/phpunit tests" diff --git a/MangoPay/ApiUboDeclarations.php b/MangoPay/ApiUboDeclarations.php index 9ec6dbad..010d682b 100644 --- a/MangoPay/ApiUboDeclarations.php +++ b/MangoPay/ApiUboDeclarations.php @@ -10,13 +10,21 @@ class ApiUboDeclarations extends Libraries\ApiBase /** * Creates a new UBO Declaration for an user. * @param string $userId The ID of the user - * @return \MangoPay\UboDeclaration UBO Declaration object returned from API + * @return \MangoPay\UboDeclaration|array|object UBO Declaration object returned from API */ public function Create($userId) { return $this->CreateObject('ubo_declaration_create', null, '\MangoPay\UboDeclaration', $userId); } + /** + * Gets all UBO Declarations for an user. + * @param string $userId The ID of the user + * @param \MangoPay\Pagination $pagination Pagination object + * @param \MangoPay\Sorting $sorting Sorting object + * @return \MangoPay\UboDeclaration[]|array List of UBO Declarations returned from API + * @throws \MangoPay\Libraries\Exception + */ public function GetAll($userId, $pagination = null, $sorting = null) { return $this->GetList("ubo_declaration_all", $pagination, '\MangoPay\UboDeclaration', $userId, null, $sorting); @@ -24,9 +32,10 @@ public function GetAll($userId, $pagination = null, $sorting = null) /** * Gets an UBO Declaration. - * @param string $userId - * @param string $uboDeclarationId - * @return UboDeclaration UBO Declaration object returned from API + * @param string $userId The ID of the user + * @param string $uboDeclarationId UBO Declaration identifier + * @return UboDeclaration|array|object UBO Declaration object returned from API + * @throws \MangoPay\Libraries\Exception */ public function Get($userId, $uboDeclarationId) { @@ -35,8 +44,8 @@ public function Get($userId, $uboDeclarationId) /** * Gets an UBO Declaration directly by Id. - * @param string $uboDeclarationId - * @return UboDeclaration UBO Declaration object returned from API + * @param string $uboDeclarationId UBO Declaration identifier + * @return UboDeclaration|array|object UBO Declaration object returned from API */ public function GetById($uboDeclarationId) { @@ -45,10 +54,11 @@ public function GetById($uboDeclarationId) /** * Creates a new UBO for the specified arguments - * @param string $userId int - * @param string $uboDeclarationId int - * @param Ubo $ubo - * @return Ubo UBO object returned from API + * @param string $userId The ID of the user + * @param string $uboDeclarationId The ID of the UBO declaration + * @param Ubo $ubo The UBO object to be created + * @return Ubo|array|object UBO object returned from API + * @throws \MangoPay\Libraries\ResponseException */ public function CreateUbo($userId, $uboDeclarationId, $ubo) { @@ -60,10 +70,10 @@ public function CreateUbo($userId, $uboDeclarationId, $ubo) /** * Updates an UBO - * @param string $userId - * @param string $uboDeclarationId - * @param Ubo $ubo - * @return Ubo UBO object returned from API + * @param string $userId The ID of the user + * @param string $uboDeclarationId The ID of the UBO declaration + * @param Ubo $ubo The UBO object to be updated + * @return Ubo|array|object UBO object returned from API */ public function UpdateUbo($userId, $uboDeclarationId, $ubo) { @@ -72,10 +82,11 @@ public function UpdateUbo($userId, $uboDeclarationId, $ubo) /** * Gets an UBO - * @param string $userId - * @param string $uboDeclarationId - * @param string $uboId - * @return Ubo UBO object returned from API + * @param string $userId The ID of the user + * @param string $uboDeclarationId The ID of the UBO declaration + * @param string $uboId The ID of the UBO + * @return \MangoPay\Ubo|array|object UBO object returned from API + * @throws \MangoPay\Libraries\Exception */ public function GetUbo($userId, $uboDeclarationId, $uboId) { @@ -84,9 +95,9 @@ public function GetUbo($userId, $uboDeclarationId, $uboId) /** * Updates an UBO Declaration with the status VALIDATION_ASKED. - * @param string $userId - * @param string $uboDeclarationId - * @return UboDeclaration + * @param string $userId The ID of the user + * @param string $uboDeclarationId The ID of the UBO declaration + * @return \MangoPay\UboDeclaration|array|object */ public function SubmitForValidation($userId, $uboDeclarationId) { @@ -98,8 +109,10 @@ public function SubmitForValidation($userId, $uboDeclarationId) /** * Gets an UBO Declaration. - * @param string $uboDeclarationId - * @return UboDeclaration UBO Declaration object returned from API + * @param string $uboDeclarationId UBO Declaration identifier + * @return \MangoPay\UboDeclaration|array|object UBO Declaration object returned from API + * @throws \MangoPay\Libraries\Exception + * @throws \Exception */ public function GetUboDeclarationById($uboDeclarationId) { diff --git a/MangoPay/KycDocument.php b/MangoPay/KycDocument.php index 1befe53b..1970c81b 100644 --- a/MangoPay/KycDocument.php +++ b/MangoPay/KycDocument.php @@ -3,30 +3,59 @@ namespace MangoPay; /** - * KYC document entity + * KYC document entity. */ class KycDocument extends Libraries\Document { /** + * The type of the document for the user verification. + * * @var string + * * @see \MangoPay\KycDocumentType + * @see https://mangopay.com/docs/endpoints/kyc-documents#kyc-document-object */ public $Type; /** + * The label of KYC document type. + * * @var string - * @see \MangoPay\KycDocumentStatus + * @phpstan-var \MangoPay\KycDocumentStatus::* + */ + public $TypeLabel; + + /** + * The status of the KYC document. + * + * @var string + * + * @see KycDocumentStatus */ public $Status; /** + * The label of KYC document status. + * + * @var string + */ + public $StatusLabel; + + /** + * The unique identifier of the user. + * * @var string */ public $UserId; /** - * More information regarding why the document has been rejected. + * The series of codes providing more precision regarding the reason why the identity proof document was refused. + * You can review the explanations for each code in the Flags list. + * * @var array + * + * @see KycDocumentRefusedReasonType + * @see https://mangopay.com/docs/concepts/users/verification/document-process#flags-list */ public $Flags; } diff --git a/MangoPay/Libraries/ApiBase.php b/MangoPay/Libraries/ApiBase.php index 5714038b..5549d0ce 100644 --- a/MangoPay/Libraries/ApiBase.php +++ b/MangoPay/Libraries/ApiBase.php @@ -274,7 +274,7 @@ protected function GetRequestType($key) /** * Create object in API * @param string $methodKey Key with request data - * @param object $entity Entity object + * @param object|null $entity Entity object * @param object $responseClassName Name of entity class from response * @param string $entityId Entity identifier * @return object Response data @@ -310,7 +310,8 @@ protected function CreateObject($methodKey, $entity, $responseClassName = null, /** * Get entity object from API * @param string $methodKey Key with request data - * @param object $responseClassName Name of entity class from response + * @param string $responseClassName Name of entity class from response + * @param array $params path variable in urls * @return object Response data * @throws Exception */ diff --git a/MangoPay/PayIn.php b/MangoPay/PayIn.php index 5625a25d..63f61fcc 100644 --- a/MangoPay/PayIn.php +++ b/MangoPay/PayIn.php @@ -13,6 +13,23 @@ class PayIn extends Transaction */ public $CreditedWalletId; + /** + * The mode applied for the 3DS protocol for CB, Visa, and Mastercard. + * Default values: DEFAULT. Allowed values: DEFAULT, FORCE, NO_CHOICE + * + * @var string + */ + public $SecureMode; + + /** + * The 3DS protocol version to be applied to the transaction. Allowing values: V1, V2_1 + * + * @see https://mangopay.com/docs/concepts/payments/payment-methods/card/3ds + * @see https://mangopay.com/docs/endpoints/direct-card-payins#direct-card-payin-object + * @var string + */ + public $Requested3DSVersion; + /** * PaymentType {CARD, BANK_WIRE, DIRECT_DEBIT, PAYPAL, PAYCONIQ } * @var string @@ -43,6 +60,32 @@ class PayIn extends Transaction */ public $RecurringPayinRegistrationId; + /** + * The IP address of the end user initiating the transaction, in IPV4 or IPV6 format. + * @var string + */ + public $IpAddress; + + /** + * Information about the browser used by the end user (author) to perform the payment. + * @var BrowserInfo + */ + public $BrowserInfo; + + /** + * Information about the end user billing address. If left empty, the default values will be automatically taken into account. + * Default values: FirstName, LastName, and Address information of the Shipping object if any, otherwise the user (author). + * @var Billing + */ + public $Billing; + + /** + * Information about the end user’s shipping address. If left empty, the default values will be automatically taken into account. + * Default values: FirstName, LastName, and Address information of the Billing object, if supplied, otherwise of the user (author). + * @var Shipping + */ + public $Shipping; + /** * Allowed values: ECommerce (default), TelephoneOrder * diff --git a/MangoPay/PayOut.php b/MangoPay/PayOut.php index 0f10bff8..a8cc28f7 100644 --- a/MangoPay/PayOut.php +++ b/MangoPay/PayOut.php @@ -7,6 +7,20 @@ */ class PayOut extends Transaction { + /** + * The unique identifier of the bank account. + * + * @var string + */ + public $BankAccountId; + + /** + * Custom description to appear on the user’s bank statement along with the platform name. + * The recommended length is 12 characters – strings longer than this may be truncated depending on the bank. + * @var string + */ + public $BankWireRef; + /** * Debited wallet Id * @var string @@ -19,12 +33,24 @@ class PayOut extends Transaction */ public $PaymentType; + /** + * One of PayOutPaymentDetails implementations, depending on $PaymentType + * @var object + */ + public $PayoutPaymentDetails; + /** * One of PayOutPaymentDetails implementations, depending on $PaymentType * @var object */ public $MeanOfPaymentDetails; + /** + * Payout mode requested, default is 'STANDARD', Allowed values are + * 'STANDARD', 'INSTANT_PAYMENT', 'INSTANT_PAYMENT_ONLY' + * @var string + */ + public $PayoutModeRequested; /** * Get array with mapping which property depends on other property diff --git a/MangoPay/Refund.php b/MangoPay/Refund.php index c3c01571..0660d240 100644 --- a/MangoPay/Refund.php +++ b/MangoPay/Refund.php @@ -37,6 +37,12 @@ class Refund extends Transaction */ public $RefundReason; + /** + * Message related to the refund + * @var string + */ + public $RefundReasonMessage; + /** * @var string */ diff --git a/MangoPay/UboDeclaration.php b/MangoPay/UboDeclaration.php index 7b30f6b5..399acc00 100644 --- a/MangoPay/UboDeclaration.php +++ b/MangoPay/UboDeclaration.php @@ -8,7 +8,8 @@ class UboDeclaration extends Libraries\EntityBase { /** - * @var int Unix timestamp, Date of process + * The Declaration process date. + * @var int Unix timestamp, Date of the process */ public $ProcessedDate; @@ -19,6 +20,12 @@ class UboDeclaration extends Libraries\EntityBase */ public $Status; + /** + * The output status of Declaration status. + * @var string + */ + public $OutputStatus; + /** * List of reasons why the declaration was refused. * @var string diff --git a/composer.json b/composer.json index 0b07c1c1..840755b8 100644 --- a/composer.json +++ b/composer.json @@ -22,6 +22,6 @@ }, "require-dev": { "phpunit/phpunit": ">=5.7.27 <10", - "friendsofphp/php-cs-fixer": "^2.18" + "friendsofphp/php-cs-fixer": "^3.54" } } diff --git a/php_env/PHP_8.1/Dockerfile b/php_env/PHP_8.1/Dockerfile new file mode 100644 index 00000000..15b2e86f --- /dev/null +++ b/php_env/PHP_8.1/Dockerfile @@ -0,0 +1,24 @@ +FROM php:8.1-cli + +# Update and import specific required librairies + +RUN apt-get update && apt-get install -y apt-utils +RUN apt-get install -y \ + unzip \ + libicu-dev \ + libonig-dev \ + gcc \ + wget \ + zlib1g-dev \ + libzip-dev + +# Parametrize PHP + +RUN docker-php-ext-install mbstring +RUN docker-php-ext-install intl +RUN docker-php-ext-install zip +RUN docker-php-ext-install pcntl +RUN docker-php-source delete + +# Install composer +COPY --from=composer:2 /usr/bin/composer /usr/bin/composer diff --git a/php_env/PHP_8.2/Dockerfile b/php_env/PHP_8.2/Dockerfile new file mode 100644 index 00000000..266375cb --- /dev/null +++ b/php_env/PHP_8.2/Dockerfile @@ -0,0 +1,28 @@ +FROM php:8.2-cli + +# Update and import specific required librairies + +RUN apt-get update && apt-get install -y apt-utils +RUN apt-get install -y \ + unzip \ + libicu-dev \ + libonig-dev \ + gcc \ + wget \ + zlib1g-dev \ + libzip-dev + +# Parametrize PHP + +RUN docker-php-ext-install mbstring +RUN docker-php-ext-install intl +RUN docker-php-ext-install zip +RUN docker-php-ext-install pcntl +RUN docker-php-source delete + +# Install composer +COPY composer.sh / +RUN chmod +x composer.sh +RUN /composer.sh +RUN mv composer.phar /usr/local/bin/composer +RUN mkdir /.composer && chmod o+rwx /.composer