diff --git a/Sift/Schema/ComplexTypes/booking.json b/Sift/Schema/ComplexTypes/booking.json
index 3d3252f..74e969b 100644
--- a/Sift/Schema/ComplexTypes/booking.json
+++ b/Sift/Schema/ComplexTypes/booking.json
@@ -25,6 +25,12 @@
"$currency_code": {
"type": [ "string", "null" ]
},
+ "$exchange_rate": {
+ "oneOf": [
+ { "$ref": "exchange_rate.json" },
+ { "type": "null" }
+ ]
+ },
"$iata_carrier_code": {
"type": [ "string", "null" ]
},
diff --git a/Sift/Schema/ComplexTypes/discount.json b/Sift/Schema/ComplexTypes/discount.json
index 3cecbca..1c650d8 100644
--- a/Sift/Schema/ComplexTypes/discount.json
+++ b/Sift/Schema/ComplexTypes/discount.json
@@ -13,6 +13,12 @@
"$currency_code": {
"type": [ "string", "null" ]
},
+ "$exchange_rate": {
+ "oneOf": [
+ { "$ref": "exchange_rate.json" },
+ { "type": "null" }
+ ]
+ },
"$minimum_purchase_amount": {
"type": [ "integer", "null" ],
"format": "long"
diff --git a/Sift/Schema/ComplexTypes/exchange_rate.json b/Sift/Schema/ComplexTypes/exchange_rate.json
new file mode 100644
index 0000000..ac74dd3
--- /dev/null
+++ b/Sift/Schema/ComplexTypes/exchange_rate.json
@@ -0,0 +1,18 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema",
+ "title": "ExchangeRate",
+ "type": "object",
+ "required": [
+ "$quote_currency_code",
+ "$rate"
+ ],
+ "properties": {
+ "$quote_currency_code": {
+ "type": [ "string", "null" ]
+ },
+ "$rate": {
+ "type": [ "number", "null" ],
+ "format": "float"
+ }
+ }
+}
\ No newline at end of file
diff --git a/Sift/Schema/ComplexTypes/item.json b/Sift/Schema/ComplexTypes/item.json
index d8ef4da..901d86d 100644
--- a/Sift/Schema/ComplexTypes/item.json
+++ b/Sift/Schema/ComplexTypes/item.json
@@ -16,6 +16,12 @@
"$currency_code": {
"type": [ "string", "null" ]
},
+ "$exchange_rate": {
+ "oneOf": [
+ { "$ref": "exchange_rate.json" },
+ { "type": "null" }
+ ]
+ },
"$quantity": {
"type": [ "integer", "null" ]
},
diff --git a/Sift/Schema/create_order.json b/Sift/Schema/create_order.json
index 8bb5919..985bd32 100644
--- a/Sift/Schema/create_order.json
+++ b/Sift/Schema/create_order.json
@@ -27,6 +27,12 @@
"$currency_code": {
"type": [ "string", "null" ]
},
+ "$exchange_rate": {
+ "oneOf": [
+ { "$ref": "ComplexTypes/exchange_rate.json" },
+ { "type": "null" }
+ ]
+ },
"$billing_address": {
"oneOf": [
{ "$ref": "ComplexTypes/address.json" },
diff --git a/Sift/Schema/transaction.json b/Sift/Schema/transaction.json
index bceb3b9..d8155b8 100644
--- a/Sift/Schema/transaction.json
+++ b/Sift/Schema/transaction.json
@@ -30,6 +30,12 @@
"$currency_code": {
"type": [ "string", "null" ]
},
+ "$exchange_rate": {
+ "oneOf": [
+ { "$ref": "ComplexTypes/exchange_rate.json" },
+ { "type": "null" }
+ ]
+ },
"$order_id": {
"type": [ "string", "null" ]
},
diff --git a/Sift/Schema/update_order.json b/Sift/Schema/update_order.json
index 9ea3089..e55464b 100644
--- a/Sift/Schema/update_order.json
+++ b/Sift/Schema/update_order.json
@@ -27,6 +27,12 @@
"$currency_code": {
"type": [ "string", "null" ]
},
+ "$exchange_rate": {
+ "oneOf": [
+ { "$ref": "ComplexTypes/exchange_rate.json" },
+ { "type": "null" }
+ ]
+ },
"$billing_address": {
"oneOf": [
{ "$ref": "ComplexTypes/address.json" },
diff --git a/Sift/Schema/wager.json b/Sift/Schema/wager.json
index db88bd2..ff0a996 100644
--- a/Sift/Schema/wager.json
+++ b/Sift/Schema/wager.json
@@ -27,6 +27,12 @@
"$currency_code": {
"type": [ "string", "null" ]
},
+ "$exchange_rate": {
+ "oneOf": [
+ { "$ref": "ComplexTypes/exchange_rate.json" },
+ { "type": "null" }
+ ]
+ },
"$wager_event_type": {
"type": [ "string", "null" ]
},
diff --git a/Sift/Sift.csproj b/Sift/Sift.csproj
index 4c16f53..927b0ab 100644
--- a/Sift/Sift.csproj
+++ b/Sift/Sift.csproj
@@ -4,8 +4,8 @@
Sift
Sift
Sift
- 1.5.0
- Release 1.5.0
+ 1.6.0
+ Release 1.6.0
netstandard2.0
Sift
sift;siftscience;client;api;client;async
diff --git a/Test.Integration.Net7/EventsAPI/Order.cs b/Test.Integration.Net7/EventsAPI/Order.cs
index 002c57e..6d71395 100644
--- a/Test.Integration.Net7/EventsAPI/Order.cs
+++ b/Test.Integration.Net7/EventsAPI/Order.cs
@@ -56,7 +56,12 @@ private EventResponse CreateOrder(Client sift)
order_id = OrderId,
user_email = UserEmail,
amount = 115940000,
- currency_code = "USD",
+ currency_code = "EUR",
+ exchange_rate = new ExchangeRate
+ {
+ quote_currency_code = "USD",
+ rate = 1.14
+ },
billing_address = new Address()
{
name = "Bill Jones",
@@ -122,7 +127,12 @@ private EventResponse CreateOrder(Client sift)
item_id = ItemId,
product_title = "Microwavable Kettle Corn: Original Flavor",
price = 4990000,
- currency_code = "USD",
+ currency_code = "EUR",
+ exchange_rate = new ExchangeRate
+ {
+ quote_currency_code = "USD",
+ rate = 1.14
+ },
upc = "097564307560",
sku = "03586005",
isbn = "0446576220",
@@ -149,7 +159,12 @@ private EventResponse CreateOrder(Client sift)
discount = new Discount()
{
amount = 5000000,
- currency_code = "USD",
+ currency_code = "EUR",
+ exchange_rate = new ExchangeRate
+ {
+ quote_currency_code = "USD",
+ rate = 1.14
+ },
minimum_purchase_amount = 25000000
}
}
diff --git a/Test.Integration.Net7/EventsAPI/Transactions.cs b/Test.Integration.Net7/EventsAPI/Transactions.cs
index 42c90f9..14485d2 100644
--- a/Test.Integration.Net7/EventsAPI/Transactions.cs
+++ b/Test.Integration.Net7/EventsAPI/Transactions.cs
@@ -43,7 +43,12 @@ public void TransactionTest()
transaction_type = "$sale",
transaction_status = "$failure",
amount = 506790000,
- currency_code = "USD",
+ currency_code = "EUR",
+ exchange_rate = new ExchangeRate
+ {
+ quote_currency_code = "USD",
+ rate = 1.14
+ },
order_id = OrderId,
transaction_id = TransactionId,
billing_address = new Address()
diff --git a/Test.Integration.Net7/EventsAPI/Wagers.cs b/Test.Integration.Net7/EventsAPI/Wagers.cs
index 22ffa67..56cb0f3 100644
--- a/Test.Integration.Net7/EventsAPI/Wagers.cs
+++ b/Test.Integration.Net7/EventsAPI/Wagers.cs
@@ -34,7 +34,12 @@ public void WagerTest()
wager_type = "$parlay",
wager_status = "$accept",
amount = 5000,
- currency_code = "USD",
+ currency_code = "EUR",
+ exchange_rate = new ExchangeRate
+ {
+ quote_currency_code = "USD",
+ rate = 1.14
+ },
minimum_wager_amount = 100L,
wager_event_type = "NBA",
wager_event_name = "Bulls-Lakers",
diff --git a/Test.Integration.NetFx48/EventsAPI/Order.cs b/Test.Integration.NetFx48/EventsAPI/Order.cs
index 75d8622..2b7ef68 100644
--- a/Test.Integration.NetFx48/EventsAPI/Order.cs
+++ b/Test.Integration.NetFx48/EventsAPI/Order.cs
@@ -40,7 +40,12 @@ public void CreateOrder()
order_id = OrderId,
user_email = UserEmail,
amount = 115940000,
- currency_code = "USD",
+ currency_code = "EUR",
+ exchange_rate = new ExchangeRate
+ {
+ quote_currency_code = "USD",
+ rate = 1.14
+ },
billing_address = new Address()
{
name = "Bill Jones",
@@ -106,7 +111,12 @@ public void CreateOrder()
item_id = ItemId,
product_title = "Microwavable Kettle Corn: Original Flavor",
price = 4990000,
- currency_code = "USD",
+ currency_code = "EUR",
+ exchange_rate = new ExchangeRate
+ {
+ quote_currency_code = "USD",
+ rate = 1.14
+ },
upc = "097564307560",
sku = "03586005",
isbn = "0446576220",
@@ -133,7 +143,12 @@ public void CreateOrder()
discount = new Discount()
{
amount = 5000000,
- currency_code = "USD",
+ currency_code = "EUR",
+ exchange_rate = new ExchangeRate
+ {
+ quote_currency_code = "USD",
+ rate = 1.14
+ },
minimum_purchase_amount = 25000000
}
}
diff --git a/Test.Integration.NetFx48/EventsAPI/Transactions.cs b/Test.Integration.NetFx48/EventsAPI/Transactions.cs
index 1d4bcc7..43647c2 100644
--- a/Test.Integration.NetFx48/EventsAPI/Transactions.cs
+++ b/Test.Integration.NetFx48/EventsAPI/Transactions.cs
@@ -39,7 +39,12 @@ public void TransactionTest()
transaction_type = "$sale",
transaction_status = "$failure",
amount = 506790000,
- currency_code = "USD",
+ currency_code = "EUR",
+ exchange_rate = new ExchangeRate
+ {
+ quote_currency_code = "USD",
+ rate = 1.14
+ },
order_id = OrderId,
transaction_id = TransactionId,
billing_address = new Address()
diff --git a/Test.Integration.NetFx48/EventsAPI/Wagers.cs b/Test.Integration.NetFx48/EventsAPI/Wagers.cs
index a9cff6d..013ded8 100644
--- a/Test.Integration.NetFx48/EventsAPI/Wagers.cs
+++ b/Test.Integration.NetFx48/EventsAPI/Wagers.cs
@@ -34,7 +34,12 @@ public void WagerTest()
wager_type = "$parlay",
wager_status = "$accept",
amount = 5000,
- currency_code = "USD",
+ currency_code = "EUR",
+ exchange_rate = new ExchangeRate
+ {
+ quote_currency_code = "USD",
+ rate = 1.14
+ },
minimum_wager_amount = 100L,
wager_event_type = "NBA",
wager_event_name = "Bulls-Lakers",
diff --git a/Test/Test.cs b/Test/Test.cs
index 8d31f0b..3546cfc 100644
--- a/Test/Test.cs
+++ b/Test/Test.cs
@@ -2763,7 +2763,12 @@ public void TestWagerEvent()
wager_type = "$parlay",
wager_status = "$accept",
amount = 5000L,
- currency_code = "USD",
+ currency_code = "EUR",
+ exchange_rate = new ExchangeRate
+ {
+ quote_currency_code = "USD",
+ rate = 1.14
+ },
wager_event_type = "NFL",
wager_event_name = "Example Game",
wager_event_id = "event456",
@@ -2777,7 +2782,11 @@ public void TestWagerEvent()
"\"$wager_type\":\"$parlay\"," +
"\"$wager_status\":\"$accept\"," +
"\"$amount\":5000," +
- "\"$currency_code\":\"USD\"," +
+ "\"$currency_code\":\"EUR\"," +
+ "\"$exchange_rate\":{" +
+ "\"$quote_currency_code\":\"USD\"," +
+ "\"$rate\":1.14" +
+ "}," +
"\"$wager_event_type\":\"NFL\"," +
"\"$wager_event_name\":\"Example Game\"," +
"\"$wager_event_id\":\"event456\"," +
@@ -2801,6 +2810,151 @@ public void TestWagerEvent()
Assert.Equal("https://api.sift.com/v205/events?abuse_types=legacy,payment_abuse&return_score=true",
Uri.UnescapeDataString(eventRequest.Request.RequestUri!.ToString()));
}
+
+ [Fact]
+ public void TestTransactionEventWithExchangeRate()
+ {
+ //Please provide the valid session id in place of 'sessionId'
+ var sessionId = "sessionId";
+ var transaction = new Transaction
+ {
+ user_id = "test_dotnet_transaction_event",
+ amount = 100000000L,
+ currency_code = "EUR",
+ session_id = sessionId,
+ transaction_type = "$deposit",
+ transaction_status = "$failure",
+ exchange_rate = new ExchangeRate
+ {
+ quote_currency_code = "USD",
+ rate = 1.14
+ },
+ };
+
+ Assert.Equal("{" +
+ "\"$type\":\"$transaction\"," +
+ "\"$user_id\":\"test_dotnet_transaction_event\"," +
+ "\"$session_id\":\"sessionId\"," +
+ "\"$transaction_type\":\"$deposit\"," +
+ "\"$transaction_status\":\"$failure\"," +
+ "\"$amount\":100000000," +
+ "\"$currency_code\":\"EUR\"," +
+ "\"$exchange_rate\":{" +
+ "\"$quote_currency_code\":\"USD\"," +
+ "\"$rate\":1.14" +
+ "}" +
+ "}", transaction.ToJson());
+
+ EventRequest eventRequest = new EventRequest
+ {
+ Event = transaction
+ };
+
+ Assert.Equal("https://api.sift.com/v205/events", eventRequest.Request.RequestUri!.ToString());
+
+ eventRequest = new EventRequest
+ {
+ Event = transaction,
+ AbuseTypes = { "legacy", "payment_abuse" },
+ ReturnScore = true
+ };
+
+ Assert.Equal("https://api.sift.com/v205/events?abuse_types=legacy,payment_abuse&return_score=true",
+ Uri.UnescapeDataString(eventRequest.Request.RequestUri!.ToString()));
+ }
+
+ [Fact]
+ public void TestCreateOrderWithExchangeRate()
+ {
+ //Please provide the valid session id in place of 'sessionId'
+ var sessionId = "sessionId";
+ var createOrder = new CreateOrder
+ {
+ user_id = "test_dotnet_order_with_all_exchange_rate_fields",
+ order_id = "oid",
+ amount = 1000000000000L,
+ currency_code = "EUR",
+ session_id = sessionId,
+ user_email = "bill@gmail.com",
+ bookings = new ObservableCollection()
+ {
+ new Booking()
+ {
+ booking_type = "$flight",
+ title = "SFO - LAS, 2 Adults",
+ start_time= 2038412903,
+ end_time= 2038412903,
+ price = 49900000,
+ currency_code = "EUR",
+ exchange_rate = new ExchangeRate
+ {
+ quote_currency_code = "USD",
+ rate = 1.14
+ }
+ }
+ },
+ promotions = new ObservableCollection()
+ {
+ new Promotion()
+ {
+ discount = new Discount()
+ {
+ percentage_off = 0.2,
+ amount = 5000000,
+ currency_code = "EUR",
+ exchange_rate = new ExchangeRate
+ {
+ quote_currency_code = "USD",
+ rate = 1.14
+ }
+ }
+ }
+ },
+ items = new ObservableCollection- ()
+ {
+ new Item()
+ {
+ item_id = "12344321",
+ price = 4990000,
+ currency_code = "EUR",
+ exchange_rate = new ExchangeRate
+ {
+ quote_currency_code = "USD",
+ rate = 1.14
+ }
+ }
+ },
+ };
+
+ // Augment with custom fields
+ Assert.Equal("{\"$type\":\"$create_order\",\"$user_id\":\"test_dotnet_order_with_all_exchange_rate_fields\"," +
+ "\"$session_id\":\"sessionId\",\"$order_id\":\"oid\",\"$user_email\":\"bill@gmail.com\",\"$amount\":1000000000000," +
+ "\"$currency_code\":\"EUR\",\"$items\":[{\"$item_id\":\"12344321\",\"$price\":4990000,\"$currency_code\":\"EUR\"," +
+ "\"$exchange_rate\":{\"$quote_currency_code\":\"USD\",\"$rate\":1.14}}],\"$bookings\":[{\"$booking_type\":\"$flight\"," +
+ "\"$title\":\"SFO - LAS, 2 Adults\",\"$start_time\":2038412903,\"$end_time\":2038412903,\"$price\":49900000," +
+ "\"$currency_code\":\"EUR\",\"$exchange_rate\":{\"$quote_currency_code\":\"USD\",\"$rate\":1.14}}],\"$promotions\":" +
+ "[{\"$discount\":{\"$percentage_off\":0.2,\"$amount\":5000000,\"$currency_code\":\"EUR\",\"$exchange_rate\":" +
+ "{\"$quote_currency_code\":\"USD\",\"$rate\":1.14}}}]}", createOrder.ToJson());
+
+
+ EventRequest eventRequest = new EventRequest
+ {
+ Event = createOrder
+ };
+
+ Assert.Equal("https://api.sift.com/v205/events", eventRequest.Request.RequestUri!.ToString());
+
+ eventRequest = new EventRequest
+ {
+ Event = createOrder,
+ AbuseTypes = { "legacy", "payment_abuse" },
+ ReturnScore = true,
+ ReturnRouteInfo = true
+ };
+
+ Assert.Equal("https://api.sift.com/v205/events?abuse_types=legacy,payment_abuse&return_score=true&return_route_info=true",
+ Uri.UnescapeDataString(eventRequest.Request.RequestUri!.ToString()));
+ }
}
}