Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added support for shipping address #17

Merged
merged 1 commit into from
Jun 3, 2022
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
13 changes: 12 additions & 1 deletion src/Model/CreatePaymentCustomer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,23 @@ final class CreatePaymentCustomer
private $phone;
/** @var Address|null */
private $billingAddress;
/** @var Address|null */
private $shippingAddress;

/**
* @param string|null $name
* @param string|null $surname
* @param string|null $email
* @param string|null $phone - customer phone in international format max 15 numeric chars https://en.wikipedia.org/wiki/MSISDN
*/
public function __construct($name, $surname, $email, $phone, Address $billingAddress = null)
public function __construct($name, $surname, $email, $phone, Address $billingAddress = null, Address $shippingAddress = null)
{
$this->name = $name === null ? null : new StringValue($name);
$this->surname = $surname === null ? null : new StringValue($surname);
$this->email = $email === null ? null : new StringValue($email);
$this->phone = $phone === null ? null : new PhoneNumber($phone);
$this->billingAddress = $billingAddress;
$this->shippingAddress = $shippingAddress;
}

/**
Expand Down Expand Up @@ -72,4 +75,12 @@ public function getBillingAddress()
{
return $this->billingAddress;
}

/**
* @return Address|null
*/
public function getShippingAddress()
{
return $this->shippingAddress;
}
}
10 changes: 10 additions & 0 deletions src/Model/CreatePaymentParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,16 @@ public function toArray()
'street' => $billingAddress->getStreet(),
);
}

$shippingAddress = $this->customer->getShippingAddress();
if ($shippingAddress) {
$result['customer']['shipping_address'] = array(
'country_code' => $shippingAddress->getCountryCode(),
'city' => $shippingAddress->getCity(),
'zip' => $shippingAddress->getZip(),
'street' => $shippingAddress->getStreet(),
);
}
} else {
$result['customer'] = null;
}
Expand Down