Skip to content

Commit

Permalink
5.20.0
Browse files Browse the repository at this point in the history
Co-authored-by: Sara Vasquez <[email protected]>
Co-authored-by: Debra Do <[email protected]>
  • Loading branch information
3 people committed Oct 18, 2023
1 parent 33cde4b commit a80e296
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 5.20.0
- Add `SUBSCRIPTIONBILLINGSKIPPED` webhook notification support
- Add `implicitlyVaultedPaymentMethodToken` and `implicitlyVaultedPaymentMethodGlobalId` to `LocalPaymentDetails`

## 5.19.0
- Add `MerchantTokenIdentifier`, `SourceCardLast4` to `ApplePayCard` and `ApplePayDetails`
- Add `ThreeDSecureAuthenticationId` to `CustomerRequest` and `PaymentMethodRequest`
Expand Down
11 changes: 3 additions & 8 deletions src/Braintree/Braintree.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,16 @@
<PropertyGroup>
<Description>Braintree Client Library</Description>
<Copyright>Copyright © Braintree, a division of PayPal, Inc. 2021</Copyright>
<VersionPrefix>5.19.0</VersionPrefix>
<VersionPrefix>5.20.0</VersionPrefix>
<Authors>Braintree</Authors>
<!-- We target NET standard 2.0 so that we can support NET Core 2.1. When NET Core 2.1 reaches EOL, we can update to Net Standard 2.1 -->
<TargetFrameworks>net452;netstandard2.0</TargetFrameworks>
<AssemblyName>Braintree</AssemblyName>
<PackageId>Braintree</PackageId>
<PackageTags>braintree;paypal;venmo;intenational;payments;gateway;currencies;money;visa;mastercard;bitcoin;maestro;apple pay;android pay;amex;jcb;diners club;discover;american express</PackageTags>
<PackageReleaseNotes>
- Add `MerchantTokenIdentifier`, `SourceCardLast4` to `ApplePayCard` and `ApplePayDetails`
- Add `ThreeDSecureAuthenticationId` to `CustomerRequest` and `PaymentMethodRequest`
- Add `processing_overrides` to `Transaction.sale` options
- Add industry data fields to `TransactionRequest`
- `ArrivalDate`
- `TicketIssuerAddress`
- Remove `byte[]` to `String` content conversion for requests containing files in `BraintreeService`
- Add `SUBSCRIPTIONBILLINGSKIPPED` webhook notification support
- Add `implicitlyVaultedPaymentMethodToken` and `implicitlyVaultedPaymentMethodGlobalId` to `LocalPaymentDetails`
</PackageReleaseNotes>
<PackageProjectUrl>https://github.com/braintree/braintree_dotnet</PackageProjectUrl>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
Expand Down
4 changes: 4 additions & 0 deletions src/Braintree/LocalPaymentDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public class LocalPaymentDetails
public virtual string DebugId { get; protected set; }
public virtual string Description { get; protected set; }
public virtual string FundingSource { get; protected set; }
public virtual string ImplicitlyVaultedPaymentMethodGlobalId { get; protected set; }
public virtual string ImplicitlyVaultedPaymentMethodToken { get; protected set; }
public virtual string PayerId { get; protected set; }
public virtual string PaymentId { get; protected set; }
public virtual string RefundFromTransactionFeeAmount { get; protected set; }
Expand All @@ -24,6 +26,8 @@ protected internal LocalPaymentDetails(NodeWrapper node)
DebugId = node.GetString("debug-id");
Description = node.GetString("description");
FundingSource = node.GetString("funding-source");
ImplicitlyVaultedPaymentMethodGlobalId = node.GetString("implicitly-vaulted-payment-method-global-id");
ImplicitlyVaultedPaymentMethodToken = node.GetString("implicitly-vaulted-payment-method-token");
PayerId = node.GetString("payer-id");
PaymentId = node.GetString("payment-id");
RefundFromTransactionFeeAmount = node.GetString("refund-from-transaction-fee-amount");
Expand Down
4 changes: 2 additions & 2 deletions src/Braintree/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("5.19.0.0")]
[assembly: AssemblyFileVersion("5.19.0.0")]
[assembly: AssemblyVersion("5.20.0.0")]
[assembly: AssemblyFileVersion("5.20.0.0")]
1 change: 1 addition & 0 deletions src/Braintree/WebhookNotification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public enum WebhookKind
[Description("payment_method_customer_data_updated")] PAYMENT_METHOD_CUSTOMER_DATA_UPDATED,
[Description("payment_method_revoked_by_customer")] PAYMENT_METHOD_REVOKED_BY_CUSTOMER,
[Description("recipient_updated_granted_payment_method")] RECIPIENT_UPDATED_GRANTED_PAYMENT_METHOD,
[Description("subscription_billing_skipped")] SUBSCRIPTION_BILLING_SKIPPED,
[Description("subscription_canceled")] SUBSCRIPTION_CANCELED,
[Description("subscription_expired")] SUBSCRIPTION_EXPIRED,
[Description("subscription_charged_successfully")] SUBSCRIPTION_CHARGED_SUCCESSFULLY,
Expand Down
12 changes: 12 additions & 0 deletions src/Braintree/WebhookTestingGateway.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ private string SubjectSampleXml(WebhookKind kind, string id)
return DisputeDisputedSampleXml(id);
} else if (kind == WebhookKind.DISPUTE_EXPIRED) {
return DisputeExpiredSampleXml(id);
} else if (kind == WebhookKind.SUBSCRIPTION_BILLING_SKIPPED) {
return SubscriptionBillingSkippedSampleXml(id);
} else if (kind == WebhookKind.SUBSCRIPTION_CHARGED_SUCCESSFULLY) {
return SubscriptionChargedSuccessfullySampleXml(id);
} else if (kind == WebhookKind.SUBSCRIPTION_CHARGED_UNSUCCESSFULLY) {
Expand Down Expand Up @@ -427,6 +429,16 @@ private string SubscriptionXml(string id)
);
}

