diff --git a/CHANGELOG.md b/CHANGELOG.md index 380c6b0f..9db213ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## 5.27.0 +- Add `PayerName`, `Bic` and `IbanLastChars` to LocalPaymentCompleted webhook +- Add `edit_paypal_vault_id` to `PayPalAccount` +- Add `AniFirstNameResponseCode` and `AniLastNameResponseCode` to `CreditCardVerification` +- Add `ShippingTaxAmount` to `Transaction` and `TransactionRequest` +- Add `networkTokenizationAttributes` to `TransactionCreditCardRequest` +- Add `NetworkTokenizationAttributesRequest` class +- Add validation error codes: + - `CREDIT_CARD_NETWORK_TOKENIZATION_ATTRIBUTE_CRYPTOGRAM_IS_REQUIRED` + ## 5.26.0 - Add attributes to `ThreeDSecureLookupRequest` - `MerchantInitiatedRequestType` diff --git a/src/Braintree/Braintree.csproj b/src/Braintree/Braintree.csproj index 84f1d2f4..7a5dbeed 100644 --- a/src/Braintree/Braintree.csproj +++ b/src/Braintree/Braintree.csproj @@ -4,7 +4,7 @@ Braintree Client Library Copyright © Braintree, a division of PayPal, Inc. 2021 - 5.26.0 + 5.27.0 Braintree net452;netstandard2.0 @@ -12,18 +12,14 @@ Braintree braintree;paypal;venmo;intenational;payments;gateway;currencies;money;visa;mastercard;bitcoin;maestro;apple pay;android pay;amex;jcb;diners club;discover;american express - - Add attributes to `ThreeDSecureLookupRequest` - - `MerchantInitiatedRequestType` - - `PriorAuthenticationId` - - `MerchantOnRecordName` - - `PriorAuthenticationDetails` - - Add `ForeignRetailer` to `Transaction` and `TransactionRequest` - - Add `InternationalPhone` to `Address` and `Customer` - - Add `fundingSourceDescription` to `PayPalAccount` - - Add missing `AndroidPayCard` error code - - Add `REFUND_FAILED` to `WebhookKind` - - Add `FinalCapture` to Transaction `TransactionRequest` - - Deprecate `paypal_tracking_id` in favor of `paypal_tracker_id` in PackageDetails + - Add `PayerName`, `Bic` and `IbanLastChars` to LocalPaymentCompleted webhook + - Add `edit_paypal_vault_id` to `PayPalAccount` + - Add `AniFirstNameResponseCode` and `AniLastNameResponseCode` to `CreditCardVerification` + - Add `ShippingTaxAmount` to `Transaction` and `TransactionRequest` + - Add `networkTokenizationAttributes` to `TransactionCreditCardRequest` + - Add `NetworkTokenizationAttributesRequest` class + - Add validation error codes: + - `CREDIT_CARD_NETWORK_TOKENIZATION_ATTRIBUTE_CRYPTOGRAM_IS_REQUIRED` https://github.com/braintree/braintree_dotnet false diff --git a/src/Braintree/CreditCardVerification.cs b/src/Braintree/CreditCardVerification.cs index 41f3dd85..40db7b19 100644 --- a/src/Braintree/CreditCardVerification.cs +++ b/src/Braintree/CreditCardVerification.cs @@ -18,33 +18,37 @@ public enum VerificationStatus public class CreditCardVerification { public virtual decimal? Amount { get; protected set; } + public virtual string AniFirstNameResponseCode { get; protected set; } + public virtual string AniLastNameResponseCode { get; protected set; } public virtual string AvsErrorResponseCode { get; protected set; } public virtual string AvsPostalCodeResponseCode { get; protected set; } public virtual string AvsStreetAddressResponseCode { get; protected set; } + public virtual Address BillingAddress { get; protected set; } + public virtual DateTime? CreatedAt { get; protected set; } + public virtual CreditCard CreditCard { get; protected set; } public virtual string CurrencyIsoCode { get; protected set; } public virtual string CvvResponseCode { get; protected set; } public virtual TransactionGatewayRejectionReason? GatewayRejectionReason { get; protected set; } - public virtual string ProcessorResponseCode { get; protected set; } - public virtual string ProcessorResponseText { get; protected set; } - public virtual ProcessorResponseType ProcessorResponseType { get; protected set; } + public virtual string GraphQLId { get; protected set; } + public virtual string Id { get; protected set; } + public virtual string MerchantAccountId { get; protected set; } public virtual string NetworkResponseCode { get; protected set; } public virtual string NetworkResponseText { get; protected set; } public virtual string NetworkTransactionId { get; protected set; } - public virtual string MerchantAccountId { get; protected set; } - public virtual VerificationStatus? Status { get; protected set; } - public virtual string GraphQLId { get; protected set; } - public virtual string Id { get; protected set; } - public virtual Address BillingAddress { get; protected set; } - public virtual CreditCard CreditCard { get; protected set; } - public virtual DateTime? CreatedAt { get; protected set; } + public virtual string ProcessorResponseCode { get; protected set; } + public virtual string ProcessorResponseText { get; protected set; } + public virtual ProcessorResponseType ProcessorResponseType { get; protected set; } public virtual RiskData RiskData { get; protected set; } + public virtual VerificationStatus? Status { get; protected set; } public virtual ThreeDSecureInfo ThreeDSecureInfo { get; protected set; } - + public CreditCardVerification(NodeWrapper node, IBraintreeGateway gateway) { if (node == null) return; Amount = node.GetDecimal("amount"); + AniFirstNameResponseCode = node.GetString("ani-first-name-response-code"); + AniLastNameResponseCode = node.GetString("ani-last-name-response-code"); AvsErrorResponseCode = node.GetString("avs-error-response-code"); AvsPostalCodeResponseCode = node.GetString("avs-postal-code-response-code"); AvsStreetAddressResponseCode = node.GetString("avs-street-address-response-code"); diff --git a/src/Braintree/LocalPaymentCompleted.cs b/src/Braintree/LocalPaymentCompleted.cs index 55035172..09a8552b 100644 --- a/src/Braintree/LocalPaymentCompleted.cs +++ b/src/Braintree/LocalPaymentCompleted.cs @@ -4,15 +4,21 @@ namespace Braintree { public class LocalPaymentCompleted { - public virtual string PaymentId { get; protected set; } + public virtual string Bic { get; protected set; } + public virtual string IbanLastChars { get; protected set; } public virtual string PayerId { get; protected set; } + public virtual string PayerName { get; protected set; } + public virtual string PaymentId { get; protected set; } public virtual string PaymentMethodNonce { get; protected set; } public virtual Transaction Transaction { get; protected set; } protected internal LocalPaymentCompleted(NodeWrapper node, IBraintreeGateway gateway) { - PaymentId = node.GetString("payment-id"); + Bic = node.GetString("bic"); + IbanLastChars = node.GetString("iban-last-chars"); PayerId = node.GetString("payer-id"); + PayerName = node.GetString("payer-name"); + PaymentId = node.GetString("payment-id"); PaymentMethodNonce = node.GetString("payment-method-nonce"); var transactionNode = node.GetNode("transaction"); diff --git a/src/Braintree/NetworkTokenizationAttributesRequest.cs b/src/Braintree/NetworkTokenizationAttributesRequest.cs new file mode 100644 index 00000000..eb258bbe --- /dev/null +++ b/src/Braintree/NetworkTokenizationAttributesRequest.cs @@ -0,0 +1,46 @@ +#pragma warning disable 1591 + +using System; + +namespace Braintree +{ + /// + /// A class for building transaction requests with manual key entry. + /// + /// + /// A network tokenization attributes request can be constructed as follows: + /// + /// NetworkTokenizationAttributesRequest createRequest = new NetworkTokenizationAttributesRequest + /// { + /// Cryptogram = "validcryptogram", + /// EcommerceIndicator = "05", + /// TokenRequestorId = "123456" + /// } + /// + /// + public class NetworkTokenizationAttributesRequest : Request + { + public string Cryptogram { get; set; } + public string EcommerceIndicator { get; set; } + public string TokenRequestorId { get; set; } + + public override string ToXml() + { + return ToXml("network-tokenization-attributes"); + } + + public override string ToXml(string root) + { + return BuildRequest(root).ToXml(); + } + + protected virtual RequestBuilder BuildRequest(string root) + { + return new RequestBuilder(root). + AddElement("cryptogram", Cryptogram). + AddElement("ecommerce-indicator", EcommerceIndicator). + AddElement("token-requestor-id", TokenRequestorId); + + } + } +} diff --git a/src/Braintree/PayPalAccount.cs b/src/Braintree/PayPalAccount.cs index fb65d59c..98afb411 100644 --- a/src/Braintree/PayPalAccount.cs +++ b/src/Braintree/PayPalAccount.cs @@ -7,6 +7,7 @@ public class PayPalAccount : PaymentMethod public virtual string BillingAgreementId { get; protected set; } public virtual DateTime? CreatedAt { get; protected set; } public virtual string CustomerId { get; protected set; } + public virtual string EditPayPalVaultId {get; protected set;} public virtual string Email { get; protected set; } public virtual string FundingSourceDescription { get; protected set; } public virtual string ImageUrl { get; protected set; } @@ -22,6 +23,7 @@ protected internal PayPalAccount(NodeWrapper node, IBraintreeGateway gateway) BillingAgreementId = node.GetString("billing-agreement-id"); CreatedAt = node.GetDateTime("created-at"); CustomerId = node.GetString("customer-id"); + EditPayPalVaultId = node.GetString("edit-paypal-vault-id"); Email = node.GetString("email"); FundingSourceDescription = node.GetString("funding-source-description"); ImageUrl = node.GetString("image-url"); diff --git a/src/Braintree/Properties/AssemblyInfo.cs b/src/Braintree/Properties/AssemblyInfo.cs index 179b4e85..524501f4 100644 --- a/src/Braintree/Properties/AssemblyInfo.cs +++ b/src/Braintree/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // Build Number // Revision // -[assembly: AssemblyVersion("5.26.0.0")] -[assembly: AssemblyFileVersion("5.26.0.0")] +[assembly: AssemblyVersion("5.27.0.0")] +[assembly: AssemblyFileVersion("5.27.0.0")] diff --git a/src/Braintree/Transaction.cs b/src/Braintree/Transaction.cs index 4123e734..f65e2fcc 100644 --- a/src/Braintree/Transaction.cs +++ b/src/Braintree/Transaction.cs @@ -125,9 +125,17 @@ public enum ACHReasonCodes /// public class Transaction { - public virtual string Id { get; protected set; } + + public virtual string AchReturnCode { get; protected set; } + public virtual string AcquirerReferenceNumber { get; protected set; } + public virtual string AdditionalProcessorResponse { get; protected set; } public virtual List AddOns { get; protected set; } public virtual decimal? Amount { get; protected set; } + public virtual AndroidPayDetails AndroidPayDetails { get; protected set; } + public virtual ApplePayDetails ApplePayDetails { get; protected set; } + public virtual List AuthorizationAdjustments { get; protected set; } + public virtual DateTime? AuthorizationExpiresAt { get; protected set; } + public virtual string AuthorizedTransactionId { get; protected set; } public virtual string AvsErrorResponseCode { get; protected set; } public virtual string AvsPostalCodeResponseCode { get; protected set; } public virtual string AvsStreetAddressResponseCode { get; protected set; } @@ -137,85 +145,80 @@ public class Transaction public virtual CreditCard CreditCard { get; protected set; } public virtual string CurrencyIsoCode { get; protected set; } public virtual CustomerDetails CustomerDetails { get; protected set; } + public virtual Dictionary CustomFields { get; protected set; } public virtual string CvvResponseCode { get; protected set; } public virtual TransactionDebitNetwork DebitNetwork { get; protected set; } public virtual Descriptor Descriptor { get; protected set; } + public virtual DisbursementDetails DisbursementDetails { get; protected set; } + public virtual decimal? DiscountAmount { get; protected set; } public virtual List Discounts { get; protected set; } public virtual List Disputes { get; protected set; } + public virtual TransactionEscrowStatus EscrowStatus { get; protected set; } + public virtual FacilitatedDetails FacilitatedDetails { get; protected set; } + public virtual FacilitatorDetails FacilitatorDetails { get; protected set; } + public virtual bool? ForeignRetailer { get; protected set; } public virtual TransactionGatewayRejectionReason GatewayRejectionReason { get; protected set; } public virtual string GraphQLId { get; protected set; } + public virtual string Id { get; protected set; } + public virtual decimal? InstallmentCount { get; protected set; } + public virtual List Installments { get; protected set; } + public virtual LocalPaymentDetails LocalPaymentDetails { get; protected set; } public virtual string MerchantAccountId { get; protected set; } + public virtual string MerchantAdviceCode { get; protected set; } + public virtual string MerchantAdviceCodeText { get; protected set; } + public virtual MetaCheckoutCardDetails MetaCheckoutCardDetails { get; protected set; } + public virtual MetaCheckoutTokenDetails MetaCheckoutTokenDetails { get; protected set; } + public virtual string NetworkResponseCode { get; protected set; } + public virtual string NetworkResponseText { get; protected set; } + public virtual CreditCard NetworkToken { get; protected set; } + public virtual string NetworkTransactionId { get; protected set; } public virtual string OrderId { get; protected set; } + public virtual PackageDetails[] Packages { get; protected set; } + public virtual List PartialSettlementTransactionIds { get; protected set; } + public virtual PaymentInstrumentType PaymentInstrumentType { get; protected set; } + public virtual PayPalDetails PayPalDetails { get; protected set; } + public virtual PayPalHereDetails PayPalHereDetails { get; protected set; } public virtual string PlanId { get; protected set; } public virtual bool? ProcessedWithNetworkToken { get; protected set; } public virtual string ProcessorAuthorizationCode { get; protected set; } - public virtual ProcessorResponseType ProcessorResponseType { get; protected set; } public virtual string ProcessorResponseCode { get; protected set; } public virtual string ProcessorResponseText { get; protected set; } + public virtual ProcessorResponseType ProcessorResponseType { get; protected set; } public virtual string ProcessorSettlementResponseCode { get; protected set; } public virtual string ProcessorSettlementResponseText { get; protected set; } - public virtual string AdditionalProcessorResponse { get; protected set; } - public virtual string NetworkResponseCode { get; protected set; } - public virtual string NetworkResponseText { get; protected set; } - public virtual string VoiceReferralNumber { get; protected set; } public virtual string PurchaseOrderNumber { get; protected set; } public virtual bool? Recurring { get; protected set; } + public virtual List RefundedInstallments { get; protected set; } public virtual string RefundedTransactionId { get; protected set; } public virtual List RefundIds { get; protected set; } - public virtual List PartialSettlementTransactionIds { get; protected set; } - public virtual string AuthorizedTransactionId { get; protected set; } + public virtual bool? Retried { get; protected set; } + public virtual string RetriedTransactionId { get; protected set; } + public virtual string RetrievalReferenceNumber { get; protected set; } + public virtual List RetryIds { get; protected set; } + public virtual RiskData RiskData { get; protected set; } + public virtual SamsungPayCardDetails SamsungPayCardDetails { get; protected set; } + public virtual string ScaExemptionRequested { get; protected set; } + public virtual SepaDirectDebitAccountDetails SepaDirectDebitAccountDetails { get; protected set; } + public virtual string SepaDirectDebitReturnCode { get; protected set; } + public virtual decimal? ServiceFeeAmount { get; protected set; } public virtual string SettlementBatchId { get; protected set; } public virtual Address ShippingAddress { get; protected set; } - public virtual TransactionEscrowStatus EscrowStatus { get; protected set; } + public virtual decimal? ShippingAmount { get; protected set; } + public virtual decimal? ShippingTaxAmount { get; protected set; } + public virtual string ShipsFromPostalCode { get; protected set; } public virtual TransactionStatus Status { get; protected set; } public virtual StatusEvent[] StatusHistory { get; protected set; } - public virtual List AuthorizationAdjustments { get; protected set; } - public virtual string SubscriptionId { get; protected set; } public virtual SubscriptionDetails SubscriptionDetails { get; protected set; } + public virtual string SubscriptionId { get; protected set; } public virtual decimal? TaxAmount { get; protected set; } public virtual bool? TaxExempt { get; protected set; } + public virtual ThreeDSecureInfo ThreeDSecureInfo { get; protected set; } public virtual TransactionType Type { get; protected set; } public virtual DateTime? UpdatedAt { get; protected set; } - public virtual Dictionary CustomFields { get; protected set; } - public virtual decimal? ServiceFeeAmount { get; protected set; } - public virtual DisbursementDetails DisbursementDetails { get; protected set; } - public virtual ApplePayDetails ApplePayDetails { get; protected set; } - public virtual AndroidPayDetails AndroidPayDetails { get; protected set; } - public virtual PayPalDetails PayPalDetails { get; protected set; } - public virtual PayPalHereDetails PayPalHereDetails { get; protected set; } - public virtual LocalPaymentDetails LocalPaymentDetails { get; protected set; } - public virtual VenmoAccountDetails VenmoAccountDetails { get; protected set; } - public virtual SepaDirectDebitAccountDetails SepaDirectDebitAccountDetails { get; protected set; } public virtual UsBankAccountDetails UsBankAccountDetails { get; protected set; } - public virtual MetaCheckoutCardDetails MetaCheckoutCardDetails { get; protected set; } - public virtual MetaCheckoutTokenDetails MetaCheckoutTokenDetails { get; protected set; } + public virtual VenmoAccountDetails VenmoAccountDetails { get; protected set; } public virtual VisaCheckoutCardDetails VisaCheckoutCardDetails { get; protected set; } - public virtual SamsungPayCardDetails SamsungPayCardDetails { get; protected set; } - public virtual PackageDetails[] Packages { get; protected set; } - public virtual PaymentInstrumentType PaymentInstrumentType { get; protected set; } - public virtual RiskData RiskData { get; protected set; } - public virtual ThreeDSecureInfo ThreeDSecureInfo { get; protected set; } - public virtual FacilitatedDetails FacilitatedDetails { get; protected set; } - public virtual FacilitatorDetails FacilitatorDetails { get; protected set; } - public virtual string ScaExemptionRequested { get; protected set; } - public virtual decimal? DiscountAmount { get; protected set; } - public virtual decimal? ShippingAmount { get; protected set; } - public virtual string ShipsFromPostalCode { get; protected set; } - public virtual string AchReturnCode { get; protected set; } - public virtual string SepaDirectDebitReturnCode { get; protected set; } - public virtual string NetworkTransactionId { get; protected set; } - public virtual DateTime? AuthorizationExpiresAt { get; protected set; } - public virtual string RetrievalReferenceNumber { get; protected set; } - public virtual string AcquirerReferenceNumber { get; protected set; } - public virtual decimal? InstallmentCount { get; protected set; } - public virtual List Installments { get; protected set; } - public virtual List RefundedInstallments { get; protected set; } - public virtual bool? Retried { get; protected set; } - public virtual string RetriedTransactionId { get; protected set; } - public virtual List RetryIds { get; protected set; } - public virtual string MerchantAdviceCode { get; protected set; } - public virtual string MerchantAdviceCodeText { get; protected set; } - public virtual bool? ForeignRetailer { get; protected set; } + public virtual string VoiceReferralNumber { get; protected set; } private IBraintreeGateway Gateway; @@ -292,6 +295,11 @@ protected internal Transaction(NodeWrapper node, IBraintreeGateway gateway) { CreditCard = new CreditCard(creditCardNode, gateway); } + var networkTokenNode = node.GetNode("network-token"); + if (networkTokenNode != null) + { + NetworkToken = new CreditCard(networkTokenNode, gateway); + } var subscriptionNode = node.GetNode("subscription"); if (subscriptionNode != null) { @@ -439,6 +447,7 @@ protected internal Transaction(NodeWrapper node, IBraintreeGateway gateway) DiscountAmount = node.GetDecimal("discount-amount"); ShippingAmount = node.GetDecimal("shipping-amount"); + ShippingTaxAmount = node.GetDecimal("shipping-tax-amount"); ShipsFromPostalCode = node.GetString("ships-from-postal-code"); AchReturnCode = node.GetString("ach-return-code"); diff --git a/src/Braintree/TransactionRequest.cs b/src/Braintree/TransactionRequest.cs index 793fda9e..e06ef3b6 100644 --- a/src/Braintree/TransactionRequest.cs +++ b/src/Braintree/TransactionRequest.cs @@ -7,14 +7,16 @@ namespace Braintree { public class TransactionCreditCardRequest : BaseCreditCardRequest { - public string Token { get; set; } + public NetworkTokenizationAttributesRequest NetworkTokenizationAttributes { get; set; } public PaymentReaderCardDetailsRequest PaymentReaderCardDetails { get; set; } + public string Token { get; set; } protected override RequestBuilder BuildRequest(string root) { return base.BuildRequest(root) - .AddElement("token", Token) - .AddElement("payment-reader-card-details", PaymentReaderCardDetails); + .AddElement("network-tokenization-attributes", NetworkTokenizationAttributes) + .AddElement("payment-reader-card-details", PaymentReaderCardDetails) + .AddElement("token", Token); } } @@ -86,6 +88,7 @@ public class TransactionRequest : Request public AddressRequest ShippingAddress { get; set; } public string ShippingAddressId { get; set; } public decimal? ShippingAmount { get; set; } + public decimal? ShippingTaxAmount { get; set; } public string ShipsFromPostalCode { get; set; } public decimal? TaxAmount { get; set; } public bool? TaxExempt { get; set; } @@ -186,6 +189,7 @@ protected virtual RequestBuilder BuildRequest(string root) builder.AddElement("shipping", ShippingAddress); builder.AddElement("shipping-address-id", ShippingAddressId); if (ShippingAmount.HasValue) builder.AddElement("shipping-amount", ShippingAmount); + if (ShippingTaxAmount.HasValue) builder.AddElement("shipping-tax-amount", ShippingTaxAmount); builder.AddElement("ships-from-postal-code", ShipsFromPostalCode); if (TaxAmount.HasValue) builder.AddElement("tax-amount", TaxAmount); if (TaxExempt.HasValue) builder.AddElement("tax-exempt", TaxExempt); diff --git a/src/Braintree/ValidationErrorCode.cs b/src/Braintree/ValidationErrorCode.cs index eb7c88e3..0d858b4b 100644 --- a/src/Braintree/ValidationErrorCode.cs +++ b/src/Braintree/ValidationErrorCode.cs @@ -106,6 +106,7 @@ public enum ValidationErrorCode CREDIT_CARD_EXPIRATION_YEAR_IS_INVALID = 81713, CREDIT_CARD_INVALID_PARAMS_FOR_CREDIT_CARD_UPDATE = 91745, CREDIT_CARD_INVALID_VENMO_SDK_PAYMENT_METHOD_CODE = 91727, + CREDIT_CARD_NETWORK_TOKENIZATION_ATTRIBUTE_CRYPTOGRAM_IS_REQUIRED = 81762, CREDIT_CARD_NUMBER_HAS_INVALID_LENGTH = 81716, CREDIT_CARD_NUMBER_IS_INVALID = 81715, CREDIT_CARD_NUMBER_IS_PROHIBITED = 81750, diff --git a/src/Braintree/WebhookTestingGateway.cs b/src/Braintree/WebhookTestingGateway.cs index 59000c73..fd3f34b7 100644 --- a/src/Braintree/WebhookTestingGateway.cs +++ b/src/Braintree/WebhookTestingGateway.cs @@ -622,8 +622,11 @@ private static string GrantedPaymentMethodRevokedSampleXml(string id) { private static string LocalPaymentCompletedSampleXml() { return Node("local-payment", - Node("payment-id", "a-payment-id"), + Node("bic", "a-bic"), + Node("iban-last-chars", "1234"), Node("payer-id", "a-payer-id"), + Node("payer-name", "a-payer-name"), + Node("payment-id", "a-payment-id"), Node("payment-method-nonce", "ee257d98-de40-47e8-96b3-a6954ea7a9a4"), Node("transaction", Node("id", "1"), diff --git a/test/Braintree.Tests.Integration/CreditCardVerificationIntegrationTest.cs b/test/Braintree.Tests.Integration/CreditCardVerificationIntegrationTest.cs index 93d093e5..8f910dc0 100644 --- a/test/Braintree.Tests.Integration/CreditCardVerificationIntegrationTest.cs +++ b/test/Braintree.Tests.Integration/CreditCardVerificationIntegrationTest.cs @@ -56,7 +56,28 @@ public void Create_ReturnsSuccessfulResponse() Assert.AreEqual("Approved", verification.ProcessorResponseText); Assert.AreEqual(ProcessorResponseType.APPROVED, verification.ProcessorResponseType); } + + [Test] + public void Create_ReturnsSuccessfulResponseForVisaANI() + { + var request = new CreditCardVerificationRequest + { + CreditCard = new CreditCardVerificationCreditCardRequest + { + Number = SandboxValues.CreditCardNumber.VISA, + ExpirationDate = "05/2009", + }, + }; + Result result = gateway.CreditCardVerification.Create(request); + Assert.IsTrue(result.IsSuccess()); + CreditCardVerification verification = result.Target; + Assert.AreEqual("I", verification.AniFirstNameResponseCode); + Assert.AreEqual("I", verification.AniLastNameResponseCode); + Assert.AreEqual("1000", verification.ProcessorResponseCode); + Assert.AreEqual("Approved", verification.ProcessorResponseText); + Assert.AreEqual(ProcessorResponseType.APPROVED, verification.ProcessorResponseType); + } [Test] public void CreatePaymentMethodNonce_ReturnsSuccessfulResponse() diff --git a/test/Braintree.Tests.Integration/MerchantAccountIntegrationTest.cs b/test/Braintree.Tests.Integration/MerchantAccountIntegrationTest.cs index 25128073..82878729 100644 --- a/test/Braintree.Tests.Integration/MerchantAccountIntegrationTest.cs +++ b/test/Braintree.Tests.Integration/MerchantAccountIntegrationTest.cs @@ -387,13 +387,13 @@ public void RetrievesCurrencyIsoCode() public void CreateForCurrency() { gateway = new BraintreeGateway( - "client_id$development$signup_client_id", - "client_secret$development$signup_client_secret" + "client_id$development$integration_client_id", + "client_secret$development$integration_client_secret" ); ResultImpl merchantResult = gateway.Merchant.Create(new MerchantRequest { Email = "name@email.com", - CountryCodeAlpha3 = "USA", + CountryCodeAlpha3 = "GBR", PaymentMethods = new string[] {"credit_card", "paypal"}, CompanyName = "Ziarog LTD" }); @@ -402,13 +402,13 @@ public void CreateForCurrency() gateway = new BraintreeGateway(merchantResult.Target.Credentials.AccessToken); Result result = gateway.MerchantAccount.CreateForCurrency(new MerchantAccountCreateForCurrencyRequest { - Currency = "GBP", + Currency = "USD", Id = "testId", }); Assert.IsTrue(result.IsSuccess()); Assert.AreEqual("testId", result.Target.Id); - Assert.AreEqual("GBP", result.Target.CurrencyIsoCode); + Assert.AreEqual("USD", result.Target.CurrencyIsoCode); } [Test] @@ -421,13 +421,13 @@ public void CreateForCurrencyAsync() #endif { gateway = new BraintreeGateway( - "client_id$development$signup_client_id", - "client_secret$development$signup_client_secret" + "client_id$development$integration_client_id", + "client_secret$development$integration_client_secret" ); ResultImpl merchantResult = gateway.Merchant.Create(new MerchantRequest { Email = "name@email.com", - CountryCodeAlpha3 = "USA", + CountryCodeAlpha3 = "GBR", PaymentMethods = new string[] {"credit_card", "paypal"}, CompanyName = "Ziarog LTD" }); @@ -436,13 +436,13 @@ public void CreateForCurrencyAsync() gateway = new BraintreeGateway(merchantResult.Target.Credentials.AccessToken); Result result = await gateway.MerchantAccount.CreateForCurrencyAsync(new MerchantAccountCreateForCurrencyRequest { - Currency = "GBP", + Currency = "USD", Id = "testId", }); Assert.IsTrue(result.IsSuccess()); Assert.AreEqual("testId", result.Target.Id); - Assert.AreEqual("GBP", result.Target.CurrencyIsoCode); + Assert.AreEqual("USD", result.Target.CurrencyIsoCode); } #if net452 ).GetAwaiter().GetResult(); @@ -453,13 +453,13 @@ public void CreateForCurrencyAsync() public void CreateForCurrency_HandlesAlreadyExistingMerchantAccountForCurrency() { gateway = new BraintreeGateway( - "client_id$development$signup_client_id", - "client_secret$development$signup_client_secret" + "client_id$development$integration_client_id", + "client_secret$development$integration_client_secret" ); ResultImpl merchantResult = gateway.Merchant.Create(new MerchantRequest { Email = "name@email.com", - CountryCodeAlpha3 = "USA", + CountryCodeAlpha3 = "GBR", PaymentMethods = new string[] {"credit_card", "paypal"}, CompanyName = "Ziarog LTD" }); @@ -468,7 +468,7 @@ public void CreateForCurrency_HandlesAlreadyExistingMerchantAccountForCurrency() gateway = new BraintreeGateway(merchantResult.Target.Credentials.AccessToken); Result result = gateway.MerchantAccount.CreateForCurrency(new MerchantAccountCreateForCurrencyRequest { - Currency = "USD", + Currency = "GBP", }); Assert.IsFalse(result.IsSuccess()); @@ -481,13 +481,13 @@ public void CreateForCurrency_HandlesAlreadyExistingMerchantAccountForCurrency() public void CreateForCurrency_HandlesCurrencyRequirement() { gateway = new BraintreeGateway( - "client_id$development$signup_client_id", - "client_secret$development$signup_client_secret" + "client_id$development$integration_client_id", + "client_secret$development$integration_client_secret" ); ResultImpl merchantResult = gateway.Merchant.Create(new MerchantRequest { Email = "name@email.com", - CountryCodeAlpha3 = "USA", + CountryCodeAlpha3 = "GBR", PaymentMethods = new string[] {"credit_card", "paypal"}, CompanyName = "Ziarog LTD" }); @@ -507,13 +507,13 @@ public void CreateForCurrency_HandlesCurrencyRequirement() public void CreateForCurrency_HandlesInvalidCurrency() { gateway = new BraintreeGateway( - "client_id$development$signup_client_id", - "client_secret$development$signup_client_secret" + "client_id$development$integration_client_id", + "client_secret$development$integration_client_secret" ); ResultImpl merchantResult = gateway.Merchant.Create(new MerchantRequest { Email = "name@email.com", - CountryCodeAlpha3 = "USA", + CountryCodeAlpha3 = "GBR", PaymentMethods = new string[] {"credit_card", "paypal"}, CompanyName = "Ziarog LTD" }); @@ -535,13 +535,13 @@ public void CreateForCurrency_HandlesInvalidCurrency() public void CreateForCurrency_HandlesExistingMerchantAccountForId() { gateway = new BraintreeGateway( - "client_id$development$signup_client_id", - "client_secret$development$signup_client_secret" + "client_id$development$integration_client_id", + "client_secret$development$integration_client_secret" ); ResultImpl merchantResult = gateway.Merchant.Create(new MerchantRequest { Email = "name@email.com", - CountryCodeAlpha3 = "USA", + CountryCodeAlpha3 = "GBR", PaymentMethods = new string[] {"credit_card", "paypal"}, CompanyName = "Ziarog LTD" }); @@ -597,7 +597,7 @@ public void All_ReturnsMerchantAccountWithCorrectAttributes() ResultImpl result = gateway.Merchant.Create(new MerchantRequest { Email = "name@email.com", - CountryCodeAlpha3 = "USA", + CountryCodeAlpha3 = "GBR", PaymentMethods = new string[] {"credit_card", "paypal"}, Scope = "read_write,shared_vault_transactions", }); @@ -613,7 +613,7 @@ public void All_ReturnsMerchantAccountWithCorrectAttributes() Assert.AreEqual(1, merchantAccounts.Count); MerchantAccount merchantAccount = merchantAccounts[0]; - Assert.AreEqual("USD", merchantAccount.CurrencyIsoCode); + Assert.AreEqual("GBP", merchantAccount.CurrencyIsoCode); Assert.AreEqual(MerchantAccountStatus.ACTIVE, merchantAccount.Status); Assert.IsTrue(merchantAccount.IsDefault); } diff --git a/test/Braintree.Tests.Integration/MerchantIntegrationTest.cs b/test/Braintree.Tests.Integration/MerchantIntegrationTest.cs index e9bfec69..537f35e5 100644 --- a/test/Braintree.Tests.Integration/MerchantIntegrationTest.cs +++ b/test/Braintree.Tests.Integration/MerchantIntegrationTest.cs @@ -23,7 +23,7 @@ public void Create_ReturnsMerchantAndCredentials() { ResultImpl result = gateway.Merchant.Create(new MerchantRequest { Email = "name@email.com", - CountryCodeAlpha3 = "USA", + CountryCodeAlpha3 = "GBR", PaymentMethods = new string[] {"credit_card", "paypal"}, Scope = "read_write,shared_vault_transactions", }); @@ -32,10 +32,10 @@ public void Create_ReturnsMerchantAndCredentials() Assert.IsFalse(string.IsNullOrEmpty(result.Target.Id)); Assert.AreEqual("name@email.com", result.Target.Email); Assert.AreEqual("name@email.com", result.Target.CompanyName); - Assert.AreEqual("USA", result.Target.CountryCodeAlpha3); - Assert.AreEqual("US", result.Target.CountryCodeAlpha2); - Assert.AreEqual("840", result.Target.CountryCodeNumeric); - Assert.AreEqual("United States of America", result.Target.CountryName); + Assert.AreEqual("GBR", result.Target.CountryCodeAlpha3); + Assert.AreEqual("GB", result.Target.CountryCodeAlpha2); + Assert.AreEqual("826", result.Target.CountryCodeNumeric); + Assert.AreEqual("United Kingdom", result.Target.CountryName); Assert.IsTrue(result.Target.Credentials.AccessToken.StartsWith("access_token$")); Assert.IsTrue(result.Target.Credentials.RefreshToken.StartsWith("refresh_token$")); @@ -49,7 +49,7 @@ public void Create_FailsWithInvalidPaymentMethods() { ResultImpl result = gateway.Merchant.Create(new MerchantRequest { Email = "name@email.com", - CountryCodeAlpha3 = "USA", + CountryCodeAlpha3 = "GBR", PaymentMethods = new string[] {"fake_money"} }); @@ -64,13 +64,13 @@ public void Create_FailsWithInvalidPaymentMethods() public void Create_MultiCurrencyMerchant() { gateway = new BraintreeGateway( - "client_id$development$signup_client_id", - "client_secret$development$signup_client_secret" + "client_id$development$integration_client_id", + "client_secret$development$integration_client_secret" ); ResultImpl result = gateway.Merchant.Create(new MerchantRequest { Email = "name@email.com", - CountryCodeAlpha3 = "USA", + CountryCodeAlpha3 = "GBR", PaymentMethods = new string[] {"credit_card", "paypal"}, CompanyName = "Ziarog LTD", Currencies = new string[] {"GBP", "USD"} @@ -80,10 +80,10 @@ public void Create_MultiCurrencyMerchant() Assert.IsFalse(string.IsNullOrEmpty(result.Target.Id)); Assert.AreEqual("name@email.com", result.Target.Email); Assert.AreEqual("Ziarog LTD", result.Target.CompanyName); - Assert.AreEqual("USA", result.Target.CountryCodeAlpha3); - Assert.AreEqual("US", result.Target.CountryCodeAlpha2); - Assert.AreEqual("840", result.Target.CountryCodeNumeric); - Assert.AreEqual("United States of America", result.Target.CountryName); + Assert.AreEqual("GBR", result.Target.CountryCodeAlpha3); + Assert.AreEqual("GB", result.Target.CountryCodeAlpha2); + Assert.AreEqual("826", result.Target.CountryCodeNumeric); + Assert.AreEqual("United Kingdom", result.Target.CountryName); Assert.IsTrue(result.Target.Credentials.AccessToken.StartsWith("access_token$")); Assert.IsTrue(result.Target.Credentials.RefreshToken.StartsWith("refresh_token$")); @@ -94,30 +94,30 @@ public void Create_MultiCurrencyMerchant() var usdMerchantAccount = (from ma in result.Target.MerchantAccounts where ma.Id == "USD" select ma).ToArray()[0]; Assert.AreEqual("USD", usdMerchantAccount.CurrencyIsoCode); - Assert.IsTrue(usdMerchantAccount.IsDefault.Value); + Assert.IsFalse(usdMerchantAccount.IsDefault.Value); var gbpMerchantAccount = (from ma in result.Target.MerchantAccounts where ma.Id == "GBP" select ma).ToArray()[0]; Assert.AreEqual("GBP", gbpMerchantAccount.CurrencyIsoCode); - Assert.IsFalse(gbpMerchantAccount.IsDefault.Value); + Assert.IsTrue(gbpMerchantAccount.IsDefault.Value); } [Test] public void Create_PayPalOnlyMultiCurrencyMerchant() { gateway = new BraintreeGateway( - "client_id$development$signup_client_id", - "client_secret$development$signup_client_secret" + "client_id$development$integration_client_id", + "client_secret$development$integration_client_secret" ); ResultImpl result = gateway.Merchant.Create(new MerchantRequest { Email = "name@email.com", - CountryCodeAlpha3 = "USA", + CountryCodeAlpha3 = "GBR", PaymentMethods = new string[] {"paypal"}, CompanyName = "Ziarog LTD", Currencies = new string[] {"GBP", "USD"}, PayPalAccount = new PayPalOnlyAccountRequest { - ClientId = "paypal_client_id", - ClientSecret = "paypal_client_secret" + ClientId = "fake_client_id", + ClientSecret = "fake_client_secret" } }); @@ -125,10 +125,10 @@ public void Create_PayPalOnlyMultiCurrencyMerchant() Assert.IsFalse(string.IsNullOrEmpty(result.Target.Id)); Assert.AreEqual("name@email.com", result.Target.Email); Assert.AreEqual("Ziarog LTD", result.Target.CompanyName); - Assert.AreEqual("USA", result.Target.CountryCodeAlpha3); - Assert.AreEqual("US", result.Target.CountryCodeAlpha2); - Assert.AreEqual("840", result.Target.CountryCodeNumeric); - Assert.AreEqual("United States of America", result.Target.CountryName); + Assert.AreEqual("GBR", result.Target.CountryCodeAlpha3); + Assert.AreEqual("GB", result.Target.CountryCodeAlpha2); + Assert.AreEqual("826", result.Target.CountryCodeNumeric); + Assert.AreEqual("United Kingdom", result.Target.CountryName); Assert.IsTrue(result.Target.Credentials.AccessToken.StartsWith("access_token$")); Assert.IsTrue(result.Target.Credentials.RefreshToken.StartsWith("refresh_token$")); @@ -139,107 +139,29 @@ public void Create_PayPalOnlyMultiCurrencyMerchant() var usdMerchantAccount = (from ma in result.Target.MerchantAccounts where ma.Id == "USD" select ma).ToArray()[0]; Assert.AreEqual("USD", usdMerchantAccount.CurrencyIsoCode); - Assert.IsTrue(usdMerchantAccount.IsDefault.Value); + Assert.IsFalse(usdMerchantAccount.IsDefault.Value); var gbpMerchantAccount = (from ma in result.Target.MerchantAccounts where ma.Id == "GBP" select ma).ToArray()[0]; Assert.AreEqual("GBP", gbpMerchantAccount.CurrencyIsoCode); - Assert.IsFalse(gbpMerchantAccount.IsDefault.Value); - } - - [Test] - public void Create_AllowsCreationOfNonUSMerchantIfOnboardingApplicationIsInternal() - { - gateway = new BraintreeGateway( - "client_id$development$signup_client_id", - "client_secret$development$signup_client_secret" - ); - - ResultImpl result = gateway.Merchant.Create(new MerchantRequest { - Email = "name@email.com", - CountryCodeAlpha3 = "JPN", - PaymentMethods = new string[] {"paypal"}, - PayPalAccount = new PayPalOnlyAccountRequest { - ClientId = "paypal_client_id", - ClientSecret = "paypal_client_secret" - } - }); - - Assert.IsTrue(result.IsSuccess()); - Assert.IsFalse(string.IsNullOrEmpty(result.Target.Id)); - Assert.AreEqual("name@email.com", result.Target.Email); - Assert.AreEqual("name@email.com", result.Target.CompanyName); - Assert.AreEqual("JPN", result.Target.CountryCodeAlpha3); - Assert.AreEqual("JP", result.Target.CountryCodeAlpha2); - Assert.AreEqual("392", result.Target.CountryCodeNumeric); - Assert.AreEqual("Japan", result.Target.CountryName); - - Assert.IsTrue(result.Target.Credentials.AccessToken.StartsWith("access_token$")); - Assert.IsTrue(result.Target.Credentials.RefreshToken.StartsWith("refresh_token$")); - Assert.IsTrue(result.Target.Credentials.ExpiresAt > DateTime.Now); - Assert.AreEqual("bearer", result.Target.Credentials.TokenType); - - Assert.AreEqual(1, result.Target.MerchantAccounts.Length); - - var merchantAccount = result.Target.MerchantAccounts[0]; - Assert.AreEqual("JPY", merchantAccount.CurrencyIsoCode); - Assert.IsTrue(merchantAccount.IsDefault.Value); - } - - [Test] - public void Create_DefaultsToUSDForNonUSMerchantIfOnboardingApplicationIsInternalAndCountryCurrencyNotSupported() - { - gateway = new BraintreeGateway( - "client_id$development$signup_client_id", - "client_secret$development$signup_client_secret" - ); - - ResultImpl result = gateway.Merchant.Create(new MerchantRequest { - Email = "name@email.com", - CountryCodeAlpha3 = "YEM", - PaymentMethods = new string[] {"paypal"}, - PayPalAccount = new PayPalOnlyAccountRequest { - ClientId = "paypal_client_id", - ClientSecret = "paypal_client_secret" - } - }); - - Assert.IsTrue(result.IsSuccess()); - Assert.IsFalse(string.IsNullOrEmpty(result.Target.Id)); - Assert.AreEqual("name@email.com", result.Target.Email); - Assert.AreEqual("name@email.com", result.Target.CompanyName); - Assert.AreEqual("YEM", result.Target.CountryCodeAlpha3); - Assert.AreEqual("YE", result.Target.CountryCodeAlpha2); - Assert.AreEqual("887", result.Target.CountryCodeNumeric); - Assert.AreEqual("Yemen", result.Target.CountryName); - - Assert.IsTrue(result.Target.Credentials.AccessToken.StartsWith("access_token$")); - Assert.IsTrue(result.Target.Credentials.RefreshToken.StartsWith("refresh_token$")); - Assert.IsTrue(result.Target.Credentials.ExpiresAt > DateTime.Now); - Assert.AreEqual("bearer", result.Target.Credentials.TokenType); - - Assert.AreEqual(1, result.Target.MerchantAccounts.Length); - - var merchantAccount = result.Target.MerchantAccounts[0]; - Assert.AreEqual("USD", merchantAccount.CurrencyIsoCode); - Assert.IsTrue(merchantAccount.IsDefault.Value); + Assert.IsTrue(gbpMerchantAccount.IsDefault.Value); } [Test] public void Create_ReturnsErrorIfInvalidCurrencyPassed() { gateway = new BraintreeGateway( - "client_id$development$signup_client_id", - "client_secret$development$signup_client_secret" + "client_id$development$integration_client_id", + "client_secret$development$integration_client_secret" ); ResultImpl result = gateway.Merchant.Create(new MerchantRequest { Email = "name@email.com", - CountryCodeAlpha3 = "USA", + CountryCodeAlpha3 = "GBR", PaymentMethods = new string[] {"paypal"}, - Currencies = new string[] {"GBP", "FAKE"}, + Currencies = new string[] {"USD", "FAKE"}, PayPalAccount = new PayPalOnlyAccountRequest { - ClientId = "paypal_client_id", - ClientSecret = "paypal_client_secret" + ClientId = "fake_client_id", + ClientSecret = "fake_client_secret" } }); diff --git a/test/Braintree.Tests.Integration/PaymentMethodIntegrationTest.cs b/test/Braintree.Tests.Integration/PaymentMethodIntegrationTest.cs index 2fe9f642..fd51da39 100644 --- a/test/Braintree.Tests.Integration/PaymentMethodIntegrationTest.cs +++ b/test/Braintree.Tests.Integration/PaymentMethodIntegrationTest.cs @@ -103,6 +103,7 @@ public void Create_CreatesPayPalAccountWithOrderPaymentNonce() PayPalAccount paypalAccount = (PayPalAccount) paymentMethodResult.Target; Assert.IsNotNull(paypalAccount.PayerId); Assert.IsNull(paypalAccount.FundingSourceDescription); + Assert.IsNull(paypalAccount.EditPayPalVaultId); } [Test] diff --git a/test/Braintree.Tests.Integration/TransactionIntegrationTest.cs b/test/Braintree.Tests.Integration/TransactionIntegrationTest.cs index f976e74b..279c80c3 100644 --- a/test/Braintree.Tests.Integration/TransactionIntegrationTest.cs +++ b/test/Braintree.Tests.Integration/TransactionIntegrationTest.cs @@ -3896,7 +3896,7 @@ public void Sale_GatewayRejectedForApplicationIncomplete() ResultImpl merchantResult = oauthGateway.Merchant.Create(new MerchantRequest { Email = "name@email.com", - CountryCodeAlpha3 = "USA", + CountryCodeAlpha3 = "GBR", PaymentMethods = new string[] { "credit_card", "paypal" } }); @@ -5651,21 +5651,18 @@ public void Sale_WithExternalVaultStatusVaultedWithoutPreviousNetworkTransaction [Test] public void Sale_WithExternalVault_ValidationErrorPaymentInstrumentIsInvalid() { - CustomerRequest customerRequest = new CustomerRequest + Customer customer = gateway.Customer.Create(new CustomerRequest()).Target; + + var paypalCreateRequest = new PaymentMethodRequest { - CreditCard = new CreditCardRequest - { - CardholderName = "Fred Jones", - Number = "5105105105105100", - ExpirationDate = "05/12" - } + CustomerId = customer.Id, + PaymentMethodNonce = Nonce.PayPalBillingAgreement, }; - - CreditCard creditCard = gateway.Customer.Create(customerRequest).Target.CreditCards[0]; + PaymentMethod paypalPaymentMethod = gateway.PaymentMethod.Create(paypalCreateRequest).Target; var request = new TransactionRequest { Amount = SandboxValues.TransactionAmount.AUTHORIZE, - PaymentMethodToken = creditCard.Token, + PaymentMethodToken = paypalPaymentMethod.Token, ExternalVault = new ExternalVaultRequest { Status = "vaulted", @@ -5920,6 +5917,33 @@ public void Sale_WithLevel3SummaryFields_ReturnsSuccessfulResponse() Assert.AreEqual("12345", transaction.ShipsFromPostalCode); } + [Test] + public void Sale_WithShippingTaxAmount() + { + var request = new TransactionRequest + { + Amount = SandboxValues.TransactionAmount.AUTHORIZE, + CreditCard = new TransactionCreditCardRequest + { + Number = SandboxValues.CreditCardNumber.VISA, + ExpirationDate = "05/2009", + }, + ShippingAmount = 1.00M, + ShippingTaxAmount = 3.00M, + DiscountAmount = 2.00M, + ShipsFromPostalCode = "12345", + }; + + Result result = gateway.Transaction.Sale(request); + Assert.IsTrue(result.IsSuccess()); + Transaction transaction = result.Target; + + Assert.AreEqual(1.00, transaction.ShippingAmount); + Assert.AreEqual(3.00, transaction.ShippingTaxAmount); + Assert.AreEqual(2.00, transaction.DiscountAmount); + Assert.AreEqual("12345", transaction.ShipsFromPostalCode); + } + [Test] public void Sale_WhenDiscountAmountCannotBeNegative() { @@ -8315,6 +8339,7 @@ public void SubmitForSettlement_WithLevel3Data() TaxAmount = 1.12M, TaxExempt = true, ShippingAmount = 1.00M, + ShippingTaxAmount = 0.23M, DiscountAmount = 2.00M, ShipsFromPostalCode = "12345", LineItems = new TransactionLineItemRequest[] @@ -8341,6 +8366,7 @@ public void SubmitForSettlement_WithLevel3Data() Result result = gateway.Transaction.SubmitForSettlement(transaction.Id, submitForSettlementRequest); Assert.IsTrue(result.IsSuccess()); + Assert.AreEqual(0.23, result.Target.ShippingTaxAmount); Assert.AreEqual(TransactionStatus.SUBMITTED_FOR_SETTLEMENT, result.Target.Status); } @@ -11119,6 +11145,56 @@ public void Unsucccessful_ManualKeyEntryTransaction() { Assert.AreEqual(ValidationErrorCode.TRANSACTION_PAYMENT_INSTRUMENT_NOT_SUPPORTED_BY_MERCHANT_ACCOUNT, transactionError.Code); } + [Test] + public void Successful_ExternalNetworkTokenTransaction() { + var request = new TransactionRequest { + Amount = 100, + CreditCard = new TransactionCreditCardRequest + { + Number = "5105105105105100", + ExpirationDate = "05/2012", + NetworkTokenizationAttributes = new NetworkTokenizationAttributesRequest + { + Cryptogram = "8F34DFB312DC79C24FD5320622F3E11682D79E6B0C0FD881", + EcommerceIndicator = "05", + TokenRequestorId = "1234567" + } + }, + }; + + var transactionResult = gateway.Transaction.Sale(request); + Assert.IsTrue(transactionResult.IsSuccess()); + Transaction transaction = transactionResult.Target; + + Assert.IsTrue(transaction.ProcessedWithNetworkToken); + Assert.IsTrue(transaction.NetworkToken.IsNetworkTokenized); + } + + [Test] + public void Unsuccessful_ExternalNetworkTokenTransaction() { + var request = new TransactionRequest { + Amount = 100, + CreditCard = new TransactionCreditCardRequest + { + Number = "5105105105105100", + ExpirationDate = "05/2012", + NetworkTokenizationAttributes = new NetworkTokenizationAttributesRequest + { + EcommerceIndicator = "05", + TokenRequestorId = "1234567" + } + }, + }; + + var transactionResult = gateway.Transaction.Sale(request); + Assert.IsFalse(transactionResult.IsSuccess()); + var transactionError = transactionResult.Errors.ForObject("Transaction").ForObject("CreditCard").OnField("NetworkTokenizationAttributes")[0]; + Assert.AreEqual( + ValidationErrorCode.CREDIT_CARD_NETWORK_TOKENIZATION_ATTRIBUTE_CRYPTOGRAM_IS_REQUIRED, + transactionError.Code + ); + } + [Test] public void Successful_AdjustAuthorization() { var request = new TransactionRequest { diff --git a/test/Braintree.Tests/CreditCardVerificationTest.cs b/test/Braintree.Tests/CreditCardVerificationTest.cs index d6468525..85dbe5cb 100644 --- a/test/Braintree.Tests/CreditCardVerificationTest.cs +++ b/test/Braintree.Tests/CreditCardVerificationTest.cs @@ -89,5 +89,25 @@ public void ConstructFromResponseWithNoVerification() Assert.AreEqual(null, verification.ProcessorResponseText); Assert.AreEqual(null, verification.CvvResponseCode); } + + [Test] + public void DeserializesVisaAniResponseCodeFromXml() + { + StringBuilder builder = new StringBuilder(); + builder.Append("\n"); + builder.Append("\n"); + builder.Append(" M\n"); + builder.Append(" M\n"); + builder.Append("\n"); + + XmlDocument doc = new XmlDocument(); + doc.LoadXml(builder.ToString()); + XmlNode newNode = doc.DocumentElement; + var node = new NodeWrapper(newNode); + + CreditCardVerification verification = new CreditCardVerification(node, gateway); + Assert.AreEqual("M", verification.AniFirstNameResponseCode); + Assert.AreEqual("M", verification.AniLastNameResponseCode); + } } } diff --git a/test/Braintree.Tests/NetworkTokenizationAttributesRequestTest.cs b/test/Braintree.Tests/NetworkTokenizationAttributesRequestTest.cs new file mode 100644 index 00000000..a1ed640a --- /dev/null +++ b/test/Braintree.Tests/NetworkTokenizationAttributesRequestTest.cs @@ -0,0 +1,24 @@ +using NUnit.Framework; +using System; + +namespace Braintree.Tests +{ + [TestFixture] + public class NetworkTokenizationAttributesRequestTest + { + [Test] + public void ToXml_IncludesAllProperties() + { + var request = new NetworkTokenizationAttributesRequest() + { + Cryptogram = "validcryptogram", + EcommerceIndicator = "05", + TokenRequestorId = "123456" + }; + + Assert.IsTrue(request.ToXml("network-tokenization-attributes").Contains("validcryptogram")); + Assert.IsTrue(request.ToXml("network-tokenization-attributes").Contains("05")); + Assert.IsTrue(request.ToXml("network-tokenization-attributes").Contains("123456")); + } + } +} diff --git a/test/Braintree.Tests/PayPalAccountTest.cs b/test/Braintree.Tests/PayPalAccountTest.cs index 583e0d6d..38034d53 100644 --- a/test/Braintree.Tests/PayPalAccountTest.cs +++ b/test/Braintree.Tests/PayPalAccountTest.cs @@ -33,6 +33,7 @@ public void ConstructFromXMLResponse() builder.Append("billingagreementid"); builder.Append("2018-04-12T19:54:16Z"); builder.Append("1396526238"); + builder.Append("BA-ID1"); builder.Append("some-email"); builder.Append("VISA 1234"); builder.Append("https://google.com/image.png"); @@ -53,6 +54,7 @@ public void ConstructFromXMLResponse() Assert.AreEqual("billingagreementid", paypalAccount.BillingAgreementId); Assert.AreEqual("4/12/2018 7:54:16 PM", paypalAccount.CreatedAt?.ToString(CultureInfo.GetCultureInfo("en-US"))); Assert.AreEqual("1396526238", paypalAccount.CustomerId); + Assert.AreEqual("BA-ID1", paypalAccount.EditPayPalVaultId); Assert.AreEqual("some-email", paypalAccount.Email); Assert.AreEqual("VISA 1234", paypalAccount.FundingSourceDescription); Assert.AreEqual("https://google.com/image.png", paypalAccount.ImageUrl); diff --git a/test/Braintree.Tests/TransactionCreditCardRequestTest.cs b/test/Braintree.Tests/TransactionCreditCardRequestTest.cs index 605f7539..f8e51842 100644 --- a/test/Braintree.Tests/TransactionCreditCardRequestTest.cs +++ b/test/Braintree.Tests/TransactionCreditCardRequestTest.cs @@ -12,5 +12,19 @@ public void ToXml_Includes_Token() request.Token = "my-token"; Assert.IsTrue(request.ToXml().Contains("my-token")); } + + [Test] + public void ToXml_Includes_NetworkTokenizationAttributesRequest() + { + TransactionCreditCardRequest request = new TransactionCreditCardRequest(); + request.NetworkTokenizationAttributes = new NetworkTokenizationAttributesRequest(); + request.NetworkTokenizationAttributes.Cryptogram = "validcryptogram"; + request.NetworkTokenizationAttributes.EcommerceIndicator = "05"; + request.NetworkTokenizationAttributes.TokenRequestorId = "123456"; + + Assert.IsTrue(request.ToXml().Contains("validcryptogram")); + Assert.IsTrue(request.ToXml().Contains("05")); + Assert.IsTrue(request.ToXml().Contains("123456")); + } } } diff --git a/test/Braintree.Tests/TransactionRequestTest.cs b/test/Braintree.Tests/TransactionRequestTest.cs index 05ea945e..c5767161 100644 --- a/test/Braintree.Tests/TransactionRequestTest.cs +++ b/test/Braintree.Tests/TransactionRequestTest.cs @@ -115,5 +115,23 @@ public void ToXml_IncludesFinalCapture() Assert.AreEqual("true",doc.GetElementsByTagName("final-capture")[0].InnerXml); } + + public void ToXml_Includes_ShippingTaxAmount() + { + TransactionRequest request = new TransactionRequest(); + request.ShippingAmount = 1.00M; + request.DiscountAmount = 2.00M; + request.ShippingTaxAmount = 3.00M; + request.ShipsFromPostalCode = "12345"; + + string xml = request.ToXml(); + XmlDocument doc = new XmlDocument(); + doc.LoadXml(xml); + + Assert.AreEqual("1.00", doc.GetElementsByTagName("shipping-amount")[0].InnerXml); + Assert.AreEqual("2.00", doc.GetElementsByTagName("discount-amount")[0].InnerXml); + Assert.AreEqual("12345", doc.GetElementsByTagName("ships-from-postal-code")[0].InnerXml); + Assert.AreEqual("3.00", doc.GetElementsByTagName("shipping-tax-amount")[0].InnerXml); + } } } diff --git a/test/Braintree.Tests/TransactionTest.cs b/test/Braintree.Tests/TransactionTest.cs index 16a508af..6320a9da 100644 --- a/test/Braintree.Tests/TransactionTest.cs +++ b/test/Braintree.Tests/TransactionTest.cs @@ -182,6 +182,7 @@ public void DeserializesLevel3SummaryFieldsFromXml() string xml = "\n" + "\n" + " 1.00\n" + + " 1.00\n" + " 2.00\n" + " 12345\n" + " \n" + @@ -196,6 +197,7 @@ public void DeserializesLevel3SummaryFieldsFromXml() Transaction transaction = new Transaction(node, gateway); Assert.AreEqual(1.00M, transaction.ShippingAmount); + Assert.AreEqual(1.00M, transaction.ShippingTaxAmount); Assert.AreEqual(2.00M, transaction.DiscountAmount); Assert.AreEqual("12345", transaction.ShipsFromPostalCode); } @@ -413,5 +415,25 @@ public void DeserializesForeignRetailerFromXml() Transaction transaction = new Transaction(node, gateway); Assert.IsTrue(transaction.ForeignRetailer); } + + [Test] + public void DeserializesExternalNetworkTokenResponseFromXml() + { + string xml = "\n" + + "\n" + + "\n" + + " true\n" + + "\n" + + "\n"; + + XmlDocument doc = new XmlDocument(); + doc.LoadXml(xml); + XmlNode newNode = doc.DocumentElement; + var node = new NodeWrapper(newNode); + + Transaction transaction = new Transaction(node, gateway); + + Assert.IsTrue(transaction.NetworkToken.IsNetworkTokenized); + } } } diff --git a/test/Braintree.Tests/WebhookNotificationTest.cs b/test/Braintree.Tests/WebhookNotificationTest.cs index e9adcc95..25b3394c 100644 --- a/test/Braintree.Tests/WebhookNotificationTest.cs +++ b/test/Braintree.Tests/WebhookNotificationTest.cs @@ -716,8 +716,11 @@ public void SampleNotification_ReturnsANotificationForLocalPaymentCompleted() Assert.AreEqual(WebhookKind.LOCAL_PAYMENT_COMPLETED, notification.Kind); LocalPaymentCompleted localPayment = notification.LocalPaymentCompleted; - Assert.AreEqual("a-payment-id", localPayment.PaymentId); Assert.AreEqual("a-payer-id", localPayment.PayerId); + Assert.AreEqual("a-bic", localPayment.Bic); + Assert.AreEqual("1234", localPayment.IbanLastChars); + Assert.AreEqual("a-payer-name", localPayment.PayerName); + Assert.AreEqual("a-payment-id", localPayment.PaymentId); Assert.AreEqual("ee257d98-de40-47e8-96b3-a6954ea7a9a4", localPayment.PaymentMethodNonce); Assert.NotNull(localPayment.Transaction); }