diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index e19da56..b1f6b25 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -17,11 +17,11 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Setup .NET - uses: actions/setup-dotnet@v4 + uses: actions/setup-dotnet@v5 with: - dotnet-version: 7.x.x + dotnet-version: 8.x.x - name: build run: | ./build.sh --target=restore @@ -33,30 +33,30 @@ jobs: runs-on: ubuntu-latest if: ${{ github.ref == 'refs/heads/master' }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Setup .NET - uses: actions/setup-dotnet@v4 + uses: actions/setup-dotnet@v5 with: - dotnet-version: 7.x.x + dotnet-version: 8.x.x - name: siftDotNetIntegrationTest run: | ./build.sh --target=restore ./build.sh --target=generate ./build.sh --target=build - ./build.sh --target=testNet7 --filter=Account - ./build.sh --target=testNet7 --filter=Cart - ./build.sh --target=testNet7 --filter=Chargebacks - ./build.sh --target=testNet7 --filter=Contents - ./build.sh --target=testNet7 --filter=LoginLogout - ./build.sh --target=testNet7 --filter=Notifications - ./build.sh --target=testNet7 --filter=Order - ./build.sh --target=testNet7 --filter=Passwords - ./build.sh --target=testNet7 --filter=Promotions - ./build.sh --target=testNet7 --filter=Sessions - ./build.sh --target=testNet7 --filter=Transactions - ./build.sh --target=testNet7 --filter=Verifications - ./build.sh --target=testNet7 --filter=DecisionsRequests - ./build.sh --target=testNet7 --filter=Labels - ./build.sh --target=testNet7 --filter=MerchantRequests - ./build.sh --target=testNet7 --filter=Scores - ./build.sh --target=testNet7 --filter=VerificationsRequests + ./build.sh --target=testNet --filter=Account + ./build.sh --target=testNet --filter=Cart + ./build.sh --target=testNet --filter=Chargebacks + ./build.sh --target=testNet --filter=Contents + ./build.sh --target=testNet --filter=LoginLogout + ./build.sh --target=testNet --filter=Notifications + ./build.sh --target=testNet --filter=Order + ./build.sh --target=testNet --filter=Passwords + ./build.sh --target=testNet --filter=Promotions + ./build.sh --target=testNet --filter=Sessions + ./build.sh --target=testNet --filter=Transactions + ./build.sh --target=testNet --filter=Verifications + ./build.sh --target=testNet --filter=DecisionsRequests + ./build.sh --target=testNet --filter=Labels + ./build.sh --target=testNet --filter=MerchantRequests + ./build.sh --target=testNet --filter=Scores + ./build.sh --target=testNet --filter=VerificationsRequests diff --git a/.github/workflows/publishing2NuGet.yml b/.github/workflows/publishing2NuGet.yml index 91ecb2f..f3765bc 100644 --- a/.github/workflows/publishing2NuGet.yml +++ b/.github/workflows/publishing2NuGet.yml @@ -10,17 +10,15 @@ jobs: SOLUTION: 'Sift.sln' runs-on: windows-latest steps: - - uses: actions/checkout@v2 - - name: Setup NuGet - uses: NuGet/setup-nuget@v1.0.5 + - uses: actions/checkout@v5 - name: Setup .NET - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v5 with: - dotnet-version: 7.x.x + dotnet-version: 8.x.x - name: Build run: | - dotnet --info + dotnet --info echo $GITHUB_REF_NAME bash -x ./build.sh --target=pack - name: Publish - run: nuget push artifacts\Sift*.nupkg -Source 'https://api.nuget.org/v3/index.json' -ApiKey ${{secrets.NUGET_API_KEY}} + run: dotnet nuget push artifacts\Sift*.nupkg --source 'https://api.nuget.org/v3/index.json' --api-key ${{secrets.NUGET_API_KEY}} diff --git a/.gitignore b/.gitignore index d7bc231..4dcdedd 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,7 @@ tarballs/ test-results/ Thumbs.db .vs/ +.idea/ # mac bundle stuff *.dmg diff --git a/CHANGES.MD b/CHANGES.MD new file mode 100644 index 0000000..c2290c7 --- /dev/null +++ b/CHANGES.MD @@ -0,0 +1,74 @@ +# CHANGES + +## 1.6.0 (2025-10-18) + +### NuGet Package Updates +- Bumped `Newtonsoft.Json` from `13.0.2` to `13.0.4` +- Bumped `System.ComponentModel.Annotations` from `4.5.0` to `5.0.0` + +### Breaking Changes +- **`$iata_carrier_code`** moved from `Booking` to `Segment` complex type (API v205 compliance) + +### Added +- **`$exchange_rate`** field support in `$create_order`, `$update_order`, `$transaction`, `$wager` events and `$booking`, `$item`, `$discount` complex types +- **`$card_bin_metadata`** field in `$payment_method` complex type +- **`$promotions`** field in `$update_account` event +- **`$iata_carrier_code`** field in `Segment` complex type +- Apple Silicon (ARM64) native support (`osx-arm64` runtime) +- .NET 8.0 support (migrated integration tests from .NET 7) +- Comprehensive integration test coverage for all new fields + +### Changed +- Renamed `Test.Integration.Net7` to `Test.Integration.Net` (targeting .NET 8.0) + +## 1.5.0 (2024-12-24) + +### Added +- iGaming Events API support +- New event type `$wager` +- Extra fields for `$deposit` and `$withdrawal` Transactions + +## 1.4.0 (2024-09-27) + +### Added +- Support for `$iata_carrier_code` field in `$booking` complex field + +## 1.3.0 (2024-06-18) + +### Added +- Warnings to Event Response + +## 1.2.0 (2023-12-22) + +### Fixed +- PSP Merchants API fixes + +## 1.1.0 (2023-10-20) + +### Added +- Score percentiles support in Score API + +## 1.0.0 (2023-09-01) + +### Changed +- Updates in Verification API (breaking changes - see README for examples) + +## 0.13.0 (2023-08-31) + +### Added +- Initial public release + +## 0.12.0 (2023-08-28) + +### Added +- Pre-release features + +## 0.11.0-beta (2023-02-10) + +### Added +- Beta release + +## 0.10.1-beta (2022-12-05) + +### Added +- Beta release diff --git a/README.md b/README.md index bdc7efe..8e4478b 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,43 @@ The official Sift .NET client, supporting .NET Standard 2.0+ +## Latest Release (v1.6.0) + +- Full Sift API v205 compliance with multi-currency support (`$exchange_rate`), enhanced payment validation (`$card_bin_metadata`), and account promotions tracking +- **Breaking:** `$iata_carrier_code` moved from `Booking` to `Segment` complex type +- iGaming API enhancements with `$wager`, `$deposit`, and `$withdrawal` transaction support + +See [CHANGES.MD](CHANGES.MD) for full release history. + ## Documentation +### Breaking Change in v1.6.0 + +**`$iata_carrier_code` field relocation**: The `$iata_carrier_code` field has been moved from the `Booking` complex type to the `Segment` complex type to align with Sift API v205 specification. + +```csharp +// BEFORE v1.6.0 - NO LONGER WORKS +var booking = new Booking +{ + iata_carrier_code = "AS", // ❌ This property no longer exists + segments = new ObservableCollection() { /* ... */ } +}; + +// v1.6.0+ - REQUIRED +var booking = new Booking +{ + segments = new ObservableCollection() + { + new Segment() + { + iata_carrier_code = "AS", // ✅ Now at segment level + departure_airport_code = "SFO", + arrival_airport_code = "LAS" + } + } +}; +``` + ### Initialization // You can also pass in your own HttpClient implementation as the second parameter. @@ -675,74 +710,92 @@ The official Sift .NET client, supporting .NET Standard 2.0+ // Construct reserved events with known fields Transaction var transaction = new Transaction { - "$user_id" : "billy_jones_301", - "$amount" : 506790000, - "$currency_code" : "USD", - "$user_email" : "billjones1@example.com", - "$verification_phone_number" : "+123456789012", - "$transaction_type" : "$sale", - "$transaction_status" : "$failure", - "$decline_category" : "$bank_decline", - "$order_id" : "ORDER-123124124", - "$transaction_id" : "719637215", - "$ip" : "54.208.214.78", - "$billing_address" : { - "$name" : "Bill Jones", - "$phone" : "1-415-555-6041", - "$address_1" : "2100 Main Street", - "$address_2" : "Apt 3B", - "$city" : "New London", - "$region" : "New Hampshire", - "$country" : "US", - "$zipcode" : "03257" + user_id = "billy_jones_301", + amount = 506790000, + currency_code = "EUR", + exchange_rate = new ExchangeRate // NEW in v1.6.0: Multi-currency support + { + quote_currency_code = "USD", + rate = 1.14 }, - "$brand_name" : "sift", - "$site_domain" : "sift.com", - "$site_country" : "US", - "$ordered_from" : { - "$store_id" : "123", - "$store_address" : { - "$name" : "Bill Jones", - "$phone" : "1-415-555-6040", - "$address_1" : "2100 Main Street", - "$address_2" : "Apt 3B", - "$city" : "New London", - "$region" : "New Hampshire", - "$country" : "US", - "$zipcode" : "03257" + user_email = "billjones1@example.com", + verification_phone_number = "+123456789012", + transaction_type = "$sale", + transaction_status = "$failure", + decline_category = "$bank_decline", + order_id = "ORDER-123124124", + transaction_id = "719637215", + billing_address = new Address() + { + name = "Bill Jones", + phone = "1-415-555-6041", + address_1 = "2100 Main Street", + address_2 = "Apt 3B", + city = "New London", + region = "New Hampshire", + country = "US", + zipcode = "03257" + }, + brand_name = "sift", + site_domain = "sift.com", + site_country = "US", + ordered_from = new OrderedFrom() + { + store_id = "123", + store_address = new Address() + { + name = "Bill Jones", + phone = "1-415-555-6040", + address_1 = "2100 Main Street", + address_2 = "Apt 3B", + city = "New London", + region = "New Hampshire", + country = "US", + zipcode = "03257" } }, - "$payment_method" : { - "$payment_type" : "$credit_card", - "$payment_gateway" : "$braintree", - "$card_bin" : "542486", - "$card_last4" : "4444" + payment_method = new PaymentMethod() + { + payment_type = "$credit_card", + payment_gateway = "$braintree", + card_bin = "542486", + card_last4 = "4444", + card_bin_metadata = new CardBinMetadata // NEW in v1.6.0: Enhanced card validation + { + bank = "Chase", + brand = "VISA", + country = "US", + level = "Gold", + type = "CREDIT" + } }, - "$status_3ds" : "$attempted", - "$triggered_3ds" : "$processor", - "$merchant_initiated_transaction" : false, - "$shipping_address" : { - "$name" : "Bill Jones", - "$phone" : "1-415-555-6041", - "$address_1" : "2100 Main Street", - "$address_2" : "Apt 3B", - "$city" : "New London", - "$region" : "New Hampshire", - "$country" : "US", - "$zipcode" : "03257" + status_3ds = "$attempted", + triggered_3ds = "$processor", + merchant_initiated_transaction = false, + shipping_address = new Address() + { + name = "Bill Jones", + phone = "1-415-555-6041", + address_1 = "2100 Main Street", + address_2 = "Apt 3B", + city = "New London", + region = "New Hampshire", + country = "US", + zipcode = "03257" }, - "$session_id" : "gigtleqddo84l8cm15qe4il", - "$seller_user_id" : "slinkys_emporium", - "digital_wallet" : "apple_pay", - "coupon_code" : "dollarMadness", - "shipping_choice" : "FedEx Ground Courier", - "is_first_time_buyer" : false, - "$browser" : { - "$user_agent" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36", - "$accept_language" : "en-US", - "$content_language" : "en-GB" + session_id = "gigtleqddo84l8cm15qe4il", + seller_user_id = "slinkys_emporium", + browser = new Browser + { + user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36", + accept_language = "en-US", + content_language = "en-GB" } }; + // Augment with custom fields + transaction.AddField("digital_wallet", "apple_pay"); + transaction.AddField("coupon_code", "dollarMadness"); + transaction.AddField("is_first_time_buyer", false); EventRequest eventRequest = new EventRequest() { @@ -757,21 +810,24 @@ The official Sift .NET client, supporting .NET Standard 2.0+ // Handle InnerException } - // Construct reserved events with known fields Wager + // Construct reserved events with known fields Wager (NEW in v1.5.0: iGaming support) var wager = new Wager { - "$type" : "$wager", - "$api_key" : "YOUR_API_KEY", - "$user_id" : "billy_jones_301", - "$wager_id". : "ID000001", - "$wager_type" : "spread", - "$wager_status" : "$accept", - "$amount" : 506790000, - "$currency_code" : "USD", - "$event_type" : "Sportsbook", - "$event_name" : "NFL", - "$event_id" : "KHG23423093", - "$minimum_wager_amount" : 3000000 + user_id = "billy_jones_301", + wager_id = "ID000001", + wager_type = "$parlay", + wager_status = "$accept", + amount = 506790000, + currency_code = "EUR", + exchange_rate = new ExchangeRate // NEW in v1.6.0: Multi-currency support for wagers + { + quote_currency_code = "USD", + rate = 1.14 + }, + minimum_wager_amount = 3000000, + wager_event_type = "Sportsbook", + wager_event_name = "Bulls-Lakers", + wager_event_id = "nba-23-11100" }; EventRequest eventRequest = new EventRequest() @@ -787,6 +843,61 @@ The official Sift .NET client, supporting .NET Standard 2.0+ // Handle InnerException } + // Construct reserved events with known fields UpdateAccount + var updateAccount = new UpdateAccount + { + user_id = "billy_jones_301", + user_email = "billjones1@example.com", + name = "Bill Jones", + phone = "1-415-555-6041", + changed_password = true, + billing_address = new Address() + { + name = "Bill Jones", + phone = "1-415-555-6041", + address_1 = "2100 Main Street", + address_2 = "Apt 3B", + city = "New London", + region = "New Hampshire", + country = "US", + zipcode = "03257" + }, + promotions = new ObservableCollection() // NEW in v1.6.0: Promotions tracking + { + new Promotion() + { + promotion_id = "FirstTimeBuyer", + status = "$success", + description = "$5 off", + discount = new Discount() + { + amount = 5000000, + currency_code = "USD", + minimum_purchase_amount = 25000000 + } + } + }, + browser = new Browser + { + user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36", + accept_language = "en-US", + content_language = "en-GB" + } + }; + + EventRequest eventRequest = new EventRequest() + { + Event = updateAccount + }; + try + { + EventResponse res = sift.SendAsync(eventRequest).Result; + } + catch (AggregateException ae) + { + // Handle InnerException + } + #### IncludeScorePercentile in EventRequest diff --git a/Sift.sln b/Sift.sln index ffb8448..0807b02 100644 --- a/Sift.sln +++ b/Sift.sln @@ -6,7 +6,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sift", "Sift\Sift.csproj", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test", "Test\Test.csproj", "{E34BBAD1-9AAC-4120-92C9-3574CCFAF01D}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test.Integration.Net7", "Test.Integration.Net7\Test.Integration.Net7.csproj", "{C3E39BBC-D51F-4230-979B-AA2E5597ECD8}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test.Integration.Net", "Test.Integration.Net\Test.Integration.Net.csproj", "{C3E39BBC-D51F-4230-979B-AA2E5597ECD8}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test.Integration.NetFx48", "Test.Integration.NetFx48\Test.Integration.NetFx48.csproj", "{B5A60307-AAE2-4D1B-B3B6-95440A0F6381}" EndProject diff --git a/Sift/Core/Client.cs b/Sift/Core/Client.cs index be45012..6049e17 100644 --- a/Sift/Core/Client.cs +++ b/Sift/Core/Client.cs @@ -2,13 +2,14 @@ using System; using System.Net.Http; using System.Reflection; +using System.Runtime.InteropServices; using System.Threading.Tasks; namespace Sift { public class Client : IDisposable { - static string UserAgent = "sift-dotnet/" + Assembly.GetExecutingAssembly().GetName().Version; + static string UserAgent = $"sift-dotnet/{Assembly.GetExecutingAssembly().GetName().Version} ({RuntimeInformation.FrameworkDescription}; {RuntimeInformation.OSArchitecture}; {Environment.OSVersion})"; readonly String apiKey; readonly HttpClient http; diff --git a/Sift/Schema/ComplexTypes/booking.json b/Sift/Schema/ComplexTypes/booking.json index 3d3252f..6a9c30b 100644 --- a/Sift/Schema/ComplexTypes/booking.json +++ b/Sift/Schema/ComplexTypes/booking.json @@ -25,8 +25,11 @@ "$currency_code": { "type": [ "string", "null" ] }, - "$iata_carrier_code": { - "type": [ "string", "null" ] + "$exchange_rate": { + "oneOf": [ + { "$ref": "exchange_rate.json" }, + { "type": "null" } + ] }, "$quantity": { "type": [ "integer", "null" ] diff --git a/Sift/Schema/ComplexTypes/card_bin_metadata.json b/Sift/Schema/ComplexTypes/card_bin_metadata.json new file mode 100644 index 0000000..54284e5 --- /dev/null +++ b/Sift/Schema/ComplexTypes/card_bin_metadata.json @@ -0,0 +1,22 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema", + "title": "CardBinMetadata", + "type": "object", + "properties": { + "$bank": { + "type": [ "string", "null" ] + }, + "$brand": { + "type": [ "string", "null" ] + }, + "$country": { + "type": [ "string", "null" ] + }, + "$level": { + "type": [ "string", "null" ] + }, + "$type": { + "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/guest.json b/Sift/Schema/ComplexTypes/guest.json index 5635f52..5997ccc 100644 --- a/Sift/Schema/ComplexTypes/guest.json +++ b/Sift/Schema/ComplexTypes/guest.json @@ -20,6 +20,12 @@ }, "$birth_date": { "type": [ "string", "null" ] + }, + "$guest_user_id": { + "type": [ "string", "null" ] + }, + "$guest_booking_reference_id": { + "type": [ "string", "null" ] } } } 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/ComplexTypes/payment_method.json b/Sift/Schema/ComplexTypes/payment_method.json index 89b9229..00d9e06 100644 --- a/Sift/Schema/ComplexTypes/payment_method.json +++ b/Sift/Schema/ComplexTypes/payment_method.json @@ -92,6 +92,12 @@ }, "$wallet_type": { "type": [ "string", "null" ] + }, + "$card_bin_metadata": { + "oneOf": [ + { "$ref": "card_bin_metadata.json" }, + { "type": "null" } + ] } } } diff --git a/Sift/Schema/ComplexTypes/segment.json b/Sift/Schema/ComplexTypes/segment.json index 580f4e0..860d59a 100644 --- a/Sift/Schema/ComplexTypes/segment.json +++ b/Sift/Schema/ComplexTypes/segment.json @@ -23,6 +23,9 @@ "$fare_class": { "type": [ "string", "null" ] }, + "$iata_carrier_code": { + "type": [ "string", "null" ] + }, "$departure_address": { "oneOf": [ { "$ref": "address.json" }, 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_account.json b/Sift/Schema/update_account.json index 770594c..599ee76 100644 --- a/Sift/Schema/update_account.json +++ b/Sift/Schema/update_account.json @@ -81,6 +81,10 @@ }, "$verification_phone_number": { "type": [ "string", "null" ] + }, + "$promotions": { + "type": [ "array", "null" ], + "items": { "$ref": "ComplexTypes/promotion.json" } } } } 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..c4e250b 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 @@ -13,7 +13,6 @@ https://github.com/siftscience/sift-dotnet https://raw.github.com/siftscience/sift-dotnet/master/LICENSE true - win10-x64 True @@ -27,7 +26,7 @@ - - + + diff --git a/Test.Integration.Net7/DecisionsAPI/DecisionsRequests.cs b/Test.Integration.Net/DecisionsAPI/DecisionsRequests.cs similarity index 98% rename from Test.Integration.Net7/DecisionsAPI/DecisionsRequests.cs rename to Test.Integration.Net/DecisionsAPI/DecisionsRequests.cs index 9c46260..a694f2f 100644 --- a/Test.Integration.Net7/DecisionsAPI/DecisionsRequests.cs +++ b/Test.Integration.Net/DecisionsAPI/DecisionsRequests.cs @@ -1,9 +1,9 @@ using Sift; using System; -using Test.Integration.Net7.Uitlities; +using Test.Integration.Net.Uitlities; using Xunit; -namespace Test.Integration.Net7.DecisionsAPI +namespace Test.Integration.Net.DecisionsAPI { public class DecisionsRequests { diff --git a/Test.Integration.Net7/EventsAPI/Account.cs b/Test.Integration.Net/EventsAPI/Account.cs similarity index 91% rename from Test.Integration.Net7/EventsAPI/Account.cs rename to Test.Integration.Net/EventsAPI/Account.cs index 6fb4681..72f51da 100644 --- a/Test.Integration.Net7/EventsAPI/Account.cs +++ b/Test.Integration.Net/EventsAPI/Account.cs @@ -1,9 +1,9 @@ using Sift; using System.Collections.ObjectModel; -using Test.Integration.Net7.Uitlities; +using Test.Integration.Net.Uitlities; using Xunit; -namespace Test.Integration.Net7.EventsAPI +namespace Test.Integration.Net.EventsAPI { public class Account { @@ -32,6 +32,7 @@ public void CreateAccount() user_id = UserId, session_id = SessionId, user_email = UserEmail, + verification_phone_number = "+123456789012", name = "Bill Jones", phone = "1-415-555-6040", referrer_user_id = ReferrerUserId, @@ -174,6 +175,21 @@ public void UpdateAccount() country = "US", zipcode = "03257" }, + promotions = new ObservableCollection() + { + new Promotion() + { + promotion_id = "UpdatedPromotion", + status = "$success", + description = "$10 off updated account", + discount = new Discount() + { + amount = 10000000, + currency_code = "USD", + minimum_purchase_amount = 50000000 + } + } + }, social_sign_on_type = "$twitter", browser = new Browser { diff --git a/Test.Integration.Net7/EventsAPI/Cart.cs b/Test.Integration.Net/EventsAPI/Cart.cs similarity index 98% rename from Test.Integration.Net7/EventsAPI/Cart.cs rename to Test.Integration.Net/EventsAPI/Cart.cs index 3a81124..881d173 100644 --- a/Test.Integration.Net7/EventsAPI/Cart.cs +++ b/Test.Integration.Net/EventsAPI/Cart.cs @@ -1,9 +1,9 @@ using Sift; using System.Collections.ObjectModel; -using Test.Integration.Net7.Uitlities; +using Test.Integration.Net.Uitlities; using Xunit; -namespace Test.Integration.Net7.EventsAPI +namespace Test.Integration.Net.EventsAPI { public class Cart { diff --git a/Test.Integration.Net7/EventsAPI/Chargebacks.cs b/Test.Integration.Net/EventsAPI/Chargebacks.cs similarity index 96% rename from Test.Integration.Net7/EventsAPI/Chargebacks.cs rename to Test.Integration.Net/EventsAPI/Chargebacks.cs index 35199b7..50f29c9 100644 --- a/Test.Integration.Net7/EventsAPI/Chargebacks.cs +++ b/Test.Integration.Net/EventsAPI/Chargebacks.cs @@ -1,8 +1,8 @@ using Sift; -using Test.Integration.Net7.Uitlities; +using Test.Integration.Net.Uitlities; using Xunit; -namespace Test.Integration.Net7.EventsAPI +namespace Test.Integration.Net.EventsAPI { public class Chargebacks { diff --git a/Test.Integration.Net7/EventsAPI/Contents.cs b/Test.Integration.Net/EventsAPI/Contents.cs similarity index 99% rename from Test.Integration.Net7/EventsAPI/Contents.cs rename to Test.Integration.Net/EventsAPI/Contents.cs index afc7531..aadc4c3 100644 --- a/Test.Integration.Net7/EventsAPI/Contents.cs +++ b/Test.Integration.Net/EventsAPI/Contents.cs @@ -1,10 +1,10 @@ using Sift; using System; using System.Collections.ObjectModel; -using Test.Integration.Net7.Uitlities; +using Test.Integration.Net.Uitlities; using Xunit; -namespace Test.Integration.Net7.EventsAPI +namespace Test.Integration.Net.EventsAPI { public class Contents { diff --git a/Test.Integration.Net7/EventsAPI/LoginLogout.cs b/Test.Integration.Net/EventsAPI/LoginLogout.cs similarity index 97% rename from Test.Integration.Net7/EventsAPI/LoginLogout.cs rename to Test.Integration.Net/EventsAPI/LoginLogout.cs index deecda5..99bcdfa 100644 --- a/Test.Integration.Net7/EventsAPI/LoginLogout.cs +++ b/Test.Integration.Net/EventsAPI/LoginLogout.cs @@ -1,9 +1,9 @@ using Sift; using System.Collections.ObjectModel; -using Test.Integration.Net7.Uitlities; +using Test.Integration.Net.Uitlities; using Xunit; -namespace Test.Integration.Net7.EventsAPI +namespace Test.Integration.Net.EventsAPI { public class LoginLogout { diff --git a/Test.Integration.Net7/EventsAPI/Notifications.cs b/Test.Integration.Net/EventsAPI/Notifications.cs similarity index 95% rename from Test.Integration.Net7/EventsAPI/Notifications.cs rename to Test.Integration.Net/EventsAPI/Notifications.cs index 8b6a904..fa36820 100644 --- a/Test.Integration.Net7/EventsAPI/Notifications.cs +++ b/Test.Integration.Net/EventsAPI/Notifications.cs @@ -1,8 +1,8 @@ using Sift; -using Test.Integration.Net7.Uitlities; +using Test.Integration.Net.Uitlities; using Xunit; -namespace Test.Integration.Net7.EventsAPI +namespace Test.Integration.Net.EventsAPI { public class Notifications { diff --git a/Test.Integration.Net7/EventsAPI/Order.cs b/Test.Integration.Net/EventsAPI/Order.cs similarity index 93% rename from Test.Integration.Net7/EventsAPI/Order.cs rename to Test.Integration.Net/EventsAPI/Order.cs index 002c57e..338ec6b 100644 --- a/Test.Integration.Net7/EventsAPI/Order.cs +++ b/Test.Integration.Net/EventsAPI/Order.cs @@ -1,10 +1,10 @@ using Sift; using System; using System.Collections.ObjectModel; -using Test.Integration.Net7.Uitlities; +using Test.Integration.Net.Uitlities; using Xunit; -namespace Test.Integration.Net7.EventsAPI +namespace Test.Integration.Net.EventsAPI { public class Order { @@ -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/Passwords.cs b/Test.Integration.Net/EventsAPI/Passwords.cs similarity index 95% rename from Test.Integration.Net7/EventsAPI/Passwords.cs rename to Test.Integration.Net/EventsAPI/Passwords.cs index 803c6d6..f73651b 100644 --- a/Test.Integration.Net7/EventsAPI/Passwords.cs +++ b/Test.Integration.Net/EventsAPI/Passwords.cs @@ -1,8 +1,8 @@ using Sift; -using Test.Integration.Net7.Uitlities; +using Test.Integration.Net.Uitlities; using Xunit; -namespace Test.Integration.Net7.EventsAPI +namespace Test.Integration.Net.EventsAPI { public class Passwords { diff --git a/Test.Integration.Net7/EventsAPI/Promotions.cs b/Test.Integration.Net/EventsAPI/Promotions.cs similarity index 97% rename from Test.Integration.Net7/EventsAPI/Promotions.cs rename to Test.Integration.Net/EventsAPI/Promotions.cs index ca171f7..c830508 100644 --- a/Test.Integration.Net7/EventsAPI/Promotions.cs +++ b/Test.Integration.Net/EventsAPI/Promotions.cs @@ -1,9 +1,9 @@ using Sift; using System.Collections.ObjectModel; -using Test.Integration.Net7.Uitlities; +using Test.Integration.Net.Uitlities; using Xunit; -namespace Test.Integration.Net7.EventsAPI +namespace Test.Integration.Net.EventsAPI { public class Promotions { diff --git a/Test.Integration.Net7/EventsAPI/Sessions.cs b/Test.Integration.Net/EventsAPI/Sessions.cs similarity index 92% rename from Test.Integration.Net7/EventsAPI/Sessions.cs rename to Test.Integration.Net/EventsAPI/Sessions.cs index 7480fb0..b2facf9 100644 --- a/Test.Integration.Net7/EventsAPI/Sessions.cs +++ b/Test.Integration.Net/EventsAPI/Sessions.cs @@ -1,8 +1,8 @@ using Sift; -using Test.Integration.Net7.Uitlities; +using Test.Integration.Net.Uitlities; using Xunit; -namespace Test.Integration.Net7.EventsAPI +namespace Test.Integration.Net.EventsAPI { public class Sessions { diff --git a/Test.Integration.Net7/EventsAPI/Transactions.cs b/Test.Integration.Net/EventsAPI/Transactions.cs similarity index 85% rename from Test.Integration.Net7/EventsAPI/Transactions.cs rename to Test.Integration.Net/EventsAPI/Transactions.cs index 42c90f9..9dc5246 100644 --- a/Test.Integration.Net7/EventsAPI/Transactions.cs +++ b/Test.Integration.Net/EventsAPI/Transactions.cs @@ -2,10 +2,10 @@ using System; using System.Collections.ObjectModel; using System.Diagnostics; -using Test.Integration.Net7.Uitlities; +using Test.Integration.Net.Uitlities; using Xunit; -namespace Test.Integration.Net7.EventsAPI +namespace Test.Integration.Net.EventsAPI { public class Transactions { @@ -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() @@ -240,5 +245,40 @@ 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", + transaction_type = "$withdrawal", + transaction_status = "$failure", + payment_method = new PaymentMethod + { + payment_type = "$credit_card", + card_bin = "542486", + card_last4 = "4444", + card_bin_metadata = new CardBinMetadata + { + bank = "Chase", + brand = "VISA", + country = "US", + level = "Gold", + type = "CREDIT" + } + } + }; + + 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/Verifications.cs b/Test.Integration.Net/EventsAPI/Verifications.cs similarity index 95% rename from Test.Integration.Net7/EventsAPI/Verifications.cs rename to Test.Integration.Net/EventsAPI/Verifications.cs index f5a6cb7..030cc19 100644 --- a/Test.Integration.Net7/EventsAPI/Verifications.cs +++ b/Test.Integration.Net/EventsAPI/Verifications.cs @@ -1,8 +1,8 @@ using Sift; -using Test.Integration.Net7.Uitlities; +using Test.Integration.Net.Uitlities; using Xunit; -namespace Test.Integration.Net7.EventsAPI +namespace Test.Integration.Net.EventsAPI { public class Verifications { diff --git a/Test.Integration.Net7/EventsAPI/Wagers.cs b/Test.Integration.Net/EventsAPI/Wagers.cs similarity index 82% rename from Test.Integration.Net7/EventsAPI/Wagers.cs rename to Test.Integration.Net/EventsAPI/Wagers.cs index 22ffa67..e0d9f3a 100644 --- a/Test.Integration.Net7/EventsAPI/Wagers.cs +++ b/Test.Integration.Net/EventsAPI/Wagers.cs @@ -1,10 +1,10 @@ using Sift; using System; using System.Diagnostics; -using Test.Integration.Net7.Uitlities; +using Test.Integration.Net.Uitlities; using Xunit; -namespace Test.Integration.Net7.EventsAPI +namespace Test.Integration.Net.EventsAPI { public class Wagers { @@ -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.Net7/LabelsAPI/Labels.cs b/Test.Integration.Net/LabelsAPI/Labels.cs similarity index 94% rename from Test.Integration.Net7/LabelsAPI/Labels.cs rename to Test.Integration.Net/LabelsAPI/Labels.cs index 6ce2654..57b575c 100644 --- a/Test.Integration.Net7/LabelsAPI/Labels.cs +++ b/Test.Integration.Net/LabelsAPI/Labels.cs @@ -1,8 +1,8 @@ using Sift; -using Test.Integration.Net7.Uitlities; +using Test.Integration.Net.Uitlities; using Xunit; -namespace Test.Integration.Net7.LabelsAPI +namespace Test.Integration.Net.LabelsAPI { public class Labels { diff --git a/Test.Integration.Net7/PSPMerchantManagementAPI/MerchantRequests.cs b/Test.Integration.Net/PSPMerchantManagementAPI/MerchantRequests.cs similarity index 98% rename from Test.Integration.Net7/PSPMerchantManagementAPI/MerchantRequests.cs rename to Test.Integration.Net/PSPMerchantManagementAPI/MerchantRequests.cs index b5c5734..a1a208a 100644 --- a/Test.Integration.Net7/PSPMerchantManagementAPI/MerchantRequests.cs +++ b/Test.Integration.Net/PSPMerchantManagementAPI/MerchantRequests.cs @@ -1,9 +1,9 @@ using Sift; using System; -using Test.Integration.Net7.Uitlities; +using Test.Integration.Net.Uitlities; using Xunit; -namespace Test.Integration.Net7.PSPMerchantManagementAPI +namespace Test.Integration.Net.PSPMerchantManagementAPI { public class MerchantRequests { diff --git a/Test.Integration.Net7/ScoreAPI/Scores.cs b/Test.Integration.Net/ScoreAPI/Scores.cs similarity index 94% rename from Test.Integration.Net7/ScoreAPI/Scores.cs rename to Test.Integration.Net/ScoreAPI/Scores.cs index bc5cdae..ee30bf4 100644 --- a/Test.Integration.Net7/ScoreAPI/Scores.cs +++ b/Test.Integration.Net/ScoreAPI/Scores.cs @@ -1,9 +1,9 @@ using Sift; using System.Collections.Generic; -using Test.Integration.Net7.Uitlities; +using Test.Integration.Net.Uitlities; using Xunit; -namespace Test.Integration.Net7.ScoreAPI +namespace Test.Integration.Net.ScoreAPI { public class Scores { diff --git a/Test.Integration.Net7/Test.Integration.Net7.csproj b/Test.Integration.Net/Test.Integration.Net.csproj similarity index 74% rename from Test.Integration.Net7/Test.Integration.Net7.csproj rename to Test.Integration.Net/Test.Integration.Net.csproj index b246dc7..ea66213 100644 --- a/Test.Integration.Net7/Test.Integration.Net7.csproj +++ b/Test.Integration.Net/Test.Integration.Net.csproj @@ -1,16 +1,19 @@  - net7.0 + net8.0 false + + latest - - - - + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Test.Integration.Net7/Uitlities/EnvironmentVariable.cs b/Test.Integration.Net/Uitlities/EnvironmentVariable.cs similarity index 93% rename from Test.Integration.Net7/Uitlities/EnvironmentVariable.cs rename to Test.Integration.Net/Uitlities/EnvironmentVariable.cs index c7a0f63..091c2b8 100644 --- a/Test.Integration.Net7/Uitlities/EnvironmentVariable.cs +++ b/Test.Integration.Net/Uitlities/EnvironmentVariable.cs @@ -2,7 +2,7 @@ using System; using System.IO; -namespace Test.Integration.Net7.Uitlities +namespace Test.Integration.Net.Uitlities { internal class EnvironmentVariable { @@ -10,9 +10,10 @@ internal class EnvironmentVariable public EnvironmentVariable() { - var builder = new ConfigurationBuilder() + var builder = new ConfigurationManager() .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true); + .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true) + .AddEnvironmentVariables(); configuration = builder.Build(); } @@ -20,7 +21,7 @@ public string ApiKey { get { - var envAPI_KEY = Environment.GetEnvironmentVariable("API_KEY"); + var envAPI_KEY = configuration["API_KEY"] ?? configuration["Values:ApiKey"]; if (string.IsNullOrEmpty(envAPI_KEY)) { throw new Exception("Specify API Key"); @@ -32,7 +33,7 @@ public string AccountId { get { - var envACCOUNT_ID = Environment.GetEnvironmentVariable("ACCOUNT_ID"); + var envACCOUNT_ID = configuration["ACCOUNT_ID"] ?? configuration["Values:AccountId"]; if (string.IsNullOrEmpty(envACCOUNT_ID)) { throw new Exception("Specify ACCOUNT ID"); diff --git a/Test.Integration.Net7/VerificationAPI/VerificationsRequests.cs b/Test.Integration.Net/VerificationAPI/VerificationsRequests.cs similarity index 96% rename from Test.Integration.Net7/VerificationAPI/VerificationsRequests.cs rename to Test.Integration.Net/VerificationAPI/VerificationsRequests.cs index d7703b2..7c1d70e 100644 --- a/Test.Integration.Net7/VerificationAPI/VerificationsRequests.cs +++ b/Test.Integration.Net/VerificationAPI/VerificationsRequests.cs @@ -1,9 +1,9 @@ using Sift; using System; -using Test.Integration.Net7.Uitlities; +using Test.Integration.Net.Uitlities; using Xunit; -namespace Test.Integration.Net7.VerificationAPI +namespace Test.Integration.Net.VerificationAPI { public class VerificationsRequests { diff --git a/Test.Integration.Net7/local.settings.json b/Test.Integration.Net/local.settings.json similarity index 100% rename from Test.Integration.Net7/local.settings.json rename to Test.Integration.Net/local.settings.json diff --git a/Test.Integration.Net7/xunit.runner.json b/Test.Integration.Net/xunit.runner.json similarity index 100% rename from Test.Integration.Net7/xunit.runner.json rename to Test.Integration.Net/xunit.runner.json diff --git a/Test.Integration.NetFx48/EventsAPI/Account.cs b/Test.Integration.NetFx48/EventsAPI/Account.cs index ee9a14c..691cf1d 100644 --- a/Test.Integration.NetFx48/EventsAPI/Account.cs +++ b/Test.Integration.NetFx48/EventsAPI/Account.cs @@ -34,6 +34,7 @@ public void CreateAccount() user_id = UserId, session_id = SessionId, user_email = UserEmail, + verification_phone_number = "+123456789012", name = "Bill Jones", phone = "1-415-555-6040", referrer_user_id = ReferrerUserId, @@ -90,6 +91,12 @@ public void CreateAccount() } }, social_sign_on_type = "$twitter", + app = new App + { + app_name = "MyTestApp", + app_version = "1.2.3", + client_language = "en-US" + }, browser = new Browser { user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36", @@ -176,7 +183,28 @@ public void UpdateAccount() country = "US", zipcode = "03257" }, + promotions = new ObservableCollection() + { + new Promotion() + { + promotion_id = "UpdatedPromotion", + status = "$success", + description = "$10 off updated account", + discount = new Discount() + { + amount = 10000000, + currency_code = "USD", + minimum_purchase_amount = 50000000 + } + } + }, social_sign_on_type = "$twitter", + app = new App + { + app_name = "MyTestApp", + app_version = "1.2.3", + client_language = "en-US" + }, browser = new Browser { user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36", 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..19eca2a 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() @@ -236,5 +241,40 @@ 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", + transaction_type = "$withdrawal", + transaction_status = "$failure", + payment_method = new PaymentMethod + { + payment_type = "$credit_card", + card_bin = "542486", + card_last4 = "4444", + card_bin_metadata = new CardBinMetadata + { + bank = "Chase", + brand = "VISA", + country = "US", + level = "Gold", + type = "CREDIT" + } + } + }; + + 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..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.Integration.NetFx48/Test.Integration.NetFx48.csproj b/Test.Integration.NetFx48/Test.Integration.NetFx48.csproj index a59d670..09932a9 100644 --- a/Test.Integration.NetFx48/Test.Integration.NetFx48.csproj +++ b/Test.Integration.NetFx48/Test.Integration.NetFx48.csproj @@ -10,9 +10,9 @@ - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/Test/Test.cs b/Test/Test.cs index 8d31f0b..2c519bb 100644 --- a/Test/Test.cs +++ b/Test/Test.cs @@ -55,7 +55,6 @@ public void TestEventRequest() end_time= 2038412903, price = 49900000, currency_code = "USD", - iata_carrier_code = "AS", quantity = 1, venue_id = "venue-123", event_id = "event-123", @@ -70,7 +69,9 @@ public void TestEventRequest() loyalty_program = "skymiles", loyalty_program_id = "PSOV34DF", phone = "1-415-555-6040", - email = "jdoe@domain.com" + email = "jdoe@domain.com", + guest_user_id = "johndoe_1985-01-19", + guest_booking_reference_id = "AO0999837df" }, new Guest() { @@ -107,6 +108,7 @@ public void TestEventRequest() end_time = 2038412903, vessel_number = "LH454", fare_class = "Premium Economy", + iata_carrier_code = "AS", departure_airport_code = "SFO", arrival_airport_code = "LAS" } @@ -162,10 +164,10 @@ public void TestEventRequest() "\"$session_id\":\"sessionId\",\"$order_id\":\"oid\",\"$user_email\":\"bill@gmail.com\"," + "\"$amount\":1000000000000,\"$currency_code\":\"USD\",\"$billing_address\":{\"$name\":\"gary\",\"$city\":\"san francisco\"}," + "\"$bookings\":[{\"$booking_type\":\"$flight\",\"$title\":\"SFO - LAS, 2 Adults\",\"$start_time\":2038412903," + - "\"$end_time\":2038412903,\"$price\":49900000,\"$currency_code\":\"USD\",\"$iata_carrier_code\":\"AS\",\"$quantity\":1,\"$guests\":[{\"$name\":\"John Doe\"," + + "\"$end_time\":2038412903,\"$price\":49900000,\"$currency_code\":\"USD\",\"$quantity\":1,\"$guests\":[{\"$name\":\"John Doe\"," + "\"$email\":\"jdoe@domain.com\",\"$phone\":\"1-415-555-6040\",\"$loyalty_program\":\"skymiles\",\"$loyalty_program_id\":\"PSOV34DF\"," + - "\"$birth_date\":\"1985-01-19\"},{\"$name\":\"John Doe\"}],\"$segments\":[{\"$start_time\":203841290300,\"$end_time\":2038412903," + - "\"$vessel_number\":\"LH454\",\"$departure_airport_code\":\"SFO\",\"$arrival_airport_code\":\"LAS\",\"$fare_class\":\"Premium Economy\"," + + "\"$birth_date\":\"1985-01-19\",\"$guest_user_id\":\"johndoe_1985-01-19\",\"$guest_booking_reference_id\":\"AO0999837df\"},{\"$name\":\"John Doe\"}],\"$segments\":[{\"$start_time\":203841290300,\"$end_time\":2038412903," + + "\"$vessel_number\":\"LH454\",\"$departure_airport_code\":\"SFO\",\"$arrival_airport_code\":\"LAS\",\"$fare_class\":\"Premium Economy\",\"$iata_carrier_code\":\"AS\"," + "\"$departure_address\":{\"$name\":\"Bill Jones\",\"$address_1\":\"2100 Main Street\",\"$address_2\":\"Apt 3B\",\"$city\":\"New London\"," + "\"$region\":\"New Hampshire\",\"$country\":\"US\",\"$zipcode\":\"03257\",\"$phone\":\"1-415-555-6040\"}," + "\"$arrival_address\":{\"$name\":\"Bill Jones\",\"$address_1\":\"2100 Main Street\",\"$address_2\":\"Apt 3B\",\"$city\":\"New London\"," + @@ -2763,7 +2765,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 +2784,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 +2812,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())); + } } } diff --git a/Test/Test.csproj b/Test/Test.csproj index 97ca3c2..156d9bb 100644 --- a/Test/Test.csproj +++ b/Test/Test.csproj @@ -1,15 +1,18 @@ - net7.0 + net8.0 enable enable - - - + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/build.cake b/build.cake index 45626c3..65ab812 100644 --- a/build.cake +++ b/build.cake @@ -4,7 +4,7 @@ var ARTIFACTS_DIR = "./artifacts/"; var SOLUTION = "./Sift.sln"; var SIFT = "./Sift/Sift.csproj"; var TEST = "./Test/Test.csproj"; -var TEST_NET7 = "./Test.Integration.Net7/Test.Integration.Net7.csproj"; +var TEST_NET = "./Test.Integration.Net/Test.Integration.Net.csproj"; Task("clean") .Does(() => @@ -36,13 +36,13 @@ Task("build") Task("test") .Does(() => DotNetCoreTest(TEST)); -Task("testNet7") +Task("testNet") .Does(() => { var testFilter = Argument("filter", ""); if (string.IsNullOrEmpty(testFilter)) { - DotNetCoreTest(TEST_NET7); + DotNetCoreTest(TEST_NET); } else { @@ -50,7 +50,7 @@ Task("testNet7") { ArgumentCustomization = args => args.Append("--filter=" + testFilter) }; - DotNetCoreTest(TEST_NET7, settings); + DotNetCoreTest(TEST_NET, settings); } });