diff --git a/Riskified.SDK.Sample/OrderTransmissionExample.cs b/Riskified.SDK.Sample/OrderTransmissionExample.cs index 7cd9547..c3a6a14 100644 --- a/Riskified.SDK.Sample/OrderTransmissionExample.cs +++ b/Riskified.SDK.Sample/OrderTransmissionExample.cs @@ -379,6 +379,19 @@ private static Order GenerateOrder(int orderNum) DecisionDetails decisionDetails = new DecisionDetails(ExternalStatusType.Approved, DateTime.Now); // make sure to initialize DateTime with the correct timezone + // This is an example for an order with charge free sums (e.g. gift card payment) + var chargeFreePayments = new ChargeFreePaymentDetails( + gateway: "giftcard", + amount: 45 + ); + + // This is an example for client details section + var clientDetails = new ClientDetails( + accept_language: "en-CA", + user_agent: "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)" + ); + + var order = new Order( merchantOrderId: orderNum.ToString(), email: "tester@exampler.com", @@ -400,7 +413,9 @@ private static Order GenerateOrder(int orderNum) decisionDetails: decisionDetails, vendorId: "2", vendorName: "domestic", - additionalEmails: new [] {"a@a.com","b@b.com"}); + additionalEmails: new [] {"a@a.com","b@b.com"}, + chargeFreePaymentDetails: chargeFreePayments, + clientDetails: clientDetails); return order; } diff --git a/Riskified.SDK/Model/Order.cs b/Riskified.SDK/Model/Order.cs index c051fb1..e982e08 100644 --- a/Riskified.SDK/Model/Order.cs +++ b/Riskified.SDK/Model/Order.cs @@ -35,6 +35,8 @@ public class Order : OrderBase /// The fulfillment status of the order /// The source of the order /// No charge sums - including all payments made for this order in giftcards, cash, checks or other non chargebackable payment methods + /// Technical information regarding the customer's browsing session + /// Payment sums made using non-chargebackable methods and should be omitted from the Chargeback gurantee sum and Riskified fee public Order(string merchantOrderId, string email, Customer customer, @@ -61,7 +63,9 @@ public Order(string merchantOrderId, string[] additionalEmails = null, string vendorId = null, string vendorName = null, - DecisionDetails decisionDetails = null) : base(merchantOrderId) + DecisionDetails decisionDetails = null, + ClientDetails clientDetails = null, + ChargeFreePaymentDetails chargeFreePaymentDetails = null) : base(merchantOrderId) { LineItems = lineItems; ShippingLines = shippingLines; @@ -91,6 +95,8 @@ public Order(string merchantOrderId, VendorId = vendorId; VendorName = vendorName; Decision = decisionDetails; + ClientDetails = clientDetails; + ChargeFreePaymentDetails = chargeFreePaymentDetails; } /// diff --git a/Riskified.SDK/Model/OrderBase.cs b/Riskified.SDK/Model/OrderBase.cs index fd1d955..ac9904b 100644 --- a/Riskified.SDK/Model/OrderBase.cs +++ b/Riskified.SDK/Model/OrderBase.cs @@ -153,5 +153,11 @@ public OrderBase(string merchantOrderId) : base(merchantOrderId) [JsonProperty(PropertyName = "additional_emails")] public string[] AdditionalEmails { get; set; } + + [JsonProperty(PropertyName = "client_details")] + public ClientDetails ClientDetails { get; set; } + + [JsonProperty(PropertyName = "charge_free_payment_details")] + public ChargeFreePaymentDetails ChargeFreePaymentDetails { get; set; } } } diff --git a/Riskified.SDK/Model/OrderElements/ChargeFreePaymentDetails.cs b/Riskified.SDK/Model/OrderElements/ChargeFreePaymentDetails.cs new file mode 100644 index 0000000..755dea0 --- /dev/null +++ b/Riskified.SDK/Model/OrderElements/ChargeFreePaymentDetails.cs @@ -0,0 +1,37 @@ +using Newtonsoft.Json; +using Riskified.SDK.Exceptions; +using Riskified.SDK.Utils; + +namespace Riskified.SDK.Model.OrderElements +{ + public class ChargeFreePaymentDetails : IJsonSerializable + { + /// + /// Creates a new Non-chargebackable payment sum + /// + /// The gateway used to pay this payment part + /// The sum payed using this method + public ChargeFreePaymentDetails(string gateway, double amount) + { + Gateway = gateway; + Amount = amount; + } + + /// + /// Validates the objects fields content + /// + /// Should use weak validations or strong + /// throws an exception if one of the parameters doesn't match the expected format + public void Validate(Validations validationType = Validations.Weak) + { + InputValidators.ValidateValuedString(Gateway, "Gateway"); + InputValidators.ValidateZeroOrPositiveValue(Amount, "Amount"); + } + + [JsonProperty(PropertyName = "gateway")] + public string Gateway { get; set; } + + [JsonProperty(PropertyName = "amount")] + public double Amount { get; set; } + } +} diff --git a/Riskified.SDK/Model/OrderElements/ClientDetails.cs b/Riskified.SDK/Model/OrderElements/ClientDetails.cs new file mode 100644 index 0000000..cf1c059 --- /dev/null +++ b/Riskified.SDK/Model/OrderElements/ClientDetails.cs @@ -0,0 +1,34 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Riskified.SDK.Utils; +using System; +using System.Collections.Generic; + +namespace Riskified.SDK.Model.OrderElements +{ + public class ClientDetails : IJsonSerializable + { + /// + /// Technical information regarding the customer's browsing session + /// + /// List of two-letter language codes sent from the client + /// The full User-Agent sent from the client + public ClientDetails(string accept_language = null, + string user_agent = null) + { + this.AcceptLanguage = accept_language; + this.UserAgent = user_agent; + } + + public void Validate(Utils.Validations validationType = Validations.Weak) + { + return; + } + + [JsonProperty(PropertyName = "accept_language")] + public string AcceptLanguage { get; set; } + + [JsonProperty(PropertyName = "user_agent")] + public string UserAgent { get; set; } + } +} diff --git a/Riskified.SDK/Model/OrderElements/LineItem.cs b/Riskified.SDK/Model/OrderElements/LineItem.cs index 497148d..b44f781 100644 --- a/Riskified.SDK/Model/OrderElements/LineItem.cs +++ b/Riskified.SDK/Model/OrderElements/LineItem.cs @@ -62,6 +62,10 @@ public LineItem(string title, EventCity = eventCity; Latitude = latitude; Longitude = longitude; + + // Digital Goods (gift cards) + SenderName = sender_name; + DisplayName = display_name; } /// @@ -196,6 +200,16 @@ public void Validate(Validations validationType = Validations.Weak) [JsonConverter(typeof(StringEnumConverter))] public DeliveredToType DeliveredTo { get; set; } + /// + /// The digital good's (giftcard) sender name. + /// + [JsonProperty(PropertyName = "sender_name")] + public string SenderName { get; set; } + /// + /// The digital good's (giftcard) display name. + /// + [JsonProperty(PropertyName = "display_name")] + public string DisplayName { get; set; } } } diff --git a/Riskified.SDK/Properties/AssemblyInfo.cs b/Riskified.SDK/Properties/AssemblyInfo.cs index b30f6f2..55b80f3 100644 --- a/Riskified.SDK/Properties/AssemblyInfo.cs +++ b/Riskified.SDK/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.0.4.0")] -[assembly: AssemblyFileVersion("2.0.4.0")] +[assembly: AssemblyVersion("2.0.4.1")] +[assembly: AssemblyFileVersion("2.0.4.1")] diff --git a/Riskified.SDK/Riskified.SDK.csproj b/Riskified.SDK/Riskified.SDK.csproj index 1ec7a49..391a2ef 100644 --- a/Riskified.SDK/Riskified.SDK.csproj +++ b/Riskified.SDK/Riskified.SDK.csproj @@ -49,6 +49,8 @@ + +