diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b8d280..140ca82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ 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.0] - 2025-05-12 +### Added +- Make billing and shipping address optional for Customer Info + ## [3.4.9] - 2025-04-22 ### Added - Provide `setCustomerCreatedDate` method to set `extra_merchant_data` for the `createPaymentRequest` callback config. diff --git a/docs/request/customerinfo.md b/docs/request/customerinfo.md index 4326f09..6d86858 100644 --- a/docs/request/customerinfo.md +++ b/docs/request/customerinfo.md @@ -1,7 +1,7 @@ [<](../index.md) Altapay - PHP Api - Customer Info ================================================== -A customer object requries a billing address +You can optionally supply a billing address when you instantiate a Customer object. ```php $billingAddress = new \Altapay\Request\Address(); @@ -12,7 +12,12 @@ $billingAddress->City = 'City'; $billingAddress->PostalCode = 'Postal code'; $billingAddress->Region = 'Region'; $billingAddress->Country = 'Country'; + +// 1) With a billing address: $customer = new Altapay\Request\Customer($billingAddress); + +// 2) Without a billing address: +$customer = new Altapay\Request\Customer(); ``` We can also add a shipping address diff --git a/src/AbstractApi.php b/src/AbstractApi.php index 24fb8a5..82ac64f 100644 --- a/src/AbstractApi.php +++ b/src/AbstractApi.php @@ -55,7 +55,7 @@ abstract class AbstractApi /** * PHP API version */ - const PHP_API_VERSION = '3.4.9'; + const PHP_API_VERSION = '3.5.0'; /** * Event dispatcher diff --git a/src/Request/Customer.php b/src/Request/Customer.php index 48bd7f3..5088d1b 100644 --- a/src/Request/Customer.php +++ b/src/Request/Customer.php @@ -125,14 +125,14 @@ class Customer extends AbstractSerializer /** * Billing address * - * @var Address + * @var Address|null */ private $billing; /** * Shipping address * - * @var Address + * @var Address|null */ private $shipping; @@ -265,9 +265,9 @@ class Customer extends AbstractSerializer /** * Customer constructor. * - * @param Address $billingAddress Billing address + * @param Address|null $billingAddress Billing address */ - public function __construct(Address $billingAddress) + public function __construct(Address $billingAddress = null) { $this->billing = $billingAddress; } @@ -860,8 +860,13 @@ public function serialize() $output['shipping_ref'] = $this->shippingRef; } - $this->setAddress($output, 'billing_', $this->billing); - $this->setAddress($output, 'shipping_', $this->shipping); + if ($this->billing) { + $this->setAddress($output, 'billing_', $this->billing); + } + + if ($this->shipping) { + $this->setAddress($output, 'shipping_', $this->shipping); + } return $output; }