-
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.
Merge pull request #5 from Riskified/decision_endpoint
Decision endpoint
- Loading branch information
Showing
9 changed files
with
189 additions
and
2 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Newtonsoft.Json; | ||
using Riskified.SDK.Model.OrderElements; | ||
using Riskified.SDK.Utils; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Riskified.SDK.Model | ||
{ | ||
public class OrderDecision : AbstractOrder | ||
{ | ||
public OrderDecision(int merchantOrderId, DecisionDetails decision) | ||
: base(merchantOrderId) | ||
{ | ||
this.Decision = decision; | ||
} | ||
|
||
/// <summary> | ||
/// Validates the objects fields content | ||
/// </summary> | ||
/// <param name="isWeak">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 override void Validate(Validations validationType = Validations.Weak) | ||
{ | ||
base.Validate(validationType); | ||
InputValidators.ValidateObjectNotNull(this.Decision, "Decision"); | ||
this.Decision.Validate(validationType); | ||
} | ||
|
||
/// <summary> | ||
/// An object containing information about the decision the merchant made on the order. | ||
/// </summary> | ||
[JsonProperty(PropertyName = "decision")] | ||
public DecisionDetails Decision { 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,79 @@ | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Converters; | ||
using Riskified.SDK.Utils; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Riskified.SDK.Model.OrderElements | ||
{ | ||
|
||
public class DecisionDetails : IJsonSerializable | ||
{ | ||
|
||
public DecisionDetails(ExternalStatusType externalStatus, DateTime? decidedAt, string reason = null, float? amount = null, string currency = null, string notes = null) | ||
{ | ||
this.ExternalStatus = externalStatus; | ||
this.DecidedAt = decidedAt; | ||
|
||
// Optional fields | ||
this.Reason = reason; | ||
this.Amount = amount; | ||
this.Currency = currency; | ||
this.Notes = Notes; | ||
} | ||
|
||
public void Validate(Utils.Validations validationType = Validations.Weak) | ||
{ | ||
InputValidators.ValidateObjectNotNull(this.ExternalStatus, "External Status"); | ||
if(this.DecidedAt != null) | ||
{ | ||
InputValidators.ValidateDateNotDefault(DecidedAt.Value, "Decided At"); | ||
} | ||
|
||
if(Currency != null) | ||
{ | ||
InputValidators.ValidateCurrency(this.Currency); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// The external status, meaning the merchant decision on the order | ||
/// </summary> | ||
[JsonProperty(PropertyName = "external_status")] | ||
[JsonConverter(typeof(StringEnumConverter))] | ||
public ExternalStatusType ExternalStatus { get; set; } | ||
|
||
/// <summary> | ||
/// The date when the order was decided. | ||
/// </summary> | ||
[JsonProperty(PropertyName = "decided_at")] | ||
public DateTime? DecidedAt { get; set; } | ||
|
||
/// <summary> | ||
/// A reason for the decision. | ||
/// </summary> | ||
[JsonProperty(PropertyName = "reason")] | ||
public string Reason { get; set; } | ||
|
||
/// <summary> | ||
/// The amount the decision is relevant on. | ||
/// </summary> | ||
[JsonProperty(PropertyName = "amount")] | ||
public float? Amount { get; set; } | ||
|
||
/// <summary> | ||
/// The three letter code (ISO 4217) for the currency used for the payment. | ||
/// </summary> | ||
[JsonProperty(PropertyName = "currency")] | ||
public string Currency { get; set; } | ||
|
||
/// <summary> | ||
/// Free text for describing the decision. | ||
/// </summary> | ||
[JsonProperty(PropertyName = "notes")] | ||
public string Notes { 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,27 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Runtime.Serialization; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Riskified.SDK.Model | ||
{ | ||
public enum ExternalStatusType | ||
{ | ||
[EnumMember(Value = "approved")] | ||
Approved, | ||
[EnumMember(Value = "checkout")] | ||
Checkout, | ||
[EnumMember(Value = "cancelled")] | ||
Cancelled, | ||
[EnumMember(Value = "declined")] | ||
Declined, | ||
[EnumMember(Value = "declined_fraud")] | ||
DeclinedFraud, | ||
[EnumMember(Value = "chargedback_fraud")] | ||
ChargedbackFraud, | ||
[EnumMember(Value = "chargedback_not_fraud")] | ||
ChargedbackNotFraud | ||
} | ||
} |
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
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