Skip to content

Commit

Permalink
6.16.0
Browse files Browse the repository at this point in the history
Co-authored-by: Iris Booker <iris.booker@getbraintree.com>
Co-authored-by: Sara Vasquez <saravasquez@paypal.com>
  • Loading branch information
3 people committed Jan 9, 2024
1 parent 16efb08 commit fe3d852
Show file tree
Hide file tree
Showing 43 changed files with 922 additions and 79 deletions.
24 changes: 24 additions & 0 deletions BTStandard/Sniffs/PreferIsSetSniff.php
@@ -0,0 +1,24 @@
<?php

namespace BTStandard\Sniffs;

use PHP_CodeSniffer\Sniffs\Sniff;
use PHP_CodeSniffer\Files\File;

class PreferIsSetSniff implements Sniff
{
public function register()
{
return array(T_STRING);
}

public function process(File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
if (str_contains($tokens[$stackPtr]['content'], "array_key_exists")) {
$warning = 'isset is preferred over array_key_exists as it contains a null check. Ensure using array_key_exists is safe, otherwise use isset';
$phpcsFile->addWarning($warning, $stackPtr, '');
}
}
}
?>
4 changes: 4 additions & 0 deletions BTStandard/ruleset.xml
@@ -0,0 +1,4 @@
<?xml version="1.0"?>
<ruleset name="BTStandard">
<description>A custom Braintree coding standard.</description>
</ruleset>
16 changes: 16 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,21 @@
# Changelog

## 6.16.0
* Deprecate `threeDSecureToken` in favor of `threeDSecureAuthenticationId`
* Deprecate `venmoSdkSession`, `venmoSdkPaymentMethodCode`, and `isVenmoSdk()`
* Add `PICKUP_IN_STORE` to `ShippingMethod` enum
* Add to `CreditCardVerification` create request
* `externalVault`
* `paymentMethodNonce`
* `riskData`
* `threeDSecureAuthenticationId`
* `threeDSecurePassThru`
* Add `phoneNumber` to `Address`, `CreditCardGateway`, `PaymentMethodGateway` and `CustomerGateway`
* Add `packages` to `Transaction`
* Add `packageTracking` method to `TransactionGateway` to make request to add tracking information to transactions
* Add check for empty `liabilityShift` in `RiskData`
* Add `imageUrl`, `upcCode`, and `upcType` to `lineItems` in `TransactionGateway`

## 6.15.0
* Add `billingAddress` and `shippingAddress` to `VenmoProfileData` for `PaymentMethodCustomerDataUpdated` webhook
* Add `MetaCheckoutCard` and `MetaCheckoutToken` payment methods
Expand Down
17 changes: 14 additions & 3 deletions lib/Braintree/AddressGateway.php
Expand Up @@ -177,9 +177,20 @@ public function updateNoValidate($customerOrId, $addressId, $attributes)
public static function createSignature()
{
return [
'company', 'countryCodeAlpha2', 'countryCodeAlpha3', 'countryCodeNumeric',
'countryName', 'customerId', 'extendedAddress', 'firstName',
'lastName', 'locality', 'postalCode', 'region', 'streetAddress'
'company',
'countryCodeAlpha2',
'countryCodeAlpha3',
'countryCodeNumeric',
'countryName',
'customerId',
'extendedAddress',
'firstName',
'lastName',
'locality',
'phoneNumber',
'postalCode',
'region',
'streetAddress'
];
}

