Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private static Order generateOrder() {
address.setProvince("New York");
address.setProvinceCode("NY");
address.setZip("64155");
order.setBillingAddress(address);
order.setBillingAddress(Arrays.asList(address));

return order;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static void main(String[] arg) throws FieldBadFormatException, ParseExcep

try {
// Riskified client parameters can be set in the constructor, like this:
// RiskifiedClient client = new RiskifiedClient("<shop_url>", "<auth_token>", Environment.SANDBOX);
RiskifiedClient client = new RiskifiedClient("shopurl", "authtoken", Environment.SANDBOX);


// Response resAdviseOrder = client.adviseOrder(adviseOrder);
Expand Down Expand Up @@ -89,6 +89,7 @@ public static void main(String[] arg) throws FieldBadFormatException, ParseExcep
System.out.println("description: " + resCreateOrder.getOrder().getDescription());
System.out.println("risk score: " + resCreateOrder.getOrder().getRiskScore());


// Response resChargebackOrder = client.chargebackOrder(chargebackOrder);
//
// System.out.println("-----------------------------------------");
Expand All @@ -106,20 +107,35 @@ public static void main(String[] arg) throws FieldBadFormatException, ParseExcep
// System.out.println("status: " + resDecision.getOrder().getStatus());
// System.out.println("description: " + resDecision.getOrder().getDescription());
// //System.out.println("risk score: " + resDecision.getOrder().getRiskScore());
// Response response = client.analyzeOrder(order);
// System.out.println("-----------------------------------------");
// System.out.println("Create order response:");
// System.out.println("id: " + response.getOrder().getId());
// System.out.println("status: " + response.getOrder().getStatus());
// System.out.println("description: " + response.getOrder().getDescription());
// System.out.println("category: " + response.getOrder().getCategory());
// System.out.println("risk score: " + response.getOrder().getRiskScore());
// if (response.getOrder().getAdvice() != null) {
// for(Recommendation recs: response.getOrder().getAdvice().getRecommendation()){
// System.out.println("rec type: " + recs.getType() + "is recommended: " + recs.getIsRecommended());
// }
//
// }
Response response = client.analyzeOrder(order);
System.out.println("-----------------------------------------");
System.out.println("decide order response:");
System.out.println("id: " + response.getOrder().getId());
System.out.println("status: " + response.getOrder().getStatus());
System.out.println("description: " + response.getOrder().getDescription());
System.out.println("category: " + response.getOrder().getCategory());
System.out.println("risk score: " + response.getOrder().getRiskScore());
System.out.println("risk indicators: " + response.getOrder().getRiskIndicators());
if (response.getOrder().getRiskIndicators() != null) {
RiskIndicators riskIndicators = response.getOrder().getRiskIndicators();

System.out.println("\n=== Risk Indicators ===");

// Option 1: Get all fields and iterate through them
System.out.println("All risk indicator fields:");
for (String fieldName : riskIndicators.getFields()) {
Object value = riskIndicators.get(fieldName);
System.out.println(" " + fieldName + ": " + value);
}

}
if (response.getOrder().getAdvice() != null) {
for(Recommendation recs: response.getOrder().getAdvice().getRecommendation()){
System.out.println("rec type: " + recs.getType() + "is recommended: " + recs.getRecommended());
}

}


/*
Response resScreenOrder = client.screenOrder(screenOrder);
Expand Down Expand Up @@ -339,7 +355,7 @@ private static CheckoutOrder generateCheckoutOrder() throws ParseException {
address.setProvince("New York");
address.setProvinceCode("NY");
address.setZip("64155");
order.setBillingAddress(address);
order.setBillingAddress(Arrays.asList(address));

address = new Address("John", "Doe", "108 Main Street", "NYC", "1234567", "United States");
address.setCompany("Kansas Computers");
Expand Down Expand Up @@ -398,11 +414,11 @@ private static CheckoutOrder generateAdviseOrder() throws ParseException {
address.setProvince("New York");
address.setProvinceCode("NY");
address.setZip("64155");
order.setBillingAddress(address);
order.setBillingAddress(Arrays.asList(address));

address = new Address("John", "Doe", "108 Main Street", "NYC", "1234567", "United States");

order.setShippingAddress((address));
order.setShippingAddress(Arrays.asList(address));


return order;
Expand Down Expand Up @@ -442,35 +458,41 @@ private static ChargebackOrder generateChargebackOrder() throws ParseException {

private static Order generateOrder() throws ParseException {
Order order = new Order();
order.setId("#120000000003460");
order.setId("test_indicator_7");
order.setName("#12345");
order.setEmail("great.customer@example.com");
order.setCreatedAt(parseDate("28-03-2025 00:00:00.0"));
order.setCreatedAt(parseDate("30-09-2025 00:00:00.0"));
order.setClosedAt(parseDate("28-03-2025 00:00:00.0"));
order.setCurrency("CAD");
order.setUpdatedAt(parseDate("11-03-2025 00:00:00.0"));
order.setGateway("mypaymentprocessor");
order.setBrowserIp("124.185.86.55");
order.setGateway("giftcard");
order.setSource("phone");
//order.setBrowserIp("124.185.86.55");
order.setTotalPrice(120.22);
order.setTotalDiscounts(5);
order.setCartToken("1sdaf23j212");
//order.setCartToken("1sdaf23j212");
order.setAdditionalEmails(Arrays.asList("my@email.com", "second@email.co.uk"));
order.setNote("Shipped to my hotel.");
order.setReferringSite("google.com");

Customer customer = new Customer("great.customer@example.com", "john", "smith", "999", parseDate("15-12-2016 00:00:00.0"), true, 10);
Customer customer = new Customer(null, "john", "doe");
//Customer customer = new Customer("great.customer@example.com", "john", "smith", "999", parseDate("15-12-2016 00:00:00.0"), true, 10);
customer.setAccountType("guest");
SocialDetails social = new SocialDetails("Facebook", "john.smith", "http://www.facebook.com/john.smith");
social.setEmail("john.smith@facebook.com");
customer.getSocial().add(social);
//customer.getSocial().add(social);
order.setCustomer(customer);

Recipient lineItemRecipient = new Recipient();
//Wallet wallet = new Wallet();
//wallet.setId("wallet123");
LineItem lineItem = new LineItem(200, 4, "ACME Spring", "AAA2");
lineItem.setColor("black");
Recipient recipient = new Recipient();
//recipient.setRoutingNumber("CNRB008304");
//recipient.setAccountNumber("786868768");
recipient.setEmail("regularLineItem@risky.com");
//lineItem.setRecipient(recipient);
//lineItemRecipient.setWallet(wallet);
lineItemRecipient.setRoutingNumber("CNRB008304");
lineItemRecipient.setAccountNumber("786868768");
lineItemRecipient.setEmail("regularLineItem@risky.com");
lineItem.setRecipient(lineItemRecipient);
//System.out.println("lineItemRecipient : " + lineItemRecipient.getWallet().getId());

TravelLineItem travelLineItem = new TravelLineItem(340, 1, "Flight from Israel to France", "211", "B11", 1, 1);
travelLineItem.setDeparturePortCode("LLBG");
Expand Down Expand Up @@ -516,7 +538,7 @@ private static Order generateOrder() throws ParseException {

cr.setAuthenticationResult(authResults);

order.setPaymentDetails(Arrays.asList( cr ));
//order.setPaymentDetails(Arrays.asList( cr ));


order.setLineItems(Arrays.asList(new LineItem(100, 1, "ACME Widget", "101"), lineItem, travelLineItem));
Expand Down Expand Up @@ -545,7 +567,7 @@ private static Order generateOrder() throws ParseException {



order.setPaymentDetails(Arrays.asList(new CreditCardPaymentDetails("370002", "y", "n", "xxxx-xxxx-xxxx-1234", "VISA"), cr ));
//order.setPaymentDetails(Arrays.asList(new CreditCardPaymentDetails("370002", "y", "n", "xxxx-xxxx-xxxx-1234", "VISA"), cr ));

Address address = new Address("John", "Doe", "108 Main Street", "NYC", "1234567", "United States");
address.setCompany("Kansas Computers");
Expand All @@ -555,7 +577,16 @@ private static Order generateOrder() throws ParseException {
address.setProvince("New York");
address.setProvinceCode("NY");
address.setZip("64155");
order.setBillingAddress(address);

Address address2 = new Address("address2", "Doe", "108 Main Street", "NYC", "1234567", "United States");
address2.setCompany("Kansas Computers");
address2.setCountryCode("US");
address2.setName("John Doe");
address2.setAddress2("Second street");
address2.setProvince("New York");
address2.setProvinceCode("NY");
address2.setZip("64155");
order.setBillingAddress(Arrays.asList(address, address2));

address = new Address("John", "Doe", "108 Main Street", "NYC", "1234567", "United States");
address.setCompany("Kansas Computers");
Expand All @@ -565,7 +596,17 @@ private static Order generateOrder() throws ParseException {
address.setProvince("New York");
address.setProvinceCode("NY");
address.setZip("64155");
order.setShippingAddress((address));

address2 = new Address("address2", "Doe", "108 Main Street", "NYC", "1234567", "United States");
address2.setCompany("Kansas Computers");
address2.setCountryCode("US");
address2.setName("John Doe");
address2.setAddress2("Second street");
address2.setProvince("New York");
address2.setProvinceCode("NY");
address2.setZip("64155");
order.setShippingAddress(Arrays.asList(address, address2));


return order;
}
Expand Down Expand Up @@ -658,7 +699,7 @@ private static CheckoutOrder generateScreenOrder() throws ParseException {
address.setProvince("New York");
address.setProvinceCode("NY");
address.setZip("64155");
order.setBillingAddress(address);
order.setBillingAddress(Arrays.asList(address));

address = new Address("John", "Doe", "108 Main Street", "NYC", "1234567", "United States");
address.setCompany("Kansas Computers");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ private static Order generateOrder() {
address.setProvince("New York");
address.setProvinceCode("NY");
address.setZip("64155");
order.setBillingAddress(address);
order.setBillingAddress(Arrays.asList(address));

address = new Address("John", "Doe", "108 Main Street", "NYC", "1234567", "United States");
address.setCompany("Kansas Computers");
Expand Down
2 changes: 1 addition & 1 deletion riskified-sdk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.riskified</groupId>
<artifactId>riskified-sdk</artifactId>
<version>v3.3.0</version>
<version>v4.0.0</version>
<name>Riskified SDK</name>
<description>Riskified rest api SDK for java</description>
<url>https://www.riskified.com</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,7 @@ private HttpPost createPostRequest(String url) {
postRequest.setHeader(HttpHeaders.ACCEPT, "application/vnd.riskified.com; version=2");
postRequest.setHeader(HttpHeaders.ACCEPT, "application/json");
postRequest.setHeader("X-RISKIFIED-SHOP-DOMAIN", shopUrl);
postRequest.setHeader("User-Agent","riskified_java_sdk/3.3.0"); // TODO: take the version automatically
postRequest.setHeader("User-Agent","riskified_java_sdk/4.0.0"); // TODO: take the version automatically
postRequest.setHeader("Version",versionHeaderValue);
return postRequest;
}
Expand Down
20 changes: 11 additions & 9 deletions riskified-sdk/src/main/java/com/riskified/models/BaseOrder.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public abstract class BaseOrder implements IValidated {
private String vendorId;
private String vendorName;
private String vendorIntegrationType;
private Address shippingAddress;
private Address billingAddress;
private List<Address> shippingAddress;
private List<Address> billingAddress;
private List<? extends IPaymentDetails> paymentDetails;
private ClientDetails clientDetails;
private List<DiscountCode> discountCodes;
Expand Down Expand Up @@ -141,13 +141,15 @@ public void validate(Validation validationType) throws FieldBadFormatException {
}

if (this.billingAddress != null) {
this.billingAddress.validate(validationType);
for (Address billingAddress : this.billingAddress) {
billingAddress.validate(validationType);
}
}

if (this.shippingAddress != null) {
// for (Address shippingAddress : this.shippingAddress) {
for (Address shippingAddress : this.shippingAddress) {
shippingAddress.validate(validationType);
// }
}
}
if (this.decision != null) {
this.decision.validate(validationType);
Expand Down Expand Up @@ -534,17 +536,17 @@ public void setVendorIntegrationType(String vendorIntegrationType) {
this.vendorIntegrationType = vendorIntegrationType;
}

public Address getShippingAddress() {return shippingAddress;}
public List<Address> getShippingAddress() {return shippingAddress;}

public void setShippingAddress(Address shippingAddress) {
public void setShippingAddress(List<Address> shippingAddress) {
this.shippingAddress = shippingAddress;
}

public Address getBillingAddress() {
public List<Address> getBillingAddress() {
return billingAddress;
}

public void setBillingAddress(Address billingAddress) {
public void setBillingAddress(List<Address> billingAddress) {
this.billingAddress = billingAddress;
}

Expand Down
10 changes: 5 additions & 5 deletions riskified-sdk/src/main/java/com/riskified/models/Recipient.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class Recipient implements IValidated {
private Date createdAt;
private Date updatedAt;
private boolean selfRecipient;
private String walletId;
private Wallet wallet;

public Recipient() {
}
Expand Down Expand Up @@ -81,11 +81,11 @@ public void setSelfRecipient(boolean selfRecipient) {
this.selfRecipient = selfRecipient;
}

public String getWalletId(){
return walletId;
public Wallet getWallet(){
return wallet;
}

public void setWalletId(String walletId){
this.walletId = walletId;
public void setWallet(Wallet wallet){
this.wallet = wallet;
}
}
3 changes: 3 additions & 0 deletions riskified-sdk/src/main/java/com/riskified/models/UseCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ public void setUseCase(String useCase) {
public String getDecision() {
return decision;
}
public void setDecision(String decision) {
this.decision = decision;
}
}
24 changes: 24 additions & 0 deletions riskified-sdk/src/main/java/com/riskified/models/Wallet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.riskified.models;

import com.riskified.validations.FieldBadFormatException;
import com.riskified.validations.IValidated;
import com.riskified.validations.Validation;

public class Wallet implements IValidated {
String id;


public Wallet() {
}

public void validate(Validation validationType)
throws FieldBadFormatException {
}

public String getId() {
return this.id;
}
public void setId(String id) {
this.id = id;
}
}
Loading