Usage examples

Examples to use with the Fraud Prevention SDK for Node.js to implement common workflows

|

OrderPurchaseScreen

Request object

{
  "transaction": {
    "site_info": {
      "country_code": "USA",
      "agent_assisted": false
    },
    "device_details": {
      "device_box": "TrustWidget",
      "ip_address": "1.1.1.1"
    },
    "customer_account": {
      "account_type": "STANDARD",
      "name": {
        "last_name": "Smith",
        "first_name": "John"
      },
      "email_address": "test@example.com"
    },
    "transaction_details": {
      "order_id": "33322220004",
      "current_order_status": "IN_PROGRESS",
      "order_type": "CREATE",
      "travel_products": [
        {
          "price": {
            "value": 100,
            "currency_code": "USD"
          },
          "inventory_type": "Agency",
          "inventory_source": "AGENCY",
          "travelers_references": [
            "Reference"
          ],
          "pick_up_location": "pick up location",
          "drop_off_location": "drop off location",
          "pickup_time": "2023-01-18T05:00:00.000Z",
          "return_time": "2023-01-08T04:30:00.000Z",
          "type": "CAR"
        }
      ],
      "travelers": [
        {
          "traveler_name": {
            "last_name": "Brown",
            "first_name": "Sally"
          },
          "email_address": "imsafe@example.com",
          "telephones": [
            {
              "type": "HOME",
              "country_access_code": "1",
              "area_code": "962",
              "phone_number": "1234567"
            }
          ],
          "primary": true,
          "birth_date": "1970-04-08T05:45:00.000Z"
        }
      ],
      "payments": [
        {
          "brand": "VISA",
          "billing_name": {
            "last_name": "Brown",
            "first_name": "Sally"
          },
          "billing_address": {
            "address_line1": "address",
            "city": "city",
            "zip_code": "11183",
            "country_code": "USA"
          },
          "billing_email_address": "sally@example.com",
          "authorized_amount": {
            "value": 100,
            "currency_code": "USD"
          },
          "verified_amount": {
            "value": 123,
            "currency_code": "USD"
          },
          "card_type": "MASTER_CARD",
          "card_number": "4111111111111111",
          "expiry_date": "2027-04-08T05:00:00.000Z",
          "card_avs_response": "Z",
          "card_cvv_response": "0",
          "telephones": [
            {
              "type": "HOME",
              "country_access_code": "1",
              "area_code": "962",
              "phone_number": "1234567"
            }
          ],
          "method": "CREDIT_CARD"
        }
      ]
    }
  }
}

SDK example

let siteInfo = new SiteInfo({
    countryCode: "USA",
    agentAssisted: false
})

let deviceDetails = new DeviceDetails({
    deviceBox: "TrustWidget",
    ipAddress: "1.1.1.1"
})

let customerAccount = new CustomerAccount({
    accountType: "STANDARD",
    name: new Name({
        firstName: "John",
        lastName: "Smith"
    }),
    emailAddress: "test@example.com"
})

let telephones = [
    new Telephone({
        type: "HOME",
        countryAccessCode: "1",
        areaCode: "962",
        phoneNumber: "1234567"
    })]

let birthDate = new Date("1970-04-08T08:45:00.000")

let travelerName = new Name({
    firstName: "Sally",
    lastName: "Brown"
})

let travelers = [
    new Traveler({
        emailAddress: "imsafe@example.com",
        primary: true,
        telephones: telephones,
        travelerName: travelerName,
        birthDate: birthDate
    })
]

let price = new Amount({
    currencyCode: "USD",
    value: 100
})

let returnTime = new Date("2023-01-08T07:30:00.000")
let pickupTime = new Date("2023-01-18T08:00:00.000")

let travelProducts = [
    new Car({
        inventoryType: "Agency",
        inventorySource: "AGENCY",
        travelersReferences: ["Reference"],
        price: price,
        pickUpLocation: "pick up location",
        dropOffLocation: "drop off location",
        returnTime: returnTime,
        pickupTime: pickupTime
    })
]