Expand Down
4 changes: 4 additions & 0 deletions lib/Braintree/ApplePayGateway.php
Expand Up @@ -34,8 +34,10 @@ public function registerDomain($domain)
{
$path = $this->_config->merchantPath() . '/processing/apple_pay/validate_domains';
$response = $this->_http->post($path, ['url' => $domain]);
// phpcs:ignore
if (array_key_exists('response', $response) && $response['response']['success']) {
return new Result\Successful();
// phpcs:ignore
} elseif (array_key_exists('apiErrorResponse', $response)) {
return new Result\Error($response['apiErrorResponse']);
}
Expand Down Expand Up @@ -64,9 +66,11 @@ public function registeredDomains()
{
$path = $this->_config->merchantPath() . '/processing/apple_pay/registered_domains';
$response = $this->_http->get($path);
// // phpcs:ignore
if (array_key_exists('response', $response) && array_key_exists('domains', $response['response'])) {
$options = ApplePayOptions::factory($response['response']);
return new Result\Successful($options, 'applePayOptions');
// phpcs:ignore
} elseif (array_key_exists('apiErrorResponse', $response)) {
return new Result\Error($response['apiErrorResponse']);
} else {
Expand Down
1 change: 1 addition & 0 deletions lib/Braintree/Base.php
Expand Up @@ -41,6 +41,7 @@ public function __get($name)
if (isset($this->_attributes['globalId'])) {
$this->_attributes['graphQLId'] = $this->_attributes['globalId'];
}
// phpcs:ignore
if (array_key_exists($name, $this->_attributes)) {
return $this->_attributes[$name];
} else {
Expand Down
2 changes: 2 additions & 0 deletions lib/Braintree/ClientTokenGateway.php
Expand Up @@ -34,6 +34,7 @@ public function __construct($gateway)
*/
public function generate($params = [])
{
// phpcs:ignore
if (!array_key_exists("version", $params)) {
$params["version"] = ClientToken::DEFAULT_VERSION;
}
Expand Down Expand Up @@ -62,6 +63,7 @@ public function _doGenerate($subPath, $params)
*/
public function conditionallyVerifyKeys($params)
{
// phpcs:ignore
if (array_key_exists("customerId", $params)) {
Util::verifyKeys($this->generateWithCustomerIdSignature(), $params);
} else {
Expand Down
3 changes: 3 additions & 0 deletions lib/Braintree/CreditCard.php
Expand Up @@ -81,9 +81,12 @@ public function isExpired()
return $this->expired;
}

// NEXT_MAJOR_VERSION Remove this method
/**
* checks whether the card is associated with venmo sdk
*
* @deprecated
*
* @return boolean
*/
public function isVenmoSdk()
Expand Down
23 changes: 20 additions & 3 deletions lib/Braintree/CreditCardGateway.php
Expand Up @@ -39,6 +39,7 @@ 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 All @@ -54,6 +55,7 @@ public function create($attribs)
*/
public function createNoValidate($attribs)
{
$this->_checkForDeprecatedAttributes($attribs);
$result = $this->create($attribs);
return Util::returnObjectOrThrowException(__CLASS__, $result);
}
Expand Down Expand Up @@ -275,6 +277,7 @@ public function saleNoValidate($token, $transactionAttribs)
public function update($token, $attributes)
{
Util::verifyKeys(self::updateSignature(), $attributes);
$this->_checkForDeprecatedAttributes($attributes);
$this->_validateId($token);
return $this->_doUpdate('put', '/payment_methods/credit_card/' . $token, ['creditCard' => $attributes]);
}
Expand All @@ -295,6 +298,7 @@ public function update($token, $attributes)
*/
public function updateNoValidate($token, $attributes)
{
$this->_checkForDeprecatedAttributes($attributes);
$result = $this->update($token, $attributes);
return Util::returnObjectOrThrowException(__CLASS__, $result);
}
Expand All @@ -314,24 +318,28 @@ public function delete($token)
return new Result\Successful();
}

// NEXT_MAJOR_VERSION Remove venmoSdkSession
// The old venmo SDK class has been deprecated
private static function baseOptions()
{
return [
'makeDefault',
'skipAdvancedFraudChecking',
'venmoSdkSession',
'venmoSdkSession', //Deprecated
'verificationAccountType',
'verificationAmount',
'verificationMerchantAccountId',
'verifyCard',
];
}

// NEXT_MAJOR_VERSION Remove venmoSdkPaymentMethodCode
// The old venmo SDK class has been deprecated
private static function baseSignature($options)
{
return [
'billingAddressId', 'cardholderName', 'cvv', 'number',
'expirationDate', 'expirationMonth', 'expirationYear', 'token', 'venmoSdkPaymentMethodCode',
'expirationDate', 'expirationMonth', 'expirationYear', 'token', 'venmoSdkPaymentMethodCode', // Deprecated
'deviceData', 'paymentMethodNonce',
['options' => $options],
[
Expand All @@ -355,7 +363,8 @@ public static function billingAddressSignature()
'locality',
'region',
'postalCode',
'streetAddress'
'streetAddress',
'phoneNumber'
];
}

Expand Down Expand Up @@ -404,6 +413,7 @@ public static function updateSignature()
];

foreach ($signature as $key => $value) {
// phpcs:ignore
if (is_array($value) and array_key_exists('billingAddress', $value)) {
// phpcs:ignore
$signature[$key]['billingAddress'] = array_merge_recursive($value['billingAddress'], $updateExistingBillingSignature);
Expand Down Expand Up @@ -466,4 +476,11 @@ private function _verifyGatewayResponse($response)
);
}
}

private function _checkForDeprecatedAttributes($attributes)
{
if (isset($attributes['venmoSdkSession']) || isset($attributes['venmoSdkPaymentMethodCode'])) {
trigger_error('The Venmo SDK integration is Unsupported. Please update your integration to use Pay with Venmo instead.', E_USER_DEPRECATED);
}
}
}
48 changes: 43 additions & 5 deletions lib/Braintree/CreditCardVerification.php
Expand Up @@ -72,13 +72,51 @@ public static function search($query)
public static function createSignature()
{
return [
['options' => ['amount', 'merchantAccountId', 'accountType']],
['creditCard' =>
[
'cardholderName', 'cvv', 'number',
'expirationDate', 'expirationMonth', 'expirationYear',
['billingAddress' => CreditCardGateway::billingAddressSignature()]
['billingAddress' => CreditCardGateway::billingAddressSignature()],
'cardholderName',
'cvv',
'expirationDate',
'expirationMonth',
'expirationYear',
'number'
]
]];
],
['externalVault' =>
[
'previousNetworkTransactionId',
'status'
]
],
'intendedTransactionSource',
['options' =>
[
'accountType',
'amount',
'merchantAccountId',
]
],
'paymentMethodNonce',
['riskData' =>
[
'customerBrowser',
'customerIp'
]
],
'threeDSecureAuthenticationId',
['threeDSecurePassThru' =>
[
'authenticationResponse',
'cavv',
'cavvAlgorithm',
'directoryResponse',
'dsTransactionId',
'eciFlag',
'threeDSecureVersion',
'xid'
]
]
];
}
}
5 changes: 3 additions & 2 deletions lib/Braintree/CustomerGateway.php
Expand Up @@ -150,7 +150,7 @@ public static function createSignature()
'firstName', 'lastName', 'company', 'countryName',
'countryCodeAlpha2', 'countryCodeAlpha3', 'countryCodeNumeric',
'extendedAddress', 'locality', 'postalCode', 'region',
'streetAddress'],
'streetAddress', 'phoneNumber'],
],
]]
]],
Expand All @@ -168,6 +168,7 @@ public static function updateSignature()
$creditCardSignature = CreditCardGateway::updateSignature();

