SFRA
SFRA ポスト認証統合
概要
以下のコードと指示はSFRA構造に基づいており、このセクションには影響を受けるすべてのコントローラーのリストが含まれています。
Forterカートリッジの関連するSFRAセクションは、カートリッジ内の以下のパスを使用して見つけることができます。
カートリッジ
>
int_forter_sfra
>
カートリッジ
>
コントローラー
>
CheckoutService.js
カートリッジをストアフロントアプリケーションに統合するには、コアカートリッジに変更を加える必要はありません。代わりに、既存のコードをカートリッジ内で上書きすることをお勧めします。ストアフロントアプリケーションに同じコントローラーやテンプレートが拡張または置き換えられている場合、影響を受けるすべてのコード変更はストアフロントアプリケーションのトップレベルカートリッジに追加する必要があります。
ForterValidate.jsファイルの呼び出し
実際の決済ゲートウェイコントローラー(CyberSource、Adyen、Braintreeなど)内で、既存の認証フローの一部としてForterValidate.jsファイルを呼び出す必要があります。実際のゲートウェイ認証内でrequireメソッドを呼び出します。以下の例では、これは関数の一部として定義されていますforterCall.
forterCall = require('int_forter_mfra/cartridge/scripts/pipelets/forter/ForterValidate'),MFRA コード例
以下は、認証フローの一部としてトリガーされる Authorize.net AUTHORIZE_NET-Authorize コントローラーのコードです。SFRA インテグレーション.
サンプル Authorize.net チェックアウトフロー (MFRAベース)
function Authorize(orderNumber, paymentInstrument, paymentProcessor) {
var serverErrors = [],
fieldErrors = {},
error = false;
try {
Transaction.wrap(function () {
paymentInstrument.paymentTransaction.setTransactionID(orderNumber);
paymentInstrument.paymentTransaction.setPaymentProcessor(paymentProcessor);
});
var argCCAuth = {
orderNumber : orderNumber,
PaymentInstrument : paymentInstrument
},
authResponse = doAuth(argCCAuth);
if (authResponse.result === false) {
var argOrderValidate = {
orderNumber : orderNumber,
orderValidateAttemptInput : 1
},
forterCall = require('int_forter_mfra/cartridge/scripts/pipelets/forter/ForterValidate'),
forterDecision = forterCall.validateOrder(argOrderValidate);
// in case if no response from Forter, try to call one more time
if (forterDecision.result === false && forterDecision.orderValidateAttemptInput == 2) {
var argOrderValidate = {
orderNumber : orderNumber,
orderValidateAttemptInput : 2
},
forterCall = require('int_forter_mfra/cartridge/scripts/pipelets/forter/ForterValidate'),
forterDecision = forterCall.validateOrder(argOrderValidate);
}
error = true;
serverErrors.push(
Resource.msg('error.technical', 'checkout', null)
);
}
if (authResponse.result === true) {
var argOrderValidate = {
orderNumber : orderNumber,
orderValidateAttemptInput : 1
},
forterCall = require('int_forter_mfra/cartridge/scripts/pipelets/forter/ForterValidate'),
forterDecision = forterCall.validateOrder(argOrderValidate);
// in case if no response from Forter, try to call one more time
if (forterDecision.result === false && forterDecision.orderValidateAttemptInput == 2) {
var argOrderValidate = {
orderNumber : orderNumber,
orderValidateAttemptInput : 2
};
forterCall = require('int_forter_mfra/cartridge/scripts/pipelets/forter/ForterValidate'),
forterDecision = forterCall.validateOrder(argOrderValidate);
}
if (forterDecision.JsonResponseOutput.processorAction === 'skipCapture' || forterDecision.JsonResponseOutput.processorAction === 'notReviewed') {
error = false;
} else if (forterDecision.JsonResponseOutput.processorAction === 'disabled' || forterDecision.JsonResponseOutput.processorAction === 'internalError' || forterDecision.JsonResponseOutput.processorAction === 'capture') {
var argCCCapture = {
AuthorizeNetResponse : authResponse.AuthorizeNetResponse,
orderNumber : orderNumber,
PaymentInstrument : paymentInstrument
},
captureResponse = doCapture(argCCCapture);
if (captureResponse.result === true) {
error = false;
}
if (captureResponse.result === false) {
var argVoid = {
AuthorizeNetResponse : authResponse.AuthorizeNetResponse,
orderNumber : orderNumber,
PaymentInstrument : paymentInstrument
},
voidResponse = doVoid(argVoid);
error = true;
serverErrors.push(
Resource.msg('error.technical', 'checkout', null)
);
}
} else {
var argVoid = {
AuthorizeNetResponse : authResponse.AuthorizeNetResponse,
orderNumber : orderNumber,
PaymentInstrument : paymentInstrument
},
voidResponse = doVoid(argVoid);
error = true;
serverErrors.push(
Resource.msg('error.technical', 'checkout', null)
);
}
}
} catch (e) {
error = true;
serverErrors.push(
Resource.msg('error.technical', 'checkout', null)
);
}
return { fieldErrors: fieldErrors, serverErrors: serverErrors, error: error };
}
function doAuth(argCCAuth) {
var authorizenetCCAuthRequest = require('~/cartridge/scripts/pipelets/AuthorizenetCCAuthRequest'),
authResponse = authorizenetCCAuthRequest.execute(argCCAuth);
return authResponse;
}
function doCapture(argCCCapture) {
var authorizenetCCCaptureRequest = require('~/cartridge/scripts/pipelets/AuthorizenetCCCaptureRequest'),
captureResponse = authorizenetCCCaptureRequest.execute(argCCCapture);
return captureResponse;
}
function doVoid(argVoid) {
var authorizenetVoidRequest = require('~/cartridge/scripts/pipelets/AuthorizenetVoidRequest'),
voidResponse = authorizenetVoidRequest.execute(argVoid);
return voidResponse;
}サンプル MFRA ヘルパースクリプト
以下のスクリプトは、Forterの決定を支払い処理業者に返すためにCyberSourceのチェックアウトフローに基づいており、各注文の処理を自動化します。
サンプル ヘルパースクリプト
/**
* Helper script for calling Forter from payment processor scripts
*
*/
var forterCall = require('int_forter_mfra/cartridge/scripts/pipelets/forter/ForterValidate');
function callForter(authResponses, orderNumber) {
var argOrderValidate = {
orderNumber: orderNumber,
authResponses: authResponses,
orderValidateAttemptInput: 1
};
try {
var forterDecision = forterCall.validateOrder(argOrderValidate);
// in case if no response from Forter, try to call one more time
if (forterDecision.result === false && forterDecision.orderValidateAttemptInput == 1) {
var argOrderValidate = {
orderNumber: orderNumber,
authResponses: authResponses,
orderValidateAttemptInput: 2
};
var forterDecision = forterCall.validateOrder(argOrderValidate);
}
if (forterDecision.JsonResponseOutput.processorAction === 'skipCapture' || forterDecision.JsonResponseOutput.processorAction === 'notReviewed') {
return forterDecision;
} else {
if (!empty(forterDecision.PlaceOrderError)) {
return {error : true, forterErrorCode : forterDecision.PlaceOrderError};
} else {
return forterDecision;
}
}
} catch (e) {
return {error : true};
}
}