この文章は Salesforce 機械翻訳システムを使用して翻訳されました。詳細はこちらをご参照ください。
英語に切り替える

GatewayErrorResponse クラス

要求禁止応答、カスタム検証エラー、期限切れの API トークンなど、PaymentGateway アダプターからのエラーの後にエラー表示で応答するために使用します。

名前空間

CommercePayments

使用方法

GatewayErrorResponse を使用して、支払ゲートウェイアダプターによって送信されたエラー応答��関する情報を保存するオブジェクトを作成します。

GatewayResponse は、有効な要求ではなく例外を受信すると、GatewayErrorResponse をコールしてその例外に関する情報を含むエラーオブジェクトを作成します。
1global commercepayments.GatewayResponse processRequest(commercepayments.paymentGatewayContext gatewayContext) {
2        commercepayments.RequestType requestType = gatewayContext.getPaymentRequestType();
3        commercepayments.GatewayResponse response;
4        try {
5            if (requestType == commercepayments.RequestType.Authorize) {
6                response = createAuthResponse((commercepayments.AuthorizationRequest)gatewayContext.getPaymentRequest());
7            } else if (requestType == commercepayments.RequestType.Capture) {
8                response =  createCaptureResponse((commercepayments.CaptureRequest)gatewayContext.getPaymentRequest()) ;
9            } else if (requestType == commercepayments.RequestType.ReferencedRefund) {
10                response = createRefundResponse((commercepayments.ReferencedRefundRequest)gatewayContext.getPaymentRequest());
11            }
12            return response;
13        } catch(SalesforceValidationException e) {
14             commercepayments.GatewayErrorResponse error = new commercepayments.GatewayErrorResponse('400', e.getMessage());
15             return error;
16        }
17    }

GatewayErrorResponse のコンストラクター

GatewayErrorResponse のコンストラクターは次のとおりです。

GatewayErrorResponse(errorCode, errorMessage)

errorCodeerrorMessage を受け入れる GatewayErrorResponse オブジェクトを作成するためのコンストラクター。

署名

global GatewayErrorResponse(String errorCode, String errorMessage)

パラメーター

errorCode
型: String
ユーザーに返される HTTP 状況コードと一致する必要があります。いくつか例を紹介しましょう。
  • 不正な要求の状況コードの場合、errorCode は 400 である必要があります。
  • 禁止された要求の状況コードの場合、errorCode は 403 である必要があります。
  • errorCode が有効な HTTP 状況でない場合、500 内部サーバーエラーが返されます。

errorCode には値を指定する必要があります。そうしない場合、プラットフォームでエラーが発生します。

メモ

errorMessage
型: String
エラー発生後のユーザーへのメッセージ応答。

errorMessage には値を指定する必要があります。そうしない場合、プラットフォームでエラーが発生します。

メモ