Skip to content

Commit

Permalink
release: version 5.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Miguel Vela Romera committed Sep 3, 2020
1 parent 542d5cb commit b31a507
Show file tree
Hide file tree
Showing 16 changed files with 306 additions and 27 deletions.
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": "5.0.0",
"version": "5.1.0",
"license": "MIT",
"require": {
"php": "^7.2.5|^7.3",
Expand Down
12 changes: 11 additions & 1 deletion src/Domain/Checkouts/Service/Builder/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,24 @@ public function setMessage(string $message): Error
return $this->set('message', $message);
}

/**
* @param string $detailedMessage
* @return Error
*/
public function setDetailedMessage(string $detailedMessage): Error
{
return $this->set('detailedMessage', $detailedMessage);
}

/**
* @return ErrorObject
*/
protected function buildObject(): ErrorObject
{
return new ErrorObject(
$this->get('code'),
$this->get('message')
$this->get('message'),
$this->get('detailedMessage')
);
}
}
18 changes: 17 additions & 1 deletion src/Domain/Checkouts/ValueObject/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,26 @@ class Error
*/
private $message;

/**
* @var string
*/
private $detailedMessage;

/**
* Error constructor.
*
* @param int $code
* @param string $message
* @param string $detailedMessage
*/
public function __construct(
int $code,
string $message
string $message,
string $detailedMessage = null
) {
$this->code = $code;
$this->message = $message;
$this->detailedMessage = $detailedMessage;
}

/**
Expand All @@ -52,4 +60,12 @@ public function getMessage(): string
{
return $this->message;
}

/**
* @return string|null
*/
public function getDetailedMessage(): ?string
{
return $this->detailedMessage;
}
}
12 changes: 11 additions & 1 deletion src/Domain/Paymentlinks/Service/Builder/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,24 @@ public function setMessage(string $message): Error
return $this->set('message', $message);
}

/**
* @param string $detailedMessage
* @return Error
*/
public function setDetailedMessage(string $detailedMessage): Error
{
return $this->set('detailedMessage', $detailedMessage);
}

/**
* @return ErrorObject
*/
protected function buildObject(): ErrorObject
{
return new ErrorObject(
$this->get('code'),
$this->get('message')
$this->get('message'),
$this->get('detailedMessage')
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,24 @@ public function setMessage(string $message): ResponsePaymentError
return $this->set('message', $message);
}

/**
* @param string $detailedMessage
* @return ResponsePaymentError
*/
public function setDetailedMessage(string $detailedMessage): ResponsePaymentError
{
return $this->set('detailedMessage', $detailedMessage);
}

/**
* @return ResponsePaymentErrorObject
*/
protected function buildObject(): ResponsePaymentErrorObject
{
return new ResponsePaymentErrorObject(
$this->get('code'),
$this->get('message')
$this->get('message'),
$this->get('detailedMessage')
);
}
}
18 changes: 17 additions & 1 deletion src/Domain/Paymentlinks/ValueObject/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,26 @@ class Error
*/
private $message;

/**
* @var string
*/
private $detailedMessage;

/**
* Error constructor.
*
* @param int $code
* @param string $message
* @param string $detailedMessage
*/
public function __construct(
int $code,
string $message
string $message,
string $detailedMessage = null
) {
$this->code = $code;
$this->message = $message;
$this->detailedMessage = $detailedMessage;
}

/**
Expand All @@ -52,4 +60,12 @@ public function getMessage(): string
{
return $this->message;
}

/**
* @return string|null
*/
public function getDetailedMessage(): ?string
{
return $this->detailedMessage;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,26 @@ class ResponsePaymentError
*/
private $message;

/**
* @var string
*/
private $detailedMessage;

/**
* ResponsePaymentError constructor.
*
* @param int $code
* @param string $message
* @param string $detailedMessage
*/
public function __construct(
int $code,
string $message
string $message,
string $detailedMessage = null
) {
$this->code = $code;
$this->message = $message;
$this->detailedMessage = $detailedMessage;
}

/**
Expand All @@ -52,4 +60,12 @@ public function getMessage(): string
{
return $this->message;
}

/**
* @return string|null
*/
public function getDetailedMessage(): ?string
{
return $this->detailedMessage;
}
}
12 changes: 11 additions & 1 deletion src/Domain/Payments/Service/Builder/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,24 @@ public function setMessage(string $message): Error
return $this->set('message', $message);
}

