Skip to content

Commit

Permalink
Merge pull request #9 from Riskified/new_fields
Browse files Browse the repository at this point in the history
New fields
  • Loading branch information
ErezSela committed Oct 29, 2015
2 parents 3bd9a84 + 89affc5 commit ec47538
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 18 deletions.
43 changes: 31 additions & 12 deletions Riskified.SDK.Sample/OrderTransmissionExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public static void SendOrdersToRiskifiedExample()
{
new PartialRefundDetails(
refundId: "12345",
refundedAt: DateTime.Now,
refundedAt: DateTime.Now, // make sure to initialize DateTime with the correct timezone
amount: 5.3,
currency: "USD",
reason: "Customer partly refunded on shipping fees")
Expand Down Expand Up @@ -211,6 +211,7 @@ public static void SendOrdersToRiskifiedExample()

private static OrderDecision GenerateDecision(int p)
{
// make sure to initialize DateTime with the correct timezone
OrderDecision orderDecision = new OrderDecision(p, new DecisionDetails(ExternalStatusType.ChargebackFraud, DateTime.Now, "used proxy and stolen credit card."));
return orderDecision;
}
Expand All @@ -228,7 +229,7 @@ private static OrderCheckout GenerateOrderCheckout(string orderNum)
ordersCount: 4,
email: "[email protected]",
verifiedEmail: true,
createdAt: new DateTime(2013, 12, 8, 14, 12, 12),
createdAt: new DateTime(2013, 12, 8, 14, 12, 12, DateTimeKind.Local), // make sure to initialize DateTime with the correct timezone
notes: "No additional info");

var items = new[]
Expand All @@ -248,7 +249,7 @@ private static OrderCheckout GenerateOrderCheckout(string orderNum)
private static OrderCheckoutDenied GenerateOrderCheckoutDenied(int orderNum)
{
var authorizationError = new AuthorizationError(
createdAt: new DateTime(2013, 12, 8, 14, 12, 12),
createdAt: new DateTime(2013, 12, 8, 14, 12, 12, DateTimeKind.Local), // make sure to initialize DateTime with the correct timezone
errorCode: AuthorizationErrorCode.IncorrectNumber,
message: "credit card expired.");

Expand All @@ -266,7 +267,7 @@ private static OrderFulfillment GenerateFulfillment(int fulfillOrderId)
FulfillmentDetails[] fulfillmentList = new FulfillmentDetails[] {
new FulfillmentDetails(
fulfillmentId: "123",
createdAt: new DateTime(2013, 12, 8, 14, 12, 12),
createdAt: new DateTime(2013, 12, 8, 14, 12, 12, DateTimeKind.Local),
status: FulfillmentStatusCode.Success,
lineItems: new LineItem[] { new LineItem("Bag", 10.0, 1) },
trackingCompany: "TestCompany")
Expand Down Expand Up @@ -305,7 +306,7 @@ private static Order GenerateOrder(int orderNum)
ordersCount: 4,
email: "[email protected]",
verifiedEmail: true,
createdAt: new DateTime(2013, 12, 8, 14, 12, 12),
createdAt: new DateTime(2013, 12, 8, 14, 12, 12, DateTimeKind.Local), // make sure to initialize DateTime with the correct timezone
notes: "No additional info",
address: customerAddress);

Expand Down Expand Up @@ -359,11 +360,25 @@ private static Order GenerateOrder(int orderNum)
var items = new[]
{
new LineItem(title: "Bag",price: 55.44,quantityPurchased: 1,productId: 48484,sku: "1272727"),
new LineItem(title: "Monster", price: 22.3, quantityPurchased: 3, seller: new Seller(customer: customer,correspondence: 1, priceNegotiated: true, startingPrice: 120))
new LineItem(title: "Monster", price: 22.3, quantityPurchased: 3, seller: new Seller(customer: customer,correspondence: 1, priceNegotiated: true, startingPrice: 120)),
// Events Tickets Industry
new LineItem(title: "Concert",
price: 123,
quantityPurchased: 1,
category: "Singers",
subCategory: "Rock",
eventName: "Bon Jovy",
eventSectionName: "Section",
eventCountry: "USA",
eventCountryCode: "US",
latitude: 0,
longitude: 0)
};

var discountCodes = new[] { new DiscountCode(moneyDiscountSum: 7, code: "1") };

DecisionDetails decisionDetails = new DecisionDetails(ExternalStatusType.Approved, DateTime.Now); // make sure to initialize DateTime with the correct timezone

var order = new Order(
merchantOrderId: orderNum.ToString(),
email: "[email protected]",
Expand All @@ -377,11 +392,15 @@ private static Order GenerateOrder(int orderNum)
customerBrowserIp: "165.12.1.1",
currency: "USD",
totalPrice: 100.60,
createdAt: DateTime.Now,
updatedAt: DateTime.Now,
createdAt: DateTime.Now, // make sure to initialize DateTime with the correct timezone
updatedAt: DateTime.Now, // make sure to initialize DateTime with the correct timezone
discountCodes: discountCodes,
source: "web",
noChargeDetails: noChargeAmount);
noChargeDetails: noChargeAmount,
decisionDetails: decisionDetails,
vendorId: "2",
vendorName: "domestic",
additionalEmails: new [] {"[email protected]","[email protected]"});

