Skip to content

Commit

Permalink
6.14.0
Browse files Browse the repository at this point in the history
Co-authored-by: Sara Vasquez <saravasquez@paypal.com>
Co-authored-by: Debra Do <debdo@paypal.com>
  • Loading branch information
3 people committed Oct 18, 2023
1 parent c7bdef5 commit 084ed5b
Show file tree
Hide file tree
Showing 7 changed files with 189 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 6.14.0
* Add `arrivalDate` and `ticketIssuerAddress` to Transaction object
* Add `SUBSCRIPTION_BILLING_SKIPPED` WebhookNotification

## 6.13.0
* Add `retry_ids` and `retry_transaction_id` to Transaction object
* Add `processing_overrides` to `Transaction.sale` options
Expand Down
69 changes: 68 additions & 1 deletion lib/Braintree/TransactionGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ public static function createSignature()
['industryType',
['data' =>
[
'arrivalDate',
'folioNumber',
'checkInDate',
'checkOutDate',
Expand Down Expand Up @@ -278,7 +279,8 @@ public static function createSignature()
'kind',
'amount'
]
]
],
'ticketIssuerAddress'
]
]
]
Expand Down Expand Up @@ -333,6 +335,71 @@ public static function submitForSettlementSignature()
'shippingAmount',
'discountAmount',
'shipsFromPostalCode',
['industry' =>
['industryType',
['data' =>
[
'advancedDeposit',
'arrivalDate',
'checkInDate',
'checkOutDate',
'customerCode',
'departureDate',
'fareAmount',
'feeAmount',
'fireSafe',
'folioNumber',
'issuedDate',
'issuingCarrierCode',
'lodgingCheckInDate',
'lodgingCheckOutDate',
'lodgingName',
'noShow',
'passengerFirstName',
'passengerLastName',
'passengerMiddleInitial',
'passengerTitle',
'propertyPhone',
'restrictedTicket',
'roomRate',
'roomTax',
'taxAmount',
'ticketIssuerAddress',
'ticketNumber',
'travelAgencyCode',
'travelAgencyName',
'travelPackage',
['legs' =>
[
'arrivalAirportCode',
'arrivalTime',
'carrierCode',
'conjunctionTicket',
'couponNumber',
'departureAirportCode',
'departureDate',
'departureTime',
'endorsementOrRestrictions',
'exchangeTicket',
'fareAmount',
'fareBasisCode',
'feeAmount',
'flightNumber',
'serviceClass',
'stopoverPermitted',
'taxAmount',
]
],
['additionalCharges' =>
[
'amount',
'kind'
]
]
]
]
]
],
['lineItems' =>
[
'commodityCode',
Expand Down
2 changes: 1 addition & 1 deletion lib/Braintree/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class Version
{
const MAJOR = 6;
const MINOR = 13;
const MINOR = 14;
const TINY = 0;

protected function __construct()
Expand Down
1 change: 1 addition & 0 deletions lib/Braintree/WebhookNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class WebhookNotification extends Base
const PAYMENT_METHOD_CUSTOMER_DATA_UPDATED = 'payment_method_customer_data_updated';
const PAYMENT_METHOD_REVOKED_BY_CUSTOMER = 'payment_method_revoked_by_customer';
const RECIPIENT_UPDATED_GRANTED_PAYMENT_METHOD = 'recipient_updated_granted_payment_method';
const SUBSCRIPTION_BILLING_SKIPPED = 'subscription_billing_skipped';
const SUBSCRIPTION_CANCELED = 'subscription_canceled';
const SUBSCRIPTION_CHARGED_SUCCESSFULLY = 'subscription_charged_successfully';
const SUBSCRIPTION_CHARGED_UNSUCCESSFULLY = 'subscription_charged_unsuccessfully';
Expand Down
19 changes: 19 additions & 0 deletions lib/Braintree/WebhookTestingGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ private static function _sampleXml($kind, $id, $sourceMerchantId)
case WebhookNotification::DISPUTE_EXPIRED:
$subjectXml = self::_disputeExpiredSampleXml($id);
break;
case WebhookNotification::SUBSCRIPTION_BILLING_SKIPPED:
$subjectXml = self::_subscriptionBillingSkippedSampleXml($id);
break;
case WebhookNotification::SUBSCRIPTION_CHARGED_SUCCESSFULLY:
$subjectXml = self::_subscriptionChargedSuccessfullySampleXml($id);
break;
Expand Down Expand Up @@ -515,6 +518,22 @@ private static function _subscriptionSampleXml($id)
";
}

private static function _subscriptionBillingSkippedSampleXml($id)
{
return "
<subscription>
<id>{$id}</id>
<status>Active</status>
<transactions type=\"array\">
</transactions>
<add_ons type=\"array\">
</add_ons>
<discounts type=\"array\">
</discounts>
</subscription>
";
}

private static function _subscriptionChargedSuccessfullySampleXml($id)
{
return "
Expand Down
78 changes: 76 additions & 2 deletions tests/integration/TransactionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5660,6 +5660,8 @@ public function testSale_withTravelFlightIndustryData()
'feeAmount' => '10.00',
'taxAmount' => '20.00',
'restrictedTicket' => false,
'arrivalDate' => '2020-01-05',
'ticketIssuerAddress' => 'issuer-address',
'legs' => [
[
'conjunctionTicket' => 'CJ0001',
Expand Down Expand Up @@ -5706,6 +5708,78 @@ public function testSale_withTravelFlightIndustryData()
$this->assertTrue($result->success);
}

public function testSubmitForSettlement_withTravelFlightIndustryData()
{
$http = new HttpClientApi(Braintree\Configuration::$global);
$nonce = $http->nonce_for_new_card([
"creditCard" => [
"number" => "4111111111111111",
"expirationMonth" => "11",
"expirationYear" => "2099"
],
"share" => true
]);

$result = Braintree\Transaction::sale([
'amount' => '100.00',
'paymentMethodNonce' => $nonce,
'merchantAccountId' => Test\Helper::fakeFirstDataMerchantAccountId()
]);

$this->assertTrue($result->success);
$transaction = $result->transaction;
$this->assertEquals(Braintree\Transaction::AUTHORIZED, $transaction->status);
$this->assertEquals(Braintree\Transaction::SALE, $transaction->type);

$submitForSettlementParams = [
'industry' => [
'industryType' => Braintree\Transaction::TRAVEL_AND_FLIGHT_INDUSTRY,
'data' => [
'passengerFirstName' => 'John',
'passengerLastName' => 'Doe',
'passengerMiddleInitial' => 'M',
'passengerTitle' => 'Mr.',
'issuedDate' => '2018-01-01',
'travelAgencyName' => 'Expedia',
'travelAgencyCode' => '12345678',
'ticketNumber' => 'ticket-number',
'issuingCarrierCode' => 'AA',
'customerCode' => 'customer-code',
'fareAmount' => '70.00',
'feeAmount' => '10.00',
'restrictedTicket' => false,
'arrivalDate' => '2020-01-05',
'ticketIssuerAddress' => 'issuer-address',
'legs' => [
[
'conjunctionTicket' => 'CJ0001',
'exchangeTicket' => 'ET0001',
'couponNumber' => '1',
'serviceClass' => 'Y',
'carrierCode' => 'AA',
'fareBasisCode' => 'W',
'flightNumber' => 'AA100',
'departureDate' => '2018-01-02',
'departureAirportCode' => 'MDW',
'departureTime' => '08:00',
'arrivalAirportCode' => 'ATX',
'arrivalTime' => '10:00',
'stopoverPermitted' => false,
'fareAmount' => '35.00',
'feeAmount' => '5.00',
'taxAmount' => '10.00',
'endorsementOrRestrictions' => 'NOT REFUNDABLE'
],
]
]
]
];
$submitResult = Braintree\Transaction::submitForSettlement($transaction->id, null, $submitForSettlementParams);
$this->assertEquals(true, $submitResult->success);
$submitTransaction = $submitResult->transaction;
$this->assertEquals(Braintree\Transaction::SUBMITTED_FOR_SETTLEMENT, $submitTransaction->status);
}

public function testSale_withTravelFlightIndustryDataValidation()
{
$result = Braintree\Transaction::sale([
Expand Down Expand Up @@ -6855,7 +6929,7 @@ public function testNonRetriedTransaction()
]);

$transaction = $result->transaction;
$this->assertFalse(property_exists($transaction, "retried"));
$this->assertFalse($transaction->retried);
$this->assertTrue(count($transaction->retryIds) == 0);
}

Expand Down Expand Up @@ -6883,6 +6957,6 @@ public function testIneligibleRetryTransaction()
]);

$transaction = $result->transaction;
$this->assertFalse(property_exists($transaction, "retried"));
$this->assertFalse($transaction->retried);
}
}
20 changes: 20 additions & 0 deletions tests/unit/WebhookNotificationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,26 @@ public function testAllowsParsingUsingStaticMethods()
$this->assertEquals(Braintree\WebhookNotification::CHECK, $webhookNotification->kind);
}

public function testBuildsASampleNotificationForASubscriptionBillingSkippedWebhook()
{
$sampleNotification = Braintree\WebhookTesting::sampleNotification(
Braintree\WebhookNotification::SUBSCRIPTION_BILLING_SKIPPED,
"my_id"
);

$webhookNotification = Braintree\WebhookNotification::parse(
$sampleNotification['bt_signature'],
$sampleNotification['bt_payload']
);

$this->assertEquals(Braintree\WebhookNotification::SUBSCRIPTION_BILLING_SKIPPED, $webhookNotification->kind);
$this->assertEquals("my_id", $webhookNotification->subscription->id);
$this->assertEquals([], $webhookNotification->subscription->transactions);
$this->assertEquals([], $webhookNotification->subscription->discounts);
$this->assertEquals([], $webhookNotification->subscription->addOns);
$this->assertEquals("Active", $webhookNotification->subscription->status);
}

public function testBuildsASampleNotificationForASubscriptionChargedSuccessfullyWebhook()
{
$sampleNotification = Braintree\WebhookTesting::sampleNotification(
Expand Down

0 comments on commit 084ed5b

Please sign in to comment.