From 02c04811b086a7bde6cc4e688db188067d000e54 Mon Sep 17 00:00:00 2001 From: Bushra Asif Date: Sun, 26 Oct 2025 20:29:29 +0500 Subject: [PATCH 1/7] Add support for new customer organization fields --- CHANGELOG.md | 5 ++ docs/request/customerinfo.md | 8 +++ src/AbstractApi.php | 2 +- src/Request/Customer.php | 99 +++++++++++++++++++++++++-- src/Types/OrganisationEntityTypes.php | 64 +++++++++++++++++ 5 files changed, 172 insertions(+), 6 deletions(-) create mode 100644 src/Types/OrganisationEntityTypes.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 2de8e7c..093cbf7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [3.5.6] - 2025-10-27 +### Added +- Add support for new customer organization fields: `organisation_name`, `organisation_entity_type`, and `organisation_vat_id` with proper validation. +- Deprecate legacy customer fields (`company_name`, `company_type`, `vat_id`, `type`) with runtime warnings and migration guidance. + ## [3.5.5] - 2025-10-09 ### Fixes - Fix deprecation warnings on PHP 8.4 diff --git a/docs/request/customerinfo.md b/docs/request/customerinfo.md index 6d86858..04c7e56 100644 --- a/docs/request/customerinfo.md +++ b/docs/request/customerinfo.md @@ -46,9 +46,17 @@ setBankPhone(string) | Customer bank phone | string setBirthdate(DateTime) | Customer birthdate | DateTime setCreatedDate(DateTime) | When was the customer created | DateTime setOrganisationNumber(string) | The country specific organisation number for the customer, if it is a corporate customer. | string +setOrganisationName(string) | The organisation name. **Preferred over setCompanyName()** | string +setOrganisationEntityType(string) | The organisation nature. **Validated values:** ltd (limited company), plc (public limited company), public_institution (public institution), other (all other types). **Preferred over setCompanyType()** | string +setVatId(string) | **Deprecated:** The VAT identifier. Use setOrganisationVatId() instead | string +setOrganisationVatId(string) | The organisation VAT identifier. **Preferred method for VAT ID** | string setPersonalIdentifyNumber(string) | The country specific personal identity number for the customer, for countries where it is applicable. eg. Norway, Sweden, Finland | string setGender(string) | What gender is the customer | String (f, female, m, male) setCardHolderName(string) | Set the cardholder name associated with the customer | string +**Deprecated Methods** | | +setType(string) | **Deprecated:** Customer type indicator. Any organisation_* field automatically triggers business customer | string +setCompanyName(string) | **Deprecated:** Use setOrganisationName() instead | string +setCompanyType(string) | **Deprecated:** Use setOrganisationEntityType() instead | string ```php $customer->setEmail('email@email.com'); $customer->setBirthdate(new \DateTime('1982-07-23')); diff --git a/src/AbstractApi.php b/src/AbstractApi.php index 0b66785..82c6522 100644 --- a/src/AbstractApi.php +++ b/src/AbstractApi.php @@ -55,7 +55,7 @@ abstract class AbstractApi /** * PHP API version */ - const PHP_API_VERSION = '3.5.5'; + const PHP_API_VERSION = '3.5.6'; /** * Event dispatcher diff --git a/src/Request/Customer.php b/src/Request/Customer.php index 2b98747..d467503 100644 --- a/src/Request/Customer.php +++ b/src/Request/Customer.php @@ -24,6 +24,7 @@ namespace Altapay\Request; use Altapay\Exceptions\Exception; +use Altapay\Types\OrganisationEntityTypes; class Customer extends AbstractSerializer { @@ -46,28 +47,32 @@ class Customer extends AbstractSerializer /** * Indicator of whether the customer is an individual or a business. - * + * + * @deprecated Any customer_info[organisation_*] field set will trigger the business customer indicator. * @var string */ private $type; /** * Name of the customer,if the customer type is Business. - * + * + * @deprecated Please use customer_info[organisation_name] field instead. * @var string */ private $companyName; /** * The nature of the company. - * + * + * @deprecated Please use customer_info[organisation_entity_type] field instead. * @var string */ private $companyType; /** * The company's VAT registration number. - * + * + * @deprecated Please use customer_info[organisation_vat_id] field instead. * @var string */ private $vatId; @@ -114,6 +119,27 @@ class Customer extends AbstractSerializer */ private $organisationNumber; + /** + * The organisation name. + * + * @var string + */ + private $organisationName; + + /** + * The organisation nature (ltd, plc, public_institution, other). + * + * @var string + */ + private $organisationEntityType; + + /** + * The organisation VAT identifier. + * + * @var string + */ + private $organisationVatId; + /** * The country specific personal identity number for the customer, * for countries where it is applicable. eg. Norway, Sweden, Finland @@ -315,6 +341,7 @@ public function setUsername($username) /** * Set Customer Type * + * @deprecated Any customer_info[organisation_*] field set will trigger the business customer indicator. * @param string $type * * @return $this @@ -329,6 +356,7 @@ public function setType($type) /** * Set Company Name * + * @deprecated Please use setOrganisationName() method instead. * @param string $companyName * * @return $this @@ -343,6 +371,7 @@ public function setCompanyName($companyName) /** * Set Company Type * + * @deprecated Please use setOrganisationEntityType() method instead. * @param string $companyType * * @return $this @@ -357,6 +386,7 @@ public function setCompanyType($companyType) /** * Set VAT Id * + * @deprecated Please use setOrganisationVatId() method instead. The vat_id field is deprecated. * @param string $vatId * * @return $this @@ -500,6 +530,54 @@ public function setOrganisationNumber($organisationNumber) return $this; } + /** + * Set Organisation Name + * + * @param string $organisationName + * + * @return $this + */ + public function setOrganisationName($organisationName) + { + $this->organisationName = $organisationName; + + return $this; + } + + /** + * Set Organisation Entity Type + * + * @param string $organisationEntityType + * + * @return $this + * + * @throws Exception + */ + public function setOrganisationEntityType($organisationEntityType) + { + if (!OrganisationEntityTypes::isAllowed($organisationEntityType)) { + throw new Exception('setOrganisationEntityType() only allows the values: ' . implode(', ', OrganisationEntityTypes::getAllowed())); + } + + $this->organisationEntityType = $organisationEntityType; + + return $this; + } + + /** + * Set Organisation VAT ID + * + * @param string $organisationVatId + * + * @return $this + */ + public function setOrganisationVatId($organisationVatId) + { + $this->organisationVatId = $organisationVatId; + + return $this; + } + /** * @param string $personalIdentifyNumber * @@ -793,9 +871,20 @@ public function serialize() } if ($this->organisationNumber) { - $output['organisationNumber'] = $this->organisationNumber; + $output['organisation_number'] = $this->organisationNumber; + } + + if ($this->organisationName) { + $output['organisation_name'] = $this->organisationName; } + if ($this->organisationEntityType) { + $output['organisation_entity_type'] = $this->organisationEntityType; + } + + if ($this->organisationVatId) { + $output['organisation_vat_id'] = $this->organisationVatId; + } if ($this->personalIdentifyNumber) { $output['personalIdentifyNumber'] = $this->personalIdentifyNumber; } diff --git a/src/Types/OrganisationEntityTypes.php b/src/Types/OrganisationEntityTypes.php new file mode 100644 index 0000000..be23e8f --- /dev/null +++ b/src/Types/OrganisationEntityTypes.php @@ -0,0 +1,64 @@ + + */ + private static $types = [ + 'ltd', + 'plc', + 'public_institution', + 'other', + ]; + + /** + * Get allowed values + * + * @return list + */ + public static function getAllowed() + { + return self::$types; + } + + /** + * Is the requested value allowed + * + * @param string $value + * + * @return bool + */ + public static function isAllowed($value) + { + return in_array($value, self::$types); + } +} \ No newline at end of file From 931dcaed834cb938264bb629002c58a079b169bc Mon Sep 17 00:00:00 2001 From: Bushra Asif Date: Sun, 26 Oct 2025 20:36:27 +0500 Subject: [PATCH 2/7] Add sonarqube workflow --- .github/workflows/sonarqube-analysis.yml | 31 ++++++++++++++++++++++++ sonar-project.properties | 3 +++ 2 files changed, 34 insertions(+) create mode 100644 .github/workflows/sonarqube-analysis.yml create mode 100644 sonar-project.properties diff --git a/.github/workflows/sonarqube-analysis.yml b/.github/workflows/sonarqube-analysis.yml new file mode 100644 index 0000000..324ba29 --- /dev/null +++ b/.github/workflows/sonarqube-analysis.yml @@ -0,0 +1,31 @@ +name: SonarQube Analysis + +on: + pull_request: + push: + branches: ["**"] + +jobs: + build: + name: Run SonarQube Analysis + runs-on: self-hosted + + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 + + - name: SonarQube Scan + uses: sonarsource/sonarqube-scan-action@v6 + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} + + - name: SonarQube Quality Gate check + id: sonarqube-quality-gate-check + uses: sonarsource/sonarqube-quality-gate-action@v1.2.0 + with: + pollingTimeoutSec: 600 + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..b194212 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,3 @@ +sonar.projectKey=AltaPay_api-php_90804e1e-91c4-43f6-a024-51f03ac0e4e8 +sonar.projectBaseDir=src +sonar.coverage.exclusions=** \ No newline at end of file From 5c4cd34b0fd7db4a9418641e8ac4fc3baed89cdf Mon Sep 17 00:00:00 2001 From: Bushra Asif Date: Sun, 26 Oct 2025 20:40:28 +0500 Subject: [PATCH 3/7] Updated sonar-properties --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index b194212..6921e39 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,3 +1,3 @@ sonar.projectKey=AltaPay_api-php_90804e1e-91c4-43f6-a024-51f03ac0e4e8 sonar.projectBaseDir=src -sonar.coverage.exclusions=** \ No newline at end of file +sonar.coverage.exclusions=** From e1ab1513eaad371a62e80bcf49401b3785d0c5cc Mon Sep 17 00:00:00 2001 From: Bushra Asif Date: Sun, 26 Oct 2025 20:42:05 +0500 Subject: [PATCH 4/7] Fix missing line space space --- src/Types/OrganisationEntityTypes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Types/OrganisationEntityTypes.php b/src/Types/OrganisationEntityTypes.php index be23e8f..8278bb9 100644 --- a/src/Types/OrganisationEntityTypes.php +++ b/src/Types/OrganisationEntityTypes.php @@ -61,4 +61,4 @@ public static function isAllowed($value) { return in_array($value, self::$types); } -} \ No newline at end of file +} From 95f157db2292964abc0d9ec2dfb34e47d79a99fb Mon Sep 17 00:00:00 2001 From: Bushra Asif Date: Sun, 26 Oct 2025 22:55:55 +0500 Subject: [PATCH 5/7] Fix phpstan issues --- src/Request/Customer.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Request/Customer.php b/src/Request/Customer.php index d467503..2d07747 100644 --- a/src/Request/Customer.php +++ b/src/Request/Customer.php @@ -47,7 +47,7 @@ class Customer extends AbstractSerializer /** * Indicator of whether the customer is an individual or a business. - * + * * @deprecated Any customer_info[organisation_*] field set will trigger the business customer indicator. * @var string */ @@ -55,7 +55,7 @@ class Customer extends AbstractSerializer /** * Name of the customer,if the customer type is Business. - * + * * @deprecated Please use customer_info[organisation_name] field instead. * @var string */ @@ -63,7 +63,7 @@ class Customer extends AbstractSerializer /** * The nature of the company. - * + * * @deprecated Please use customer_info[organisation_entity_type] field instead. * @var string */ @@ -71,7 +71,7 @@ class Customer extends AbstractSerializer /** * The company's VAT registration number. - * + * * @deprecated Please use customer_info[organisation_vat_id] field instead. * @var string */ @@ -356,7 +356,7 @@ public function setType($type) /** * Set Company Name * - * @deprecated Please use setOrganisationName() method instead. + * @deprecated Use setOrganisationName() method instead. * @param string $companyName * * @return $this @@ -371,7 +371,7 @@ public function setCompanyName($companyName) /** * Set Company Type * - * @deprecated Please use setOrganisationEntityType() method instead. + * @deprecated Use setOrganisationEntityType() method instead. * @param string $companyType * * @return $this @@ -386,7 +386,7 @@ public function setCompanyType($companyType) /** * Set VAT Id * - * @deprecated Please use setOrganisationVatId() method instead. The vat_id field is deprecated. + * @deprecated Use setOrganisationVatId() method instead. The vat_id field is deprecated. * @param string $vatId * * @return $this From c73706c1ba0c268096c7a017c2c1594dae30ca9a Mon Sep 17 00:00:00 2001 From: Bushra Asif Date: Sun, 26 Oct 2025 23:01:36 +0500 Subject: [PATCH 6/7] Fix unit test --- tests/Request/CustomerTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Request/CustomerTest.php b/tests/Request/CustomerTest.php index 7f76bd5..7958de0 100644 --- a/tests/Request/CustomerTest.php +++ b/tests/Request/CustomerTest.php @@ -21,11 +21,11 @@ public function test_customer(): void $customer->setGender('f'); $serialized = $customer->serialize(); - $this->assertArrayHasKey('organisationNumber', $serialized); + $this->assertArrayHasKey('organisation_number', $serialized); $this->assertArrayHasKey('personalIdentifyNumber', $serialized); $this->assertArrayHasKey('gender', $serialized); - $this->assertSame('123', $serialized['organisationNumber']); + $this->assertSame('123', $serialized['organisation_number']); $this->assertSame('20304050', $serialized['personalIdentifyNumber']); $this->assertSame('F', $serialized['gender']); From 89f58b6ef393358a177f7e0241ec61e526269088 Mon Sep 17 00:00:00 2001 From: Bushra Asif Date: Sun, 26 Oct 2025 23:05:12 +0500 Subject: [PATCH 7/7] Fix typo --- src/Request/Customer.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Request/Customer.php b/src/Request/Customer.php index 2d07747..e304406 100644 --- a/src/Request/Customer.php +++ b/src/Request/Customer.php @@ -56,7 +56,7 @@ class Customer extends AbstractSerializer /** * Name of the customer,if the customer type is Business. * - * @deprecated Please use customer_info[organisation_name] field instead. + * @deprecated Use customer_info[organisation_name] field instead. * @var string */ private $companyName; @@ -64,7 +64,7 @@ class Customer extends AbstractSerializer /** * The nature of the company. * - * @deprecated Please use customer_info[organisation_entity_type] field instead. + * @deprecated Use customer_info[organisation_entity_type] field instead. * @var string */ private $companyType; @@ -72,7 +72,7 @@ class Customer extends AbstractSerializer /** * The company's VAT registration number. * - * @deprecated Please use customer_info[organisation_vat_id] field instead. + * @deprecated Use customer_info[organisation_vat_id] field instead. * @var string */ private $vatId;