Skip to content

Commit

Permalink
release v7.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Miguel Vela Romera committed Dec 22, 2020
1 parent fe29223 commit 43dbac1
Show file tree
Hide file tree
Showing 44 changed files with 2,942 additions and 207 deletions.
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ The debug-property is passed through to the Guzzle Client. See
<http://docs.guzzlephp.org/en/stable/request-options.html#debug> 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.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 12 additions & 1 deletion src/Domain/Checkouts/Service/Builder/Checkout/RequestBody.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
*/
Expand All @@ -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')
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php

declare(strict_types=1);

/**
* @copyright Copyright (c) 2018-2020 Payvision B.V. (https://www.payvision.com/)
* @license see LICENCE.TXT
*
* Warning! This file is auto-generated! Any changes made to this file will be deleted in the future!
*/

namespace Payvision\SDK\Domain\Checkouts\Service\Builder\Checkout;

use Payvision\SDK\Domain\Checkouts\ValueObject\Checkout\RequestThreeDSecure as RequestThreeDSecureObject;
use Payvision\SDK\Domain\Checkouts\ValueObject\ThreeDSecureAdditionalInfo;
use Payvision\SDK\Domain\Checkouts\ValueObject\ThreeDSecureExemption;
use Payvision\SDK\Domain\Checkouts\ValueObject\ThreeDSecureRecurringInfo;
use Payvision\SDK\Domain\Service\Builder\Basic;

class RequestThreeDSecure extends Basic
{
/**
* @return RequestThreeDSecureObject
*/
public function build(): RequestThreeDSecureObject
{
return $this->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')
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand All @@ -114,6 +125,7 @@ public function __construct()
$this->optionBuilder = new RequestOptionBuilder();
$this->orderBuilder = new RequestOrderBuilder();
$this->shippingAddressBuilder = new RequestShippingAddressBuilder();
$this->threeDSecureBuilder = new RequestThreeDSecureBuilder();
}

/**
Expand Down Expand Up @@ -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
*/
Expand All @@ -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
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<?php

declare(strict_types=1);

/**
* @copyright Copyright (c) 2018-2020 Payvision B.V. (https://www.payvision.com/)
* @license see LICENCE.TXT
*
* Warning! This file is auto-generated! Any changes made to this file will be deleted in the future!
*/

namespace Payvision\SDK\Domain\Checkouts\Service\Builder\Composite\Checkout;

use Payvision\SDK\Domain\Checkouts\ValueObject\Checkout\RequestThreeDSecure as RequestThreeDSecureObject;
use Payvision\SDK\Domain\Checkouts\Service\Builder\ThreeDSecureAdditionalInfo as ThreeDSecureAdditionalInfoBuilder;
use Payvision\SDK\Domain\Checkouts\Service\Builder\ThreeDSecureExemption as ThreeDSecureExemptionBuilder;
use Payvision\SDK\Domain\Checkouts\Service\Builder\ThreeDSecureRecurringInfo as ThreeDSecureRecurringInfoBuilder;
use Payvision\SDK\Domain\Service\Builder\Basic;

class RequestThreeDSecure extends Basic
{
/**
* @var ThreeDSecureAdditionalInfoBuilder
*/
private $additionalInfoBuilder;

/**
* @var bool
*/
private $isAdditionalInfoBuilderTouched = false;

/**
* @var ThreeDSecureExemptionBuilder
*/
private $exemptionBuilder;

/**
* @var bool
*/
private $isExemptionBuilderTouched = false;

/**
* @var ThreeDSecureRecurringInfoBuilder
*/
private $recurringInfoBuilder;

/**
* @var bool
*/
private $isRecurringInfoBuilderTouched = false;

public function __construct()
{
$this->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')
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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')
);
}
}
Loading

0 comments on commit 43dbac1

Please sign in to comment.