Skip to content

Commit

Permalink
Add payment type enum to PaypalPaymentDetails, and serialise this pro…
Browse files Browse the repository at this point in the history
…perty on both PaypalPaymentDetails and CreditCardPaymentDetails as a string, in line with api docs.
  • Loading branch information
Kieran Gelders committed Nov 26, 2019
1 parent 27650ae commit 4d1160a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
11 changes: 6 additions & 5 deletions Riskified.SDK/Model/OrderElements/CreditCardPaymentDetails.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Riskified.SDK.Exceptions;
using Riskified.SDK.Model.OrderCheckoutElements;
using Riskified.SDK.Utils;
Expand All @@ -7,10 +8,6 @@ namespace Riskified.SDK.Model.OrderElements
{
public class CreditCardPaymentDetails : IPaymentDetails
{
public enum _type
{
credit_card, paypal
}

/// <summary>
/// The payment information for the order
Expand Down Expand Up @@ -96,7 +93,11 @@ public void Validate(Validations validationType = Validations.Weak)
public string Mid { get; set; }

[JsonProperty(PropertyName = "_type")]
public _type Type { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public PaymentDetailsType Type
{
get { return PaymentDetailsType.credit_card; }
}

[JsonProperty(PropertyName = "authentication_result")]
public AuthenticationResult AuthenticationResult { get; set; }
Expand Down
7 changes: 7 additions & 0 deletions Riskified.SDK/Model/OrderElements/PaymentDetailsType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Riskified.SDK.Model.OrderElements
{
public enum PaymentDetailsType
{
credit_card, paypal
}
}
7 changes: 7 additions & 0 deletions Riskified.SDK/Model/OrderElements/PaypalPaymentDetails.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Riskified.SDK.Exceptions;
using Riskified.SDK.Model.OrderCheckoutElements;
using Riskified.SDK.Utils;
Expand Down Expand Up @@ -69,5 +70,11 @@ public void Validate(Validations validationType = Validations.Weak)
[JsonProperty(PropertyName = "authentication_result")]
public AuthenticationResult AuthenticationResult { get; set; }

[JsonProperty(PropertyName = "_type")]
[JsonConverter(typeof(StringEnumConverter))]
public PaymentDetailsType Type
{
get { return PaymentDetailsType.paypal; }
}
}
}
7 changes: 3 additions & 4 deletions Riskified.SDK/Riskified.SDK.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<Compile Include="Model\OrderElements\IPaymentDetails.cs" />
<Compile Include="Model\OrderElements\NoChargeDetails.cs" />
<Compile Include="Model\OrderElements\Passenger.cs" />
<Compile Include="Model\OrderElements\PaymentDetailsType.cs" />
<Compile Include="Model\OrderElements\PaypalPaymentDetails.cs" />
<Compile Include="Model\OrderElements\ProductType.cs" />
<Compile Include="Model\OrderElements\Recipient.cs" />
Expand Down Expand Up @@ -143,9 +144,7 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Folder Include="Model\AccountActionElements\" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand All @@ -154,4 +153,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>

0 comments on commit 4d1160a

Please sign in to comment.