Skip to content

[Checkout] Skip serialisation of attributes with default values #1170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Adyen.Test/PaymentMethodDetailsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public void TestAchPaymentMethod()
{
var achDetails = new AchDetails
{
Type = AchDetails.TypeEnum.Ach,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marked as a breaking change - Developers will have to add this property after this change.
Suggestion: Can we make auto-populate this property? It seems like it could only have one possible value.

BankAccountNumber = "1234567",
BankLocationId = "1234567",
EncryptedBankAccountNumber = "1234asdfg",
Expand Down Expand Up @@ -45,6 +46,7 @@ public void TestApplePayPaymentMethod()
{
var applePay = new ApplePayDetails
{
Type = ApplePayDetails.TypeEnum.Applepay,
ApplePayToken = "VNRWtuNlNEWkRCSm1xWndjMDFFbktkQU..."
};
var paymentRequest = new PaymentRequest
Expand Down Expand Up @@ -73,6 +75,7 @@ public void TestGooglePayPaymentMethod()
Reference = "google pay test",
PaymentMethod = new CheckoutPaymentMethod(new GooglePayDetails
{
Type = GooglePayDetails.TypeEnum.Googlepay,
GooglePayToken = "==Payload as retrieved from Google Pay response==",
FundingSource = GooglePayDetails.FundingSourceEnum.Debit
}),
Expand All @@ -98,6 +101,7 @@ public void TestIdealPaymentMethod()
Reference = "ideal test",
PaymentMethod = new CheckoutPaymentMethod(new IdealDetails
{
Type = IdealDetails.TypeEnum.Ideal,
Issuer = "1121"
}),
ReturnUrl = "https://your-company.com/checkout?shopperOrder=12xy.."
Expand All @@ -119,6 +123,7 @@ public void TestBacsDirectDebitDetails()
Reference = "bacs direct debit test",
PaymentMethod = new CheckoutPaymentMethod(new BacsDirectDebitDetails
{
Type = BacsDirectDebitDetails.TypeEnum.DirectdebitGB,
BankAccountNumber = "NL0123456789",
BankLocationId = "121000358",
HolderName = "John Smith"
Expand Down Expand Up @@ -146,6 +151,7 @@ public void TestPaypalSuccess()
Reference = "paypal test",
PaymentMethod = new CheckoutPaymentMethod( new PayPalDetails
{
Type = PayPalDetails.TypeEnum.Paypal,
Subtype = PayPalDetails.SubtypeEnum.Sdk,
StoredPaymentMethodId = "2345654212345432345"
}),
Expand Down
8 changes: 6 additions & 2 deletions Adyen.Test/SerializerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,12 @@ public void CheckoutLongSerializationTest()
}
}.ToJson();
// Assert that Long parameters set to zero are actually serialised (just like Int)
Assert.IsTrue(checkoutSessionRequest.Contains("amountExcludingTax\": 0,"));
Assert.IsTrue(checkoutSessionRequest.Contains("taxAmount\": 0"));
Assert.IsTrue(checkoutSessionRequest.Contains("\"amountExcludingTax\": 0,"));
Assert.IsTrue(checkoutSessionRequest.Contains("\"taxAmount\": 0"));
// check attribute with default values
Assert.IsFalse(checkoutSessionRequest.Contains("\"mode\": \"embedded\""));
Assert.IsFalse(checkoutSessionRequest.Contains("\"splitCardFundingSources\": false"));
Assert.IsFalse(checkoutSessionRequest.Contains("\"threeDSAuthenticationOnly\": false"));
}

[TestMethod]
Expand Down
1 change: 1 addition & 0 deletions Adyen/Adyen.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<RootNamespace>Adyen</RootNamespace>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed, it would take the Adyen-.csproj as default

<TargetFrameworks>net8.0;net6.0;net462;netstandard2.0</TargetFrameworks>
<LangVersion>12</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Model/Checkout/AchDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public enum TypeEnum
/// <param name="storedPaymentMethodId">This is the &#x60;recurringDetailReference&#x60; returned in the response when you created the token..</param>
/// <param name="transferInstrumentId">The unique identifier of your user&#39;s verified transfer instrument, which you can use to top up their balance accounts..</param>
/// <param name="type">**ach** (default to TypeEnum.Ach).</param>
public AchDetails(AccountHolderTypeEnum? accountHolderType = default(AccountHolderTypeEnum?), string bankAccountNumber = default(string), BankAccountTypeEnum? bankAccountType = default(BankAccountTypeEnum?), string bankLocationId = default(string), string checkoutAttemptId = default(string), string encryptedBankAccountNumber = default(string), string encryptedBankLocationId = default(string), string ownerName = default(string), string recurringDetailReference = default(string), string storedPaymentMethodId = default(string), string transferInstrumentId = default(string), TypeEnum? type = TypeEnum.Ach)
public AchDetails(AccountHolderTypeEnum? accountHolderType = default(AccountHolderTypeEnum?), string bankAccountNumber = default(string), BankAccountTypeEnum? bankAccountType = default(BankAccountTypeEnum?), string bankLocationId = default(string), string checkoutAttemptId = default(string), string encryptedBankAccountNumber = default(string), string encryptedBankLocationId = default(string), string ownerName = default(string), string recurringDetailReference = default(string), string storedPaymentMethodId = default(string), string transferInstrumentId = default(string), TypeEnum? type = null)
{
this.AccountHolderType = accountHolderType;
this.BankAccountNumber = bankAccountNumber;
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Model/Checkout/AffirmDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public enum TypeEnum
/// </summary>
/// <param name="checkoutAttemptId">The checkout attempt identifier..</param>
/// <param name="type">**affirm** (default to TypeEnum.Affirm).</param>
public AffirmDetails(string checkoutAttemptId = default(string), TypeEnum? type = TypeEnum.Affirm)
public AffirmDetails(string checkoutAttemptId = default(string), TypeEnum? type = null)
{
this.CheckoutAttemptId = checkoutAttemptId;
this.Type = type;
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Model/Checkout/AmazonPayDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public enum TypeEnum
/// <param name="checkoutAttemptId">The checkout attempt identifier..</param>
/// <param name="checkoutSessionId">The &#x60;checkoutSessionId&#x60; is used to identify the checkout session at the Amazon Pay side. This field is required only for drop-in and components integration, where it replaces the amazonPayToken..</param>
/// <param name="type">**amazonpay** (default to TypeEnum.Amazonpay).</param>
public AmazonPayDetails(string amazonPayToken = default(string), string checkoutAttemptId = default(string), string checkoutSessionId = default(string), TypeEnum? type = TypeEnum.Amazonpay)
public AmazonPayDetails(string amazonPayToken = default(string), string checkoutAttemptId = default(string), string checkoutSessionId = default(string), TypeEnum? type = null)
{
this.AmazonPayToken = amazonPayToken;
this.CheckoutAttemptId = checkoutAttemptId;
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Model/Checkout/AndroidPayDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public enum TypeEnum
/// </summary>
/// <param name="checkoutAttemptId">The checkout attempt identifier..</param>
/// <param name="type">**androidpay** (default to TypeEnum.Androidpay).</param>
public AndroidPayDetails(string checkoutAttemptId = default(string), TypeEnum? type = TypeEnum.Androidpay)
public AndroidPayDetails(string checkoutAttemptId = default(string), TypeEnum? type = null)
{
this.CheckoutAttemptId = checkoutAttemptId;
this.Type = type;
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Model/Checkout/ApplePayDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected ApplePayDetails() { }
/// <param name="recurringDetailReference">This is the &#x60;recurringDetailReference&#x60; returned in the response when you created the token..</param>
/// <param name="storedPaymentMethodId">This is the &#x60;recurringDetailReference&#x60; returned in the response when you created the token..</param>
/// <param name="type">**applepay** (default to TypeEnum.Applepay).</param>
public ApplePayDetails(string applePayToken = default(string), string checkoutAttemptId = default(string), FundingSourceEnum? fundingSource = default(FundingSourceEnum?), string recurringDetailReference = default(string), string storedPaymentMethodId = default(string), TypeEnum? type = TypeEnum.Applepay)
public ApplePayDetails(string applePayToken = default(string), string checkoutAttemptId = default(string), FundingSourceEnum? fundingSource = default(FundingSourceEnum?), string recurringDetailReference = default(string), string storedPaymentMethodId = default(string), TypeEnum? type = null)
{
this.ApplePayToken = applePayToken;
this.CheckoutAttemptId = checkoutAttemptId;
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Model/Checkout/ApplePayDonations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected ApplePayDonations() { }
/// <param name="recurringDetailReference">This is the &#x60;recurringDetailReference&#x60; returned in the response when you created the token..</param>
/// <param name="storedPaymentMethodId">This is the &#x60;recurringDetailReference&#x60; returned in the response when you created the token..</param>
/// <param name="type">**applepay** (default to TypeEnum.Applepay).</param>
public ApplePayDonations(string applePayToken = default(string), string checkoutAttemptId = default(string), FundingSourceEnum? fundingSource = default(FundingSourceEnum?), string recurringDetailReference = default(string), string storedPaymentMethodId = default(string), TypeEnum? type = TypeEnum.Applepay)
public ApplePayDonations(string applePayToken = default(string), string checkoutAttemptId = default(string), FundingSourceEnum? fundingSource = default(FundingSourceEnum?), string recurringDetailReference = default(string), string storedPaymentMethodId = default(string), TypeEnum? type = null)
{
this.ApplePayToken = applePayToken;
this.CheckoutAttemptId = checkoutAttemptId;
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Model/Checkout/AuthenticationData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public enum AttemptAuthenticationEnum
/// <param name="attemptAuthentication">Indicates when 3D Secure authentication should be attempted. This overrides all other rules, including [Dynamic 3D Secure settings](https://docs.adyen.com/risk-management/dynamic-3d-secure). Possible values: * **always**: Perform 3D Secure authentication. * **never**: Don&#39;t perform 3D Secure authentication. If PSD2 SCA or other national regulations require authentication, the transaction gets declined..</param>
/// <param name="authenticationOnly">Required to trigger the [authentication-only flow](https://docs.adyen.com/online-payments/3d-secure/authentication-only/). If set to **true**, you will only perform the 3D Secure 2 authentication, and will not proceed to the payment authorization. Default: **false**. (default to false).</param>
/// <param name="threeDSRequestData">threeDSRequestData.</param>
public AuthenticationData(AttemptAuthenticationEnum? attemptAuthentication = default(AttemptAuthenticationEnum?), bool? authenticationOnly = false, ThreeDSRequestData threeDSRequestData = default(ThreeDSRequestData))
public AuthenticationData(AttemptAuthenticationEnum? attemptAuthentication = default(AttemptAuthenticationEnum?), bool? authenticationOnly = null, ThreeDSRequestData threeDSRequestData = default(ThreeDSRequestData))
{
this.AttemptAuthentication = attemptAuthentication;
this.AuthenticationOnly = authenticationOnly;
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Model/Checkout/BacsDirectDebitDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public enum TypeEnum
/// <param name="storedPaymentMethodId">This is the &#x60;recurringDetailReference&#x60; returned in the response when you created the token..</param>
/// <param name="transferInstrumentId">The unique identifier of your user&#39;s verified transfer instrument, which you can use to top up their balance accounts..</param>
/// <param name="type">**directdebit_GB** (default to TypeEnum.DirectdebitGB).</param>
public BacsDirectDebitDetails(string bankAccountNumber = default(string), string bankLocationId = default(string), string checkoutAttemptId = default(string), string holderName = default(string), string recurringDetailReference = default(string), string storedPaymentMethodId = default(string), string transferInstrumentId = default(string), TypeEnum? type = TypeEnum.DirectdebitGB)
public BacsDirectDebitDetails(string bankAccountNumber = default(string), string bankLocationId = default(string), string checkoutAttemptId = default(string), string holderName = default(string), string recurringDetailReference = default(string), string storedPaymentMethodId = default(string), string transferInstrumentId = default(string), TypeEnum? type = null)
{
this.BankAccountNumber = bankAccountNumber;
this.BankLocationId = bankLocationId;
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Model/Checkout/BalanceCheckRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ protected BalanceCheckRequest() { }
/// <param name="threeDSAuthenticationOnly">Required to trigger the [authentication-only flow](https://docs.adyen.com/online-payments/3d-secure/authentication-only/). If set to **true**, you will only perform the 3D Secure 2 authentication, and will not proceed to the payment authorization.Default: **false**. (default to false).</param>
/// <param name="totalsGroup">The reference value to aggregate sales totals in reporting. When not specified, the store field is used (if available)..</param>
/// <param name="trustedShopper">Set to true if the payment should be routed to a trusted MID..</param>
public BalanceCheckRequest(AccountInfo accountInfo = default(AccountInfo), Amount additionalAmount = default(Amount), Dictionary<string, string> additionalData = default(Dictionary<string, string>), Amount amount = default(Amount), ApplicationInfo applicationInfo = default(ApplicationInfo), Address billingAddress = default(Address), BrowserInfo browserInfo = default(BrowserInfo), int? captureDelayHours = default(int?), DateTime dateOfBirth = default(DateTime), ForexQuote dccQuote = default(ForexQuote), Address deliveryAddress = default(Address), DateTime deliveryDate = default(DateTime), string deviceFingerprint = default(string), int? fraudOffset = default(int?), Installments installments = default(Installments), Dictionary<string, string> localizedShopperStatement = default(Dictionary<string, string>), string mcc = default(string), string merchantAccount = default(string), string merchantOrderReference = default(string), MerchantRiskIndicator merchantRiskIndicator = default(MerchantRiskIndicator), Dictionary<string, string> metadata = default(Dictionary<string, string>), string orderReference = default(string), Dictionary<string, string> paymentMethod = default(Dictionary<string, string>), Recurring recurring = default(Recurring), RecurringProcessingModelEnum? recurringProcessingModel = default(RecurringProcessingModelEnum?), string reference = default(string), string selectedBrand = default(string), string selectedRecurringDetailReference = default(string), string sessionId = default(string), string shopperEmail = default(string), string shopperIP = default(string), ShopperInteractionEnum? shopperInteraction = default(ShopperInteractionEnum?), string shopperLocale = default(string), Name shopperName = default(Name), string shopperReference = default(string), string shopperStatement = default(string), string socialSecurityNumber = default(string), List<Split> splits = default(List<Split>), string store = default(string), string telephoneNumber = default(string), ThreeDS2RequestData threeDS2RequestData = default(ThreeDS2RequestData), bool? threeDSAuthenticationOnly = false, string totalsGroup = default(string), bool? trustedShopper = default(bool?))
public BalanceCheckRequest(AccountInfo accountInfo = default(AccountInfo), Amount additionalAmount = default(Amount), Dictionary<string, string> additionalData = default(Dictionary<string, string>), Amount amount = default(Amount), ApplicationInfo applicationInfo = default(ApplicationInfo), Address billingAddress = default(Address), BrowserInfo browserInfo = default(BrowserInfo), int? captureDelayHours = default(int?), DateTime dateOfBirth = default(DateTime), ForexQuote dccQuote = default(ForexQuote), Address deliveryAddress = default(Address), DateTime deliveryDate = default(DateTime), string deviceFingerprint = default(string), int? fraudOffset = default(int?), Installments installments = default(Installments), Dictionary<string, string> localizedShopperStatement = default(Dictionary<string, string>), string mcc = default(string), string merchantAccount = default(string), string merchantOrderReference = default(string), MerchantRiskIndicator merchantRiskIndicator = default(MerchantRiskIndicator), Dictionary<string, string> metadata = default(Dictionary<string, string>), string orderReference = default(string), Dictionary<string, string> paymentMethod = default(Dictionary<string, string>), Recurring recurring = default(Recurring), RecurringProcessingModelEnum? recurringProcessingModel = default(RecurringProcessingModelEnum?), string reference = default(string), string selectedBrand = default(string), string selectedRecurringDetailReference = default(string), string sessionId = default(string), string shopperEmail = default(string), string shopperIP = default(string), ShopperInteractionEnum? shopperInteraction = default(ShopperInteractionEnum?), string shopperLocale = default(string), Name shopperName = default(Name), string shopperReference = default(string), string shopperStatement = default(string), string socialSecurityNumber = default(string), List<Split> splits = default(List<Split>), string store = default(string), string telephoneNumber = default(string), ThreeDS2RequestData threeDS2RequestData = default(ThreeDS2RequestData), bool? threeDSAuthenticationOnly = null, string totalsGroup = default(string), bool? trustedShopper = default(bool?))
{
this.Amount = amount;
this.MerchantAccount = merchantAccount;
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Model/Checkout/BrowserInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected BrowserInfo() { }
/// <param name="screenWidth">The total width of the shopper&#39;s device screen in pixels. (required).</param>
/// <param name="timeZoneOffset">Time difference between UTC time and the shopper&#39;s browser local time, in minutes. (required).</param>
/// <param name="userAgent">The user agent value of the shopper&#39;s browser. (required).</param>
public BrowserInfo(string acceptHeader = default(string), int? colorDepth = default(int?), bool? javaEnabled = default(bool?), bool? javaScriptEnabled = true, string language = default(string), int? screenHeight = default(int?), int? screenWidth = default(int?), int? timeZoneOffset = default(int?), string userAgent = default(string))
public BrowserInfo(string acceptHeader = default(string), int? colorDepth = default(int?), bool? javaEnabled = default(bool?), bool? javaScriptEnabled = null, string language = default(string), int? screenHeight = default(int?), int? screenWidth = default(int?), int? timeZoneOffset = default(int?), string userAgent = default(string))
{
this.AcceptHeader = acceptHeader;
this.ColorDepth = colorDepth;
Expand Down
Loading
Loading