diff --git a/src/Message/CreateCustomerRequest.php b/src/Message/CreateCustomerRequest.php index b49d0332..d0e13944 100644 --- a/src/Message/CreateCustomerRequest.php +++ b/src/Message/CreateCustomerRequest.php @@ -104,11 +104,32 @@ public function setEmail($value) return $this->setParameter('email', $value); } + /** + * Get the customer's shipping address. + * + * @return array + */ + public function getShipping() + { + return $this->getParameter('shipping'); + } + + /** + * Sets the customer's shipping address. + * + * @param array $value + * @return CreateCustomerRequest provides a fluent interface. + */ + public function setShipping($value) + { + return $this->setParameter('shipping', $value); + } + public function getName() { return $this->getParameter('name'); } - + /** * Sets the customer's name. * @@ -156,6 +177,9 @@ public function getData() $data['source'] = $this->getSource(); } + if ($this->getShipping()) { + $data['shipping'] = $this->getShipping(); + } if ($this->getName()) { $data['name'] = $this->getName(); } diff --git a/src/Message/UpdateCustomerRequest.php b/src/Message/UpdateCustomerRequest.php index d05cf8c9..90e55993 100644 --- a/src/Message/UpdateCustomerRequest.php +++ b/src/Message/UpdateCustomerRequest.php @@ -50,13 +50,34 @@ public function getEmail() * Sets the customer's email address. * * @param string $value - * @return CreateCustomerRequest provides a fluent interface. + * @return UpdateCustomerRequest provides a fluent interface. */ public function setEmail($value) { return $this->setParameter('email', $value); } + /** + * Get the customer's shipping address. + * + * @return array + */ + public function getShipping() + { + return $this->getParameter('shipping'); + } + + /** + * Sets the customer's shipping address. + * + * @param array $value + * @return UpdateCustomerRequest provides a fluent interface. + */ + public function setShipping($value) + { + return $this->setParameter('shipping', $value); + } + /** * Get the customer's source. * @@ -71,7 +92,7 @@ public function getSource() * Sets the customer's source. * * @param string $value - * @return CreateCustomerRequest provides a fluent interface. + * @return UpdateCustomerRequest provides a fluent interface. */ public function setSource($value) { @@ -102,6 +123,10 @@ public function getData() $data['source'] = $this->getSource(); } + if ($this->getShipping()) { + $data['shipping'] = $this->getShipping(); + } + return $data; } diff --git a/tests/Message/CreateCustomerRequestTest.php b/tests/Message/CreateCustomerRequestTest.php index bdf9d4bc..e9ea9e4c 100644 --- a/tests/Message/CreateCustomerRequestTest.php +++ b/tests/Message/CreateCustomerRequestTest.php @@ -21,8 +21,11 @@ public function testEndpoint() public function testData() { + $shipping = array('name' => 'John Doe', ['address' => ['line1' => 'Some street']]); + $this->request->setEmail('customer@business.dom'); $this->request->setDescription('New customer'); + $this->request->setShipping($shipping); $this->request->setMetadata(['field' => 'value']); $this->request->setPaymentMethod('payment_method_id'); $this->request->setName('Customer Name'); @@ -33,6 +36,7 @@ public function testData() $this->assertSame('New customer', $data['description']); $this->assertArrayHasKey('field', $data['metadata']); $this->assertSame('value', $data['metadata']['field']); + $this->assertSame($shipping, $data['shipping']); $this->assertSame('payment_method_id', $data['payment_method']); $this->assertSame('Customer Name', $data['name']); } diff --git a/tests/Message/UpdateCustomerRequestTest.php b/tests/Message/UpdateCustomerRequestTest.php index 6cf362f1..4834362b 100644 --- a/tests/Message/UpdateCustomerRequestTest.php +++ b/tests/Message/UpdateCustomerRequestTest.php @@ -19,9 +19,12 @@ public function testEndpoint() public function testData() { + $shipping = array('name' => 'John Doe', ['address' => ['line1' => 'Some street']]); + $this->request->setEmail('customer@business.dom'); $this->request->setDescription('New customer'); $this->request->setMetadata(array('field' => 'value')); + $this->request->setshipping($shipping); $data = $this->request->getData(); @@ -29,6 +32,7 @@ public function testData() $this->assertSame('New customer', $data['description']); $this->assertArrayHasKey('field', $data['metadata']); $this->assertSame('value', $data['metadata']['field']); + $this->assertSame($shipping, $data['shipping']); } public function testDataWithToken()