Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Sift/Schema/ComplexTypes/card_bin_metadata.json
Original file line number Diff line number Diff line change
@@ -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" ]
}
}
}
6 changes: 6 additions & 0 deletions Sift/Schema/ComplexTypes/payment_method.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@
},
"$wallet_type": {
"type": [ "string", "null" ]
},
"$card_bin_metadata": {
"oneOf": [
{ "$ref": "card_bin_metadata.json" },
{ "type": "null" }
]
}
}
}
4 changes: 2 additions & 2 deletions Sift/Sift.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<Authors>Sift</Authors>
<AssemblyTitle>Sift</AssemblyTitle>
<AssemblyName>Sift</AssemblyName>
<VersionPrefix>1.5.0</VersionPrefix>
<PackageReleaseNotes>Release 1.5.0</PackageReleaseNotes>
<VersionPrefix>1.6.0</VersionPrefix>
<PackageReleaseNotes>Release 1.6.0</PackageReleaseNotes>
<TargetFramework>netstandard2.0</TargetFramework>
<PackageId>Sift</PackageId>
<PackageTags>sift;siftscience;client;api;client;async</PackageTags>
Expand Down
35 changes: 35 additions & 0 deletions Test.Integration.Net7/EventsAPI/Transactions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,5 +240,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());
}
}
}
35 changes: 35 additions & 0 deletions Test.Integration.NetFx48/EventsAPI/Transactions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,5 +236,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());
}
}
}
70 changes: 69 additions & 1 deletion Test/Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2619,11 +2619,11 @@

string responseBody = "{\"status\":53,\"error_message\":\"Invalid field value(s) for fields: $.$amount, $.$currency_code. Please check the documentation for valid field values.\",\"time\":1717399201,\"warnings\":{\"count\":2,\"items\":[{\"message\":\"Invalid field value at $.$amount\"},{\"message\":\"Invalid field value at $.$currency_code\"}]}}";

EventResponse response = JsonConvert.DeserializeObject<EventResponse>(responseBody);

Check warning on line 2622 in Test/Test.cs

View workflow job for this annotation

GitHub Actions / build

Converting null literal or possible null value to non-nullable type.

Check warning on line 2622 in Test/Test.cs

View workflow job for this annotation

GitHub Actions / build

Converting null literal or possible null value to non-nullable type.

Assert.Equal("https://api.sift.com/v205/events?fields=warnings",
Uri.UnescapeDataString(eventRequest.Request.RequestUri!.ToString()));
Assert.Equal(2, response.Warnings.Count);

Check warning on line 2626 in Test/Test.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 2626 in Test/Test.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

}

Expand Down Expand Up @@ -2801,6 +2801,74 @@
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",
session_id = sessionId,
transaction_type = "$deposit",
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"
}
}
};

Assert.Equal("{" +
"\"$type\":\"$transaction\"," +
"\"$user_id\":\"test_dotnet_transaction_event\"," +
"\"$session_id\":\"sessionId\"," +
"\"$transaction_type\":\"$deposit\"," +
"\"$transaction_status\":\"$failure\"," +
"\"$amount\":100000000," +
"\"$currency_code\":\"EUR\"," +
"\"$payment_method\":{" +
"\"$payment_type\":\"$credit_card\"," +
"\"$card_bin\":\"542486\"," +
"\"$card_last4\":\"4444\"," +
"\"$card_bin_metadata\":{" +
"\"$bank\":\"Chase\"," +
"\"$brand\":\"VISA\"," +
"\"$country\":\"US\"," +
"\"$level\":\"Gold\"," +
"\"$type\":\"CREDIT\"" +
"}" +
"}" +
"}", 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()));
}
}
}
Loading