Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Braintree 6x #75

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ language: php
sudo: false

php:
- 7.2
- 7.3
- 8.2

before_script:
- travis_retry composer self-update
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[![Total Downloads](https://poser.pugx.org/omnipay/braintree/d/total.png)](https://packagist.org/packages/omnipay/braintree)

[Omnipay](https://github.com/thephpleague/omnipay) is a framework agnostic, multi-gateway payment
processing library for PHP 7.2+. This package implements Braintree support for Omnipay.
processing library for PHP 7.3+. This package implements Braintree support for Omnipay.

## Installation

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
},
"require": {
"omnipay/common": "^3",
"braintree/braintree_php": "^5.0"
"braintree/braintree_php": "^6.0"
},
"require-dev": {
"omnipay/tests": "^3"
"omnipay/tests": "^4"
},
"extra": {
"branch-alias": {
Expand Down
41 changes: 21 additions & 20 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
<testsuites>
<testsuite name="Omnipay Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./src</directory>
</whitelist>
</filter>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
convertWarningsToExceptions="true"
convertNoticesToExceptions="true"
convertErrorsToExceptions="true"
bootstrap="vendor/autoload.php"
backupStaticAttributes="false"
processIsolation="false"
stopOnFailure="false"
backupGlobals="false"
colors="true">
<coverage>
<include>
<directory>./src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Omnipay Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
2 changes: 1 addition & 1 deletion src/MerchantIndividual.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public function setName($value)
{
$names = explode(' ', $value, 2);
$this->setFirstName($names[0]);
$this->setLastName(isset($names[1]) ? $names[1] : null);
$this->setLastName($names[1] ?? null);

return $this;
}
Expand Down
10 changes: 0 additions & 10 deletions src/Message/AbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,6 @@ public function setDeviceData($value)
return $this->setParameter('deviceData', $value);
}

public function getDeviceSessionId()
{
return $this->getParameter('deviceSessionId');
}

public function setDeviceSessionId($value)
{
return $this->setParameter('deviceSessionId', $value);
}

public function getMerchantAccountId()
{
return $this->getParameter('merchantAccountId');
Expand Down
1 change: 0 additions & 1 deletion src/Message/AuthorizeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public function getData()
'customerId' => $this->getCustomerId(),
'descriptor' => $this->getDescriptor(),
'deviceData' => $this->getDeviceData(),
'deviceSessionId' => $this->getDeviceSessionId(),
'merchantAccountId' => $this->getMerchantAccountId(),
'orderId' => $this->getTransactionId(),
'purchaseOrderNumber' => $this->getPurchaseOrderNumber(),
Expand Down
40 changes: 18 additions & 22 deletions tests/GatewayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ class GatewayTest extends GatewayTestCase
*/
protected $gateway;

public function setUp()
/**
* @var array
*/
protected $options;

public function setUp(): void
{
parent::setUp();

Expand Down Expand Up @@ -150,30 +155,21 @@ public function testCancelSubscription()
public function testParseNotification()
{
if(Version::MAJOR >= 3) {
$xml = '<notification></notification>';
$payload = base64_encode($xml);
$signature = Digest::hexDigestSha1(Configuration::privateKey(), $payload);
$gatewayMock = $this->buildGatewayMock($payload);
$gateway = new Gateway($this->getHttpClient(), $this->getHttpRequest(), $gatewayMock);
$params = array(
'bt_signature' => $payload.'|'.$signature,
'bt_payload' => $payload
);
$request = $gateway->parseNotification($params);
$this->assertInstanceOf('\Braintree\WebhookNotification', $request);
$xml = '<notification><subject></subject><kind></kind></notification>';
} else {
$xml = '<notification><subject></subject></notification>';
$payload = base64_encode($xml);
$signature = Digest::hexDigestSha1(Configuration::privateKey(), $payload);
$gatewayMock = $this->buildGatewayMock($payload);
$gateway = new Gateway($this->getHttpClient(), $this->getHttpRequest(), $gatewayMock);
$params = array(
'bt_signature' => $payload.'|'.$signature,
'bt_payload' => $payload
);
$request = $gateway->parseNotification($params);
$this->assertInstanceOf('\Braintree\WebhookNotification', $request);
}

$payload = base64_encode($xml);
$signature = Digest::hexDigestSha1(Configuration::privateKey(), $payload);
$gatewayMock = $this->buildGatewayMock($payload);
$gateway = new Gateway($this->getHttpClient(), $this->getHttpRequest(), $gatewayMock);
$params = array(
'bt_signature' => $payload.'|'.$signature,
'bt_payload' => $payload
);
$request = $gateway->parseNotification($params);
$this->assertInstanceOf('\Braintree\WebhookNotification', $request);
}

/**
Expand Down
7 changes: 6 additions & 1 deletion tests/MerchantBusinessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@

class MerchantBusinessTest extends TestCase
{
public function setUp()
/**
* @var MerchantBusiness
*/
protected $business;

public function setUp(): void
{
$this->business = new MerchantBusiness();
}
Expand Down
7 changes: 6 additions & 1 deletion tests/MerchantFundingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@

class MerchantFundingTest extends TestCase
{
public function setUp()
/**
* @var MerchantFunding
*/
protected $funding;

public function setUp(): void
{
$this->funding = new MerchantFunding();
}
Expand Down
7 changes: 6 additions & 1 deletion tests/MerchantIndividualTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@

class MerchantIndividualTest extends TestCase
{
public function setUp()
/**
* @var MerchantIndividual
*/
protected $individual;

public function setUp(): void
{
$this->individual = new MerchantIndividual();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Message/AbstractMerchantAccountRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AbstractMerchantAccountRequestTest extends TestCase
*/
private $request;

public function setUp()
public function setUp(): void
{
$this->request = Mockery::mock('\Omnipay\Braintree\Message\AbstractMerchantAccountRequest')->makePartial();
$this->request->initialize();
Expand Down
3 changes: 1 addition & 2 deletions tests/Message/AbstractRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class AbstractRequestTest extends TestCase
*/
private $request;

public function setUp()
public function setUp(): void
{
$this->request = Mockery::mock('\Omnipay\Braintree\Message\AbstractRequest')->makePartial();
$this->request->initialize();
Expand Down Expand Up @@ -42,7 +42,6 @@ public function provideKeepsData(){
array('customerId', 'abc123'),
array('descriptor', array('a' => 'b')),
array('deviceData', 'abc123'),
array('deviceSessionId', 'abc123'),
array('merchantAccountId', 'abc123'),
array('recurring', true),
array('addBillingAddressToPaymentMethod', true),
Expand Down
16 changes: 9 additions & 7 deletions tests/Message/AuthorizeRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Braintree\Configuration;
use Omnipay\Tests\TestCase;
use Omnipay\Common\Exception\InvalidRequestException;

class AuthorizeRequestTest extends TestCase
{
Expand All @@ -12,7 +13,7 @@ class AuthorizeRequestTest extends TestCase
*/
private $request;

public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down Expand Up @@ -176,23 +177,24 @@ public function testGetServiceFeeAmountNoDecimalsRounding()
$this->assertSame('137', $this->request->getServiceFeeAmount());
}

/**
* @expectedException \Omnipay\Common\Exception\InvalidRequestException
*/
public function testServiceFeeAmountWithIntThrowsException()
{
// ambiguous value, avoid errors upgrading from v0.9
$this->assertSame($this->request, $this->request->setServiceFeeAmount(10));

$this->expectException(InvalidRequestException::class);

$this->request->getServiceFeeAmount();

}

/**
* @expectedException \Omnipay\Common\Exception\InvalidRequestException
*/
public function testServiceFeeAmountWithIntStringThrowsException()
{
// ambiguous value, avoid errors upgrading from v0.9
$this->assertSame($this->request, $this->request->setServiceFeeAmount('10'));

$this->expectException(InvalidRequestException::class);

$this->request->getServiceFeeAmount();
}
}
2 changes: 1 addition & 1 deletion tests/Message/CaptureRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class CaptureRequestTest extends TestCase
*/
private $request;

public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/Message/ClientTokenRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ClientTokenRequestTest extends TestCase
*/
private $request;

public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/Message/ClientTokenResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ClientTokenResponseTest extends TestCase
*/
private $request;

public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/Message/CreateCustomerRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class CreateCustomerRequestTest extends TestCase
*/
private $request;

public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/Message/CreateMerchantAccountRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class CreateMerchantAccountRequestTest extends TestCase
*/
private $request;

public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/Message/CustomerResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CustomerResponseTest extends TestCase
*/
private $request;

public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/Message/DeleteCustomerRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DeleteCustomerRequestTest extends TestCase
*/
private $request;

public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/Message/DeletePaymentMethodRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DeletePaymentMethodRequestTest extends TestCase
*/
private $request;

public function setUp()
public function setUp(): void
{
$this->request = new DeletePaymentMethodRequest($this->getHttpClient(), $this->getHttpRequest(), Configuration::gateway());
$this->request->initialize(
Expand Down
2 changes: 1 addition & 1 deletion tests/Message/FindCustomerRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class FindCustomerRequestTest extends TestCase
*/
private $request;

public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/Message/FindRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class FindRequestTest extends TestCase
*/
private $request;

public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/Message/PlanRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class PlanRequestTest extends TestCase
/** @var PlanRequest */
private $request;

public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/Message/PlanResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class PlanResponseTest extends TestCase
/** @var PlanRequest */
private $request;

public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/Message/PurchaseRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class PurchaseRequestTest extends TestCase
*/
private $request;

public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
Loading