From 22f82f6998c347743a6d6dc5cc8a625aa1457751 Mon Sep 17 00:00:00 2001 From: Omri Mosseri Date: Thu, 29 Oct 2015 15:58:35 +0200 Subject: [PATCH] Update the sample --- .../OrderTransmissionExample.cs | 43 +++++++++++++------ Riskified.SDK/Model/Order.cs | 2 +- Riskified.SDK/Model/OrderBase.cs | 3 -- .../Model/OrderElements/AddressInformation.cs | 2 +- .../Model/OrderElements/BasicAddress.cs | 2 +- 5 files changed, 34 insertions(+), 18 deletions(-) diff --git a/Riskified.SDK.Sample/OrderTransmissionExample.cs b/Riskified.SDK.Sample/OrderTransmissionExample.cs index b308387..7cd9547 100644 --- a/Riskified.SDK.Sample/OrderTransmissionExample.cs +++ b/Riskified.SDK.Sample/OrderTransmissionExample.cs @@ -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") @@ -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; } @@ -228,7 +229,7 @@ private static OrderCheckout GenerateOrderCheckout(string orderNum) ordersCount: 4, email: "test@example.com", 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[] @@ -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."); @@ -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") @@ -305,7 +306,7 @@ private static Order GenerateOrder(int orderNum) ordersCount: 4, email: "test@example.com", 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); @@ -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: "tester@exampler.com", @@ -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 [] {"a@a.com","b@b.com"}); return order; } @@ -396,7 +415,7 @@ private static Order PayPalGenerateOrder(int orderNum) ordersCount: 4, email: "test@example.com", 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 @@ -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; diff --git a/Riskified.SDK/Model/Order.cs b/Riskified.SDK/Model/Order.cs index 1496fa4..c051fb1 100644 --- a/Riskified.SDK/Model/Order.cs +++ b/Riskified.SDK/Model/Order.cs @@ -90,7 +90,7 @@ public Order(string merchantOrderId, AdditionalEmails = additionalEmails; VendorId = vendorId; VendorName = vendorName; - DecisionDetails = decisionDetails; + Decision = decisionDetails; } /// diff --git a/Riskified.SDK/Model/OrderBase.cs b/Riskified.SDK/Model/OrderBase.cs index e63795d..fd1d955 100644 --- a/Riskified.SDK/Model/OrderBase.cs +++ b/Riskified.SDK/Model/OrderBase.cs @@ -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; } } } diff --git a/Riskified.SDK/Model/OrderElements/AddressInformation.cs b/Riskified.SDK/Model/OrderElements/AddressInformation.cs index 07d5ea8..fd015c0 100644 --- a/Riskified.SDK/Model/OrderElements/AddressInformation.cs +++ b/Riskified.SDK/Model/OrderElements/AddressInformation.cs @@ -37,7 +37,7 @@ public AddressInformation(string firstName, string lastName, string address1, st /// /// Validation level to use on this model /// throws an exception if one of the parameters doesn't match the expected format - public void Validate(Validations validationType = Validations.Weak) + public override void Validate(Validations validationType = Validations.Weak) { base.Validate(validationType); diff --git a/Riskified.SDK/Model/OrderElements/BasicAddress.cs b/Riskified.SDK/Model/OrderElements/BasicAddress.cs index 9de26dd..51d8026 100644 --- a/Riskified.SDK/Model/OrderElements/BasicAddress.cs +++ b/Riskified.SDK/Model/OrderElements/BasicAddress.cs @@ -38,7 +38,7 @@ public BasicAddress(string address1 = null, string city = null, string country = /// /// Validation level to use on this model /// throws an exception if one of the parameters doesn't match the expected format - public void Validate(Validations validationType = Validations.Weak) + public virtual void Validate(Validations validationType = Validations.Weak) { // optional fields validations if(!string.IsNullOrEmpty(Phone))