foreach ($creditCardSignature as $key => $value) {
// phpcs:ignore
if (is_array($value) and array_key_exists('options', $value)) {
array_push($creditCardSignature[$key]['options'], 'updateExistingToken');
}
Expand Down Expand Up @@ -197,7 +198,7 @@ public static function updateSignature()
'firstName', 'lastName', 'company', 'countryName',
'countryCodeAlpha2', 'countryCodeAlpha3', 'countryCodeNumeric',
'extendedAddress', 'locality', 'postalCode', 'region',
'streetAddress'],
'streetAddress', 'phoneNumber'],
],
]],
]],
Expand Down
1 change: 1 addition & 0 deletions lib/Braintree/Dispute/EvidenceDetails.php
Expand Up @@ -14,6 +14,7 @@ class EvidenceDetails extends Instance
// phpcs:ignore PEAR.Commenting.FunctionComment.Missing
public function __construct($attributes)
{
// phpcs:ignore
if (array_key_exists('category', $attributes)) {
$attributes['tag'] = $attributes['category'];
}
Expand Down
4 changes: 4 additions & 0 deletions lib/Braintree/DisputeGateway.php
Expand Up @@ -71,6 +71,7 @@ public function addFileEvidence($disputeId, $documentIdOrRequest)
}

try {
// phpcs:ignore
if (array_key_exists('category', $request)) {
if (trim($request['category']) == "") {
throw new InvalidArgumentException('category cannot be blank');
Expand Down Expand Up @@ -120,18 +121,21 @@ public function addTextEvidence($id, $contentOrRequest)
throw new Exception\NotFound();
}

// phpcs:ignore
if (array_key_exists('tag', $request)) {
trigger_error('$tag is deprecated, use $category instead', E_USER_DEPRECATED);
$evidence['category'] = $request['tag'];
}

// phpcs:ignore
if (array_key_exists('category', $request)) {
if (trim($request['category']) == "") {
throw new InvalidArgumentException('category cannot be blank');
}
$evidence['category'] = $request['category'];
}

// phpcs:ignore
if (array_key_exists('sequenceNumber', $request)) {
if (trim($request['sequenceNumber']) == "") {
throw new InvalidArgumentException('sequenceNumber cannot be blank');
Expand Down
4 changes: 4 additions & 0 deletions lib/Braintree/Error/Codes.php
Expand Up @@ -304,6 +304,10 @@ class Codes
const TRANSACTION_LINE_ITEM_TAX_AMOUNT_FORMAT_IS_INVALID = '95827';
const TRANSACTION_LINE_ITEM_TAX_AMOUNT_IS_TOO_LARGE = '95828';
const TRANSACTION_LINE_ITEM_TAX_AMOUNT_CANNOT_BE_NEGATIVE = '95829';
const TRANSACTION_LINE_ITEM_UPC_CODE_IS_MISSING = '95830';
const TRANSACTION_LINE_ITEM_UPC_CODE_IS_TOO_LONG = '95831';
const TRANSACTION_LINE_ITEM_UPC_TYPE_IS_MISSING = '95832';
const TRANSACTION_LINE_ITEM_UPC_TYPE_IS_INVALID = '95833';

const TRANSACTION_EXTERNAL_VAULT_STATUS_IS_INVALID = '915175';
const TRANSACTION_EXTERNAL_VAULT_STATUS_WITH_PREVIOUS_NETWORK_TRANSACTION_ID_IS_INVALID = '915177';
Expand Down
1 change: 1 addition & 0 deletions lib/Braintree/Instance.php
Expand Up @@ -28,6 +28,7 @@ public function __construct($attributes)
*/
public function __get($name)
{
// phpcs:ignore
if (array_key_exists($name, $this->_attributes)) {
return $this->_attributes[$name];
} else {
Expand Down

0 comments on commit fe3d852

Please sign in to comment.