Skip to content

Commit

Permalink
Added client details and charge free amount
Browse files Browse the repository at this point in the history
  • Loading branch information
Omri Mosseri committed Dec 9, 2015
1 parent ec47538 commit ab651b3
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 4 deletions.
17 changes: 16 additions & 1 deletion Riskified.SDK.Sample/OrderTransmissionExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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: "[email protected]",
Expand All @@ -400,7 +413,9 @@ private static Order GenerateOrder(int orderNum)
decisionDetails: decisionDetails,
vendorId: "2",
vendorName: "domestic",
additionalEmails: new [] {"[email protected]","[email protected]"});
additionalEmails: new [] {"[email protected]","[email protected]"},
chargeFreePaymentDetails: chargeFreePayments,
clientDetails: clientDetails);

return order;
}
Expand Down
8 changes: 7 additions & 1 deletion Riskified.SDK/Model/Order.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public class Order : OrderBase
/// <param name="fulfillmentStatus">The fulfillment status of the order</param>
/// <param name="source">The source of the order</param>
/// <param name="noChargeDetails">No charge sums - including all payments made for this order in giftcards, cash, checks or other non chargebackable payment methods</param>
/// <param name="ClientDetails">Technical information regarding the customer's browsing session</param>
/// <param name="chargeFreePaymentDetails">Payment sums made using non-chargebackable methods and should be omitted from the Chargeback gurantee sum and Riskified fee</param>
public Order(string merchantOrderId,
string email,
Customer customer,
Expand All @@ -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;
Expand Down Expand Up @@ -91,6 +95,8 @@ public Order(string merchantOrderId,
VendorId = vendorId;
VendorName = vendorName;
Decision = decisionDetails;
ClientDetails = clientDetails;
ChargeFreePaymentDetails = chargeFreePaymentDetails;
}

/// <summary>
Expand Down
6 changes: 6 additions & 0 deletions Riskified.SDK/Model/OrderBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
}
37 changes: 37 additions & 0 deletions Riskified.SDK/Model/OrderElements/ChargeFreePaymentDetails.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Newtonsoft.Json;
using Riskified.SDK.Exceptions;
using Riskified.SDK.Utils;

namespace Riskified.SDK.Model.OrderElements
{
public class ChargeFreePaymentDetails : IJsonSerializable
{
/// <summary>
/// Creates a new Non-chargebackable payment sum
/// </summary>
/// <param name="gateway">The gateway used to pay this payment part</param>
/// <param name="amount">The sum payed using this method</param>
public ChargeFreePaymentDetails(string gateway, double amount)
{
Gateway = gateway;
Amount = amount;
}

/// <summary>
/// Validates the objects fields content
/// </summary>
/// <param name="validationType">Should use weak validations or strong</param>
/// <exception cref="OrderFieldBadFormatException">throws an exception if one of the parameters doesn't match the expected format</exception>
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; }
}
}
34 changes: 34 additions & 0 deletions Riskified.SDK/Model/OrderElements/ClientDetails.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Technical information regarding the customer's browsing session
/// </summary>
/// <param name="accept_language">List of two-letter language codes sent from the client</param>
/// <param name="user_agent">The full User-Agent sent from the client</param>
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; }
}
}
14 changes: 14 additions & 0 deletions Riskified.SDK/Model/OrderElements/LineItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ public LineItem(string title,
EventCity = eventCity;
Latitude = latitude;
Longitude = longitude;

// Digital Goods (gift cards)
SenderName = sender_name;
DisplayName = display_name;
}

/// <summary>
Expand Down Expand Up @@ -196,6 +200,16 @@ public void Validate(Validations validationType = Validations.Weak)
[JsonConverter(typeof(StringEnumConverter))]
public DeliveredToType DeliveredTo { get; set; }

/// <summary>
/// The digital good's (giftcard) sender name.
/// </summary>
[JsonProperty(PropertyName = "sender_name")]
public string SenderName { get; set; }

/// <summary>
/// The digital good's (giftcard) display name.
/// </summary>
[JsonProperty(PropertyName = "display_name")]
public string DisplayName { get; set; }
}
}
4 changes: 2 additions & 2 deletions Riskified.SDK/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
2 changes: 2 additions & 0 deletions Riskified.SDK/Riskified.SDK.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Exceptions\RiskifiedAuthenticationException.cs" />
<Compile Include="Model\OrderElements\ChargeFreePaymentDetails.cs" />
<Compile Include="Model\OrderElements\ClientDetails.cs" />
<Compile Include="Model\OrderElements\DeliveredToType.cs" />
<Compile Include="Model\OrderElements\ExternalStatusType.cs" />
<Compile Include="Model\IJsonSerializable.cs" />
Expand Down

0 comments on commit ab651b3

Please sign in to comment.