diff --git a/README.md b/README.md index bdc7efe..80244e8 100644 --- a/README.md +++ b/README.md @@ -313,7 +313,8 @@ The official Sift .NET client, supporting .NET Standard 2.0+ user_email = "billjones1@example.com", verification_phone_number = "+123456789012", amount = 115940000, - currency_code = "USD", + currency_code = "CAD", + amount_usd = 100940000, billing_address = new Address() { name = "Bill Jones", @@ -332,7 +333,10 @@ The official Sift .NET client, supporting .NET Standard 2.0+ payment_type = "$credit_card", payment_gateway = "$braintree", card_bin = "542486", - card_last4 = "4444" + card_last4 = "4444", + card_bin_country = "US", + card_brand = "visa", + card_type = "gold" }, new PaymentMethod() { @@ -381,7 +385,8 @@ The official Sift .NET client, supporting .NET Standard 2.0+ item_id = "12344321", product_title = "Microwavable Kettle Corn: Original Flavor", price = 4990000, - currency_code = "USD", + currency_code = "CAD", + price_usd = 4500000 upc = "097564307560", sku = "03586005", isbn = "0446576220", @@ -408,7 +413,8 @@ The official Sift .NET client, supporting .NET Standard 2.0+ discount = new Discount() { amount = 5000000, - currency_code = "USD", + currency_code = "CAD", + amount_usd = 4700000 minimum_purchase_amount = 25000000 } } @@ -444,7 +450,8 @@ The official Sift .NET client, supporting .NET Standard 2.0+ user_email = "billjones1@example.com", verification_phone_number = "+123456789012", amount = 115940000, - currency_code = "USD", + currency_code = "CAD", + amount_usd = 100940000, billing_address = new Address() { name = "Bill Jones", @@ -463,7 +470,10 @@ The official Sift .NET client, supporting .NET Standard 2.0+ payment_type = "$credit_card", payment_gateway = "$braintree", card_bin = "542486", - card_last4 = "4444" + card_last4 = "4444", + card_bin_country = "US", + card_brand = "visa", + card_type = "gold" }, new PaymentMethod() { @@ -512,7 +522,8 @@ The official Sift .NET client, supporting .NET Standard 2.0+ item_id = "12344321", product_title = "Microwavable Kettle Corn: Original Flavor", price = 4990000, - currency_code = "USD", + currency_code = "CAD", + price_usd = 4500000 upc = "097564307560", sku = "03586005", isbn = "0446576220", @@ -539,7 +550,8 @@ The official Sift .NET client, supporting .NET Standard 2.0+ discount = new Discount() { amount = 5000000, - currency_code = "USD", + currency_code = "CAD", + amount_usd = 4700000 minimum_purchase_amount = 25000000 } } @@ -677,7 +689,8 @@ The official Sift .NET client, supporting .NET Standard 2.0+ { "$user_id" : "billy_jones_301", "$amount" : 506790000, - "$currency_code" : "USD", + "$currency_code" : "CAD", + "$amount_usd" : 480090000, "$user_email" : "billjones1@example.com", "$verification_phone_number" : "+123456789012", "$transaction_type" : "$sale", @@ -716,7 +729,10 @@ The official Sift .NET client, supporting .NET Standard 2.0+ "$payment_type" : "$credit_card", "$payment_gateway" : "$braintree", "$card_bin" : "542486", - "$card_last4" : "4444" + "$card_last4" : "4444", + "card_bin_country = "US", + "card_brand = "visa", + "card_type = "gold" }, "$status_3ds" : "$attempted", "$triggered_3ds" : "$processor", @@ -767,7 +783,8 @@ The official Sift .NET client, supporting .NET Standard 2.0+ "$wager_type" : "spread", "$wager_status" : "$accept", "$amount" : 506790000, - "$currency_code" : "USD", + "$currency_code" : "CAD", + "$amount_usd" : 480090000, "$event_type" : "Sportsbook", "$event_name" : "NFL", "$event_id" : "KHG23423093", diff --git a/Sift/Schema/ComplexTypes/booking.json b/Sift/Schema/ComplexTypes/booking.json index 3d3252f..30fd627 100644 --- a/Sift/Schema/ComplexTypes/booking.json +++ b/Sift/Schema/ComplexTypes/booking.json @@ -25,6 +25,10 @@ "$currency_code": { "type": [ "string", "null" ] }, + "$price_usd": { + "type": [ "integer", "null" ], + "format": "long" + }, "$iata_carrier_code": { "type": [ "string", "null" ] }, diff --git a/Sift/Schema/ComplexTypes/discount.json b/Sift/Schema/ComplexTypes/discount.json index 3cecbca..e006637 100644 --- a/Sift/Schema/ComplexTypes/discount.json +++ b/Sift/Schema/ComplexTypes/discount.json @@ -13,9 +13,13 @@ "$currency_code": { "type": [ "string", "null" ] }, - "$minimum_purchase_amount": { + "$amount_usd": { "type": [ "integer", "null" ], "format": "long" }, + "$minimum_purchase_amount": { + "type": [ "integer", "null" ], + "format": "long" + } } } diff --git a/Sift/Schema/ComplexTypes/item.json b/Sift/Schema/ComplexTypes/item.json index d8ef4da..ccb933a 100644 --- a/Sift/Schema/ComplexTypes/item.json +++ b/Sift/Schema/ComplexTypes/item.json @@ -16,6 +16,10 @@ "$currency_code": { "type": [ "string", "null" ] }, + "$price_usd": { + "type": [ "integer", "null" ], + "format": "long" + }, "$quantity": { "type": [ "integer", "null" ] }, diff --git a/Sift/Schema/ComplexTypes/payment_method.json b/Sift/Schema/ComplexTypes/payment_method.json index 89b9229..cb574db 100644 --- a/Sift/Schema/ComplexTypes/payment_method.json +++ b/Sift/Schema/ComplexTypes/payment_method.json @@ -15,6 +15,15 @@ "$card_last4": { "type": [ "string", "null" ] }, + "$card_bin_country": { + "type": [ "string", "null" ] + }, + "$card_brand": { + "type": [ "string", "null" ] + }, + "$card_type": { + "type": [ "string", "null" ] + }, "$avs_result_code": { "type": [ "string", "null" ] }, diff --git a/Sift/Schema/create_order.json b/Sift/Schema/create_order.json index 8bb5919..ec9b56a 100644 --- a/Sift/Schema/create_order.json +++ b/Sift/Schema/create_order.json @@ -27,6 +27,10 @@ "$currency_code": { "type": [ "string", "null" ] }, + "$amount_usd": { + "type": [ "integer", "null" ], + "format": "long" + }, "$billing_address": { "oneOf": [ { "$ref": "ComplexTypes/address.json" }, diff --git a/Sift/Schema/transaction.json b/Sift/Schema/transaction.json index bceb3b9..a599c9c 100644 --- a/Sift/Schema/transaction.json +++ b/Sift/Schema/transaction.json @@ -30,6 +30,10 @@ "$currency_code": { "type": [ "string", "null" ] }, + "$amount_usd": { + "type": [ "integer", "null" ], + "format": "long" + }, "$order_id": { "type": [ "string", "null" ] }, diff --git a/Sift/Schema/update_order.json b/Sift/Schema/update_order.json index 9ea3089..868223f 100644 --- a/Sift/Schema/update_order.json +++ b/Sift/Schema/update_order.json @@ -27,6 +27,10 @@ "$currency_code": { "type": [ "string", "null" ] }, + "$amount_usd": { + "type": [ "integer", "null" ], + "format": "long" + }, "$billing_address": { "oneOf": [ { "$ref": "ComplexTypes/address.json" }, diff --git a/Sift/Schema/wager.json b/Sift/Schema/wager.json index db88bd2..52ab017 100644 --- a/Sift/Schema/wager.json +++ b/Sift/Schema/wager.json @@ -27,6 +27,10 @@ "$currency_code": { "type": [ "string", "null" ] }, + "$amount_usd": { + "type": [ "integer", "null" ], + "format": "long" + }, "$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..9eaa308 100644 --- a/Test.Integration.Net7/EventsAPI/Order.cs +++ b/Test.Integration.Net7/EventsAPI/Order.cs @@ -321,5 +321,59 @@ private EventResponse OrderStatus(Client sift) EventResponse res = sift.SendAsync(eventRequest).Result; return res; } + + [Fact] + public void UpdateOrderEventWithItemBookingDiscountPricesInUsdTest() + { + var sift = new Client(ApiKey); + + var updateOrder = new UpdateOrder + { + user_id = UserId, + session_id = SessionId, + order_id = OrderId, + amount = 100000, + currency_code = "EUR", + amount_usd = 120000, + items = new ObservableCollection() + { + new Item() + { + price = 100000, + currency_code = "EUR", + price_usd = 120000 + } + }, + bookings = new ObservableCollection() + { + new Booking() + { + booking_type = "$flight", + price = 100000, + currency_code = "EUR", + price_usd = 120000 + } + }, + promotions = new ObservableCollection() + { + new Promotion() + { + discount = new Discount() + { + amount = 100000, + currency_code = "EUR", + amount_usd = 120000 + } + } + } + }; + + EventRequest eventRequest = new EventRequest() + { + Event = updateOrder + }; + EventResponse res = sift.SendAsync(eventRequest).Result; + Assert.Equal("0", res.Status.ToString()); + } } } diff --git a/Test.Integration.Net7/EventsAPI/Transactions.cs b/Test.Integration.Net7/EventsAPI/Transactions.cs index 42c90f9..310c7cd 100644 --- a/Test.Integration.Net7/EventsAPI/Transactions.cs +++ b/Test.Integration.Net7/EventsAPI/Transactions.cs @@ -240,5 +240,37 @@ public void WithdrawalTransactionTest() EventResponse res = sift.SendAsync(eventRequest).Result; Assert.Equal("0", res.Status.ToString()); } + + [Fact] + public void TransactionEventWithAmountAndBinMetadataFieldsTest() + { + var sift = new Client(ApiKey); + var transaction = new Transaction + { + user_id = "test_dotnet_transaction_event", + amount = 100000000L, + currency_code = "EUR", + amount_usd = 120000000L, + transaction_type = "$withdrawal", + transaction_status = "$failure", + payment_method = new PaymentMethod + { + payment_type = "$credit_card", + card_bin = "542486", + card_last4 = "4444", + card_bin_country = "US", + card_brand = "Visa", + card_type = "Gold" + } + }; + + EventRequest eventRequest = new EventRequest() + { + Event = transaction + }; + EventResponse res = sift.SendAsync(eventRequest).Result; + Assert.Equal("0", res.Status.ToString()); + } + } } diff --git a/Test.Integration.Net7/EventsAPI/Wagers.cs b/Test.Integration.Net7/EventsAPI/Wagers.cs index 22ffa67..e1c99db 100644 --- a/Test.Integration.Net7/EventsAPI/Wagers.cs +++ b/Test.Integration.Net7/EventsAPI/Wagers.cs @@ -34,7 +34,8 @@ public void WagerTest() wager_type = "$parlay", wager_status = "$accept", amount = 5000, - currency_code = "USD", + currency_code = "EUR", + amount_usd = 6000, 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..67711e0 100644 --- a/Test.Integration.NetFx48/EventsAPI/Order.cs +++ b/Test.Integration.NetFx48/EventsAPI/Order.cs @@ -309,5 +309,59 @@ public void OrderStatus() EventResponse res = sift.SendAsync(eventRequest).Result; Assert.Equal("0", res.Status.ToString()); } + + [Fact] + public void UpdateOrderEventWithItemBookingDiscountPricesInUsdTest() + { + var sift = new Client(ApiKey); + + var updateOrder = new UpdateOrder + { + user_id = UserId, + session_id = SessionId, + order_id = OrderId, + amount = 100000, + currency_code = "EUR", + amount_usd = 120000, + items = new ObservableCollection() + { + new Item() + { + price = 100000, + currency_code = "EUR", + price_usd = 120000 + } + }, + bookings = new ObservableCollection() + { + new Booking() + { + booking_type = "$flight", + price = 100000, + currency_code = "EUR", + price_usd = 120000 + } + }, + promotions = new ObservableCollection() + { + new Promotion() + { + discount = new Discount() + { + amount = 100000, + currency_code = "EUR", + amount_usd = 120000 + } + } + } + }; + + EventRequest eventRequest = new EventRequest() + { + Event = updateOrder + }; + EventResponse res = sift.SendAsync(eventRequest).Result; + Assert.Equal("0", res.Status.ToString()); + } } } diff --git a/Test.Integration.NetFx48/EventsAPI/Transactions.cs b/Test.Integration.NetFx48/EventsAPI/Transactions.cs index 1d4bcc7..003f212 100644 --- a/Test.Integration.NetFx48/EventsAPI/Transactions.cs +++ b/Test.Integration.NetFx48/EventsAPI/Transactions.cs @@ -236,5 +236,36 @@ public void WithdrawalTransactionTest() EventResponse res = sift.SendAsync(eventRequest).Result; Assert.Equal("0", res.Status.ToString()); } + + [Fact] + public void TransactionEventWithAmountAndBinMetadataFieldsTest() + { + var sift = new Client(ApiKey); + var transaction = new Transaction + { + user_id = "test_dotnet_transaction_event", + amount = 100000000L, + currency_code = "EUR", + amount_usd = 120000000L, + transaction_type = "$withdrawal", + transaction_status = "$failure", + payment_method = new PaymentMethod + { + payment_type = "$credit_card", + card_bin = "542486", + card_last4 = "4444", + card_bin_country = "US", + card_brand = "Visa", + card_type = "Gold" + } + }; + + EventRequest eventRequest = new EventRequest() + { + Event = transaction + }; + EventResponse res = sift.SendAsync(eventRequest).Result; + Assert.Equal("0", res.Status.ToString()); + } } } diff --git a/Test.Integration.NetFx48/EventsAPI/Wagers.cs b/Test.Integration.NetFx48/EventsAPI/Wagers.cs index a9cff6d..5ef3e3d 100644 --- a/Test.Integration.NetFx48/EventsAPI/Wagers.cs +++ b/Test.Integration.NetFx48/EventsAPI/Wagers.cs @@ -34,7 +34,8 @@ public void WagerTest() wager_type = "$parlay", wager_status = "$accept", amount = 5000, - currency_code = "USD", + currency_code = "EUR", + amount_usd = 6000, 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..89ade54 100644 --- a/Test/Test.cs +++ b/Test/Test.cs @@ -2763,7 +2763,8 @@ public void TestWagerEvent() wager_type = "$parlay", wager_status = "$accept", amount = 5000L, - currency_code = "USD", + amount_usd = 6000L, + currency_code = "EUR", wager_event_type = "NFL", wager_event_name = "Example Game", wager_event_id = "event456", @@ -2777,7 +2778,8 @@ public void TestWagerEvent() "\"$wager_type\":\"$parlay\"," + "\"$wager_status\":\"$accept\"," + "\"$amount\":5000," + - "\"$currency_code\":\"USD\"," + + "\"$currency_code\":\"EUR\"," + + "\"$amount_usd\":6000," + "\"$wager_event_type\":\"NFL\"," + "\"$wager_event_name\":\"Example Game\"," + "\"$wager_event_id\":\"event456\"," + @@ -2801,6 +2803,158 @@ 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 TestTransactionEventWithAmountAndBinMetadataFields() + { + //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", + amount_usd = 120000000L, + session_id = sessionId, + transaction_type = "$withdrawal", + transaction_status = "$failure", + payment_method = new PaymentMethod + { + payment_type = "$credit_card", + card_bin = "542486", + card_last4 = "4444", + card_bin_country = "US", + card_brand = "Visa", + card_type = "Gold" + } + }; + + Assert.Equal("{" + + "\"$type\":\"$transaction\"," + + "\"$user_id\":\"test_dotnet_transaction_event\"," + + "\"$session_id\":\"sessionId\"," + + "\"$transaction_type\":\"$withdrawal\"," + + "\"$transaction_status\":\"$failure\"," + + "\"$amount\":100000000," + + "\"$currency_code\":\"EUR\"," + + "\"$amount_usd\":120000000," + + "\"$payment_method\":{" + + "\"$payment_type\":\"$credit_card\"," + + "\"$card_bin\":\"542486\"," + + "\"$card_last4\":\"4444\"," + + "\"$card_bin_country\":\"US\"," + + "\"$card_brand\":\"Visa\"," + + "\"$card_type\":\"Gold\"" + + "}" + + "}", 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 TestUpdateOrderEventWithItemBookingDiscountPricesInUsd() + { + //Please provide the valid session id in place of 'sessionId' + var sessionId = "sessionId"; + var updateOrder = new UpdateOrder + { + user_id = "test_dotnet_order_with_price_usd", + session_id = sessionId, + order_id = "12345", + amount = 100000, + currency_code = "EUR", + amount_usd = 120000, + items = new ObservableCollection() + { + new Item() + { + price = 100000, + currency_code = "EUR", + price_usd = 120000 + } + }, + bookings = new ObservableCollection() + { + new Booking() + { + booking_type = "$flight", + price = 100000, + currency_code = "EUR", + price_usd = 120000 + } + }, + promotions = new ObservableCollection() + { + new Promotion() + { + discount = new Discount() + { + amount = 100000, + currency_code = "EUR", + amount_usd = 120000 + } + } + } + }; + + // Augment with custom fields + Assert.Equal("{\"$type\":\"$update_order\",\"$user_id\":\"test_dotnet_order_with_price_usd\",\"$session_id\":\"sessionId\"," + + "\"$order_id\":\"12345\"," + + "\"$amount\":100000," + + "\"$currency_code\":\"EUR\"," + + "\"$amount_usd\":120000," + + "\"$items\":[{" + + "\"$price\":100000," + + "\"$currency_code\":\"EUR\"," + + "\"$price_usd\":120000" + + "}]," + + "\"$bookings\":[{" + + "\"$booking_type\":\"$flight\"," + + "\"$price\":100000," + + "\"$currency_code\":\"EUR\"," + + "\"$price_usd\":120000" + + "}]," + + "\"$promotions\":[{" + + "\"$discount\":{" + + "\"$amount\":100000," + + "\"$currency_code\":\"EUR\"," + + "\"$amount_usd\":120000" + + "}}]" + + "}", + updateOrder.ToJson()); + + EventRequest eventRequest = new EventRequest + { + Event = updateOrder + }; + + Assert.Equal("https://api.sift.com/v205/events", eventRequest.Request.RequestUri!.ToString()); + + eventRequest = new EventRequest + { + Event = updateOrder, + 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())); + } } }