Skip to content

Commit

Permalink
3.31.0
Browse files Browse the repository at this point in the history
  • Loading branch information
braintreeps committed Apr 10, 2018
1 parent 7053be1 commit 617a854
Show file tree
Hide file tree
Showing 20 changed files with 833 additions and 571 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
## Unreleased

## 3.31.0
* Fix issue where webhook verification would fail due to missing global public key configuration value
* Fix issue where webhook testing did not work on instantiated gateway
* Add support for VCR compelling evidence dispute representment

## 3.30.0
* Add `oauthAccessRevocation` to `WebhookNotification`s
* Add support for `profileId` in Transaction#create options for VenmoAccounts
* Add support for dispute search by `customerId`, `disbursementDate`, and `effectiveDate`
* Make `CustomerGateway::find` backward compatible
* Remove `sepaMandateType` and `sepaMandateAcceptanceLocation` params from `ClientTokenGateway`

## 3.29.0
* Add support for `association_filter_id` in `Customer#find`
Expand Down
2 changes: 1 addition & 1 deletion lib/Braintree/ClientTokenGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function generateWithCustomerIdSignature()
return [
"version", "customerId", "proxyMerchantId",
["options" => ["makeDefault", "verifyCard", "failOnDuplicatePaymentMethod"]],
"merchantAccountId", "sepaMandateType", "sepaMandateAcceptanceLocation"];
"merchantAccountId"];
}

/**
Expand Down
12 changes: 6 additions & 6 deletions lib/Braintree/Dispute.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,22 +115,22 @@ public static function accept($id)
* Adds file evidence to a dispute, given a dispute ID and a document ID
*
* @param string $disputeId
* @param string $documentId
* @param string $documentIdOrRequest
*/
public static function addFileEvidence($disputeId, $documentId)
public static function addFileEvidence($disputeId, $documentIdOrRequest)
{
return Configuration::gateway()->dispute()->addFileEvidence($disputeId, $documentId);
return Configuration::gateway()->dispute()->addFileEvidence($disputeId, $documentIdOrRequest);
}

