Skip to content

Commit

Permalink
Adding support for $merchant_profile complex field to $create_accoun…
Browse files Browse the repository at this point in the history
…t, $update_account, and $chargeback events (#70)
  • Loading branch information
rsomavarapu-sift authored Apr 4, 2022
1 parent 1a830b1 commit c138736
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGES.MD
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
3.4.4 (2022-03-24)
=================
- Add support for `$merchant_profile` complex field to `$create_account`, `$update_account`, and `$chargeback` events

3.4.3 (2021-10-12)
=================
- Add support for `$shortened_iban_first6`, `$shortened_iban_last4`, and `$sepa_direct_debit_mandate` to `$payment_method` complex field and `$transaction` event
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ Java 1.7 or later.
<dependency>
<groupId>com.siftscience</groupId>
<artifactId>sift-java</artifactId>
<version>3.4.3</version>
<version>3.4.4</version>
</dependency>
```
### Gradle
```
dependencies {
compile 'com.siftscience:sift-java:3.4.3'
compile 'com.siftscience:sift-java:3.4.4'
}
```
### Other
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ apply plugin: 'signing'
apply plugin: 'java-library-distribution'

group = 'com.siftscience'
version = '3.4.3'
version = '3.4.4'

repositories {
mavenCentral()
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/siftscience/model/BaseAccountFieldSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public abstract class BaseAccountFieldSet<T extends BaseAccountFieldSet<T>>
@Expose @SerializedName("$billing_address") private Address billingAddress;
@Expose @SerializedName("$shipping_address") private Address shippingAddress;
@Expose @SerializedName("$social_sign_on_type") private String socialSignOnType;
@Expose @SerializedName("$merchant_profile") private MerchantProfile merchantProfile;

public String getUserEmail() {
return userEmail;
Expand Down Expand Up @@ -87,4 +88,13 @@ public T setSocialSignOnType(String socialSignOnType) {
this.socialSignOnType = socialSignOnType;
return (T) this;
}

public MerchantProfile getMerchantProfile() {
return merchantProfile;
}

public T setMerchantProfile(MerchantProfile merchantProfile) {
this.merchantProfile = merchantProfile;
return (T) this;
}
}
10 changes: 10 additions & 0 deletions src/main/java/com/siftscience/model/ChargebackFieldSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public static ChargebackFieldSet fromJson(String json) {
@Expose @SerializedName("$transaction_id") private String transactionId;
@Expose @SerializedName("$chargeback_state") private String chargebackState;
@Expose @SerializedName("$chargeback_reason") private String chargebackReason;
@Expose @SerializedName("$merchant_profile") private MerchantProfile merchantProfile;

@Override
public String getEventType() {
Expand Down Expand Up @@ -53,4 +54,13 @@ public ChargebackFieldSet setChargebackReason(String chargebackReason) {
this.chargebackReason = chargebackReason;
return this;
}

public MerchantProfile getMerchantProfile() {
return merchantProfile;
}

public ChargebackFieldSet setMerchantProfile(MerchantProfile merchantProfile) {
this.merchantProfile = merchantProfile;
return this;
}
}
22 changes: 19 additions & 3 deletions src/test/java/com/siftscience/ChargebackEventTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,23 @@ public void testChargeback() throws Exception {
" \"$transaction_id\" : \"719637215\",\n" +
"\n" +
" \"$chargeback_state\" : \"$lost\",\n" +
" \"$chargeback_reason\" : \"$duplicate\"\n" +
"}";
" \"$chargeback_reason\" : \"$duplicate\",\n" +
" \"$merchant_profile\" : {\n" +
" \"$merchant_id\" : \"12345\",\n" +
" \"$merchant_category_code\" : \"9876\",\n" +
" \"$merchant_name\" : \"ABC Merchant\",\n" +
" \"$merchant_address\" : {\n" +
" \"$address_1\" : \"2100 Main Street\",\n" +
" \"$address_2\" : \"Apt 3B\",\n" +
" \"$city\" : \"New London\",\n" +
" \"$country\" : \"US\",\n" +
" \"$name\" : \"Bill Jones\",\n" +
" \"$phone\" : \"1-415-555-6040\",\n" +
" \"$region\" : \"New Hampshire\",\n" +
" \"$zipcode\" : \"03257\"\n" +
" }\n" +
" }\n" +
"}\n";

// Start a new mock server and enqueue a mock response.
MockWebServer server = new MockWebServer();
Expand All @@ -50,7 +65,8 @@ public void testChargeback() throws Exception {
.setOrderId("ORDER-123124124")
.setTransactionId("719637215")
.setChargebackState("$lost")
.setChargebackReason("$duplicate"));
.setChargebackReason("$duplicate")
.setMerchantProfile(TestUtils.sampleMerchantProfile()));

EventResponse siftResponse = request.send();

Expand Down
22 changes: 19 additions & 3 deletions src/test/java/com/siftscience/CreateAccountEventTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,23 @@ public void testCreateAccount() throws Exception {
" \"referral_code\" : \"MIKEFRIENDS\",\n" +
" \"email_confirmed_status\" : \"$pending\",\n" +
" \"phone_confirmed_status\" : \"$pending\",\n" +
" \"$account_types\" : [\"merchant\", \"premium\"]\n" +
"}";
" \"$account_types\" : [\"merchant\", \"premium\"],\n" +
" \"$merchant_profile\" : {\n" +
" \"$merchant_id\" : \"12345\",\n" +
" \"$merchant_category_code\" : \"9876\",\n" +
" \"$merchant_name\" : \"ABC Merchant\",\n" +
" \"$merchant_address\" : {\n" +
" \"$address_1\" : \"2100 Main Street\",\n" +
" \"$address_2\" : \"Apt 3B\",\n" +
" \"$city\" : \"New London\",\n" +
" \"$country\" : \"US\",\n" +
" \"$name\" : \"Bill Jones\",\n" +
" \"$phone\" : \"1-415-555-6040\",\n" +
" \"$region\" : \"New Hampshire\",\n" +
" \"$zipcode\" : \"03257\"\n" +
" }\n" +
" }\n" +
"}\n";

// Start a new mock server and enqueue a mock response.
MockWebServer server = new MockWebServer();
Expand Down Expand Up @@ -127,7 +142,8 @@ public void testCreateAccount() throws Exception {
.setCustomField("referral_code", "MIKEFRIENDS")
.setCustomField("email_confirmed_status", "$pending")
.setCustomField("phone_confirmed_status", "$pending")
.setAccountTypes(Arrays.asList("merchant", "premium")));
.setAccountTypes(Arrays.asList("merchant", "premium"))
.setMerchantProfile(TestUtils.sampleMerchantProfile()));

SiftResponse siftResponse = request.send();

Expand Down
23 changes: 20 additions & 3 deletions src/test/java/com/siftscience/UpdateAccountEventTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,23 @@ public void testUpdateAccount() throws Exception {
" \"$social_sign_on_type\" : \"$twitter\",\n" +
" \"email_confirmed_status\" : \"$success\",\n" +
" \"phone_confirmed_status\" : \"$success\",\n" +
" \"$account_types\" : [\"merchant\", \"premium\"]\n" +
"}";
" \"$account_types\" : [\"merchant\", \"premium\"],\n" +
" \"$merchant_profile\" : {\n" +
" \"$merchant_id\" : \"12345\",\n" +
" \"$merchant_category_code\" : \"9876\",\n" +
" \"$merchant_name\" : \"ABC Merchant\",\n" +
" \"$merchant_address\" : {\n" +
" \"$address_1\" : \"2100 Main Street\",\n" +
" \"$address_2\" : \"Apt 3B\",\n" +
" \"$city\" : \"New London\",\n" +
" \"$country\" : \"US\",\n" +
" \"$name\" : \"Bill Jones\",\n" +
" \"$phone\" : \"1-415-555-6040\",\n" +
" \"$region\" : \"New Hampshire\",\n" +
" \"$zipcode\" : \"03257\"\n" +
" }\n" +
" }\n" +
"}\n";

// Start a new mock server and enqueue a mock response.
MockWebServer server = new MockWebServer();
Expand Down Expand Up @@ -99,7 +114,9 @@ public void testUpdateAccount() throws Exception {
.setSocialSignOnType("$twitter")
.setCustomField("email_confirmed_status", "$success")
.setCustomField("phone_confirmed_status", "$success")
.setAccountTypes(Arrays.asList("merchant", "premium")));
.setAccountTypes(Arrays.asList("merchant", "premium"))
.setMerchantProfile(TestUtils.sampleMerchantProfile()));


SiftResponse siftResponse = request.send();

Expand Down

0 comments on commit c138736

Please sign in to comment.