SDK Usage Examples

Screen Order

Request Object

{
  "transaction": {
    "site_info": {
      "country_code": "USA",
      "agent_assisted": "false"
    },
    "device_details": {
      "device_box": "TrustWidget"
    },
    "customer_account": {
      "account_type": "STANDARD",
      "email_address": "riskrtest@expedia.com"
    },
    "transaction_details": {
      "order_id": "33322220004",
      "current_order_status": "IN_PROGRESS",
      "order_type": "CREATE",
      "travelers": [
        {
          "email_address": "imsafe@gmail.com",
          "primary": true,
          "birth_date": "2020-04-15T08:00:00.000-0700",
          "telephones": [
            {
              "type": "Home",
              "country_access_code": "1",
              "area_code": "1",
              "phone_number": "1234567"
            }
          ],
          "traveler_name": {
            "first_name": "Sally",
            "last_name": "Brown"
          }
        }
      ],
      "travel_products": [
        {
          "type": "Car",
          "inventory_source": "AGENCY",
          "inventory_type": "InventoryType",
          "travelers_reference": [],
          "price": {
            "currency_code": "USD",
            "value": 100
          },
          "pick_up_location": "pick up location",
          "drop_off_location": "drop off location",
          "return_time": "2020-04-08T07:30:00.000-0700",
          "pickup_time": "2020-04-15T08:00:00.000-0700"
        }
      ],
      "payments": [
        {
          "method": "CREDIT_CARD",
          "billing_name": {
            "first_name": "Sally",
            "last_name": "Brown"
          },
          "brand": "Visa",
          "authorized_amount": {
            "currency_code": "USD",
            "value": 100
          },
          "card_avs_response": "Z",
          "billing_email_address": "sally@example.com"
        }
      ]
    }
  }
}

SDK Example

SiteInfo siteInfo = SiteInfo.builder().countryCode("USA").agentAssisted(false).build();
DeviceDetails deviceDetails = DeviceDetails.builder().deviceBox("TrustWidget").build();
CustomerAccount customerAccount =
  CustomerAccount.builder()
    .accountType(CustomerAccount.AccountType.STANDARD)
    .name(Name.builder().firstName("John").lastName("Smith").build())
    .emailAddress("test@example.com")
    .build();

List<Telephone> telephones = List.of(
  Telephone.builder()
    .type(TelephoneType.HOME)
    .countryAccessCode("1")
    .areaCode("962")
    .phoneNumber("1234567")
    .build());

OffsetDateTime birthDate =
  OffsetDateTime.of(
    LocalDate.of(1970, 4, 8),
    LocalTime.of(8, 0),
    ZoneOffset.of("-07:00")
  );

List<Traveler> travelers = List.of(
  Traveler.builder()
    .emailAddress("imsafe@example.com")
    .primary(true)
    .telephones(telephones)
    .travelerName(Name.builder().firstName("Sally").lastName("Brown").build())
    .birthDate(birthDate)
    .build());

Amount price =
  Amount.builder()
    .currencyCode("USD")
    .value(100)
    .build();

OffsetDateTime returnTime =
  OffsetDateTime.of(
    LocalDate.of(2023, 1, 8),
    LocalTime.of(7, 30),
    ZoneOffset.of("-07:00")
  );

OffsetDateTime pickupTime =
  OffsetDateTime.of(
    LocalDate.of(2023, 1, 18),
    LocalTime.of(8, 0),
    ZoneOffset.of("-07:00")
  );

List<TravelProduct> travelProducts = List.of(
  Car.builder()
    .inventoryType("Agency")
    .inventorySource(TravelProduct.InventorySource.AGENCY)
    .travelersReferences(List.of())
    .price(price)
    .pickUpLocation("pick up location")
    .dropOffLocation("drop off location")
    .returnTime(returnTime)
    .pickupTime(pickupTime)
    .type("Car")
    .build());

List<CreditCard> payments = List.of(
  CreditCard.builder()
    .method(PaymentMethod.CREDIT_CARD)
    .billingName(Name.builder().firstName("Sally").lastName("Brown").build())
    .brand("Visa")
    .authorizedAmount(Amount.builder().value(100).currencyCode("USD").build())
    .verifiedAmount(Amount.builder().value(123).currencyCode("US").build())
    .cardAvsResponse("Z")
    .cardCvvResponse("0")
    .billingEmailAddress("sally@example.com")
    .cardNumber("4111111111111111")
    .telephones(telephones)
    .cardType("dd")
    .build());

TransactionDetails transactionDetails =
  TransactionDetails.builder()
    .orderId("33322220004")
    .currentOrderStatus(TransactionDetails.CurrentOrderStatus.IN_PROGRESS)
    .orderType(TransactionDetails.OrderType.CREATE)
    .travelers(travelers)
    .travelProducts(travelProducts)
    .payments(payments)
    .build();

OrderPurchaseTransaction transaction =
  OrderPurchaseTransaction.builder()
    .siteInfo(siteInfo)
    .deviceDetails(deviceDetails)
    .customerAccount(customerAccount)
    .transactionDetails(transactionDetails)
    .bypassRiskFlag(true)
    .build();

OrderPurchaseScreenRequest request =
  OrderPurchaseScreenRequest.builder().transaction(transaction).build();

FraudPreventionClient fraudPreventionClient = FraudPreventionClient.builder().build();

OrderPurchaseScreenResponse response = fraudPreventionClient.screen(request);

Response Object

{
  "RISK_ID": "RISK_ID",
  "decision": "ACCEPT",
  "error_detail": null
}

Order Update

Request Object

{
  "type": "ORDER_UPDATE",
  "risk_id": "RISK_ID",
  "order_status": "COMPLETED",
  "cancellation_reason": {
    "primary_reason_code": "PRIMARY REASON CODE",
    "sub_reason_code": "SUB REASON CODE",
    "primary_reason_description": "PRIMARY REASON DESCRIPTION",
    "sub_reason_description": "SUB REASON DESCRIPTION"
  }
}

SDK Example

CancellationReason cancellationReason =
  CancellationReason.builder()
    .primaryReasonCode("PRIMARY REASON CODE")
    .subReasonCode("SUB REASON CODE")
    .primaryReasonDescription("PRIMARY REASON DESCRIPTION")
    .subReasonDescription("SUB REASON DESCRIPTION")
    .build();

OrderUpdate orderUpdate =
  OrderUpdate.builder()
    .type(UpdateType.ORDER_UPDATE)
    .riskId("RISK_ID")
    .orderStatus(Status.COMPLETED)
    .cancellationReason(cancellationReason)
    .build();

FraudPreventionClient fraudPreventionClient = FraudPreventionClient.builder().build();

fraudPreventionClient.update(orderUpdate);
Did you find this page helpful?
How can we improve this content?
Thank you for helping us improve Developer Hub!