return order;
}
Expand All @@ -396,7 +415,7 @@ private static Order PayPalGenerateOrder(int orderNum)
ordersCount: 4,
email: "[email protected]",
verifiedEmail: true,
createdAt: new DateTime(2013, 12, 8, 14, 12, 12),
createdAt: new DateTime(2013, 12, 8, 14, 12, 12, DateTimeKind.Local), // make sure to initialize DateTime with the correct timezone
notes: "No additional info");

// putting sample billing details
Expand Down Expand Up @@ -462,8 +481,8 @@ private static Order PayPalGenerateOrder(int orderNum)
customerBrowserIp: "165.12.1.1",
currency: "USD",
totalPrice: 100.60,
createdAt: DateTime.Now,
updatedAt: DateTime.Now,
createdAt: DateTime.Now, // make sure to initialize DateTime with the correct timezone
updatedAt: DateTime.Now, // make sure to initialize DateTime with the correct timezone
discountCodes: discountCodes);

return order;
Expand Down
2 changes: 1 addition & 1 deletion Riskified.SDK/Model/Order.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public Order(string merchantOrderId,
AdditionalEmails = additionalEmails;
VendorId = vendorId;
VendorName = vendorName;
DecisionDetails = decisionDetails;
Decision = decisionDetails;
}

/// <summary>
Expand Down
3 changes: 0 additions & 3 deletions Riskified.SDK/Model/OrderBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,5 @@ public OrderBase(string merchantOrderId) : base(merchantOrderId)

[JsonProperty(PropertyName = "additional_emails")]
public string[] AdditionalEmails { get; set; }

[JsonProperty(PropertyName = "decision")]
public DecisionDetails DecisionDetails { get; set; }
}
}
2 changes: 1 addition & 1 deletion Riskified.SDK/Model/OrderElements/AddressInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public AddressInformation(string firstName, string lastName, string address1, st
/// </summary>
/// <param name="validationType">Validation level to use on this model</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)
public override void Validate(Validations validationType = Validations.Weak)
{
base.Validate(validationType);

Expand Down
2 changes: 1 addition & 1 deletion Riskified.SDK/Model/OrderElements/BasicAddress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public BasicAddress(string address1 = null, string city = null, string country =
/// </summary>
/// <param name="validationType">Validation level to use on this model</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)
public virtual void Validate(Validations validationType = Validations.Weak)
{
// optional fields validations
if(!string.IsNullOrEmpty(Phone))
Expand Down

0 comments on commit ec47538

Please sign in to comment.