Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 6 additions & 1 deletion docs/request/customerinfo.md
Original file line number Diff line number Diff line change
@@ -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();
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/AbstractApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 11 additions & 6 deletions src/Request/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down