/**
* @param string $detailedMessage
* @return Error
*/
public function setDetailedMessage(string $detailedMessage): Error
{
return $this->set('detailedMessage', $detailedMessage);
}

/**
* @return ErrorObject
*/
protected function buildObject(): ErrorObject
{
return new ErrorObject(
$this->get('code'),
$this->get('message')
$this->get('message'),
$this->get('detailedMessage')
);
}
}
18 changes: 17 additions & 1 deletion src/Domain/Payments/ValueObject/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,26 @@ class Error
*/
private $message;

/**
* @var string
*/
private $detailedMessage;

/**
* Error constructor.
*
* @param int $code
* @param string $message
* @param string $detailedMessage
*/
public function __construct(
int $code,
string $message
string $message,
string $detailedMessage = null
) {
$this->code = $code;
$this->message = $message;
$this->detailedMessage = $detailedMessage;
}

/**
Expand All @@ -52,4 +60,12 @@ public function getMessage(): string
{
return $this->message;
}

/**
* @return string|null
*/
public function getDetailedMessage(): ?string
{
return $this->detailedMessage;
}
}
85 changes: 85 additions & 0 deletions src/Domain/Service/Helper/AfterpayErrorMessageHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php

declare(strict_types=1);

/**
* @copyright Copyright (c) 2018-2020 Payvision B.V. (https://www.payvision.com/)
* @license see LICENCE.TXT
*/

namespace Payvision\SDK\Domain\Service\Helper;

use Payvision\SDK\Exception\AfterpayErrorException;

