From b5cef74c6079d36f6f3b3c8743c80dc7719cb27d Mon Sep 17 00:00:00 2001 From: Diego Garcia Date: Wed, 12 Jul 2023 20:46:24 -0300 Subject: [PATCH] + Added new fields --- lib/PagSeguroClient.cs | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/lib/PagSeguroClient.cs b/lib/PagSeguroClient.cs index f419909..4d071d8 100644 --- a/lib/PagSeguroClient.cs +++ b/lib/PagSeguroClient.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Net; using System.Net.Http; using System.Reflection; @@ -70,6 +71,8 @@ public string ChargePeriodText } public Double AmountPerPayment { get; set; } + + public Double MembershipFee { get; set; } public int TrialPeriodDuration { get; set; } public int ExpirationValue { get; set; } @@ -90,7 +93,19 @@ public string ExpirationUnitText public string Details { get; set; } - + + public Double MaxAmountPerPeriod { get; set; } + public Double MaxAmountPerPayment { get; set; } + public Double MaxTotalAmount { get; set; } + public Double MaxPaymentsPerPeriod { get; set; } + public DateTime InitialDate { get; set; } + public DateTime FinalDate { get; set; } + public string DayOfYear { get; set; } + public string DayOfMonth { get; set; } + public string DayOfWeek { get; set; } + + public string CancelUrl { get; set; } + public int MaxUses { get; set; } } public class PagSeguroPreApprovalPlanResponse @@ -293,6 +308,8 @@ public PagSeguroPreApprovalPayment() public class PagSeguroClient { + // always use dot separator for doubles + private CultureInfo _enUsCulture = CultureInfo.GetCultureInfo("en-US"); private string Email { get; set; } private string Token { get; set; } @@ -398,7 +415,7 @@ public async Task CreatePreApprovalPlan(PagSeg content.Add(new KeyValuePair("preApprovalName", preApproval.Name)); content.Add(new KeyValuePair("preApprovalCharge", preApproval.ChargeText)); content.Add(new KeyValuePair("preApprovalPeriod", preApproval.ChargePeriodText)); - content.Add(new KeyValuePair("preApprovalAmountPerPayment", preApproval.AmountPerPayment.ToString("0.00"))); + content.Add(new KeyValuePair("preApprovalAmountPerPayment", preApproval.AmountPerPayment.ToString("0.00", _enUsCulture))); if (preApproval.TrialPeriodDuration > 0) { @@ -406,8 +423,14 @@ public async Task CreatePreApprovalPlan(PagSeg preApproval.TrialPeriodDuration.ToString())); } - content.Add(new KeyValuePair("preApprovalExpirationValue", preApproval.ExpirationValue.ToString())); - content.Add(new KeyValuePair("preApprovalExpirationUnit", preApproval.ExpirationUnitText)); + if (preApproval.ExpirationValue > 0) + { + content.Add(new KeyValuePair("preApprovalExpirationValue", + preApproval.ExpirationValue.ToString())); + content.Add(new KeyValuePair("preApprovalExpirationUnit", + preApproval.ExpirationUnitText)); + } + content.Add(new KeyValuePair("preApprovalDetails", preApproval.Details)); content.Add(new KeyValuePair("receiverEmail", Email)); @@ -506,7 +529,7 @@ public async Task RequestPreApprovalPayment(PagSeguroP { content.Add(new KeyValuePair($"itemId{i+1}", preApprovalPaymentRequest.Items[i].Id)); content.Add(new KeyValuePair($"itemDescription{i+1}", preApprovalPaymentRequest.Items[i].Description)); - content.Add(new KeyValuePair($"itemAmount{i+1}", preApprovalPaymentRequest.Items[i].Ammount.ToString("0.00"))); + content.Add(new KeyValuePair($"itemAmount{i+1}", preApprovalPaymentRequest.Items[i].Ammount.ToString("0.00", _enUsCulture))); content.Add(new KeyValuePair($"itemQuantity{i+1}", preApprovalPaymentRequest.Items[i].Quantity.ToString())); }