From 413cbed607ee192822644e16cf47c7a86e3bddae Mon Sep 17 00:00:00 2001 From: Ivan Mitrikeski Date: Tue, 11 May 2021 11:44:40 -0400 Subject: [PATCH] Issue #65 Fix --- src/Message/CreatePaymentMethodRequest.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Message/CreatePaymentMethodRequest.php b/src/Message/CreatePaymentMethodRequest.php index 33726f5..1841e0c 100644 --- a/src/Message/CreatePaymentMethodRequest.php +++ b/src/Message/CreatePaymentMethodRequest.php @@ -32,26 +32,30 @@ public function getData() $data['billingAddress'] = []; - if ($this->getStreetAddress() !== '') { + if ($this->getStreetAddress() !== NULL && $this->getStreetAddress() !== '') { $data['billingAddress']['streetAddress'] = $this->getStreetAddress(); } - if ($this->getLocality() !== '') { + if ($this->getLocality() !== NULL && $this->getLocality() !== '') { $data['billingAddress']['locality'] = $this->getLocality(); } - if ($this->getPostalCode() !== '') { + if ($this->getPostalCode() !== NULL && $this->getPostalCode() !== '') { $data['billingAddress']['postalCode'] = $this->getPostalCode(); } - if ($this->getRegion() !== '') { + if ($this->getRegion() !== NULL && $this->getRegion() !== '') { $data['billingAddress']['region'] = $this->getRegion(); } - if ($this->getCountryCodeAlpha2() !== '') { + if ($this->getCountryCodeAlpha2() !== NULL && $this->getCountryCodeAlpha2() !== '') { $data['billingAddress']['countryCodeAlpha2'] = $this->getCountryCodeAlpha2(); } + if (count($data['billingAddress']) === 0) { + unset($data['billingAddress']); + } + $data = array_merge($data, $this->getOptionData()); return $data;