Skip to content

Commit

Permalink
Major Version 6 (#324)
Browse files Browse the repository at this point in the history
* set to php 7.2 in sdk docker image to get tests running

* Add unit tests for RiskData

* drop RiskDataScore integration check

* update README

* Require PHP >=7.3.0 (#309)

* Update README.md

* Remove AmexExpressCheckout

* Remove deviceSessionID and fraudMerchantID from lib/

* Update CreditCardTest integration

* Remove deviceSessionID and fraudMerchantID from rest of tests

* Remove masterpass (#311)

* Remove MasterpassCard, MasterpassCardDetails, and relevant tests

* Address remaining NEXT_MAJOR_VERSION notes (#314)
* Rename isUsingInstanceProxy to isUsingProxy
* Rename isAuthenticatedInstanceProxy to isAuthenticatedProxy
* Remove TRANSACTION_EXTERNAL_VAULT_CARD_TYPE_IS_INVALID  error code
* Remove snake case parameters

* Rename Android Pay to Google Pay (#310)

* Php 8 support (#308)

* update docker image to php8.0

* bump phpunit to >=9.0

* setUp and teardown must be void compatible

* rename CloseTagTest, fix breaking changes from phpunit7-> 9 in unit tests

* address phpunit deprecation warnings

* make integration tests setUp void compatible

* fix breaking changes in integration tests

* update tests to resolve deprecation warnings

* Don't create phpunit cache file

* correct phpunit semver in composer.json

* add phpunit result cache to gitignore just in case

* update Dockerfile for php8

* Audit sanity language use

* Rename isUsingInstanceProxy to isUsingProxy

* Rename isAuthenticatedInstanceProxy to isAuthenticatedProxy

* Remove TRANSACTION_EXTERNAL_VAULT_CARD_TYPE_IS_INVALID  error code

* better name for test to check we're omitting php closing tags

* fixup deprecated tests from result of merging major update branch

* DateTimeImmutable support (public issue #278) (#316)

* Remove TRANSACTION_EXTERNAL_VAULT_CARD_TYPE_IS_INVALID  error code

* support DateTimeImmutableObjects for date params

* Add `toArray` function to Base and Instance classes (resolves #289?) (#322)

* Final tweaks - Major version 6 (#323)

Co-authored-by: Samantha Cannillo <[email protected]>
  • Loading branch information
2 people authored and GitHub Enterprise committed Apr 5, 2021
1 parent 1dde52a commit 97b0b30
Show file tree
Hide file tree
Showing 43 changed files with 542 additions and 943 deletions.
18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
## Unreleased
## 6.0.0 (unreleased)
* Add `adjustAuthorization` method to Transaction, for supporting multiple authorizations on a single transaction
* Add `storeId` and `storeIds` to Transaction search
* Add `merchantAccountId` parameter to Transaction refund
* Parameters that supported DateTime objects can also support DateTimeImmutable objects (closes #278)
* Add `toArray` function to Base and Instance classes (resolves #289)
* Add `jsonSerialize` to Instance class
* Breaking Changes:
* Require PHP 7.3 or higher
* Rename `AndroidPayCard` to `GooglePayCard`
* Rename `AndroidPayCardDetails` to `GooglePayCardDetails`
* Remove Configuration#isAuthenticatedInstanceProxy method in favor of Configuration#isAuthenticatedProxy
* Remove Configuration#isUsingInstanceProxy method in favor of Configuration#isUsingProxy
* Remove `TRANSACTION_EXTERNAL_VAULT_CARD_TYPE_IS_INVALID ` and `RISK_DATA_CUSTOMER_BROWSER_IS_TOO_LONG` error codes
* Remove `customer_ip` and `customer_browser` snake case parameters in favor of camel case `customerIp` and `customerBrowser` accepted in `Customer#create` and `Transaction#sale`
* Remove `AmexExpressCheckoutCard` and `AmexExpressCheckoutCardDetails`
* Remove `MasterpassCard` and `MasterpassCardDetails`
* Remove deprecated parameters:
* `deviceSessionId` from CreditCardGateway#update, CreditCardGateway#create, CustomerGateway#create, CustomerGateway#update, PaymentMethodGateay#update, and TransactionGateway#create
* `fraudMerchantId` from CreditCardGateway#update, CreditCardGateway#create, CustomerGateway#create, CustomerGateway#update, PaymentMethodGateay#update, and TransactionGateway#create

## 5.5.0
* Add `scaExemption` to Transaction sale
Expand Down
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
FROM debian:stretch
FROM debian:buster

RUN apt-get update
RUN apt-get -y install gnupg curl wget

# For installing php7
RUN apt -y install lsb-release apt-transport-https ca-certificates
RUN wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
RUN echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php7.3.list
RUN echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php8.0.list

RUN apt-get update

RUN apt-get -y install rake php7.3 php7.3-cli php7.3-curl php-pear php7.3-xml php7.3-mbstring
RUN update-alternatives --set php /usr/bin/php7.3
RUN apt-get -y install rake php8.0 php8.0-cli php8.0-curl php-pear php8.0-xml php8.0-mbstring

RUN update-alternatives --set php /usr/bin/php8.0 && php -v
WORKDIR /braintree-php
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2017 Braintree, a division of PayPal, Inc.
Copyright (c) 2021 Braintree, a division of PayPal, Inc.

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
Expand Down
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@ The following PHP extensions are required:
* openssl
* xmlwriter

PHP version >= 7.2 is required. The Braintree PHP SDK is tested against PHP versions 7.3 and 7.4.
PHP version >= 7.3 is required. The Braintree PHP SDK is tested against PHP versions 7.3 and 7.4, and 8.0.

_The PHP core development community has released [End-of-Life branches](https://www.php.net/eol.php) for PHP versions 5.4 - 7.1, and are no longer receiving security updates. As a result, Braintree does not support these versions of PHP._
_The PHP core development community has released [End-of-Life branches](https://www.php.net/eol.php) for PHP versions 5.4 - 7.2, and are no longer receiving security updates. As a result, Braintree does not support these versions of PHP._

## Versions

Braintree employs a deprecation policy for our SDKs. For more information on the statuses of an SDK check our [developer docs](http://developers.braintreepayments.com/reference/general/server-sdk-deprecation-policy).

| Major version number | Status | Released | Deprecated | Unsupported |
| -------------------- | ------ | -------- | ---------- | ----------- |
| 5.x.x | Active | March 2020 | TBA | TBA |
| 6.x.x | Active | March 2021 | TBA | TBA |
| 5.x.x | Inactive | March 2020 | March 2023 | March 2024 |
| 4.x.x | Inactive | May 2019 | March 2022 | March 2023 |
| 3.x.x | Inactive | May 2015 | March 2022 | March 2023 |

Expand Down Expand Up @@ -61,9 +62,10 @@ $gateway = new Braintree\Gateway($config)

// Then, create a transaction:
$result = $gateway->transaction()->sale([
'amount' => '1000.00',
'paymentMethodNonce' => 'nonceFromTheClient',
'options' => [ 'submitForSettlement' => true ]
'amount' => '10.00',
'paymentMethodNonce' => $nonceFromTheClient,
'deviceData' => $deviceDataFromTheClient,
'options' => [ 'submitForSettlement' => True ]
]);

if ($result->success) {
Expand All @@ -73,8 +75,9 @@ if ($result->success) {
print_r("\n code: " . $result->transaction->processorResponseCode);
print_r("\n text: " . $result->transaction->processorResponseText);
} else {
print_r("Validation errors: \n");
print_r($result->errors->deepAll());
foreach($result->errors->deepAll() AS $error) {
print_r($error->code . ": " . $error->message . "\n");
}
}
```

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
}
],
"require": {
"php": ">=7.2.0",
"php": ">=7.3.0",
"ext-curl": "*",
"ext-dom": "*",
"ext-hash": "*",
"ext-openssl": "*",
"ext-xmlwriter": "*"
},
"require-dev": {
"phpunit/phpunit": ">=9.0"
"phpunit/phpunit": "^9.0"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 2 additions & 2 deletions lib/Braintree.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

require_once(__DIR__ . DIRECTORY_SEPARATOR . 'autoload.php');

if (version_compare(PHP_VERSION, '7.2.0', '<')) {
throw new Braintree\Exception('PHP version >= 7.2.0 required');
if (version_compare(PHP_VERSION, '7.3.0', '<')) {
throw new Braintree\Exception('PHP version >= 7.3.0 required');
}

class Braintree {
Expand Down
83 changes: 0 additions & 83 deletions lib/Braintree/AmexExpressCheckoutCard.php

This file was deleted.

16 changes: 16 additions & 0 deletions lib/Braintree/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,20 @@ public function jsonSerialize()
{
return $this->_attributes;
}

/**
* Implementation of to an Array
*
* @ignore
* @return array
*/
public function toArray()
{
return array_map(function ($value) {
if (!is_array($value))
return method_exists($value, 'toArray') ? $value->toArray() : $value;
else
return $value;
}, $this->_attributes);
}
}
46 changes: 13 additions & 33 deletions lib/Braintree/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,21 +212,6 @@ public static function proxyType($value = null)
self::$global->setProxyType($value);
}

/**
* @deprecated Use isUsingInstanceProxy instead.
* Specifies whether or not a proxy is properly configured
*
* @return bool true if a proxy is configured properly, false if not
*/
public static function isUsingProxy()
{
// NEXT_MAJOR_VERSION Remove this method and rename isUsingInstanceProxy to isUsingProxy
trigger_error('DEPRECATED: Use isUsingInstanceProxy instead.', E_USER_DEPRECATED);
$proxyHost = self::$global->getProxyHost();
$proxyPort = self::$global->getProxyPort();
return !empty($proxyHost) && !empty($proxyPort);
}

public static function proxyUser($value = null)
{
if (empty($value)) {
Expand All @@ -243,22 +228,6 @@ public static function proxyPassword($value = null)
self::$global->setProxyPassword($value);
}

/**
* @deprecated Use isAuthenticatedInstanceProxy instead.
* Specified whether or not a username and password have been provided for
* use with an authenticated proxy
*
* @return bool true if both proxyUser and proxyPassword are present
*/
public static function isAuthenticatedProxy()
{
// NEXT_MAJOR_VERSION Remove this method and rename isAuthenticatedInstanceProxy to isAuthenticatedProxy
trigger_error('DEPRECATED: Use isAuthenticatedInstanceProxy instead.', E_USER_DEPRECATED);
$proxyUser = self::$global->getProxyUser();
$proxyPwd = self::$global->getProxyPassword();
return !empty($proxyUser) && !empty($proxyPwd);
}

/**
* Specify if the HTTP client is able to decode gzipped responses.
*
Expand Down Expand Up @@ -556,14 +525,25 @@ public function graphQLPortNumber()
return getenv("GRAPHQL_PORT") ?: 8080;
}

public function isUsingInstanceProxy()
/**
* Specifies whether or not a proxy is properly configured
*
* @return bool true if a proxy is configured properly, false if not
*/
public function isUsingProxy()
{
$proxyHost = $this->getProxyHost();
$proxyPort = $this->getProxyPort();
return !empty($proxyHost) && !empty($proxyPort);
}

public function isAuthenticatedInstanceProxy()
/**
* Specified whether or not a username and password have been provided for
* use with an authenticated proxy
*
* @return bool true if both proxyUser and proxyPassword are present
*/
public function isAuthenticatedProxy()
{
$proxyUser = $this->getProxyUser();
$proxyPwd = $this->getProxyPassword();
Expand Down
14 changes: 1 addition & 13 deletions lib/Braintree/CreditCardGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public function __construct($gateway)
public function create($attribs)
{
Util::verifyKeys(self::createSignature(), $attribs);
$this->_checkForDeprecatedAttributes($attribs);
return $this->_doCreate('/payment_methods', ['credit_card' => $attribs]);
}

Expand Down Expand Up @@ -230,15 +229,14 @@ public function saleNoValidate($token, $transactionAttribs)
* is the 2nd attribute. $token is not sent in object context.
*
* @access public
* @param array $attributes (Note: $deviceSessionId and $fraudMerchantId params are deprecated. Use $deviceData instead)
* @param array $attributes
* @param string $token (optional)
* @return Result\Successful|Result\Error
*/
public function update($token, $attributes)
{
Util::verifyKeys(self::updateSignature(), $attributes);
$this->_validateId($token);
$this->_checkForDeprecatedAttributes($attributes);
return $this->_doUpdate('put', '/payment_methods/credit_card/' . $token, ['creditCard' => $attributes]);
}

Expand Down Expand Up @@ -280,7 +278,6 @@ private static function baseSignature($options)
'billingAddressId', 'cardholderName', 'cvv', 'number',
'expirationDate', 'expirationMonth', 'expirationYear', 'token', 'venmoSdkPaymentMethodCode',
'deviceData', 'paymentMethodNonce',
'deviceSessionId', 'fraudMerchantId', // NEXT_MAJOR_VERSION remove deviceSessionId and fraudMerchantId
['options' => $options],
[
'billingAddress' => self::billingAddressSignature()
Expand Down Expand Up @@ -437,13 +434,4 @@ private function _verifyGatewayResponse($response)
}
}

private function _checkForDeprecatedAttributes($attributes)
{
if (isset($attributes['deviceSessionId'])) {
trigger_error('$deviceSessionId is deprecated, use $deviceData instead', E_USER_DEPRECATED);
}
if (isset($attributes['fraudMerchantId'])) {
trigger_error('$fraudMerchantId is deprecated, use $deviceData instead', E_USER_DEPRECATED);
}
}
}
Loading

0 comments on commit 97b0b30

Please sign in to comment.