let expiryDate = new Date("2027-04-08T08:00:00.000")

let payments = [
    new CreditCard({
        billingName: new Name({
            firstName: "Sally",
            lastName: "Brown"
        }),
        brand: "VISA",
        authorizedAmount: new Amount({
            value: 100,
            currencyCode: "USD"
        }),
        verifiedAmount: new Amount({
            value: 123,
            currencyCode: "USD"
        }),
        cardAvsResponse: "Z",
        cardCvvResponse: "0",
        billingEmailAddress: "sally@example.com",
        cardNumber: "4111111111111111",
        telephones: telephones,
        cardType: "MASTER_CARD",
        expiryDate: expiryDate,
        billingAddress: new PaymentBillingAddress({
            zipCode: "11183",
            addressLine1: "address",
            city: "city",
            countryCode: "USA"
        })
    })
]

let transactionDetails = new TransactionDetails({
    orderId: "33322220004",
    currentOrderStatus: "IN_PROGRESS",
    orderType: "CREATE",
    travelers: travelers,
    travelProducts: travelProducts,
    payments: payments
})

let transaction = new OrderPurchaseTransaction({
    siteInfo: siteInfo,
    deviceDetails: deviceDetails,
    customerAccount: customerAccount,
    transactionDetails: transactionDetails
})

let request = new OrderPurchaseScreenRequest({
    transaction: transaction
})

let fraudPreventionClient = new FraudPreventionV2Client({
    key: "KEY",
    secret: "SECRET",
    endpoint: "https://api.expediagroup.com",
    authEndpoint: "https://api.expediagroup.com/identity/oauth2/v3/token?grant_type=client_credentials"
})

let fraudPreventionClient = new FraudPreventionV2Client({ })

let response = fraudPreventionClient.screenOrder(request)

OrderPurchaseUpdate: Order Update

Request object

