# Native Mobile App Tests

## [Native Mobile App Testing](https://docs.forter.com/extensions/native-mobile-app-tests#native-mobile-app-testing)

### [App Testing Overview](https://docs.forter.com/extensions/native-mobile-app-tests#app-testing-overview)

If you have native applications for iOS or Android, we recommend integrating our mobile SDKs in order to ensure accurate decisions for this order segment. We have dedicated sections outlining the recommended integrations for [iOS](https://docs.forter.com/mobile-sdks/ios-sdk-overview "iOS") and [Android](https://docs.forter.com/mobile-sdks/android-sdk-overview "Android").

### [Step 1: Retrieve the forterMobileUID](https://docs.forter.com/extensions/native-mobile-app-tests#step-1-retrieve-the-fortermobileuid)  
Once you've installed the relevant Forter mobile SDKs, make sure that the SDK is generating a unique device identifier. This identifier should be specific to the device (such as the [IDFV](https://developer.apple.com/documentation/uikit/uidevice/1620059-identifierforvendor "IDFV") for iOS and [Device Identifier for Android](https://developer.android.com/training/articles/user-data-ids "Device Identifier for Android") and it should persist across multiple user sessions.

When a customer makes a purchase from the mobile app, the unique Identifier should **also** be included as the _forterMobileUID_ value in the connectionInformation object of the [Order API](https://docs.forter.com/reference/order-v3 "Order API"). Since the Order API call is server-to-server, this value, along with the customer's IP address and userAgent data should be retrieved from your HTTPS request headers and passed to the SFCC cartridge.

### [Step 2: Update OrderType](https://docs.forter.com/extensions/native-mobile-app-tests#step-2-update-ordertype)
Make sure that the orderType field in the ForterOrder.ds file is updated to the "MOBILE" enum value.

#### [Step 2.2 Mobile App Order Mapping](https://docs.forter.com/extensions/native-mobile-app-tests#step-22-mobile-app-order-mapping)  
The below code represents a mapped mobile app order for an SFRA Adyen integration. Please note that the following fields in the connectionInformation object have been updated:

- **orderType** - This should always be "MOBILE" for transactions placed on an app
- **forterMobileUID** - This should correspond to the ID that is passed to the mobile SDK and included in the backend order request. It **replaces** the forterTokenCookie value for mobile orders
- **customerIP** - This should be the IP that corresponds to the end user's device. NOT the IP of your server.

Below is an example of how the connectionInformation object should appear for a native mobile app order:

```java
{
  "orderId": "Example_order_fdse0rr489",
  "orderType": "MOBILE",
  "timeSentToForter": 1415287568000,
  "checkoutTime": 1415273168,
  "connectionInformation": {
    "customerIP": "107.57.208.5",
    "userAgent": "testStore 18.4.1 rv:184100001 (iPhone; iOS 12.4.1; en_US; iPhone10,3)",
    "forterMobileUID": "6A9798AG16FF41F7B6B9878DD488ADD5", // pass unique Identifier here
    "mobileAppVersion": "18.4.1"
  },
  "totalAmount": {
    "amountUSD": "99.95"
  }
}
```

### [Sample Mobile Order](https://docs.forter.com/extensions/native-mobile-app-tests#sample-mobile-order)  
```javascript
var ForterLogger = require("int_forter/cartridge/scripts/lib/forter/ForterLogger.ds");
/**
 * ForterOrder class is the DTO object for request.
 * To include this script use:
 * var ForterOrder = require("int_forter/cartridge/scripts/lib/forter/dto/ForterOrder.ds");
 */
function ForterOrder(args) {
  var log = new ForterLogger("ForterOrder.ds"),
      order = args.Order,
      site = dw.system.Site.getCurrent(),
      paymentInstruments = order.getPaymentInstruments(),
      a = null,
      authResponse = null,
      shipment = null;
  /* Implementation details for the order processing... */
}
```

### [Step 3: Testing](https://docs.forter.com/extensions/native-mobile-app-tests#step-3-testing)

#### [Normal QA email address](https://docs.forter.com/extensions/native-mobile-app-tests#normal-qa-email-address)  
Place a phone order in your sandbox environment using any valid test email address. The transaction should show in the [portal transactions tab](https://portal.forter.com/transactions "portal transactions tab") and include a mobile phone icon next to the order number.

#### [Declined by Forter](https://docs.forter.com/extensions/native-mobile-app-tests#declined-by-forter) 
Place a purchase with email address decline@forter.com using a valid test card credit card or payment method. This email address will always generate a "decline" decision in Forter's sandbox environment and will enable you to test your SFCC cartridge flow for a declined mobile transaction. Once you've placed this declined order, please check your cartridge business manager and review and (potentially update) your processorResponse.json file to either void funds and cancel declined mobile app orders.

#### [Approved by Forter](https://docs.forter.com/extensions/native-mobile-app-tests#approved-by-forter)  
Create an order using approve@forter.com and a valid test card for the transaction. This will generate an "approve" decision and the transaction should show in the [portal transactions tab](https://portal.forter.com/transactions " portal transactions tab") and include a mobile icon next to the order number. Make sure to review and update your processorResponse.json file to capture the funds and proceed with this order in your OMS.