/**
* Adds text evidence to a dispute, given a dispute ID and content
*
* @param string $id
* @param string $content
* @param string $contentOrRequest
*/
public static function addTextEvidence($id, $content)
public static function addTextEvidence($id, $contentOrRequest)
{
return Configuration::gateway()->dispute()->addTextEvidence($id, $content);
return Configuration::gateway()->dispute()->addTextEvidence($id, $contentOrRequest);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Braintree/Dispute/EvidenceDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*
* @package Braintree
*
* @property-read string $category
* @property-read string $comment
* @property-read date $created_at
* @property-read string $id
Expand All @@ -22,7 +23,6 @@ public function __construct($attributes)
{
if (array_key_exists('category', $attributes)) {
$attributes['tag'] = $attributes['category'];
unset($attributes['category']);
}
parent::__construct($attributes);
}
Expand Down
33 changes: 21 additions & 12 deletions lib/Braintree/DisputeGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,27 +69,32 @@ public function accept($id)
* Adds file evidence to a dispute, given a dispute ID and a document ID
*
* @param string $disputeId
* @param string $documentId
* @param string $documentIdOrRequest
*/
public function addFileEvidence($disputeId, $documentId)
public function addFileEvidence($disputeId, $documentIdOrRequest)
{
$request = is_array($documentIdOrRequest) ? $documentIdOrRequest : ['documentId' => $documentIdOrRequest];

if (trim($disputeId) == "") {
throw new Exception\NotFound('dispute with id "' . $disputeId . '" not found');
}

if (trim($documentId) == "") {
throw new Exception\NotFound('document with id "' . $documentId . '" not found');
if (trim($request['documentId']) == "") {
throw new Exception\NotFound('document with id "' . $request['documentId'] . '" not found');
}

try {
if (trim($disputeId) == "") {
throw new Exception\NotFound();
if (array_key_exists('category', $request)) {
if (trim($request['category']) == "") {
throw new InvalidArgumentException('category cannot be blank');
}
}

$request['document_upload_id'] = $request['documentId'];
unset($request['documentId']);

$path = $this->_config->merchantPath() . '/disputes/' . $disputeId . '/evidence';
$response = $this->_http->post($path, [
'document_upload_id' => $documentId
]);
$response = $this->_http->post($path, ['evidence' => $request]);

if (isset($response['apiErrorResponse'])) {
return new Result\Error($response['apiErrorResponse']);
Expand Down Expand Up @@ -127,12 +132,16 @@ public function addTextEvidence($id, $contentOrRequest)
}

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

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

if (array_key_exists('sequenceNumber', $request)) {
if (trim($request['sequenceNumber']) == "") {
throw new InvalidArgumentException('sequenceNumber cannot be blank');
Expand Down
29 changes: 24 additions & 5 deletions lib/Braintree/Error/Codes.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,30 @@ class Codes
const DESCRIPTOR_INTERNATIONAL_PHONE_FORMAT_IS_INVALID = '92205';
const DESCRIPTOR_URL_FORMAT_IS_INVALID = '92206';

const DISPUTE_CAN_ONLY_ADD_EVIDENCE_TO_OPEN_DISPUTE = '95701';
const DISPUTE_CAN_ONLY_REMOVE_EVIDENCE_FROM_OPEN_DISPUTE = '95702';
const DISPUTE_CAN_ONLY_ADD_EVIDENCE_TO_DISPUTE = '95703';
const DISPUTE_CAN_ONLY_ACCEPT_OPEN_DISPUTE = '95704';
const DISPUTE_CAN_ONLY_FINALIZE_OPEN_DISPUTE = '95705';
const DISPUTE_CAN_ONLY_ADD_EVIDENCE_TO_OPEN_DISPUTE = '95701';
const DISPUTE_CAN_ONLY_REMOVE_EVIDENCE_FROM_OPEN_DISPUTE = '95702';
const DISPUTE_CAN_ONLY_ADD_EVIDENCE_TO_DISPUTE = '95703';
const DISPUTE_CAN_ONLY_ACCEPT_OPEN_DISPUTE = '95704';
const DISPUTE_CAN_ONLY_FINALIZE_OPEN_DISPUTE = '95705';
const DISPUTE_CAN_ONLY_CREATE_EVIDENCE_WITH_VALID_CATEGORY = '95706';

const DISPUTE_EVIDENCE_CONTENT_DATE_INVALID = '95707';
const DISPUTE_EVIDENCE_CONTENT_TOO_LONG = '95708';
const DISPUTE_EVIDENCE_CONTENT_ARN_TOO_LONG = '95709';
const DISPUTE_EVIDENCE_CONTENT_PHONE_TOO_LONG = '95710';
const DISPUTE_EVIDENCE_CATEGORY_TEXT_ONLY = '95711';
const DISPUTE_EVIDENCE_CATEGORY_DOCUMENT_ONLY = '95712';
const DISPUTE_EVIDENCE_CATEGORY_NOT_FOR_REASON_CODE = '95713';
const DISPUTE_EVIDENCE_CATEGORY_DUPLICATE = '95713';
const DISPUTE_EVIDENCE_CATEGORY_EMAIL_INVALID = '95713';

const DISPUTE_DIGITAL_GOODS_MISSING_EVIDENCE = '95720';
const DISPUTE_DIGITAL_GOODS_MISSING_DOWNLOAD_DATE = '95721';
const DISPUTE_PRIOR_NON_DISPUTED_TRANSACTION_MISSING_ARN = '95722';
const DISPUTE_PRIOR_NON_DISPUTED_TRANSACTION_MISSING_DATE = '95723';
const DISPUTE_RECURRING_TRANSACTION_MISSING_DATE = '95724';
const DISPUTE_RECURRING_TRANSACTION_MISSING_ARN = '95725';
const DISPUTE_VALID_EVIDENCE_REQUIRED_TO_FINALIZE = '95726';

const DOCUMENT_UPLOAD_KIND_IS_INVALID = '84901';
const DOCUMENT_UPLOAD_FILE_IS_TOO_LARGE = '84902';
Expand Down
9 changes: 9 additions & 0 deletions lib/Braintree/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,5 +256,14 @@ public function webhookNotification()
{
return new WebhookNotificationGateway($this);
}

/**
*
* @return WebhookTestingGateway
*/
public function webhookTesting()
{
return new WebhookTestingGateway($this);
}
}
class_alias('Braintree\Gateway', 'Braintree_Gateway');
3 changes: 2 additions & 1 deletion lib/Braintree/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ function prepareMultipart($ch, $requestBody, $file, $boundary) {
}

// build file parameter
$filePath = end(explode(DIRECTORY_SEPARATOR, $filePath));
$splitFilePath = explode(DIRECTORY_SEPARATOR, $filePath);
$filePath = end($splitFilePath);
$filePath = str_replace($disallow, "_", $filePath);
$body[] = implode("\r\n", [
"Content-Disposition: form-data; name=\"file\"; filename=\"{$filePath}\"",
Expand Down
5 changes: 0 additions & 5 deletions lib/Braintree/PaymentMethodGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,6 @@ private function _verifyGatewayResponse($response)
AmexExpressCheckoutCard::factory($response['amexExpressCheckoutCard']),
"paymentMethod"
);
} else if (isset($response['europeBankAccount'])) {
return new Result\Successful(
EuropeBankAccount::factory($response['europeBankAccount']),
"paymentMethod"
);
} else if (isset($response['usBankAccount'])) {
return new Result\Successful(
UsBankAccount::factory($response['usBankAccount']),
Expand Down
8 changes: 0 additions & 8 deletions lib/Braintree/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,6 @@ protected function _initialize($transactionAttribs)
);
}

if (isset($transactionAttribs['europeBankAccount'])) {
$this->_set('europeBankAccount',
new Transaction\EuropeBankAccountDetails(
$transactionAttribs['europeBankAccount']
)
);
}

if (isset($transactionAttribs['usBankAccount'])) {
$this->_set('usBankAccount',
new Transaction\UsBankAccountDetails(
Expand Down
2 changes: 1 addition & 1 deletion lib/Braintree/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Version
* class constants
*/
const MAJOR = 3;
const MINOR = 30;
const MINOR = 31;
const TINY = 0;

/**
Expand Down
8 changes: 4 additions & 4 deletions lib/Braintree/WebhookNotificationGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ public function verify($challenge)
if (!preg_match('/^[a-f0-9]{20,32}$/', $challenge)) {
throw new Exception\InvalidChallenge("challenge contains non-hex characters");
}
$publicKey = $this->config->publicKey();
$digest = Digest::hexDigestSha1($this->config->privateKey(), $challenge);
$publicKey = $this->config->getPublicKey();
$digest = Digest::hexDigestSha1($this->config->getPrivateKey(), $challenge);
return "{$publicKey}|{$digest}";
}

private function _payloadMatches($signature, $payload)
{
$payloadSignature = Digest::hexDigestSha1($this->config->privateKey(), $payload);
$payloadSignature = Digest::hexDigestSha1($this->config->getPrivateKey(), $payload);
return Digest::secureCompare($signature, $payloadSignature);
}

Expand All @@ -65,7 +65,7 @@ private function _matchingSignature($signaturePairs)
foreach ($signaturePairs as $pair)
{
$components = preg_split("/\|/", $pair);
if ($components[0] == $this->config->publicKey()) {
if ($components[0] == $this->config->getPublicKey()) {
return $components[1];
}
}
Expand Down
Loading

0 comments on commit 617a854

Please sign in to comment.