{
  "type": "ORDER_UPDATE",
  "risk_id": "RISK_ID",
  "order_status": "COMPLETED",
  "acquirer_reference_number": null,
  "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

let cancellationReason = new CancellationReason({
  primaryReasonCode: "Primary reason code",
  subReasonCode: "Sub reason code",
  primaryReasonDescription: "Primary reason description",
  subReasonDescription: "Sub reason description"
})

let orderUpdate = new OrderUpdate({
  riskId: "Risk ID",
  orderStatus: "COMPLETED",
  cancellationReason: cancellationReason
})

let fraudPreventionClient = new FraudPreventionV2Client({ })

let response = fraudPreventionClient.notifyWithOrderUpdate(orderUpdate)

OrderPurchaseUpdate: Chargeback Feedback

Request object

{
  "type": "CHARGEBACK_FEEDBACK",
  "risk_id": "Risk ID",
  "chargeback_detail": {
    "chargeback_status": "RECEIVED",
    "chargeback_reason": "FRAUD",
    "chargeback_amount": {
      "value": 100.0,
      "currency_code": "USD"
    },
    "bank_reason_code": "Bank reason code",
    "chargeback_reported_date_time": "2023-06-05T15:31:02.882011+03:00"
  }
}

SDK example

let chargebackDetail = new ChargebackDetail({
  chargebackReason: "FRAUD",
  chargebackAmount: new Amount({
    value: 100,
    currencyCode: "USD"
  }),
  bankReasonCode: "Bank reason code",
  chargebackReportedDateTime: new Date("2023-06-05T15:31:02.882011"),
  chargebackStatus: "RECEIVED"
})

let chargebackFeedback = new ChargebackFeedback({
  riskId: "Risk ID",
  chargebackDetail: chargebackDetail
})

let fraudPreventionClient = new FraudPreventionV2Client({ })

let response = fraudPreventionClient.notifyWithOrderUpdate(chargebackFeedback)

OrderPurchaseUpdate: Insult Feedback

Request object

{
  "type": "INSULT_FEEDBACK",
  "risk_id": "RISK_ID",
  "insult_detail": {
    "insult_reported_date_time": "2023-06-05T15:31:03.361215+03:00"
  }
}

SDK example

let insultDetail = new InsultDetail({
  insultReportedDateTime: new Date("2023-06-05T15:31:03.361215")
})

let insultFeedback = new InsultFeedback({
  riskId: "Risk ID",
  insultDetail: insultDetail
})

let fraudPreventionClient = new FraudPreventionV2Client({ })

let response = fraudPreventionClient.notifyWithOrderUpdate(insultFeedback)

OrderPurchaseUpdate: Issued Refund Update

Request object

{
  "refundStatus": "ISSUED",
  "risk_id": "RISK_ID",
  "refund_details": {
    "refund_issued_date_time": "2023-06-05T15:31:03.957554+03:00",
    "refund_issued_amount": {
      "value": 100.0,
      "currency_code": "USD"
    }
  },
  "type": "REFUND_UPDATE",
  "refund_status": "ISSUED"
}

SDK example

let issuedRefundUpdateDetails = new IssuedRefundUpdateDetails({
  refundIssuedDateTime: new Date("2023-06-05T15:31:03.957554"),
  refundIssuedAmount = new Amount({
    value: 100,
    currencyCode: "USD"
  })
})

let issuedRefundUpdate = new IssuedRefundUpdate({
  riskId: "Risk ID",
  refundDetails: issuedRefundUpdateDetails
})

let fraudPreventionClient = new FraudPreventionV2Client({ })

let response = fraudPreventionClient.notifyWithOrderUpdate(issuedRefundUpdate)

OrderPurchaseUpdate: Settled Refund Update

Request object

{
  "refundStatus": "SETTLED",
  "risk_id": "RISK_ID",
  "refund_details": {
    "refund_settlement_date_time": "2023-06-05T15:31:04.363157+03:00",
    "refund_deposit_date_time": "2023-06-05T15:31:04.363193+03:00",
    "acquirer_reference_number": "ACQUIRER_REF_NUMBER",
    "settlement_id": "SETTLEMENT_ID",
    "refund_settled_amount": {
      "value": 100.0,
      "currency_code": "USD"
    }
  },
  "type": "REFUND_UPDATE",
  "refund_status": "SETTLED"
}

SDK example

let settledRefundUpdateDetails = new SettledRefundUpdateDetails({
  refundSettlementDateTime: new Date("2023-06-05T15:31:04.363157"),
  refundDepositDateTime: new Date("2023-06-05T15:31:04.363193"),
  acquirerReferenceNumber: "Acquirer referncer number",
  settlementId: "Settlement ID",
  refundSettledAmount: new Amount({
    value: 100,
    currencyCode: "USD"
  })
})

let settledRefundUpdate = new SettleRefundUpdate({
  riskId: "Risk ID",
  refundDetails: settledRefundUpdateDetails
})

let fraudPreventionClient = new FraudPreventionV2Client({ })

let response = fraudPreventionClient.notifyWithOrderUpdate(settledRefundUpdate)

OrderPurchaseUpdate: Payment Update

Request object

{
  "type": "PAYMENT_UPDATE",
  "risk_id": "Risk ID",
  "merchant_order_code": "Merchant order code"
}

SDK example

let paymentUpdate = new PaymentUpdate({
  riskId: "Risk ID",
  merchantOrderCode: "Merchant order code"
})

let fraudPreventionClient = new FraudPreventionV2Client({ })

let response = fraudPreventionClient.notifyWithOrderUpdate(paymentUpdate)

AccountTakeoverScreen

Request object

{
  "transaction": {
    "site_info": {
      "locale": "en-US",
      "name": "expedia.com",
      "brand_name": "BRAND_NAME",
      "placement_name": "LOGIN"
    },
    "device_details": {
      "source": "SOURCE",
      "device_box": "DEVICE_BOX",
      "ip_address": "127.0.0.1",
      "user_agent": "USER_AGENT",
      "type": "WEBSITE"
    },
    "customer_account": {
      "user_id": "USER_ID",
      "account_type": "INDIVIDUAL",
      "account_role": "USER",
      "name": {
        "last_name": "LAST_NAME",
        "first_name": "FIRST_NAME",
        "middle_name": "MIDDLE_NAME",
        "title": "TITLE",
        "suffix": "SUFFIX"
      },
      "username": "USERNAME",
      "email_address": "user@example.com",
      "telephones": [
        {
          "type": "HOME",
          "platform_type": "MOBILE",
          "country_access_code": "1",
          "area_code": "123",
          "phone_number": "123456",
          "extension_number": "123",
          "preference_rank": 0,
          "last_verified_date_time": "1970-01-01T00:00:00+00:00",
          "verified_flag": false
        }
      ],
      "address": {
        "address_type": "HOME",
        "address_line1": "ADDRESS_LINE1",
        "address_line2": "ADDRESS_LINE2",
        "city": "CITY",
        "state": "AB",
        "zip_code": "ZIP_CODE",
        "country_code": "ABC"
      },
      "registered_time": "1970-01-01T00:00:00+00:00",
      "active_flag": false,
      "loyalty_member_id": "LOYALTY_MEMBER_ID"
    },
    "transaction_details": {
      "type": "LOGIN",
      "transaction_date_time": "1970-01-01T00:00:00+00:00",
      "transaction_id": "TRANSACTION_ID",
      "current_user_session": {
        "session_id": "SESSION_ID",
        "start_date_time": "1970-01-01T00:00:00+00:00",
        "challenge_detail": {
          "displayed_flag": false,
          "type": "CAPTCHA",
          "status": "SUCCESS"
        }
      },
      "authentication_type": "CREDENTIALS",
      "authentication_sub_type": "EMAIL",
      "successful_login_flag": false,
      "failed_login_reason": "INVALID_CREDENTIALS"
    }
  }
}

SDK example

let siteInfo = new AccountTakeoverSiteInfo({
    locale: "en-US",
    name: "expedia.com",
    brandName: "BRAND_NAME",
    placementName: "LOGIN"
})

let deviceDetails = new AccountTakeoverDeviceDetails({
    source: "SOURCE",
    deviceBox: "DEVICE_BOX",
    ipAddress: "127.0.0.1",
    userAgent: "USER_AGENT",
    type: "WEBSITE"
})

let name = new AccountTakeoverName({
    firstName: "FIRST_NAME",
    middleName: "MIDDLE_NAME",
    lastName: "LAST_NAME",
    suffix: "SUFFIX",
    title: "TITLE"
})

let telephone = new Telephone({
    type: "HOME",
    platformType: "MOBILE",
    countryAccessCode: "1",
    areaCode: "123",
    phoneNumber: "123456",
    extensionNumber: "123",
    preferenceRank: 0,
    lastVerifiedDateTime: new Date("1970-01-01T00:00:00.000Z"),
    verifiedFlag: false
})

let address = new CustomerAccountAddress({
    addressType: "HOME",
    addressLine1: "ADDRESS_LINE1",
    addressLine2: "ADDRESS_LINE2",
    city: "CITY",
    state: "AB",
    zipCode: "ZIP_CODE",
    countryCode: "ABC"
})

let customerAccount = new AccountTakeoverCustomerAccount({
    userId: "USER_ID",
    accountType: "INDIVIDUAL",
    accountRole: "USER",
    name: name,
    username: "USERNAME",
    emailAddress: "user@example.com",
    telephones: [telephone],
    address: address,
    registeredTime: new Date("1970-01-01T00:00:00.000Z"),
    activeFlag: false,
    loyaltyMemberId: "LOYALTY_MEMBER_ID"
})

let challengeDetail = new ChallengeDetail({
    displayedFlag: false,
    type: "CAPTCHA",
    status: "SUCCESS"
})

let currentUserSession = new CurrentUserSession({
    sessionId: "SESSION_ID",
    startDateTime: new Date("1970-01-01T00:00:00.000Z"),
    challengeDetail: challengeDetail
})

let transactionId = "TRANSACTION_ID"

let transactionDetails = new LoginTransactionDetails({
    transactionDateTime: new Date("1970-01-01T00:00:00.000Z"),
    transactionId: transactionId,
    currentUserSession: currentUserSession,
    authenticationType: "CREDENTIALS",
    authenticationSubType: "EMAIL",
    successfulLoginFlag: false,
    failedLoginReason: "INVALID_CREDENTIALS"
})

let transaction = new AccountTransaction({
    siteInfo: siteInfo,
    deviceDetails: deviceDetails,
    customerAccount: customerAccount,
    transactionDetails: transactionDetails
})

let accountScreenRequest = new AccountScreenRequest({transaction: transaction})

let fraudPreventionClient = new FraudPreventionV2Client({
    key: "KEY",
    secret: "SECRET",
})

let response = fraudPreventionClient.screenAccount(accountScreenRequest)

AccountTakeoverUpdate: Multifactor Authentication Update

Request

{
  "type": "MULTI_FACTOR_AUTHENTICATION_UPDATE",
  "risk_id": "RISK_ID",
  "multi_factor_authentication_attempts": [
    {
      "delivery_method": "SMS",
      "status": "SUCCESS",
      "reference_id": "REF_ID",
      "provider_name": "PROVIDER_NAME",
      "attempt_count": 1,
      "update_start_date_time": "1970-01-01T00:00:00+00:00",
      "update_end_date_time": "1970-01-01T00:00:00+00:00",
      "telephone": {
        "country_access_code": "1",
        "area_code": "123",
        "phone_number": "123456"
      }
    }
  ]
}

SDK Example

let telephone = new Telephone({
    countryAccessCode: "1",
    areaCode: "123",
    phoneNumber: "123456"
})

let multiFactorAuthAttempt = new MultiFactorAuthenticationAttempt({
    deliveryMethod: "SMS",
    status: "SUCCESS",
    referenceId: "REF_ID",
    providerName: "PROVIDER_NAME",
    attemptCount: 1,
    updateStartDateTime: new Date("1970-01-01T00:00:00.000Z"),
    updateEndDateTime: new Date("1970-01-01T00:00:00.000Z"),
    telephone: telephone
})

let multifactorAuthUpdate = new MultiFactorAuthenticationUpdate({
    riskId: "RISK_ID",
    multiFactorAuthenticationAttempts: [multiFactorAuthAttempt]
})

let fraudPreventionClient = new FraudPreventionV2Client({
    key: "KEY",
    secret: "SECRET"
})

let response = fraudPreventionClient.notifyWithAccountUpdate(multifactorAuthUpdate)

AccountTakeoverUpdate: Remediation Update

Request

{
  "type": "REMEDIATION_UPDATE",
  "risk_id": "RISK_ID",
  "remediation_update_actions": [
    {
      "action_name": "PASSWORD_RESET",
      "status": "SUCCESS",
      "update_end_date_time": "1970-01-01T00:00:00+00:00"
    }
  ]
}

SDK Example

let remediationUpdateAction = new RemediationUpdateAction({
    actionName: "PASSWORD_RESET",
    status: "SUCCESS",
    updateEndDateTime: new Date("1970-01-01T00:00:00.000Z")
})

let remediationUpdate = new RemediationUpdate({
    riskId: "RISK_ID",
    remediationUpdateActions: [remediationUpdateAction]
})

let fraudPreventionClient = new FraudPreventionV2Client({
    key: "KEY",
    secret: "SECRET",
})

let response = fraudPreventionClient.notifyWithAccountUpdate(remediationUpdate)
Did you find this page helpful?
How can we improve this content?
Thank you for helping us improve Developer Hub!