private string SubscriptionBillingSkippedSampleXml(string id)
{
return Node("subscription",
Node("id", id),
NodeAttr("transactions", TYPE_ARRAY),
NodeAttr("add_ons", TYPE_ARRAY),
NodeAttr("discounts", TYPE_ARRAY)
);
}

private string SubscriptionChargedSuccessfullySampleXml(string id)
{
return Node("subscription",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10211,7 +10211,7 @@ public void Sale_NetworkTokenizedTransaction() {
Assert.IsTrue(transactionResult.IsSuccess());
Transaction transaction = transactionResult.Target;
Assert.IsTrue(transaction.ProcessedWithNetworkToken);
Assert.IsNull(transaction.Retried);
Assert.IsFalse(transaction.Retried);
}

[Test]
Expand Down Expand Up @@ -10271,7 +10271,7 @@ public void Sale_NotAvailableForRetry()
var transactionResult = gateway.Transaction.Sale(request);
Assert.IsTrue(transactionResult.IsSuccess());
Transaction transaction = transactionResult.Target;
Assert.IsNull(transaction.Retried);
Assert.IsFalse(transaction.Retried);
}

[Test]
Expand Down
57 changes: 57 additions & 0 deletions test/Braintree.Tests/LocalPaymentDetailsTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using System.Xml;
using NUnit.Framework;

namespace Braintree.Tests
{
[TestFixture]
public class LocalPaymentDetailsTest
{
private NodeWrapper nodeFromXml(string xml)
{
XmlDocument doc = new XmlDocument();
doc.LoadXml(xml);
XmlNode newNode = doc.DocumentElement;
return new NodeWrapper(newNode);
}

[Test]
public void IncludesFields()
{
string xml = "<local-payment>" +

"<capture-id>CAT-1234</capture-id>" +
"<custom-field>whatever</custom-field>" +
"<debug-id>DEB-1234</debug-id>" +
"<description>Detailed text</description>" +
"<funding-source>ideal</funding-source>" +
"<implicitly-vaulted-payment-method-global-id>abcdefgabcdefg</implicitly-vaulted-payment-method-global-id>" +
"<implicitly-vaulted-payment-method-token>cx9rav</implicitly-vaulted-payment-method-token>" +
"<payer-id>nothing</payer-id>" +
"<payment-id>ABC12345</payment-id>" +
"<refund-from-transaction-fee-amount>2.00</refund-from-transaction-fee-amount>" +
"<refund-from-transaction-fee-currency-iso-code>EUR</refund-from-transaction-fee-currency-iso-code>" +
"<refund-id>REF-1234</refund-id>" +
"<transaction-fee-amount>10.00</transaction-fee-amount>" +
"<transaction-fee-currency-iso-code>EUR</transaction-fee-currency-iso-code>" +
"</local-payment>";
var node = nodeFromXml(xml);

LocalPaymentDetails details = new LocalPaymentDetails(node);

Assert.AreEqual("CAT-1234", details.CaptureId);
Assert.AreEqual("whatever", details.CustomField);
Assert.AreEqual("DEB-1234", details.DebugId);
Assert.AreEqual("Detailed text", details.Description);
Assert.AreEqual("ideal", details.FundingSource);
Assert.AreEqual("abcdefgabcdefg", details.ImplicitlyVaultedPaymentMethodGlobalId);
Assert.AreEqual("cx9rav", details.ImplicitlyVaultedPaymentMethodToken);
Assert.AreEqual("nothing", details.PayerId);
Assert.AreEqual("ABC12345", details.PaymentId);
Assert.AreEqual("2.00", details.RefundFromTransactionFeeAmount);
Assert.AreEqual("EUR", details.RefundFromTransactionFeeCurrencyIsoCode);
Assert.AreEqual("REF-1234", details.RefundId);
Assert.AreEqual("10.00", details.TransactionFeeAmount);
Assert.AreEqual("EUR", details.TransactionFeeCurrencyIsoCode);
}
}
}
14 changes: 14 additions & 0 deletions test/Braintree.Tests/WebhookNotificationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,20 @@ public void SampleNotification_ReturnsANotificationForAConnectedMerchantPayPalSt
Assert.AreEqual("oauth_application_client_id", notification.ConnectedMerchantPayPalStatusChanged.OAuthApplicationClientId);
}

[Test]
public void SampleNotification_ReturnsANotificationForSubscriptionBillingSkipped()
{
Dictionary<string, string> sampleNotification = gateway.WebhookTesting.SampleNotification(WebhookKind.SUBSCRIPTION_BILLING_SKIPPED, "my_id");

WebhookNotification notification = gateway.WebhookNotification.Parse(sampleNotification["bt_signature"], sampleNotification["bt_payload"]);

Assert.AreEqual(WebhookKind.SUBSCRIPTION_BILLING_SKIPPED, notification.Kind);
Assert.AreEqual("my_id", notification.Subscription.Id);
Assert.AreEqual(0, notification.Subscription.Transactions.Count);
Assert.AreEqual(0, notification.Subscription.Discounts.Count);
Assert.AreEqual(0, notification.Subscription.AddOns.Count);
}

[Test]
public void SampleNotification_ReturnsANotificationForSubscriptionChargedSuccessfully()
{
Expand Down

0 comments on commit a80e296

Please sign in to comment.