diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 79753a6..ec175bd 100755 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,17 +3,12 @@ on: [push] jobs: # Check there is no syntax errors in the project php-linter: - name: PHP Syntax check 5.6|7.4|8.1 + name: PHP Syntax check 7.4|8.1 runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2.0.0 - - name: PHP syntax checker 5.6 - uses: prestashop/github-action-php-lint/5.6@master - with: - folder-to-exclude: "! -path \"./.php-cs-fixer.dist.php\" ! -path \"./tests/*\" ! -path \"./vendor/*\"" - - name: PHP syntax checker 7.4 uses: prestashop/github-action-php-lint/7.4@master with: @@ -38,7 +33,7 @@ jobs: uses: actions/checkout@v2.0.0 - name: Cache dependencies - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: vendor key: php-${{ hashFiles('composer.lock') }} diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index a22a975..29b8ade 100755 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -14,7 +14,7 @@ jobs: uses: actions/checkout@v2.0.0 - name: Cache dependencies - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: vendor key: php-${{ hashFiles('composer.lock') }} diff --git a/bridgesdk.zip b/bridgesdk.zip new file mode 100644 index 0000000..f70c557 Binary files /dev/null and b/bridgesdk.zip differ diff --git a/composer.json b/composer.json index 1116fa3..f0badc3 100755 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "202ecommerce/bridge-sdk", - "version": "1.0.0", + "version": "2.0.0", "description": "Bridge API SDK", "homepage": "https://docs.bridgeapi.io/", "license": "AFL-3.0", diff --git a/gitrepo.zip b/gitrepo.zip new file mode 100644 index 0000000..6c07c57 Binary files /dev/null and b/gitrepo.zip differ diff --git a/src/Client.php b/src/Client.php index ff84962..5e58ca0 100644 --- a/src/Client.php +++ b/src/Client.php @@ -72,7 +72,7 @@ class Client /** * @var string */ - private $version = '2021-06-01'; + private $version = '2025-01-15'; /** * @var Stream diff --git a/src/Model/AbstractModel.php b/src/Model/AbstractModel.php index 77ffbdf..cc75db5 100644 --- a/src/Model/AbstractModel.php +++ b/src/Model/AbstractModel.php @@ -30,7 +30,9 @@ public function jsonSerialize() foreach ($getterName as $value) { if ('get' === substr($value, 0, 3) && 'getAfterParam' !== $value) { $key = lcfirst(substr($value, 3, \strlen($value))); - $gettableAttributes[$this->transformToPascalCase($key)] = $this->{$value}(); + if (false === empty($this->{$value}())) { + $gettableAttributes[$this->transformToPascalCase($key)] = $this->{$value}(); + } } } diff --git a/src/Model/Bank/Bank.php b/src/Model/Bank/Bank.php index 1ecd1f7..a63211a 100755 --- a/src/Model/Bank/Bank.php +++ b/src/Model/Bank/Bank.php @@ -40,21 +40,6 @@ class Bank extends AbstractModel */ protected $logoUrl; - /** - * @var null|bool - */ - protected $isHighlighted; - - /** - * @var ?string - */ - protected $primaryColor; - - /** - * @var ?string - */ - protected $secondaryColor; - /** * @var ?string */ @@ -63,22 +48,7 @@ class Bank extends AbstractModel /** * @var array */ - protected $capabilities = []; - - /** - * @var array - */ - protected $form = []; - - /** - * @var array - */ - protected $channelType = []; - - /** - * @var ?int - */ - protected $displayOrder; + protected $environments = []; /** * @return int @@ -184,84 +154,6 @@ public function setLogoUrl($logoUrl) ); } - /** - * @return null|bool - */ - public function isHighlighted() - { - return $this->isHighlighted; - } - - /** - * @param null|bool $isHighlighted - * - * @return Bank - */ - public function setIsHighlighted($isHighlighted) - { - if (true === \is_bool($isHighlighted) || null === $isHighlighted) { - $this->isHighlighted = $isHighlighted; - - return $this; - } - - throw new InvalidArgumentException( - 'Is highlighted must be a string or null, '.\gettype($isHighlighted).' is given.' - ); - } - - /** - * @return null|string - */ - public function getPrimaryColor() - { - return $this->primaryColor; - } - - /** - * @param null|string $primaryColor - * - * @return Bank - */ - public function setPrimaryColor($primaryColor) - { - if (true === \is_string($primaryColor) || null === $primaryColor) { - $this->primaryColor = $primaryColor; - - return $this; - } - - throw new InvalidArgumentException( - 'Primary color must be a string or null, '.\gettype($primaryColor).' is given.' - ); - } - - /** - * @return null|string - */ - public function getSecondaryColor() - { - return $this->secondaryColor; - } - - /** - * @param null|string $secondaryColor - * - * @return Bank - */ - public function setSecondaryColor($secondaryColor) - { - if (true === \is_string($secondaryColor) || null === $secondaryColor) { - $this->secondaryColor = $secondaryColor; - - return $this; - } - - throw new InvalidArgumentException( - 'Secondary color must be a string or null, '.\gettype($secondaryColor).' is given.' - ); - } - /** * @return null|string */ @@ -291,104 +183,26 @@ public function setParentName($parentName) /** * @return array */ - public function getCapabilities() - { - return $this->capabilities; - } - - /** - * @param array $capabilities - * - * @return Bank - */ - public function setCapabilities($capabilities) - { - if (true === \is_array($capabilities)) { - $this->capabilities = $capabilities; - - return $this; - } - - throw new InvalidArgumentException( - 'Capabilities must be an array, '.\gettype($capabilities).' is given.' - ); - } - - /** - * @return array - */ - public function getForm() - { - return $this->form; - } - - /** - * @param array $form - * - * @return Bank - */ - public function setForm($form) - { - if (true === \is_array($form)) { - $this->form = $form; - - return $this; - } - - throw new InvalidArgumentException( - 'Form must be an array, '.\gettype($form).' is given.' - ); - } - - /** - * @return array - */ - public function getChannelType() - { - return $this->channelType; - } - - /** - * @param array $channelType - * - * @return Bank - */ - public function setChannelType($channelType) - { - if (true === \is_array($channelType)) { - $this->channelType = $channelType; - - return $this; - } - - throw new InvalidArgumentException( - 'Channel type must be an array, '.\gettype($channelType).' is given.' - ); - } - - /** - * @return null|int - */ - public function getDisplayOrder() + public function getEnvironments() { - return $this->displayOrder; + return $this->environments; } /** - * @param null|int $displayOrder + * @param array $environments * * @return Bank */ - public function setDisplayOrder($displayOrder) + public function setEnvironments($environments) { - if (true === \is_int($displayOrder) || null === $displayOrder) { - $this->displayOrder = $displayOrder; + if (true === \is_array($environments)) { + $this->environments = $environments; return $this; } throw new InvalidArgumentException( - 'Display order must be an int or null, '.\gettype($displayOrder).' is given.' + 'Environments must be an array, '.\gettype($environments).' is given.' ); } } diff --git a/src/Model/Payment/CreatePayment.php b/src/Model/Payment/CreatePayment.php index 6253fdb..e66e592 100755 --- a/src/Model/Payment/CreatePayment.php +++ b/src/Model/Payment/CreatePayment.php @@ -23,17 +23,12 @@ class CreatePayment extends AbstractModel /** * @var string */ - private $successfulCallbackUrl; - - /** - * @var string - */ - private $unsuccessfulCallbackUrl; + private $callbackUrl; /** * @var int */ - private $bankId; + private $providerId; /** * @var array @@ -48,78 +43,52 @@ class CreatePayment extends AbstractModel /** * @return string */ - public function getSuccessfulCallbackUrl() - { - return $this->successfulCallbackUrl; - } - - /** - * @param string $successfulCallbackUrl - * - * @return CreatePayment - */ - public function setSuccessfulCallbackUrl($successfulCallbackUrl) - { - if (true === \is_string($successfulCallbackUrl)) { - $this->successfulCallbackUrl = $successfulCallbackUrl; - - return $this; - } - - throw new InvalidArgumentException( - 'Successful callback url must be a string '.\gettype($successfulCallbackUrl).' is given.' - ); - } - - /** - * @return string - */ - public function getUnsuccessfulCallbackUrl() + public function getCallbackUrl() { - return $this->unsuccessfulCallbackUrl; + return $this->callbackUrl; } /** - * @param string $unsuccessfulCallbackUrl + * @param string $callbackUrl * * @return CreatePayment */ - public function setUnsuccessfulCallbackUrl($unsuccessfulCallbackUrl) + public function setCallbackUrl($callbackUrl) { - if (true === \is_string($unsuccessfulCallbackUrl)) { - $this->unsuccessfulCallbackUrl = $unsuccessfulCallbackUrl; + if (true === \is_string($callbackUrl)) { + $this->callbackUrl = $callbackUrl; return $this; } throw new InvalidArgumentException( - 'Unsuccessful callback url must be a string '.\gettype($unsuccessfulCallbackUrl).' is given.' + 'Callback url must be a string '.\gettype($callbackUrl).' is given.' ); } /** * @return int */ - public function getBankId() + public function getProviderId() { - return $this->bankId; + return $this->providerId; } /** - * @param int $bankId + * @param int $providerId * * @return CreatePayment */ - public function setBankId($bankId) + public function setProviderId($providerId) { - if (true === \is_int($bankId)) { - $this->bankId = $bankId; + if (true === \is_int($providerId)) { + $this->providerId = $providerId; return $this; } throw new InvalidArgumentException( - 'Bank id must be an int '.\gettype($bankId).' is given.' + 'Provider id must be an int '.\gettype($providerId).' is given.' ); } diff --git a/src/Model/Payment/CreatePaymentUrl.php b/src/Model/Payment/CreatePaymentUrl.php index 4d29b7e..7cdc646 100755 --- a/src/Model/Payment/CreatePaymentUrl.php +++ b/src/Model/Payment/CreatePaymentUrl.php @@ -28,7 +28,7 @@ class CreatePaymentUrl extends AbstractModel /** * @var string */ - private $consentUrl; + private $url; /** * @return string @@ -59,26 +59,26 @@ public function setId($id) /** * @return string */ - public function getConsentUrl() + public function getUrl() { - return $this->consentUrl; + return $this->url; } /** - * @param string $consentUrl + * @param string $url * * @return CreatePaymentUrl */ - public function setConsentUrl($consentUrl) + public function setUrl($url) { - if (true === \is_string($consentUrl)) { - $this->consentUrl = $consentUrl; + if (true === \is_string($url)) { + $this->url = $url; return $this; } throw new InvalidArgumentException( - 'Consent url must be a string '.\gettype($consentUrl).' is given.' + 'Consent url must be a string '.\gettype($url).' is given.' ); } } diff --git a/src/Model/Payment/Payment.php b/src/Model/Payment/Payment.php index f89592b..56db93d 100755 --- a/src/Model/Payment/Payment.php +++ b/src/Model/Payment/Payment.php @@ -39,7 +39,7 @@ class Payment extends AbstractModel /** * @var int */ - private $bankId; + private $providerId; /** * @var string @@ -130,26 +130,26 @@ public function setStatusReason($statusReason) /** * @return int */ - public function getBankId() + public function getProviderId() { - return $this->bankId; + return $this->providerId; } /** - * @param int $bankId + * @param int $providerId * * @return Payment */ - public function setBankId($bankId) + public function setProviderId($providerId) { - if (true === \is_int($bankId)) { - $this->bankId = $bankId; + if (true === \is_int($providerId)) { + $this->providerId = $providerId; return $this; } throw new InvalidArgumentException( - 'Bank id must be an int '.\gettype($bankId).' is given.' + 'Provider id must be an int '.\gettype($providerId).' is given.' ); } diff --git a/src/Model/Payment/PaymentUser.php b/src/Model/Payment/PaymentUser.php index f04bc41..6e7a50b 100644 --- a/src/Model/Payment/PaymentUser.php +++ b/src/Model/Payment/PaymentUser.php @@ -31,7 +31,22 @@ class PaymentUser extends AbstractModel private $lastName; /** - * @var string + * @var string|null + */ + protected $companyName; + + /** + * @var string|null + */ + protected $email; + + /** + * @var string|null + */ + protected $externalReference; + + /** + * @var string|null */ private $ipAddress; @@ -84,9 +99,80 @@ public function setLastName($lastName) } /** - * @return string + * @return string|null + */ + public function getCompanyName(): ?string + { + return $this->companyName; + } + + /** + * @param string $companyName + * + * @return PaymentUser + */ + public function setCompanyName(string $companyName): PaymentUser + { + if (true === \is_string($companyName)) { + $this->companyName = $companyName; + + return $this; + } + + throw new InvalidArgumentException('Company name must be a string '.\gettype($companyName).' is given.'); } + + /** + * @return string|null + */ + public function getEmail(): ?string + { + return $this->email; + } + + /** + * @param string $email + * + * @return PaymentUser + */ + public function setEmail(string $email): PaymentUser + { + if (true === \is_string($email)) { + $this->email = $email; + + return $this; + } + + throw new InvalidArgumentException('Email must be a string '.\gettype($email).' is given.'); + } + + /** + * @return string|null + */ + public function getExternalReference(): ?string + { + return $this->externalReference; + } + + /** + * @param string $externalReference + * + * @return PaymentUser + */ + public function setExternalReference(string $externalReference): PaymentUser + { + if (true === \is_string($externalReference)) { + $this->externalReference = $externalReference; + + return $this; + } + + throw new InvalidArgumentException('External reference must be a string '.\gettype($externalReference).' is given.'); + } + + /** + * @return string|null */ - public function getIpAddress() + public function getIpAddress(): ?string { return $this->ipAddress; } @@ -96,7 +182,7 @@ public function getIpAddress() * * @return PaymentUser */ - public function setIpAddress($ipAddress) + public function setIpAddress(string $ipAddress) { if (true === \is_string($ipAddress)) { $this->ipAddress = $ipAddress; diff --git a/src/Request/AbstractRequest.php b/src/Request/AbstractRequest.php index c6c4490..3346ee3 100755 --- a/src/Request/AbstractRequest.php +++ b/src/Request/AbstractRequest.php @@ -52,7 +52,7 @@ abstract class AbstractRequest implements RequestInterface, JsonSerializable public function __construct(array $headers = [], $version = '1.1', $query = []) { $this->uri = new ApiUri(); - $this->uri = $this->uri->withPath('/v2'.$this->requestTarget); + $this->uri = $this->uri->withPath('/v3' . $this->requestTarget); $this->setQuery($query); if (!empty($this->getQuery())) { diff --git a/src/Request/BankRequest.php b/src/Request/BankRequest.php index f68902c..e4c5aac 100755 --- a/src/Request/BankRequest.php +++ b/src/Request/BankRequest.php @@ -22,7 +22,7 @@ class BankRequest extends AbstractRequest { - protected $requestTarget = '/banks/:idBank'; + protected $requestTarget = '/providers/:providerId'; protected $method = 'GET'; @@ -34,7 +34,7 @@ class BankRequest extends AbstractRequest public function setModel(AbstractModel $body) { if ($body instanceof Bank) { - $this->uri = $this->uri->withPath(str_replace(':idBank', (string) $body->getId(), $this->uri->getPath())); + $this->uri = $this->uri->withPath(str_replace(':providerId', (string) $body->getId(), $this->uri->getPath())); return parent::setModel($body); } diff --git a/src/Request/CreatePaymentRequest.php b/src/Request/CreatePaymentRequest.php index 3f487f7..63d461e 100755 --- a/src/Request/CreatePaymentRequest.php +++ b/src/Request/CreatePaymentRequest.php @@ -22,7 +22,7 @@ class CreatePaymentRequest extends AbstractRequest { - protected $requestTarget = '/payment-requests'; + protected $requestTarget = '/payment/payment-requests'; protected $method = 'POST'; diff --git a/src/Request/ListBanksRequest.php b/src/Request/ListBanksRequest.php index 083a390..792e5f4 100755 --- a/src/Request/ListBanksRequest.php +++ b/src/Request/ListBanksRequest.php @@ -23,7 +23,7 @@ class ListBanksRequest extends AbstractRequest /** * @var string */ - protected $requestTarget = '/banks'; + protected $requestTarget = '/providers'; /** * @var string diff --git a/src/Request/PaymentRequest.php b/src/Request/PaymentRequest.php index 271e927..e9cbd08 100755 --- a/src/Request/PaymentRequest.php +++ b/src/Request/PaymentRequest.php @@ -22,7 +22,7 @@ class PaymentRequest extends AbstractRequest { - protected $requestTarget = '/payment-requests/:idPayment'; + protected $requestTarget = '/payment/payment-requests/:idPayment'; protected $method = 'GET'; diff --git a/src/Response/BankResponse.php b/src/Response/BankResponse.php index ff817fc..0685c70 100755 --- a/src/Response/BankResponse.php +++ b/src/Response/BankResponse.php @@ -46,6 +46,12 @@ public function getModel() return (new Error())->hydrate($output); } + $output['logo_url'] = empty($output['images']) || empty($output['images']['logo']) ? '' : $output['images']['logo']; + $output['parent_name'] = empty($output['group_name']) ? '' : $output['group_name']; + if (isset($response['payment_metadata']['provider_environments'])) { + $output['environments'] = $output['payment_metadata']['provider_environments']; + } + return (new Bank())->hydrate($output); } }