From 43dbac1e07a833bb8a8ebed50f01d5da7339b305 Mon Sep 17 00:00:00 2001 From: Miguel Vela Romera Date: Tue, 22 Dec 2020 17:33:06 +0100 Subject: [PATCH] release v7.0.0 --- README.md | 26 ++- composer.json | 2 +- .../Service/Builder/Checkout/RequestBody.php | 13 +- .../Builder/Checkout/RequestThreeDSecure.php | 78 ++++++++ .../Composite/Checkout/RequestBody.php | 24 ++- .../Checkout/RequestThreeDSecure.php | 115 +++++++++++ .../Builder/Payment/ResponseThreeDSecure.php | 32 ++- .../Builder/ThreeDSecureAdditionalInfo.php | 85 ++++++++ .../Service/Builder/ThreeDSecureExemption.php | 85 ++++++++ .../Builder/ThreeDSecureRecurringInfo.php | 65 +++++++ .../ValueObject/Checkout/RequestBody.php | 18 +- .../Checkout/RequestThreeDSecure.php | 91 +++++++++ .../Payment/ResponseThreeDSecure.php | 69 ++++++- .../ThreeDSecureAdditionalInfo.php | 103 ++++++++++ .../ValueObject/ThreeDSecureExemption.php | 103 ++++++++++ .../ValueObject/ThreeDSecureRecurringInfo.php | 71 +++++++ .../Builder/Composite/Link/RequestBody.php | 58 ++++-- .../Composite/Link/RequestThreeDSecure.php | 115 +++++++++++ .../Service/Builder/Link/RequestBody.php | 29 ++- .../Builder/Link/RequestThreeDSecure.php | 78 ++++++++ .../Builder/ThreeDSecureAdditionalInfo.php | 85 ++++++++ .../Service/Builder/ThreeDSecureExemption.php | 85 ++++++++ .../Builder/ThreeDSecureRecurringInfo.php | 65 +++++++ .../ValueObject/Link/RequestBody.php | 44 +++-- .../ValueObject/Link/RequestThreeDSecure.php | 91 +++++++++ .../ThreeDSecureAdditionalInfo.php | 103 ++++++++++ .../ValueObject/ThreeDSecureExemption.php | 103 ++++++++++ .../ValueObject/ThreeDSecureRecurringInfo.php | 71 +++++++ .../Builder/Composite/Payment/RequestBody.php | 2 +- .../Composite/Payment/RequestThreeDSecure.php | 165 ++++++++++++++++ .../Builder/Payment/RequestThreeDSecure.php | 57 +++++- .../Builder/Payment/RequestTransaction.php | 108 +++++----- .../Builder/Payment/ResponseThreeDSecure.php | 32 ++- .../Builder/ThreeDSecureAdditionalInfo.php | 85 ++++++++ .../Service/Builder/ThreeDSecureExemption.php | 85 ++++++++ .../Builder/ThreeDSecureRecurringInfo.php | 65 +++++++ .../Payment/RequestThreeDSecure.php | 94 ++++++++- .../Payment/RequestTransaction.php | 184 +++++++++--------- .../Payment/ResponseThreeDSecure.php | 69 ++++++- .../ThreeDSecureAdditionalInfo.php | 103 ++++++++++ .../ValueObject/ThreeDSecureExemption.php | 103 ++++++++++ .../ValueObject/ThreeDSecureRecurringInfo.php | 71 +++++++ tests/Test/Api/AbstractPaymentTest.php | 15 +- .../Unit/Application/Request/BuilderTest.php | 4 +- 44 files changed, 2942 insertions(+), 207 deletions(-) create mode 100644 src/Domain/Checkouts/Service/Builder/Checkout/RequestThreeDSecure.php create mode 100644 src/Domain/Checkouts/Service/Builder/Composite/Checkout/RequestThreeDSecure.php create mode 100644 src/Domain/Checkouts/Service/Builder/ThreeDSecureAdditionalInfo.php create mode 100644 src/Domain/Checkouts/Service/Builder/ThreeDSecureExemption.php create mode 100644 src/Domain/Checkouts/Service/Builder/ThreeDSecureRecurringInfo.php create mode 100644 src/Domain/Checkouts/ValueObject/Checkout/RequestThreeDSecure.php create mode 100644 src/Domain/Checkouts/ValueObject/ThreeDSecureAdditionalInfo.php create mode 100644 src/Domain/Checkouts/ValueObject/ThreeDSecureExemption.php create mode 100644 src/Domain/Checkouts/ValueObject/ThreeDSecureRecurringInfo.php create mode 100644 src/Domain/Paymentlinks/Service/Builder/Composite/Link/RequestThreeDSecure.php create mode 100644 src/Domain/Paymentlinks/Service/Builder/Link/RequestThreeDSecure.php create mode 100644 src/Domain/Paymentlinks/Service/Builder/ThreeDSecureAdditionalInfo.php create mode 100644 src/Domain/Paymentlinks/Service/Builder/ThreeDSecureExemption.php create mode 100644 src/Domain/Paymentlinks/Service/Builder/ThreeDSecureRecurringInfo.php create mode 100644 src/Domain/Paymentlinks/ValueObject/Link/RequestThreeDSecure.php create mode 100644 src/Domain/Paymentlinks/ValueObject/ThreeDSecureAdditionalInfo.php create mode 100644 src/Domain/Paymentlinks/ValueObject/ThreeDSecureExemption.php create mode 100644 src/Domain/Paymentlinks/ValueObject/ThreeDSecureRecurringInfo.php create mode 100644 src/Domain/Payments/Service/Builder/Composite/Payment/RequestThreeDSecure.php create mode 100644 src/Domain/Payments/Service/Builder/ThreeDSecureAdditionalInfo.php create mode 100644 src/Domain/Payments/Service/Builder/ThreeDSecureExemption.php create mode 100644 src/Domain/Payments/Service/Builder/ThreeDSecureRecurringInfo.php create mode 100644 src/Domain/Payments/ValueObject/ThreeDSecureAdditionalInfo.php create mode 100644 src/Domain/Payments/ValueObject/ThreeDSecureExemption.php create mode 100644 src/Domain/Payments/ValueObject/ThreeDSecureRecurringInfo.php diff --git a/README.md b/README.md index 9d66930..3b6fd40 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ The debug-property is passed through to the Guzzle Client. See for more information about debugging. -### Creating a payment request +### Creating a request The PHP SDK is a direct reflection of how the JSON structure of the requests and responses are typically built for the Payvision API. @@ -114,6 +114,30 @@ Now we have an API Request that we can execute using our API Connection: $requestHeaders = []; // Optional request headers $apiResponse = $apiConnection->execute($apiRequest, $requestHeaders); +#### About builders + +It is **strongly recommended** that you always use the builders provided +by the SDK to create your objects, and never directly instantiate them. +The reason behind this is that the method signature of the +constructor call of a value object can change quite often as the API +specification grows. This can quickly lead to backward compatible breaking +changes in your code. Builders overcome this problem by abstracting the +creation of value objects. And they're also a lot cleaner to work with. + +#### Handling an array as response + +Some API endpoints will not return a single object, but rather an array +of objects. The [GET payments](https://developers.acehubpaymentservices.com/v3.3/reference#get-payment-by-tracking-code-2) +endpoint is an example of this. + +In this case, where you as a developer know that you can expect an array +as a result, you need to use the `ApiConnection::executeAndReturnArray()`-method +instead of the `execute()`-method: + + $apiRequest = RequestBuilder::getPayments($businessId, $trackingCode); + $apiResponses = $apiConnection->executeAndReturnArray($apiRequest); + $apiResponse = $apiResponses[0]; // for example + ### Handling the responses The `$apiResponse` in the above example is an object of the type that is diff --git a/composer.json b/composer.json index b9b5342..6653236 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "payvision/payvision-sdk-php", "description": "Payvision PHP SDK", "type": "library", - "version": "6.0.0", + "version": "7.0.0", "license": "MIT", "require": { "php": "~7.1.3||~7.2.5||~7.3.0||~7.4.0", diff --git a/src/Domain/Checkouts/Service/Builder/Checkout/RequestBody.php b/src/Domain/Checkouts/Service/Builder/Checkout/RequestBody.php index 8d8243d..71e6b19 100644 --- a/src/Domain/Checkouts/Service/Builder/Checkout/RequestBody.php +++ b/src/Domain/Checkouts/Service/Builder/Checkout/RequestBody.php @@ -20,6 +20,7 @@ use Payvision\SDK\Domain\Checkouts\ValueObject\Checkout\RequestOption; use Payvision\SDK\Domain\Checkouts\ValueObject\Checkout\RequestOrder; use Payvision\SDK\Domain\Checkouts\ValueObject\Checkout\RequestShippingAddress; +use Payvision\SDK\Domain\Checkouts\ValueObject\Checkout\RequestThreeDSecure; use Payvision\SDK\Domain\Service\Builder\Basic; class RequestBody extends Basic @@ -104,6 +105,15 @@ public function setShippingAddress(RequestShippingAddress $shippingAddress): Req return $this->set('shippingAddress', $shippingAddress); } + /** + * @param RequestThreeDSecure $threeDSecure + * @return RequestBody + */ + public function setThreeDSecure(RequestThreeDSecure $threeDSecure): RequestBody + { + return $this->set('threeDSecure', $threeDSecure); + } + /** * @return RequestBodyObject */ @@ -117,7 +127,8 @@ protected function buildObject(): RequestBodyObject $this->get('dba'), $this->get('option'), $this->get('order'), - $this->get('shippingAddress') + $this->get('shippingAddress'), + $this->get('threeDSecure') ); } } diff --git a/src/Domain/Checkouts/Service/Builder/Checkout/RequestThreeDSecure.php b/src/Domain/Checkouts/Service/Builder/Checkout/RequestThreeDSecure.php new file mode 100644 index 0000000..0997c58 --- /dev/null +++ b/src/Domain/Checkouts/Service/Builder/Checkout/RequestThreeDSecure.php @@ -0,0 +1,78 @@ +buildAndReset(); + } + + /** + * @param ThreeDSecureAdditionalInfo $additionalInfo + * @return RequestThreeDSecure + */ + public function setAdditionalInfo(ThreeDSecureAdditionalInfo $additionalInfo): RequestThreeDSecure + { + return $this->set('additionalInfo', $additionalInfo); + } + + /** + * @param ThreeDSecureExemption $exemption + * @return RequestThreeDSecure + */ + public function setExemption(ThreeDSecureExemption $exemption): RequestThreeDSecure + { + return $this->set('exemption', $exemption); + } + + /** + * @param ThreeDSecureRecurringInfo $recurringInfo + * @return RequestThreeDSecure + */ + public function setRecurringInfo(ThreeDSecureRecurringInfo $recurringInfo): RequestThreeDSecure + { + return $this->set('recurringInfo', $recurringInfo); + } + + /** + * @param string $version + * @return RequestThreeDSecure + */ + public function setVersion(string $version): RequestThreeDSecure + { + return $this->set('version', $version); + } + + /** + * @return RequestThreeDSecureObject + */ + protected function buildObject(): RequestThreeDSecureObject + { + return new RequestThreeDSecureObject( + $this->get('additionalInfo'), + $this->get('exemption'), + $this->get('recurringInfo'), + $this->get('version') + ); + } +} diff --git a/src/Domain/Checkouts/Service/Builder/Composite/Checkout/RequestBody.php b/src/Domain/Checkouts/Service/Builder/Composite/Checkout/RequestBody.php index 9eaf13b..b0dd48e 100644 --- a/src/Domain/Checkouts/Service/Builder/Composite/Checkout/RequestBody.php +++ b/src/Domain/Checkouts/Service/Builder/Composite/Checkout/RequestBody.php @@ -20,6 +20,7 @@ use Payvision\SDK\Domain\Checkouts\Service\Builder\Checkout\RequestOption as RequestOptionBuilder; use Payvision\SDK\Domain\Checkouts\Service\Builder\Checkout\RequestOrder as RequestOrderBuilder; use Payvision\SDK\Domain\Checkouts\Service\Builder\Composite\Checkout\RequestShippingAddress as RequestShippingAddressBuilder; +use Payvision\SDK\Domain\Checkouts\Service\Builder\Composite\Checkout\RequestThreeDSecure as RequestThreeDSecureBuilder; use Payvision\SDK\Domain\Service\Builder\Basic; class RequestBody extends Basic @@ -104,6 +105,16 @@ class RequestBody extends Basic */ private $isShippingAddressBuilderTouched = false; + /** + * @var RequestThreeDSecureBuilder + */ + private $threeDSecureBuilder; + + /** + * @var bool + */ + private $isThreeDSecureBuilderTouched = false; + public function __construct() { $this->checkoutBuilder = new RequestCheckoutBuilder(); @@ -114,6 +125,7 @@ public function __construct() $this->optionBuilder = new RequestOptionBuilder(); $this->orderBuilder = new RequestOrderBuilder(); $this->shippingAddressBuilder = new RequestShippingAddressBuilder(); + $this->threeDSecureBuilder = new RequestThreeDSecureBuilder(); } /** @@ -196,6 +208,15 @@ public function shippingAddress(): RequestShippingAddressBuilder return $this->shippingAddressBuilder; } + /** + * @return RequestThreeDSecureBuilder + */ + public function threeDSecure(): RequestThreeDSecureBuilder + { + $this->isThreeDSecureBuilderTouched = true; + return $this->threeDSecureBuilder; + } + /** * @return RequestBodyObject */ @@ -209,7 +230,8 @@ protected function buildObject(): RequestBodyObject $this->isDbaBuilderTouched ? $this->dbaBuilder->build() : null, $this->isOptionBuilderTouched ? $this->optionBuilder->build() : null, $this->isOrderBuilderTouched ? $this->orderBuilder->build() : null, - $this->isShippingAddressBuilderTouched ? $this->shippingAddressBuilder->build() : null + $this->isShippingAddressBuilderTouched ? $this->shippingAddressBuilder->build() : null, + $this->isThreeDSecureBuilderTouched ? $this->threeDSecureBuilder->build() : null ); } } diff --git a/src/Domain/Checkouts/Service/Builder/Composite/Checkout/RequestThreeDSecure.php b/src/Domain/Checkouts/Service/Builder/Composite/Checkout/RequestThreeDSecure.php new file mode 100644 index 0000000..1ffc6f2 --- /dev/null +++ b/src/Domain/Checkouts/Service/Builder/Composite/Checkout/RequestThreeDSecure.php @@ -0,0 +1,115 @@ +additionalInfoBuilder = new ThreeDSecureAdditionalInfoBuilder(); + $this->exemptionBuilder = new ThreeDSecureExemptionBuilder(); + $this->recurringInfoBuilder = new ThreeDSecureRecurringInfoBuilder(); + } + + /** + * @return RequestThreeDSecureObject + */ + public function build(): RequestThreeDSecureObject + { + return $this->buildAndReset(); + } + + /** + * @return ThreeDSecureAdditionalInfoBuilder + */ + public function additionalInfo(): ThreeDSecureAdditionalInfoBuilder + { + $this->isAdditionalInfoBuilderTouched = true; + return $this->additionalInfoBuilder; + } + + /** + * @return ThreeDSecureExemptionBuilder + */ + public function exemption(): ThreeDSecureExemptionBuilder + { + $this->isExemptionBuilderTouched = true; + return $this->exemptionBuilder; + } + + /** + * @return ThreeDSecureRecurringInfoBuilder + */ + public function recurringInfo(): ThreeDSecureRecurringInfoBuilder + { + $this->isRecurringInfoBuilderTouched = true; + return $this->recurringInfoBuilder; + } + + /** + * @param string $version + * @return RequestThreeDSecure + */ + public function setVersion(string $version): RequestThreeDSecure + { + return $this->set('version', $version); + } + + /** + * @return RequestThreeDSecureObject + */ + protected function buildObject(): RequestThreeDSecureObject + { + return new RequestThreeDSecureObject( + $this->isAdditionalInfoBuilderTouched ? $this->additionalInfoBuilder->build() : null, + $this->isExemptionBuilderTouched ? $this->exemptionBuilder->build() : null, + $this->isRecurringInfoBuilderTouched ? $this->recurringInfoBuilder->build() : null, + $this->get('version') + ); + } +} diff --git a/src/Domain/Checkouts/Service/Builder/Payment/ResponseThreeDSecure.php b/src/Domain/Checkouts/Service/Builder/Payment/ResponseThreeDSecure.php index 9c00820..5069757 100644 --- a/src/Domain/Checkouts/Service/Builder/Payment/ResponseThreeDSecure.php +++ b/src/Domain/Checkouts/Service/Builder/Payment/ResponseThreeDSecure.php @@ -24,6 +24,15 @@ public function build(): ResponseThreeDSecureObject return $this->buildAndReset(); } + /** + * @param string $authenticationResult + * @return ResponseThreeDSecure + */ + public function setAuthenticationResult(string $authenticationResult): ResponseThreeDSecure + { + return $this->set('authenticationResult', $authenticationResult); + } + /** * @param string $enrollmentResult * @return ResponseThreeDSecure @@ -33,6 +42,15 @@ public function setEnrollmentResult(string $enrollmentResult): ResponseThreeDSec return $this->set('enrollmentResult', $enrollmentResult); } + /** + * @param string $flow + * @return ResponseThreeDSecure + */ + public function setFlow(string $flow): ResponseThreeDSecure + { + return $this->set('flow', $flow); + } + /** * @param string $validationResult * @return ResponseThreeDSecure @@ -42,14 +60,26 @@ public function setValidationResult(string $validationResult): ResponseThreeDSec return $this->set('validationResult', $validationResult); } + /** + * @param string $version + * @return ResponseThreeDSecure + */ + public function setVersion(string $version): ResponseThreeDSecure + { + return $this->set('version', $version); + } + /** * @return ResponseThreeDSecureObject */ protected function buildObject(): ResponseThreeDSecureObject { return new ResponseThreeDSecureObject( + $this->get('authenticationResult'), $this->get('enrollmentResult'), - $this->get('validationResult') + $this->get('flow'), + $this->get('validationResult'), + $this->get('version') ); } } diff --git a/src/Domain/Checkouts/Service/Builder/ThreeDSecureAdditionalInfo.php b/src/Domain/Checkouts/Service/Builder/ThreeDSecureAdditionalInfo.php new file mode 100644 index 0000000..5b9da89 --- /dev/null +++ b/src/Domain/Checkouts/Service/Builder/ThreeDSecureAdditionalInfo.php @@ -0,0 +1,85 @@ +buildAndReset(); + } + + /** + * @param string $challengeIndicator + * @return ThreeDSecureAdditionalInfo + */ + public function setChallengeIndicator(string $challengeIndicator): ThreeDSecureAdditionalInfo + { + return $this->set('challengeIndicator', $challengeIndicator); + } + + /** + * @param string $challengeWindowSize + * @return ThreeDSecureAdditionalInfo + */ + public function setChallengeWindowSize(string $challengeWindowSize): ThreeDSecureAdditionalInfo + { + return $this->set('challengeWindowSize', $challengeWindowSize); + } + + /** + * @param string $decoupledIndicator + * @return ThreeDSecureAdditionalInfo + */ + public function setDecoupledIndicator(string $decoupledIndicator): ThreeDSecureAdditionalInfo + { + return $this->set('decoupledIndicator', $decoupledIndicator); + } + + /** + * @param int $decoupledMaxTime + * @return ThreeDSecureAdditionalInfo + */ + public function setDecoupledMaxTime(int $decoupledMaxTime): ThreeDSecureAdditionalInfo + { + return $this->set('decoupledMaxTime', $decoupledMaxTime); + } + + /** + * @param int $merchantFraudRate + * @return ThreeDSecureAdditionalInfo + */ + public function setMerchantFraudRate(int $merchantFraudRate): ThreeDSecureAdditionalInfo + { + return $this->set('merchantFraudRate', $merchantFraudRate); + } + + /** + * @return ThreeDSecureAdditionalInfoObject + */ + protected function buildObject(): ThreeDSecureAdditionalInfoObject + { + return new ThreeDSecureAdditionalInfoObject( + $this->get('challengeIndicator'), + $this->get('challengeWindowSize'), + $this->get('decoupledIndicator'), + $this->get('decoupledMaxTime'), + $this->get('merchantFraudRate') + ); + } +} diff --git a/src/Domain/Checkouts/Service/Builder/ThreeDSecureExemption.php b/src/Domain/Checkouts/Service/Builder/ThreeDSecureExemption.php new file mode 100644 index 0000000..9757fa8 --- /dev/null +++ b/src/Domain/Checkouts/Service/Builder/ThreeDSecureExemption.php @@ -0,0 +1,85 @@ +buildAndReset(); + } + + /** + * @param bool $lowValue + * @return ThreeDSecureExemption + */ + public function setLowValue(bool $lowValue): ThreeDSecureExemption + { + return $this->set('lowValue', $lowValue); + } + + /** + * @param bool $secureCoorporate + * @return ThreeDSecureExemption + */ + public function setSecureCoorporate(bool $secureCoorporate): ThreeDSecureExemption + { + return $this->set('secureCoorporate', $secureCoorporate); + } + + /** + * @param bool $transactionRiskAnalysis + * @return ThreeDSecureExemption + */ + public function setTransactionRiskAnalysis(bool $transactionRiskAnalysis): ThreeDSecureExemption + { + return $this->set('transactionRiskAnalysis', $transactionRiskAnalysis); + } + + /** + * @param bool $trustedBeneficiary + * @return ThreeDSecureExemption + */ + public function setTrustedBeneficiary(bool $trustedBeneficiary): ThreeDSecureExemption + { + return $this->set('trustedBeneficiary', $trustedBeneficiary); + } + + /** + * @param string $vmid + * @return ThreeDSecureExemption + */ + public function setVmid(string $vmid): ThreeDSecureExemption + { + return $this->set('vmid', $vmid); + } + + /** + * @return ThreeDSecureExemptionObject + */ + protected function buildObject(): ThreeDSecureExemptionObject + { + return new ThreeDSecureExemptionObject( + $this->get('lowValue'), + $this->get('secureCoorporate'), + $this->get('transactionRiskAnalysis'), + $this->get('trustedBeneficiary'), + $this->get('vmid') + ); + } +} diff --git a/src/Domain/Checkouts/Service/Builder/ThreeDSecureRecurringInfo.php b/src/Domain/Checkouts/Service/Builder/ThreeDSecureRecurringInfo.php new file mode 100644 index 0000000..017da01 --- /dev/null +++ b/src/Domain/Checkouts/Service/Builder/ThreeDSecureRecurringInfo.php @@ -0,0 +1,65 @@ +buildAndReset(); + } + + /** + * @param \Payvision\SDK\DataType\DateTime $purchaseDate + * @return ThreeDSecureRecurringInfo + */ + public function setPurchaseDate(\Payvision\SDK\DataType\DateTime $purchaseDate): ThreeDSecureRecurringInfo + { + return $this->set('purchaseDate', $purchaseDate); + } + + /** + * @param \Payvision\SDK\DataType\Date $recurringEnd + * @return ThreeDSecureRecurringInfo + */ + public function setRecurringEnd(\Payvision\SDK\DataType\Date $recurringEnd): ThreeDSecureRecurringInfo + { + return $this->set('recurringEnd', $recurringEnd); + } + + /** + * @param int $recurringFrequency + * @return ThreeDSecureRecurringInfo + */ + public function setRecurringFrequency(int $recurringFrequency): ThreeDSecureRecurringInfo + { + return $this->set('recurringFrequency', $recurringFrequency); + } + + /** + * @return ThreeDSecureRecurringInfoObject + */ + protected function buildObject(): ThreeDSecureRecurringInfoObject + { + return new ThreeDSecureRecurringInfoObject( + $this->get('purchaseDate'), + $this->get('recurringEnd'), + $this->get('recurringFrequency') + ); + } +} diff --git a/src/Domain/Checkouts/ValueObject/Checkout/RequestBody.php b/src/Domain/Checkouts/ValueObject/Checkout/RequestBody.php index e26253d..08dae99 100644 --- a/src/Domain/Checkouts/ValueObject/Checkout/RequestBody.php +++ b/src/Domain/Checkouts/ValueObject/Checkout/RequestBody.php @@ -55,6 +55,11 @@ class RequestBody */ private $shippingAddress; + /** + * @var RequestThreeDSecure + */ + private $threeDSecure; + /** * RequestBody constructor. * @@ -66,6 +71,7 @@ class RequestBody * @param RequestOption $option * @param RequestOrder $order * @param RequestShippingAddress $shippingAddress + * @param RequestThreeDSecure $threeDSecure */ public function __construct( RequestCheckout $checkout, @@ -75,7 +81,8 @@ public function __construct( RequestDba $dba = null, RequestOption $option = null, RequestOrder $order = null, - RequestShippingAddress $shippingAddress = null + RequestShippingAddress $shippingAddress = null, + RequestThreeDSecure $threeDSecure = null ) { $this->checkout = $checkout; $this->transaction = $transaction; @@ -85,6 +92,7 @@ public function __construct( $this->option = $option; $this->order = $order; $this->shippingAddress = $shippingAddress; + $this->threeDSecure = $threeDSecure; } /** @@ -150,4 +158,12 @@ public function getShippingAddress(): ?RequestShippingAddress { return $this->shippingAddress; } + + /** + * @return RequestThreeDSecure|null + */ + public function getThreeDSecure(): ?RequestThreeDSecure + { + return $this->threeDSecure; + } } diff --git a/src/Domain/Checkouts/ValueObject/Checkout/RequestThreeDSecure.php b/src/Domain/Checkouts/ValueObject/Checkout/RequestThreeDSecure.php new file mode 100644 index 0000000..4ce0640 --- /dev/null +++ b/src/Domain/Checkouts/ValueObject/Checkout/RequestThreeDSecure.php @@ -0,0 +1,91 @@ +additionalInfo = $additionalInfo; + $this->exemption = $exemption; + $this->recurringInfo = $recurringInfo; + $this->version = $version; + } + + /** + * @return ThreeDSecureAdditionalInfo|null + */ + public function getAdditionalInfo(): ?ThreeDSecureAdditionalInfo + { + return $this->additionalInfo; + } + + /** + * @return ThreeDSecureExemption|null + */ + public function getExemption(): ?ThreeDSecureExemption + { + return $this->exemption; + } + + /** + * @return ThreeDSecureRecurringInfo|null + */ + public function getRecurringInfo(): ?ThreeDSecureRecurringInfo + { + return $this->recurringInfo; + } + + /** + * @return string|null + */ + public function getVersion(): ?string + { + return $this->version; + } +} diff --git a/src/Domain/Checkouts/ValueObject/Payment/ResponseThreeDSecure.php b/src/Domain/Checkouts/ValueObject/Payment/ResponseThreeDSecure.php index 65d7882..bf7ed7a 100644 --- a/src/Domain/Checkouts/ValueObject/Payment/ResponseThreeDSecure.php +++ b/src/Domain/Checkouts/ValueObject/Payment/ResponseThreeDSecure.php @@ -13,28 +13,79 @@ class ResponseThreeDSecure { + public const ENROLLMENT_RESULT_AUTHENTICATED = 'Y'; + public const ENROLLMENT_RESULT_ATTEMPTED = 'A'; + public const ENROLLMENT_RESULT_INVALID = 'N'; + public const ENROLLMENT_RESULT_BYPASSED = 'B'; + + public const VALIDATION_RESULT_AUTHENTICATED = 'Y'; + public const VALIDATION_RESULT_ATTEMPTED = 'A'; + public const VALIDATION_RESULT_UNAVAILABLE = 'U'; + public const VALIDATION_RESULT_INVALID = 'N'; + + public const AUTHENTICATION_RESULT_AUTHENTICATED = 'Y'; + public const AUTHENTICATION_RESULT_ATTEMPTED = 'A'; + public const AUTHENTICATION_RESULT_FAILED = 'N'; + public const AUTHENTICATION_RESULT_UNAVAILABLE = 'U'; + public const AUTHENTICATION_RESULT_REJECTED = 'R'; + + public const FLOW_FRICTIONLESS = 'FRICTIONLESS'; + public const FLOW_CHALLENGE = 'CHALLENGE'; + + /** + * @var string + */ + private $authenticationResult; + /** * @var string */ private $enrollmentResult; + /** + * @var string + */ + private $flow; + /** * @var string */ private $validationResult; + /** + * @var string + */ + private $version; + /** * ResponseThreeDSecure constructor. * + * @param string $authenticationResult * @param string $enrollmentResult + * @param string $flow * @param string $validationResult + * @param string $version */ public function __construct( + string $authenticationResult = null, string $enrollmentResult = null, - string $validationResult = null + string $flow = null, + string $validationResult = null, + string $version = null ) { + $this->authenticationResult = $authenticationResult; $this->enrollmentResult = $enrollmentResult; + $this->flow = $flow; $this->validationResult = $validationResult; + $this->version = $version; + } + + /** + * @return string|null + */ + public function getAuthenticationResult(): ?string + { + return $this->authenticationResult; } /** @@ -45,6 +96,14 @@ public function getEnrollmentResult(): ?string return $this->enrollmentResult; } + /** + * @return string|null + */ + public function getFlow(): ?string + { + return $this->flow; + } + /** * @return string|null */ @@ -52,4 +111,12 @@ public function getValidationResult(): ?string { return $this->validationResult; } + + /** + * @return string|null + */ + public function getVersion(): ?string + { + return $this->version; + } } diff --git a/src/Domain/Checkouts/ValueObject/ThreeDSecureAdditionalInfo.php b/src/Domain/Checkouts/ValueObject/ThreeDSecureAdditionalInfo.php new file mode 100644 index 0000000..93fe23c --- /dev/null +++ b/src/Domain/Checkouts/ValueObject/ThreeDSecureAdditionalInfo.php @@ -0,0 +1,103 @@ +challengeIndicator = $challengeIndicator; + $this->challengeWindowSize = $challengeWindowSize; + $this->decoupledIndicator = $decoupledIndicator; + $this->decoupledMaxTime = $decoupledMaxTime; + $this->merchantFraudRate = $merchantFraudRate; + } + + /** + * @return string|null + */ + public function getChallengeIndicator(): ?string + { + return $this->challengeIndicator; + } + + /** + * @return string|null + */ + public function getChallengeWindowSize(): ?string + { + return $this->challengeWindowSize; + } + + /** + * @return string|null + */ + public function getDecoupledIndicator(): ?string + { + return $this->decoupledIndicator; + } + + /** + * @return int|null + */ + public function getDecoupledMaxTime(): ?int + { + return $this->decoupledMaxTime; + } + + /** + * @return int|null + */ + public function getMerchantFraudRate(): ?int + { + return $this->merchantFraudRate; + } +} diff --git a/src/Domain/Checkouts/ValueObject/ThreeDSecureExemption.php b/src/Domain/Checkouts/ValueObject/ThreeDSecureExemption.php new file mode 100644 index 0000000..b0fa3d9 --- /dev/null +++ b/src/Domain/Checkouts/ValueObject/ThreeDSecureExemption.php @@ -0,0 +1,103 @@ +lowValue = $lowValue; + $this->secureCoorporate = $secureCoorporate; + $this->transactionRiskAnalysis = $transactionRiskAnalysis; + $this->trustedBeneficiary = $trustedBeneficiary; + $this->vmid = $vmid; + } + + /** + * @return bool|null + */ + public function getLowValue(): ?bool + { + return $this->lowValue; + } + + /** + * @return bool|null + */ + public function getSecureCoorporate(): ?bool + { + return $this->secureCoorporate; + } + + /** + * @return bool|null + */ + public function getTransactionRiskAnalysis(): ?bool + { + return $this->transactionRiskAnalysis; + } + + /** + * @return bool|null + */ + public function getTrustedBeneficiary(): ?bool + { + return $this->trustedBeneficiary; + } + + /** + * @return string|null + */ + public function getVmid(): ?string + { + return $this->vmid; + } +} diff --git a/src/Domain/Checkouts/ValueObject/ThreeDSecureRecurringInfo.php b/src/Domain/Checkouts/ValueObject/ThreeDSecureRecurringInfo.php new file mode 100644 index 0000000..46f28c4 --- /dev/null +++ b/src/Domain/Checkouts/ValueObject/ThreeDSecureRecurringInfo.php @@ -0,0 +1,71 @@ +purchaseDate = $purchaseDate; + $this->recurringEnd = $recurringEnd; + $this->recurringFrequency = $recurringFrequency; + } + + /** + * @return \Payvision\SDK\DataType\DateTime|null + */ + public function getPurchaseDate(): ?\Payvision\SDK\DataType\DateTime + { + return $this->purchaseDate; + } + + /** + * @return \Payvision\SDK\DataType\Date|null + */ + public function getRecurringEnd(): ?\Payvision\SDK\DataType\Date + { + return $this->recurringEnd; + } + + /** + * @return int|null + */ + public function getRecurringFrequency(): ?int + { + return $this->recurringFrequency; + } +} diff --git a/src/Domain/Paymentlinks/Service/Builder/Composite/Link/RequestBody.php b/src/Domain/Paymentlinks/Service/Builder/Composite/Link/RequestBody.php index c42394a..4171586 100644 --- a/src/Domain/Paymentlinks/Service/Builder/Composite/Link/RequestBody.php +++ b/src/Domain/Paymentlinks/Service/Builder/Composite/Link/RequestBody.php @@ -12,35 +12,36 @@ namespace Payvision\SDK\Domain\Paymentlinks\Service\Builder\Composite\Link; use Payvision\SDK\Domain\Paymentlinks\ValueObject\Link\RequestBody as RequestBodyObject; -use Payvision\SDK\Domain\Paymentlinks\Service\Builder\Link\RequestTransaction as RequestTransactionBuilder; use Payvision\SDK\Domain\Paymentlinks\Service\Builder\Link\RequestLink as RequestLinkBuilder; +use Payvision\SDK\Domain\Paymentlinks\Service\Builder\Link\RequestTransaction as RequestTransactionBuilder; use Payvision\SDK\Domain\Paymentlinks\Service\Builder\BasicAddress as BasicAddressBuilder; use Payvision\SDK\Domain\Paymentlinks\Service\Builder\BasicCustomer as BasicCustomerBuilder; use Payvision\SDK\Domain\Paymentlinks\Service\Builder\Link\RequestDba as RequestDbaBuilder; use Payvision\SDK\Domain\Paymentlinks\Service\Builder\Link\RequestOrder as RequestOrderBuilder; +use Payvision\SDK\Domain\Paymentlinks\Service\Builder\Composite\Link\RequestThreeDSecure as RequestThreeDSecureBuilder; use Payvision\SDK\Domain\Service\Builder\Basic; class RequestBody extends Basic { /** - * @var RequestTransactionBuilder + * @var RequestLinkBuilder */ - private $transactionBuilder; + private $linkBuilder; /** * @var bool */ - private $isTransactionBuilderTouched = false; + private $isLinkBuilderTouched = false; /** - * @var RequestLinkBuilder + * @var RequestTransactionBuilder */ - private $linkBuilder; + private $transactionBuilder; /** * @var bool */ - private $isLinkBuilderTouched = false; + private $isTransactionBuilderTouched = false; /** * @var BasicAddressBuilder @@ -92,15 +93,26 @@ class RequestBody extends Basic */ private $isShippingAddressBuilderTouched = false; + /** + * @var RequestThreeDSecureBuilder + */ + private $threeDSecureBuilder; + + /** + * @var bool + */ + private $isThreeDSecureBuilderTouched = false; + public function __construct() { - $this->transactionBuilder = new RequestTransactionBuilder(); $this->linkBuilder = new RequestLinkBuilder(); + $this->transactionBuilder = new RequestTransactionBuilder(); $this->billingAddressBuilder = new BasicAddressBuilder(); $this->customerBuilder = new BasicCustomerBuilder(); $this->dbaBuilder = new RequestDbaBuilder(); $this->orderBuilder = new RequestOrderBuilder(); $this->shippingAddressBuilder = new BasicAddressBuilder(); + $this->threeDSecureBuilder = new RequestThreeDSecureBuilder(); } /** @@ -112,21 +124,21 @@ public function build(): RequestBodyObject } /** - * @return RequestTransactionBuilder + * @return RequestLinkBuilder */ - public function transaction(): RequestTransactionBuilder + public function link(): RequestLinkBuilder { - $this->isTransactionBuilderTouched = true; - return $this->transactionBuilder; + $this->isLinkBuilderTouched = true; + return $this->linkBuilder; } /** - * @return RequestLinkBuilder + * @return RequestTransactionBuilder */ - public function link(): RequestLinkBuilder + public function transaction(): RequestTransactionBuilder { - $this->isLinkBuilderTouched = true; - return $this->linkBuilder; + $this->isTransactionBuilderTouched = true; + return $this->transactionBuilder; } /** @@ -174,19 +186,29 @@ public function shippingAddress(): BasicAddressBuilder return $this->shippingAddressBuilder; } + /** + * @return RequestThreeDSecureBuilder + */ + public function threeDSecure(): RequestThreeDSecureBuilder + { + $this->isThreeDSecureBuilderTouched = true; + return $this->threeDSecureBuilder; + } + /** * @return RequestBodyObject */ protected function buildObject(): RequestBodyObject { return new RequestBodyObject( - $this->isTransactionBuilderTouched ? $this->transactionBuilder->build() : null, $this->isLinkBuilderTouched ? $this->linkBuilder->build() : null, + $this->isTransactionBuilderTouched ? $this->transactionBuilder->build() : null, $this->isBillingAddressBuilderTouched ? $this->billingAddressBuilder->build() : null, $this->isCustomerBuilderTouched ? $this->customerBuilder->build() : null, $this->isDbaBuilderTouched ? $this->dbaBuilder->build() : null, $this->isOrderBuilderTouched ? $this->orderBuilder->build() : null, - $this->isShippingAddressBuilderTouched ? $this->shippingAddressBuilder->build() : null + $this->isShippingAddressBuilderTouched ? $this->shippingAddressBuilder->build() : null, + $this->isThreeDSecureBuilderTouched ? $this->threeDSecureBuilder->build() : null ); } } diff --git a/src/Domain/Paymentlinks/Service/Builder/Composite/Link/RequestThreeDSecure.php b/src/Domain/Paymentlinks/Service/Builder/Composite/Link/RequestThreeDSecure.php new file mode 100644 index 0000000..f4197aa --- /dev/null +++ b/src/Domain/Paymentlinks/Service/Builder/Composite/Link/RequestThreeDSecure.php @@ -0,0 +1,115 @@ +additionalInfoBuilder = new ThreeDSecureAdditionalInfoBuilder(); + $this->exemptionBuilder = new ThreeDSecureExemptionBuilder(); + $this->recurringInfoBuilder = new ThreeDSecureRecurringInfoBuilder(); + } + + /** + * @return RequestThreeDSecureObject + */ + public function build(): RequestThreeDSecureObject + { + return $this->buildAndReset(); + } + + /** + * @return ThreeDSecureAdditionalInfoBuilder + */ + public function additionalInfo(): ThreeDSecureAdditionalInfoBuilder + { + $this->isAdditionalInfoBuilderTouched = true; + return $this->additionalInfoBuilder; + } + + /** + * @return ThreeDSecureExemptionBuilder + */ + public function exemption(): ThreeDSecureExemptionBuilder + { + $this->isExemptionBuilderTouched = true; + return $this->exemptionBuilder; + } + + /** + * @return ThreeDSecureRecurringInfoBuilder + */ + public function recurringInfo(): ThreeDSecureRecurringInfoBuilder + { + $this->isRecurringInfoBuilderTouched = true; + return $this->recurringInfoBuilder; + } + + /** + * @param string $version + * @return RequestThreeDSecure + */ + public function setVersion(string $version): RequestThreeDSecure + { + return $this->set('version', $version); + } + + /** + * @return RequestThreeDSecureObject + */ + protected function buildObject(): RequestThreeDSecureObject + { + return new RequestThreeDSecureObject( + $this->isAdditionalInfoBuilderTouched ? $this->additionalInfoBuilder->build() : null, + $this->isExemptionBuilderTouched ? $this->exemptionBuilder->build() : null, + $this->isRecurringInfoBuilderTouched ? $this->recurringInfoBuilder->build() : null, + $this->get('version') + ); + } +} diff --git a/src/Domain/Paymentlinks/Service/Builder/Link/RequestBody.php b/src/Domain/Paymentlinks/Service/Builder/Link/RequestBody.php index ff7551f..29416ca 100644 --- a/src/Domain/Paymentlinks/Service/Builder/Link/RequestBody.php +++ b/src/Domain/Paymentlinks/Service/Builder/Link/RequestBody.php @@ -12,12 +12,13 @@ namespace Payvision\SDK\Domain\Paymentlinks\Service\Builder\Link; use Payvision\SDK\Domain\Paymentlinks\ValueObject\Link\RequestBody as RequestBodyObject; -use Payvision\SDK\Domain\Paymentlinks\ValueObject\Link\RequestTransaction; use Payvision\SDK\Domain\Paymentlinks\ValueObject\Link\RequestLink; +use Payvision\SDK\Domain\Paymentlinks\ValueObject\Link\RequestTransaction; use Payvision\SDK\Domain\Paymentlinks\ValueObject\BasicAddress; use Payvision\SDK\Domain\Paymentlinks\ValueObject\BasicCustomer; use Payvision\SDK\Domain\Paymentlinks\ValueObject\Link\RequestDba; use Payvision\SDK\Domain\Paymentlinks\ValueObject\Link\RequestOrder; +use Payvision\SDK\Domain\Paymentlinks\ValueObject\Link\RequestThreeDSecure; use Payvision\SDK\Domain\Service\Builder\Basic; class RequestBody extends Basic @@ -31,21 +32,21 @@ public function build(): RequestBodyObject } /** - * @param RequestTransaction $transaction + * @param RequestLink $link * @return RequestBody */ - public function setTransaction(RequestTransaction $transaction): RequestBody + public function setLink(RequestLink $link): RequestBody { - return $this->set('transaction', $transaction); + return $this->set('link', $link); } /** - * @param RequestLink $link + * @param RequestTransaction $transaction * @return RequestBody */ - public function setLink(RequestLink $link): RequestBody + public function setTransaction(RequestTransaction $transaction): RequestBody { - return $this->set('link', $link); + return $this->set('transaction', $transaction); } /** @@ -93,19 +94,29 @@ public function setShippingAddress(BasicAddress $shippingAddress): RequestBody return $this->set('shippingAddress', $shippingAddress); } + /** + * @param RequestThreeDSecure $threeDSecure + * @return RequestBody + */ + public function setThreeDSecure(RequestThreeDSecure $threeDSecure): RequestBody + { + return $this->set('threeDSecure', $threeDSecure); + } + /** * @return RequestBodyObject */ protected function buildObject(): RequestBodyObject { return new RequestBodyObject( - $this->get('transaction'), $this->get('link'), + $this->get('transaction'), $this->get('billingAddress'), $this->get('customer'), $this->get('dba'), $this->get('order'), - $this->get('shippingAddress') + $this->get('shippingAddress'), + $this->get('threeDSecure') ); } } diff --git a/src/Domain/Paymentlinks/Service/Builder/Link/RequestThreeDSecure.php b/src/Domain/Paymentlinks/Service/Builder/Link/RequestThreeDSecure.php new file mode 100644 index 0000000..a3d70bc --- /dev/null +++ b/src/Domain/Paymentlinks/Service/Builder/Link/RequestThreeDSecure.php @@ -0,0 +1,78 @@ +buildAndReset(); + } + + /** + * @param ThreeDSecureAdditionalInfo $additionalInfo + * @return RequestThreeDSecure + */ + public function setAdditionalInfo(ThreeDSecureAdditionalInfo $additionalInfo): RequestThreeDSecure + { + return $this->set('additionalInfo', $additionalInfo); + } + + /** + * @param ThreeDSecureExemption $exemption + * @return RequestThreeDSecure + */ + public function setExemption(ThreeDSecureExemption $exemption): RequestThreeDSecure + { + return $this->set('exemption', $exemption); + } + + /** + * @param ThreeDSecureRecurringInfo $recurringInfo + * @return RequestThreeDSecure + */ + public function setRecurringInfo(ThreeDSecureRecurringInfo $recurringInfo): RequestThreeDSecure + { + return $this->set('recurringInfo', $recurringInfo); + } + + /** + * @param string $version + * @return RequestThreeDSecure + */ + public function setVersion(string $version): RequestThreeDSecure + { + return $this->set('version', $version); + } + + /** + * @return RequestThreeDSecureObject + */ + protected function buildObject(): RequestThreeDSecureObject + { + return new RequestThreeDSecureObject( + $this->get('additionalInfo'), + $this->get('exemption'), + $this->get('recurringInfo'), + $this->get('version') + ); + } +} diff --git a/src/Domain/Paymentlinks/Service/Builder/ThreeDSecureAdditionalInfo.php b/src/Domain/Paymentlinks/Service/Builder/ThreeDSecureAdditionalInfo.php new file mode 100644 index 0000000..ab1dc05 --- /dev/null +++ b/src/Domain/Paymentlinks/Service/Builder/ThreeDSecureAdditionalInfo.php @@ -0,0 +1,85 @@ +buildAndReset(); + } + + /** + * @param string $challengeIndicator + * @return ThreeDSecureAdditionalInfo + */ + public function setChallengeIndicator(string $challengeIndicator): ThreeDSecureAdditionalInfo + { + return $this->set('challengeIndicator', $challengeIndicator); + } + + /** + * @param string $challengeWindowSize + * @return ThreeDSecureAdditionalInfo + */ + public function setChallengeWindowSize(string $challengeWindowSize): ThreeDSecureAdditionalInfo + { + return $this->set('challengeWindowSize', $challengeWindowSize); + } + + /** + * @param string $decoupledIndicator + * @return ThreeDSecureAdditionalInfo + */ + public function setDecoupledIndicator(string $decoupledIndicator): ThreeDSecureAdditionalInfo + { + return $this->set('decoupledIndicator', $decoupledIndicator); + } + + /** + * @param int $decoupledMaxTime + * @return ThreeDSecureAdditionalInfo + */ + public function setDecoupledMaxTime(int $decoupledMaxTime): ThreeDSecureAdditionalInfo + { + return $this->set('decoupledMaxTime', $decoupledMaxTime); + } + + /** + * @param int $merchantFraudRate + * @return ThreeDSecureAdditionalInfo + */ + public function setMerchantFraudRate(int $merchantFraudRate): ThreeDSecureAdditionalInfo + { + return $this->set('merchantFraudRate', $merchantFraudRate); + } + + /** + * @return ThreeDSecureAdditionalInfoObject + */ + protected function buildObject(): ThreeDSecureAdditionalInfoObject + { + return new ThreeDSecureAdditionalInfoObject( + $this->get('challengeIndicator'), + $this->get('challengeWindowSize'), + $this->get('decoupledIndicator'), + $this->get('decoupledMaxTime'), + $this->get('merchantFraudRate') + ); + } +} diff --git a/src/Domain/Paymentlinks/Service/Builder/ThreeDSecureExemption.php b/src/Domain/Paymentlinks/Service/Builder/ThreeDSecureExemption.php new file mode 100644 index 0000000..282af18 --- /dev/null +++ b/src/Domain/Paymentlinks/Service/Builder/ThreeDSecureExemption.php @@ -0,0 +1,85 @@ +buildAndReset(); + } + + /** + * @param bool $lowValue + * @return ThreeDSecureExemption + */ + public function setLowValue(bool $lowValue): ThreeDSecureExemption + { + return $this->set('lowValue', $lowValue); + } + + /** + * @param bool $secureCoorporate + * @return ThreeDSecureExemption + */ + public function setSecureCoorporate(bool $secureCoorporate): ThreeDSecureExemption + { + return $this->set('secureCoorporate', $secureCoorporate); + } + + /** + * @param bool $transactionRiskAnalysis + * @return ThreeDSecureExemption + */ + public function setTransactionRiskAnalysis(bool $transactionRiskAnalysis): ThreeDSecureExemption + { + return $this->set('transactionRiskAnalysis', $transactionRiskAnalysis); + } + + /** + * @param bool $trustedBeneficiary + * @return ThreeDSecureExemption + */ + public function setTrustedBeneficiary(bool $trustedBeneficiary): ThreeDSecureExemption + { + return $this->set('trustedBeneficiary', $trustedBeneficiary); + } + + /** + * @param string $vmid + * @return ThreeDSecureExemption + */ + public function setVmid(string $vmid): ThreeDSecureExemption + { + return $this->set('vmid', $vmid); + } + + /** + * @return ThreeDSecureExemptionObject + */ + protected function buildObject(): ThreeDSecureExemptionObject + { + return new ThreeDSecureExemptionObject( + $this->get('lowValue'), + $this->get('secureCoorporate'), + $this->get('transactionRiskAnalysis'), + $this->get('trustedBeneficiary'), + $this->get('vmid') + ); + } +} diff --git a/src/Domain/Paymentlinks/Service/Builder/ThreeDSecureRecurringInfo.php b/src/Domain/Paymentlinks/Service/Builder/ThreeDSecureRecurringInfo.php new file mode 100644 index 0000000..256b4f8 --- /dev/null +++ b/src/Domain/Paymentlinks/Service/Builder/ThreeDSecureRecurringInfo.php @@ -0,0 +1,65 @@ +buildAndReset(); + } + + /** + * @param \Payvision\SDK\DataType\DateTime $purchaseDate + * @return ThreeDSecureRecurringInfo + */ + public function setPurchaseDate(\Payvision\SDK\DataType\DateTime $purchaseDate): ThreeDSecureRecurringInfo + { + return $this->set('purchaseDate', $purchaseDate); + } + + /** + * @param \Payvision\SDK\DataType\Date $recurringEnd + * @return ThreeDSecureRecurringInfo + */ + public function setRecurringEnd(\Payvision\SDK\DataType\Date $recurringEnd): ThreeDSecureRecurringInfo + { + return $this->set('recurringEnd', $recurringEnd); + } + + /** + * @param int $recurringFrequency + * @return ThreeDSecureRecurringInfo + */ + public function setRecurringFrequency(int $recurringFrequency): ThreeDSecureRecurringInfo + { + return $this->set('recurringFrequency', $recurringFrequency); + } + + /** + * @return ThreeDSecureRecurringInfoObject + */ + protected function buildObject(): ThreeDSecureRecurringInfoObject + { + return new ThreeDSecureRecurringInfoObject( + $this->get('purchaseDate'), + $this->get('recurringEnd'), + $this->get('recurringFrequency') + ); + } +} diff --git a/src/Domain/Paymentlinks/ValueObject/Link/RequestBody.php b/src/Domain/Paymentlinks/ValueObject/Link/RequestBody.php index c409457..b6243ae 100644 --- a/src/Domain/Paymentlinks/ValueObject/Link/RequestBody.php +++ b/src/Domain/Paymentlinks/ValueObject/Link/RequestBody.php @@ -17,14 +17,14 @@ class RequestBody { /** - * @var RequestTransaction + * @var RequestLink */ - private $transaction; + private $link; /** - * @var RequestLink + * @var RequestTransaction */ - private $link; + private $transaction; /** * @var BasicAddress @@ -51,49 +51,57 @@ class RequestBody */ private $shippingAddress; + /** + * @var RequestThreeDSecure + */ + private $threeDSecure; + /** * RequestBody constructor. * - * @param RequestTransaction $transaction * @param RequestLink $link + * @param RequestTransaction $transaction * @param BasicAddress $billingAddress * @param BasicCustomer $customer * @param RequestDba $dba * @param RequestOrder $order * @param BasicAddress $shippingAddress + * @param RequestThreeDSecure $threeDSecure */ public function __construct( - RequestTransaction $transaction, RequestLink $link, + RequestTransaction $transaction, BasicAddress $billingAddress = null, BasicCustomer $customer = null, RequestDba $dba = null, RequestOrder $order = null, - BasicAddress $shippingAddress = null + BasicAddress $shippingAddress = null, + RequestThreeDSecure $threeDSecure = null ) { - $this->transaction = $transaction; $this->link = $link; + $this->transaction = $transaction; $this->billingAddress = $billingAddress; $this->customer = $customer; $this->dba = $dba; $this->order = $order; $this->shippingAddress = $shippingAddress; + $this->threeDSecure = $threeDSecure; } /** - * @return RequestTransaction + * @return RequestLink */ - public function getTransaction(): RequestTransaction + public function getLink(): RequestLink { - return $this->transaction; + return $this->link; } /** - * @return RequestLink + * @return RequestTransaction */ - public function getLink(): RequestLink + public function getTransaction(): RequestTransaction { - return $this->link; + return $this->transaction; } /** @@ -135,4 +143,12 @@ public function getShippingAddress(): ?BasicAddress { return $this->shippingAddress; } + + /** + * @return RequestThreeDSecure|null + */ + public function getThreeDSecure(): ?RequestThreeDSecure + { + return $this->threeDSecure; + } } diff --git a/src/Domain/Paymentlinks/ValueObject/Link/RequestThreeDSecure.php b/src/Domain/Paymentlinks/ValueObject/Link/RequestThreeDSecure.php new file mode 100644 index 0000000..9215965 --- /dev/null +++ b/src/Domain/Paymentlinks/ValueObject/Link/RequestThreeDSecure.php @@ -0,0 +1,91 @@ +additionalInfo = $additionalInfo; + $this->exemption = $exemption; + $this->recurringInfo = $recurringInfo; + $this->version = $version; + } + + /** + * @return ThreeDSecureAdditionalInfo|null + */ + public function getAdditionalInfo(): ?ThreeDSecureAdditionalInfo + { + return $this->additionalInfo; + } + + /** + * @return ThreeDSecureExemption|null + */ + public function getExemption(): ?ThreeDSecureExemption + { + return $this->exemption; + } + + /** + * @return ThreeDSecureRecurringInfo|null + */ + public function getRecurringInfo(): ?ThreeDSecureRecurringInfo + { + return $this->recurringInfo; + } + + /** + * @return string|null + */ + public function getVersion(): ?string + { + return $this->version; + } +} diff --git a/src/Domain/Paymentlinks/ValueObject/ThreeDSecureAdditionalInfo.php b/src/Domain/Paymentlinks/ValueObject/ThreeDSecureAdditionalInfo.php new file mode 100644 index 0000000..8d4da62 --- /dev/null +++ b/src/Domain/Paymentlinks/ValueObject/ThreeDSecureAdditionalInfo.php @@ -0,0 +1,103 @@ +challengeIndicator = $challengeIndicator; + $this->challengeWindowSize = $challengeWindowSize; + $this->decoupledIndicator = $decoupledIndicator; + $this->decoupledMaxTime = $decoupledMaxTime; + $this->merchantFraudRate = $merchantFraudRate; + } + + /** + * @return string|null + */ + public function getChallengeIndicator(): ?string + { + return $this->challengeIndicator; + } + + /** + * @return string|null + */ + public function getChallengeWindowSize(): ?string + { + return $this->challengeWindowSize; + } + + /** + * @return string|null + */ + public function getDecoupledIndicator(): ?string + { + return $this->decoupledIndicator; + } + + /** + * @return int|null + */ + public function getDecoupledMaxTime(): ?int + { + return $this->decoupledMaxTime; + } + + /** + * @return int|null + */ + public function getMerchantFraudRate(): ?int + { + return $this->merchantFraudRate; + } +} diff --git a/src/Domain/Paymentlinks/ValueObject/ThreeDSecureExemption.php b/src/Domain/Paymentlinks/ValueObject/ThreeDSecureExemption.php new file mode 100644 index 0000000..9240667 --- /dev/null +++ b/src/Domain/Paymentlinks/ValueObject/ThreeDSecureExemption.php @@ -0,0 +1,103 @@ +lowValue = $lowValue; + $this->secureCoorporate = $secureCoorporate; + $this->transactionRiskAnalysis = $transactionRiskAnalysis; + $this->trustedBeneficiary = $trustedBeneficiary; + $this->vmid = $vmid; + } + + /** + * @return bool|null + */ + public function getLowValue(): ?bool + { + return $this->lowValue; + } + + /** + * @return bool|null + */ + public function getSecureCoorporate(): ?bool + { + return $this->secureCoorporate; + } + + /** + * @return bool|null + */ + public function getTransactionRiskAnalysis(): ?bool + { + return $this->transactionRiskAnalysis; + } + + /** + * @return bool|null + */ + public function getTrustedBeneficiary(): ?bool + { + return $this->trustedBeneficiary; + } + + /** + * @return string|null + */ + public function getVmid(): ?string + { + return $this->vmid; + } +} diff --git a/src/Domain/Paymentlinks/ValueObject/ThreeDSecureRecurringInfo.php b/src/Domain/Paymentlinks/ValueObject/ThreeDSecureRecurringInfo.php new file mode 100644 index 0000000..6cae0b6 --- /dev/null +++ b/src/Domain/Paymentlinks/ValueObject/ThreeDSecureRecurringInfo.php @@ -0,0 +1,71 @@ +purchaseDate = $purchaseDate; + $this->recurringEnd = $recurringEnd; + $this->recurringFrequency = $recurringFrequency; + } + + /** + * @return \Payvision\SDK\DataType\DateTime|null + */ + public function getPurchaseDate(): ?\Payvision\SDK\DataType\DateTime + { + return $this->purchaseDate; + } + + /** + * @return \Payvision\SDK\DataType\Date|null + */ + public function getRecurringEnd(): ?\Payvision\SDK\DataType\Date + { + return $this->recurringEnd; + } + + /** + * @return int|null + */ + public function getRecurringFrequency(): ?int + { + return $this->recurringFrequency; + } +} diff --git a/src/Domain/Payments/Service/Builder/Composite/Payment/RequestBody.php b/src/Domain/Payments/Service/Builder/Composite/Payment/RequestBody.php index 6d60b20..131bd57 100644 --- a/src/Domain/Payments/Service/Builder/Composite/Payment/RequestBody.php +++ b/src/Domain/Payments/Service/Builder/Composite/Payment/RequestBody.php @@ -22,7 +22,7 @@ use Payvision\SDK\Domain\Payments\Service\Builder\Order as OrderBuilder; use Payvision\SDK\Domain\Payments\Service\Builder\Payment\RequestQr as RequestQrBuilder; use Payvision\SDK\Domain\Payments\Service\Builder\Composite\Payment\RequestShippingAddress as RequestShippingAddressBuilder; -use Payvision\SDK\Domain\Payments\Service\Builder\Payment\RequestThreeDSecure as RequestThreeDSecureBuilder; +use Payvision\SDK\Domain\Payments\Service\Builder\Composite\Payment\RequestThreeDSecure as RequestThreeDSecureBuilder; use Payvision\SDK\Domain\Payments\Service\Builder\Payment\RequestWallet as RequestWalletBuilder; use Payvision\SDK\Domain\Service\Builder\Basic; diff --git a/src/Domain/Payments/Service/Builder/Composite/Payment/RequestThreeDSecure.php b/src/Domain/Payments/Service/Builder/Composite/Payment/RequestThreeDSecure.php new file mode 100644 index 0000000..df05dd1 --- /dev/null +++ b/src/Domain/Payments/Service/Builder/Composite/Payment/RequestThreeDSecure.php @@ -0,0 +1,165 @@ +additionalInfoBuilder = new ThreeDSecureAdditionalInfoBuilder(); + $this->exemptionBuilder = new ThreeDSecureExemptionBuilder(); + $this->recurringInfoBuilder = new ThreeDSecureRecurringInfoBuilder(); + } + + /** + * @return RequestThreeDSecureObject + */ + public function build(): RequestThreeDSecureObject + { + return $this->buildAndReset(); + } + + /** + * @return ThreeDSecureAdditionalInfoBuilder + */ + public function additionalInfo(): ThreeDSecureAdditionalInfoBuilder + { + $this->isAdditionalInfoBuilderTouched = true; + return $this->additionalInfoBuilder; + } + + /** + * @param string $avv + * @return RequestThreeDSecure + */ + public function setAvv(string $avv): RequestThreeDSecure + { + return $this->set('avv', $avv); + } + + /** + * @param bool $checkEnrollment + * @return RequestThreeDSecure + */ + public function setCheckEnrollment(bool $checkEnrollment): RequestThreeDSecure + { + return $this->set('checkEnrollment', $checkEnrollment); + } + + /** + * @param string $dsTransactionId + * @return RequestThreeDSecure + */ + public function setDsTransactionId(string $dsTransactionId): RequestThreeDSecure + { + return $this->set('dsTransactionId', $dsTransactionId); + } + + /** + * @param string $eci + * @return RequestThreeDSecure + */ + public function setEci(string $eci): RequestThreeDSecure + { + return $this->set('eci', $eci); + } + + /** + * @return ThreeDSecureExemptionBuilder + */ + public function exemption(): ThreeDSecureExemptionBuilder + { + $this->isExemptionBuilderTouched = true; + return $this->exemptionBuilder; + } + + /** + * @return ThreeDSecureRecurringInfoBuilder + */ + public function recurringInfo(): ThreeDSecureRecurringInfoBuilder + { + $this->isRecurringInfoBuilderTouched = true; + return $this->recurringInfoBuilder; + } + + /** + * @param string $version + * @return RequestThreeDSecure + */ + public function setVersion(string $version): RequestThreeDSecure + { + return $this->set('version', $version); + } + + /** + * @param string $xid + * @return RequestThreeDSecure + */ + public function setXid(string $xid): RequestThreeDSecure + { + return $this->set('xid', $xid); + } + + /** + * @return RequestThreeDSecureObject + */ + protected function buildObject(): RequestThreeDSecureObject + { + return new RequestThreeDSecureObject( + $this->isAdditionalInfoBuilderTouched ? $this->additionalInfoBuilder->build() : null, + $this->get('avv'), + $this->get('checkEnrollment'), + $this->get('dsTransactionId'), + $this->get('eci'), + $this->isExemptionBuilderTouched ? $this->exemptionBuilder->build() : null, + $this->isRecurringInfoBuilderTouched ? $this->recurringInfoBuilder->build() : null, + $this->get('version'), + $this->get('xid') + ); + } +} diff --git a/src/Domain/Payments/Service/Builder/Payment/RequestThreeDSecure.php b/src/Domain/Payments/Service/Builder/Payment/RequestThreeDSecure.php index c248679..f8bbc14 100644 --- a/src/Domain/Payments/Service/Builder/Payment/RequestThreeDSecure.php +++ b/src/Domain/Payments/Service/Builder/Payment/RequestThreeDSecure.php @@ -12,6 +12,9 @@ namespace Payvision\SDK\Domain\Payments\Service\Builder\Payment; use Payvision\SDK\Domain\Payments\ValueObject\Payment\RequestThreeDSecure as RequestThreeDSecureObject; +use Payvision\SDK\Domain\Payments\ValueObject\ThreeDSecureAdditionalInfo; +use Payvision\SDK\Domain\Payments\ValueObject\ThreeDSecureExemption; +use Payvision\SDK\Domain\Payments\ValueObject\ThreeDSecureRecurringInfo; use Payvision\SDK\Domain\Service\Builder\Basic; class RequestThreeDSecure extends Basic @@ -24,6 +27,15 @@ public function build(): RequestThreeDSecureObject return $this->buildAndReset(); } + /** + * @param ThreeDSecureAdditionalInfo $additionalInfo + * @return RequestThreeDSecure + */ + public function setAdditionalInfo(ThreeDSecureAdditionalInfo $additionalInfo): RequestThreeDSecure + { + return $this->set('additionalInfo', $additionalInfo); + } + /** * @param string $avv * @return RequestThreeDSecure @@ -43,14 +55,50 @@ public function setCheckEnrollment(bool $checkEnrollment): RequestThreeDSecure } /** - * @param int $eci + * @param string $dsTransactionId * @return RequestThreeDSecure */ - public function setEci(int $eci): RequestThreeDSecure + public function setDsTransactionId(string $dsTransactionId): RequestThreeDSecure + { + return $this->set('dsTransactionId', $dsTransactionId); + } + + /** + * @param string $eci + * @return RequestThreeDSecure + */ + public function setEci(string $eci): RequestThreeDSecure { return $this->set('eci', $eci); } + /** + * @param ThreeDSecureExemption $exemption + * @return RequestThreeDSecure + */ + public function setExemption(ThreeDSecureExemption $exemption): RequestThreeDSecure + { + return $this->set('exemption', $exemption); + } + + /** + * @param ThreeDSecureRecurringInfo $recurringInfo + * @return RequestThreeDSecure + */ + public function setRecurringInfo(ThreeDSecureRecurringInfo $recurringInfo): RequestThreeDSecure + { + return $this->set('recurringInfo', $recurringInfo); + } + + /** + * @param string $version + * @return RequestThreeDSecure + */ + public function setVersion(string $version): RequestThreeDSecure + { + return $this->set('version', $version); + } + /** * @param string $xid * @return RequestThreeDSecure @@ -66,9 +114,14 @@ public function setXid(string $xid): RequestThreeDSecure protected function buildObject(): RequestThreeDSecureObject { return new RequestThreeDSecureObject( + $this->get('additionalInfo'), $this->get('avv'), $this->get('checkEnrollment'), + $this->get('dsTransactionId'), $this->get('eci'), + $this->get('exemption'), + $this->get('recurringInfo'), + $this->get('version'), $this->get('xid') ); } diff --git a/src/Domain/Payments/Service/Builder/Payment/RequestTransaction.php b/src/Domain/Payments/Service/Builder/Payment/RequestTransaction.php index 1129b86..b62baa3 100644 --- a/src/Domain/Payments/Service/Builder/Payment/RequestTransaction.php +++ b/src/Domain/Payments/Service/Builder/Payment/RequestTransaction.php @@ -33,6 +33,15 @@ public function setAmount(float $amount): RequestTransaction return $this->set('amount', $amount); } + /** + * @param string $currencyCode + * @return RequestTransaction + */ + public function setCurrencyCode(string $currencyCode): RequestTransaction + { + return $this->set('currencyCode', $currencyCode); + } + /** * @param string $trackingCode * @return RequestTransaction @@ -43,57 +52,57 @@ public function setTrackingCode(string $trackingCode): RequestTransaction } /** - * @param string $currencyCode + * @param int $brandId * @return RequestTransaction */ - public function setCurrencyCode(string $currencyCode): RequestTransaction + public function setBrandId(int $brandId): RequestTransaction { - return $this->set('currencyCode', $currencyCode); + return $this->set('brandId', $brandId); } /** - * @param string $returnUrl + * @param string $countryCode * @return RequestTransaction */ - public function setReturnUrl(string $returnUrl): RequestTransaction + public function setCountryCode(string $countryCode): RequestTransaction { - return $this->set('returnUrl', $returnUrl); + return $this->set('countryCode', $countryCode); } /** - * @param bool $tokenize + * @param string $descriptor * @return RequestTransaction */ - public function setTokenize(bool $tokenize): RequestTransaction + public function setDescriptor(string $descriptor): RequestTransaction { - return $this->set('tokenize', $tokenize); + return $this->set('descriptor', $descriptor); } /** - * @param string $token + * @param string $invoiceId * @return RequestTransaction */ - public function setToken(string $token): RequestTransaction + public function setInvoiceId(string $invoiceId): RequestTransaction { - return $this->set('token', $token); + return $this->set('invoiceId', $invoiceId); } /** - * @param int $storeId + * @param string $languageCode * @return RequestTransaction */ - public function setStoreId(int $storeId): RequestTransaction + public function setLanguageCode(string $languageCode): RequestTransaction { - return $this->set('storeId', $storeId); + return $this->set('languageCode', $languageCode); } /** - * @param string $source + * @param string $notifyUrl * @return RequestTransaction */ - public function setSource(string $source): RequestTransaction + public function setNotifyUrl(string $notifyUrl): RequestTransaction { - return $this->set('source', $source); + return $this->set('notifyUrl', $notifyUrl); } /** @@ -115,57 +124,48 @@ public function setPurchaseId(string $purchaseId): RequestTransaction } /** - * @param int $brandId - * @return RequestTransaction - */ - public function setBrandId(int $brandId): RequestTransaction - { - return $this->set('brandId', $brandId); - } - - /** - * @param string $notifyUrl + * @param string $returnUrl * @return RequestTransaction */ - public function setNotifyUrl(string $notifyUrl): RequestTransaction + public function setReturnUrl(string $returnUrl): RequestTransaction { - return $this->set('notifyUrl', $notifyUrl); + return $this->set('returnUrl', $returnUrl); } /** - * @param string $languageCode + * @param string $source * @return RequestTransaction */ - public function setLanguageCode(string $languageCode): RequestTransaction + public function setSource(string $source): RequestTransaction { - return $this->set('languageCode', $languageCode); + return $this->set('source', $source); } /** - * @param string $invoiceId + * @param int $storeId * @return RequestTransaction */ - public function setInvoiceId(string $invoiceId): RequestTransaction + public function setStoreId(int $storeId): RequestTransaction { - return $this->set('invoiceId', $invoiceId); + return $this->set('storeId', $storeId); } /** - * @param string $descriptor + * @param string $token * @return RequestTransaction */ - public function setDescriptor(string $descriptor): RequestTransaction + public function setToken(string $token): RequestTransaction { - return $this->set('descriptor', $descriptor); + return $this->set('token', $token); } /** - * @param string $countryCode + * @param bool $tokenize * @return RequestTransaction */ - public function setCountryCode(string $countryCode): RequestTransaction + public function setTokenize(bool $tokenize): RequestTransaction { - return $this->set('countryCode', $countryCode); + return $this->set('tokenize', $tokenize); } /** @@ -184,21 +184,21 @@ protected function buildObject(): RequestTransactionObject { return new RequestTransactionObject( $this->get('amount'), - $this->get('trackingCode'), $this->get('currencyCode'), - $this->get('returnUrl'), - $this->get('tokenize'), - $this->get('token'), - $this->get('storeId'), - $this->get('source'), - $this->get('payTimeout'), - $this->get('purchaseId'), + $this->get('trackingCode'), $this->get('brandId'), - $this->get('notifyUrl'), - $this->get('languageCode'), - $this->get('invoiceId'), - $this->get('descriptor'), $this->get('countryCode'), + $this->get('descriptor'), + $this->get('invoiceId'), + $this->get('languageCode'), + $this->get('notifyUrl'), + $this->get('payTimeout'), + $this->get('purchaseId'), + $this->get('returnUrl'), + $this->get('source'), + $this->get('storeId'), + $this->get('token'), + $this->get('tokenize'), $this->get('type') ); } diff --git a/src/Domain/Payments/Service/Builder/Payment/ResponseThreeDSecure.php b/src/Domain/Payments/Service/Builder/Payment/ResponseThreeDSecure.php index cbf84d7..c585e03 100644 --- a/src/Domain/Payments/Service/Builder/Payment/ResponseThreeDSecure.php +++ b/src/Domain/Payments/Service/Builder/Payment/ResponseThreeDSecure.php @@ -24,6 +24,15 @@ public function build(): ResponseThreeDSecureObject return $this->buildAndReset(); } + /** + * @param string $authenticationResult + * @return ResponseThreeDSecure + */ + public function setAuthenticationResult(string $authenticationResult): ResponseThreeDSecure + { + return $this->set('authenticationResult', $authenticationResult); + } + /** * @param string $enrollmentResult * @return ResponseThreeDSecure @@ -33,6 +42,15 @@ public function setEnrollmentResult(string $enrollmentResult): ResponseThreeDSec return $this->set('enrollmentResult', $enrollmentResult); } + /** + * @param string $flow + * @return ResponseThreeDSecure + */ + public function setFlow(string $flow): ResponseThreeDSecure + { + return $this->set('flow', $flow); + } + /** * @param string $validationResult * @return ResponseThreeDSecure @@ -42,14 +60,26 @@ public function setValidationResult(string $validationResult): ResponseThreeDSec return $this->set('validationResult', $validationResult); } + /** + * @param string $version + * @return ResponseThreeDSecure + */ + public function setVersion(string $version): ResponseThreeDSecure + { + return $this->set('version', $version); + } + /** * @return ResponseThreeDSecureObject */ protected function buildObject(): ResponseThreeDSecureObject { return new ResponseThreeDSecureObject( + $this->get('authenticationResult'), $this->get('enrollmentResult'), - $this->get('validationResult') + $this->get('flow'), + $this->get('validationResult'), + $this->get('version') ); } } diff --git a/src/Domain/Payments/Service/Builder/ThreeDSecureAdditionalInfo.php b/src/Domain/Payments/Service/Builder/ThreeDSecureAdditionalInfo.php new file mode 100644 index 0000000..b74c2dc --- /dev/null +++ b/src/Domain/Payments/Service/Builder/ThreeDSecureAdditionalInfo.php @@ -0,0 +1,85 @@ +buildAndReset(); + } + + /** + * @param string $challengeIndicator + * @return ThreeDSecureAdditionalInfo + */ + public function setChallengeIndicator(string $challengeIndicator): ThreeDSecureAdditionalInfo + { + return $this->set('challengeIndicator', $challengeIndicator); + } + + /** + * @param string $challengeWindowSize + * @return ThreeDSecureAdditionalInfo + */ + public function setChallengeWindowSize(string $challengeWindowSize): ThreeDSecureAdditionalInfo + { + return $this->set('challengeWindowSize', $challengeWindowSize); + } + + /** + * @param string $decoupledIndicator + * @return ThreeDSecureAdditionalInfo + */ + public function setDecoupledIndicator(string $decoupledIndicator): ThreeDSecureAdditionalInfo + { + return $this->set('decoupledIndicator', $decoupledIndicator); + } + + /** + * @param int $decoupledMaxTime + * @return ThreeDSecureAdditionalInfo + */ + public function setDecoupledMaxTime(int $decoupledMaxTime): ThreeDSecureAdditionalInfo + { + return $this->set('decoupledMaxTime', $decoupledMaxTime); + } + + /** + * @param int $merchantFraudRate + * @return ThreeDSecureAdditionalInfo + */ + public function setMerchantFraudRate(int $merchantFraudRate): ThreeDSecureAdditionalInfo + { + return $this->set('merchantFraudRate', $merchantFraudRate); + } + + /** + * @return ThreeDSecureAdditionalInfoObject + */ + protected function buildObject(): ThreeDSecureAdditionalInfoObject + { + return new ThreeDSecureAdditionalInfoObject( + $this->get('challengeIndicator'), + $this->get('challengeWindowSize'), + $this->get('decoupledIndicator'), + $this->get('decoupledMaxTime'), + $this->get('merchantFraudRate') + ); + } +} diff --git a/src/Domain/Payments/Service/Builder/ThreeDSecureExemption.php b/src/Domain/Payments/Service/Builder/ThreeDSecureExemption.php new file mode 100644 index 0000000..cac9276 --- /dev/null +++ b/src/Domain/Payments/Service/Builder/ThreeDSecureExemption.php @@ -0,0 +1,85 @@ +buildAndReset(); + } + + /** + * @param bool $lowValue + * @return ThreeDSecureExemption + */ + public function setLowValue(bool $lowValue): ThreeDSecureExemption + { + return $this->set('lowValue', $lowValue); + } + + /** + * @param bool $secureCoorporate + * @return ThreeDSecureExemption + */ + public function setSecureCoorporate(bool $secureCoorporate): ThreeDSecureExemption + { + return $this->set('secureCoorporate', $secureCoorporate); + } + + /** + * @param bool $transactionRiskAnalysis + * @return ThreeDSecureExemption + */ + public function setTransactionRiskAnalysis(bool $transactionRiskAnalysis): ThreeDSecureExemption + { + return $this->set('transactionRiskAnalysis', $transactionRiskAnalysis); + } + + /** + * @param bool $trustedBeneficiary + * @return ThreeDSecureExemption + */ + public function setTrustedBeneficiary(bool $trustedBeneficiary): ThreeDSecureExemption + { + return $this->set('trustedBeneficiary', $trustedBeneficiary); + } + + /** + * @param string $vmid + * @return ThreeDSecureExemption + */ + public function setVmid(string $vmid): ThreeDSecureExemption + { + return $this->set('vmid', $vmid); + } + + /** + * @return ThreeDSecureExemptionObject + */ + protected function buildObject(): ThreeDSecureExemptionObject + { + return new ThreeDSecureExemptionObject( + $this->get('lowValue'), + $this->get('secureCoorporate'), + $this->get('transactionRiskAnalysis'), + $this->get('trustedBeneficiary'), + $this->get('vmid') + ); + } +} diff --git a/src/Domain/Payments/Service/Builder/ThreeDSecureRecurringInfo.php b/src/Domain/Payments/Service/Builder/ThreeDSecureRecurringInfo.php new file mode 100644 index 0000000..779aaff --- /dev/null +++ b/src/Domain/Payments/Service/Builder/ThreeDSecureRecurringInfo.php @@ -0,0 +1,65 @@ +buildAndReset(); + } + + /** + * @param \Payvision\SDK\DataType\DateTime $purchaseDate + * @return ThreeDSecureRecurringInfo + */ + public function setPurchaseDate(\Payvision\SDK\DataType\DateTime $purchaseDate): ThreeDSecureRecurringInfo + { + return $this->set('purchaseDate', $purchaseDate); + } + + /** + * @param \Payvision\SDK\DataType\Date $recurringEnd + * @return ThreeDSecureRecurringInfo + */ + public function setRecurringEnd(\Payvision\SDK\DataType\Date $recurringEnd): ThreeDSecureRecurringInfo + { + return $this->set('recurringEnd', $recurringEnd); + } + + /** + * @param int $recurringFrequency + * @return ThreeDSecureRecurringInfo + */ + public function setRecurringFrequency(int $recurringFrequency): ThreeDSecureRecurringInfo + { + return $this->set('recurringFrequency', $recurringFrequency); + } + + /** + * @return ThreeDSecureRecurringInfoObject + */ + protected function buildObject(): ThreeDSecureRecurringInfoObject + { + return new ThreeDSecureRecurringInfoObject( + $this->get('purchaseDate'), + $this->get('recurringEnd'), + $this->get('recurringFrequency') + ); + } +} diff --git a/src/Domain/Payments/ValueObject/Payment/RequestThreeDSecure.php b/src/Domain/Payments/ValueObject/Payment/RequestThreeDSecure.php index 4942ccb..d033a26 100644 --- a/src/Domain/Payments/ValueObject/Payment/RequestThreeDSecure.php +++ b/src/Domain/Payments/ValueObject/Payment/RequestThreeDSecure.php @@ -11,8 +11,17 @@ namespace Payvision\SDK\Domain\Payments\ValueObject\Payment; +use Payvision\SDK\Domain\Payments\ValueObject\ThreeDSecureAdditionalInfo; +use Payvision\SDK\Domain\Payments\ValueObject\ThreeDSecureExemption; +use Payvision\SDK\Domain\Payments\ValueObject\ThreeDSecureRecurringInfo; + class RequestThreeDSecure { + /** + * @var ThreeDSecureAdditionalInfo + */ + private $additionalInfo; + /** * @var string */ @@ -24,10 +33,30 @@ class RequestThreeDSecure private $checkEnrollment; /** - * @var int + * @var string + */ + private $dsTransactionId; + + /** + * @var string */ private $eci; + /** + * @var ThreeDSecureExemption + */ + private $exemption; + + /** + * @var ThreeDSecureRecurringInfo + */ + private $recurringInfo; + + /** + * @var string + */ + private $version; + /** * @var string */ @@ -36,23 +65,46 @@ class RequestThreeDSecure /** * RequestThreeDSecure constructor. * + * @param ThreeDSecureAdditionalInfo $additionalInfo * @param string $avv * @param bool $checkEnrollment - * @param int $eci + * @param string $dsTransactionId + * @param string $eci + * @param ThreeDSecureExemption $exemption + * @param ThreeDSecureRecurringInfo $recurringInfo + * @param string $version * @param string $xid */ public function __construct( + ThreeDSecureAdditionalInfo $additionalInfo = null, string $avv = null, bool $checkEnrollment = null, - int $eci = null, + string $dsTransactionId = null, + string $eci = null, + ThreeDSecureExemption $exemption = null, + ThreeDSecureRecurringInfo $recurringInfo = null, + string $version = null, string $xid = null ) { + $this->additionalInfo = $additionalInfo; $this->avv = $avv; $this->checkEnrollment = $checkEnrollment; + $this->dsTransactionId = $dsTransactionId; $this->eci = $eci; + $this->exemption = $exemption; + $this->recurringInfo = $recurringInfo; + $this->version = $version; $this->xid = $xid; } + /** + * @return ThreeDSecureAdditionalInfo|null + */ + public function getAdditionalInfo(): ?ThreeDSecureAdditionalInfo + { + return $this->additionalInfo; + } + /** * @return string|null */ @@ -70,13 +122,45 @@ public function getCheckEnrollment(): ?bool } /** - * @return int|null + * @return string|null + */ + public function getDsTransactionId(): ?string + { + return $this->dsTransactionId; + } + + /** + * @return string|null */ - public function getEci(): ?int + public function getEci(): ?string { return $this->eci; } + /** + * @return ThreeDSecureExemption|null + */ + public function getExemption(): ?ThreeDSecureExemption + { + return $this->exemption; + } + + /** + * @return ThreeDSecureRecurringInfo|null + */ + public function getRecurringInfo(): ?ThreeDSecureRecurringInfo + { + return $this->recurringInfo; + } + + /** + * @return string|null + */ + public function getVersion(): ?string + { + return $this->version; + } + /** * @return string|null */ diff --git a/src/Domain/Payments/ValueObject/Payment/RequestTransaction.php b/src/Domain/Payments/ValueObject/Payment/RequestTransaction.php index f090c09..f7c3f24 100644 --- a/src/Domain/Payments/ValueObject/Payment/RequestTransaction.php +++ b/src/Domain/Payments/ValueObject/Payment/RequestTransaction.php @@ -21,37 +21,42 @@ class RequestTransaction /** * @var string */ - private $trackingCode; + private $currencyCode; /** * @var string */ - private $currencyCode; + private $trackingCode; + + /** + * @var int + */ + private $brandId; /** * @var string */ - private $returnUrl; + private $countryCode; /** - * @var bool + * @var string */ - private $tokenize; + private $descriptor; /** * @var string */ - private $token; + private $invoiceId; /** - * @var int + * @var string */ - private $storeId; + private $languageCode; /** * @var string */ - private $source; + private $notifyUrl; /** * @var int @@ -63,35 +68,30 @@ class RequestTransaction */ private $purchaseId; - /** - * @var int - */ - private $brandId; - /** * @var string */ - private $notifyUrl; + private $returnUrl; /** * @var string */ - private $languageCode; + private $source; /** - * @var string + * @var int */ - private $invoiceId; + private $storeId; /** * @var string */ - private $descriptor; + private $token; /** - * @var string + * @var bool */ - private $countryCode; + private $tokenize; /** * @var string @@ -102,58 +102,58 @@ class RequestTransaction * RequestTransaction constructor. * * @param float $amount - * @param string $trackingCode * @param string $currencyCode - * @param string $returnUrl - * @param bool $tokenize - * @param string $token - * @param int $storeId - * @param string $source - * @param int $payTimeout - * @param string $purchaseId + * @param string $trackingCode * @param int $brandId - * @param string $notifyUrl - * @param string $languageCode - * @param string $invoiceId - * @param string $descriptor * @param string $countryCode + * @param string $descriptor + * @param string $invoiceId + * @param string $languageCode + * @param string $notifyUrl + * @param int $payTimeout + * @param string $purchaseId + * @param string $returnUrl + * @param string $source + * @param int $storeId + * @param string $token + * @param bool $tokenize * @param string $type */ public function __construct( float $amount, - string $trackingCode, string $currencyCode, - string $returnUrl = null, - bool $tokenize = null, - string $token = null, - int $storeId = null, - string $source = null, - int $payTimeout = null, - string $purchaseId = null, + string $trackingCode, int $brandId = null, - string $notifyUrl = null, - string $languageCode = null, - string $invoiceId = null, - string $descriptor = null, string $countryCode = null, + string $descriptor = null, + string $invoiceId = null, + string $languageCode = null, + string $notifyUrl = null, + int $payTimeout = null, + string $purchaseId = null, + string $returnUrl = null, + string $source = null, + int $storeId = null, + string $token = null, + bool $tokenize = null, string $type = null ) { $this->amount = $amount; - $this->trackingCode = $trackingCode; $this->currencyCode = $currencyCode; - $this->returnUrl = $returnUrl; - $this->tokenize = $tokenize; - $this->token = $token; - $this->storeId = $storeId; - $this->source = $source; - $this->payTimeout = $payTimeout; - $this->purchaseId = $purchaseId; + $this->trackingCode = $trackingCode; $this->brandId = $brandId; - $this->notifyUrl = $notifyUrl; - $this->languageCode = $languageCode; - $this->invoiceId = $invoiceId; - $this->descriptor = $descriptor; $this->countryCode = $countryCode; + $this->descriptor = $descriptor; + $this->invoiceId = $invoiceId; + $this->languageCode = $languageCode; + $this->notifyUrl = $notifyUrl; + $this->payTimeout = $payTimeout; + $this->purchaseId = $purchaseId; + $this->returnUrl = $returnUrl; + $this->source = $source; + $this->storeId = $storeId; + $this->token = $token; + $this->tokenize = $tokenize; $this->type = $type; } @@ -165,6 +165,14 @@ public function getAmount(): float return $this->amount; } + /** + * @return string + */ + public function getCurrencyCode(): string + { + return $this->currencyCode; + } + /** * @return string */ @@ -174,51 +182,51 @@ public function getTrackingCode(): string } /** - * @return string + * @return int|null */ - public function getCurrencyCode(): string + public function getBrandId(): ?int { - return $this->currencyCode; + return $this->brandId; } /** * @return string|null */ - public function getReturnUrl(): ?string + public function getCountryCode(): ?string { - return $this->returnUrl; + return $this->countryCode; } /** - * @return bool|null + * @return string|null */ - public function getTokenize(): ?bool + public function getDescriptor(): ?string { - return $this->tokenize; + return $this->descriptor; } /** * @return string|null */ - public function getToken(): ?string + public function getInvoiceId(): ?string { - return $this->token; + return $this->invoiceId; } /** - * @return int|null + * @return string|null */ - public function getStoreId(): ?int + public function getLanguageCode(): ?string { - return $this->storeId; + return $this->languageCode; } /** * @return string|null */ - public function getSource(): ?string + public function getNotifyUrl(): ?string { - return $this->source; + return $this->notifyUrl; } /** @@ -237,52 +245,44 @@ public function getPurchaseId(): ?string return $this->purchaseId; } - /** - * @return int|null - */ - public function getBrandId(): ?int - { - return $this->brandId; - } - /** * @return string|null */ - public function getNotifyUrl(): ?string + public function getReturnUrl(): ?string { - return $this->notifyUrl; + return $this->returnUrl; } /** * @return string|null */ - public function getLanguageCode(): ?string + public function getSource(): ?string { - return $this->languageCode; + return $this->source; } /** - * @return string|null + * @return int|null */ - public function getInvoiceId(): ?string + public function getStoreId(): ?int { - return $this->invoiceId; + return $this->storeId; } /** * @return string|null */ - public function getDescriptor(): ?string + public function getToken(): ?string { - return $this->descriptor; + return $this->token; } /** - * @return string|null + * @return bool|null */ - public function getCountryCode(): ?string + public function getTokenize(): ?bool { - return $this->countryCode; + return $this->tokenize; } /** diff --git a/src/Domain/Payments/ValueObject/Payment/ResponseThreeDSecure.php b/src/Domain/Payments/ValueObject/Payment/ResponseThreeDSecure.php index a1d12c7..5d6ed47 100644 --- a/src/Domain/Payments/ValueObject/Payment/ResponseThreeDSecure.php +++ b/src/Domain/Payments/ValueObject/Payment/ResponseThreeDSecure.php @@ -13,28 +13,79 @@ class ResponseThreeDSecure { + public const ENROLLMENT_RESULT_AUTHENTICATED = 'Y'; + public const ENROLLMENT_RESULT_ATTEMPTED = 'A'; + public const ENROLLMENT_RESULT_INVALID = 'N'; + public const ENROLLMENT_RESULT_BYPASSED = 'B'; + + public const VALIDATION_RESULT_AUTHENTICATED = 'Y'; + public const VALIDATION_RESULT_ATTEMPTED = 'A'; + public const VALIDATION_RESULT_UNAVAILABLE = 'U'; + public const VALIDATION_RESULT_INVALID = 'N'; + + public const AUTHENTICATION_RESULT_AUTHENTICATED = 'Y'; + public const AUTHENTICATION_RESULT_ATTEMPTED = 'A'; + public const AUTHENTICATION_RESULT_FAILED = 'N'; + public const AUTHENTICATION_RESULT_UNAVAILABLE = 'U'; + public const AUTHENTICATION_RESULT_REJECTED = 'R'; + + public const FLOW_FRICTIONLESS = 'FRICTIONLESS'; + public const FLOW_CHALLENGE = 'CHALLENGE'; + + /** + * @var string + */ + private $authenticationResult; + /** * @var string */ private $enrollmentResult; + /** + * @var string + */ + private $flow; + /** * @var string */ private $validationResult; + /** + * @var string + */ + private $version; + /** * ResponseThreeDSecure constructor. * + * @param string $authenticationResult * @param string $enrollmentResult + * @param string $flow * @param string $validationResult + * @param string $version */ public function __construct( + string $authenticationResult = null, string $enrollmentResult = null, - string $validationResult = null + string $flow = null, + string $validationResult = null, + string $version = null ) { + $this->authenticationResult = $authenticationResult; $this->enrollmentResult = $enrollmentResult; + $this->flow = $flow; $this->validationResult = $validationResult; + $this->version = $version; + } + + /** + * @return string|null + */ + public function getAuthenticationResult(): ?string + { + return $this->authenticationResult; } /** @@ -45,6 +96,14 @@ public function getEnrollmentResult(): ?string return $this->enrollmentResult; } + /** + * @return string|null + */ + public function getFlow(): ?string + { + return $this->flow; + } + /** * @return string|null */ @@ -52,4 +111,12 @@ public function getValidationResult(): ?string { return $this->validationResult; } + + /** + * @return string|null + */ + public function getVersion(): ?string + { + return $this->version; + } } diff --git a/src/Domain/Payments/ValueObject/ThreeDSecureAdditionalInfo.php b/src/Domain/Payments/ValueObject/ThreeDSecureAdditionalInfo.php new file mode 100644 index 0000000..069b594 --- /dev/null +++ b/src/Domain/Payments/ValueObject/ThreeDSecureAdditionalInfo.php @@ -0,0 +1,103 @@ +challengeIndicator = $challengeIndicator; + $this->challengeWindowSize = $challengeWindowSize; + $this->decoupledIndicator = $decoupledIndicator; + $this->decoupledMaxTime = $decoupledMaxTime; + $this->merchantFraudRate = $merchantFraudRate; + } + + /** + * @return string|null + */ + public function getChallengeIndicator(): ?string + { + return $this->challengeIndicator; + } + + /** + * @return string|null + */ + public function getChallengeWindowSize(): ?string + { + return $this->challengeWindowSize; + } + + /** + * @return string|null + */ + public function getDecoupledIndicator(): ?string + { + return $this->decoupledIndicator; + } + + /** + * @return int|null + */ + public function getDecoupledMaxTime(): ?int + { + return $this->decoupledMaxTime; + } + + /** + * @return int|null + */ + public function getMerchantFraudRate(): ?int + { + return $this->merchantFraudRate; + } +} diff --git a/src/Domain/Payments/ValueObject/ThreeDSecureExemption.php b/src/Domain/Payments/ValueObject/ThreeDSecureExemption.php new file mode 100644 index 0000000..c48af6d --- /dev/null +++ b/src/Domain/Payments/ValueObject/ThreeDSecureExemption.php @@ -0,0 +1,103 @@ +lowValue = $lowValue; + $this->secureCoorporate = $secureCoorporate; + $this->transactionRiskAnalysis = $transactionRiskAnalysis; + $this->trustedBeneficiary = $trustedBeneficiary; + $this->vmid = $vmid; + } + + /** + * @return bool|null + */ + public function getLowValue(): ?bool + { + return $this->lowValue; + } + + /** + * @return bool|null + */ + public function getSecureCoorporate(): ?bool + { + return $this->secureCoorporate; + } + + /** + * @return bool|null + */ + public function getTransactionRiskAnalysis(): ?bool + { + return $this->transactionRiskAnalysis; + } + + /** + * @return bool|null + */ + public function getTrustedBeneficiary(): ?bool + { + return $this->trustedBeneficiary; + } + + /** + * @return string|null + */ + public function getVmid(): ?string + { + return $this->vmid; + } +} diff --git a/src/Domain/Payments/ValueObject/ThreeDSecureRecurringInfo.php b/src/Domain/Payments/ValueObject/ThreeDSecureRecurringInfo.php new file mode 100644 index 0000000..1d7ffdb --- /dev/null +++ b/src/Domain/Payments/ValueObject/ThreeDSecureRecurringInfo.php @@ -0,0 +1,71 @@ +purchaseDate = $purchaseDate; + $this->recurringEnd = $recurringEnd; + $this->recurringFrequency = $recurringFrequency; + } + + /** + * @return \Payvision\SDK\DataType\DateTime|null + */ + public function getPurchaseDate(): ?\Payvision\SDK\DataType\DateTime + { + return $this->purchaseDate; + } + + /** + * @return \Payvision\SDK\DataType\Date|null + */ + public function getRecurringEnd(): ?\Payvision\SDK\DataType\Date + { + return $this->recurringEnd; + } + + /** + * @return int|null + */ + public function getRecurringFrequency(): ?int + { + return $this->recurringFrequency; + } +} diff --git a/tests/Test/Api/AbstractPaymentTest.php b/tests/Test/Api/AbstractPaymentTest.php index 9ea1a8a..9d4942b 100644 --- a/tests/Test/Api/AbstractPaymentTest.php +++ b/tests/Test/Api/AbstractPaymentTest.php @@ -66,7 +66,7 @@ protected function prepareFakePaymentRequest(): void * @throws ReflectionException * @throws Exception */ - public function testPaymentCreationSuccessful(): void + public function testPaymentCreationSuccessful(): PaymentResponse { $requestObject = $this->createFakePaymentRequest(); $request = RequestBuilder::newPayment($requestObject); @@ -76,6 +76,19 @@ public function testPaymentCreationSuccessful(): void self::assertInstanceOf($request->getResponseObjectByStatusCode(200), $response); self::assertEquals(PaymentResponse::PENDING, $response->getResult()); + + return $response; + } + + /** + * @depends testPaymentCreationSuccessful + */ + public function testGetPayments(PaymentResponse $response): void + { + $trackingCode = $response->getBody()->getTransaction()->getTrackingCode(); + + $request = RequestBuilder::getPayments($this->credentials['businessId'], $trackingCode); + $responses = $this->apiConnection->executeAndReturnArray($request); } /** diff --git a/tests/Test/Unit/Application/Request/BuilderTest.php b/tests/Test/Unit/Application/Request/BuilderTest.php index 66d51ee..56c3b26 100644 --- a/tests/Test/Unit/Application/Request/BuilderTest.php +++ b/tests/Test/Unit/Application/Request/BuilderTest.php @@ -70,7 +70,7 @@ public function testNestedReflection(): void $requestObject = new PaymentRequest( PaymentRequest::ACTION_PAYMENT, new PaymentRequestBody( - new PaymentRequestTransaction(1.00, 'XXX', 'EUR') + new PaymentRequestTransaction(1.00, 'EUR', 'XXX') ), new PaymentRequestHeader('abc123') ); @@ -84,8 +84,8 @@ public function testNestedReflection(): void 'body' => [ 'transaction' => [ 'amount' => 1.00, - 'trackingCode' => 'XXX', 'currencyCode' => 'EUR', + 'trackingCode' => 'XXX', ], ], 'action' => 'payment',