---
title: ネイティブモバイルアプリテスト
slug: I0MeCVDTl7SMT-Il_QVWN
createdAt: 2025-07-30T21:22:24.109Z
---

# ネイティブモバイルアプリのテスト

## アプリテストの概要

iOSまたはAndroidのネイティブアプリケーションをお持ちの場合は、この注文セグメントの正確な判断を確保するために、当社のモバイルSDKを統合することをお勧めします。 [iOS](https://docs.forter.com/mobile-sdks/ios-sdk-overview) と [Android](https://docs.forter.com/mobile-sdks/android-sdk-overview) の推奨統合について説明する専用セクションがあります。

## ステップ1: `forterMobileUID`

関連するForterモバイルSDKをインストールしたら、SDKがユニークなデバイス識別子を生成していることを確認してください。この識別子はデバイス固有である必要があります（例えば、[IDFV](https://developer.apple.com/documentation/uikit/uidevice/1620059-identifierforvendor)) iOS用と [Android用のデバイス識別子](https://developer.android.com/training/articles/user-data-ids) であり、複数のユーザーセッションにわたって持続する必要があります。

顧客がモバイルアプリから購入を行うと、ユニークな識別子は *forterMobileUID* 値として `connectionInformation` オブジェクトに含まれる必要があります。[Order API](https://docs.forter.com/reference/order-v3)。Order APIの呼び出しはサーバー間で行われるため、この値は顧客のIPアドレスやuserAgentデータとともに、HTTPSリクエストヘッダーから取得し、SFCCカートリッジに渡す必要があります。

## ステップ 2: 注文タイプの更新

「`orderType`」フィールドは、`ForterOrder.ds`ファイルで「`"MOBILE"`」列挙値に更新されていることを確認してください。

### ステップ 2.2 モバイルアプリ注文マッピング

以下のコードは、SFRA Adyen統合のためのマッピングされたモバイルアプリ注文を表しています。以下の「`connectionInformation`」オブジェクトのフィールドが更新されていることに注意してください:

- **orderType** - アプリで行われた取引の場合、これは常に「MOBILE」である必要があります。
- **forterMobileUID** - これは、モバイルSDKに渡され、バックエンドの注文リクエストに含まれるIDに対応する必要があります。これは、モバイル注文の「`forterTokenCookie`」値を置き換えます。
- **customerIP** - これは、エンドユーザーのデバイスに対応するIPである必要があります。あなたのサーバーのIPではありません。

以下は、ネイティブモバイルアプリの注文に対してconnectionInformationオブジェクトがどのように表示されるべきかの例です:

```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"
  }
}
```

:::ExpandableHeading
### 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;
    
    for each (var paymentInstrument in paymentInstruments) {
        if (paymentInstrument.paymentMethod == 'CREDIT_CARD') {
            a = paymentInstrument;
            authResponse = args.CreditCardAuthResponse;
        } else if (paymentInstrument.paymentMethod == 'PayPal' || paymentInstrument.paymentMethod == 'ApplePay') {
            a = paymentInstrument;
            authResponse = {}; // not necessary as this info can be retreived from a  instrument
        } else if (paymentInstrument.paymentMethod == 'GIFT_CERTIFICATE') { // optional if this is an accepted a  method in your store
        	a = paymentInstrument;
        	authResponse = args.GCRedemptionTransaction;
        }
    }

    forterOrderType = function {
      for each (var type in OrderType) {
        if (orderType.type == 'SFCC storeFront web') {
            return "WEB";
        } else if (orderType.type == 'iOS version mobile' || orderType.type == 'Android linux mobile') {
            return "MOBILE"
       }
    }

    // General parameters
    this.orderId               = order.originalOrderNo;   // Required
    this.orderType             = order.forterOrderType;   // "MOBILE" for app and "WEB" for web orders,
    this.timeSentToForter      = (new Date()).getTime();          // Required
    this.checkoutTime          = new Number((order.creationDate.getTime()/1000).toFixed());    // Required //must be seconds, not milliseconds
    this.connectionInformation = new ForterConnectionInformation(order);    // Required

    // Calculate totals
    this.totalAmount                     = {};                                // Required
    this.totalAmount.amountLocalCurrency = order.totalGrossPrice.value.toFixed(2);
    this.totalAmount.currency            = order.totalGrossPrice.currencyCode;
    this.amountUSD                       = order.totalGrossPrice.value
    

    //Calculate totals for discounts
    var orderTotal    = order.getMerchandizeTotalPrice(),
        adjOrderTotal = order.getAdjustedMerchandizeTotalPrice(),
        shipTotal     = order.getShippingTotalPrice(),
        adjShipTotal  = order.getAdjustedShippingTotalPrice(),
        total         = orderTotal.add(shipTotal),
        adjTotal      = adjOrderTotal.add(adjShipTotal);

    // Discounts
    var discountPrice = 0;
    var couponName = '';
    var couponType = '';
    if (!order.getCouponLineItems().isEmpty()) {
        var coupons     = order.getCouponLineItems();
        var couponNames = [];

        for each (let coup in coupons) {
            couponNames.push(coup.getCouponCode());
            if (!coup.getPriceAdjustments().isEmpty()) {
                var coupAdjustments = coup.getPriceAdjustments();
                for each (let coupAdj in coupAdjustments) {
                    discountPrice += coupAdj.priceValue;
                }
            }
        }

        couponName = couponNames.join(",");
        discountPrice = discountPrice*(-1);

        if (discountPrice > 0) {
            this.totalDiscount = {};                                                // Optional
            this.totalDiscount.couponCodeUsed = couponName.substring(0,20);         // Required
            this.totalDiscount.couponDiscountAmount = {};                            // Required
            this.totalDiscount.couponDiscountAmount.amountLocalCurrency = discountPrice.toFixed(2);
            this.totalDiscount.couponDiscountAmount.currency = order.currencyCode;
            this.totalDiscount.discountType = "COUPON";                                // Required
        }
    }

    // Customer's details
    this.accountOwner = new ForterCustomer(order);

    // Cart items (regular product)
    this.cartItems = [];                                                    // Required
    for each (var pli in order.productLineItems) {
        this.cartItems.push(new ForterCartItem(pli));
    }
    
    // Cart items (gift certificate)
    for each (var gcli in order.giftCertificateLineItems) {
        this.cartItems.push(new ForterCartItem(gcli));
    }

    // Payments
    this.a  = [];                                                        // Required
    this.a .push(new ForterPayment(order, authResponse, a , log));

    // Delivery and Recipient (shipping information)
    if (order.shipments.length > 0) {
        shipment = order.shipments[0];
        
        this.primaryDeliveryDetails = {};
        this.primaryDeliveryDetails.deliveryPrice = {};
        this.primaryDeliveryDetails.deliveryMethod = (!empty(shipment.getShippingMethod()) && !empty(shipment.getShippingMethod().getDisplayName())) ? shipment.getShippingMethod().getDisplayName() : ""; //"BY AIR";
        
        var deliveryType = "PHYSICAL"; //default value
        if (order.productLineItems.size() > 0 && order.giftCertificateLineItems.size() == 0) {
            deliveryType = "PHYSICAL"; //if real products only
        } else if (order.productLineItems.size() == 0 && order.giftCertificateLineItems.size() > 0) {
            deliveryType = "DIGITAL";  //if gift certificates only
            this.primaryDeliveryDetails.deliveryMethod = "email";
        } else if (order.productLineItems.size() > 0 && order.giftCertificateLineItems.size() > 0) {
            deliveryType = "HYBRID";  //if gift certificates and real products
        }
        this.primaryDeliveryDetails.deliveryType                      = deliveryType;
        
        this.primaryDeliveryDetails.deliveryPrice.amountLocalCurrency = shipment.adjustedShippingTotalPrice.value.toFixed(2);
        this.primaryDeliveryDetails.deliveryPrice.currency            = shipment.adjustedShippingTotalPrice.currencyCode.toString();
  
            if (shipment.productLineItems.size() > 0) {
                
                this.primaryRecipient = {};                                                // Optional
                this.primaryRecipient.personalDetails = {};

                this.primaryRecipient.personalDetails.firstName = shipment.shippingAddress.firstName; //from the shipping address
                this.primaryRecipient.personalDetails.lastName = shipment.shippingAddress.lastName;  //from the shipping address
    
                this.primaryRecipient.address = {};
                this.primaryRecipient.address.address1 = shipment.shippingAddress.address1;
                this.primaryRecipient.address.address2 = !empty(shipment.shippingAddress.address2) ? shipment.shippingAddress.address2 : "";
                this.primaryRecipient.address.zip = shipment.shippingAddress.postalCode;
                this.primaryRecipient.address.city = shipment.shippingAddress.city;
                this.primaryRecipient.address.region = shipment.shippingAddress.stateCode;
                this.primaryRecipient.address.country = shipment.shippingAddress.countryCode.value.toUpperCase();
    
                this.primaryRecipient.phone = [];
                if (!empty(shipment.shippingAddress.phone)){
                    this.primaryRecipient.phone.push(new ForterPhone(shipment.shippingAddress.phone));
                }
                
            } else if (shipment.giftCertificateLineItems.size() > 0) {
                this.primaryRecipient = {};                                                // Optional
                this.primaryRecipient.personalDetails = {};
                
                this.primaryRecipient.personalDetails.fullName = shipment.giftCertificateLineItems[0].recipientName; //from the gift form
                this.primaryRecipient.personalDetails.email = shipment.giftCertificateLineItems[0].recipientEmail;   //from the gift form
            }
    
            if (shipment.gift == true) {
                this.primaryRecipient.comments = {};
                this.primaryRecipient.comments.messageToBeneficiary = shipment.giftMessage ? shipment.giftMessage : "";
            }
    }

    function ForterConnectionInformation(order) {

        this.customerIP = request.httpRemoteAddress;                    // Required
        this.userAgent  = request.httpUserAgent;

        var orderType = order.orderTypeRawRequest;

        if request.httpCookies { // if web or mobile browser order
            for (var i = 0; i < request.httpCookies.cookieCount; i++) {
                if (request.httpCookies[i].name == "forterToken") {
                    this.forterTokenCookie = request.httpCookies[i].value;  
                } else {
                    this.forterTokenCookie = "";
                }
            }
        } else if (orderType.type == 'iOS version mobile' || orderType.type == 'Android linux mobile') { // if app order
            if (request.http.mUID) {
                this.forterMobileUID = request.http.mUID;
            } else {
                this.forterMobileUID = "";
            }

            this.mobileAppVersion = request.http.versionHeaders
        }


        this.userAgent = request.httpUserAgent;                          // Required
        this.forterTokenCookie = "";                                     // Conditional
        for (var i = 0; i < request.httpCookies.cookieCount; i++) {
            if (request.httpCookies[i].name == "forterToken") {
                this.forterTokenCookie = request.httpCookies[i].value;
            }
        }
    }
}

function ForterCustomer(order) {

    if (order.customer.profile != null) {
        this.firstName = order.customer.profile.firstName;
        this.lastName = order.customer.profile.lastName;
        this.email = order.customer.profile.email;
        this.accountId = order.customer.ID;
        this.created = new Number((order.customer.profile.getCreationDate().getTime()/1000).toFixed());

        var query = "customerNo = {0} AND paymentStatus = {1}";
        var allOrders : SeekableIterator = dw.order.OrderMgr.searchOrders(query, "creationDate desc", order.customer.profile.customerNo, 2);
        this.pastOrdersCount = new Number(allOrders.count);

    } else {
        this.firstName = order.billingAddress.firstName;
        this.lastName = order.billingAddress.lastName;
        this.email = order.customerEmail;
    }
}

function ForterApplePay(auth, ap) {
// where var ap is the raw applepay response data from your payment gateway 
    var processorResponseCode = "",
        processorResponseText = "";

    // format the expiration month. from 1 to 01, etc.
    if (ap.creditCardExpirationMonth.toString().length == 1) {
        var creditCardExpMonth = "0" + cc.creditCardExpirationMonth.toString();
    } else {
        var creditCardExpMonth = cc.creditCardExpirationMonth.toString();
    }

    this.nameOnCard = ap.creditCardHolder;
    this.cardBrand = ap.creditCardType;
    this.token = ap.token;
    this.lastFourDigits = ap.creditCardNumberLastDigits; //optional
    this.expirationMonth = creditCardExpMonth;
    this.expirationYear = cc.creditCardExpirationYear.toString();

    this.verificationResults = {};
    this.verificationResults.avsFullResult = auth.avs.toString(); // optional
    this.verificationResults.cvvResult = auth.cvd_code.toString(); // optional
    this.verificationResults.authorizationCode = auth.authorization_num.toString();
    
    processorResponseCode = auth.exact_resp_code.toString();
    processorResponseText = auth.exact_message.toString();

    this.verificationResults.processorResponseCode = processorResponseCode;
    this.verificationResults.processorResponseText = processorResponseText; 
}

function ForterCartItem(item) {
    
    this.basicItemData = {};
    
    if (item instanceof dw.order.ProductLineItem) {
        this.basicItemData.productId = item.productID;     //Optional
        this.basicItemData.name      = item.productName;   //Required
        this.basicItemData.quantity  = item.quantityValue; //Required
    
        var product = item.getProduct();
        if (product.getCategories().isEmpty() && !empty(product.getVariationModel())) {
            product = product.getVariationModel().getMaster();
        }
        this.basicItemData.category = empty(product) ? "" : product.getCategories()[0].getDisplayName();
        this.basicItemData.type     = "TANGIBLE";                                            // Add if type is available. Change according to the actual item type
    
        //if any adjustements
        this.basicItemData.price = {};
        this.basicItemData.price.amountLocalCurrency = item.adjustedPrice.value.toFixed(2);
        this.basicItemData.price.currency = item.adjustedPrice.currencyCode.toString();
    }
    
    if (item instanceof dw.order.GiftCertificateLineItem) {
        this.basicItemData.name     = item.lineItemText;                                   //Required
        this.basicItemData.quantity = 1;                                                   //Required (set 1 by default for a gift cert?)
    
        this.basicItemData.type = "NON_TANGIBLE";                                          // Add if type is available. Change according to the actual item type
        this.deliveryDetails = {};
        this.deliveryDetails.deliveryType = "DIGITAL";
        this.deliveryDetails.deliveryMethod = "email";
    
        this.basicItemData.price = {};
        this.basicItemData.price.amountLocalCurrency = item.price.value.toFixed(2);
        this.basicItemData.price.currency = item.price.currencyCode.toString();
        
        
        this.beneficiaries = [];  
        this.beneficiaries.push(new ForterBeneficiaryDetailsFromGiftCard(item));
    }
}

module.exports = ForterOrder;
```
:::

## ステップ 3: テスト

### 通常のQAメールアドレス

有効なテストメールアドレスを使用して、サンドボックス環境で電話注文を行います。取引は [ポータルトランザクションタブ](https://portal.forter.com/transactions) に表示され、注文番号の横に携帯電話のアイコンが含まれるべきです。

![](https://api.archbee.com/api/optimize/dYhsqkppjaUNAqFmds_Ny-o4caS21ku95oL5d0N32Zu-20250724-184334.png)

### Forterによって拒否されました

メールアドレスで購入を行います `decline@forter.com` 有効なテストカードのクレジットカードまたは支払い方法を使用してください。このメールアドレスは、Forterのサンドボックス環境で常に「拒否」の決定を生成し、拒否されたモバイル取引のためにSFCCカートリッジフローをテストすることを可能にします。この拒否された注文を行ったら、カートリッジビジネスマネージャーを確認し、あなたの `processorResponse.json` ファイルをレビューし（必要に応じて更新し）、拒否されたモバイルアプリの注文をキャンセルして資金を無効にしてください。

### Forterによって承認されました

取引のために `approve@forter.com` と有効なテストカードを使用して注文を作成します。これにより「承認」の決定が生成され、取引は[ ポータルトランザクションタブ](https://portal.forter.com/transactions) に表示され、注文番号の横にモバイルアイコンが含まれます。資金を捕捉し、この注文をOMSで進めるために、あなたの `processorResponse.json` ファイルを確認し、更新してください。
