GatewayNotificationResponse クラス
名前空間
使用方法
このクラスのインスタンスを作成するとき、CommercePayments 名前空間を指定する必要があります。このクラスのコンストラクターは、引数を取りません。次に例を示します。
CommercePayments.GatewayNotificationResponse gnr = new CommercePayments.GatewayNotificationResponse();非同期支払ゲートウェイが通知を送信すると、プラットフォームはその通知の受信に成功したか失敗したかを確認する必要があります。支払ゲートウェイアダプターはこのクラスを使用して、ゲートウェイが通知に対して期待する確認応答を作成します。GatewayNotificationResponse は、processNotification メソッドの戻り値の型です。
例
1commercepayments.GatewayNotificationResponse gnr = new commercepayments.GatewayNotificationResponse();
2if (saveResult.isSuccess()) {
3 system.debug('Notification accepted by platform');
4} else {
5 system.debug('Errors in the result '+ Blob.valueOf(saveResult.getErrorMessage()));
6}
7gnr.setStatusCode(200);
8gnr.setResponseBody(Blob.valueOf('[accepted]'));
9return gnr;GatewayNotificationResponse のメソッド
GatewayNotificationResponse のメソッドは次のとおりです。
setResponseBody(responseBody)
署名
global void setResponseBody(Blob responseBody)
パラメーター
- responseBody
- 型: Blob
- 一般的な応答の値には、応答の受信が成功した場合の accepted が含まれます。次に例を示します。
1commercepayments.GatewayNotificationResponse gnr = new commercepayments.GatewayNotificationResponse(); 2if (saveResult.isSuccess()) { 3 system.debug('Notification accepted by platform'); 4} else { 5 system.debug('Errors in the result '+ Blob.valueOf(saveResult.getErrorMessage())); 6} 7gnr.setStatusCode(200); 8gnr.setResponseBody(Blob.valueOf('[accepted]')); 9return gnr;
戻り値
型: void
setStatusCode(statusCode)
署名
global void setStatusCode(Integer statusCode)
パラメーター
- statusCode
- 型: Integer
- 状況コードは、支払プラットフォーム応答の種別によって異なります。ユーザーは支払プラットフォームが返す可能性のあるすべての値を考慮して、GatewayNotificationResponse クラスを設定する必要があります。次に例を示します。
1commercepayments.GatewayNotificationResponse gnr = new commercepayments.GatewayNotificationResponse(); 2if (saveResult.isSuccess()) { 3 system.debug('Notification accepted by platform'); 4} else { 5 system.debug('Errors in the result '+ Blob.valueOf(saveResult.getErrorMessage())); 6} 7gnr.setStatusCode(200); 8gnr.setResponseBody(Blob.valueOf('[accepted]')); 9return gnr;
戻り値
型: void