Skip to content

Commit

Permalink
XOL-5226 Handle new Stripe API variables for v2019-12-03 (#16)
Browse files Browse the repository at this point in the history
* XOL-5226 Handle new Stripe API variables for v2019-09-09

* XOL-5226 Statement descriptor change

* XOL-5226 Just change the getData and keep the old getter and setters. Let driver do the work

* XOL-5226 Restore missing method

* XOL-5226 Update travis build

* XOL-5226 Fix failing tests

* XOL-5226 Fix more failures
  • Loading branch information
rushi authored Mar 3, 2020
1 parent 6f3a709 commit 62f39bf
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
language: php

php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2

before_script:
- composer install -n --dev --prefer-source
Expand Down
6 changes: 3 additions & 3 deletions src/Message/AuthorizeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,21 +221,21 @@ public function getData()

$apiVersion = $this->getApiVersion();
if (is_null($apiVersion) || (!is_null($apiVersion) && $apiVersion >= self::API_VERSION_STATEMENT_DESCRIPTOR)) {
$data['statement_descriptor'] = $this->getStatementDescriptor();
$data['statement_descriptor_suffix'] = $this->getStatementDescriptor();
} else {
$data['statement_description'] = $this->getStatementDescriptor();
}

if ($this->getDestination()) {
$data['destination'] = $this->getDestination();
$data['transfer_data'] = ['destination' => $this->getDestination()];
}

if ($this->getOnBehalfOf()) {
$data['on_behalf_of'] = $this->getOnBehalfOf();
}

if ($this->getApplicationFee()) {
$data['application_fee'] = $this->getApplicationFeeInteger();
$data['application_fee_amount'] = $this->getApplicationFeeInteger();
}

if ($this->getTransferGroup()) {
Expand Down
6 changes: 3 additions & 3 deletions tests/Message/AuthorizeRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function testGetData()
$this->assertSame('Order #42', $data['description']);
$this->assertSame('false', $data['capture']);
$this->assertSame(array('foo' => 'bar'), $data['metadata']);
$this->assertSame(100, $data['application_fee']);
$this->assertSame(100, $data['application_fee_amount']);
}

/**
Expand Down Expand Up @@ -69,7 +69,7 @@ public function testDataWithStatementDescriptor()
$this->request->setStatementDescriptor('OMNIPAY');
$data = $this->request->getData();

$this->assertSame('OMNIPAY', $data['statement_descriptor']);
$this->assertSame('OMNIPAY', $data['statement_descriptor_suffix']);
}

public function testDataWithSourceAndDestination()
Expand All @@ -79,7 +79,7 @@ public function testDataWithSourceAndDestination()
$data = $this->request->getData();

$this->assertSame('abc', $data['source']);
$this->assertSame('xyz', $data['destination']);
$this->assertSame('xyz', $data['transfer_data']['destination']);
}

public function testDataWithToken()
Expand Down
8 changes: 4 additions & 4 deletions tests/Message/PurchaseRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function testShouldReturnDataAsAnArray()
'object' => 'card',
'email' => null
),
'statement_descriptor' => 'FOO',
'statement_descriptor_suffix' => 'FOO',
'description' => null,
'capture' => 'true',
'metadata' => null
Expand Down Expand Up @@ -100,7 +100,7 @@ public function testShouldReturnLevel3DataIfItemsPresent()
'object' => 'card',
'email' => null
),
'statement_descriptor' => 'BOBS ANTIQUES',
'statement_descriptor_suffix' => 'BOBS ANTIQUES',
'description' => null,
'capture' => 'true',
'metadata' => null,
Expand Down Expand Up @@ -178,7 +178,7 @@ public function testShouldNotReturnLevel3DataIfItemsAmountsDoNotAddUpToAmountCha
'object' => 'card',
'email' => null
),
'statement_descriptor' => 'BOBS ANTIQUES',
'statement_descriptor_suffix' => 'BOBS ANTIQUES',
'description' => null,
'capture' => 'true',
'metadata' => null
Expand All @@ -195,7 +195,7 @@ public function testShouldUseOlderKeyOfStatementDescriptorWhenApiVersionIsBefore

$data = $this->request->getData();

$this->assertFalse(isset($data['statement_descriptor']), 'statement_descriptor should not be used for older version of the API');
$this->assertFalse(isset($data['statement_descriptor_suffix']), 'statement_descriptor_suffix should not be used for older version of the API');
$this->assertNotNull($data['statement_description'], 'statement_description should be used for this api version');
$this->assertEquals('FOO', $data['statement_description']);
}
Expand Down

0 comments on commit 62f39bf

Please sign in to comment.