-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added client details and charge free amount
- Loading branch information
Omri Mosseri
committed
Dec 9, 2015
1 parent
ec47538
commit ab651b3
Showing
8 changed files
with
118 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]", | ||
|
@@ -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; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
Riskified.SDK/Model/OrderElements/ChargeFreePaymentDetails.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters