Skip to content

Commit

Permalink
+ Added new fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Diego Garcia committed Jul 12, 2023
1 parent 0b72a1e commit b5cef74
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions lib/PagSeguroClient.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Net;
using System.Net.Http;
using System.Reflection;
Expand Down Expand Up @@ -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; }

Expand All @@ -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
Expand Down Expand Up @@ -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; }

Expand Down Expand Up @@ -398,16 +415,22 @@ public async Task<PagSeguroPreApprovalPlanResponse> CreatePreApprovalPlan(PagSeg
content.Add(new KeyValuePair<string, string>("preApprovalName", preApproval.Name));
content.Add(new KeyValuePair<string, string>("preApprovalCharge", preApproval.ChargeText));
content.Add(new KeyValuePair<string, string>("preApprovalPeriod", preApproval.ChargePeriodText));
content.Add(new KeyValuePair<string, string>("preApprovalAmountPerPayment", preApproval.AmountPerPayment.ToString("0.00")));
content.Add(new KeyValuePair<string, string>("preApprovalAmountPerPayment", preApproval.AmountPerPayment.ToString("0.00", _enUsCulture)));

if (preApproval.TrialPeriodDuration > 0)
{
content.Add(new KeyValuePair<string, string>("preApprovalTrialPeriodDuration",
preApproval.TrialPeriodDuration.ToString()));
}

content.Add(new KeyValuePair<string, string>("preApprovalExpirationValue", preApproval.ExpirationValue.ToString()));
content.Add(new KeyValuePair<string, string>("preApprovalExpirationUnit", preApproval.ExpirationUnitText));
if (preApproval.ExpirationValue > 0)
{
content.Add(new KeyValuePair<string, string>("preApprovalExpirationValue",
preApproval.ExpirationValue.ToString()));
content.Add(new KeyValuePair<string, string>("preApprovalExpirationUnit",
preApproval.ExpirationUnitText));
}

content.Add(new KeyValuePair<string, string>("preApprovalDetails", preApproval.Details));
content.Add(new KeyValuePair<string, string>("receiverEmail", Email));

Expand Down Expand Up @@ -506,7 +529,7 @@ public async Task<PagSeguroPaymentResponse> RequestPreApprovalPayment(PagSeguroP
{
content.Add(new KeyValuePair<string, string>($"itemId{i+1}", preApprovalPaymentRequest.Items[i].Id));
content.Add(new KeyValuePair<string, string>($"itemDescription{i+1}", preApprovalPaymentRequest.Items[i].Description));
content.Add(new KeyValuePair<string, string>($"itemAmount{i+1}", preApprovalPaymentRequest.Items[i].Ammount.ToString("0.00")));
content.Add(new KeyValuePair<string, string>($"itemAmount{i+1}", preApprovalPaymentRequest.Items[i].Ammount.ToString("0.00", _enUsCulture)));
content.Add(new KeyValuePair<string, string>($"itemQuantity{i+1}", preApprovalPaymentRequest.Items[i].Quantity.ToString()));
}

Expand Down

0 comments on commit b5cef74

Please sign in to comment.