Skip to content

Commit

Permalink
Add support for billing address in CreatePaymentMethodRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
dennislindsey committed Apr 12, 2021
1 parent 94393c2 commit 1473f77
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
8 changes: 4 additions & 4 deletions src/Message/CreateCustomerRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
34 changes: 18 additions & 16 deletions tests/Message/CreateCustomerRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,24 @@ public function testGetDataWithAVS()
'lastName' => 'Jones',
'email' => '[email protected]',
'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());
Expand Down

0 comments on commit 1473f77

Please sign in to comment.