Skip to content

Commit f8693ee

Browse files
braintreepswysmith-publicgitDavid Johnsonspikovski-pubWesley Davison
committed
6.28.0
Co-authored-by: Wyatt Smith <wysmith@paypal.com> Co-authored-by: David Johnson <djohnson14@paypal.com> Co-authored-by: Sharon Pikovski <spikovski@paypal.com> Co-authored-by: Wesley Davison <wdavison@paypal.com> Co-authored-by: Kevin Laguerre <klaguerre@paypal.com> Co-authored-by: Nayana Keshavamurthy <nkeshavamurthy@paypal.com>
1 parent 2843f65 commit f8693ee

12 files changed

+188
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 6.28.0
4+
* Add `upcomingRetryDate` to Transaction
5+
* Add `remainingFileEvidenceStorage` to `Dispute`
6+
* Add `transaction_retried` webhook
7+
* Add `transfer type` to Transaction
8+
39
## 6.27.0
410
* Add Session Id to Customer Recommendations Payload
511

lib/Braintree/TransactionGateway.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public static function cloneSignature()
8383
public static function createSignature()
8484
{
8585
return [
86+
'accountFundingTransaction',
8687
'amount',
8788
['applePayCard' =>
8889
[
@@ -335,6 +336,10 @@ public static function createSignature()
335336
'threeDSecureToken', //Deprecated
336337
'threeDSecureAuthenticationId',
337338
'transactionSource',
339+
[ 'transfer' => [
340+
'type',
341+
],
342+
],
338343
'type',
339344
'venmoSdkPaymentMethodCode', // Deprecated
340345
[

lib/Braintree/Version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
class Version
1010
{
1111
const MAJOR = 6;
12-
const MINOR = 27;
12+
const MINOR = 28;
1313
const TINY = 0;
1414

1515
protected function __construct()

lib/Braintree/WebhookNotification.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class WebhookNotification extends Base
4646
const SUBSCRIPTION_WENT_ACTIVE = 'subscription_went_active';
4747
const SUBSCRIPTION_WENT_PAST_DUE = 'subscription_went_past_due';
4848
const TRANSACTION_DISBURSED = 'transaction_disbursed';
49+
const TRANSACTION_RETRIED = 'transaction_retried';
4950
const TRANSACTION_REVIEWED = 'transaction_reviewed';
5051
const TRANSACTION_SETTLED = 'transaction_settled';
5152
const TRANSACTION_SETTLEMENT_DECLINED = 'transaction_settlement_declined';

lib/Braintree/WebhookTestingGateway.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ private static function _sampleXml($kind, $id, $sourceMerchantId)
4646
case WebhookNotification::TRANSACTION_DISBURSED:
4747
$subjectXml = self::_transactionDisbursedSampleXml($id);
4848
break;
49+
case WebhookNotification::TRANSACTION_RETRIED:
50+
$subjectXml = self::_transactionRetriedSampleXml($id);
51+
break;
4952
case WebhookNotification::TRANSACTION_REVIEWED:
5053
$subjectXml = self::_transactionReviewedSampleXml($id);
5154
break;
@@ -234,6 +237,20 @@ private static function _transactionDisbursedSampleXml($id)
234237
";
235238
}
236239

240+
private static function _transactionRetriedSampleXml($id)
241+
{
242+
return "
243+
<transaction>
244+
<id>{$id}</id>
245+
<amount>100.00</amount>
246+
<status>submitted_for_settlement</status>
247+
<type>sale</type>
248+
<currency-iso-code>USD</currency-iso-code>
249+
<retried-transaction-id>original_txn_id</retried-transaction-id>
250+
</transaction>
251+
";
252+
}
253+
237254
private static function _transactionReviewedSampleXml($id)
238255
{
239256
return "

tests/integration/DisputeTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,23 @@ public function testAddFileEvidence_addsEvidence()
9393
$this->assertEquals($result->evidence->id, $updatedDispute->evidence[0]->id);
9494
}
9595

96+
public function testAddFileEvidence_updatesRemainingFileEvidenceStorage()
97+
{
98+
$dispute = $this->createSampleDispute();
99+
$initialStorage = $dispute->remainingFileEvidenceStorage;
100+
101+
$this->assertNotNull($initialStorage);
102+
103+
$disputeId = $this->createSampleDispute()->id;
104+
$documentId = $this->createSampleDocument()->id;
105+
$this->gateway->dispute()->addFileEvidence($disputeId, $documentId);
106+
107+
$updatedDispute = $this->gateway->dispute()->find($disputeId);
108+
$updatedStorage = $updatedDispute->remainingFileEvidenceStorage;
109+
110+
$this->assertTrue($updatedStorage < $initialStorage);
111+
}
112+
96113
public function testAddFileEvidence_addsEvidence_withCategory()
97114
{
98115
$disputeId = $this->createSampleDispute()->id;

tests/integration/TransactionTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7303,4 +7303,15 @@ public function testCreateTransactionDoesNotReturnForeignRetailerWhenSkippedInRe
73037303
$this->assertEquals(Braintree\Transaction::AUTHORIZED, $transaction->status);
73047304
$this->assertFalse(property_exists($transaction, "foreignRetailer"));
73057305
}
7306+
7307+
public function testTransactionWithUpcomingRetryDate()
7308+
{
7309+
$transaction = Braintree\Transaction::find('first_attempted_ach_transaction');
7310+
7311+
$tomorrow = new DateTime('tomorrow');
7312+
$expectedDate = $tomorrow->format('Y-m-d');
7313+
7314+
$this->assertNotNull($transaction->upcomingRetryDate);
7315+
$this->assertStringContainsString($expectedDate, $transaction->upcomingRetryDate);
7316+
}
73067317
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
namespace Test\Integration;
4+
5+
require_once dirname(__DIR__) . '/Setup.php';
6+
7+
use Braintree;
8+
use Test\Setup;
9+
10+
class TransactionTransferTest extends Setup
11+
{
12+
public function testSaleWithValidAftTransferType()
13+
{
14+
$transactionParams = [
15+
'type' => 'sale',
16+
'amount' => '100.00',
17+
'merchantAccountId' => 'aft_first_data_wallet_transfer',
18+
'creditCard' => [
19+
'number' => '4111111111111111',
20+
'expirationDate' => '06/2026',
21+
'cvv' => '123',
22+
],
23+
'transfer' => [
24+
'type' => 'wallet_transfer',
25+
],
26+
];
27+
28+
$result = Braintree\Transaction::sale($transactionParams);
29+
30+
$this->assertTrue($result->success);
31+
$this->assertTrue($result->transaction->accountFundingTransaction);
32+
$this->assertEquals(Braintree\Transaction::AUTHORIZED, $result->transaction->status);
33+
}
34+
35+
public function testSaleWithInvalidTransferType()
36+
{
37+
$transactionParams = [
38+
'type' => 'sale',
39+
'amount' => '100.00',
40+
41+
'merchantAccountId' => 'aft_first_data_wallet_transfer',
42+
'creditCard' => [
43+
'number' => '4111111111111111',
44+
'expirationDate' => '06/2026',
45+
'cvv' => '123',
46+
],
47+
'transfer' => [
48+
'type' => 'invalid_transfer',
49+
],
50+
];
51+
52+
$result = Braintree\Transaction::sale($transactionParams);
53+
54+
$this->assertFalse($result->success);
55+
}
56+
}

tests/unit/DisputeTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public function setUp(): void
4040
'replyByDate' => DateTime::createFromFormat('Ymd-His', '20130417-0000417'),
4141
'status' => 'open',
4242
'updatedAt' => DateTime::createFromFormat('Ymd-His', '20130410-105039'),
43+
'remainingFileEvidenceStorage' => '31902983',
4344
'evidence' => [[
4445
'category' => null,
4546
'comment' => null,
@@ -148,6 +149,7 @@ public function testConstructorPopulatesNewFields()
148149
$this->assertEquals("Reason code 83 description", $dispute->reasonDescription);
149150
$this->assertEquals("123456", $dispute->referenceNumber);
150151
$this->assertEquals(DateTime::createFromFormat('Ymd-His', '20130410-105039'), $dispute->updatedAt);
152+
$this->assertEquals("31902983", $dispute->remainingFileEvidenceStorage);
151153
$this->assertNull($dispute->evidence[0]->comment);
152154
$this->assertEquals(DateTime::createFromFormat('Ymd-His', '20130411-105039'), $dispute->evidence[0]->createdAt);
153155
$this->assertNull($dispute->evidence[0]->category);

tests/unit/TransactionTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,19 @@ public function testTransactionWithSepaDebitAccountDetail()
220220
$this->assertEquals("1234", $details["last4"]);
221221
}
222222

223+
public function testTransactionWithUpcomingRetryDate()
224+
{
225+
$transaction = Braintree\Transaction::factory([
226+
'id' => '123',
227+
'type' => 'sale',
228+
'amount' => '12.34',
229+
'status' => 'processor_declined',
230+
'upcomingRetryDate' => '2023-12-15'
231+
]);
232+
233+
$this->assertEquals('2023-12-15', $transaction->upcomingRetryDate);
234+
}
235+
223236
private function mockTransactionGatewayDoCreate()
224237
{
225238
return $this->getMockBuilder('Braintree\TransactionGateway')

0 commit comments

Comments
 (0)