Skip to content

Commit

Permalink
Added BnplType enum
Browse files Browse the repository at this point in the history
  • Loading branch information
pmaryska committed Sep 6, 2024
1 parent 5303f23 commit 77cd6c9
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 54 deletions.
48 changes: 48 additions & 0 deletions GoPay.net-sdk/src/Model/Payment/Bnpl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using GoPay.Common;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Globalization;


namespace GoPay.Model.Payments
{
public class Bnpl
{

[JsonProperty("bnplType")]
[JsonConverter(typeof(SafeJsonEnumStringConvertor), (int) BnplType.UNKNOWN)]
public BnplType bnplType { get; set; }

[JsonProperty("label")]
public Dictionary<CultureInfo, string> Label { get; set; }

[JsonProperty("image")]
public Image Image { get; set; }


public Bnpl AddLabel(CultureInfo locale, string label)
{
if (this.Label == null)
{
this.Label = new Dictionary<CultureInfo, string>();
}

this.Label.Add(locale, label);
return this;
}

public override string ToString()
{
Console.WriteLine("KONZOLE");
Console.WriteLine(bnplType);
return string.Format(
"BnplType [BnplType={0}, Label={1}, Image={2}]",
bnplType, Label, Image
);
}



}
}
44 changes: 5 additions & 39 deletions GoPay.net-sdk/src/Model/Payment/BnplType.cs
Original file line number Diff line number Diff line change
@@ -1,45 +1,11 @@
using GoPay.Common;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Globalization;



namespace GoPay.Model.Payments
{
public class BnplType
public enum BnplType
{
DEFERRED_PAYMENT,
PAY_IN_THREE,

[JsonProperty("bnplType")]
public string BnplCategory { get; set; }

[JsonProperty("label")]
public Dictionary<CultureInfo, string> Label { get; set; }

[JsonProperty("image")]
public Image Image { get; set; }


public BnplType AddLabel(CultureInfo locale, string label)
{
if (this.Label == null)
{
this.Label = new Dictionary<CultureInfo, string>();
}

this.Label.Add(locale, label);
return this;
}

public override string ToString()
{
return string.Format(
"BnplType [BnplType={0}, Label={1}, Image={2}]",
BnplCategory, Label, Image
);
}



UNKNOWN
}
}
6 changes: 3 additions & 3 deletions GoPay.net-sdk/src/Model/Payment/EnabledPaymentInstrument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class EnabledPaymentInstrument
public List<Swift> EnabledSwifts { get; set; }

[JsonProperty("enabledBnplTypes")]
public List<BnplType> EnabledBnplTypes { get; set; }
public List<Bnpl> EnabledBnplTypes { get; set; }


public EnabledPaymentInstrument AddLabel(CultureInfo locale, string label)
Expand Down Expand Up @@ -58,12 +58,12 @@ public EnabledPaymentInstrument AddEnabledSwift(Swift swift)
return this;
}

public EnabledPaymentInstrument AddEnabledBnplType(BnplType bnplType)
public EnabledPaymentInstrument AddEnabledBnplType(Bnpl bnplType)
{

if (this.EnabledBnplTypes == null)
{
this.EnabledBnplTypes = new List<BnplType>();
this.EnabledBnplTypes = new List<Bnpl>();
}

this.EnabledBnplTypes.Add(bnplType);
Expand Down
12 changes: 7 additions & 5 deletions GoPay.net-sdk/src/Model/Payment/Payer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections.Generic;
using Newtonsoft.Json.Converters;
using System.Xml.Linq;
using GoPay.Common;

namespace GoPay.Model.Payments
{
Expand All @@ -26,11 +27,12 @@ public class Payer
[JsonProperty("default_swift")]
public string DefaultSwift { get; set; }

[JsonProperty("allowed_bnpl_types")]
public IList<string> AllowedBnplTypes { get; set; }
[JsonProperty("allowed_bnpl_types", ItemConverterType = typeof(StringEnumConverter))]
public IList<BnplType> AllowedBnplTypes { get; set; }

[JsonProperty("default_bnpl_type")]
public string DefaultBnplType { get; set; }
[JsonProperty(PropertyName = "default_bnpl_type")]
[JsonConverter(typeof(SafeJsonEnumStringConvertor), (int) BnplType.UNKNOWN)]
public Nullable<BnplType> DefaultBnplType { get; set; }

[JsonProperty("contact")]
public PayerContact Contact { get; set; }
Expand Down Expand Up @@ -60,7 +62,7 @@ public Payer()
{
AllowedPaymentInstruments = new List<PaymentInstrument>();
AllowedSwifts = new List<string>();
AllowedBnplTypes = new List<string>();
AllowedBnplTypes = new List<BnplType>();
}

public override string ToString()
Expand Down
14 changes: 7 additions & 7 deletions GoPay.net-sdkTests/src/Tests/CreatePaymentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ public static BasePayment createBasePayment()

List<string> swifts = new List<string>();
swifts.Add("GIBACZPX");
swifts.Add("RZBCCZPP");
swifts.Add("RZBCCZPP");

/* List<string> allowedBnplTypes = new List<string>
{
"LATER",
"THIRDS"
}; */
/* List<BnplType> allowedBnplTypes = new List<BnplType>
{
BnplType.DEFERRED_PAYMENT,
BnplType.PAY_IN_THREE
}; */


BasePayment basePayment = new BasePayment()
Expand Down Expand Up @@ -70,7 +70,7 @@ public static BasePayment createBasePayment()
// AllowedBnplTypes = allowedBnplTypes,
DefaultPaymentInstrument = PaymentInstrument.BANK_ACCOUNT,
// DefaultPaymentInstrument = PaymentInstrument.TWISTO,
// DefaultBnplType = "LATER",
// DefaultBnplType = BnplType.DEFERRED_PAYMENT,
// PaymentInstrument = PaymentInstrument.BANK_ACCOUNT,
Contact = new PayerContact()
{
Expand Down

0 comments on commit 77cd6c9

Please sign in to comment.