From 1473f770f5ef86c6a6c98146e93f758abaa66dde Mon Sep 17 00:00:00 2001 From: Dennis Date: Mon, 12 Apr 2021 16:23:03 -0700 Subject: [PATCH] Add support for billing address in CreatePaymentMethodRequest --- src/Message/CreateCustomerRequest.php | 8 ++--- tests/Message/CreateCustomerRequestTest.php | 34 +++++++++++---------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/Message/CreateCustomerRequest.php b/src/Message/CreateCustomerRequest.php index 00bf91a..c5ac5a7 100644 --- a/src/Message/CreateCustomerRequest.php +++ b/src/Message/CreateCustomerRequest.php @@ -11,13 +11,13 @@ class CreateCustomerRequest extends AbstractRequest public function getData() { $data = $this->getCustomerData(); - - $data += $this->getOptionData(); - + + $data['creditCard'] = $this->getOptionData(); + $creditCard = $this->getCardData(); if (array_key_exists('billing', $creditCard) && !empty($billingAddress = $creditCard['billing'])) { - $data['billingAddress'] = [ + $data['creditCard']['billingAddress'] = [ 'company' => $billingAddress['company'], 'countryCodeAlpha3' => $billingAddress['countryName'], 'extendedAddress' => $billingAddress['extendedAddress'], diff --git a/tests/Message/CreateCustomerRequestTest.php b/tests/Message/CreateCustomerRequestTest.php index f6f17be..97f07ee 100644 --- a/tests/Message/CreateCustomerRequestTest.php +++ b/tests/Message/CreateCustomerRequestTest.php @@ -81,22 +81,24 @@ public function testGetDataWithAVS() 'lastName' => 'Jones', 'email' => 'mike.jones@example.com', 'paymentMethodNonce' => 'testnonce', - 'options' => [ - 'addBillingAddressToPaymentMethod' => true, - 'failOnDuplicatePaymentMethod' => false, - 'makeDefault' => true, - 'verifyCard' => true, - ], - 'billingAddress' => [ - 'company' => 'Apple Inc', - 'countryCodeAlpha3' => 'USA', - 'extendedAddress' => 'Suite 101', - 'firstName' => 'John', - 'lastName' => 'Doe', - 'locality' => 'Los Angeles', - 'postalCode' => '90210', - 'region' => 'CA', - 'streetAddress' => '123 Main Street', + 'creditCard' => [ + 'options' => [ + 'addBillingAddressToPaymentMethod' => true, + 'failOnDuplicatePaymentMethod' => false, + 'makeDefault' => true, + 'verifyCard' => true, + ], + 'billingAddress' => [ + 'company' => 'Apple Inc', + 'countryCodeAlpha3' => 'USA', + 'extendedAddress' => 'Suite 101', + 'firstName' => 'John', + 'lastName' => 'Doe', + 'locality' => 'Los Angeles', + 'postalCode' => '90210', + 'region' => 'CA', + 'streetAddress' => '123 Main Street', + ], ], ]; $this->assertSame($expectedData, $this->request->getData());