class AfterpayErrorMessageHelper
{
public const BILLTO_CITY_MISSING = 'billto.city.missing';
public const BILLTO_HOUSENUMBER_INVALID = 'billto.housenumber.invalid';
public const BILLTO_HOUSENUMBER_MISSING = 'billto.housenumber.missing';
public const BILLTO_HOUSENUMBERADDITION_INVALID = 'billto.housenumberaddition.invalid';
public const BILLTO_HOUSENUMBERADDITION_MISSING = 'billto.housenumberaddition.missing';
public const BILLTO_ISOCOUNTRYCODE_INVALID = 'billto.isocountrycode.invalid';
public const BILLTO_ISOCOUNTRYCODE_MISSING = 'billto.isocountrycode.missing';
public const BILLTO_ISOLANGUAGE_MISSING = 'billto.isolanguage.missing';
public const BILLTO_PERSON_DATEOFBIRTH_INVALID = 'billto.person.dateofbirth.invalid';
public const BILLTO_PERSON_EMAILADDRESS_INVALID = 'billto.person.emailaddress.invalid';
public const BILLTO_PERSON_EMAILADDRESS_MISSING = 'billto.person.emailaddress.missing';
public const BILLTO_PERSON_GENDER_INVALID = 'billto.person.gender.invalid';
public const BILLTO_PERSON_GENDER_MISSING = 'billto.person.gender.missing';
public const BILLTO_PERSON_INITIALS_INVALID = 'billto.person.initials.invalid';
public const BILLTO_PERSON_INITIALS_MISSING = 'billto.person.initials.missing';
public const BILLTO_PERSON_LASTNAME_INVALID = 'billto.person.lastname.invalid';
public const BILLTO_PERSON_LASTNAME_MISSING = 'billto.person.lastname.missing';
public const BILLTO_PERSON_PREFIX_INVALID = 'billto.person.prefix.invalid';
public const BILLTO_PERSON_PREFIX_MISSING = 'billto.person.prefix.missing';
public const BILLTO_PHONENUMBER1_INVALID = 'billto.phonenumber1.invalid';
public const BILLTO_PHONENUMBER1_MISSING = 'billto.phonenumber1.missing';
public const BILLTO_PHONENUMBER2_INVALID = 'billto.phonenumber2.invalid';
public const BILLTO_PHONENUMBER2_MISSING = 'billto.phonenumber2.missing';
public const BILLTO_POSTALCODE_INVALID = 'billto.postalcode.invalid';
public const BILLTO_POSTALCODE_MISSING = 'billto.postalcode.missing';
public const BILLTO_STREETNAME_MISSING = 'billto.streetname.missing';
public const SHIPTO_HOUSENUMBER_INVALID = 'shipto.housenumber.invalid';
public const SHIPTO_HOUSENUMBER_MISSING = 'shipto.housenumber.missing';
public const SHIPTO_HOUSENUMBERADDITION_INVALID = 'shipto.housenumberaddition.invalid';
public const SHIPTO_HOUSENUMBERADDITION_MISSING = 'shipto.housenumberaddition.missing';
public const SHIPTO_ISOCOUNTRYCODE_INVALID = 'shipto.isocountrycode.invalid';
public const SHIPTO_ISOCOUNTRYCODE_MISSING = 'shipto.isocountrycode.missing';
public const SHIPTO_ISOLANGUAGE_MISSING = 'shipto.isolanguage.missing';
public const SHIPTO_PERSON_GENDER_INVALID = 'shipto.person.gender.invalid';
public const SHIPTO_PERSON_GENDER_MISSING = 'shipto.person.gender.missing';
public const SHIPTO_PERSON_INITIALS_INVALID = 'shipto.person.initials.invalid';
public const SHIPTO_PERSON_INITIALS_MISSING = 'shipto.person.initials.missing';
public const SHIPTO_PERSON_LASTNAME_MISSING = 'shipto.person.lastname.missing';
public const SHIPTO_PERSON_PREFIX_INVALID = 'shipto.person.prefix.invalid';
public const SHIPTO_PERSON_PREFIX_MISSING = 'shipto.person.prefix.missing';
public const SHIPTO_POSTALCODE_INVALID = 'shipto.postalcode.invalid';
public const SHIPTO_POSTALCODE_MISSING = 'shipto.postalcode.missing';
public const SHIPTO_STREETNAME_MISSING = 'shipto.streetname.missing';

/**
* @param string $errorDetail
* @return array
* @throws AfterpayErrorException
*/
public static function extractMessageCodes(string $errorDetail): array
{
$result = [];
$messages = \explode('|', $errorDetail);
foreach ($messages as $message) {
$result[] = self::extractMessageCode(\trim($message));
}
return $result;
}

/**
* @throws AfterpayErrorException
*/
protected static function extractMessageCode(string $message): string
{
if (\preg_match('/^(field\.)?(?P<code>[a-z]+\.[a-z.]+)/', $message, $matches)) {
return $matches['code'];
}
throw new AfterpayErrorException('Unable to handle Afterpay error code: ' . $message);
}
}
16 changes: 16 additions & 0 deletions src/Exception/AfterpayErrorException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

/**
* @copyright Copyright (c) 2018-2020 Payvision B.V. (https://www.payvision.com/)
* @license see LICENCE.TXT
*/

namespace Payvision\SDK\Exception;

use Exception;

class AfterpayErrorException extends Exception
{
}
10 changes: 5 additions & 5 deletions src/Exception/ApiException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

class ApiException extends Exception
{
const RESPONSE_CLASS_NOT_FOUND = 1100;
const CANNOT_BUILD_RESPONSE = 1101;
const INVALID_REQUEST_METHOD = 1102;
const RESPONSE_CLASS_NOT_SET = 1103;
const INVALID_RESPONSE = 1104;
public const RESPONSE_CLASS_NOT_FOUND = 1100;
public const CANNOT_BUILD_RESPONSE = 1101;
public const INVALID_REQUEST_METHOD = 1102;
public const RESPONSE_CLASS_NOT_SET = 1103;
public const INVALID_RESPONSE = 1104;
}
Loading

0 comments on commit b31a507

Please sign in to comment.