AuthorizationResponse クラス
名前空間
使用方法
このクラスのコンストラクタは、引数を取りません。次に例を示します。
CommercePayments.AuthorizationResponse authr = new CommercePayments.AuthorizationResponse();承認トランザクション後の支払ゲートウェイの応答に関する情報が含まれます。ゲートウェイアダプタは支払ゲートウェイの応答を使用して、AuthorizationResponse 項目に入力します。支払プラットフォームはこのクラスの情報を使用して、ユーザに表示される承認ゲートウェイ応答を作成します。
例
1private commercepayments.GatewayResponse createAuthResponse(HttpResponse response, Double amount) {
2 Map<String, Object> mapOfResponseValues = (Map
3 <String, Object>) JSON.deserializeUntyped(response.getBody());
4
5 commercepayments.AuthorizationResponse authResponse = new commercepayments.AuthorizationResponse();
6
7 String resultCode = (String)mapOfResponseValues.get('resultCode');
8
9 if(resultCode != null){
10 system.debug('Response - success');
11 if(resultCode.equals('Authorised')){
12 system.debug('status - authorised');
13 authResponse.setGatewayAuthCode((String)mapOfResponseValues.get('authCode'));
14 authResponse.setSalesforceResultCodeInfo(new commercepayments.SalesforceResultCodeInfo(commercepayments.SalesforceResultCode.Success));
15 } else {
16 //Sample returns 200 with refused status in some cases
17 system.debug('status - refused');
18 authResponse.setGatewayResultCodeDescription((String)mapOfResponseValues.get('refusalReason'));
19 authResponse.setSalesforceResultCodeInfo(new commercepayments.SalesforceResultCodeInfo(commercepayments.SalesforceResultCode.Decline));
20 }
21 authResponse.setGatewayReferenceNumber((String)mapOfResponseValues.get('pspReference'));
22 authResponse.setAmount(amount);
23 authResponse.setGatewayDate(system.now());
24 return authResponse;
25 } else {
26 system.debug('Response - failed');
27 system.debug('Validation error');
28 String statusCode = (String)mapOfResponseValues.get('errorType');
29 String message = (String)mapOfResponseValues.get('message');
30 commercepayments.GatewayErrorResponse error = new commercepayments.GatewayErrorResponse(statusCode, message);
31 return error;
32 }
33 }AuthorizationResponse のメソッド
AuthorizationResponse のメソッドは次のとおりです。
setAuthorizationExpirationDate(authExpDate)
署名
global void setAuthorizationExpirationDate(Datetime authExpDate)
パラメータ
- authExpDate
- 型: Datetime
戻り値
型: void
setGatewayAuthCode(gatewayAuthCode)
署名
global void setGatewayAuthCode(String gatewayAuthCode)
パラメータ
- gatewayAuthCode
- 型: String
- ゲートウェイから返された承認コード。
戻り値
型: void
setGatewayAvsCode(gatewayAvsCode)
署名
global void setGatewayAvsCode(String gatewayAvsCode)
パラメータ
- gatewayAvsCode
- 型: String
- 支払プラットフォームが支払ゲートウェイからトークン化を要求するときに、支払方法に対応付けられた住所を確認するために使用されます。
戻り値
型: void
setGatewayDate(gatewayDate)
setGatewayMessage(gatewayMessage)
setGatewayReferenceDetails(gatewayReferenceDetails)
署名
global void setGatewayReferenceDetails(String gatewayReferenceDetails)
パラメータ
- gatewayReferenceDetails
- 型: String
戻り値
型: void
setGatewayReferenceNumber(gatewayReferenceNumber)
署名
global void setGatewayReferenceNumber(String gatewayReferenceNumber)
パラメータ
- gatewayReferenceNumber
- 型: String
- 支払ゲートウェイにより作成された一意の承認 ID。
戻り値
型: void
setGatewayResultCode(gatewayResultCode)
署名
global void setGatewayResultCode(String gatewayResultCode)
パラメータ
- gatewayResultCode
- 型: String
- ゲートウェイ固有の結果コード。Salesforce 固有の結果コードを対応付けるために使用する必要があります。
戻り値
型: void
setGatewayResultCodeDescription(gatewayResultCodeDescription)
署名
global void setGatewayResultCodeDescription(String gatewayResultCodeDescription)
パラメータ
- gatewayResultCodeDescription
- 型: String
- ゲートウェイの結果コードの説明。この項目を使用して、ゲートウェイが特定の結果コードを返した理由の詳細を確認します。
戻り値
型: void
setPaymentMethodTokenizationResponse(paymentMethodTokenizationResponse)
署名
global void setPaymentMethodTokenizationResponse(commercepayments.PaymentMethodTokenizationResponse paymentMethodTokenizationResponse)
パラメータ
- paymentMethodTokenizationResponse
- PaymentMethodTokenizationResponse
- 支払方法のトークン化要求に対して支払ゲートウェイアダプタによって送信されるゲートウェイ応答。
戻り値
型: void
setSalesforceResultCodeInfo(salesforceResultCodeInfo)
署名
global void setSalesforceResultCodeInfo(commercepayments.SalesforceResultCodeInfo salesforceResultCodeInfo)
パラメータ
- salesforceResultCodeInfo
- 型: SalesforceResultCodeInfo
- Salesforce 結果コード値の説明。
戻り値
型: void