From 19f166d87b595907c4c8f4ce550a0aa6c3dfa4ec Mon Sep 17 00:00:00 2001 From: mahmishr Date: Fri, 26 Sep 2025 11:29:41 +0530 Subject: [PATCH 01/20] Update MerchantConfiguration.php --- .../Core/MerchantConfiguration.php | 452 ++++++++++++++++-- 1 file changed, 422 insertions(+), 30 deletions(-) diff --git a/lib/Authentication/Core/MerchantConfiguration.php b/lib/Authentication/Core/MerchantConfiguration.php index d9bdd90e..50339c84 100644 --- a/lib/Authentication/Core/MerchantConfiguration.php +++ b/lib/Authentication/Core/MerchantConfiguration.php @@ -206,7 +206,7 @@ class MerchantConfiguration */ protected $useMLEGlobally=null; - /** + /** * Enable MLE for optional APIs globally (alias for useMLEGlobally) * * @var bool @@ -223,17 +223,48 @@ class MerchantConfiguration /** * Curl mapToControlMLEonAPI * - * @var array - */ + * Expected values (strings or booleans): + * "apiFunctionName1" => "true::true" + * "apiFunctionName2" => "false::false" + * "apiFunctionName3" => "true::false" + * "apiFunctionName4" => "false::true" + * "apiFunctionName5" => "true" (request only; response uses global flag) + * "apiFunctionName6" => "false" (request only; response uses global flag) + * "apiFunctionName7" => "::true" (response only; request uses global flag) + * "apiFunctionName8" => "true::" (request true; response uses global flag) + * + * A bare boolean (true/false) acts like "true"/"false" string (request only). + * + * @var array + */ protected $mapToControlMLEonAPI = []; /** - * Curl mleKeyAlias + * Internal parsed per-API Request MLE flags. + * @var array + */ + protected $internalMapToControlRequestMLEonAPI = []; + + /** + * Internal parsed per-API Response MLE flags. + * @var array + */ + protected $internalMapToControlResponseMLEonAPI = []; + + /** + * @deprecated Use requestMleKeyAlias instead. Retained for backward compatibility. * * @var string */ protected $mleKeyAlias = GlobalParameter::DEFAULT_MLE_ALIAS_FOR_CERT; + /** + * Optional parameter. User can pass a custom requestMleKeyAlias to fetch from the certificate. + * + * @var string + */ + protected $requestMleKeyAlias = GlobalParameter::DEFAULT_MLE_ALIAS_FOR_CERT; + /** * Curl DefaultDeveloperId * @@ -276,6 +307,43 @@ class MerchantConfiguration */ protected $mleForRequestPublicCertPath; + /** + * Enable Response (Outbound) MLE globally (encrypted responses if API supports it) + * + * @var bool + */ + protected $enableResponseMleGlobally = false; + + /** + * KID value for the Response MLE public certificate (returned by CyberSource portal) + * + * @var string + */ + protected $responseMleKID = ''; + + /** + * Private key file path used to decrypt Response MLE payloads (e.g. .p12 / .pem) + * + * @var string + */ + protected $responseMlePrivateKeyFilePath = ''; + + /** + * Private key (in‑memory) used to decrypt Response MLE payloads. + * Provide the raw private key string (e.g. PEM / PKCS#8). Mutually exclusive with responseMlePrivateKeyFilePath. + * + * @var string + */ + protected $responseMlePrivateKey = ''; + + /** + * Password for the private key file (e.g. .p12 or encrypted .pem) used for Response MLE decryption. + * Optional. Required only when the key file is password-protected. + * + * @var string + */ + protected $responseMlePrivateKeyFilePassword = ''; + /** * Constructor */ @@ -1012,7 +1080,7 @@ public function setEnableRequestMLEForOptionalApisGlobally($enableRequestMLEForO $this->enableRequestMLEForOptionalApisGlobally = (bool)$enableRequestMLEForOptionalApisGlobally || (bool)$this->useMLEGlobally; } - /** + /** * Get the value of disableRequestMLEForMandatoryApisGlobally * * @return bool @@ -1033,9 +1101,9 @@ public function setDisableRequestMLEForMandatoryApisGlobally($disableRequestMLEF } /** - * Get the value of mapToControlMLEonAPI + * Get the value of mapToControlMLEonAPI (raw user-supplied) * - * @return array + * @return array */ public function getMapToControlMLEonAPI() { @@ -1043,19 +1111,155 @@ public function getMapToControlMLEonAPI() } /** - * Set the value of mapToControlMLEonAPI + * Set the value of mapToControlMLEonAPI. + * Accepts associative array or stdClass whose values are string|bool. * - * @param array $mapToControlMLEonAPI + * Parsing to internal request/response maps happens immediately. + * + * @param array|object $mapToControlMLEonAPI + * @return void */ public function setMapToControlMLEonAPI($mapToControlMLEonAPI) { - if ($mapToControlMLEonAPI !== null) { - if (is_array($mapToControlMLEonAPI) && $this->isAssocArrayOfStringBool($mapToControlMLEonAPI)) { - $this->mapToControlMLEonAPI = $mapToControlMLEonAPI; - } else { - throw new InvalidArgumentException("mapToControlMLEonAPI in merchantConfig must be an array type."); + if ($mapToControlMLEonAPI === null) { + return; + } + + // Allow stdClass (from json_decode without assoc) + if (is_object($mapToControlMLEonAPI)) { //// + $mapToControlMLEonAPI = get_object_vars($mapToControlMLEonAPI); + } + + if (!is_array($mapToControlMLEonAPI)) { + throw new InvalidArgumentException("mapToControlMLEonAPI must be an associative array or object."); + } + + foreach ($mapToControlMLEonAPI as $k => $v) {/// + if (!is_string($k)) { + throw new InvalidArgumentException("mapToControlMLEonAPI keys must be strings."); + } + if (!is_string($v) && !is_bool($v)) { + throw new InvalidArgumentException("mapToControlMLEonAPI values must be string or bool."); } } + + $this->mapToControlMLEonAPI = $mapToControlMLEonAPI; + $this->parseMapToControlMLEonAPI(); // build internal maps + } + + /** + * Internal helper: canonical boolean token? + * @param string $v + * @return bool + */ + private function isBooleanToken($v)/// + { + return $v === 'true' || $v === 'false'; + } + + /** + * Parse one raw entry into request/response booleans. + * + * @param string|bool $raw + * @param bool $defaultRequest + * @param bool $defaultResponse + * @return array{0:bool,1:bool} + */ + private function parseMleEntry($raw, $defaultRequest, $defaultResponse) //// + { + // Direct boolean -> request only + if (is_bool($raw)) { + return [$raw, $defaultResponse]; + } + + $raw = trim((string)$raw); + + // Plain string true/false (request only) + if ($this->isBooleanToken($raw)) { + return [$raw === 'true', $defaultResponse]; + } + + // Pattern with '::' + if (strpos($raw, '::') !== false) { + $parts = explode('::', $raw); + if (count($parts) !== 2) { + // Invalid pattern -> defaults + if (self::$logger) { + self::$logger->warning("Invalid MLE map value '$raw' (too many separators). Using defaults."); + } + return [$defaultRequest, $defaultResponse]; + } + $reqPart = trim($parts[0]); + $respPart = trim($parts[1]); + + $reqFlag = $defaultRequest; + $respFlag = $defaultResponse; + + if ($reqPart !== '') { + if ($this->isBooleanToken($reqPart)) { + $reqFlag = ($reqPart === 'true'); + } else { + if (self::$logger) { + self::$logger->warning("Invalid request MLE token '$reqPart' in '$raw'. Using default."); + } + } + } + if ($respPart !== '') { + if ($this->isBooleanToken($respPart)) { + $respFlag = ($respPart === 'true'); + } else { + if (self::$logger) { + self::$logger->warning("Invalid response MLE token '$respPart' in '$raw'. Using default."); + } + } + } + + return [$reqFlag, $respFlag]; + } + + // Unrecognized format -> defaults + if (self::$logger) { + self::$logger->warning("Unrecognized MLE map value '$raw'. Using defaults."); + } + return [$defaultRequest, $defaultResponse]; + } + + /** + * Build internal request/response MLE control maps from raw map. + * + * @return void + */ + private function parseMapToControlMLEonAPI() ///////// + { + $this->internalMapToControlRequestMLEonAPI = []; + $this->internalMapToControlResponseMLEonAPI = []; + + $defaultRequest = (bool)$this->enableRequestMLEForOptionalApisGlobally; + $defaultResponse = (bool)$this->enableResponseMleGlobally; + + foreach ($this->mapToControlMLEonAPI as $apiFunc => $rawVal) { + list($reqFlag, $respFlag) = $this->parseMleEntry($rawVal, $defaultRequest, $defaultResponse); + $this->internalMapToControlRequestMLEonAPI[$apiFunc] = $reqFlag; + $this->internalMapToControlResponseMLEonAPI[$apiFunc] = $respFlag; + } + } + + /** + * (Optional) expose parsed request MLE map. + * @return array + */ + public function getInternalMapToControlRequestMLEonAPI() + { + return $this->internalMapToControlRequestMLEonAPI; + } + + /** + * (Optional) expose parsed response MLE map. + * @return array + */ + public function getInternalMapToControlResponseMLEonAPI() + { + return $this->internalMapToControlResponseMLEonAPI; } /** @@ -1076,6 +1280,90 @@ public function getMleForRequestPublicCertPath() { return $this->mleForRequestPublicCertPath; } + + /** + * Set enableResponseMleGlobally + * + * @param bool $enableResponseMleGlobally + * @return void + */ + public function setEnableResponseMleGlobally($enableResponseMleGlobally) + { + $this->enableResponseMleGlobally = (bool)$enableResponseMleGlobally; + } + + /** + * Get enableResponseMleGlobally + * + * @return bool + */ + public function getEnableResponseMleGlobally() + { + return $this->enableResponseMleGlobally; + } + + /** + * Set responseMleKID + * + * @param string $responseMleKID + * @return void + */ + public function setResponseMleKID($responseMleKID) + { + $this->responseMleKID = is_string($responseMleKID) ? trim($responseMleKID) : ''; + } + + /** + * Get responseMleKID + * + * @return string + */ + public function getResponseMleKID() + { + return $this->responseMleKID; + } + + /** + * Set responseMlePrivateKeyFilePath + * + * @param string $responseMlePrivateKeyFilePath + * @return void + */ + public function setResponseMlePrivateKeyFilePath($responseMlePrivateKeyFilePath) + { + $this->responseMlePrivateKeyFilePath = is_string($responseMlePrivateKeyFilePath) ? trim($responseMlePrivateKeyFilePath) : ''; + } + + /** + * Get responseMlePrivateKeyFilePath + * + * @return string + */ + public function getResponseMlePrivateKeyFilePath() + { + return $this->responseMlePrivateKeyFilePath; + } + + public function setResponseMlePrivateKey($responseMlePrivateKey) + { + // Accept only string; trim. If resource/object passed, ignore for now (simplify). + $this->responseMlePrivateKey = is_string($responseMlePrivateKey) ? trim($responseMlePrivateKey) : ''; + } + + public function getResponseMlePrivateKey() + { + return $this->responseMlePrivateKey; + } + + public function setResponseMlePrivateKeyFilePassword($responseMlePrivateKeyFilePassword) + { + $this->responseMlePrivateKeyFilePassword = is_string($responseMlePrivateKeyFilePassword) ? $responseMlePrivateKeyFilePassword : ''; + } + + public function getResponseMlePrivateKeyFilePassword() + { + return $this->responseMlePrivateKeyFilePassword; + } private function isAssocArrayOfStringBool($array) { foreach ($array as $key => $value) { @@ -1097,17 +1385,34 @@ public function getMleKeyAlias() } /** - * Set the value of mleKeyAlias + * Get requestMleKeyAlias (replacement for mleKeyAlias) + * + * @return string + */ + public function getRequestMleKeyAlias() + { + if (!isset($this->requestMleKeyAlias) || empty(trim($this->requestMleKeyAlias))) { + $this->requestMleKeyAlias = GlobalParameter::DEFAULT_MLE_ALIAS_FOR_CERT; + } + return $this->requestMleKeyAlias; + } + + /** + * Set requestMleKeyAlias (preferred new field) * - * @param string $mleKeyAlias + * @param string $requestMleKeyAlias + * @return $this */ - public function setMleKeyAlias($mleKeyAlias) + public function setRequestMleKeyAlias($requestMleKeyAlias) { - if (!is_null($mleKeyAlias) & !empty(trim($mleKeyAlias)) ) { - $this->mleKeyAlias = $mleKeyAlias; - }else{ - $this->mleKeyAlias = GlobalParameter::DEFAULT_MLE_ALIAS_FOR_CERT; + if (!is_null($requestMleKeyAlias) && strlen(trim($requestMleKeyAlias)) > 0) { + $this->requestMleKeyAlias = trim($requestMleKeyAlias); + } else { + $this->requestMleKeyAlias = GlobalParameter::DEFAULT_MLE_ALIAS_FOR_CERT; } + // Keep legacy field synchronized for any older code paths. + $this->mleKeyAlias = $this->requestMleKeyAlias; + return $this; } /** @@ -1245,6 +1550,30 @@ public static function setMerchantCredentials($connectionDet) $config = $config->setMleForRequestPublicCertPath($connectionDet->mleForRequestPublicCertPath); } + // Prefer new requestMleKeyAlias; fallback to deprecated mleKeyAlias + if (isset($connectionDet->requestMleKeyAlias)) { + $config = $config->setRequestMleKeyAlias($connectionDet->requestMleKeyAlias); + } elseif (isset($connectionDet->mleKeyAlias)) { + $config = $config->setMleKeyAlias($connectionDet->mleKeyAlias); + } + + // Response MLE (outbound) new fields + if (isset($connectionDet->enableResponseMleGlobally)) { + $config = $config->setEnableResponseMleGlobally($connectionDet->enableResponseMleGlobally); + } + if (isset($connectionDet->responseMleKID)) { + $config = $config->setResponseMleKID($connectionDet->responseMleKID); + } + if (isset($connectionDet->responseMlePrivateKeyFilePath)) { + $config = $config->setResponseMlePrivateKeyFilePath($connectionDet->responseMlePrivateKeyFilePath); + } + if (isset($connectionDet->responseMlePrivateKeyFilePassword)) { + $config = $config->setResponseMlePrivateKeyFilePassword($connectionDet->responseMlePrivateKeyFilePassword); + } + if (isset($connectionDet->responseMlePrivateKey)) { + $config = $config->setResponseMlePrivateKey($connectionDet->responseMlePrivateKey); + } + $config->validateMerchantData(); if($error_message != null){ $error_message = GlobalParameter::NOT_ENTERED. $error_message; @@ -1413,16 +1742,17 @@ public function validateMerchantData() } private function validateMLEConfiguration(){ - $requestMleConfigured = $this->enableRequestMLEForOptionalApisGlobally; - if ($this->mapToControlMLEonAPI !== null && !empty($this->mapToControlMLEonAPI)) { - foreach ($this->mapToControlMLEonAPI as $value) { - if ($value) { - $requestMleConfigured = true; - break; - } - } + // Re-parse in case global flags changed since last parse + $this->parseMapToControlMLEonAPI();//// + + /* + * REQUEST MLE VALIDATION + */ + $requestMleConfigured = (bool)$this->enableRequestMLEForOptionalApisGlobally; + foreach ($this->internalMapToControlRequestMLEonAPI as $flag) { + if ($flag) { $requestMleConfigured = true; break; } } - // if MLE=true then check for auth Type + if ($requestMleConfigured && strcasecmp($this->authenticationType, GlobalParameter::JWT) !== 0) { $error_message = GlobalParameter::REQUEST_MLE_AUTH_ERROR; $exception = new AuthException($error_message, 0); @@ -1441,6 +1771,68 @@ private function validateMLEConfiguration(){ throw $exception; } } + + /* + * RESPONSE (OUTBOUND) MLE VALIDATION + * Trigger if global flag OR any per-API response flag is true. + */ + $responseMleConfigured = (bool)$this->enableResponseMleGlobally; //// + foreach ($this->internalMapToControlResponseMLEonAPI as $flag) { + if ($flag) { $responseMleConfigured = true; break; } + } + + if ($responseMleConfigured) { + if (strcasecmp($this->authenticationType, GlobalParameter::JWT) !== 0) { + $error_message = "Response MLE is only supported for JWT authentication type."; + $exception = new AuthException($error_message, 0); + self::$logger->error($error_message); + throw $exception; + } + + $hasFilePath = !empty($this->responseMlePrivateKeyFilePath); + $hasInMemoryKey = !empty($this->responseMlePrivateKey); + + if (!$hasFilePath && !$hasInMemoryKey) { + $error_message = "Response MLE enabled but neither responseMlePrivateKeyFilePath nor responseMlePrivateKey provided. Provide exactly one."; + $exception = new AuthException($error_message, 0); + self::$logger->error($error_message); + throw $exception; + } + + if ($hasFilePath && $hasInMemoryKey) { + $error_message = "Both responseMlePrivateKeyFilePath and responseMlePrivateKey supplied. Provide only one."; + $exception = new AuthException($error_message, 0); + self::$logger->error($error_message); + throw $exception; + } + + if ($hasFilePath) { + if (!file_exists($this->responseMlePrivateKeyFilePath) || + !is_readable($this->responseMlePrivateKeyFilePath) || + !is_file($this->responseMlePrivateKeyFilePath)) { + $error_message = "Response MLE private key file not found or not readable at " . $this->responseMlePrivateKeyFilePath; + $exception = new AuthException($error_message, 0); + self::$logger->error($error_message); + throw $exception; + } + // Password (if any) is optional; no strict validation here. + } else { + // Basic sanity check for in-memory key: must contain typical PEM header or be non-trivial length. + if (strlen($this->responseMlePrivateKey) < 32) { + $error_message = "responseMlePrivateKey appears invalid (too short)."; + $exception = new AuthException($error_message, 0); + self::$logger->error($error_message); + throw $exception; + } + } + + if (empty($this->responseMleKID)) { + $error_message = "Response MLE enabled but responseMleKID not provided."; + $exception = new AuthException($error_message, 0); + self::$logger->error($error_message); + throw $exception; + } + } } } From 22977bfc79c8a98e37200a1a932b510df52bbf83 Mon Sep 17 00:00:00 2001 From: mahmishr Date: Fri, 26 Sep 2025 15:35:00 +0530 Subject: [PATCH 02/20] response mle code --- lib/Api/PaymentsApi.php | 5 +- lib/ApiClient.php | 20 ++++- lib/Authentication/Core/Authentication.php | 4 +- lib/Authentication/Core/TokenGenerator.php | 2 +- .../Http/HttpSignatureGenerator.php | 2 +- .../Jwt/JsonWebTokenGenerator.php | 8 +- .../OAuth/OAuthTokenGenerator.php | 2 +- lib/Authentication/Util/Cache.php | 43 +++++++++ lib/Authentication/Util/GlobalParameter.php | 1 + lib/Authentication/Util/MLEUtility.php | 87 +++++++++++++++++++ 10 files changed, 162 insertions(+), 12 deletions(-) diff --git a/lib/Api/PaymentsApi.php b/lib/Api/PaymentsApi.php index 71f5754d..1f80bc49 100644 --- a/lib/Api/PaymentsApi.php +++ b/lib/Api/PaymentsApi.php @@ -314,7 +314,7 @@ public function createPaymentWithHttpInfo($createPaymentRequest) throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } - + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "createPayment,createPaymentWithHttpInfo"); // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -338,7 +338,8 @@ public function createPaymentWithHttpInfo($createPaymentRequest) $httpBody, $headerParams, '\CyberSource\Model\PtsV2PaymentsPost201Response', - '/pts/v2/payments' + '/pts/v2/payments', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/ApiClient.php b/lib/ApiClient.php index 17fcb49e..de524d93 100755 --- a/lib/ApiClient.php +++ b/lib/ApiClient.php @@ -221,7 +221,7 @@ public function getApiKeyWithPrefix($apiKeyIdentifier) * @throws \CyberSource\ApiException on a non 2xx response * @return mixed */ - public function callApi($resourcePath, $method, $queryParams, $postData, $headerParams, $responseType = null, $endpointPath = null) + public function callApi($resourcePath, $method, $queryParams, $postData, $headerParams, $responseType = null, $endpointPath = null, $isResponseMLEForAPI=false) { self::$logger->info("CALLING API \"$resourcePath\" STARTED"); $headers = []; @@ -258,7 +258,7 @@ public function callApi($resourcePath, $method, $queryParams, $postData, $header if($this->merchantConfig->getAuthenticationType() != GlobalParameter::MUTUAL_AUTH) { - $authHeader = $this->callAuthenticationHeader($method, $postData, $resourcePath); + $authHeader = $this->callAuthenticationHeader($method, $postData, $resourcePath, $isResponseMLEForAPI); } $requestHeaders=[]; @@ -487,6 +487,18 @@ public function callApi($resourcePath, $method, $queryParams, $postData, $header $data ); } + + // Response MLE decryption (if flagged and JWT auth) + if ($isResponseMLEForAPI + && $this->merchantConfig->getAuthenticationType() === GlobalParameter::JWT + && \CyberSource\Authentication\Util\MLEUtility::checkIsMleEncryptedResponse($data)) { + try { + $data = \CyberSource\Authentication\Util\MLEUtility::decryptMleResponsePayload($this->merchantConfig, $data); + } catch (\Exception $e) { + self::$logger->warning("Response MLE decryption failed: " . $e->getMessage() . " (falling back to raw response)"); + } + } + self::$logger->close(); return [$data, $response_info['http_code'], $http_header]; } else { @@ -623,11 +635,11 @@ protected function httpParseHeaders($raw_headers) * Purpose : This function calling the Authentication and making an Auth Header * */ - public function callAuthenticationHeader($method, $postData, $resourcePath) + public function callAuthenticationHeader($method, $postData, $resourcePath, $isResponseMLEForAPI) { $merchantConfig = $this->merchantConfig; $authentication = new Authentication($merchantConfig->getLogConfiguration()); - $getToken = $authentication->generateToken($resourcePath, $postData, $method, $merchantConfig); + $getToken = $authentication->generateToken($resourcePath, $postData, $method, $merchantConfig, $isResponseMLEForAPI); if($merchantConfig->getAuthenticationType() == GlobalParameter::HTTP_SIGNATURE){ $host = "Host:".$merchantConfig->getHost(); $vcMerchant = "v-c-merchant-id:".$merchantConfig->getMerchantID(); diff --git a/lib/Authentication/Core/Authentication.php b/lib/Authentication/Core/Authentication.php index 077cb4da..a54f8c00 100644 --- a/lib/Authentication/Core/Authentication.php +++ b/lib/Authentication/Core/Authentication.php @@ -26,7 +26,7 @@ public function __construct(\CyberSource\Logging\LogConfiguration $logConfig = n } //call http signature and jwt - function generateToken($resourcePath, $inputData, $method, $merchantConfig) + function generateToken($resourcePath, $inputData, $method, $merchantConfig, $isResponseMLEForAPI) { if(is_null($merchantConfig)) { @@ -37,7 +37,7 @@ function generateToken($resourcePath, $inputData, $method, $merchantConfig) $tokenGenerator = $this->getTokenGenerator($merchantConfig); if (null !== self::$logger) { self::$logger->close(); } - return $tokenGenerator->generateToken($resourcePath, $inputData, $method, $merchantConfig); + return $tokenGenerator->generateToken($resourcePath, $inputData, $method, $merchantConfig, $isResponseMLEForAPI); } function getTokenGenerator($merchantConfig) { diff --git a/lib/Authentication/Core/TokenGenerator.php b/lib/Authentication/Core/TokenGenerator.php index 2b627c37..9bea6a82 100644 --- a/lib/Authentication/Core/TokenGenerator.php +++ b/lib/Authentication/Core/TokenGenerator.php @@ -4,7 +4,7 @@ interface TokenGenerator { - public function generateToken($resourcePath, $payloadData, $method, $merchantConfig); + public function generateToken($resourcePath, $payloadData, $method, $merchantConfig, $isResponseMLEForAPI=false); } ?> \ No newline at end of file diff --git a/lib/Authentication/Http/HttpSignatureGenerator.php b/lib/Authentication/Http/HttpSignatureGenerator.php index 03ec1b24..ed944591 100644 --- a/lib/Authentication/Http/HttpSignatureGenerator.php +++ b/lib/Authentication/Http/HttpSignatureGenerator.php @@ -24,7 +24,7 @@ public function __construct(\CyberSource\Logging\LogConfiguration $logConfig) } //Signature Creation function - public function generateToken($resourcePath, $payloadData, $method, $merchantConfig) //add + public function generateToken($resourcePath, $payloadData, $method, $merchantConfig, $isResponseMLEForAPI = false) //add { $host = $merchantConfig->getHost(); $date = date("D, d M Y G:i:s ").GlobalParameter::GMT; diff --git a/lib/Authentication/Jwt/JsonWebTokenGenerator.php b/lib/Authentication/Jwt/JsonWebTokenGenerator.php index 022e9dee..8e7fd5b6 100644 --- a/lib/Authentication/Jwt/JsonWebTokenGenerator.php +++ b/lib/Authentication/Jwt/JsonWebTokenGenerator.php @@ -26,18 +26,24 @@ public function __construct(\CyberSource\Logging\LogConfiguration $logConfig) } //calling Signature - public function generateToken($resourcePath, $payloadData, $method, $merchantConfig) + public function generateToken($resourcePath, $payloadData, $method, $merchantConfig, $isResponseMLEForAPI=false) { $date = gmdate("D, d M Y G:i:s ").GlobalParameter::GMT; if($method==GlobalParameter::GET || $method==GlobalParameter::DELETE) { $jwtBody = array("iat"=>$date); + if (!empty($isResponseMLEForAPI)) { + $jwtBody['v-c-response-mle-kid'] = $merchantConfig->getResponseMleKID(); + } } else if($method==GlobalParameter::POST || $method==GlobalParameter::PUT || $method==GlobalParameter::PATCH) { $digestObj = new PayloadDigest($merchantConfig->getLogConfiguration()); $digest = $digestObj->generateDigest($payloadData); $jwtBody = array("digest"=>$digest,"digestAlgorithm"=>"SHA-256","iat"=>$date); + if (!empty($isResponseMLEForAPI)) { + $jwtBody['v-c-response-mle-kid'] = $merchantConfig ->getResponseMleKID(); + } } else { diff --git a/lib/Authentication/OAuth/OAuthTokenGenerator.php b/lib/Authentication/OAuth/OAuthTokenGenerator.php index 08ec6d92..061d07d0 100644 --- a/lib/Authentication/OAuth/OAuthTokenGenerator.php +++ b/lib/Authentication/OAuth/OAuthTokenGenerator.php @@ -22,7 +22,7 @@ public function __construct() } //Generate OAuth Token Function - public function generateToken($resourcePath, $payloadData, $method, $merchantConfig) //add + public function generateToken($resourcePath, $payloadData, $method, $merchantConfig, $isResponseMLEForAPI = false) //add { $accessToken = $merchantConfig->getAccessToken(); if(isset($accessToken)) diff --git a/lib/Authentication/Util/Cache.php b/lib/Authentication/Util/Cache.php index e47b4d28..8184c265 100644 --- a/lib/Authentication/Util/Cache.php +++ b/lib/Authentication/Util/Cache.php @@ -299,4 +299,47 @@ public static function validateCertificateExpiry($certificate, $keyAlias, $cache // throw new MLEException("Error validating certificate expiry: " . $e->getMessage()); } } + + public function getMleResponsePrivateKeyFromFilePath($merchantConfig) ///check + { + $merchantId = $merchantConfig->getMerchantID(); + $filePath = $merchantConfig->getResponseMlePrivateKeyFilePath(); + if (empty($filePath) || !file_exists($filePath)) { + self::$logger->debug("Response MLE private key file not found: " . $filePath); + return null; + } + $cacheKey = $merchantId . GlobalParameter::MLE_CACHE_IDENTIFIER_FOR_RESPONSE_PRIVATE_KEY; + $modTime = filemtime($filePath); + + if (!isset(self::$file_cache[$cacheKey]) || self::$file_cache[$cacheKey]['file_mod_time'] !== $modTime) { + $privateKey = null; + $ext = strtolower(pathinfo($filePath, PATHINFO_EXTENSION)); + try { + if (in_array($ext, ['p12','pfx'])) { + $pkcs12 = file_get_contents($filePath); + $certs = []; + $pwd = $merchantConfig->getResponseMlePrivateKeyFilePassword(); + if (!openssl_pkcs12_read($pkcs12, $certs, $pwd)) { + throw new \Exception("Unable to read p12/pfx private key (bad password or corrupt file)."); + } + $privateKey = $certs['pkey'] ?? null; + } else { + // pem / key / p8 assumed to contain a private key block + $privateKey = file_get_contents($filePath); + } + } catch (\Exception $e) { + self::$logger->error("Failed loading Response MLE private key: " . $e->getMessage()); + return null; + } + if (empty($privateKey)) { + self::$logger->error("Empty Response MLE private key after loading: " . $filePath); + return null; + } + self::$file_cache[$cacheKey] = [ + 'response_mle_private_key' => $privateKey, + 'file_mod_time' => $modTime + ]; + } + return self::$file_cache[$cacheKey]['response_mle_private_key']; + } } diff --git a/lib/Authentication/Util/GlobalParameter.php b/lib/Authentication/Util/GlobalParameter.php index f6e61914..ac3391b0 100644 --- a/lib/Authentication/Util/GlobalParameter.php +++ b/lib/Authentication/Util/GlobalParameter.php @@ -75,6 +75,7 @@ class GlobalParameter const DEFAULT_PROXY_PORT = 443; const MLE_CACHE_IDENTIFIER_FOR_CONFIG_CERT = "_mleCertFromMerchantConfig"; const MLE_CACHE_IDENTIFIER_FOR_P12_CERT = "_mleCertFromP12"; + const MLE_CACHE_IDENTIFIER_FOR_RESPONSE_PRIVATE_KEY = "_mleResponsePrivateKey"; const MERCHANT_SECRET_KEY_REQ = " MerchantSecretKey is Mandatory\n"; const KEY_PASSWORD_EMPTY = "KeyPassword Empty/Null. Assigining merchantID value\n"; diff --git a/lib/Authentication/Util/MLEUtility.php b/lib/Authentication/Util/MLEUtility.php index 8b2956b8..a2775930 100644 --- a/lib/Authentication/Util/MLEUtility.php +++ b/lib/Authentication/Util/MLEUtility.php @@ -59,6 +59,36 @@ public static function checkIsMLEForAPI($merchantConfig, $inboundMLEStatus, $ope return $isMLEForAPI; } + public static function checkIsResponseMLEForAPI($merchantConfig, $operationIds) + { + // default false + $isResponseMLEForAPI = false; + + // Global flag + if (method_exists($merchantConfig, 'getEnableResponseMleGlobally') && + $merchantConfig->getEnableResponseMleGlobally()) { + $isResponseMLEForAPI = true; + } + + // Multiple operation ids (e.g., apiCall, apiCallAsync) + $operationArray = array_map('trim', explode(',', (string)$operationIds)); + + // Per-operation override map (internal response map) + if (method_exists($merchantConfig, 'getInternalMapToControlResponseMLEonAPI')) { + $map = $merchantConfig->getInternalMapToControlResponseMLEonAPI(); + if (is_array($map) && !empty($map)) { + foreach ($operationArray as $operationId) { + if (array_key_exists($operationId, $map)) { + $isResponseMLEForAPI = (bool)$map[$operationId]; //check + break; + } + } + } + } + + return $isResponseMLEForAPI; + } + public static function encryptRequestPayload($merchantConfig, $requestBody) { if ($requestBody === null || $requestBody === '') { @@ -91,6 +121,45 @@ public static function encryptRequestPayload($merchantConfig, $requestBody) return $mleRequest; } + public static function checkIsMleEncryptedResponse($responseBody) + { + if ($responseBody === null) { return false; } + $trim = trim($responseBody); + if ($trim === '' || $trim[0] !== '{') { return false; } + try { + $decoded = json_decode($responseBody, true); + if (!is_array($decoded)) { return false; } + if (count($decoded) !== 1) { return false; } + return array_key_exists('encryptedResponse', $decoded) && is_string($decoded['encryptedResponse']); + } catch (\Exception $e) { + return false; + } + } + + public static function decryptMleResponsePayload($merchantConfig, $mleResponseBody) + { + if (!self::checkIsMleEncryptedResponse($mleResponseBody)) { + throw new MLEException("Response body is not MLE encrypted."); + } + $jweToken = self::getResponseMleToken($mleResponseBody); + if (empty($jweToken)) { + return $mleResponseBody; + } + $privateKey = self::getMleResponsePrivateKey($merchantConfig); + if (empty($privateKey)) { + throw new MLEException("Response MLE private key not available for decryption."); + } + try { + $decrypted = \CyberSource\Authentication\Util\JWE\JWEUtility::decryptJWEUsingPrivateKey($privateKey, $jweToken); + if ($decrypted === null) { + throw new MLEException("Failed to decrypt MLE response payload."); + } + return $decrypted; + } catch (\Exception $e) { + throw new MLEException("MLE Response decryption error: " . $e->getMessage()); + } + } + private static function generateToken($cert, $requestBody) { try { @@ -140,6 +209,24 @@ private static function generateToken($cert, $requestBody) } } + private static function getResponseMleToken($mleResponseBody) + { + try { + $decoded = json_decode($mleResponseBody, true); + return $decoded['encryptedResponse'] ?? null; + } catch (\Exception $e) { + return null; + } + } + + private static function getMleResponsePrivateKey($merchantConfig) + { + if (!isset(self::$cache)) { + self::$cache = new Cache(); + } + return self::$cache->getMleResponsePrivateKeyFromFilePath($merchantConfig); + } + public static function getMLECert($merchantConfig) { try { From cf8fe74cb06a6adb16bebd352ed3d5f2a623c0c5 Mon Sep 17 00:00:00 2001 From: mahmishr Date: Mon, 13 Oct 2025 23:24:07 +0530 Subject: [PATCH 03/20] mle code --- lib/ApiClient.php | 70 ++++- .../Core/MerchantConfiguration.php | 215 ++++++++++----- lib/Authentication/Util/Cache.php | 259 +++++++++++++++--- lib/Authentication/Util/JWE/JWEUtility.php | 3 + lib/Authentication/Util/MLEUtility.php | 39 ++- 5 files changed, 463 insertions(+), 123 deletions(-) diff --git a/lib/ApiClient.php b/lib/ApiClient.php index de524d93..0a5d5a8d 100755 --- a/lib/ApiClient.php +++ b/lib/ApiClient.php @@ -32,6 +32,7 @@ use CyberSource\Authentication\Util\GlobalParameter as GlobalParameter; use CyberSource\Authentication\PayloadDigest\PayloadDigest as PayloadDigest; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; $stream_headers = array(); @@ -464,15 +465,47 @@ public function callApi($resourcePath, $method, $queryParams, $postData, $header } elseif ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299) { // return raw body if response is a file if ($responseType === '\SplFileObject' || $responseType === 'string') { - self::$logger->close(); + self::$logger->close(); return [$http_body, $response_info['http_code'], $http_header]; } - + + // Decrypt BEFORE json_decode //chck + if (MLEUtility::checkIsMleEncryptedResponse($http_body)) { + echo "[MLE][ApiClient] isResponseMLEForAPI=" . ($isResponseMLEForAPI ? "true" : "false") . + " authType=" . $this->merchantConfig->getAuthenticationType() . "\n"; + + try { + $http_body = MLEUtility::decryptMleResponsePayload($this->merchantConfig, $http_body); + self::$logger->debug("HTTP Response Body after MLE decryption:\n" . print_r( + $this->merchantConfig->getLogConfiguration()->isMaskingEnabled() + ? \CyberSource\Utilities\Helpers\DataMasker::maskData($http_body) + : $http_body, + true + )); + echo "m here 11.\n"; + } catch (\Exception $e) { + self::$logger->warning("Response MLE decryption failed: " . $e->getMessage() . " (using encrypted body)"); + } + } + $data = json_decode($http_body); if (json_last_error() > 0) { // if response is a string $data = $http_body; } } else { + // Error path: still attempt decryption so error payload can be read //chck + if (MLEUtility::checkIsMleEncryptedResponse($http_body)) { + echo "[MLE][ApiClient] isResponseMLEForAPI=" . ($isResponseMLEForAPI ? "true" : "false") . + " authType=" . $this->merchantConfig->getAuthenticationType() . "\n"; + + try { + echo "m here 10.\n"; + $http_body = MLEUtility::decryptMleResponsePayload($this->merchantConfig, $http_body); + } catch (\Exception $e) { + // Ignore; proceed with encrypted body + } + } + $data = json_decode($http_body); if (json_last_error() > 0) { // if response is a string $data = $http_body; @@ -488,17 +521,6 @@ public function callApi($resourcePath, $method, $queryParams, $postData, $header ); } - // Response MLE decryption (if flagged and JWT auth) - if ($isResponseMLEForAPI - && $this->merchantConfig->getAuthenticationType() === GlobalParameter::JWT - && \CyberSource\Authentication\Util\MLEUtility::checkIsMleEncryptedResponse($data)) { - try { - $data = \CyberSource\Authentication\Util\MLEUtility::decryptMleResponsePayload($this->merchantConfig, $data); - } catch (\Exception $e) { - self::$logger->warning("Response MLE decryption failed: " . $e->getMessage() . " (falling back to raw response)"); - } - } - self::$logger->close(); return [$data, $response_info['http_code'], $http_header]; } else { @@ -532,11 +554,33 @@ public function callApi($resourcePath, $method, $queryParams, $postData, $header self::$logger->close(); throw $exception; } elseif ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299) { + // Check if response needs MLE decryption for file downloads + if (MLEUtility::checkIsMleEncryptedResponse($http_body)) { + self::$logger->debug("[MLE][ApiClient][FileDownload] Encrypted response detected for file download"); + + try { + $http_body = MLEUtility::decryptMleResponsePayload($this->merchantConfig, $http_body); + self::$logger->debug("File download response decrypted successfully"); + } catch (\Exception $e) { + self::$logger->warning("File download MLE decryption failed: " . $e->getMessage() . " (using encrypted content)"); + } + } + $stream_headers['http_code'] = $response_info['http_code']; self::$logger->close(); return [$http_body, $stream_headers['http_code'], $stream_headers]; } else { + // Error path: attempt decryption for file downloads too + if (MLEUtility::checkIsMleEncryptedResponse($http_body)) { + self::$logger->debug("[MLE][ApiClient][FileDownload] Encrypted error response detected"); + + try { + $http_body = MLEUtility::decryptMleResponsePayload($this->merchantConfig, $http_body); + } catch (\Exception $e) { + // Ignore; proceed with encrypted body for error case + } + } self::$logger->error("ApiException : [".$response_info['http_code']."] Error connecting to the API ($url)"); self::$logger->close(); throw new ApiException( diff --git a/lib/Authentication/Core/MerchantConfiguration.php b/lib/Authentication/Core/MerchantConfiguration.php index 50339c84..05bae908 100644 --- a/lib/Authentication/Core/MerchantConfiguration.php +++ b/lib/Authentication/Core/MerchantConfiguration.php @@ -328,13 +328,13 @@ class MerchantConfiguration */ protected $responseMlePrivateKeyFilePath = ''; - /** - * Private key (in‑memory) used to decrypt Response MLE payloads. - * Provide the raw private key string (e.g. PEM / PKCS#8). Mutually exclusive with responseMlePrivateKeyFilePath. - * - * @var string - */ - protected $responseMlePrivateKey = ''; + // /** + // * Private key (in‑memory) used to decrypt Response MLE payloads. + // * Provide the raw private key string (e.g. PEM / PKCS#8). Mutually exclusive with responseMlePrivateKeyFilePath. + // * + // * @var string + // */ + // protected $responseMlePrivateKey = ''; /** * Password for the private key file (e.g. .p12 or encrypted .pem) used for Response MLE decryption. @@ -1344,16 +1344,16 @@ public function getResponseMlePrivateKeyFilePath() return $this->responseMlePrivateKeyFilePath; } - public function setResponseMlePrivateKey($responseMlePrivateKey) - { - // Accept only string; trim. If resource/object passed, ignore for now (simplify). - $this->responseMlePrivateKey = is_string($responseMlePrivateKey) ? trim($responseMlePrivateKey) : ''; - } + // public function setResponseMlePrivateKey($responseMlePrivateKey) + // { + // // Accept only string; trim. If resource/object passed, ignore for now (simplify). + // $this->responseMlePrivateKey = is_string($responseMlePrivateKey) ? trim($responseMlePrivateKey) : ''; + // } - public function getResponseMlePrivateKey() - { - return $this->responseMlePrivateKey; - } + // public function getResponseMlePrivateKey() + // { + // return $this->responseMlePrivateKey; + // } public function setResponseMlePrivateKeyFilePassword($responseMlePrivateKeyFilePassword) { @@ -1375,8 +1375,8 @@ private function isAssocArrayOfStringBool($array) { } /** - * Get the value of mleKeyAlias - * + * Get the value of mleKeyAlias (legacy) + * @deprecated Use getRequestMleKeyAlias() * @return string */ public function getMleKeyAlias() @@ -1385,33 +1385,108 @@ public function getMleKeyAlias() } /** - * Get requestMleKeyAlias (replacement for mleKeyAlias) + * Get requestMleKeyAlias (authoritative in codebase). + * Fallback order: + * 1. requestMleKeyAlias if non-empty + * 2. mleKeyAlias (legacy) if non-empty + * 3. assign default to requestMleKeyAlias and return it * * @return string */ public function getRequestMleKeyAlias() { - if (!isset($this->requestMleKeyAlias) || empty(trim($this->requestMleKeyAlias))) { - $this->requestMleKeyAlias = GlobalParameter::DEFAULT_MLE_ALIAS_FOR_CERT; - } + // if (isset($this->requestMleKeyAlias) && trim($this->requestMleKeyAlias) !== '') { + // return $this->requestMleKeyAlias; + // } + // if (isset($this->mleKeyAlias) && trim($this->mleKeyAlias) !== '') { + // return $this->mleKeyAlias; + // } + // Neither provided; set default only for requestMleKeyAlias return $this->requestMleKeyAlias; } /** - * Set requestMleKeyAlias (preferred new field) + * Set requestMleKeyAlias. + * If legacy mleKeyAlias already set with a different value -> error. //to do + * + * Empty/blank input is treated as "not set" (kept empty for fallback/default logic). * * @param string $requestMleKeyAlias * @return $this */ public function setRequestMleKeyAlias($requestMleKeyAlias) { - if (!is_null($requestMleKeyAlias) && strlen(trim($requestMleKeyAlias)) > 0) { - $this->requestMleKeyAlias = trim($requestMleKeyAlias); - } else { - $this->requestMleKeyAlias = GlobalParameter::DEFAULT_MLE_ALIAS_FOR_CERT; + // $alias = trim((string)$requestMleKeyAlias); + + // if ($alias === '') { + // // Leave empty; fallback will occur in getter + // $this->requestMleKeyAlias = ''; + // return $this; + // } + + // if (isset($this->mleKeyAlias) && trim($this->mleKeyAlias) !== '' && $this->mleKeyAlias !== $alias) { + // $msg = "mleKeyAlias and requestMleKeyAlias must be the same value when both are set."; + // if (self::$logger) { self::$logger->error($msg); } + // throw new \InvalidArgumentException($msg); + // } + $alias = trim((string) $requestMleKeyAlias); + + if ($alias !== '') { + $this->requestMleKeyAlias = $alias; + } + return $this; + + // // 2. Else if legacy mleKeyAlias set, promote it to requestMleKeyAlias + // if (isset($this->mleKeyAlias) && trim($this->mleKeyAlias) !== '') { + // $this->requestMleKeyAlias = trim($this->mleKeyAlias); + // return $this; + // } + + // // 3. Else assign default constant + // $this->requestMleKeyAlias = GlobalParameter::DEFAULT_MLE_ALIAS_FOR_CERT; + // return $this; + } + + /** + * Legacy setter for mleKeyAlias. + * If requestMleKeyAlias already set with a different value -> error. //to do + * + * Empty/blank input is treated as "not set". + * + * @param string $mleKeyAlias + * @return $this + */ + public function setMleKeyAlias($mleKeyAlias) + { + $alias = trim((string)$mleKeyAlias); + if ($alias === '') { + return $this; + } + + // if ($alias === '') { + // $this->mleKeyAlias = ''; + // return $this; + // } + + // if (isset($this->requestMleKeyAlias) && trim($this->requestMleKeyAlias) !== '' && $this->requestMleKeyAlias !== $alias) { + // $msg = "mleKeyAlias and requestMleKeyAlias must be the same value when both are set."; + // if (self::$logger) { self::$logger->error($msg); } + // throw new \InvalidArgumentException($msg); + // } + if ( + $this->mleKeyAlias === GlobalParameter::DEFAULT_MLE_ALIAS_FOR_CERT + || $this->mleKeyAlias === '' + || $this->mleKeyAlias === null + ) { + $this->mleKeyAlias = $alias; + } + if ( + $this->requestMleKeyAlias === GlobalParameter::DEFAULT_MLE_ALIAS_FOR_CERT + || $this->requestMleKeyAlias === '' + || $this->requestMleKeyAlias === null + ) { + $this->requestMleKeyAlias = $alias; } - // Keep legacy field synchronized for any older code paths. - $this->mleKeyAlias = $this->requestMleKeyAlias; return $this; } @@ -1528,7 +1603,7 @@ public static function setMerchantCredentials($connectionDet) // If both are set, they must be equal if ($useMLE !== null && $enableMLE !== null && $useMLE !== $enableMLE) { - throw new \InvalidArgumentException( + throw new InvalidArgumentException( "useMLEGlobally and enableRequestMLEForOptionalApisGlobally must have the same value if both are set." ); } @@ -1542,19 +1617,20 @@ public static function setMerchantCredentials($connectionDet) $config = $config->setMapToControlMLEonAPI($connectionDet->mapToControlMLEonAPI); } - if (isset($connectionDet->mleKeyAlias)) { - $config = $config->setMleKeyAlias($connectionDet->mleKeyAlias); - } - if (isset($connectionDet->mleForRequestPublicCertPath)) { $config = $config->setMleForRequestPublicCertPath($connectionDet->mleForRequestPublicCertPath); } - // Prefer new requestMleKeyAlias; fallback to deprecated mleKeyAlias - if (isset($connectionDet->requestMleKeyAlias)) { - $config = $config->setRequestMleKeyAlias($connectionDet->requestMleKeyAlias); - } elseif (isset($connectionDet->mleKeyAlias)) { - $config = $config->setMleKeyAlias($connectionDet->mleKeyAlias); + // Prefer new field; fall back to legacy mleKeyAlias for backward compatibility. + $rawAlias = null; + if (isset($connectionDet->requestMleKeyAlias) && trim((string) $connectionDet->requestMleKeyAlias) !== '') { + $rawAlias = $connectionDet->requestMleKeyAlias; + } elseif (isset($connectionDet->mleKeyAlias) && trim((string) $connectionDet->mleKeyAlias) !== '') { + $rawAlias = $connectionDet->mleKeyAlias; + $config = $config->setMleKeyAlias($rawAlias); // keep legacy field in sync + } + if ($rawAlias !== null) { + $config=$config->setRequestMleKeyAlias($rawAlias); } // Response MLE (outbound) new fields @@ -1570,9 +1646,9 @@ public static function setMerchantCredentials($connectionDet) if (isset($connectionDet->responseMlePrivateKeyFilePassword)) { $config = $config->setResponseMlePrivateKeyFilePassword($connectionDet->responseMlePrivateKeyFilePassword); } - if (isset($connectionDet->responseMlePrivateKey)) { - $config = $config->setResponseMlePrivateKey($connectionDet->responseMlePrivateKey); - } + // if (isset($connectionDet->responseMlePrivateKey)) { + // $config = $config->setResponseMlePrivateKey($connectionDet->responseMlePrivateKey); + // } $config->validateMerchantData(); if($error_message != null){ @@ -1790,41 +1866,44 @@ private function validateMLEConfiguration(){ } $hasFilePath = !empty($this->responseMlePrivateKeyFilePath); - $hasInMemoryKey = !empty($this->responseMlePrivateKey); - - if (!$hasFilePath && !$hasInMemoryKey) { - $error_message = "Response MLE enabled but neither responseMlePrivateKeyFilePath nor responseMlePrivateKey provided. Provide exactly one."; - $exception = new AuthException($error_message, 0); - self::$logger->error($error_message); - throw $exception; - } - - if ($hasFilePath && $hasInMemoryKey) { - $error_message = "Both responseMlePrivateKeyFilePath and responseMlePrivateKey supplied. Provide only one."; - $exception = new AuthException($error_message, 0); - self::$logger->error($error_message); - throw $exception; - } + // $hasInMemoryKey = !empty($this->responseMlePrivateKey); + + // if (!$hasFilePath && !$hasInMemoryKey) { + // $error_message = "Response MLE enabled but neither responseMlePrivateKeyFilePath nor responseMlePrivateKey provided. Provide exactly one."; + // $exception = new AuthException($error_message, 0); + // self::$logger->error($error_message); + // throw $exception; + // } + + // if ($hasFilePath && $hasInMemoryKey) { + // $error_message = "Both responseMlePrivateKeyFilePath and responseMlePrivateKey supplied. Provide only one."; + // $exception = new AuthException($error_message, 0); + // self::$logger->error($error_message); + // throw $exception; + // } if ($hasFilePath) { - if (!file_exists($this->responseMlePrivateKeyFilePath) || + if ( + !file_exists($this->responseMlePrivateKeyFilePath) || !is_readable($this->responseMlePrivateKeyFilePath) || - !is_file($this->responseMlePrivateKeyFilePath)) { + !is_file($this->responseMlePrivateKeyFilePath) + ) { $error_message = "Response MLE private key file not found or not readable at " . $this->responseMlePrivateKeyFilePath; $exception = new AuthException($error_message, 0); self::$logger->error($error_message); throw $exception; } - // Password (if any) is optional; no strict validation here. - } else { - // Basic sanity check for in-memory key: must contain typical PEM header or be non-trivial length. - if (strlen($this->responseMlePrivateKey) < 32) { - $error_message = "responseMlePrivateKey appears invalid (too short)."; - $exception = new AuthException($error_message, 0); - self::$logger->error($error_message); - throw $exception; - } } + // Password (if any) is optional; no strict validation here. + // } else { + // // Basic sanity check for in-memory key: must contain typical PEM header or be non-trivial length. + // if (strlen($this->responseMlePrivateKey) < 32) { + // $error_message = "responseMlePrivateKey appears invalid (too short)."; + // $exception = new AuthException($error_message, 0); + // self::$logger->error($error_message); + // throw $exception; + // } + // } if (empty($this->responseMleKID)) { $error_message = "Response MLE enabled but responseMleKID not provided."; diff --git a/lib/Authentication/Util/Cache.php b/lib/Authentication/Util/Cache.php index 8184c265..230d6c22 100644 --- a/lib/Authentication/Util/Cache.php +++ b/lib/Authentication/Util/Cache.php @@ -11,7 +11,7 @@ class Cache { private static $file_cache = array(); private static $logger = null; - + private static $responseMleKeyLoadFailed = false; // suppress repeated error logs public function __construct() { @@ -19,6 +19,13 @@ public function __construct() self::$logger = (new LogFactory())->getLogger(\CyberSource\Utilities\Helpers\ClassHelper::getClassName(get_class($this)), new \CyberSource\Logging\LogConfiguration()); } } + public static function clearAllFileCache(): void + { + self::$file_cache = []; + if (self::$logger) { + self::$logger->debug("Cache: cleared all entries."); + } + } public function updateCache($filePath, $merchantConfig) { @@ -171,13 +178,41 @@ private function setupMLECache($merchantConfig, $cacheKey, $mleCertPath) { $configCertIdentifier = strtolower(GlobalParameter::MLE_CACHE_IDENTIFIER_FOR_CONFIG_CERT); $p12CertIdentifier = strtolower(GlobalParameter::MLE_CACHE_IDENTIFIER_FOR_P12_CERT); + $respPrivKeyIdentifier = strtolower(GlobalParameter::MLE_CACHE_IDENTIFIER_FOR_RESPONSE_PRIVATE_KEY); + + // --- Response MLE Private Key handling (early return like Java) --- + if (substr($lowercaseCacheKey, -strlen($respPrivKeyIdentifier)) === $respPrivKeyIdentifier) { + $password = $merchantConfig->getResponseMlePrivateKeyFilePassword(); + try { + $loaded = $this->loadResponseMlePrivateKey($mleCertPath, $password); + self::$file_cache[$cacheKey] = [ + 'response_mle_private_key' => $loaded['pem'], + 'file_mod_time' => $fileModTime + ]; + self::$responseMleKeyLoadFailed = false; // reset on success + if (self::$logger) { self::$logger->debug("Response MLE private key cached (length=".strlen($loaded['pem']).")"); } + } catch (MLEException $e) { + if (!self::$responseMleKeyLoadFailed) { + self::$responseMleKeyLoadFailed = true; // only log first hard failure + if (self::$logger) { self::$logger->error("Response MLE private key load failed: ".$e->getMessage()); } + } else { + if (self::$logger) { self::$logger->debug("Response MLE private key load failed again; suppressing repeated error log."); } + } + } + return; // early return either way + } + // --- End Response MLE block --- + if (str_ends_with($lowercaseCacheKey, $configCertIdentifier)) { $mleCert = $this->loadCertificateFromPEM($mleCertPath, $merchantConfig); } elseif (str_ends_with($lowercaseCacheKey, $p12CertIdentifier)) { $mleCert = $this->loadCertificateFromP12($mleCertPath, $merchantConfig); + } else { + self::$logger->warning("Unrecognized MLE cache key pattern: " . $cacheKey); + return; } - self::validateCertificateExpiry($mleCert, $merchantConfig->getMleKeyAlias(), $cacheKey); + self::validateCertificateExpiry($mleCert, $merchantConfig->getRequestMleKeyAlias(), $cacheKey); self::$file_cache[$cacheKey] = [ 'mle_cert' => $mleCert, @@ -203,9 +238,9 @@ private function loadCertificateFromPEM($filePath, $merchantConfig) { } try { - $mleCert = Utility::findCertByAlias(array("extracerts" => $certs), $merchantConfig->getMleKeyAlias()); + $mleCert = Utility::findCertByAlias(array("extracerts" => $certs), $merchantConfig->getRequestMleKeyAlias()); } catch (\Exception $e) { - self::$logger->warning("No certificate found for the specified mleKeyAlias '{$merchantConfig->getMleKeyAlias()}'. Using the first certificate from file {$filePath} as the MLE request certificate."); + self::$logger->warning("No certificate found for the specified RequestMleKeyAlias '{$merchantConfig->getRequestMleKeyAlias()}'. Using the first certificate from file {$filePath} as the MLE request certificate."); $mleCert = $certs[0]; } @@ -237,10 +272,10 @@ private function loadCertificateFromP12($filePath, $merchantConfig) { throw $exception; } - $mleCert = Utility::findCertByAlias($certs, $merchantConfig->getMleKeyAlias()); + $mleCert = Utility::findCertByAlias($certs, $merchantConfig->getRequestMleKeyAlias()); if ($mleCert == null) { - throw new MLEException("No certificate found with alias " . $merchantConfig->getMleKeyAlias() . " in " . $filePath); + throw new MLEException("No certificate found with alias " . $merchantConfig->getRequestMleKeyAlias() . " in " . $filePath); } return $mleCert; @@ -298,48 +333,200 @@ public static function validateCertificateExpiry($certificate, $keyAlias, $cache self::$logger->error("Error validating certificate expiry: " . $e->getMessage()); // throw new MLEException("Error validating certificate expiry: " . $e->getMessage()); } + } /** + * Load Response MLE private key supporting: + * - PKCS#12 (.p12, .pfx) + * - PEM / KEY / P8 + * Returns ['pem' => normalized unencrypted PEM string, 'resource' => OpenSSL key resource] + */ + private function loadResponseMlePrivateKey(string $filePath, ?string $password): array + { + if (!extension_loaded('openssl')) { + throw new MLEException("OpenSSL extension not loaded; cannot read private key."); + } + + $ext = strtolower(pathinfo($filePath, PATHINFO_EXTENSION)); + + if (in_array($ext, ['p12','pfx'], true)) { + $pkcs12 = file_get_contents($filePath); + if ($pkcs12 === false) { + throw new MLEException("Unable to read PKCS#12 file: {$filePath}"); + } + $certs = []; + if (!openssl_pkcs12_read($pkcs12, $certs, (string)$password)) { + $err = openssl_error_string(); + throw new MLEException("Unable to parse PKCS#12: {$filePath}. OpenSSL: {$err}"); + } + if (empty($certs['pkey'])) { + throw new MLEException("No private key found in PKCS#12: {$filePath}"); + } + + $exported = ''; + $exportOk = @openssl_pkey_export($certs['pkey'], $exported, null); + if (!$exportOk || trim($exported) === '') { + // Broader fallback: accept any BEGIN .. PRIVATE KEY block + if (is_string($certs['pkey']) && preg_match('/BEGIN\\s.+PRIVATE KEY/', $certs['pkey'])) { + $exported = $certs['pkey']; + } else { + // Try again via handle + $handle = @openssl_pkey_get_private($certs['pkey'], (string)$password); + if ($handle && @openssl_pkey_export($handle, $exported, null) && trim($exported) !== '') { + // success + } else { + $err = openssl_error_string(); + throw new MLEException("Failed exporting private key from PKCS#12 (OpenSSL 3 legacy issue). OpenSSL: {$err}"); + } + } + } + + $resource = @openssl_pkey_get_private($exported, (string)$password) ?: @openssl_pkey_get_private($exported); + if ($resource === false) { + throw new MLEException("Re-validation of PKCS#12 private key failed after fallback."); + } + return ['pem' => $exported, 'resource' => $resource]; + } + + if (in_array($ext, ['pem','key','p8'], true)) { + // Use your proven decryption method for encrypted PEM/P8 keys + try { + $unencryptedPem = $this->decryptPrivateKeyPem($filePath, $password); + $resource = @openssl_pkey_get_private($unencryptedPem); + if ($resource === false) { + throw new MLEException("Failed to create resource from decrypted PEM"); + } + return ['pem' => $unencryptedPem, 'resource' => $resource]; + } catch (\Exception $e) { + // If decryption fails, try the original approach for unencrypted keys + $raw = file_get_contents($filePath); + if ($raw === false || trim($raw) === '') { + throw new MLEException("Unable to read key file: {$filePath}"); + } + + $priv = @openssl_pkey_get_private($raw); + if ($priv === false) { + throw new MLEException("Unable to load private key: {$filePath}. " . $e->getMessage()); + } + + // Normalize unencrypted keys + $norm = ''; + if (@openssl_pkey_export($priv, $norm, null) && trim($norm) !== '') { + $raw = $norm; + } + + return ['pem' => $raw, 'resource' => $priv]; + } + } + + throw new MLEException("Unsupported Response MLE Private Key file format: {$ext}. Supported: .p12, .pfx, .pem, .key, .p8"); + } + + /** + * Decrypt encrypted PEM/P8 private key files using your proven method + * Integrated from your working code snippet with cross-platform compatibility + */ + private function decryptPrivateKeyPem(string $pemPath, ?string $passphrase): string + { + if (!extension_loaded('openssl')) { + throw new MLEException('The OpenSSL extension is required.'); + } + if (!is_file($pemPath) || !is_readable($pemPath)) { + throw new MLEException("PEM file not found or not readable: {$pemPath}"); + } + + $pem = file_get_contents($pemPath); + if ($pem === false || $pem === '') { + throw new MLEException('Failed to read PEM file contents.'); + } + + // Only attempt decryption if password provided and key appears encrypted + $isEncrypted = strpos($pem, 'BEGIN ENCRYPTED PRIVATE KEY') !== false || + strpos($pem, 'Proc-Type: 4,ENCRYPTED') !== false; + + if (!$isEncrypted) { + // Return as-is for unencrypted keys + return $pem; + } + + if ($passphrase === null || $passphrase === '') { + throw new MLEException('Private key is encrypted but no passphrase provided'); + } + + // Obtain an OpenSSL private key handle using the passphrase + $key = openssl_pkey_get_private($pem, $passphrase); + if ($key === false) { + // Collect the last OpenSSL error to help with debugging + $err = ''; + while ($msg = openssl_error_string()) { + $err .= ($err ? ' | ' : '') . $msg; + } + throw new MLEException('Unable to decrypt private key. ' . ($err ?: 'Check passphrase and key format.')); + } + + // Export the key without a passphrase (i.e., decrypted) + $unencryptedPem = ''; + + // Universal config - works for RSA, EC, DSA keys + // May specify what's needed for Windows compatibility + $configArgs = [ + 'config' => 'NUL', // Pass config file search on Windows + // private_key_type - let OpenSSL auto-detect + // private_key_bits - not applicable to all types + ]; + + // First attempt with minimal config (Windows-friendly) + $success = @openssl_pkey_export($key, $unencryptedPem, null, $configArgs); + + // If that fails, try without any config args (best for Mac/Linux) + if (!$success) { + $success = @openssl_pkey_export($key, $unencryptedPem, null); + } + + if (!$success) { + // Collect OpenSSL errors for debugging + $err = ''; + while ($msg = openssl_error_string()) { + $err .= ($err ? ' | ' : '') . $msg; + } + throw new MLEException('Failed to export unencrypted private key. ' . ($err ?: 'Unknown error')); + } + + // Free the key handle explicitly (PHP version compatibility) + if (is_resource($key)) { + openssl_free_key($key); + } elseif ($key instanceof \OpenSSLAsymmetricKey) { + // PHP 8+: no need to free explicitly, GC will handle it + } + + return $unencryptedPem; } - public function getMleResponsePrivateKeyFromFilePath($merchantConfig) ///check + public function getMleResponsePrivateKeyFromFilePath($merchantConfig) { $merchantId = $merchantConfig->getMerchantID(); $filePath = $merchantConfig->getResponseMlePrivateKeyFilePath(); + if (empty($filePath) || !file_exists($filePath)) { self::$logger->debug("Response MLE private key file not found: " . $filePath); return null; } + $cacheKey = $merchantId . GlobalParameter::MLE_CACHE_IDENTIFIER_FOR_RESPONSE_PRIVATE_KEY; $modTime = filemtime($filePath); - if (!isset(self::$file_cache[$cacheKey]) || self::$file_cache[$cacheKey]['file_mod_time'] !== $modTime) { - $privateKey = null; - $ext = strtolower(pathinfo($filePath, PATHINFO_EXTENSION)); - try { - if (in_array($ext, ['p12','pfx'])) { - $pkcs12 = file_get_contents($filePath); - $certs = []; - $pwd = $merchantConfig->getResponseMlePrivateKeyFilePassword(); - if (!openssl_pkcs12_read($pkcs12, $certs, $pwd)) { - throw new \Exception("Unable to read p12/pfx private key (bad password or corrupt file)."); - } - $privateKey = $certs['pkey'] ?? null; - } else { - // pem / key / p8 assumed to contain a private key block - $privateKey = file_get_contents($filePath); - } - } catch (\Exception $e) { - self::$logger->error("Failed loading Response MLE private key: " . $e->getMessage()); - return null; - } - if (empty($privateKey)) { - self::$logger->error("Empty Response MLE private key after loading: " . $filePath); - return null; - } - self::$file_cache[$cacheKey] = [ - 'response_mle_private_key' => $privateKey, - 'file_mod_time' => $modTime - ]; + if ($modTime === false) { + self::$logger->error("Unable to obtain modification time for response MLE private key file: " . $filePath); + return null; } - return self::$file_cache[$cacheKey]['response_mle_private_key']; + + if (!isset(self::$file_cache[$cacheKey]) || + self::$file_cache[$cacheKey]['file_mod_time'] !== $modTime) { + + $this->setupMLECache($merchantConfig, $cacheKey, $filePath); + } else { + self::$logger->debug("Response MLE private key retrieved from cache."); + } + + return self::$file_cache[$cacheKey]['response_mle_private_key'] ?? null; + } } diff --git a/lib/Authentication/Util/JWE/JWEUtility.php b/lib/Authentication/Util/JWE/JWEUtility.php index 216e5fc0..8981e201 100644 --- a/lib/Authentication/Util/JWE/JWEUtility.php +++ b/lib/Authentication/Util/JWE/JWEUtility.php @@ -84,6 +84,7 @@ public static function decryptJWEUsingPEM(MerchantConfiguration $merchantConfig, public static function decryptJWEUsingPrivateKey(string $privateKey, string $encodedResponse) { $jwk = JWKFactory::createFromKey($privateKey); + echo "jwk: " . json_encode($jwk->all()); // The key encryption algorithm manager with the A256KW algorithm. $keyEncryptionAlgorithmManager = new AlgorithmManager([ new RSAOAEP256() @@ -107,8 +108,10 @@ public static function decryptJWEUsingPrivateKey(string $privateKey, string $enc $jwe = $serializerManager->unserialize($encodedResponse); if($jweDecrypter -> decryptUsingKey($jwe, $jwk, 0)) { + echo "here 101 .\n"; return $jwe ->getPayload(); } else { + echo "here 100 .\n"; return null; } } diff --git a/lib/Authentication/Util/MLEUtility.php b/lib/Authentication/Util/MLEUtility.php index a2775930..aa6de9c3 100644 --- a/lib/Authentication/Util/MLEUtility.php +++ b/lib/Authentication/Util/MLEUtility.php @@ -16,6 +16,7 @@ use Jose\Component\Encryption\Compression\CompressionMethodManager; use Jose\Component\Encryption\Compression\Deflate; use CyberSource\Authentication\Util\MLEException; +use \CyberSource\Authentication\Util\JWE\JWEUtility; /* Purpose : MLE encryption for request body @@ -85,6 +86,7 @@ public static function checkIsResponseMLEForAPI($merchantConfig, $operationIds) } } } + echo "[MLE] Response MLE decision for operations [" . implode(',', $operationArray) . "]: " . ($isResponseMLEForAPI ? "true" : "false") . "\n"; return $isResponseMLEForAPI; } @@ -123,6 +125,7 @@ public static function encryptRequestPayload($merchantConfig, $requestBody) public static function checkIsMleEncryptedResponse($responseBody) { + echo " m here 2.\n"; if ($responseBody === null) { return false; } $trim = trim($responseBody); if ($trim === '' || $trim[0] !== '{') { return false; } @@ -134,26 +137,31 @@ public static function checkIsMleEncryptedResponse($responseBody) } catch (\Exception $e) { return false; } - } - - public static function decryptMleResponsePayload($merchantConfig, $mleResponseBody) + } public static function decryptMleResponsePayload($merchantConfig, $mleResponseBody) { + echo "[MLE][Decrypt] Enter decryptMleResponsePayload()\n"; + if (!self::checkIsMleEncryptedResponse($mleResponseBody)) { throw new MLEException("Response body is not MLE encrypted."); } $jweToken = self::getResponseMleToken($mleResponseBody); if (empty($jweToken)) { + echo "[MLE][Decrypt] JWE token missing in encryptedResponse wrapper.\n"; return $mleResponseBody; } $privateKey = self::getMleResponsePrivateKey($merchantConfig); if (empty($privateKey)) { + echo "[MLE][Decrypt] Private key unavailable for decryption.\n"; throw new MLEException("Response MLE private key not available for decryption."); } + echo "[MLE][Decrypt] Loaded private key (" . strlen($privateKey) . " bytes).\n"; // Cache already handles password decryption and returns unencrypted PEM + // No password needed for JWE decryption since key is already decrypted try { - $decrypted = \CyberSource\Authentication\Util\JWE\JWEUtility::decryptJWEUsingPrivateKey($privateKey, $jweToken); + $decrypted = JWEUtility::decryptJWEUsingPrivateKey($privateKey, $jweToken); if ($decrypted === null) { throw new MLEException("Failed to decrypt MLE response payload."); } + echo "[MLE][Decrypt] Decryption successful. Decrypted payload length: " . strlen($decrypted) . "\n"; return $decrypted; } catch (\Exception $e) { throw new MLEException("MLE Response decryption error: " . $e->getMessage()); @@ -211,6 +219,7 @@ private static function generateToken($cert, $requestBody) private static function getResponseMleToken($mleResponseBody) { + echo " m here 1.\n"; try { $decoded = json_decode($mleResponseBody, true); return $decoded['encryptedResponse'] ?? null; @@ -221,10 +230,28 @@ private static function getResponseMleToken($mleResponseBody) private static function getMleResponsePrivateKey($merchantConfig) { - if (!isset(self::$cache)) { + // if (null != $merchantConfig->getResponseMlePrivateKey()) { + // echo "[MLE] Using inline response private key.\n"; + // return $merchantConfig->getResponseMlePrivateKey(); + // } + + if (!isset(self::$cache)) { //check static n multithreading + echo "[MLE] Creating Cache instance for response private key.\n"; + self::$cache = new Cache(); } - return self::$cache->getMleResponsePrivateKeyFromFilePath($merchantConfig); + // self::$cache::clearAllFileCache(); + // echo "[MLE] Cleared all file cache.\n"; + $key = self::$cache->getMleResponsePrivateKeyFromFilePath($merchantConfig); + + if ($key) { + echo "[MLE] Loaded response private key from file/cache.\n"; + } else { + echo "[MLE] Failed to load response private key from file/cache.\n"; + } + + return $key; + // return self::$cache->getMleResponsePrivateKeyFromFilePath($merchantConfig); } public static function getMLECert($merchantConfig) From f65bf922a5b2214bafd8f48cd525db5ba937bb18 Mon Sep 17 00:00:00 2001 From: mahmishr Date: Wed, 15 Oct 2025 02:54:26 +0530 Subject: [PATCH 04/20] refactoring --- lib/ApiClient.php | 41 +++--- lib/Authentication/Util/Cache.php | 178 +------------------------ lib/Authentication/Util/MLEUtility.php | 22 ++- lib/Authentication/Util/Utility.php | 174 ++++++++++++++++++++++++ 4 files changed, 213 insertions(+), 202 deletions(-) diff --git a/lib/ApiClient.php b/lib/ApiClient.php index 0a5d5a8d..42effd85 100755 --- a/lib/ApiClient.php +++ b/lib/ApiClient.php @@ -469,22 +469,16 @@ public function callApi($resourcePath, $method, $queryParams, $postData, $header return [$http_body, $response_info['http_code'], $http_header]; } - // Decrypt BEFORE json_decode //chck + // Decrypt BEFORE json_decode if (MLEUtility::checkIsMleEncryptedResponse($http_body)) { - echo "[MLE][ApiClient] isResponseMLEForAPI=" . ($isResponseMLEForAPI ? "true" : "false") . - " authType=" . $this->merchantConfig->getAuthenticationType() . "\n"; try { $http_body = MLEUtility::decryptMleResponsePayload($this->merchantConfig, $http_body); - self::$logger->debug("HTTP Response Body after MLE decryption:\n" . print_r( - $this->merchantConfig->getLogConfiguration()->isMaskingEnabled() - ? \CyberSource\Utilities\Helpers\DataMasker::maskData($http_body) - : $http_body, - true - )); - echo "m here 11.\n"; } catch (\Exception $e) { - self::$logger->warning("Response MLE decryption failed: " . $e->getMessage() . " (using encrypted body)"); + $error_message = "Response MLE decryption failed: " . $e->getMessage(); + self::$logger->error("ApiException : " . $error_message); + self::$logger->close(); + throw new ApiException($error_message); } } @@ -493,16 +487,14 @@ public function callApi($resourcePath, $method, $queryParams, $postData, $header $data = $http_body; } } else { - // Error path: still attempt decryption so error payload can be read //chck + // Error path: still attempt decryption so error payload can be read if (MLEUtility::checkIsMleEncryptedResponse($http_body)) { echo "[MLE][ApiClient] isResponseMLEForAPI=" . ($isResponseMLEForAPI ? "true" : "false") . " authType=" . $this->merchantConfig->getAuthenticationType() . "\n"; - try { - echo "m here 10.\n"; $http_body = MLEUtility::decryptMleResponsePayload($this->merchantConfig, $http_body); } catch (\Exception $e) { - // Ignore; proceed with encrypted body + // Ignore; proceeding with encrypted body } } @@ -553,16 +545,15 @@ public function callApi($resourcePath, $method, $queryParams, $postData, $header $exception->setResponseObject($response_info); self::$logger->close(); throw $exception; - } elseif ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299) { - // Check if response needs MLE decryption for file downloads - if (MLEUtility::checkIsMleEncryptedResponse($http_body)) { - self::$logger->debug("[MLE][ApiClient][FileDownload] Encrypted response detected for file download"); - + } elseif ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299) { // Check if response needs MLE decryption for file downloads + if (MLEUtility::checkIsMleEncryptedResponse($http_body)) { try { $http_body = MLEUtility::decryptMleResponsePayload($this->merchantConfig, $http_body); - self::$logger->debug("File download response decrypted successfully"); } catch (\Exception $e) { - self::$logger->warning("File download MLE decryption failed: " . $e->getMessage() . " (using encrypted content)"); + $error_message = "File download MLE decryption failed: " . $e->getMessage(); + self::$logger->error("ApiException : " . $error_message); + self::$logger->close(); + throw new ApiException($error_message); } } @@ -572,13 +563,11 @@ public function callApi($resourcePath, $method, $queryParams, $postData, $header return [$http_body, $stream_headers['http_code'], $stream_headers]; } else { // Error path: attempt decryption for file downloads too - if (MLEUtility::checkIsMleEncryptedResponse($http_body)) { - self::$logger->debug("[MLE][ApiClient][FileDownload] Encrypted error response detected"); - + if (MLEUtility::checkIsMleEncryptedResponse($http_body)) { try { $http_body = MLEUtility::decryptMleResponsePayload($this->merchantConfig, $http_body); } catch (\Exception $e) { - // Ignore; proceed with encrypted body for error case + // Ignore; proceeding with encrypted body for error case } } self::$logger->error("ApiException : [".$response_info['http_code']."] Error connecting to the API ($url)"); diff --git a/lib/Authentication/Util/Cache.php b/lib/Authentication/Util/Cache.php index 230d6c22..5127022c 100644 --- a/lib/Authentication/Util/Cache.php +++ b/lib/Authentication/Util/Cache.php @@ -11,7 +11,7 @@ class Cache { private static $file_cache = array(); private static $logger = null; - private static $responseMleKeyLoadFailed = false; // suppress repeated error logs + private static $responseMleKeyLoadFailed = false; public function __construct() { @@ -178,28 +178,25 @@ private function setupMLECache($merchantConfig, $cacheKey, $mleCertPath) { $configCertIdentifier = strtolower(GlobalParameter::MLE_CACHE_IDENTIFIER_FOR_CONFIG_CERT); $p12CertIdentifier = strtolower(GlobalParameter::MLE_CACHE_IDENTIFIER_FOR_P12_CERT); - $respPrivKeyIdentifier = strtolower(GlobalParameter::MLE_CACHE_IDENTIFIER_FOR_RESPONSE_PRIVATE_KEY); - - // --- Response MLE Private Key handling (early return like Java) --- + $respPrivKeyIdentifier = strtolower(GlobalParameter::MLE_CACHE_IDENTIFIER_FOR_RESPONSE_PRIVATE_KEY); // --- Response MLE Private Key handling with early return --- if (substr($lowercaseCacheKey, -strlen($respPrivKeyIdentifier)) === $respPrivKeyIdentifier) { $password = $merchantConfig->getResponseMlePrivateKeyFilePassword(); try { - $loaded = $this->loadResponseMlePrivateKey($mleCertPath, $password); + $loaded = Utility::loadResponseMlePrivateKey($mleCertPath, $password); self::$file_cache[$cacheKey] = [ 'response_mle_private_key' => $loaded['pem'], 'file_mod_time' => $fileModTime ]; self::$responseMleKeyLoadFailed = false; // reset on success - if (self::$logger) { self::$logger->debug("Response MLE private key cached (length=".strlen($loaded['pem']).")"); } } catch (MLEException $e) { if (!self::$responseMleKeyLoadFailed) { - self::$responseMleKeyLoadFailed = true; // only log first hard failure + self::$responseMleKeyLoadFailed = true; if (self::$logger) { self::$logger->error("Response MLE private key load failed: ".$e->getMessage()); } } else { if (self::$logger) { self::$logger->debug("Response MLE private key load failed again; suppressing repeated error log."); } } } - return; // early return either way + return; } // --- End Response MLE block --- @@ -333,171 +330,6 @@ public static function validateCertificateExpiry($certificate, $keyAlias, $cache self::$logger->error("Error validating certificate expiry: " . $e->getMessage()); // throw new MLEException("Error validating certificate expiry: " . $e->getMessage()); } - } /** - * Load Response MLE private key supporting: - * - PKCS#12 (.p12, .pfx) - * - PEM / KEY / P8 - * Returns ['pem' => normalized unencrypted PEM string, 'resource' => OpenSSL key resource] - */ - private function loadResponseMlePrivateKey(string $filePath, ?string $password): array - { - if (!extension_loaded('openssl')) { - throw new MLEException("OpenSSL extension not loaded; cannot read private key."); - } - - $ext = strtolower(pathinfo($filePath, PATHINFO_EXTENSION)); - - if (in_array($ext, ['p12','pfx'], true)) { - $pkcs12 = file_get_contents($filePath); - if ($pkcs12 === false) { - throw new MLEException("Unable to read PKCS#12 file: {$filePath}"); - } - $certs = []; - if (!openssl_pkcs12_read($pkcs12, $certs, (string)$password)) { - $err = openssl_error_string(); - throw new MLEException("Unable to parse PKCS#12: {$filePath}. OpenSSL: {$err}"); - } - if (empty($certs['pkey'])) { - throw new MLEException("No private key found in PKCS#12: {$filePath}"); - } - - $exported = ''; - $exportOk = @openssl_pkey_export($certs['pkey'], $exported, null); - if (!$exportOk || trim($exported) === '') { - // Broader fallback: accept any BEGIN .. PRIVATE KEY block - if (is_string($certs['pkey']) && preg_match('/BEGIN\\s.+PRIVATE KEY/', $certs['pkey'])) { - $exported = $certs['pkey']; - } else { - // Try again via handle - $handle = @openssl_pkey_get_private($certs['pkey'], (string)$password); - if ($handle && @openssl_pkey_export($handle, $exported, null) && trim($exported) !== '') { - // success - } else { - $err = openssl_error_string(); - throw new MLEException("Failed exporting private key from PKCS#12 (OpenSSL 3 legacy issue). OpenSSL: {$err}"); - } - } - } - - $resource = @openssl_pkey_get_private($exported, (string)$password) ?: @openssl_pkey_get_private($exported); - if ($resource === false) { - throw new MLEException("Re-validation of PKCS#12 private key failed after fallback."); - } - return ['pem' => $exported, 'resource' => $resource]; - } - - if (in_array($ext, ['pem','key','p8'], true)) { - // Use your proven decryption method for encrypted PEM/P8 keys - try { - $unencryptedPem = $this->decryptPrivateKeyPem($filePath, $password); - $resource = @openssl_pkey_get_private($unencryptedPem); - if ($resource === false) { - throw new MLEException("Failed to create resource from decrypted PEM"); - } - return ['pem' => $unencryptedPem, 'resource' => $resource]; - } catch (\Exception $e) { - // If decryption fails, try the original approach for unencrypted keys - $raw = file_get_contents($filePath); - if ($raw === false || trim($raw) === '') { - throw new MLEException("Unable to read key file: {$filePath}"); - } - - $priv = @openssl_pkey_get_private($raw); - if ($priv === false) { - throw new MLEException("Unable to load private key: {$filePath}. " . $e->getMessage()); - } - - // Normalize unencrypted keys - $norm = ''; - if (@openssl_pkey_export($priv, $norm, null) && trim($norm) !== '') { - $raw = $norm; - } - - return ['pem' => $raw, 'resource' => $priv]; - } - } - - throw new MLEException("Unsupported Response MLE Private Key file format: {$ext}. Supported: .p12, .pfx, .pem, .key, .p8"); - } - - /** - * Decrypt encrypted PEM/P8 private key files using your proven method - * Integrated from your working code snippet with cross-platform compatibility - */ - private function decryptPrivateKeyPem(string $pemPath, ?string $passphrase): string - { - if (!extension_loaded('openssl')) { - throw new MLEException('The OpenSSL extension is required.'); - } - if (!is_file($pemPath) || !is_readable($pemPath)) { - throw new MLEException("PEM file not found or not readable: {$pemPath}"); - } - - $pem = file_get_contents($pemPath); - if ($pem === false || $pem === '') { - throw new MLEException('Failed to read PEM file contents.'); - } - - // Only attempt decryption if password provided and key appears encrypted - $isEncrypted = strpos($pem, 'BEGIN ENCRYPTED PRIVATE KEY') !== false || - strpos($pem, 'Proc-Type: 4,ENCRYPTED') !== false; - - if (!$isEncrypted) { - // Return as-is for unencrypted keys - return $pem; - } - - if ($passphrase === null || $passphrase === '') { - throw new MLEException('Private key is encrypted but no passphrase provided'); - } - - // Obtain an OpenSSL private key handle using the passphrase - $key = openssl_pkey_get_private($pem, $passphrase); - if ($key === false) { - // Collect the last OpenSSL error to help with debugging - $err = ''; - while ($msg = openssl_error_string()) { - $err .= ($err ? ' | ' : '') . $msg; - } - throw new MLEException('Unable to decrypt private key. ' . ($err ?: 'Check passphrase and key format.')); - } - - // Export the key without a passphrase (i.e., decrypted) - $unencryptedPem = ''; - - // Universal config - works for RSA, EC, DSA keys - // May specify what's needed for Windows compatibility - $configArgs = [ - 'config' => 'NUL', // Pass config file search on Windows - // private_key_type - let OpenSSL auto-detect - // private_key_bits - not applicable to all types - ]; - - // First attempt with minimal config (Windows-friendly) - $success = @openssl_pkey_export($key, $unencryptedPem, null, $configArgs); - - // If that fails, try without any config args (best for Mac/Linux) - if (!$success) { - $success = @openssl_pkey_export($key, $unencryptedPem, null); - } - - if (!$success) { - // Collect OpenSSL errors for debugging - $err = ''; - while ($msg = openssl_error_string()) { - $err .= ($err ? ' | ' : '') . $msg; - } - throw new MLEException('Failed to export unencrypted private key. ' . ($err ?: 'Unknown error')); - } - - // Free the key handle explicitly (PHP version compatibility) - if (is_resource($key)) { - openssl_free_key($key); - } elseif ($key instanceof \OpenSSLAsymmetricKey) { - // PHP 8+: no need to free explicitly, GC will handle it - } - - return $unencryptedPem; } public function getMleResponsePrivateKeyFromFilePath($merchantConfig) diff --git a/lib/Authentication/Util/MLEUtility.php b/lib/Authentication/Util/MLEUtility.php index aa6de9c3..54c21ad3 100644 --- a/lib/Authentication/Util/MLEUtility.php +++ b/lib/Authentication/Util/MLEUtility.php @@ -139,6 +139,9 @@ public static function checkIsMleEncryptedResponse($responseBody) } } public static function decryptMleResponsePayload($merchantConfig, $mleResponseBody) { + if (self::$logger === null) { + self::$logger = (new LogFactory())->getLogger(\CyberSource\Utilities\Helpers\ClassHelper::getClassName(static::class), $merchantConfig->getLogConfiguration()); + } echo "[MLE][Decrypt] Enter decryptMleResponsePayload()\n"; if (!self::checkIsMleEncryptedResponse($mleResponseBody)) { @@ -146,6 +149,7 @@ public static function checkIsMleEncryptedResponse($responseBody) } $jweToken = self::getResponseMleToken($mleResponseBody); if (empty($jweToken)) { + // when mle token is empty or null then fall back to non mle encrypted response echo "[MLE][Decrypt] JWE token missing in encryptedResponse wrapper.\n"; return $mleResponseBody; } @@ -154,13 +158,25 @@ public static function checkIsMleEncryptedResponse($responseBody) echo "[MLE][Decrypt] Private key unavailable for decryption.\n"; throw new MLEException("Response MLE private key not available for decryption."); } - echo "[MLE][Decrypt] Loaded private key (" . strlen($privateKey) . " bytes).\n"; // Cache already handles password decryption and returns unencrypted PEM - // No password needed for JWE decryption since key is already decrypted + echo "[MLE][Decrypt] Loaded private key (" . strlen($privateKey) . " bytes).\n"; + // Cache already handles password decryption and returns unencrypted PEM + if ($merchantConfig->getLogConfiguration()->isMaskingEnabled()) { + $maskedResponseBody = \CyberSource\Utilities\Helpers\DataMasker::maskData($mleResponseBody); + self::$logger->debug("LOG_NETWORK_RESPONSE_BEFORE_MLE_DECRYPTION: " . $maskedResponseBody); + } else { + self::$logger->debug("LOG_NETWORK_RESPONSE_BEFORE_MLE_DECRYPTION: " . $mleResponseBody); + } try { $decrypted = JWEUtility::decryptJWEUsingPrivateKey($privateKey, $jweToken); if ($decrypted === null) { throw new MLEException("Failed to decrypt MLE response payload."); } + if ($merchantConfig->getLogConfiguration()->isMaskingEnabled()) { + $maskedDecrypted = \CyberSource\Utilities\Helpers\DataMasker::maskData($decrypted); + self::$logger->debug("LOG_NETWORK_RESPONSE_AFTER_MLE_DECRYPTION: " . $maskedDecrypted); + } else { + self::$logger->debug("LOG_NETWORK_RESPONSE_AFTER_MLE_DECRYPTION: " . $decrypted); + } echo "[MLE][Decrypt] Decryption successful. Decrypted payload length: " . strlen($decrypted) . "\n"; return $decrypted; } catch (\Exception $e) { @@ -219,11 +235,11 @@ private static function generateToken($cert, $requestBody) private static function getResponseMleToken($mleResponseBody) { - echo " m here 1.\n"; try { $decoded = json_decode($mleResponseBody, true); return $decoded['encryptedResponse'] ?? null; } catch (\Exception $e) { + self::$logger->error("Failed to extract Response MLE token: " + $e->getMessage()); return null; } } diff --git a/lib/Authentication/Util/Utility.php b/lib/Authentication/Util/Utility.php index abdee1c3..aec2724f 100644 --- a/lib/Authentication/Util/Utility.php +++ b/lib/Authentication/Util/Utility.php @@ -49,5 +49,179 @@ public static function extractAllCertificates($certContent) } return $certs; } + + /** + * Load Response MLE private key supporting: + * - PKCS#12 (.p12, .pfx) + * - PEM / KEY / P8 + * + * @param string $filePath Path to the private key file + * @param string|null $password Password for encrypted keys + * @return array ['pem' => unencrypted PEM string, 'resource' => OpenSSL key resource] + * @throws MLEException If key cannot be loaded or decrypted + */ + public static function loadResponseMlePrivateKey(string $filePath, ?string $password): array + { + if (!extension_loaded('openssl')) { + throw new MLEException("OpenSSL extension not loaded; cannot read private key."); + } + + $ext = strtolower(pathinfo($filePath, PATHINFO_EXTENSION)); + + // Handle PKCS#12 formats (.p12, .pfx) + if (in_array($ext, ['p12','pfx'], true)) { + $pkcs12 = file_get_contents($filePath); + if ($pkcs12 === false) { + throw new MLEException("Unable to read PKCS#12 file: {$filePath}"); + } + $certs = []; + if (!openssl_pkcs12_read($pkcs12, $certs, (string)$password)) { + $err = openssl_error_string(); + throw new MLEException("Unable to parse PKCS#12: {$filePath}. OpenSSL: {$err}"); + } + if (empty($certs['pkey'])) { + throw new MLEException("No private key found in PKCS#12: {$filePath}"); + } + + $exported = ''; + $exportOk = @openssl_pkey_export($certs['pkey'], $exported, null); + if (!$exportOk || trim($exported) === '') { + // Broader fallback: accept any BEGIN .. PRIVATE KEY block + if (is_string($certs['pkey']) && preg_match('/BEGIN\\s.+PRIVATE KEY/', $certs['pkey'])) { + $exported = $certs['pkey']; + } else { + // Try again via handle + $handle = @openssl_pkey_get_private($certs['pkey'], (string)$password); + if ($handle && @openssl_pkey_export($handle, $exported, null) && trim($exported) !== '') { + // success + } else { + $err = openssl_error_string(); + throw new MLEException("Failed exporting private key from PKCS#12 (OpenSSL 3 legacy issue). OpenSSL: {$err}"); + } + } + } + + $resource = @openssl_pkey_get_private($exported, (string)$password) ?: @openssl_pkey_get_private($exported); + if ($resource === false) { + throw new MLEException("Re-validation of PKCS#12 private key failed after fallback."); + } + return ['pem' => $exported, 'resource' => $resource]; + } + + // Handle PEM-based formats (.pem, .key, .p8) + if (in_array($ext, ['pem','key','p8'], true)) { + try { + $unencryptedPem = self::decryptPrivateKeyPem($filePath, $password); + $resource = @openssl_pkey_get_private($unencryptedPem); + if ($resource === false) { + throw new MLEException("Failed to create resource from decrypted PEM"); + } + return ['pem' => $unencryptedPem, 'resource' => $resource]; + } catch (\Exception $e) { + // If decryption fails, try the original approach for unencrypted keys + $raw = file_get_contents($filePath); + if ($raw === false || trim($raw) === '') { + throw new MLEException("Unable to read key file: {$filePath}"); + } + + $priv = @openssl_pkey_get_private($raw); + if ($priv === false) { + throw new MLEException("Unable to load private key: {$filePath}. " . $e->getMessage()); + } + + // Normalize unencrypted keys + $norm = ''; + if (@openssl_pkey_export($priv, $norm, null) && trim($norm) !== '') { + $raw = $norm; + } + + return ['pem' => $raw, 'resource' => $priv]; + } + } + + throw new MLEException("Unsupported Response MLE Private Key file format: {$ext}. Supported: .p12, .pfx, .pem, .key, .p8"); + } + + /** + * Decrypt encrypted PEM/P8 private key files with cross-platform compatibility + * + * @param string $pemPath Path to the PEM file + * @param string|null $passphrase Password for encrypted keys + * @return string Unencrypted PEM string + * @throws MLEException If decryption fails + */ + public static function decryptPrivateKeyPem(string $pemPath, ?string $passphrase): string + { + if (!extension_loaded('openssl')) { + throw new MLEException('The OpenSSL extension is required.'); + } + if (!is_file($pemPath) || !is_readable($pemPath)) { + throw new MLEException("PEM file not found or not readable: {$pemPath}"); + } + + $pem = file_get_contents($pemPath); + if ($pem === false || $pem === '') { + throw new MLEException('Failed to read PEM file contents.'); + } + + // Only attempt decryption if password provided and key appears encrypted + $isEncrypted = strpos($pem, 'BEGIN ENCRYPTED PRIVATE KEY') !== false || + strpos($pem, 'Proc-Type: 4,ENCRYPTED') !== false; + + if (!$isEncrypted) { + // Return as-is for unencrypted keys + return $pem; + } + + if ($passphrase === null || $passphrase === '') { + throw new MLEException('Private key is encrypted but no passphrase provided'); + } + + // Obtain an OpenSSL private key handle using the passphrase + $key = openssl_pkey_get_private($pem, $passphrase); + if ($key === false) { + // Collect the last OpenSSL error to help with debugging + $err = ''; + while ($msg = openssl_error_string()) { + $err .= ($err ? ' | ' : '') . $msg; + } + throw new MLEException('Unable to decrypt private key. ' . ($err ?: 'Check passphrase and key format.')); + } + + // Export the key without a passphrase (i.e., decrypted) + $unencryptedPem = ''; + + // Universal config - works for RSA, EC, DSA keys + // May specify what's needed for Windows compatibility + $configArgs = [ + 'config' => 'NUL', // Pass config file search on Windows + ]; + + // First attempt with minimal config (Windows-friendly) + $success = @openssl_pkey_export($key, $unencryptedPem, null, $configArgs); + + // If that fails, try without any config args (best for Mac/Linux) + if (!$success) { + $success = @openssl_pkey_export($key, $unencryptedPem, null); + } + + if (!$success) { + // Collect OpenSSL errors for debugging + $err = ''; + while ($msg = openssl_error_string()) { + $err .= ($err ? ' | ' : '') . $msg; + } + throw new MLEException('Failed to export unencrypted private key. ' . ($err ?: 'Unknown error')); } + + // Free the key handle explicitly for PHP 7 compatibility + // Note: Static analyzers may flag this for PHP 8+ where signature changed + // The is_resource() guard ensures this only runs on PHP 7 + if (is_resource($key)) { + @openssl_free_key($key); + } + // PHP 8+ uses OpenSSLAsymmetricKey object and handles cleanup automatically + + return $unencryptedPem; + } } ?> \ No newline at end of file From 17cb5cf77f34af29e5ea2baaeb3585949676324b Mon Sep 17 00:00:00 2001 From: mahmishr Date: Wed, 15 Oct 2025 03:48:46 +0530 Subject: [PATCH 05/20] mustache changes --- .../ApiClient.mustache | 58 +++++++++++++++++-- .../cybersource-php-template/api.mustache | 7 ++- 2 files changed, 60 insertions(+), 5 deletions(-) diff --git a/generator/cybersource-php-template/ApiClient.mustache b/generator/cybersource-php-template/ApiClient.mustache index ed260257..bb2bfe13 100644 --- a/generator/cybersource-php-template/ApiClient.mustache +++ b/generator/cybersource-php-template/ApiClient.mustache @@ -22,6 +22,7 @@ use CyberSource\Authentication\Core\Authentication as Authentication; use CyberSource\Authentication\Util\GlobalParameter as GlobalParameter; use CyberSource\Authentication\PayloadDigest\PayloadDigest as PayloadDigest; use \{{invokerPackage}}\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; $stream_headers = array(); @@ -201,7 +202,7 @@ class ApiClient * @throws \{{invokerPackage}}\ApiException on a non 2xx response * @return mixed */ - public function callApi($resourcePath, $method, $queryParams, $postData, $headerParams, $responseType = null, $endpointPath = null) + public function callApi($resourcePath, $method, $queryParams, $postData, $headerParams, $responseType = null, $endpointPath = null, $isResponseMLEForAPI=false) { self::$logger->info("CALLING API \"$resourcePath\" STARTED"); $headers = []; @@ -238,7 +239,7 @@ class ApiClient if($this->merchantConfig->getAuthenticationType() != GlobalParameter::MUTUAL_AUTH) { - $authHeader = $this->callAuthenticationHeader($method, $postData, $resourcePath); + $authHeader = $this->callAuthenticationHeader($method, $postData, $resourcePath, $isResponseMLEForAPI); } $requestHeaders=[]; @@ -447,12 +448,34 @@ class ApiClient self::$logger->close(); return [$http_body, $response_info['http_code'], $http_header]; } + + // Decrypt BEFORE json_decode + if (MLEUtility::checkIsMleEncryptedResponse($http_body)) { + + try { + $http_body = MLEUtility::decryptMleResponsePayload($this->merchantConfig, $http_body); + } catch (\Exception $e) { + $error_message = "Response MLE decryption failed: " . $e->getMessage(); + self::$logger->error("ApiException : " . $error_message); + self::$logger->close(); + throw new ApiException($error_message); + } + } $data = json_decode($http_body); if (json_last_error() > 0) { // if response is a string $data = $http_body; } } else { + // Error path: still attempt decryption so error payload can be read + if (MLEUtility::checkIsMleEncryptedResponse($http_body)) { + try { + $http_body = MLEUtility::decryptMleResponsePayload($this->merchantConfig, $http_body); + } catch (\Exception $e) { + // Ignore; proceeding with encrypted body for error case + } + } + $data = json_decode($http_body); if (json_last_error() > 0) { // if response is a string $data = $http_body; @@ -500,11 +523,38 @@ class ApiClient self::$logger->close(); throw $exception; } elseif ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299) { + if (MLEUtility::checkIsMleEncryptedResponse($http_body)) { + self::$logger->debug("[MLE][ApiClient][FileDownload] Encrypted response detected for file download"); + + try { + $http_body = MLEUtility::decryptMleResponsePayload($this->merchantConfig, $http_body); + } catch (\Exception $e) { + $exceptionMessage = $e->getMessage() ?: 'Unknown error'; + $exceptionClass = get_class($e); + $error_message = "File download MLE decryption failed [{$exceptionClass}]: {$exceptionMessage}"; + self::$logger->error("ApiException : " . $error_message); + self::$logger->close(); + + $statusCode = isset($response_info['http_code']) ? $response_info['http_code'] : 0; + throw new ApiException($error_message, $statusCode, $stream_headers ?? [], null); + } + } + $stream_headers['http_code'] = $response_info['http_code']; self::$logger->close(); return [$http_body, $stream_headers['http_code'], $stream_headers]; } else { + // Error path: attempt decryption for file downloads too + if (MLEUtility::checkIsMleEncryptedResponse($http_body)) { + + try { + $http_body = MLEUtility::decryptMleResponsePayload($this->merchantConfig, $http_body); + } catch (\Exception $e) { + // Ignore; proceed with encrypted body for error case + } + } + self::$logger->error("ApiException : [".$response_info['http_code']."] Error connecting to the API ($url)"); self::$logger->close(); throw new ApiException( @@ -603,11 +653,11 @@ class ApiClient * Purpose : This function calling the Authentication and making an Auth Header * */ - public function callAuthenticationHeader($method, $postData, $resourcePath) + public function callAuthenticationHeader($method, $postData, $resourcePath, $isResponseMLEForAPI) { $merchantConfig = $this->merchantConfig; $authentication = new Authentication($merchantConfig->getLogConfiguration()); - $getToken = $authentication->generateToken($resourcePath, $postData, $method, $merchantConfig); + $getToken = $authentication->generateToken($resourcePath, $postData, $method, $merchantConfig, $isResponseMLEForAPI); if($merchantConfig->getAuthenticationType() == GlobalParameter::HTTP_SIGNATURE){ $host = "Host:".$merchantConfig->getHost(); $vcMerchant = "v-c-merchant-id:".$merchantConfig->getMerchantID(); diff --git a/generator/cybersource-php-template/api.mustache b/generator/cybersource-php-template/api.mustache index 8f67253d..02e8b197 100644 --- a/generator/cybersource-php-template/api.mustache +++ b/generator/cybersource-php-template/api.mustache @@ -283,6 +283,10 @@ use \Exception; {{^returnType}} self::$logger->debug("Return Type : null"); {{/returnType}} + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "{{operationId}},{{operationId}}WithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -297,7 +301,8 @@ use \Exception; {{^returnType}} null, {{/returnType}} - '{{{path}}}' + '{{{path}}}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); From 28133a176328eaac907a53bcd0c932fe2ae6d20a Mon Sep 17 00:00:00 2001 From: mahmishr Date: Wed, 15 Oct 2025 11:38:15 +0530 Subject: [PATCH 06/20] auto gen code --- lib/Api/BatchesApi.php | 28 ++++++++-- lib/Api/BillingAgreementsApi.php | 21 ++++++- lib/Api/BinLookupApi.php | 7 ++- lib/Api/CaptureApi.php | 7 ++- lib/Api/ChargebackDetailsApi.php | 7 ++- lib/Api/ChargebackSummariesApi.php | 7 ++- lib/Api/ConversionDetailsApi.php | 7 ++- lib/Api/CreateNewWebhooksApi.php | 21 ++++++- lib/Api/CreditApi.php | 7 ++- lib/Api/CustomerApi.php | 28 ++++++++-- lib/Api/CustomerPaymentInstrumentApi.php | 35 ++++++++++-- lib/Api/CustomerShippingAddressApi.php | 35 ++++++++++-- lib/Api/DecisionManagerApi.php | 35 ++++++++++-- lib/Api/DeviceDeAssociationApi.php | 14 ++++- lib/Api/DeviceSearchApi.php | 14 ++++- lib/Api/DownloadDTDApi.php | 7 ++- lib/Api/DownloadXSDApi.php | 7 ++- lib/Api/EMVTagDetailsApi.php | 14 ++++- lib/Api/FlexAPIApi.php | 7 ++- lib/Api/InstrumentIdentifierApi.php | 42 ++++++++++++-- .../InterchangeClearingLevelDetailsApi.php | 7 ++- lib/Api/InvoiceSettingsApi.php | 14 ++++- lib/Api/InvoicesApi.php | 49 +++++++++++++--- lib/Api/ManageWebhooksApi.php | 49 +++++++++++++--- lib/Api/MerchantBoardingApi.php | 14 ++++- lib/Api/MicroformIntegrationApi.php | 7 ++- lib/Api/NetFundingsApi.php | 7 ++- lib/Api/NotificationOfChangesApi.php | 7 ++- lib/Api/OrdersApi.php | 14 ++++- lib/Api/PayerAuthenticationApi.php | 21 ++++++- lib/Api/PaymentBatchSummariesApi.php | 7 ++- lib/Api/PaymentInstrumentApi.php | 28 ++++++++-- lib/Api/PaymentLinksApi.php | 28 ++++++++-- lib/Api/PaymentTokensApi.php | 7 ++- lib/Api/PaymentsApi.php | 41 ++++++++++++-- lib/Api/PayoutsApi.php | 7 ++- lib/Api/PlansApi.php | 56 ++++++++++++++++--- lib/Api/PurchaseAndRefundDetailsApi.php | 7 ++- lib/Api/PushFundsApi.php | 7 ++- lib/Api/RefundApi.php | 14 ++++- lib/Api/ReportDefinitionsApi.php | 14 ++++- lib/Api/ReportDownloadsApi.php | 7 ++- lib/Api/ReportSubscriptionsApi.php | 35 ++++++++++-- lib/Api/ReportsApi.php | 21 ++++++- lib/Api/RetrievalDetailsApi.php | 7 ++- lib/Api/RetrievalSummariesApi.php | 7 ++- lib/Api/ReversalApi.php | 14 ++++- lib/Api/SearchTransactionsApi.php | 14 ++++- lib/Api/SecureFileShareApi.php | 14 ++++- lib/Api/SubscriptionsApi.php | 56 ++++++++++++++++--- lib/Api/SubscriptionsFollowOnsApi.php | 14 ++++- lib/Api/TaxesApi.php | 14 ++++- lib/Api/TokenApi.php | 14 ++++- lib/Api/TokenizedCardApi.php | 21 ++++++- lib/Api/TransactionBatchesApi.php | 28 ++++++++-- lib/Api/TransactionDetailsApi.php | 7 ++- lib/Api/TransientTokenDataApi.php | 14 ++++- lib/Api/UnifiedCheckoutCaptureContextApi.php | 7 ++- lib/Api/UserManagementApi.php | 7 ++- lib/Api/UserManagementSearchApi.php | 7 ++- lib/Api/VerificationApi.php | 14 ++++- lib/Api/VoidApi.php | 35 ++++++++++-- lib/ApiClient.php | 2 +- lib/Authentication/Util/JWE/JWEUtility.php | 3 - lib/Authentication/Util/MLEUtility.php | 18 +----- 65 files changed, 956 insertions(+), 179 deletions(-) diff --git a/lib/Api/BatchesApi.php b/lib/Api/BatchesApi.php index 26637daa..72ec2184 100644 --- a/lib/Api/BatchesApi.php +++ b/lib/Api/BatchesApi.php @@ -188,6 +188,10 @@ public function getBatchReportWithHttpInfo($batchId) } self::$logger->debug("Return Type : \CyberSource\Model\InlineResponse20011"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getBatchReport,getBatchReportWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -197,7 +201,8 @@ public function getBatchReportWithHttpInfo($batchId) $httpBody, $headerParams, '\CyberSource\Model\InlineResponse20011', - '/accountupdater/v1/batches/{batchId}/report' + '/accountupdater/v1/batches/{batchId}/report', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -312,6 +317,10 @@ public function getBatchStatusWithHttpInfo($batchId) } self::$logger->debug("Return Type : \CyberSource\Model\InlineResponse20010"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getBatchStatus,getBatchStatusWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -321,7 +330,8 @@ public function getBatchStatusWithHttpInfo($batchId) $httpBody, $headerParams, '\CyberSource\Model\InlineResponse20010', - '/accountupdater/v1/batches/{batchId}/status' + '/accountupdater/v1/batches/{batchId}/status', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -449,6 +459,10 @@ public function getBatchesListWithHttpInfo($offset = '0', $limit = '20', $fromDa } self::$logger->debug("Return Type : \CyberSource\Model\InlineResponse2009"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getBatchesList,getBatchesListWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -458,7 +472,8 @@ public function getBatchesListWithHttpInfo($offset = '0', $limit = '20', $fromDa $httpBody, $headerParams, '\CyberSource\Model\InlineResponse2009', - '/accountupdater/v1/batches' + '/accountupdater/v1/batches', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -576,6 +591,10 @@ public function postBatchWithHttpInfo($body) } self::$logger->debug("Return Type : \CyberSource\Model\InlineResponse202"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "postBatch,postBatchWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -585,7 +604,8 @@ public function postBatchWithHttpInfo($body) $httpBody, $headerParams, '\CyberSource\Model\InlineResponse202', - '/accountupdater/v1/batches' + '/accountupdater/v1/batches', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/BillingAgreementsApi.php b/lib/Api/BillingAgreementsApi.php index dec509a8..5a56ac72 100644 --- a/lib/Api/BillingAgreementsApi.php +++ b/lib/Api/BillingAgreementsApi.php @@ -202,6 +202,10 @@ public function billingAgreementsDeRegistrationWithHttpInfo($modifyBillingAgreem } self::$logger->debug("Return Type : \CyberSource\Model\PtsV2ModifyBillingAgreementPost201Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "billingAgreementsDeRegistration,billingAgreementsDeRegistrationWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -211,7 +215,8 @@ public function billingAgreementsDeRegistrationWithHttpInfo($modifyBillingAgreem $httpBody, $headerParams, '\CyberSource\Model\PtsV2ModifyBillingAgreementPost201Response', - '/pts/v2/billing-agreements/{id}' + '/pts/v2/billing-agreements/{id}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -344,6 +349,10 @@ public function billingAgreementsIntimationWithHttpInfo($intimateBillingAgreemen } self::$logger->debug("Return Type : \CyberSource\Model\PtsV2CreditsPost201Response1"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "billingAgreementsIntimation,billingAgreementsIntimationWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -353,7 +362,8 @@ public function billingAgreementsIntimationWithHttpInfo($intimateBillingAgreemen $httpBody, $headerParams, '\CyberSource\Model\PtsV2CreditsPost201Response1', - '/pts/v2/billing-agreements/{id}/intimations' + '/pts/v2/billing-agreements/{id}/intimations', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -471,6 +481,10 @@ public function billingAgreementsRegistrationWithHttpInfo($createBillingAgreemen } self::$logger->debug("Return Type : \CyberSource\Model\PtsV2CreateBillingAgreementPost201Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "billingAgreementsRegistration,billingAgreementsRegistrationWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -480,7 +494,8 @@ public function billingAgreementsRegistrationWithHttpInfo($createBillingAgreemen $httpBody, $headerParams, '\CyberSource\Model\PtsV2CreateBillingAgreementPost201Response', - '/pts/v2/billing-agreements' + '/pts/v2/billing-agreements', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/BinLookupApi.php b/lib/Api/BinLookupApi.php index 152044b0..64a763ca 100644 --- a/lib/Api/BinLookupApi.php +++ b/lib/Api/BinLookupApi.php @@ -189,6 +189,10 @@ public function getAccountInfoWithHttpInfo($createBinLookupRequest) } self::$logger->debug("Return Type : \CyberSource\Model\InlineResponse2012"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getAccountInfo,getAccountInfoWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -198,7 +202,8 @@ public function getAccountInfoWithHttpInfo($createBinLookupRequest) $httpBody, $headerParams, '\CyberSource\Model\InlineResponse2012', - '/bin/v1/binlookup' + '/bin/v1/binlookup', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/CaptureApi.php b/lib/Api/CaptureApi.php index 3a470348..0b498a0c 100644 --- a/lib/Api/CaptureApi.php +++ b/lib/Api/CaptureApi.php @@ -202,6 +202,10 @@ public function capturePaymentWithHttpInfo($capturePaymentRequest, $id) } self::$logger->debug("Return Type : \CyberSource\Model\PtsV2PaymentsCapturesPost201Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "capturePayment,capturePaymentWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -211,7 +215,8 @@ public function capturePaymentWithHttpInfo($capturePaymentRequest, $id) $httpBody, $headerParams, '\CyberSource\Model\PtsV2PaymentsCapturesPost201Response', - '/pts/v2/payments/{id}/captures' + '/pts/v2/payments/{id}/captures', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/ChargebackDetailsApi.php b/lib/Api/ChargebackDetailsApi.php index 2024e96f..014b6559 100644 --- a/lib/Api/ChargebackDetailsApi.php +++ b/lib/Api/ChargebackDetailsApi.php @@ -204,6 +204,10 @@ public function getChargebackDetailsWithHttpInfo($startTime, $endTime, $organiza } self::$logger->debug("Return Type : \CyberSource\Model\ReportingV3ChargebackDetailsGet200Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getChargebackDetails,getChargebackDetailsWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -213,7 +217,8 @@ public function getChargebackDetailsWithHttpInfo($startTime, $endTime, $organiza $httpBody, $headerParams, '\CyberSource\Model\ReportingV3ChargebackDetailsGet200Response', - '/reporting/v3/chargeback-details' + '/reporting/v3/chargeback-details', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/ChargebackSummariesApi.php b/lib/Api/ChargebackSummariesApi.php index 17310e0d..b497da5c 100644 --- a/lib/Api/ChargebackSummariesApi.php +++ b/lib/Api/ChargebackSummariesApi.php @@ -204,6 +204,10 @@ public function getChargebackSummariesWithHttpInfo($startTime, $endTime, $organi } self::$logger->debug("Return Type : \CyberSource\Model\ReportingV3ChargebackSummariesGet200Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getChargebackSummaries,getChargebackSummariesWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -213,7 +217,8 @@ public function getChargebackSummariesWithHttpInfo($startTime, $endTime, $organi $httpBody, $headerParams, '\CyberSource\Model\ReportingV3ChargebackSummariesGet200Response', - '/reporting/v3/chargeback-summaries' + '/reporting/v3/chargeback-summaries', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/ConversionDetailsApi.php b/lib/Api/ConversionDetailsApi.php index 663e43de..e8c3c0bf 100644 --- a/lib/Api/ConversionDetailsApi.php +++ b/lib/Api/ConversionDetailsApi.php @@ -204,6 +204,10 @@ public function getConversionDetailWithHttpInfo($startTime, $endTime, $organizat } self::$logger->debug("Return Type : \CyberSource\Model\ReportingV3ConversionDetailsGet200Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getConversionDetail,getConversionDetailWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -213,7 +217,8 @@ public function getConversionDetailWithHttpInfo($startTime, $endTime, $organizat $httpBody, $headerParams, '\CyberSource\Model\ReportingV3ConversionDetailsGet200Response', - '/reporting/v3/conversion-details' + '/reporting/v3/conversion-details', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/CreateNewWebhooksApi.php b/lib/Api/CreateNewWebhooksApi.php index 779b722f..869cd507 100644 --- a/lib/Api/CreateNewWebhooksApi.php +++ b/lib/Api/CreateNewWebhooksApi.php @@ -188,6 +188,10 @@ public function findProductsToSubscribeWithHttpInfo($organizationId) } self::$logger->debug("Return Type : \CyberSource\Model\InlineResponse2003[]"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "findProductsToSubscribe,findProductsToSubscribeWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -197,7 +201,8 @@ public function findProductsToSubscribeWithHttpInfo($organizationId) $httpBody, $headerParams, '\CyberSource\Model\InlineResponse2003[]', - '/notification-subscriptions/v2/products/{organizationId}' + '/notification-subscriptions/v2/products/{organizationId}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -302,6 +307,10 @@ public function notificationSubscriptionsV2WebhooksPostWithHttpInfo($createWebho } self::$logger->debug("Return Type : \CyberSource\Model\InlineResponse2015"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "notificationSubscriptionsV2WebhooksPost,notificationSubscriptionsV2WebhooksPostWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -311,7 +320,8 @@ public function notificationSubscriptionsV2WebhooksPostWithHttpInfo($createWebho $httpBody, $headerParams, '\CyberSource\Model\InlineResponse2015', - '/notification-subscriptions/v2/webhooks' + '/notification-subscriptions/v2/webhooks', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -444,6 +454,10 @@ public function saveSymEgressKeyWithHttpInfo($vCSenderOrganizationId, $vCPermiss } self::$logger->debug("Return Type : \CyberSource\Model\InlineResponse2014"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "saveSymEgressKey,saveSymEgressKeyWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -453,7 +467,8 @@ public function saveSymEgressKeyWithHttpInfo($vCSenderOrganizationId, $vCPermiss $httpBody, $headerParams, '\CyberSource\Model\InlineResponse2014', - '/kms/egress/v2/keys-sym' + '/kms/egress/v2/keys-sym', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/CreditApi.php b/lib/Api/CreditApi.php index 23e08f42..a95caed8 100644 --- a/lib/Api/CreditApi.php +++ b/lib/Api/CreditApi.php @@ -187,6 +187,10 @@ public function createCreditWithHttpInfo($createCreditRequest) } self::$logger->debug("Return Type : \CyberSource\Model\PtsV2CreditsPost201Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "createCredit,createCreditWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -196,7 +200,8 @@ public function createCreditWithHttpInfo($createCreditRequest) $httpBody, $headerParams, '\CyberSource\Model\PtsV2CreditsPost201Response', - '/pts/v2/credits' + '/pts/v2/credits', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/CustomerApi.php b/lib/Api/CustomerApi.php index 5b0c635e..008bbed4 100644 --- a/lib/Api/CustomerApi.php +++ b/lib/Api/CustomerApi.php @@ -194,6 +194,10 @@ public function deleteCustomerWithHttpInfo($customerId, $profileId = null) } self::$logger->debug("Return Type : null"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "deleteCustomer,deleteCustomerWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -203,7 +207,8 @@ public function deleteCustomerWithHttpInfo($customerId, $profileId = null) $httpBody, $headerParams, null, - '/tms/v2/customers/{customerId}' + '/tms/v2/customers/{customerId}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -340,6 +345,10 @@ public function getCustomerWithHttpInfo($customerId, $profileId = null) } self::$logger->debug("Return Type : \CyberSource\Model\PostCustomerRequest"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getCustomer,getCustomerWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -349,7 +358,8 @@ public function getCustomerWithHttpInfo($customerId, $profileId = null) $httpBody, $headerParams, '\CyberSource\Model\PostCustomerRequest', - '/tms/v2/customers/{customerId}' + '/tms/v2/customers/{customerId}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -510,6 +520,10 @@ public function patchCustomerWithHttpInfo($customerId, $patchCustomerRequest, $p } self::$logger->debug("Return Type : \CyberSource\Model\PatchCustomerRequest"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "patchCustomer,patchCustomerWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -519,7 +533,8 @@ public function patchCustomerWithHttpInfo($customerId, $patchCustomerRequest, $p $httpBody, $headerParams, '\CyberSource\Model\PatchCustomerRequest', - '/tms/v2/customers/{customerId}' + '/tms/v2/customers/{customerId}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -663,6 +678,10 @@ public function postCustomerWithHttpInfo($postCustomerRequest, $profileId = null } self::$logger->debug("Return Type : \CyberSource\Model\PostCustomerRequest"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "postCustomer,postCustomerWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -672,7 +691,8 @@ public function postCustomerWithHttpInfo($postCustomerRequest, $profileId = null $httpBody, $headerParams, '\CyberSource\Model\PostCustomerRequest', - '/tms/v2/customers' + '/tms/v2/customers', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/CustomerPaymentInstrumentApi.php b/lib/Api/CustomerPaymentInstrumentApi.php index a53c2544..895cecc7 100644 --- a/lib/Api/CustomerPaymentInstrumentApi.php +++ b/lib/Api/CustomerPaymentInstrumentApi.php @@ -209,6 +209,10 @@ public function deleteCustomerPaymentInstrumentWithHttpInfo($customerId, $paymen } self::$logger->debug("Return Type : null"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "deleteCustomerPaymentInstrument,deleteCustomerPaymentInstrumentWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -218,7 +222,8 @@ public function deleteCustomerPaymentInstrumentWithHttpInfo($customerId, $paymen $httpBody, $headerParams, null, - '/tms/v2/customers/{customerId}/payment-instruments/{paymentInstrumentId}' + '/tms/v2/customers/{customerId}/payment-instruments/{paymentInstrumentId}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -374,6 +379,10 @@ public function getCustomerPaymentInstrumentWithHttpInfo($customerId, $paymentIn } self::$logger->debug("Return Type : \CyberSource\Model\PostCustomerPaymentInstrumentRequest"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getCustomerPaymentInstrument,getCustomerPaymentInstrumentWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -383,7 +392,8 @@ public function getCustomerPaymentInstrumentWithHttpInfo($customerId, $paymentIn $httpBody, $headerParams, '\CyberSource\Model\PostCustomerPaymentInstrumentRequest', - '/tms/v2/customers/{customerId}/payment-instruments/{paymentInstrumentId}' + '/tms/v2/customers/{customerId}/payment-instruments/{paymentInstrumentId}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -538,6 +548,10 @@ public function getCustomerPaymentInstrumentsListWithHttpInfo($customerId, $prof } self::$logger->debug("Return Type : \CyberSource\Model\PaymentInstrumentList"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getCustomerPaymentInstrumentsList,getCustomerPaymentInstrumentsListWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -547,7 +561,8 @@ public function getCustomerPaymentInstrumentsListWithHttpInfo($customerId, $prof $httpBody, $headerParams, '\CyberSource\Model\PaymentInstrumentList', - '/tms/v2/customers/{customerId}/payment-instruments' + '/tms/v2/customers/{customerId}/payment-instruments', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -723,6 +738,10 @@ public function patchCustomersPaymentInstrumentWithHttpInfo($customerId, $paymen } self::$logger->debug("Return Type : \CyberSource\Model\PatchCustomerPaymentInstrumentRequest"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "patchCustomersPaymentInstrument,patchCustomersPaymentInstrumentWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -732,7 +751,8 @@ public function patchCustomersPaymentInstrumentWithHttpInfo($customerId, $paymen $httpBody, $headerParams, '\CyberSource\Model\PatchCustomerPaymentInstrumentRequest', - '/tms/v2/customers/{customerId}/payment-instruments/{paymentInstrumentId}' + '/tms/v2/customers/{customerId}/payment-instruments/{paymentInstrumentId}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -891,6 +911,10 @@ public function postCustomerPaymentInstrumentWithHttpInfo($customerId, $postCust } self::$logger->debug("Return Type : \CyberSource\Model\PostCustomerPaymentInstrumentRequest"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "postCustomerPaymentInstrument,postCustomerPaymentInstrumentWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -900,7 +924,8 @@ public function postCustomerPaymentInstrumentWithHttpInfo($customerId, $postCust $httpBody, $headerParams, '\CyberSource\Model\PostCustomerPaymentInstrumentRequest', - '/tms/v2/customers/{customerId}/payment-instruments' + '/tms/v2/customers/{customerId}/payment-instruments', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/CustomerShippingAddressApi.php b/lib/Api/CustomerShippingAddressApi.php index c9ffd465..b38d395e 100644 --- a/lib/Api/CustomerShippingAddressApi.php +++ b/lib/Api/CustomerShippingAddressApi.php @@ -209,6 +209,10 @@ public function deleteCustomerShippingAddressWithHttpInfo($customerId, $shipping } self::$logger->debug("Return Type : null"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "deleteCustomerShippingAddress,deleteCustomerShippingAddressWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -218,7 +222,8 @@ public function deleteCustomerShippingAddressWithHttpInfo($customerId, $shipping $httpBody, $headerParams, null, - '/tms/v2/customers/{customerId}/shipping-addresses/{shippingAddressId}' + '/tms/v2/customers/{customerId}/shipping-addresses/{shippingAddressId}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -374,6 +379,10 @@ public function getCustomerShippingAddressWithHttpInfo($customerId, $shippingAdd } self::$logger->debug("Return Type : \CyberSource\Model\PostCustomerShippingAddressRequest"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getCustomerShippingAddress,getCustomerShippingAddressWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -383,7 +392,8 @@ public function getCustomerShippingAddressWithHttpInfo($customerId, $shippingAdd $httpBody, $headerParams, '\CyberSource\Model\PostCustomerShippingAddressRequest', - '/tms/v2/customers/{customerId}/shipping-addresses/{shippingAddressId}' + '/tms/v2/customers/{customerId}/shipping-addresses/{shippingAddressId}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -538,6 +548,10 @@ public function getCustomerShippingAddressesListWithHttpInfo($customerId, $profi } self::$logger->debug("Return Type : \CyberSource\Model\ShippingAddressListForCustomer"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getCustomerShippingAddressesList,getCustomerShippingAddressesListWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -547,7 +561,8 @@ public function getCustomerShippingAddressesListWithHttpInfo($customerId, $profi $httpBody, $headerParams, '\CyberSource\Model\ShippingAddressListForCustomer', - '/tms/v2/customers/{customerId}/shipping-addresses' + '/tms/v2/customers/{customerId}/shipping-addresses', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -723,6 +738,10 @@ public function patchCustomersShippingAddressWithHttpInfo($customerId, $shipping } self::$logger->debug("Return Type : \CyberSource\Model\PatchCustomerShippingAddressRequest"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "patchCustomersShippingAddress,patchCustomersShippingAddressWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -732,7 +751,8 @@ public function patchCustomersShippingAddressWithHttpInfo($customerId, $shipping $httpBody, $headerParams, '\CyberSource\Model\PatchCustomerShippingAddressRequest', - '/tms/v2/customers/{customerId}/shipping-addresses/{shippingAddressId}' + '/tms/v2/customers/{customerId}/shipping-addresses/{shippingAddressId}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -891,6 +911,10 @@ public function postCustomerShippingAddressWithHttpInfo($customerId, $postCustom } self::$logger->debug("Return Type : \CyberSource\Model\PostCustomerShippingAddressRequest"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "postCustomerShippingAddress,postCustomerShippingAddressWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -900,7 +924,8 @@ public function postCustomerShippingAddressWithHttpInfo($customerId, $postCustom $httpBody, $headerParams, '\CyberSource\Model\PostCustomerShippingAddressRequest', - '/tms/v2/customers/{customerId}/shipping-addresses' + '/tms/v2/customers/{customerId}/shipping-addresses', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/DecisionManagerApi.php b/lib/Api/DecisionManagerApi.php index 4731489a..b953458d 100644 --- a/lib/Api/DecisionManagerApi.php +++ b/lib/Api/DecisionManagerApi.php @@ -202,6 +202,10 @@ public function actionDecisionManagerCaseWithHttpInfo($id, $caseManagementAction } self::$logger->debug("Return Type : \CyberSource\Model\InlineResponse2001"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "actionDecisionManagerCase,actionDecisionManagerCaseWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -211,7 +215,8 @@ public function actionDecisionManagerCaseWithHttpInfo($id, $caseManagementAction $httpBody, $headerParams, '\CyberSource\Model\InlineResponse2001', - '/risk/v1/decisions/{id}/actions' + '/risk/v1/decisions/{id}/actions', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -360,6 +365,10 @@ public function addNegativeWithHttpInfo($type, $addNegativeListRequest) } self::$logger->debug("Return Type : \CyberSource\Model\RiskV1UpdatePost201Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "addNegative,addNegativeWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -369,7 +378,8 @@ public function addNegativeWithHttpInfo($type, $addNegativeListRequest) $httpBody, $headerParams, '\CyberSource\Model\RiskV1UpdatePost201Response', - '/risk/v1/lists/{type}/entries' + '/risk/v1/lists/{type}/entries', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -498,6 +508,10 @@ public function commentDecisionManagerCaseWithHttpInfo($id, $caseManagementComme } self::$logger->debug("Return Type : \CyberSource\Model\InlineResponse2011"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "commentDecisionManagerCase,commentDecisionManagerCaseWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -507,7 +521,8 @@ public function commentDecisionManagerCaseWithHttpInfo($id, $caseManagementComme $httpBody, $headerParams, '\CyberSource\Model\InlineResponse2011', - '/risk/v1/decisions/{id}/comments' + '/risk/v1/decisions/{id}/comments', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -641,6 +656,10 @@ public function createBundledDecisionManagerCaseWithHttpInfo($createBundledDecis } self::$logger->debug("Return Type : \CyberSource\Model\RiskV1DecisionsPost201Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "createBundledDecisionManagerCase,createBundledDecisionManagerCaseWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -650,7 +669,8 @@ public function createBundledDecisionManagerCaseWithHttpInfo($createBundledDecis $httpBody, $headerParams, '\CyberSource\Model\RiskV1DecisionsPost201Response', - '/risk/v1/decisions' + '/risk/v1/decisions', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -783,6 +803,10 @@ public function fraudUpdateWithHttpInfo($id, $fraudMarkingActionRequest) } self::$logger->debug("Return Type : \CyberSource\Model\RiskV1UpdatePost201Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "fraudUpdate,fraudUpdateWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -792,7 +816,8 @@ public function fraudUpdateWithHttpInfo($id, $fraudMarkingActionRequest) $httpBody, $headerParams, '\CyberSource\Model\RiskV1UpdatePost201Response', - '/risk/v1/decisions/{id}/marking' + '/risk/v1/decisions/{id}/marking', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/DeviceDeAssociationApi.php b/lib/Api/DeviceDeAssociationApi.php index 295a7c5e..f0f9fa0a 100644 --- a/lib/Api/DeviceDeAssociationApi.php +++ b/lib/Api/DeviceDeAssociationApi.php @@ -187,6 +187,10 @@ public function deleteTerminalAssociationWithHttpInfo($deAssociationRequestBody) } self::$logger->debug("Return Type : null"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "deleteTerminalAssociation,deleteTerminalAssociationWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -196,7 +200,8 @@ public function deleteTerminalAssociationWithHttpInfo($deAssociationRequestBody) $httpBody, $headerParams, null, - '/dms/v2/devices/deassociate' + '/dms/v2/devices/deassociate', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -322,6 +327,10 @@ public function postDeAssociateV3TerminalWithHttpInfo($deviceDeAssociateV3Reques } self::$logger->debug("Return Type : \CyberSource\Model\InlineResponse2007[]"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "postDeAssociateV3Terminal,postDeAssociateV3TerminalWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -331,7 +340,8 @@ public function postDeAssociateV3TerminalWithHttpInfo($deviceDeAssociateV3Reques $httpBody, $headerParams, '\CyberSource\Model\InlineResponse2007[]', - '/dms/v3/devices/deassociate' + '/dms/v3/devices/deassociate', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/DeviceSearchApi.php b/lib/Api/DeviceSearchApi.php index 03d2e3a0..1bea182b 100644 --- a/lib/Api/DeviceSearchApi.php +++ b/lib/Api/DeviceSearchApi.php @@ -187,6 +187,10 @@ public function postSearchQueryWithHttpInfo($postDeviceSearchRequest) } self::$logger->debug("Return Type : \CyberSource\Model\InlineResponse2006"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "postSearchQuery,postSearchQueryWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -196,7 +200,8 @@ public function postSearchQueryWithHttpInfo($postDeviceSearchRequest) $httpBody, $headerParams, '\CyberSource\Model\InlineResponse2006', - '/dms/v2/devices/search' + '/dms/v2/devices/search', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -326,6 +331,10 @@ public function postSearchQueryV3WithHttpInfo($postDeviceSearchRequestV3) } self::$logger->debug("Return Type : \CyberSource\Model\InlineResponse2008"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "postSearchQueryV3,postSearchQueryV3WithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -335,7 +344,8 @@ public function postSearchQueryV3WithHttpInfo($postDeviceSearchRequestV3) $httpBody, $headerParams, '\CyberSource\Model\InlineResponse2008', - '/dms/v3/devices/search' + '/dms/v3/devices/search', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/DownloadDTDApi.php b/lib/Api/DownloadDTDApi.php index b21d5895..9b5b75c4 100644 --- a/lib/Api/DownloadDTDApi.php +++ b/lib/Api/DownloadDTDApi.php @@ -188,6 +188,10 @@ public function getDTDV2WithHttpInfo($reportDefinitionNameVersion) } self::$logger->debug("Return Type : null"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getDTDV2,getDTDV2WithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -197,7 +201,8 @@ public function getDTDV2WithHttpInfo($reportDefinitionNameVersion) $httpBody, $headerParams, null, - '/reporting/v3/dtds/{reportDefinitionNameVersion}' + '/reporting/v3/dtds/{reportDefinitionNameVersion}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/DownloadXSDApi.php b/lib/Api/DownloadXSDApi.php index 2b16eb3a..26e1ae6a 100644 --- a/lib/Api/DownloadXSDApi.php +++ b/lib/Api/DownloadXSDApi.php @@ -188,6 +188,10 @@ public function getXSDV2WithHttpInfo($reportDefinitionNameVersion) } self::$logger->debug("Return Type : null"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getXSDV2,getXSDV2WithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -197,7 +201,8 @@ public function getXSDV2WithHttpInfo($reportDefinitionNameVersion) $httpBody, $headerParams, null, - '/reporting/v3/xsds/{reportDefinitionNameVersion}' + '/reporting/v3/xsds/{reportDefinitionNameVersion}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/EMVTagDetailsApi.php b/lib/Api/EMVTagDetailsApi.php index ce181494..cd9fe43e 100644 --- a/lib/Api/EMVTagDetailsApi.php +++ b/lib/Api/EMVTagDetailsApi.php @@ -173,6 +173,10 @@ public function getEmvTagsWithHttpInfo() } self::$logger->debug("Return Type : \CyberSource\Model\TssV2GetEmvTags200Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getEmvTags,getEmvTagsWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -182,7 +186,8 @@ public function getEmvTagsWithHttpInfo() $httpBody, $headerParams, '\CyberSource\Model\TssV2GetEmvTags200Response', - '/tss/v2/transactions/emvTagDetails' + '/tss/v2/transactions/emvTagDetails', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -292,6 +297,10 @@ public function parseEmvTagsWithHttpInfo($body) } self::$logger->debug("Return Type : \CyberSource\Model\TssV2PostEmvTags200Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "parseEmvTags,parseEmvTagsWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -301,7 +310,8 @@ public function parseEmvTagsWithHttpInfo($body) $httpBody, $headerParams, '\CyberSource\Model\TssV2PostEmvTags200Response', - '/tss/v2/transactions/emvTagDetails' + '/tss/v2/transactions/emvTagDetails', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/FlexAPIApi.php b/lib/Api/FlexAPIApi.php index 80a8021d..16d99c1f 100644 --- a/lib/Api/FlexAPIApi.php +++ b/lib/Api/FlexAPIApi.php @@ -187,6 +187,10 @@ public function generateFlexAPICaptureContextWithHttpInfo($generateFlexAPICaptur } self::$logger->debug("Return Type : string"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "generateFlexAPICaptureContext,generateFlexAPICaptureContextWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -196,7 +200,8 @@ public function generateFlexAPICaptureContextWithHttpInfo($generateFlexAPICaptur $httpBody, $headerParams, 'string', - '/flex/v2/sessions' + '/flex/v2/sessions', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/InstrumentIdentifierApi.php b/lib/Api/InstrumentIdentifierApi.php index d39ca3e6..fb754d65 100644 --- a/lib/Api/InstrumentIdentifierApi.php +++ b/lib/Api/InstrumentIdentifierApi.php @@ -194,6 +194,10 @@ public function deleteInstrumentIdentifierWithHttpInfo($instrumentIdentifierId, } self::$logger->debug("Return Type : null"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "deleteInstrumentIdentifier,deleteInstrumentIdentifierWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -203,7 +207,8 @@ public function deleteInstrumentIdentifierWithHttpInfo($instrumentIdentifierId, $httpBody, $headerParams, null, - '/tms/v1/instrumentidentifiers/{instrumentIdentifierId}' + '/tms/v1/instrumentidentifiers/{instrumentIdentifierId}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -347,6 +352,10 @@ public function getInstrumentIdentifierWithHttpInfo($instrumentIdentifierId, $pr } self::$logger->debug("Return Type : \CyberSource\Model\PostInstrumentIdentifierRequest"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getInstrumentIdentifier,getInstrumentIdentifierWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -356,7 +365,8 @@ public function getInstrumentIdentifierWithHttpInfo($instrumentIdentifierId, $pr $httpBody, $headerParams, '\CyberSource\Model\PostInstrumentIdentifierRequest', - '/tms/v1/instrumentidentifiers/{instrumentIdentifierId}' + '/tms/v1/instrumentidentifiers/{instrumentIdentifierId}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -518,6 +528,10 @@ public function getInstrumentIdentifierPaymentInstrumentsListWithHttpInfo($instr } self::$logger->debug("Return Type : \CyberSource\Model\PaymentInstrumentList1"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getInstrumentIdentifierPaymentInstrumentsList,getInstrumentIdentifierPaymentInstrumentsListWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -527,7 +541,8 @@ public function getInstrumentIdentifierPaymentInstrumentsListWithHttpInfo($instr $httpBody, $headerParams, '\CyberSource\Model\PaymentInstrumentList1', - '/tms/v1/instrumentidentifiers/{instrumentIdentifierId}/paymentinstruments' + '/tms/v1/instrumentidentifiers/{instrumentIdentifierId}/paymentinstruments', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -695,6 +710,10 @@ public function patchInstrumentIdentifierWithHttpInfo($instrumentIdentifierId, $ } self::$logger->debug("Return Type : \CyberSource\Model\PatchInstrumentIdentifierRequest"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "patchInstrumentIdentifier,patchInstrumentIdentifierWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -704,7 +723,8 @@ public function patchInstrumentIdentifierWithHttpInfo($instrumentIdentifierId, $ $httpBody, $headerParams, '\CyberSource\Model\PatchInstrumentIdentifierRequest', - '/tms/v1/instrumentidentifiers/{instrumentIdentifierId}' + '/tms/v1/instrumentidentifiers/{instrumentIdentifierId}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -855,6 +875,10 @@ public function postInstrumentIdentifierWithHttpInfo($postInstrumentIdentifierRe } self::$logger->debug("Return Type : \CyberSource\Model\PostInstrumentIdentifierRequest"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "postInstrumentIdentifier,postInstrumentIdentifierWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -864,7 +888,8 @@ public function postInstrumentIdentifierWithHttpInfo($postInstrumentIdentifierRe $httpBody, $headerParams, '\CyberSource\Model\PostInstrumentIdentifierRequest', - '/tms/v1/instrumentidentifiers' + '/tms/v1/instrumentidentifiers', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -1019,6 +1044,10 @@ public function postInstrumentIdentifierEnrollmentWithHttpInfo($instrumentIdenti } self::$logger->debug("Return Type : null"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "postInstrumentIdentifierEnrollment,postInstrumentIdentifierEnrollmentWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -1028,7 +1057,8 @@ public function postInstrumentIdentifierEnrollmentWithHttpInfo($instrumentIdenti $httpBody, $headerParams, null, - '/tms/v1/instrumentidentifiers/{instrumentIdentifierId}/enrollment' + '/tms/v1/instrumentidentifiers/{instrumentIdentifierId}/enrollment', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/InterchangeClearingLevelDetailsApi.php b/lib/Api/InterchangeClearingLevelDetailsApi.php index 3746a9c0..a929bc1d 100644 --- a/lib/Api/InterchangeClearingLevelDetailsApi.php +++ b/lib/Api/InterchangeClearingLevelDetailsApi.php @@ -204,6 +204,10 @@ public function getInterchangeClearingLevelDetailsWithHttpInfo($startTime, $endT } self::$logger->debug("Return Type : \CyberSource\Model\ReportingV3InterchangeClearingLevelDetailsGet200Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getInterchangeClearingLevelDetails,getInterchangeClearingLevelDetailsWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -213,7 +217,8 @@ public function getInterchangeClearingLevelDetailsWithHttpInfo($startTime, $endT $httpBody, $headerParams, '\CyberSource\Model\ReportingV3InterchangeClearingLevelDetailsGet200Response', - '/reporting/v3/interchange-clearing-level-details' + '/reporting/v3/interchange-clearing-level-details', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/InvoiceSettingsApi.php b/lib/Api/InvoiceSettingsApi.php index ef34266f..ed1688c2 100644 --- a/lib/Api/InvoiceSettingsApi.php +++ b/lib/Api/InvoiceSettingsApi.php @@ -173,6 +173,10 @@ public function getInvoiceSettingsWithHttpInfo() } self::$logger->debug("Return Type : \CyberSource\Model\InvoicingV2InvoiceSettingsGet200Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getInvoiceSettings,getInvoiceSettingsWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -182,7 +186,8 @@ public function getInvoiceSettingsWithHttpInfo() $httpBody, $headerParams, '\CyberSource\Model\InvoicingV2InvoiceSettingsGet200Response', - '/invoicing/v2/invoiceSettings' + '/invoicing/v2/invoiceSettings', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -300,6 +305,10 @@ public function updateInvoiceSettingsWithHttpInfo($invoiceSettingsRequest) } self::$logger->debug("Return Type : \CyberSource\Model\InvoicingV2InvoiceSettingsGet200Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "updateInvoiceSettings,updateInvoiceSettingsWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -309,7 +318,8 @@ public function updateInvoiceSettingsWithHttpInfo($invoiceSettingsRequest) $httpBody, $headerParams, '\CyberSource\Model\InvoicingV2InvoiceSettingsGet200Response', - '/invoicing/v2/invoiceSettings' + '/invoicing/v2/invoiceSettings', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/InvoicesApi.php b/lib/Api/InvoicesApi.php index d09181ce..93eaa931 100644 --- a/lib/Api/InvoicesApi.php +++ b/lib/Api/InvoicesApi.php @@ -187,6 +187,10 @@ public function createInvoiceWithHttpInfo($createInvoiceRequest) } self::$logger->debug("Return Type : \CyberSource\Model\InvoicingV2InvoicesPost201Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "createInvoice,createInvoiceWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -196,7 +200,8 @@ public function createInvoiceWithHttpInfo($createInvoiceRequest) $httpBody, $headerParams, '\CyberSource\Model\InvoicingV2InvoicesPost201Response', - '/invoicing/v2/invoices' + '/invoicing/v2/invoices', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -339,6 +344,10 @@ public function getAllInvoicesWithHttpInfo($offset, $limit, $status = null) } self::$logger->debug("Return Type : \CyberSource\Model\InvoicingV2InvoicesAllGet200Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getAllInvoices,getAllInvoicesWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -348,7 +357,8 @@ public function getAllInvoicesWithHttpInfo($offset, $limit, $status = null) $httpBody, $headerParams, '\CyberSource\Model\InvoicingV2InvoicesAllGet200Response', - '/invoicing/v2/invoices' + '/invoicing/v2/invoices', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -471,6 +481,10 @@ public function getInvoiceWithHttpInfo($id) } self::$logger->debug("Return Type : \CyberSource\Model\InvoicingV2InvoicesGet200Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getInvoice,getInvoiceWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -480,7 +494,8 @@ public function getInvoiceWithHttpInfo($id) $httpBody, $headerParams, '\CyberSource\Model\InvoicingV2InvoicesGet200Response', - '/invoicing/v2/invoices/{id}' + '/invoicing/v2/invoices/{id}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -603,6 +618,10 @@ public function performCancelActionWithHttpInfo($id) } self::$logger->debug("Return Type : \CyberSource\Model\InvoicingV2InvoicesCancel200Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "performCancelAction,performCancelActionWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -612,7 +631,8 @@ public function performCancelActionWithHttpInfo($id) $httpBody, $headerParams, '\CyberSource\Model\InvoicingV2InvoicesCancel200Response', - '/invoicing/v2/invoices/{id}/cancelation' + '/invoicing/v2/invoices/{id}/cancelation', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -735,6 +755,10 @@ public function performPublishActionWithHttpInfo($id) } self::$logger->debug("Return Type : \CyberSource\Model\InvoicingV2InvoicesPublish200Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "performPublishAction,performPublishActionWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -744,7 +768,8 @@ public function performPublishActionWithHttpInfo($id) $httpBody, $headerParams, '\CyberSource\Model\InvoicingV2InvoicesPublish200Response', - '/invoicing/v2/invoices/{id}/publication' + '/invoicing/v2/invoices/{id}/publication', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -867,6 +892,10 @@ public function performSendActionWithHttpInfo($id) } self::$logger->debug("Return Type : \CyberSource\Model\InvoicingV2InvoicesSend200Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "performSendAction,performSendActionWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -876,7 +905,8 @@ public function performSendActionWithHttpInfo($id) $httpBody, $headerParams, '\CyberSource\Model\InvoicingV2InvoicesSend200Response', - '/invoicing/v2/invoices/{id}/delivery' + '/invoicing/v2/invoices/{id}/delivery', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -1013,6 +1043,10 @@ public function updateInvoiceWithHttpInfo($id, $updateInvoiceRequest) } self::$logger->debug("Return Type : \CyberSource\Model\InvoicingV2InvoicesPut200Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "updateInvoice,updateInvoiceWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -1022,7 +1056,8 @@ public function updateInvoiceWithHttpInfo($id, $updateInvoiceRequest) $httpBody, $headerParams, '\CyberSource\Model\InvoicingV2InvoicesPut200Response', - '/invoicing/v2/invoices/{id}' + '/invoicing/v2/invoices/{id}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/ManageWebhooksApi.php b/lib/Api/ManageWebhooksApi.php index 04d4fb6d..d927f286 100644 --- a/lib/Api/ManageWebhooksApi.php +++ b/lib/Api/ManageWebhooksApi.php @@ -188,6 +188,10 @@ public function deleteWebhookSubscriptionWithHttpInfo($webhookId) } self::$logger->debug("Return Type : null"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "deleteWebhookSubscription,deleteWebhookSubscriptionWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -197,7 +201,8 @@ public function deleteWebhookSubscriptionWithHttpInfo($webhookId) $httpBody, $headerParams, null, - '/notification-subscriptions/v2/webhooks/{webhookId}' + '/notification-subscriptions/v2/webhooks/{webhookId}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -304,6 +309,10 @@ public function getWebhookSubscriptionByIdWithHttpInfo($webhookId) } self::$logger->debug("Return Type : \CyberSource\Model\InlineResponse2015"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getWebhookSubscriptionById,getWebhookSubscriptionByIdWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -313,7 +322,8 @@ public function getWebhookSubscriptionByIdWithHttpInfo($webhookId) $httpBody, $headerParams, '\CyberSource\Model\InlineResponse2015', - '/notification-subscriptions/v2/webhooks/{webhookId}' + '/notification-subscriptions/v2/webhooks/{webhookId}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -435,6 +445,10 @@ public function getWebhookSubscriptionsByOrgWithHttpInfo($organizationId, $produ } self::$logger->debug("Return Type : \CyberSource\Model\InlineResponse2004[]"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getWebhookSubscriptionsByOrg,getWebhookSubscriptionsByOrgWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -444,7 +458,8 @@ public function getWebhookSubscriptionsByOrgWithHttpInfo($organizationId, $produ $httpBody, $headerParams, '\CyberSource\Model\InlineResponse2004[]', - '/notification-subscriptions/v2/webhooks' + '/notification-subscriptions/v2/webhooks', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -555,6 +570,10 @@ public function notificationSubscriptionsV1WebhooksWebhookIdPostWithHttpInfo($we } self::$logger->debug("Return Type : \CyberSource\Model\InlineResponse2016"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "notificationSubscriptionsV1WebhooksWebhookIdPost,notificationSubscriptionsV1WebhooksWebhookIdPostWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -564,7 +583,8 @@ public function notificationSubscriptionsV1WebhooksWebhookIdPostWithHttpInfo($we $httpBody, $headerParams, '\CyberSource\Model\InlineResponse2016', - '/notification-subscriptions/v1/webhooks/{webhookId}' + '/notification-subscriptions/v1/webhooks/{webhookId}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -684,6 +704,10 @@ public function notificationSubscriptionsV2WebhooksWebhookIdPatchWithHttpInfo($w } self::$logger->debug("Return Type : \CyberSource\Model\InlineResponse2005"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "notificationSubscriptionsV2WebhooksWebhookIdPatch,notificationSubscriptionsV2WebhooksWebhookIdPatchWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -693,7 +717,8 @@ public function notificationSubscriptionsV2WebhooksWebhookIdPatchWithHttpInfo($w $httpBody, $headerParams, '\CyberSource\Model\InlineResponse2005', - '/notification-subscriptions/v2/webhooks/{webhookId}' + '/notification-subscriptions/v2/webhooks/{webhookId}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -817,6 +842,10 @@ public function notificationSubscriptionsV2WebhooksWebhookIdStatusPutWithHttpInf } self::$logger->debug("Return Type : null"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "notificationSubscriptionsV2WebhooksWebhookIdStatusPut,notificationSubscriptionsV2WebhooksWebhookIdStatusPutWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -826,7 +855,8 @@ public function notificationSubscriptionsV2WebhooksWebhookIdStatusPutWithHttpInf $httpBody, $headerParams, null, - '/notification-subscriptions/v2/webhooks/{webhookId}/status' + '/notification-subscriptions/v2/webhooks/{webhookId}/status', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -964,6 +994,10 @@ public function saveAsymEgressKeyWithHttpInfo($vCSenderOrganizationId, $vCPermis } self::$logger->debug("Return Type : \CyberSource\Model\InlineResponse2017"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "saveAsymEgressKey,saveAsymEgressKeyWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -973,7 +1007,8 @@ public function saveAsymEgressKeyWithHttpInfo($vCSenderOrganizationId, $vCPermis $httpBody, $headerParams, '\CyberSource\Model\InlineResponse2017', - '/kms/egress/v2/keys-asym' + '/kms/egress/v2/keys-asym', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/MerchantBoardingApi.php b/lib/Api/MerchantBoardingApi.php index d2ce54f7..e4860a86 100644 --- a/lib/Api/MerchantBoardingApi.php +++ b/lib/Api/MerchantBoardingApi.php @@ -188,6 +188,10 @@ public function getRegistrationWithHttpInfo($registrationId) } self::$logger->debug("Return Type : \CyberSource\Model\InlineResponse2002"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getRegistration,getRegistrationWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -197,7 +201,8 @@ public function getRegistrationWithHttpInfo($registrationId) $httpBody, $headerParams, '\CyberSource\Model\InlineResponse2002', - '/boarding/v1/registrations/{registrationId}' + '/boarding/v1/registrations/{registrationId}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -325,6 +330,10 @@ public function postRegistrationWithHttpInfo($postRegistrationBody, $vCIdempoten } self::$logger->debug("Return Type : \CyberSource\Model\InlineResponse2013"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "postRegistration,postRegistrationWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -334,7 +343,8 @@ public function postRegistrationWithHttpInfo($postRegistrationBody, $vCIdempoten $httpBody, $headerParams, '\CyberSource\Model\InlineResponse2013', - '/boarding/v1/registrations' + '/boarding/v1/registrations', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/MicroformIntegrationApi.php b/lib/Api/MicroformIntegrationApi.php index 9f21ca62..c1ac0ea9 100644 --- a/lib/Api/MicroformIntegrationApi.php +++ b/lib/Api/MicroformIntegrationApi.php @@ -187,6 +187,10 @@ public function generateCaptureContextWithHttpInfo($generateCaptureContextReques } self::$logger->debug("Return Type : string"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "generateCaptureContext,generateCaptureContextWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -196,7 +200,8 @@ public function generateCaptureContextWithHttpInfo($generateCaptureContextReques $httpBody, $headerParams, 'string', - '/microform/v2/sessions' + '/microform/v2/sessions', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/NetFundingsApi.php b/lib/Api/NetFundingsApi.php index 0c7d5ea9..00fa91bb 100644 --- a/lib/Api/NetFundingsApi.php +++ b/lib/Api/NetFundingsApi.php @@ -211,6 +211,10 @@ public function getNetFundingDetailsWithHttpInfo($startTime, $endTime, $organiza } self::$logger->debug("Return Type : \CyberSource\Model\ReportingV3NetFundingsGet200Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getNetFundingDetails,getNetFundingDetailsWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -220,7 +224,8 @@ public function getNetFundingDetailsWithHttpInfo($startTime, $endTime, $organiza $httpBody, $headerParams, '\CyberSource\Model\ReportingV3NetFundingsGet200Response', - '/reporting/v3/net-fundings' + '/reporting/v3/net-fundings', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/NotificationOfChangesApi.php b/lib/Api/NotificationOfChangesApi.php index 6633d5de..e11b148c 100644 --- a/lib/Api/NotificationOfChangesApi.php +++ b/lib/Api/NotificationOfChangesApi.php @@ -197,6 +197,10 @@ public function getNotificationOfChangeReportWithHttpInfo($startTime, $endTime) } self::$logger->debug("Return Type : \CyberSource\Model\ReportingV3NotificationofChangesGet200Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getNotificationOfChangeReport,getNotificationOfChangeReportWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -206,7 +210,8 @@ public function getNotificationOfChangeReportWithHttpInfo($startTime, $endTime) $httpBody, $headerParams, '\CyberSource\Model\ReportingV3NotificationofChangesGet200Response', - '/reporting/v3/notification-of-changes' + '/reporting/v3/notification-of-changes', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/OrdersApi.php b/lib/Api/OrdersApi.php index cb7454c7..79dc9de2 100644 --- a/lib/Api/OrdersApi.php +++ b/lib/Api/OrdersApi.php @@ -187,6 +187,10 @@ public function createOrderWithHttpInfo($createOrderRequest) } self::$logger->debug("Return Type : \CyberSource\Model\PtsV2CreateOrderPost201Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "createOrder,createOrderWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -196,7 +200,8 @@ public function createOrderWithHttpInfo($createOrderRequest) $httpBody, $headerParams, '\CyberSource\Model\PtsV2CreateOrderPost201Response', - '/pts/v2/intents' + '/pts/v2/intents', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -329,6 +334,10 @@ public function updateOrderWithHttpInfo($id, $updateOrderRequest) } self::$logger->debug("Return Type : \CyberSource\Model\PtsV2UpdateOrderPatch201Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "updateOrder,updateOrderWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -338,7 +347,8 @@ public function updateOrderWithHttpInfo($id, $updateOrderRequest) $httpBody, $headerParams, '\CyberSource\Model\PtsV2UpdateOrderPatch201Response', - '/pts/v2/intents/{id}' + '/pts/v2/intents/{id}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/PayerAuthenticationApi.php b/lib/Api/PayerAuthenticationApi.php index f4baeacc..1c4d9b0a 100644 --- a/lib/Api/PayerAuthenticationApi.php +++ b/lib/Api/PayerAuthenticationApi.php @@ -187,6 +187,10 @@ public function checkPayerAuthEnrollmentWithHttpInfo($checkPayerAuthEnrollmentRe } self::$logger->debug("Return Type : \CyberSource\Model\RiskV1AuthenticationsPost201Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "checkPayerAuthEnrollment,checkPayerAuthEnrollmentWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -196,7 +200,8 @@ public function checkPayerAuthEnrollmentWithHttpInfo($checkPayerAuthEnrollmentRe $httpBody, $headerParams, '\CyberSource\Model\RiskV1AuthenticationsPost201Response', - '/risk/v1/authentications' + '/risk/v1/authentications', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -314,6 +319,10 @@ public function payerAuthSetupWithHttpInfo($payerAuthSetupRequest) } self::$logger->debug("Return Type : \CyberSource\Model\RiskV1AuthenticationSetupsPost201Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "payerAuthSetup,payerAuthSetupWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -323,7 +332,8 @@ public function payerAuthSetupWithHttpInfo($payerAuthSetupRequest) $httpBody, $headerParams, '\CyberSource\Model\RiskV1AuthenticationSetupsPost201Response', - '/risk/v1/authentication-setups' + '/risk/v1/authentication-setups', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -441,6 +451,10 @@ public function validateAuthenticationResultsWithHttpInfo($validateRequest) } self::$logger->debug("Return Type : \CyberSource\Model\RiskV1AuthenticationResultsPost201Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "validateAuthenticationResults,validateAuthenticationResultsWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -450,7 +464,8 @@ public function validateAuthenticationResultsWithHttpInfo($validateRequest) $httpBody, $headerParams, '\CyberSource\Model\RiskV1AuthenticationResultsPost201Response', - '/risk/v1/authentication-results' + '/risk/v1/authentication-results', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/PaymentBatchSummariesApi.php b/lib/Api/PaymentBatchSummariesApi.php index ba1f1fed..2cc9465b 100644 --- a/lib/Api/PaymentBatchSummariesApi.php +++ b/lib/Api/PaymentBatchSummariesApi.php @@ -225,6 +225,10 @@ public function getPaymentBatchSummaryWithHttpInfo($startTime, $endTime, $organi } self::$logger->debug("Return Type : \CyberSource\Model\ReportingV3PaymentBatchSummariesGet200Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getPaymentBatchSummary,getPaymentBatchSummaryWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -234,7 +238,8 @@ public function getPaymentBatchSummaryWithHttpInfo($startTime, $endTime, $organi $httpBody, $headerParams, '\CyberSource\Model\ReportingV3PaymentBatchSummariesGet200Response', - '/reporting/v3/payment-batch-summaries' + '/reporting/v3/payment-batch-summaries', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/PaymentInstrumentApi.php b/lib/Api/PaymentInstrumentApi.php index faf67917..c21142ba 100644 --- a/lib/Api/PaymentInstrumentApi.php +++ b/lib/Api/PaymentInstrumentApi.php @@ -194,6 +194,10 @@ public function deletePaymentInstrumentWithHttpInfo($paymentInstrumentId, $profi } self::$logger->debug("Return Type : null"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "deletePaymentInstrument,deletePaymentInstrumentWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -203,7 +207,8 @@ public function deletePaymentInstrumentWithHttpInfo($paymentInstrumentId, $profi $httpBody, $headerParams, null, - '/tms/v1/paymentinstruments/{paymentInstrumentId}' + '/tms/v1/paymentinstruments/{paymentInstrumentId}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -343,6 +348,10 @@ public function getPaymentInstrumentWithHttpInfo($paymentInstrumentId, $profileI } self::$logger->debug("Return Type : \CyberSource\Model\PostPaymentInstrumentRequest"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getPaymentInstrument,getPaymentInstrumentWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -352,7 +361,8 @@ public function getPaymentInstrumentWithHttpInfo($paymentInstrumentId, $profileI $httpBody, $headerParams, '\CyberSource\Model\PostPaymentInstrumentRequest', - '/tms/v1/paymentinstruments/{paymentInstrumentId}' + '/tms/v1/paymentinstruments/{paymentInstrumentId}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -520,6 +530,10 @@ public function patchPaymentInstrumentWithHttpInfo($paymentInstrumentId, $patchP } self::$logger->debug("Return Type : \CyberSource\Model\PatchPaymentInstrumentRequest"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "patchPaymentInstrument,patchPaymentInstrumentWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -529,7 +543,8 @@ public function patchPaymentInstrumentWithHttpInfo($paymentInstrumentId, $patchP $httpBody, $headerParams, '\CyberSource\Model\PatchPaymentInstrumentRequest', - '/tms/v1/paymentinstruments/{paymentInstrumentId}' + '/tms/v1/paymentinstruments/{paymentInstrumentId}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -680,6 +695,10 @@ public function postPaymentInstrumentWithHttpInfo($postPaymentInstrumentRequest, } self::$logger->debug("Return Type : \CyberSource\Model\PostPaymentInstrumentRequest"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "postPaymentInstrument,postPaymentInstrumentWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -689,7 +708,8 @@ public function postPaymentInstrumentWithHttpInfo($postPaymentInstrumentRequest, $httpBody, $headerParams, '\CyberSource\Model\PostPaymentInstrumentRequest', - '/tms/v1/paymentinstruments' + '/tms/v1/paymentinstruments', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/PaymentLinksApi.php b/lib/Api/PaymentLinksApi.php index 09ed9a08..f865389b 100644 --- a/lib/Api/PaymentLinksApi.php +++ b/lib/Api/PaymentLinksApi.php @@ -187,6 +187,10 @@ public function createPaymentLinkWithHttpInfo($createPaymentLinkRequest) } self::$logger->debug("Return Type : \CyberSource\Model\PblPaymentLinksPost201Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "createPaymentLink,createPaymentLinkWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -196,7 +200,8 @@ public function createPaymentLinkWithHttpInfo($createPaymentLinkRequest) $httpBody, $headerParams, '\CyberSource\Model\PblPaymentLinksPost201Response', - '/ipl/v2/payment-links' + '/ipl/v2/payment-links', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -335,6 +340,10 @@ public function getAllPaymentLinksWithHttpInfo($offset, $limit, $status = null) } self::$logger->debug("Return Type : \CyberSource\Model\PblPaymentLinksAllGet200Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getAllPaymentLinks,getAllPaymentLinksWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -344,7 +353,8 @@ public function getAllPaymentLinksWithHttpInfo($offset, $limit, $status = null) $httpBody, $headerParams, '\CyberSource\Model\PblPaymentLinksAllGet200Response', - '/ipl/v2/payment-links' + '/ipl/v2/payment-links', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -467,6 +477,10 @@ public function getPaymentLinkWithHttpInfo($id) } self::$logger->debug("Return Type : \CyberSource\Model\PblPaymentLinksGet200Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getPaymentLink,getPaymentLinkWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -476,7 +490,8 @@ public function getPaymentLinkWithHttpInfo($id) $httpBody, $headerParams, '\CyberSource\Model\PblPaymentLinksGet200Response', - '/ipl/v2/payment-links/{id}' + '/ipl/v2/payment-links/{id}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -613,6 +628,10 @@ public function updatePaymentLinkWithHttpInfo($id, $updatePaymentLinkRequest) } self::$logger->debug("Return Type : \CyberSource\Model\PblPaymentLinksPost201Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "updatePaymentLink,updatePaymentLinkWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -622,7 +641,8 @@ public function updatePaymentLinkWithHttpInfo($id, $updatePaymentLinkRequest) $httpBody, $headerParams, '\CyberSource\Model\PblPaymentLinksPost201Response', - '/ipl/v2/payment-links/{id}' + '/ipl/v2/payment-links/{id}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/PaymentTokensApi.php b/lib/Api/PaymentTokensApi.php index 29f2c35b..97925f13 100644 --- a/lib/Api/PaymentTokensApi.php +++ b/lib/Api/PaymentTokensApi.php @@ -187,6 +187,10 @@ public function retrieveOrDeletePaymentTokenWithHttpInfo($request) } self::$logger->debug("Return Type : \CyberSource\Model\InlineResponse201"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "retrieveOrDeletePaymentToken,retrieveOrDeletePaymentTokenWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -196,7 +200,8 @@ public function retrieveOrDeletePaymentTokenWithHttpInfo($request) $httpBody, $headerParams, '\CyberSource\Model\InlineResponse201', - '/pts/v2/payment-tokens' + '/pts/v2/payment-tokens', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/PaymentsApi.php b/lib/Api/PaymentsApi.php index 1f80bc49..ecc2dac9 100644 --- a/lib/Api/PaymentsApi.php +++ b/lib/Api/PaymentsApi.php @@ -202,6 +202,10 @@ public function createOrderRequestWithHttpInfo($orderPaymentRequest, $id) } self::$logger->debug("Return Type : \CyberSource\Model\PtsV2PaymentsOrderPost201Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "createOrderRequest,createOrderRequestWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -211,7 +215,8 @@ public function createOrderRequestWithHttpInfo($orderPaymentRequest, $id) $httpBody, $headerParams, '\CyberSource\Model\PtsV2PaymentsOrderPost201Response', - '/pts/v2/payment-references/{id}/intents' + '/pts/v2/payment-references/{id}/intents', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -314,7 +319,7 @@ public function createPaymentWithHttpInfo($createPaymentRequest) throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } - $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "createPayment,createPaymentWithHttpInfo"); + // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -329,6 +334,10 @@ public function createPaymentWithHttpInfo($createPaymentRequest) } self::$logger->debug("Return Type : \CyberSource\Model\PtsV2PaymentsPost201Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "createPayment,createPaymentWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -457,6 +466,10 @@ public function createSessionRequestWithHttpInfo($createSessionReq) } self::$logger->debug("Return Type : \CyberSource\Model\PtsV2PaymentsPost201Response2"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "createSessionRequest,createSessionRequestWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -466,7 +479,8 @@ public function createSessionRequestWithHttpInfo($createSessionReq) $httpBody, $headerParams, '\CyberSource\Model\PtsV2PaymentsPost201Response2', - '/pts/v2/payment-references' + '/pts/v2/payment-references', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -599,6 +613,10 @@ public function incrementAuthWithHttpInfo($id, $incrementAuthRequest) } self::$logger->debug("Return Type : \CyberSource\Model\PtsV2IncrementalAuthorizationPatch201Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "incrementAuth,incrementAuthWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -608,7 +626,8 @@ public function incrementAuthWithHttpInfo($id, $incrementAuthRequest) $httpBody, $headerParams, '\CyberSource\Model\PtsV2IncrementalAuthorizationPatch201Response', - '/pts/v2/payments/{id}' + '/pts/v2/payments/{id}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -741,6 +760,10 @@ public function refreshPaymentStatusWithHttpInfo($id, $refreshPaymentStatusReque } self::$logger->debug("Return Type : \CyberSource\Model\PtsV2PaymentsPost201Response1"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "refreshPaymentStatus,refreshPaymentStatusWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -750,7 +773,8 @@ public function refreshPaymentStatusWithHttpInfo($id, $refreshPaymentStatusReque $httpBody, $headerParams, '\CyberSource\Model\PtsV2PaymentsPost201Response1', - '/pts/v2/refresh-payment-status/{id}' + '/pts/v2/refresh-payment-status/{id}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -883,6 +907,10 @@ public function updateSessionReqWithHttpInfo($createSessionRequest, $id) } self::$logger->debug("Return Type : \CyberSource\Model\PtsV2PaymentsPost201Response2"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "updateSessionReq,updateSessionReqWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -892,7 +920,8 @@ public function updateSessionReqWithHttpInfo($createSessionRequest, $id) $httpBody, $headerParams, '\CyberSource\Model\PtsV2PaymentsPost201Response2', - '/pts/v2/payment-references/{id}' + '/pts/v2/payment-references/{id}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/PayoutsApi.php b/lib/Api/PayoutsApi.php index 55d2057c..3ebed382 100644 --- a/lib/Api/PayoutsApi.php +++ b/lib/Api/PayoutsApi.php @@ -187,6 +187,10 @@ public function octCreatePaymentWithHttpInfo($octCreatePaymentRequest) } self::$logger->debug("Return Type : \CyberSource\Model\PtsV2PayoutsPost201Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "octCreatePayment,octCreatePaymentWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -196,7 +200,8 @@ public function octCreatePaymentWithHttpInfo($octCreatePaymentRequest) $httpBody, $headerParams, '\CyberSource\Model\PtsV2PayoutsPost201Response', - '/pts/v2/payouts' + '/pts/v2/payouts', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/PlansApi.php b/lib/Api/PlansApi.php index 342a514c..9a3db392 100644 --- a/lib/Api/PlansApi.php +++ b/lib/Api/PlansApi.php @@ -188,6 +188,10 @@ public function activatePlanWithHttpInfo($id) } self::$logger->debug("Return Type : \CyberSource\Model\ActivateDeactivatePlanResponse"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "activatePlan,activatePlanWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -197,7 +201,8 @@ public function activatePlanWithHttpInfo($id) $httpBody, $headerParams, '\CyberSource\Model\ActivateDeactivatePlanResponse', - '/rbs/v1/plans/{id}/activate' + '/rbs/v1/plans/{id}/activate', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -319,6 +324,10 @@ public function createPlanWithHttpInfo($createPlanRequest) } self::$logger->debug("Return Type : \CyberSource\Model\CreatePlanResponse"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "createPlan,createPlanWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -328,7 +337,8 @@ public function createPlanWithHttpInfo($createPlanRequest) $httpBody, $headerParams, '\CyberSource\Model\CreatePlanResponse', - '/rbs/v1/plans' + '/rbs/v1/plans', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -447,6 +457,10 @@ public function deactivatePlanWithHttpInfo($id) } self::$logger->debug("Return Type : \CyberSource\Model\ActivateDeactivatePlanResponse"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "deactivatePlan,deactivatePlanWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -456,7 +470,8 @@ public function deactivatePlanWithHttpInfo($id) $httpBody, $headerParams, '\CyberSource\Model\ActivateDeactivatePlanResponse', - '/rbs/v1/plans/{id}/deactivate' + '/rbs/v1/plans/{id}/deactivate', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -579,6 +594,10 @@ public function deletePlanWithHttpInfo($id) } self::$logger->debug("Return Type : \CyberSource\Model\DeletePlanResponse"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "deletePlan,deletePlanWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -588,7 +607,8 @@ public function deletePlanWithHttpInfo($id) $httpBody, $headerParams, '\CyberSource\Model\DeletePlanResponse', - '/rbs/v1/plans/{id}' + '/rbs/v1/plans/{id}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -711,6 +731,10 @@ public function getPlanWithHttpInfo($id) } self::$logger->debug("Return Type : \CyberSource\Model\GetPlanResponse"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getPlan,getPlanWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -720,7 +744,8 @@ public function getPlanWithHttpInfo($id) $httpBody, $headerParams, '\CyberSource\Model\GetPlanResponse', - '/rbs/v1/plans/{id}' + '/rbs/v1/plans/{id}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -828,6 +853,10 @@ public function getPlanCodeWithHttpInfo() } self::$logger->debug("Return Type : \CyberSource\Model\GetPlanCodeResponse"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getPlanCode,getPlanCodeWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -837,7 +866,8 @@ public function getPlanCodeWithHttpInfo() $httpBody, $headerParams, '\CyberSource\Model\GetPlanCodeResponse', - '/rbs/v1/plans/code' + '/rbs/v1/plans/code', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -976,6 +1006,10 @@ public function getPlansWithHttpInfo($offset = null, $limit = null, $code = null } self::$logger->debug("Return Type : \CyberSource\Model\GetAllPlansResponse"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getPlans,getPlansWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -985,7 +1019,8 @@ public function getPlansWithHttpInfo($offset = null, $limit = null, $code = null $httpBody, $headerParams, '\CyberSource\Model\GetAllPlansResponse', - '/rbs/v1/plans' + '/rbs/v1/plans', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -1118,6 +1153,10 @@ public function updatePlanWithHttpInfo($id, $updatePlanRequest) } self::$logger->debug("Return Type : \CyberSource\Model\UpdatePlanResponse"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "updatePlan,updatePlanWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -1127,7 +1166,8 @@ public function updatePlanWithHttpInfo($id, $updatePlanRequest) $httpBody, $headerParams, '\CyberSource\Model\UpdatePlanResponse', - '/rbs/v1/plans/{id}' + '/rbs/v1/plans/{id}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/PurchaseAndRefundDetailsApi.php b/lib/Api/PurchaseAndRefundDetailsApi.php index b21854bf..3346b860 100644 --- a/lib/Api/PurchaseAndRefundDetailsApi.php +++ b/lib/Api/PurchaseAndRefundDetailsApi.php @@ -239,6 +239,10 @@ public function getPurchaseAndRefundDetailsWithHttpInfo($startTime, $endTime, $o } self::$logger->debug("Return Type : \CyberSource\Model\ReportingV3PurchaseRefundDetailsGet200Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getPurchaseAndRefundDetails,getPurchaseAndRefundDetailsWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -248,7 +252,8 @@ public function getPurchaseAndRefundDetailsWithHttpInfo($startTime, $endTime, $o $httpBody, $headerParams, '\CyberSource\Model\ReportingV3PurchaseRefundDetailsGet200Response', - '/reporting/v3/purchase-refund-details' + '/reporting/v3/purchase-refund-details', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/PushFundsApi.php b/lib/Api/PushFundsApi.php index d6a9d574..9ecbb0d4 100644 --- a/lib/Api/PushFundsApi.php +++ b/lib/Api/PushFundsApi.php @@ -253,6 +253,10 @@ public function createPushFundsTransferWithHttpInfo($pushFundsRequest, $contentT } self::$logger->debug("Return Type : \CyberSource\Model\PushFunds201Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "createPushFundsTransfer,createPushFundsTransferWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -262,7 +266,8 @@ public function createPushFundsTransferWithHttpInfo($pushFundsRequest, $contentT $httpBody, $headerParams, '\CyberSource\Model\PushFunds201Response', - '/pts/v1/push-funds-transfer' + '/pts/v1/push-funds-transfer', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/RefundApi.php b/lib/Api/RefundApi.php index 6572db3a..db828b49 100644 --- a/lib/Api/RefundApi.php +++ b/lib/Api/RefundApi.php @@ -202,6 +202,10 @@ public function refundCaptureWithHttpInfo($refundCaptureRequest, $id) } self::$logger->debug("Return Type : \CyberSource\Model\PtsV2PaymentsRefundPost201Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "refundCapture,refundCaptureWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -211,7 +215,8 @@ public function refundCaptureWithHttpInfo($refundCaptureRequest, $id) $httpBody, $headerParams, '\CyberSource\Model\PtsV2PaymentsRefundPost201Response', - '/pts/v2/captures/{id}/refunds' + '/pts/v2/captures/{id}/refunds', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -344,6 +349,10 @@ public function refundPaymentWithHttpInfo($refundPaymentRequest, $id) } self::$logger->debug("Return Type : \CyberSource\Model\PtsV2PaymentsRefundPost201Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "refundPayment,refundPaymentWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -353,7 +362,8 @@ public function refundPaymentWithHttpInfo($refundPaymentRequest, $id) $httpBody, $headerParams, '\CyberSource\Model\PtsV2PaymentsRefundPost201Response', - '/pts/v2/payments/{id}/refunds' + '/pts/v2/payments/{id}/refunds', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/ReportDefinitionsApi.php b/lib/Api/ReportDefinitionsApi.php index a8252c0c..a01fddab 100644 --- a/lib/Api/ReportDefinitionsApi.php +++ b/lib/Api/ReportDefinitionsApi.php @@ -209,6 +209,10 @@ public function getResourceInfoByReportDefinitionWithHttpInfo($reportDefinitionN } self::$logger->debug("Return Type : \CyberSource\Model\ReportingV3ReportDefinitionsNameGet200Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getResourceInfoByReportDefinition,getResourceInfoByReportDefinitionWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -218,7 +222,8 @@ public function getResourceInfoByReportDefinitionWithHttpInfo($reportDefinitionN $httpBody, $headerParams, '\CyberSource\Model\ReportingV3ReportDefinitionsNameGet200Response', - '/reporting/v3/report-definitions/{reportDefinitionName}' + '/reporting/v3/report-definitions/{reportDefinitionName}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -332,6 +337,10 @@ public function getResourceV2InfoWithHttpInfo($subscriptionType = null, $organiz } self::$logger->debug("Return Type : \CyberSource\Model\ReportingV3ReportDefinitionsGet200Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getResourceV2Info,getResourceV2InfoWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -341,7 +350,8 @@ public function getResourceV2InfoWithHttpInfo($subscriptionType = null, $organiz $httpBody, $headerParams, '\CyberSource\Model\ReportingV3ReportDefinitionsGet200Response', - '/reporting/v3/report-definitions' + '/reporting/v3/report-definitions', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/ReportDownloadsApi.php b/lib/Api/ReportDownloadsApi.php index c8ac491b..8d9d6a86 100644 --- a/lib/Api/ReportDownloadsApi.php +++ b/lib/Api/ReportDownloadsApi.php @@ -204,6 +204,10 @@ public function downloadReportWithHttpInfo($reportDate, $reportName, $organizati } self::$logger->debug("Return Type : null"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "downloadReport,downloadReportWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -213,7 +217,8 @@ public function downloadReportWithHttpInfo($reportDate, $reportName, $organizati $httpBody, $headerParams, null, - '/reporting/v3/report-downloads' + '/reporting/v3/report-downloads', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/ReportSubscriptionsApi.php b/lib/Api/ReportSubscriptionsApi.php index 750dcc44..e972f69a 100644 --- a/lib/Api/ReportSubscriptionsApi.php +++ b/lib/Api/ReportSubscriptionsApi.php @@ -194,6 +194,10 @@ public function createStandardOrClassicSubscriptionWithHttpInfo($predefinedSubsc } self::$logger->debug("Return Type : null"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "createStandardOrClassicSubscription,createStandardOrClassicSubscriptionWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -203,7 +207,8 @@ public function createStandardOrClassicSubscriptionWithHttpInfo($predefinedSubsc $httpBody, $headerParams, null, - '/reporting/v3/predefined-report-subscriptions' + '/reporting/v3/predefined-report-subscriptions', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -320,6 +325,10 @@ public function createSubscriptionWithHttpInfo($createReportSubscriptionRequest, } self::$logger->debug("Return Type : null"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "createSubscription,createSubscriptionWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -329,7 +338,8 @@ public function createSubscriptionWithHttpInfo($createReportSubscriptionRequest, $httpBody, $headerParams, null, - '/reporting/v3/report-subscriptions' + '/reporting/v3/report-subscriptions', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -447,6 +457,10 @@ public function deleteSubscriptionWithHttpInfo($reportName, $organizationId = nu } self::$logger->debug("Return Type : null"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "deleteSubscription,deleteSubscriptionWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -456,7 +470,8 @@ public function deleteSubscriptionWithHttpInfo($reportName, $organizationId = nu $httpBody, $headerParams, null, - '/reporting/v3/report-subscriptions/{reportName}' + '/reporting/v3/report-subscriptions/{reportName}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -563,6 +578,10 @@ public function getAllSubscriptionsWithHttpInfo($organizationId = null) } self::$logger->debug("Return Type : \CyberSource\Model\ReportingV3ReportSubscriptionsGet200Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getAllSubscriptions,getAllSubscriptionsWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -572,7 +591,8 @@ public function getAllSubscriptionsWithHttpInfo($organizationId = null) $httpBody, $headerParams, '\CyberSource\Model\ReportingV3ReportSubscriptionsGet200Response', - '/reporting/v3/report-subscriptions' + '/reporting/v3/report-subscriptions', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -694,6 +714,10 @@ public function getSubscriptionWithHttpInfo($reportName, $organizationId = null) } self::$logger->debug("Return Type : \CyberSource\Model\ReportingV3ReportSubscriptionsGet200ResponseSubscriptions"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getSubscription,getSubscriptionWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -703,7 +727,8 @@ public function getSubscriptionWithHttpInfo($reportName, $organizationId = null) $httpBody, $headerParams, '\CyberSource\Model\ReportingV3ReportSubscriptionsGet200ResponseSubscriptions', - '/reporting/v3/report-subscriptions/{reportName}' + '/reporting/v3/report-subscriptions/{reportName}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/ReportsApi.php b/lib/Api/ReportsApi.php index 465d3249..0539b099 100644 --- a/lib/Api/ReportsApi.php +++ b/lib/Api/ReportsApi.php @@ -194,6 +194,10 @@ public function createReportWithHttpInfo($createAdhocReportRequest, $organizatio } self::$logger->debug("Return Type : null"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "createReport,createReportWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -203,7 +207,8 @@ public function createReportWithHttpInfo($createAdhocReportRequest, $organizatio $httpBody, $headerParams, null, - '/reporting/v3/reports' + '/reporting/v3/reports', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -321,6 +326,10 @@ public function getReportByReportIdWithHttpInfo($reportId, $organizationId = nul } self::$logger->debug("Return Type : \CyberSource\Model\ReportingV3ReportsIdGet200Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getReportByReportId,getReportByReportIdWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -330,7 +339,8 @@ public function getReportByReportIdWithHttpInfo($reportId, $organizationId = nul $httpBody, $headerParams, '\CyberSource\Model\ReportingV3ReportsIdGet200Response', - '/reporting/v3/reports/{reportId}' + '/reporting/v3/reports/{reportId}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -508,6 +518,10 @@ public function searchReportsWithHttpInfo($startTime, $endTime, $timeQueryType, } self::$logger->debug("Return Type : \CyberSource\Model\ReportingV3ReportsGet200Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "searchReports,searchReportsWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -517,7 +531,8 @@ public function searchReportsWithHttpInfo($startTime, $endTime, $timeQueryType, $httpBody, $headerParams, '\CyberSource\Model\ReportingV3ReportsGet200Response', - '/reporting/v3/reports' + '/reporting/v3/reports', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/RetrievalDetailsApi.php b/lib/Api/RetrievalDetailsApi.php index 4b4fb9e4..9b3e45a1 100644 --- a/lib/Api/RetrievalDetailsApi.php +++ b/lib/Api/RetrievalDetailsApi.php @@ -204,6 +204,10 @@ public function getRetrievalDetailsWithHttpInfo($startTime, $endTime, $organizat } self::$logger->debug("Return Type : \CyberSource\Model\ReportingV3RetrievalDetailsGet200Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getRetrievalDetails,getRetrievalDetailsWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -213,7 +217,8 @@ public function getRetrievalDetailsWithHttpInfo($startTime, $endTime, $organizat $httpBody, $headerParams, '\CyberSource\Model\ReportingV3RetrievalDetailsGet200Response', - '/reporting/v3/retrieval-details' + '/reporting/v3/retrieval-details', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/RetrievalSummariesApi.php b/lib/Api/RetrievalSummariesApi.php index bfeb76bf..0d594592 100644 --- a/lib/Api/RetrievalSummariesApi.php +++ b/lib/Api/RetrievalSummariesApi.php @@ -204,6 +204,10 @@ public function getRetrievalSummaryWithHttpInfo($startTime, $endTime, $organizat } self::$logger->debug("Return Type : \CyberSource\Model\ReportingV3RetrievalSummariesGet200Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getRetrievalSummary,getRetrievalSummaryWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -213,7 +217,8 @@ public function getRetrievalSummaryWithHttpInfo($startTime, $endTime, $organizat $httpBody, $headerParams, '\CyberSource\Model\ReportingV3RetrievalSummariesGet200Response', - '/reporting/v3/retrieval-summaries' + '/reporting/v3/retrieval-summaries', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/ReversalApi.php b/lib/Api/ReversalApi.php index 5ac3b6cf..d8a7a8b8 100644 --- a/lib/Api/ReversalApi.php +++ b/lib/Api/ReversalApi.php @@ -202,6 +202,10 @@ public function authReversalWithHttpInfo($id, $authReversalRequest) } self::$logger->debug("Return Type : \CyberSource\Model\PtsV2PaymentsReversalsPost201Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "authReversal,authReversalWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -211,7 +215,8 @@ public function authReversalWithHttpInfo($id, $authReversalRequest) $httpBody, $headerParams, '\CyberSource\Model\PtsV2PaymentsReversalsPost201Response', - '/pts/v2/payments/{id}/reversals' + '/pts/v2/payments/{id}/reversals', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -329,6 +334,10 @@ public function mitReversalWithHttpInfo($mitReversalRequest) } self::$logger->debug("Return Type : \CyberSource\Model\PtsV2PaymentsReversalsPost201Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "mitReversal,mitReversalWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -338,7 +347,8 @@ public function mitReversalWithHttpInfo($mitReversalRequest) $httpBody, $headerParams, '\CyberSource\Model\PtsV2PaymentsReversalsPost201Response', - '/pts/v2/reversals' + '/pts/v2/reversals', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/SearchTransactionsApi.php b/lib/Api/SearchTransactionsApi.php index 01da666b..60635781 100644 --- a/lib/Api/SearchTransactionsApi.php +++ b/lib/Api/SearchTransactionsApi.php @@ -187,6 +187,10 @@ public function createSearchWithHttpInfo($createSearchRequest) } self::$logger->debug("Return Type : \CyberSource\Model\TssV2TransactionsPost201Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "createSearch,createSearchWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -196,7 +200,8 @@ public function createSearchWithHttpInfo($createSearchRequest) $httpBody, $headerParams, '\CyberSource\Model\TssV2TransactionsPost201Response', - '/tss/v2/searches' + '/tss/v2/searches', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -315,6 +320,10 @@ public function getSearchWithHttpInfo($searchId) } self::$logger->debug("Return Type : \CyberSource\Model\TssV2TransactionsPost201Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getSearch,getSearchWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -324,7 +333,8 @@ public function getSearchWithHttpInfo($searchId) $httpBody, $headerParams, '\CyberSource\Model\TssV2TransactionsPost201Response', - '/tss/v2/searches/{searchId}' + '/tss/v2/searches/{searchId}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/SecureFileShareApi.php b/lib/Api/SecureFileShareApi.php index f755e8e3..4066a018 100644 --- a/lib/Api/SecureFileShareApi.php +++ b/lib/Api/SecureFileShareApi.php @@ -195,6 +195,10 @@ public function getFileWithHttpInfo($fileId, $organizationId = null) } self::$logger->debug("Return Type : null"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getFile,getFileWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -204,7 +208,8 @@ public function getFileWithHttpInfo($fileId, $organizationId = null) $httpBody, $headerParams, null, - '/sfs/v1/files/{fileId}' + '/sfs/v1/files/{fileId}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -338,6 +343,10 @@ public function getFileDetailWithHttpInfo($startDate, $endDate, $organizationId } self::$logger->debug("Return Type : \CyberSource\Model\V1FileDetailsGet200Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getFileDetail,getFileDetailWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -347,7 +356,8 @@ public function getFileDetailWithHttpInfo($startDate, $endDate, $organizationId $httpBody, $headerParams, '\CyberSource\Model\V1FileDetailsGet200Response', - '/sfs/v1/file-details' + '/sfs/v1/file-details', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/SubscriptionsApi.php b/lib/Api/SubscriptionsApi.php index 633d7fa7..1cd50e7e 100644 --- a/lib/Api/SubscriptionsApi.php +++ b/lib/Api/SubscriptionsApi.php @@ -195,6 +195,10 @@ public function activateSubscriptionWithHttpInfo($id, $processSkippedPayments = } self::$logger->debug("Return Type : \CyberSource\Model\ActivateSubscriptionResponse"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "activateSubscription,activateSubscriptionWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -204,7 +208,8 @@ public function activateSubscriptionWithHttpInfo($id, $processSkippedPayments = $httpBody, $headerParams, '\CyberSource\Model\ActivateSubscriptionResponse', - '/rbs/v1/subscriptions/{id}/activate' + '/rbs/v1/subscriptions/{id}/activate', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -327,6 +332,10 @@ public function cancelSubscriptionWithHttpInfo($id) } self::$logger->debug("Return Type : \CyberSource\Model\CancelSubscriptionResponse"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "cancelSubscription,cancelSubscriptionWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -336,7 +345,8 @@ public function cancelSubscriptionWithHttpInfo($id) $httpBody, $headerParams, '\CyberSource\Model\CancelSubscriptionResponse', - '/rbs/v1/subscriptions/{id}/cancel' + '/rbs/v1/subscriptions/{id}/cancel', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -458,6 +468,10 @@ public function createSubscriptionWithHttpInfo($createSubscriptionRequest) } self::$logger->debug("Return Type : \CyberSource\Model\CreateSubscriptionResponse"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "createSubscription,createSubscriptionWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -467,7 +481,8 @@ public function createSubscriptionWithHttpInfo($createSubscriptionRequest) $httpBody, $headerParams, '\CyberSource\Model\CreateSubscriptionResponse', - '/rbs/v1/subscriptions' + '/rbs/v1/subscriptions', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -599,6 +614,10 @@ public function getAllSubscriptionsWithHttpInfo($offset = null, $limit = null, $ } self::$logger->debug("Return Type : \CyberSource\Model\GetAllSubscriptionsResponse"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getAllSubscriptions,getAllSubscriptionsWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -608,7 +627,8 @@ public function getAllSubscriptionsWithHttpInfo($offset = null, $limit = null, $ $httpBody, $headerParams, '\CyberSource\Model\GetAllSubscriptionsResponse', - '/rbs/v1/subscriptions' + '/rbs/v1/subscriptions', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -727,6 +747,10 @@ public function getSubscriptionWithHttpInfo($id) } self::$logger->debug("Return Type : \CyberSource\Model\GetSubscriptionResponse"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getSubscription,getSubscriptionWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -736,7 +760,8 @@ public function getSubscriptionWithHttpInfo($id) $httpBody, $headerParams, '\CyberSource\Model\GetSubscriptionResponse', - '/rbs/v1/subscriptions/{id}' + '/rbs/v1/subscriptions/{id}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -844,6 +869,10 @@ public function getSubscriptionCodeWithHttpInfo() } self::$logger->debug("Return Type : \CyberSource\Model\GetSubscriptionCodeResponse"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getSubscriptionCode,getSubscriptionCodeWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -853,7 +882,8 @@ public function getSubscriptionCodeWithHttpInfo() $httpBody, $headerParams, '\CyberSource\Model\GetSubscriptionCodeResponse', - '/rbs/v1/subscriptions/code' + '/rbs/v1/subscriptions/code', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -972,6 +1002,10 @@ public function suspendSubscriptionWithHttpInfo($id) } self::$logger->debug("Return Type : \CyberSource\Model\SuspendSubscriptionResponse"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "suspendSubscription,suspendSubscriptionWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -981,7 +1015,8 @@ public function suspendSubscriptionWithHttpInfo($id) $httpBody, $headerParams, '\CyberSource\Model\SuspendSubscriptionResponse', - '/rbs/v1/subscriptions/{id}/suspend' + '/rbs/v1/subscriptions/{id}/suspend', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -1118,6 +1153,10 @@ public function updateSubscriptionWithHttpInfo($id, $updateSubscription) } self::$logger->debug("Return Type : \CyberSource\Model\UpdateSubscriptionResponse"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "updateSubscription,updateSubscriptionWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -1127,7 +1166,8 @@ public function updateSubscriptionWithHttpInfo($id, $updateSubscription) $httpBody, $headerParams, '\CyberSource\Model\UpdateSubscriptionResponse', - '/rbs/v1/subscriptions/{id}' + '/rbs/v1/subscriptions/{id}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/SubscriptionsFollowOnsApi.php b/lib/Api/SubscriptionsFollowOnsApi.php index 2d885c3c..4458d987 100644 --- a/lib/Api/SubscriptionsFollowOnsApi.php +++ b/lib/Api/SubscriptionsFollowOnsApi.php @@ -202,6 +202,10 @@ public function createFollowOnSubscriptionWithHttpInfo($requestId, $createSubscr } self::$logger->debug("Return Type : \CyberSource\Model\CreateSubscriptionResponse"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "createFollowOnSubscription,createFollowOnSubscriptionWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -211,7 +215,8 @@ public function createFollowOnSubscriptionWithHttpInfo($requestId, $createSubscr $httpBody, $headerParams, '\CyberSource\Model\CreateSubscriptionResponse', - '/rbs/v1/subscriptions/follow-ons/{requestId}' + '/rbs/v1/subscriptions/follow-ons/{requestId}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -330,6 +335,10 @@ public function getFollowOnSubscriptionWithHttpInfo($requestId) } self::$logger->debug("Return Type : \CyberSource\Model\GetSubscriptionResponse1"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getFollowOnSubscription,getFollowOnSubscriptionWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -339,7 +348,8 @@ public function getFollowOnSubscriptionWithHttpInfo($requestId) $httpBody, $headerParams, '\CyberSource\Model\GetSubscriptionResponse1', - '/rbs/v1/subscriptions/follow-ons/{requestId}' + '/rbs/v1/subscriptions/follow-ons/{requestId}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/TaxesApi.php b/lib/Api/TaxesApi.php index 80bfa063..aa056f64 100644 --- a/lib/Api/TaxesApi.php +++ b/lib/Api/TaxesApi.php @@ -187,6 +187,10 @@ public function calculateTaxWithHttpInfo($taxRequest) } self::$logger->debug("Return Type : \CyberSource\Model\VasV2PaymentsPost201Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "calculateTax,calculateTaxWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -196,7 +200,8 @@ public function calculateTaxWithHttpInfo($taxRequest) $httpBody, $headerParams, '\CyberSource\Model\VasV2PaymentsPost201Response', - '/vas/v2/tax' + '/vas/v2/tax', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -329,6 +334,10 @@ public function voidTaxWithHttpInfo($voidTaxRequest, $id) } self::$logger->debug("Return Type : \CyberSource\Model\VasV2TaxVoid200Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "voidTax,voidTaxWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -338,7 +347,8 @@ public function voidTaxWithHttpInfo($voidTaxRequest, $id) $httpBody, $headerParams, '\CyberSource\Model\VasV2TaxVoid200Response', - '/vas/v2/tax/{id}' + '/vas/v2/tax/{id}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/TokenApi.php b/lib/Api/TokenApi.php index befdefcc..76cd00f6 100644 --- a/lib/Api/TokenApi.php +++ b/lib/Api/TokenApi.php @@ -218,6 +218,10 @@ public function getCardArtAssetWithHttpInfo($instrumentIdentifierId, $tokenProvi } self::$logger->debug("Return Type : \CyberSource\Model\InlineResponse200"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getCardArtAsset,getCardArtAssetWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -227,7 +231,8 @@ public function getCardArtAssetWithHttpInfo($instrumentIdentifierId, $tokenProvi $httpBody, $headerParams, '\CyberSource\Model\InlineResponse200', - '/tms/v2/tokens/{instrumentIdentifierId}/{tokenProvider}/assets/{assetType}' + '/tms/v2/tokens/{instrumentIdentifierId}/{tokenProvider}/assets/{assetType}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -358,6 +363,10 @@ public function postTokenPaymentCredentialsWithHttpInfo($tokenId, $postPaymentCr } self::$logger->debug("Return Type : string"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "postTokenPaymentCredentials,postTokenPaymentCredentialsWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -367,7 +376,8 @@ public function postTokenPaymentCredentialsWithHttpInfo($tokenId, $postPaymentCr $httpBody, $headerParams, 'string', - '/tms/v2/tokens/{tokenId}/payment-credentials' + '/tms/v2/tokens/{tokenId}/payment-credentials', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/TokenizedCardApi.php b/lib/Api/TokenizedCardApi.php index 367a5af9..d715e6a4 100644 --- a/lib/Api/TokenizedCardApi.php +++ b/lib/Api/TokenizedCardApi.php @@ -194,6 +194,10 @@ public function deleteTokenizedCardWithHttpInfo($tokenizedCardId, $profileId = n } self::$logger->debug("Return Type : null"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "deleteTokenizedCard,deleteTokenizedCardWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -203,7 +207,8 @@ public function deleteTokenizedCardWithHttpInfo($tokenizedCardId, $profileId = n $httpBody, $headerParams, null, - '/tms/v2/tokenized-cards/{tokenizedCardId}' + '/tms/v2/tokenized-cards/{tokenizedCardId}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -340,6 +345,10 @@ public function getTokenizedCardWithHttpInfo($tokenizedCardId, $profileId = null } self::$logger->debug("Return Type : \CyberSource\Model\TokenizedcardRequest"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getTokenizedCard,getTokenizedCardWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -349,7 +358,8 @@ public function getTokenizedCardWithHttpInfo($tokenizedCardId, $profileId = null $httpBody, $headerParams, '\CyberSource\Model\TokenizedcardRequest', - '/tms/v2/tokenized-cards/{tokenizedCardId}' + '/tms/v2/tokenized-cards/{tokenizedCardId}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -485,6 +495,10 @@ public function postTokenizedCardWithHttpInfo($tokenizedcardRequest, $profileId } self::$logger->debug("Return Type : \CyberSource\Model\TokenizedcardRequest"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "postTokenizedCard,postTokenizedCardWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -494,7 +508,8 @@ public function postTokenizedCardWithHttpInfo($tokenizedcardRequest, $profileId $httpBody, $headerParams, '\CyberSource\Model\TokenizedcardRequest', - '/tms/v2/tokenized-cards' + '/tms/v2/tokenized-cards', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/TransactionBatchesApi.php b/lib/Api/TransactionBatchesApi.php index 511ae83a..ece98b89 100644 --- a/lib/Api/TransactionBatchesApi.php +++ b/lib/Api/TransactionBatchesApi.php @@ -202,6 +202,10 @@ public function getTransactionBatchDetailsWithHttpInfo($id, $uploadDate = null, } self::$logger->debug("Return Type : null"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getTransactionBatchDetails,getTransactionBatchDetailsWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -211,7 +215,8 @@ public function getTransactionBatchDetailsWithHttpInfo($id, $uploadDate = null, $httpBody, $headerParams, null, - '/pts/v1/transaction-batch-details/{id}' + '/pts/v1/transaction-batch-details/{id}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -338,6 +343,10 @@ public function getTransactionBatchIdWithHttpInfo($id) } self::$logger->debug("Return Type : \CyberSource\Model\PtsV1TransactionBatchesIdGet200Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getTransactionBatchId,getTransactionBatchIdWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -347,7 +356,8 @@ public function getTransactionBatchIdWithHttpInfo($id) $httpBody, $headerParams, '\CyberSource\Model\PtsV1TransactionBatchesIdGet200Response', - '/pts/v1/transaction-batches/{id}' + '/pts/v1/transaction-batches/{id}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -487,6 +497,10 @@ public function getTransactionBatchesWithHttpInfo($startTime, $endTime) } self::$logger->debug("Return Type : \CyberSource\Model\PtsV1TransactionBatchesGet200Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getTransactionBatches,getTransactionBatchesWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -496,7 +510,8 @@ public function getTransactionBatchesWithHttpInfo($startTime, $endTime) $httpBody, $headerParams, '\CyberSource\Model\PtsV1TransactionBatchesGet200Response', - '/pts/v1/transaction-batches' + '/pts/v1/transaction-batches', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -624,6 +639,10 @@ public function uploadTransactionBatchWithHttpInfo($file) } self::$logger->debug("Return Type : null"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "uploadTransactionBatch,uploadTransactionBatchWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -633,7 +652,8 @@ public function uploadTransactionBatchWithHttpInfo($file) $httpBody, $headerParams, null, - '/pts/v1/transaction-batch-upload' + '/pts/v1/transaction-batch-upload', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/TransactionDetailsApi.php b/lib/Api/TransactionDetailsApi.php index 79a5a4da..df6b8526 100644 --- a/lib/Api/TransactionDetailsApi.php +++ b/lib/Api/TransactionDetailsApi.php @@ -188,6 +188,10 @@ public function getTransactionWithHttpInfo($id) } self::$logger->debug("Return Type : \CyberSource\Model\TssV2TransactionsGet200Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getTransaction,getTransactionWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -197,7 +201,8 @@ public function getTransactionWithHttpInfo($id) $httpBody, $headerParams, '\CyberSource\Model\TssV2TransactionsGet200Response', - '/tss/v2/transactions/{id}' + '/tss/v2/transactions/{id}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/TransientTokenDataApi.php b/lib/Api/TransientTokenDataApi.php index 08439209..b531827c 100644 --- a/lib/Api/TransientTokenDataApi.php +++ b/lib/Api/TransientTokenDataApi.php @@ -188,6 +188,10 @@ public function getPaymentCredentialsForTransientTokenWithHttpInfo($paymentCrede } self::$logger->debug("Return Type : string"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getPaymentCredentialsForTransientToken,getPaymentCredentialsForTransientTokenWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -197,7 +201,8 @@ public function getPaymentCredentialsForTransientTokenWithHttpInfo($paymentCrede $httpBody, $headerParams, 'string', - '/flex/v2/payment-credentials/{paymentCredentialsReference}' + '/flex/v2/payment-credentials/{paymentCredentialsReference}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -308,6 +313,10 @@ public function getTransactionForTransientTokenWithHttpInfo($transientToken) } self::$logger->debug("Return Type : null"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getTransactionForTransientToken,getTransactionForTransientTokenWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -317,7 +326,8 @@ public function getTransactionForTransientTokenWithHttpInfo($transientToken) $httpBody, $headerParams, null, - '/up/v1/payment-details/{transientToken}' + '/up/v1/payment-details/{transientToken}', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/UnifiedCheckoutCaptureContextApi.php b/lib/Api/UnifiedCheckoutCaptureContextApi.php index 8c8eb7f8..709fe31a 100644 --- a/lib/Api/UnifiedCheckoutCaptureContextApi.php +++ b/lib/Api/UnifiedCheckoutCaptureContextApi.php @@ -187,6 +187,10 @@ public function generateUnifiedCheckoutCaptureContextWithHttpInfo($generateUnifi } self::$logger->debug("Return Type : string"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "generateUnifiedCheckoutCaptureContext,generateUnifiedCheckoutCaptureContextWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -196,7 +200,8 @@ public function generateUnifiedCheckoutCaptureContextWithHttpInfo($generateUnifi $httpBody, $headerParams, 'string', - '/up/v1/capture-contexts' + '/up/v1/capture-contexts', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/UserManagementApi.php b/lib/Api/UserManagementApi.php index cd5f3752..ff5e9e94 100644 --- a/lib/Api/UserManagementApi.php +++ b/lib/Api/UserManagementApi.php @@ -201,6 +201,10 @@ public function getUsersWithHttpInfo($organizationId = null, $userName = null, $ } self::$logger->debug("Return Type : \CyberSource\Model\UmsV1UsersGet200Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "getUsers,getUsersWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -210,7 +214,8 @@ public function getUsersWithHttpInfo($organizationId = null, $userName = null, $ $httpBody, $headerParams, '\CyberSource\Model\UmsV1UsersGet200Response', - '/ums/v1/users' + '/ums/v1/users', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/UserManagementSearchApi.php b/lib/Api/UserManagementSearchApi.php index 1b6be2cc..212c7342 100644 --- a/lib/Api/UserManagementSearchApi.php +++ b/lib/Api/UserManagementSearchApi.php @@ -187,6 +187,10 @@ public function searchUsersWithHttpInfo($searchRequest) } self::$logger->debug("Return Type : \CyberSource\Model\UmsV1UsersGet200Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "searchUsers,searchUsersWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -196,7 +200,8 @@ public function searchUsersWithHttpInfo($searchRequest) $httpBody, $headerParams, '\CyberSource\Model\UmsV1UsersGet200Response', - '/ums/v1/users/search' + '/ums/v1/users/search', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/VerificationApi.php b/lib/Api/VerificationApi.php index c777b28b..ea3ad51b 100644 --- a/lib/Api/VerificationApi.php +++ b/lib/Api/VerificationApi.php @@ -187,6 +187,10 @@ public function validateExportComplianceWithHttpInfo($validateExportComplianceRe } self::$logger->debug("Return Type : \CyberSource\Model\RiskV1ExportComplianceInquiriesPost201Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "validateExportCompliance,validateExportComplianceWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -196,7 +200,8 @@ public function validateExportComplianceWithHttpInfo($validateExportComplianceRe $httpBody, $headerParams, '\CyberSource\Model\RiskV1ExportComplianceInquiriesPost201Response', - '/risk/v1/export-compliance-inquiries' + '/risk/v1/export-compliance-inquiries', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -314,6 +319,10 @@ public function verifyCustomerAddressWithHttpInfo($verifyCustomerAddressRequest) } self::$logger->debug("Return Type : \CyberSource\Model\RiskV1AddressVerificationsPost201Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "verifyCustomerAddress,verifyCustomerAddressWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -323,7 +332,8 @@ public function verifyCustomerAddressWithHttpInfo($verifyCustomerAddressRequest) $httpBody, $headerParams, '\CyberSource\Model\RiskV1AddressVerificationsPost201Response', - '/risk/v1/address-verifications' + '/risk/v1/address-verifications', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/Api/VoidApi.php b/lib/Api/VoidApi.php index 6062508d..0cd303c3 100644 --- a/lib/Api/VoidApi.php +++ b/lib/Api/VoidApi.php @@ -187,6 +187,10 @@ public function mitVoidWithHttpInfo($mitVoidRequest) } self::$logger->debug("Return Type : \CyberSource\Model\PtsV2PaymentsVoidsPost201Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "mitVoid,mitVoidWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -196,7 +200,8 @@ public function mitVoidWithHttpInfo($mitVoidRequest) $httpBody, $headerParams, '\CyberSource\Model\PtsV2PaymentsVoidsPost201Response', - '/pts/v2/voids' + '/pts/v2/voids', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -329,6 +334,10 @@ public function voidCaptureWithHttpInfo($voidCaptureRequest, $id) } self::$logger->debug("Return Type : \CyberSource\Model\PtsV2PaymentsVoidsPost201Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "voidCapture,voidCaptureWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -338,7 +347,8 @@ public function voidCaptureWithHttpInfo($voidCaptureRequest, $id) $httpBody, $headerParams, '\CyberSource\Model\PtsV2PaymentsVoidsPost201Response', - '/pts/v2/captures/{id}/voids' + '/pts/v2/captures/{id}/voids', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -471,6 +481,10 @@ public function voidCreditWithHttpInfo($voidCreditRequest, $id) } self::$logger->debug("Return Type : \CyberSource\Model\PtsV2PaymentsVoidsPost201Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "voidCredit,voidCreditWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -480,7 +494,8 @@ public function voidCreditWithHttpInfo($voidCreditRequest, $id) $httpBody, $headerParams, '\CyberSource\Model\PtsV2PaymentsVoidsPost201Response', - '/pts/v2/credits/{id}/voids' + '/pts/v2/credits/{id}/voids', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -613,6 +628,10 @@ public function voidPaymentWithHttpInfo($voidPaymentRequest, $id) } self::$logger->debug("Return Type : \CyberSource\Model\PtsV2PaymentsVoidsPost201Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "voidPayment,voidPaymentWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -622,7 +641,8 @@ public function voidPaymentWithHttpInfo($voidPaymentRequest, $id) $httpBody, $headerParams, '\CyberSource\Model\PtsV2PaymentsVoidsPost201Response', - '/pts/v2/payments/{id}/voids' + '/pts/v2/payments/{id}/voids', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); @@ -755,6 +775,10 @@ public function voidRefundWithHttpInfo($voidRefundRequest, $id) } self::$logger->debug("Return Type : \CyberSource\Model\PtsV2PaymentsVoidsPost201Response"); + + // Response MLE check + $isResponseMLEForAPI = MLEUtility::checkIsResponseMLEForAPI($this->apiClient->merchantConfig, "voidRefund,voidRefundWithHttpInfo"); + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -764,7 +788,8 @@ public function voidRefundWithHttpInfo($voidRefundRequest, $id) $httpBody, $headerParams, '\CyberSource\Model\PtsV2PaymentsVoidsPost201Response', - '/pts/v2/refunds/{id}/voids' + '/pts/v2/refunds/{id}/voids', + $isResponseMLEForAPI ); self::$logger->debug("Response Headers :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($httpHeader)); diff --git a/lib/ApiClient.php b/lib/ApiClient.php index f4faa794..ae1bba28 100755 --- a/lib/ApiClient.php +++ b/lib/ApiClient.php @@ -578,7 +578,7 @@ public function callApi($resourcePath, $method, $queryParams, $postData, $header $exception->setResponseObject($response_info); self::$logger->close(); throw $exception; - } elseif ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299) { // Check if response needs MLE decryption for file downloads + } elseif ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299) { if (MLEUtility::checkIsMleEncryptedResponse($http_body)) { try { $http_body = MLEUtility::decryptMleResponsePayload($this->merchantConfig, $http_body); diff --git a/lib/Authentication/Util/JWE/JWEUtility.php b/lib/Authentication/Util/JWE/JWEUtility.php index 8981e201..216e5fc0 100644 --- a/lib/Authentication/Util/JWE/JWEUtility.php +++ b/lib/Authentication/Util/JWE/JWEUtility.php @@ -84,7 +84,6 @@ public static function decryptJWEUsingPEM(MerchantConfiguration $merchantConfig, public static function decryptJWEUsingPrivateKey(string $privateKey, string $encodedResponse) { $jwk = JWKFactory::createFromKey($privateKey); - echo "jwk: " . json_encode($jwk->all()); // The key encryption algorithm manager with the A256KW algorithm. $keyEncryptionAlgorithmManager = new AlgorithmManager([ new RSAOAEP256() @@ -108,10 +107,8 @@ public static function decryptJWEUsingPrivateKey(string $privateKey, string $enc $jwe = $serializerManager->unserialize($encodedResponse); if($jweDecrypter -> decryptUsingKey($jwe, $jwk, 0)) { - echo "here 101 .\n"; return $jwe ->getPayload(); } else { - echo "here 100 .\n"; return null; } } diff --git a/lib/Authentication/Util/MLEUtility.php b/lib/Authentication/Util/MLEUtility.php index 54c21ad3..8373830c 100644 --- a/lib/Authentication/Util/MLEUtility.php +++ b/lib/Authentication/Util/MLEUtility.php @@ -125,7 +125,6 @@ public static function encryptRequestPayload($merchantConfig, $requestBody) public static function checkIsMleEncryptedResponse($responseBody) { - echo " m here 2.\n"; if ($responseBody === null) { return false; } $trim = trim($responseBody); if ($trim === '' || $trim[0] !== '{') { return false; } @@ -142,7 +141,6 @@ public static function checkIsMleEncryptedResponse($responseBody) if (self::$logger === null) { self::$logger = (new LogFactory())->getLogger(\CyberSource\Utilities\Helpers\ClassHelper::getClassName(static::class), $merchantConfig->getLogConfiguration()); } - echo "[MLE][Decrypt] Enter decryptMleResponsePayload()\n"; if (!self::checkIsMleEncryptedResponse($mleResponseBody)) { throw new MLEException("Response body is not MLE encrypted."); @@ -150,15 +148,12 @@ public static function checkIsMleEncryptedResponse($responseBody) $jweToken = self::getResponseMleToken($mleResponseBody); if (empty($jweToken)) { // when mle token is empty or null then fall back to non mle encrypted response - echo "[MLE][Decrypt] JWE token missing in encryptedResponse wrapper.\n"; return $mleResponseBody; } $privateKey = self::getMleResponsePrivateKey($merchantConfig); if (empty($privateKey)) { - echo "[MLE][Decrypt] Private key unavailable for decryption.\n"; throw new MLEException("Response MLE private key not available for decryption."); } - echo "[MLE][Decrypt] Loaded private key (" . strlen($privateKey) . " bytes).\n"; // Cache already handles password decryption and returns unencrypted PEM if ($merchantConfig->getLogConfiguration()->isMaskingEnabled()) { $maskedResponseBody = \CyberSource\Utilities\Helpers\DataMasker::maskData($mleResponseBody); @@ -177,7 +172,6 @@ public static function checkIsMleEncryptedResponse($responseBody) } else { self::$logger->debug("LOG_NETWORK_RESPONSE_AFTER_MLE_DECRYPTION: " . $decrypted); } - echo "[MLE][Decrypt] Decryption successful. Decrypted payload length: " . strlen($decrypted) . "\n"; return $decrypted; } catch (\Exception $e) { throw new MLEException("MLE Response decryption error: " . $e->getMessage()); @@ -251,8 +245,7 @@ private static function getMleResponsePrivateKey($merchantConfig) // return $merchantConfig->getResponseMlePrivateKey(); // } - if (!isset(self::$cache)) { //check static n multithreading - echo "[MLE] Creating Cache instance for response private key.\n"; + if (!isset(self::$cache)) { //check static self::$cache = new Cache(); } @@ -260,14 +253,7 @@ private static function getMleResponsePrivateKey($merchantConfig) // echo "[MLE] Cleared all file cache.\n"; $key = self::$cache->getMleResponsePrivateKeyFromFilePath($merchantConfig); - if ($key) { - echo "[MLE] Loaded response private key from file/cache.\n"; - } else { - echo "[MLE] Failed to load response private key from file/cache.\n"; - } - - return $key; - // return self::$cache->getMleResponsePrivateKeyFromFilePath($merchantConfig); + return self::$cache->getMleResponsePrivateKeyFromFilePath($merchantConfig); } public static function getMLECert($merchantConfig) From 084cb944c8e0440064a7e67aba47728102ca9ab3 Mon Sep 17 00:00:00 2001 From: mahmishr Date: Thu, 16 Oct 2025 11:55:28 +0530 Subject: [PATCH 07/20] refactoring --- lib/Authentication/Util/Cache.php | 8 +- lib/Authentication/Util/MLEUtility.php | 1 - lib/Authentication/Util/Utility.php | 140 +++++++++++++------------ 3 files changed, 79 insertions(+), 70 deletions(-) diff --git a/lib/Authentication/Util/Cache.php b/lib/Authentication/Util/Cache.php index 5127022c..3a64373c 100644 --- a/lib/Authentication/Util/Cache.php +++ b/lib/Authentication/Util/Cache.php @@ -184,17 +184,21 @@ private function setupMLECache($merchantConfig, $cacheKey, $mleCertPath) { try { $loaded = Utility::loadResponseMlePrivateKey($mleCertPath, $password); self::$file_cache[$cacheKey] = [ - 'response_mle_private_key' => $loaded['pem'], + 'response_mle_private_key' => $loaded, 'file_mod_time' => $fileModTime ]; self::$responseMleKeyLoadFailed = false; // reset on success - } catch (MLEException $e) { + } catch (\Exception $e) { if (!self::$responseMleKeyLoadFailed) { self::$responseMleKeyLoadFailed = true; if (self::$logger) { self::$logger->error("Response MLE private key load failed: ".$e->getMessage()); } } else { if (self::$logger) { self::$logger->debug("Response MLE private key load failed again; suppressing repeated error log."); } } + self::$file_cache[$cacheKey] = [ + 'response_mle_private_key' => null, + 'file_mod_time' => $fileModTime + ]; } return; } diff --git a/lib/Authentication/Util/MLEUtility.php b/lib/Authentication/Util/MLEUtility.php index 8373830c..d418d66d 100644 --- a/lib/Authentication/Util/MLEUtility.php +++ b/lib/Authentication/Util/MLEUtility.php @@ -251,7 +251,6 @@ private static function getMleResponsePrivateKey($merchantConfig) } // self::$cache::clearAllFileCache(); // echo "[MLE] Cleared all file cache.\n"; - $key = self::$cache->getMleResponsePrivateKeyFromFilePath($merchantConfig); return self::$cache->getMleResponsePrivateKeyFromFilePath($merchantConfig); } diff --git a/lib/Authentication/Util/Utility.php b/lib/Authentication/Util/Utility.php index aec2724f..a059eaae 100644 --- a/lib/Authentication/Util/Utility.php +++ b/lib/Authentication/Util/Utility.php @@ -57,13 +57,13 @@ public static function extractAllCertificates($certContent) * * @param string $filePath Path to the private key file * @param string|null $password Password for encrypted keys - * @return array ['pem' => unencrypted PEM string, 'resource' => OpenSSL key resource] - * @throws MLEException If key cannot be loaded or decrypted + * @return string unencrypted PEM string + * @throws \Exception If key cannot be loaded or decrypted */ - public static function loadResponseMlePrivateKey(string $filePath, ?string $password): array + public static function loadResponseMlePrivateKey(string $filePath, ?string $password): string { if (!extension_loaded('openssl')) { - throw new MLEException("OpenSSL extension not loaded; cannot read private key."); + throw new \Exception("OpenSSL extension not loaded; cannot read private key."); } $ext = strtolower(pathinfo($filePath, PATHINFO_EXTENSION)); @@ -72,74 +72,60 @@ public static function loadResponseMlePrivateKey(string $filePath, ?string $pass if (in_array($ext, ['p12','pfx'], true)) { $pkcs12 = file_get_contents($filePath); if ($pkcs12 === false) { - throw new MLEException("Unable to read PKCS#12 file: {$filePath}"); + throw new \Exception("Unable to read PKCS#12 file: {$filePath}"); } $certs = []; if (!openssl_pkcs12_read($pkcs12, $certs, (string)$password)) { $err = openssl_error_string(); - throw new MLEException("Unable to parse PKCS#12: {$filePath}. OpenSSL: {$err}"); + throw new \Exception("Unable to parse PKCS#12: {$filePath}. OpenSSL: {$err}"); } if (empty($certs['pkey'])) { - throw new MLEException("No private key found in PKCS#12: {$filePath}"); + throw new \Exception("No private key found in PKCS#12: {$filePath}"); } $exported = ''; + + // Clear OpenSSL error queue + while (openssl_error_string() !== false); + + // Try export without config first $exportOk = @openssl_pkey_export($certs['pkey'], $exported, null); + + // If that fails, try with Windows config + if (!$exportOk || trim($exported) === '') { + $configArgs = ['config' => 'NUL']; + $exportOk = @openssl_pkey_export($certs['pkey'], $exported, null, $configArgs); + } + + if (!$exportOk || trim($exported) === '') { + $err = ''; + while ($msg = openssl_error_string()) { + $err .= ($err ? ' | ' : '') . $msg; + } + throw new \Exception("Failed exporting private key from PKCS#12. OpenSSL: " . ($err ?: 'Unknown error')); + } + if (!$exportOk || trim($exported) === '') { // Broader fallback: accept any BEGIN .. PRIVATE KEY block if (is_string($certs['pkey']) && preg_match('/BEGIN\\s.+PRIVATE KEY/', $certs['pkey'])) { $exported = $certs['pkey']; - } else { - // Try again via handle - $handle = @openssl_pkey_get_private($certs['pkey'], (string)$password); - if ($handle && @openssl_pkey_export($handle, $exported, null) && trim($exported) !== '') { - // success - } else { - $err = openssl_error_string(); - throw new MLEException("Failed exporting private key from PKCS#12 (OpenSSL 3 legacy issue). OpenSSL: {$err}"); - } } } - - $resource = @openssl_pkey_get_private($exported, (string)$password) ?: @openssl_pkey_get_private($exported); - if ($resource === false) { - throw new MLEException("Re-validation of PKCS#12 private key failed after fallback."); - } - return ['pem' => $exported, 'resource' => $resource]; + return $exported; } // Handle PEM-based formats (.pem, .key, .p8) if (in_array($ext, ['pem','key','p8'], true)) { try { $unencryptedPem = self::decryptPrivateKeyPem($filePath, $password); - $resource = @openssl_pkey_get_private($unencryptedPem); - if ($resource === false) { - throw new MLEException("Failed to create resource from decrypted PEM"); - } - return ['pem' => $unencryptedPem, 'resource' => $resource]; + return $unencryptedPem; } catch (\Exception $e) { - // If decryption fails, try the original approach for unencrypted keys - $raw = file_get_contents($filePath); - if ($raw === false || trim($raw) === '') { - throw new MLEException("Unable to read key file: {$filePath}"); - } + throw new \Exception("Failed to load PEM/KEY/P8 private key: " . $e->getMessage()); - $priv = @openssl_pkey_get_private($raw); - if ($priv === false) { - throw new MLEException("Unable to load private key: {$filePath}. " . $e->getMessage()); - } - - // Normalize unencrypted keys - $norm = ''; - if (@openssl_pkey_export($priv, $norm, null) && trim($norm) !== '') { - $raw = $norm; - } - - return ['pem' => $raw, 'resource' => $priv]; } } - throw new MLEException("Unsupported Response MLE Private Key file format: {$ext}. Supported: .p12, .pfx, .pem, .key, .p8"); + throw new \Exception("Unsupported Response MLE Private Key file format: {$ext}. Supported: .p12, .pfx, .pem, .key, .p8"); } /** @@ -148,20 +134,20 @@ public static function loadResponseMlePrivateKey(string $filePath, ?string $pass * @param string $pemPath Path to the PEM file * @param string|null $passphrase Password for encrypted keys * @return string Unencrypted PEM string - * @throws MLEException If decryption fails + * @throws \Exception If decryption fails */ public static function decryptPrivateKeyPem(string $pemPath, ?string $passphrase): string { if (!extension_loaded('openssl')) { - throw new MLEException('The OpenSSL extension is required.'); + throw new \Exception('The OpenSSL extension is required.'); } if (!is_file($pemPath) || !is_readable($pemPath)) { - throw new MLEException("PEM file not found or not readable: {$pemPath}"); + throw new \Exception("PEM file not found or not readable: {$pemPath}"); } $pem = file_get_contents($pemPath); if ($pem === false || $pem === '') { - throw new MLEException('Failed to read PEM file contents.'); + throw new \Exception('Failed to read PEM file contents.'); } // Only attempt decryption if password provided and key appears encrypted @@ -169,35 +155,64 @@ public static function decryptPrivateKeyPem(string $pemPath, ?string $passphrase strpos($pem, 'Proc-Type: 4,ENCRYPTED') !== false; if (!$isEncrypted) { - // Return as-is for unencrypted keys - return $pem; + $priv = @openssl_pkey_get_private(private_key: $pem); + if ($priv === false) { + $err = ''; + while ($msg = openssl_error_string()) { + $err .= ($err ? ' | ' : '') . $msg; + } + throw new \Exception("Unable to load unencrypted private key from {$pemPath}. OpenSSL errors: " . ($err ?: 'No specific error')); + } + + // ALWAYS normalize to standard PKCS#8 PEM format for JWE compatibility + $normalized = ''; + // Clear error queue before export + while (openssl_error_string() !== false) + ; + + // Try export without config first + $success = @openssl_pkey_export($priv, $normalized, null); + + // If that fails, try with Windows config + if (!$success) { + $configArgs = ['config' => 'NUL']; + $success = @openssl_pkey_export($priv, $normalized, null, $configArgs); + } + + if (!$success) { + $err = ''; + while ($msg = openssl_error_string()) { + $err .= ($err ? ' | ' : '') . $msg; + } + throw new \Exception("Failed to normalize unencrypted key. OpenSSL errors: " . ($err ?: 'Unknown error')); + } + + return $normalized; } if ($passphrase === null || $passphrase === '') { - throw new MLEException('Private key is encrypted but no passphrase provided'); + throw new \Exception('Private key is encrypted but no passphrase provided'); } // Obtain an OpenSSL private key handle using the passphrase $key = openssl_pkey_get_private($pem, $passphrase); if ($key === false) { - // Collect the last OpenSSL error to help with debugging $err = ''; while ($msg = openssl_error_string()) { $err .= ($err ? ' | ' : '') . $msg; } - throw new MLEException('Unable to decrypt private key. ' . ($err ?: 'Check passphrase and key format.')); + throw new \Exception('Unable to decrypt private key. ' . ($err ?: 'Check passphrase and key format.')); } // Export the key without a passphrase (i.e., decrypted) $unencryptedPem = ''; - // Universal config - works for RSA, EC, DSA keys - // May specify what's needed for Windows compatibility + // Windows compatibility $configArgs = [ 'config' => 'NUL', // Pass config file search on Windows ]; - // First attempt with minimal config (Windows-friendly) + //(Windows-friendly) $success = @openssl_pkey_export($key, $unencryptedPem, null, $configArgs); // If that fails, try without any config args (best for Mac/Linux) @@ -211,17 +226,8 @@ public static function decryptPrivateKeyPem(string $pemPath, ?string $passphrase while ($msg = openssl_error_string()) { $err .= ($err ? ' | ' : '') . $msg; } - throw new MLEException('Failed to export unencrypted private key. ' . ($err ?: 'Unknown error')); } - - // Free the key handle explicitly for PHP 7 compatibility - // Note: Static analyzers may flag this for PHP 8+ where signature changed - // The is_resource() guard ensures this only runs on PHP 7 - if (is_resource($key)) { - @openssl_free_key($key); + throw new \Exception('Failed to export unencrypted private key. ' . ($err ?: 'Unknown error')); } - // PHP 8+ uses OpenSSLAsymmetricKey object and handles cleanup automatically - return $unencryptedPem; } } -?> \ No newline at end of file From 369dc29f78fb5205a8576f50029f76a1927bad11 Mon Sep 17 00:00:00 2001 From: mahmishr Date: Thu, 16 Oct 2025 12:45:36 +0530 Subject: [PATCH 08/20] refactoring --- lib/Authentication/Util/Utility.php | 305 +++++++++++++++++----------- 1 file changed, 185 insertions(+), 120 deletions(-) diff --git a/lib/Authentication/Util/Utility.php b/lib/Authentication/Util/Utility.php index a059eaae..3cf065e8 100644 --- a/lib/Authentication/Util/Utility.php +++ b/lib/Authentication/Util/Utility.php @@ -57,177 +57,242 @@ public static function extractAllCertificates($certContent) * * @param string $filePath Path to the private key file * @param string|null $password Password for encrypted keys - * @return string unencrypted PEM string + * @return string Unencrypted PEM string * @throws \Exception If key cannot be loaded or decrypted */ public static function loadResponseMlePrivateKey(string $filePath, ?string $password): string { - if (!extension_loaded('openssl')) { - throw new \Exception("OpenSSL extension not loaded; cannot read private key."); - } + self::validateOpenSslExtension(); $ext = strtolower(pathinfo($filePath, PATHINFO_EXTENSION)); - // Handle PKCS#12 formats (.p12, .pfx) - if (in_array($ext, ['p12','pfx'], true)) { - $pkcs12 = file_get_contents($filePath); - if ($pkcs12 === false) { - throw new \Exception("Unable to read PKCS#12 file: {$filePath}"); - } - $certs = []; - if (!openssl_pkcs12_read($pkcs12, $certs, (string)$password)) { - $err = openssl_error_string(); - throw new \Exception("Unable to parse PKCS#12: {$filePath}. OpenSSL: {$err}"); - } - if (empty($certs['pkey'])) { - throw new \Exception("No private key found in PKCS#12: {$filePath}"); - } + if (in_array($ext, ['p12', 'pfx'], true)) { + return self::loadPrivateKeyFromPkcs12($filePath, $password); + } - $exported = ''; - - // Clear OpenSSL error queue - while (openssl_error_string() !== false); - - // Try export without config first - $exportOk = @openssl_pkey_export($certs['pkey'], $exported, null); - - // If that fails, try with Windows config - if (!$exportOk || trim($exported) === '') { - $configArgs = ['config' => 'NUL']; - $exportOk = @openssl_pkey_export($certs['pkey'], $exported, null, $configArgs); - } + if (in_array($ext, ['pem', 'key', 'p8'], true)) { + return self::loadPrivateKeyFromPem($filePath, $password); + } - if (!$exportOk || trim($exported) === '') { - $err = ''; - while ($msg = openssl_error_string()) { - $err .= ($err ? ' | ' : '') . $msg; - } - throw new \Exception("Failed exporting private key from PKCS#12. OpenSSL: " . ($err ?: 'Unknown error')); - } + throw new \Exception("Unsupported Response MLE Private Key file format: {$ext}. Supported: .p12, .pfx, .pem, .key, .p8"); + } - if (!$exportOk || trim($exported) === '') { - // Broader fallback: accept any BEGIN .. PRIVATE KEY block - if (is_string($certs['pkey']) && preg_match('/BEGIN\\s.+PRIVATE KEY/', $certs['pkey'])) { - $exported = $certs['pkey']; - } - } - return $exported; + /** + * Load private key from PKCS#12 file + * + * @param string $filePath Path to the PKCS#12 file + * @param string|null $password Password for the PKCS#12 file + * @return string Unencrypted PEM string + * @throws \Exception If key cannot be loaded + */ + public static function loadPrivateKeyFromPkcs12(string $filePath, ?string $password): string + { + $pkcs12 = file_get_contents($filePath); + if ($pkcs12 === false) { + throw new \Exception("Unable to read PKCS#12 file: {$filePath}"); } - // Handle PEM-based formats (.pem, .key, .p8) - if (in_array($ext, ['pem','key','p8'], true)) { - try { - $unencryptedPem = self::decryptPrivateKeyPem($filePath, $password); - return $unencryptedPem; - } catch (\Exception $e) { - throw new \Exception("Failed to load PEM/KEY/P8 private key: " . $e->getMessage()); + $certs = []; + if (!openssl_pkcs12_read($pkcs12, $certs, (string)$password)) { + $err = openssl_error_string(); + throw new \Exception("Unable to parse PKCS#12: {$filePath}. OpenSSL: {$err}"); + } - } + if (empty($certs['pkey'])) { + throw new \Exception("No private key found in PKCS#12: {$filePath}"); } - throw new \Exception("Unsupported Response MLE Private Key file format: {$ext}. Supported: .p12, .pfx, .pem, .key, .p8"); + return self::exportPrivateKey($certs['pkey'], (string)$password); } /** - * Decrypt encrypted PEM/P8 private key files with cross-platform compatibility + * Load private key from PEM file * - * @param string $pemPath Path to the PEM file - * @param string|null $passphrase Password for encrypted keys + * @param string $filePath Path to the PEM file + * @param string|null $password Password for encrypted PEM * @return string Unencrypted PEM string - * @throws \Exception If decryption fails + * @throws \Exception If key cannot be loaded */ - public static function decryptPrivateKeyPem(string $pemPath, ?string $passphrase): string + public static function loadPrivateKeyFromPem(string $filePath, ?string $password): string { - if (!extension_loaded('openssl')) { - throw new \Exception('The OpenSSL extension is required.'); - } - if (!is_file($pemPath) || !is_readable($pemPath)) { - throw new \Exception("PEM file not found or not readable: {$pemPath}"); + if (!is_file($filePath) || !is_readable($filePath)) { + throw new \Exception("PEM file not found or not readable: {$filePath}"); } - $pem = file_get_contents($pemPath); + $pem = file_get_contents($filePath); if ($pem === false || $pem === '') { throw new \Exception('Failed to read PEM file contents.'); } - // Only attempt decryption if password provided and key appears encrypted - $isEncrypted = strpos($pem, 'BEGIN ENCRYPTED PRIVATE KEY') !== false || - strpos($pem, 'Proc-Type: 4,ENCRYPTED') !== false; + $isEncrypted = self::isPemEncrypted($pem); + + if ($isEncrypted) { + return self::decryptEncryptedPem($pem, $filePath, $password); + } + + return self::normalizeUnencryptedPem($pem, $filePath); + } + + /** + * Export private key to PEM format with cross-platform compatibility + * + * @param mixed $key OpenSSL key resource or PEM string + * @param string $password Password for the key + * @return string Exported PEM string + * @throws \Exception If export fails + */ + private static function exportPrivateKey($key, string $password): string + { + $exported = ''; - if (!$isEncrypted) { - $priv = @openssl_pkey_get_private(private_key: $pem); - if ($priv === false) { - $err = ''; - while ($msg = openssl_error_string()) { - $err .= ($err ? ' | ' : '') . $msg; - } - throw new \Exception("Unable to load unencrypted private key from {$pemPath}. OpenSSL errors: " . ($err ?: 'No specific error')); + self::clearOpenSslErrors(); + + // Try export without config first (cross-platform) + $exportOk = @openssl_pkey_export($key, $exported, null); + + // Fallback: try with Windows config + if (!$exportOk || trim($exported) === '') { + $configArgs = ['config' => 'NUL']; + $exportOk = @openssl_pkey_export($key, $exported, null, $configArgs); + } + + // Fallback: check if key is already a PEM string + if (!$exportOk || trim($exported) === '') { + if (is_string($key) && preg_match('/BEGIN\\s.+PRIVATE KEY/', $key)) { + return $key; } + + $errors = self::collectOpenSslErrors(); + throw new \Exception("Failed exporting private key. OpenSSL: " . ($errors ?: 'Unknown error')); + } + + return $exported; + } + + /** + * Normalize unencrypted PEM to standard format + * + * @param string $pem PEM string + * @param string $pemPath Path to PEM file (for error messages) + * @return string Normalized PEM string + * @throws \Exception If normalization fails + */ + public static function normalizeUnencryptedPem(string $pem, string $pemPath): string + { + self::clearOpenSslErrors(); - // ALWAYS normalize to standard PKCS#8 PEM format for JWE compatibility - $normalized = ''; - // Clear error queue before export - while (openssl_error_string() !== false) - ; + $priv = @openssl_pkey_get_private($pem); + if ($priv === false) { + $errors = self::collectOpenSslErrors(); + throw new \Exception("Unable to load unencrypted private key from {$pemPath}. OpenSSL errors: " . ($errors ?: 'No specific error')); + } - // Try export without config first - $success = @openssl_pkey_export($priv, $normalized, null); + $normalized = ''; + self::clearOpenSslErrors(); - // If that fails, try with Windows config - if (!$success) { - $configArgs = ['config' => 'NUL']; - $success = @openssl_pkey_export($priv, $normalized, null, $configArgs); - } + // Try export without config first + $success = @openssl_pkey_export($priv, $normalized, null); - if (!$success) { - $err = ''; - while ($msg = openssl_error_string()) { - $err .= ($err ? ' | ' : '') . $msg; - } - throw new \Exception("Failed to normalize unencrypted key. OpenSSL errors: " . ($err ?: 'Unknown error')); - } + // Fallback: try with Windows config + if (!$success) { + $configArgs = ['config' => 'NUL']; + $success = @openssl_pkey_export($priv, $normalized, null, $configArgs); + } - return $normalized; + if (!$success) { + $errors = self::collectOpenSslErrors(); + throw new \Exception("Failed to normalize unencrypted key. OpenSSL errors: " . ($errors ?: 'Unknown error')); } + return $normalized; + } + + /** + * Decrypt encrypted PEM file + * + * @param string $pem PEM file contents + * @param string $pemPath Path to PEM file (for error messages) + * @param string|null $passphrase Password for encrypted PEM + * @return string Decrypted PEM string + * @throws \Exception If decryption fails + */ + public static function decryptEncryptedPem(string $pem, string $pemPath, ?string $passphrase): string + { if ($passphrase === null || $passphrase === '') { throw new \Exception('Private key is encrypted but no passphrase provided'); } - // Obtain an OpenSSL private key handle using the passphrase $key = openssl_pkey_get_private($pem, $passphrase); if ($key === false) { - $err = ''; - while ($msg = openssl_error_string()) { - $err .= ($err ? ' | ' : '') . $msg; - } - throw new \Exception('Unable to decrypt private key. ' . ($err ?: 'Check passphrase and key format.')); + $errors = self::collectOpenSslErrors(); + throw new \Exception('Unable to decrypt private key. ' . ($errors ?: 'Check passphrase and key format.')); } - - // Export the key without a passphrase (i.e., decrypted) + $unencryptedPem = ''; - // Windows compatibility - $configArgs = [ - 'config' => 'NUL', // Pass config file search on Windows - ]; - - //(Windows-friendly) - $success = @openssl_pkey_export($key, $unencryptedPem, null, $configArgs); + // Try without config first (cross-platform) + $success = @openssl_pkey_export($key, $unencryptedPem, null); - // If that fails, try without any config args (best for Mac/Linux) + // Fallback: try with Windows config if (!$success) { - $success = @openssl_pkey_export($key, $unencryptedPem, null); + $configArgs = ['config' => 'NUL']; + $success = @openssl_pkey_export($key, $unencryptedPem, null, $configArgs); } - + if (!$success) { - // Collect OpenSSL errors for debugging - $err = ''; - while ($msg = openssl_error_string()) { - $err .= ($err ? ' | ' : '') . $msg; - } - throw new \Exception('Failed to export unencrypted private key. ' . ($err ?: 'Unknown error')); + $errors = self::collectOpenSslErrors(); + throw new \Exception('Failed to export unencrypted private key. ' . ($errors ?: 'Unknown error')); } + return $unencryptedPem; } + + /** + * Check if PEM is encrypted + * + * @param string $pem PEM string + * @return bool True if encrypted + */ + private static function isPemEncrypted(string $pem): bool + { + return strpos($pem, 'BEGIN ENCRYPTED PRIVATE KEY') !== false || + strpos($pem, 'Proc-Type: 4,ENCRYPTED') !== false; + } + + /** + * Clear OpenSSL error queue + * + * @return void + */ + private static function clearOpenSslErrors(): void + { + while (openssl_error_string() !== false); + } + + /** + * Collect all OpenSSL errors from the error queue + * + * @return string Concatenated error messages + */ + private static function collectOpenSslErrors(): string + { + $errors = ''; + while ($msg = openssl_error_string()) { + $errors .= ($errors ? ' | ' : '') . $msg; + } + return $errors; + } + + /** + * Validate OpenSSL extension is loaded + * + * @return void + * @throws \Exception If OpenSSL extension is not loaded + */ + private static function validateOpenSslExtension(): void + { + if (!extension_loaded('openssl')) { + throw new \Exception("OpenSSL extension not loaded; cannot read private key."); + } + } } From daf206aea34ae37921a00f50fdadd31454bb45df Mon Sep 17 00:00:00 2001 From: mahmishr Date: Thu, 16 Oct 2025 13:15:07 +0530 Subject: [PATCH 09/20] pvt key obj --- .../Core/MerchantConfiguration.php | 36 ++++++++++--------- lib/Authentication/Util/MLEUtility.php | 16 ++++++--- lib/Authentication/Util/Utility.php | 35 ++++++++++++++++++ 3 files changed, 67 insertions(+), 20 deletions(-) diff --git a/lib/Authentication/Core/MerchantConfiguration.php b/lib/Authentication/Core/MerchantConfiguration.php index 05bae908..de64e3d7 100644 --- a/lib/Authentication/Core/MerchantConfiguration.php +++ b/lib/Authentication/Core/MerchantConfiguration.php @@ -328,13 +328,14 @@ class MerchantConfiguration */ protected $responseMlePrivateKeyFilePath = ''; - // /** - // * Private key (in‑memory) used to decrypt Response MLE payloads. - // * Provide the raw private key string (e.g. PEM / PKCS#8). Mutually exclusive with responseMlePrivateKeyFilePath. - // * - // * @var string - // */ - // protected $responseMlePrivateKey = ''; + /** + * Private key (OpenSSL resource/object) used to decrypt Response MLE payloads. + * Provide the OpenSSLAsymmetricKey object (PHP 8+) or OpenSSL key resource (PHP 7). + * Mutually exclusive with responseMlePrivateKeyFilePath. + * + * @var \OpenSSLAsymmetricKey|resource|null + */ + protected $responseMlePrivateKey = null; /** * Password for the private key file (e.g. .p12 or encrypted .pem) used for Response MLE decryption. @@ -1344,16 +1345,19 @@ public function getResponseMlePrivateKeyFilePath() return $this->responseMlePrivateKeyFilePath; } - // public function setResponseMlePrivateKey($responseMlePrivateKey) - // { - // // Accept only string; trim. If resource/object passed, ignore for now (simplify). - // $this->responseMlePrivateKey = is_string($responseMlePrivateKey) ? trim($responseMlePrivateKey) : ''; - // } + public function setResponseMlePrivateKey($responseMlePrivateKey) + { + if (is_object($responseMlePrivateKey) && get_class($responseMlePrivateKey) === 'OpenSSLAsymmetricKey') { + $this->responseMlePrivateKey = $responseMlePrivateKey; + } else { + throw new \InvalidArgumentException("responseMlePrivateKey must be OpenSSLAsymmetricKey"); + } + } - // public function getResponseMlePrivateKey() - // { - // return $this->responseMlePrivateKey; - // } + public function getResponseMlePrivateKey() + { + return $this->responseMlePrivateKey; + } public function setResponseMlePrivateKeyFilePassword($responseMlePrivateKeyFilePassword) { diff --git a/lib/Authentication/Util/MLEUtility.php b/lib/Authentication/Util/MLEUtility.php index d418d66d..1619fb4f 100644 --- a/lib/Authentication/Util/MLEUtility.php +++ b/lib/Authentication/Util/MLEUtility.php @@ -240,10 +240,18 @@ private static function getResponseMleToken($mleResponseBody) private static function getMleResponsePrivateKey($merchantConfig) { - // if (null != $merchantConfig->getResponseMlePrivateKey()) { - // echo "[MLE] Using inline response private key.\n"; - // return $merchantConfig->getResponseMlePrivateKey(); - // } + if (null != $merchantConfig->getResponseMlePrivateKey()) { + $privateKey = $merchantConfig->getResponseMlePrivateKey(); + if ($privateKey !== null && !is_string($privateKey)) { + try { + $privateKey = Utility::convertKeyObjectToPem($privateKey); + } catch (\Exception $e) { + self::$logger->error("Failed to convert key object to PEM: " . $e->getMessage()); + throw new MLEException("Failed to convert key object to PEM: " . $e->getMessage()); + } + return $privateKey; + } + } if (!isset(self::$cache)) { //check static diff --git a/lib/Authentication/Util/Utility.php b/lib/Authentication/Util/Utility.php index 3cf065e8..43441899 100644 --- a/lib/Authentication/Util/Utility.php +++ b/lib/Authentication/Util/Utility.php @@ -295,4 +295,39 @@ private static function validateOpenSslExtension(): void throw new \Exception("OpenSSL extension not loaded; cannot read private key."); } } + + /** + * Convert OpenSSL key object to PEM string + * + * @param \OpenSSLAsymmetricKey|resource $key OpenSSL key object or resource + * @return string PEM string + * @throws \Exception If conversion fails + */ + public static function convertKeyObjectToPem($key): string + { + if (is_string($key)) { + // Already a PEM string + return $key; + } + + self::clearOpenSslErrors(); + + $pemString = ''; + + // Try export without config first + $success = @openssl_pkey_export($key, $pemString, null); + + // Fallback: try with Windows config + if (!$success || trim($pemString) === '') { + $configArgs = ['config' => 'NUL']; + $success = @openssl_pkey_export($key, $pemString, null, $configArgs); + } + + if (!$success || trim($pemString) === '') { + $errors = self::collectOpenSslErrors(); + throw new \Exception('Failed to convert OpenSSL key object to PEM string. OpenSSL: ' . ($errors ?: 'Unknown error')); + } + + return $pemString; + } } From e97b620879cd9e464958ddb73e42770c295c9f46 Mon Sep 17 00:00:00 2001 From: mahmishr Date: Fri, 17 Oct 2025 11:10:16 +0530 Subject: [PATCH 10/20] variable name changes in mle utility --- .../Core/MerchantConfiguration.php | 279 +++++++++--------- lib/Authentication/Util/Cache.php | 2 + lib/Authentication/Util/MLEUtility.php | 6 +- 3 files changed, 152 insertions(+), 135 deletions(-) diff --git a/lib/Authentication/Core/MerchantConfiguration.php b/lib/Authentication/Core/MerchantConfiguration.php index de64e3d7..ccd8bffc 100644 --- a/lib/Authentication/Core/MerchantConfiguration.php +++ b/lib/Authentication/Core/MerchantConfiguration.php @@ -1119,6 +1119,7 @@ public function getMapToControlMLEonAPI() * * @param array|object $mapToControlMLEonAPI * @return void + * @throws AuthException if validation fails */ public function setMapToControlMLEonAPI($mapToControlMLEonAPI) { @@ -1127,121 +1128,71 @@ public function setMapToControlMLEonAPI($mapToControlMLEonAPI) } // Allow stdClass (from json_decode without assoc) - if (is_object($mapToControlMLEonAPI)) { //// + if (is_object($mapToControlMLEonAPI)) { $mapToControlMLEonAPI = get_object_vars($mapToControlMLEonAPI); } if (!is_array($mapToControlMLEonAPI)) { - throw new InvalidArgumentException("mapToControlMLEonAPI must be an associative array or object."); + $error_message = "mapToControlMLEonAPI must be an associative array or object."; + $exception = new AuthException($error_message, 0); + if (self::$logger) { self::$logger->error($error_message); } + throw $exception; } - foreach ($mapToControlMLEonAPI as $k => $v) {/// + foreach ($mapToControlMLEonAPI as $k => $v) { if (!is_string($k)) { - throw new InvalidArgumentException("mapToControlMLEonAPI keys must be strings."); + $error_message = "mapToControlMLEonAPI keys must be strings."; + $exception = new AuthException($error_message, 0); + if (self::$logger) { self::$logger->error($error_message); } + throw $exception; } if (!is_string($v) && !is_bool($v)) { - throw new InvalidArgumentException("mapToControlMLEonAPI values must be string or bool."); + $error_message = "mapToControlMLEonAPI values must be string or bool."; + $exception = new AuthException($error_message, 0); + if (self::$logger) { self::$logger->error($error_message); } + throw $exception; } } - $this->mapToControlMLEonAPI = $mapToControlMLEonAPI; - $this->parseMapToControlMLEonAPI(); // build internal maps - } - - /** - * Internal helper: canonical boolean token? - * @param string $v - * @return bool - */ - private function isBooleanToken($v)/// - { - return $v === 'true' || $v === 'false'; - } - - /** - * Parse one raw entry into request/response booleans. - * - * @param string|bool $raw - * @param bool $defaultRequest - * @param bool $defaultResponse - * @return array{0:bool,1:bool} - */ - private function parseMleEntry($raw, $defaultRequest, $defaultResponse) //// - { - // Direct boolean -> request only - if (is_bool($raw)) { - return [$raw, $defaultResponse]; - } - - $raw = trim((string)$raw); - - // Plain string true/false (request only) - if ($this->isBooleanToken($raw)) { - return [$raw === 'true', $defaultResponse]; + // Validate the map value format - allowed values are true::true, false::false, ::true, true::, ::false, false::, true, false + if ($mapToControlMLEonAPI !== null) { + $this->validateMapToControlMLEonAPIValues($mapToControlMLEonAPI); } - - // Pattern with '::' - if (strpos($raw, '::') !== false) { - $parts = explode('::', $raw); - if (count($parts) !== 2) { - // Invalid pattern -> defaults - if (self::$logger) { - self::$logger->warning("Invalid MLE map value '$raw' (too many separators). Using defaults."); + + $this->mapToControlMLEonAPI = $mapToControlMLEonAPI; + + // Populate internal maps from the main map + if ($mapToControlMLEonAPI !== null) { + // Initialize internal maps + $this->internalMapToControlRequestMLEonAPI = []; + $this->internalMapToControlResponseMLEonAPI = []; + + foreach ($mapToControlMLEonAPI as $apiName => $value) { + // Convert boolean to string for processing + if (is_bool($value)) { + $value = $value ? 'true' : 'false'; } - return [$defaultRequest, $defaultResponse]; - } - $reqPart = trim($parts[0]); - $respPart = trim($parts[1]); - - $reqFlag = $defaultRequest; - $respFlag = $defaultResponse; - - if ($reqPart !== '') { - if ($this->isBooleanToken($reqPart)) { - $reqFlag = ($reqPart === 'true'); - } else { - if (self::$logger) { - self::$logger->warning("Invalid request MLE token '$reqPart' in '$raw'. Using default."); + + if (strpos($value, '::') !== false) { + // Format: "requestMLE::responseMLE" + $parts = explode('::', $value, 2); // Limit to 2 parts + $requestMLE = $parts[0]; + $responseMLE = $parts[1]; + + // Set request MLE value + if ($requestMLE !== '') { + $this->internalMapToControlRequestMLEonAPI[$apiName] = ($requestMLE === 'true'); } - } - } - if ($respPart !== '') { - if ($this->isBooleanToken($respPart)) { - $respFlag = ($respPart === 'true'); - } else { - if (self::$logger) { - self::$logger->warning("Invalid response MLE token '$respPart' in '$raw'. Using default."); + + // Set response MLE value + if ($responseMLE !== '') { + $this->internalMapToControlResponseMLEonAPI[$apiName] = ($responseMLE === 'true'); } + } else { + // Format: "true" or "false" - applies to request MLE only + $this->internalMapToControlRequestMLEonAPI[$apiName] = ($value === 'true'); } } - - return [$reqFlag, $respFlag]; - } - - // Unrecognized format -> defaults - if (self::$logger) { - self::$logger->warning("Unrecognized MLE map value '$raw'. Using defaults."); - } - return [$defaultRequest, $defaultResponse]; - } - - /** - * Build internal request/response MLE control maps from raw map. - * - * @return void - */ - private function parseMapToControlMLEonAPI() ///////// - { - $this->internalMapToControlRequestMLEonAPI = []; - $this->internalMapToControlResponseMLEonAPI = []; - - $defaultRequest = (bool)$this->enableRequestMLEForOptionalApisGlobally; - $defaultResponse = (bool)$this->enableResponseMleGlobally; - - foreach ($this->mapToControlMLEonAPI as $apiFunc => $rawVal) { - list($reqFlag, $respFlag) = $this->parseMleEntry($rawVal, $defaultRequest, $defaultResponse); - $this->internalMapToControlRequestMLEonAPI[$apiFunc] = $reqFlag; - $this->internalMapToControlResponseMLEonAPI[$apiFunc] = $respFlag; } } @@ -1347,11 +1298,10 @@ public function getResponseMlePrivateKeyFilePath() public function setResponseMlePrivateKey($responseMlePrivateKey) { + // Accept OpenSSLAsymmetricKey (PHP 8+) if (is_object($responseMlePrivateKey) && get_class($responseMlePrivateKey) === 'OpenSSLAsymmetricKey') { $this->responseMlePrivateKey = $responseMlePrivateKey; - } else { - throw new \InvalidArgumentException("responseMlePrivateKey must be OpenSSLAsymmetricKey"); - } + } } public function getResponseMlePrivateKey() @@ -1822,8 +1772,9 @@ public function validateMerchantData() } private function validateMLEConfiguration(){ - // Re-parse in case global flags changed since last parse - $this->parseMapToControlMLEonAPI();//// + + // Validate mapToControlMLEonAPI format + $this->validateMapToControlMLEonAPIValues($this->mapToControlMLEonAPI); /* * REQUEST MLE VALIDATION @@ -1856,7 +1807,7 @@ private function validateMLEConfiguration(){ * RESPONSE (OUTBOUND) MLE VALIDATION * Trigger if global flag OR any per-API response flag is true. */ - $responseMleConfigured = (bool)$this->enableResponseMleGlobally; //// + $responseMleConfigured = (bool)$this->enableResponseMleGlobally; foreach ($this->internalMapToControlResponseMLEonAPI as $flag) { if ($flag) { $responseMleConfigured = true; break; } } @@ -1869,22 +1820,30 @@ private function validateMLEConfiguration(){ throw $exception; } + // Validate responseMleKID + if (empty(trim($this->responseMleKID))) { + $error_message = "Response MLE enabled but responseMleKID is not set."; + $exception = new AuthException($error_message, 0); + self::$logger->error($error_message); + throw $exception; + } + $hasFilePath = !empty($this->responseMlePrivateKeyFilePath); - // $hasInMemoryKey = !empty($this->responseMlePrivateKey); - - // if (!$hasFilePath && !$hasInMemoryKey) { - // $error_message = "Response MLE enabled but neither responseMlePrivateKeyFilePath nor responseMlePrivateKey provided. Provide exactly one."; - // $exception = new AuthException($error_message, 0); - // self::$logger->error($error_message); - // throw $exception; - // } - - // if ($hasFilePath && $hasInMemoryKey) { - // $error_message = "Both responseMlePrivateKeyFilePath and responseMlePrivateKey supplied. Provide only one."; - // $exception = new AuthException($error_message, 0); - // self::$logger->error($error_message); - // throw $exception; - // } + $hasInMemoryKey = !empty($this->responseMlePrivateKey); + + if (!$hasFilePath && !$hasInMemoryKey) { + $error_message = "Response MLE enabled but neither responseMlePrivateKeyFilePath nor responseMlePrivateKey provided. Provide exactly one."; + $exception = new AuthException($error_message, 0); + self::$logger->error($error_message); + throw $exception; + } + + if ($hasFilePath && $hasInMemoryKey) { + $error_message = "Both responseMlePrivateKeyFilePath and responseMlePrivateKey supplied. Provide only one."; + $exception = new AuthException($error_message, 0); + self::$logger->error($error_message); + throw $exception; + } if ($hasFilePath) { if ( @@ -1897,24 +1856,80 @@ private function validateMLEConfiguration(){ self::$logger->error($error_message); throw $exception; } + } else { + // Basic sanity check for in-memory key + if (!is_object($this->responseMlePrivateKey)) { + $error_message = "Response MLE private key object is invalid. Must be OpenSSLAsymmetricKey"; + $exception = new AuthException($error_message, 0); + self::$logger->error($error_message); + throw $exception; + } } - // Password (if any) is optional; no strict validation here. - // } else { - // // Basic sanity check for in-memory key: must contain typical PEM header or be non-trivial length. - // if (strlen($this->responseMlePrivateKey) < 32) { - // $error_message = "responseMlePrivateKey appears invalid (too short)."; - // $exception = new AuthException($error_message, 0); - // self::$logger->error($error_message); - // throw $exception; - // } - // } - - if (empty($this->responseMleKID)) { - $error_message = "Response MLE enabled but responseMleKID not provided."; + } + } + + /** + * Validates the map values for MLE control API configuration. + * Allowed formats: "true::true", "false::false", "::true", "true::", "::false", "false::", "true", "false" + * + * @param array $mapToControlMLEonAPI the map to validate + * @throws AuthException if any value in the map has invalid format + */ + private function validateMapToControlMLEonAPIValues($mapToControlMLEonAPI) { + if (empty($mapToControlMLEonAPI) || !is_array($mapToControlMLEonAPI)) { + return; // Nothing to validate + } + + foreach ($mapToControlMLEonAPI as $apiName => $value) { + if (is_bool($value)) { + continue; // Boolean values are always valid + } + + if (!is_string($value)) { + $error_message = "Invalid value type for API '{$apiName}' in mapToControlMLEonAPI. Expected string or boolean, got " . gettype($value); $exception = new AuthException($error_message, 0); - self::$logger->error($error_message); + if (self::$logger) { self::$logger->error($error_message); } throw $exception; } + + $trimmedValue = trim($value); + + // Valid single boolean strings + if (in_array($trimmedValue, ['true', 'false'], true)) { + continue; + } + + // Valid :: format strings + if (strpos($trimmedValue, '::') !== false) { + $parts = explode('::', $trimmedValue); + if (count($parts) !== 2) { + $error_message = "Invalid format for API '{$apiName}' in mapToControlMLEonAPI. Multiple '::' separators not allowed. Value: '{$value}'"; + $exception = new AuthException($error_message, 0); + if (self::$logger) { self::$logger->error($error_message); } + throw $exception; + } + + $requestPart = trim($parts[0]); + $responsePart = trim($parts[1]); + + // Validate individual parts (can be empty, 'true', or 'false') + foreach ([$requestPart, $responsePart] as $index => $part) { + if (!empty($part) && !in_array($part, ['true', 'false'], true)) { + $partName = $index === 0 ? 'request' : 'response'; + $error_message = "Invalid {$partName} value for API '{$apiName}' in mapToControlMLEonAPI. Expected 'true', 'false', or empty. Value: '{$part}'"; + $exception = new AuthException($error_message, 0); + if (self::$logger) { self::$logger->error($error_message); } + throw $exception; + } + } + continue; + } + + // If we reach here, the format is invalid + $error_message = "Invalid format for API '{$apiName}' in mapToControlMLEonAPI. Expected formats: 'true', 'false', 'true::true', 'false::false', '::true', 'true::', etc. Value: '{$value}'"; + $exception = new AuthException($error_message, 0); + if (self::$logger) { self::$logger->error($error_message); } + throw $exception; } } diff --git a/lib/Authentication/Util/Cache.php b/lib/Authentication/Util/Cache.php index 3a64373c..46792775 100644 --- a/lib/Authentication/Util/Cache.php +++ b/lib/Authentication/Util/Cache.php @@ -179,6 +179,8 @@ private function setupMLECache($merchantConfig, $cacheKey, $mleCertPath) { $p12CertIdentifier = strtolower(GlobalParameter::MLE_CACHE_IDENTIFIER_FOR_P12_CERT); $respPrivKeyIdentifier = strtolower(GlobalParameter::MLE_CACHE_IDENTIFIER_FOR_RESPONSE_PRIVATE_KEY); // --- Response MLE Private Key handling with early return --- + $respPrivKeyIdentifier = strtolower(GlobalParameter::MLE_CACHE_IDENTIFIER_FOR_RESPONSE_PRIVATE_KEY); + // --- Response MLE Private Key handling with early return --- if (substr($lowercaseCacheKey, -strlen($respPrivKeyIdentifier)) === $respPrivKeyIdentifier) { $password = $merchantConfig->getResponseMlePrivateKeyFilePassword(); try { diff --git a/lib/Authentication/Util/MLEUtility.php b/lib/Authentication/Util/MLEUtility.php index 1619fb4f..feed992e 100644 --- a/lib/Authentication/Util/MLEUtility.php +++ b/lib/Authentication/Util/MLEUtility.php @@ -49,10 +49,10 @@ public static function checkIsMLEForAPI($merchantConfig, $inboundMLEStatus, $ope $operationArray = array_map('trim', explode(',', $operationIds)); - if (!empty($merchantConfig->getMapToControlMLEonAPI())) { + if (!empty($merchantConfig->getInternalMapToControlRequestMLEonAPI())) { foreach ($operationArray as $operationId) { - if (array_key_exists($operationId, $merchantConfig->getMapToControlMLEonAPI())) { - $isMLEForAPI = $merchantConfig->getMapToControlMLEonAPI()[$operationId]; + if (array_key_exists($operationId, $merchantConfig->getInternalMapToControlRequestMLEonAPI())) { + $isMLEForAPI = $merchantConfig->getInternalMapToControlRequestMLEonAPI()[$operationId]; break; } } From c902a89043a5b61fc467acf9ed1e00698da93d33 Mon Sep 17 00:00:00 2001 From: mahmishr Date: Fri, 17 Oct 2025 11:22:49 +0530 Subject: [PATCH 11/20] Update Cache.php --- lib/Authentication/Util/Cache.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/lib/Authentication/Util/Cache.php b/lib/Authentication/Util/Cache.php index 46792775..ec96b72c 100644 --- a/lib/Authentication/Util/Cache.php +++ b/lib/Authentication/Util/Cache.php @@ -19,13 +19,6 @@ public function __construct() self::$logger = (new LogFactory())->getLogger(\CyberSource\Utilities\Helpers\ClassHelper::getClassName(get_class($this)), new \CyberSource\Logging\LogConfiguration()); } } - public static function clearAllFileCache(): void - { - self::$file_cache = []; - if (self::$logger) { - self::$logger->debug("Cache: cleared all entries."); - } - } public function updateCache($filePath, $merchantConfig) { @@ -178,7 +171,6 @@ private function setupMLECache($merchantConfig, $cacheKey, $mleCertPath) { $configCertIdentifier = strtolower(GlobalParameter::MLE_CACHE_IDENTIFIER_FOR_CONFIG_CERT); $p12CertIdentifier = strtolower(GlobalParameter::MLE_CACHE_IDENTIFIER_FOR_P12_CERT); - $respPrivKeyIdentifier = strtolower(GlobalParameter::MLE_CACHE_IDENTIFIER_FOR_RESPONSE_PRIVATE_KEY); // --- Response MLE Private Key handling with early return --- $respPrivKeyIdentifier = strtolower(GlobalParameter::MLE_CACHE_IDENTIFIER_FOR_RESPONSE_PRIVATE_KEY); // --- Response MLE Private Key handling with early return --- if (substr($lowercaseCacheKey, -strlen($respPrivKeyIdentifier)) === $respPrivKeyIdentifier) { From 936ecc4d69f96b3f60d86d94e54a1b572084731e Mon Sep 17 00:00:00 2001 From: mahmishr Date: Fri, 17 Oct 2025 11:23:17 +0530 Subject: [PATCH 12/20] Update MLEUtility.php --- lib/Authentication/Util/MLEUtility.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/Authentication/Util/MLEUtility.php b/lib/Authentication/Util/MLEUtility.php index feed992e..bca19fa8 100644 --- a/lib/Authentication/Util/MLEUtility.php +++ b/lib/Authentication/Util/MLEUtility.php @@ -80,7 +80,7 @@ public static function checkIsResponseMLEForAPI($merchantConfig, $operationIds) if (is_array($map) && !empty($map)) { foreach ($operationArray as $operationId) { if (array_key_exists($operationId, $map)) { - $isResponseMLEForAPI = (bool)$map[$operationId]; //check + $isResponseMLEForAPI = (bool)$map[$operationId]; break; } } @@ -253,13 +253,10 @@ private static function getMleResponsePrivateKey($merchantConfig) } } - if (!isset(self::$cache)) { //check static + if (!isset(self::$cache)) { self::$cache = new Cache(); } - // self::$cache::clearAllFileCache(); - // echo "[MLE] Cleared all file cache.\n"; - return self::$cache->getMleResponsePrivateKeyFromFilePath($merchantConfig); } From 878ef372f6d236fc9ed6a6172b272a0915b498c5 Mon Sep 17 00:00:00 2001 From: mahmishr Date: Fri, 17 Oct 2025 11:31:52 +0530 Subject: [PATCH 13/20] Update MerchantConfiguration.php --- .../Core/MerchantConfiguration.php | 41 ------------------- 1 file changed, 41 deletions(-) diff --git a/lib/Authentication/Core/MerchantConfiguration.php b/lib/Authentication/Core/MerchantConfiguration.php index ccd8bffc..1b14f4cf 100644 --- a/lib/Authentication/Core/MerchantConfiguration.php +++ b/lib/Authentication/Core/MerchantConfiguration.php @@ -1127,7 +1127,6 @@ public function setMapToControlMLEonAPI($mapToControlMLEonAPI) return; } - // Allow stdClass (from json_decode without assoc) if (is_object($mapToControlMLEonAPI)) { $mapToControlMLEonAPI = get_object_vars($mapToControlMLEonAPI); } @@ -1349,13 +1348,6 @@ public function getMleKeyAlias() */ public function getRequestMleKeyAlias() { - // if (isset($this->requestMleKeyAlias) && trim($this->requestMleKeyAlias) !== '') { - // return $this->requestMleKeyAlias; - // } - // if (isset($this->mleKeyAlias) && trim($this->mleKeyAlias) !== '') { - // return $this->mleKeyAlias; - // } - // Neither provided; set default only for requestMleKeyAlias return $this->requestMleKeyAlias; } @@ -1370,35 +1362,12 @@ public function getRequestMleKeyAlias() */ public function setRequestMleKeyAlias($requestMleKeyAlias) { - // $alias = trim((string)$requestMleKeyAlias); - - // if ($alias === '') { - // // Leave empty; fallback will occur in getter - // $this->requestMleKeyAlias = ''; - // return $this; - // } - - // if (isset($this->mleKeyAlias) && trim($this->mleKeyAlias) !== '' && $this->mleKeyAlias !== $alias) { - // $msg = "mleKeyAlias and requestMleKeyAlias must be the same value when both are set."; - // if (self::$logger) { self::$logger->error($msg); } - // throw new \InvalidArgumentException($msg); - // } $alias = trim((string) $requestMleKeyAlias); if ($alias !== '') { $this->requestMleKeyAlias = $alias; } return $this; - - // // 2. Else if legacy mleKeyAlias set, promote it to requestMleKeyAlias - // if (isset($this->mleKeyAlias) && trim($this->mleKeyAlias) !== '') { - // $this->requestMleKeyAlias = trim($this->mleKeyAlias); - // return $this; - // } - - // // 3. Else assign default constant - // $this->requestMleKeyAlias = GlobalParameter::DEFAULT_MLE_ALIAS_FOR_CERT; - // return $this; } /** @@ -1417,16 +1386,6 @@ public function setMleKeyAlias($mleKeyAlias) return $this; } - // if ($alias === '') { - // $this->mleKeyAlias = ''; - // return $this; - // } - - // if (isset($this->requestMleKeyAlias) && trim($this->requestMleKeyAlias) !== '' && $this->requestMleKeyAlias !== $alias) { - // $msg = "mleKeyAlias and requestMleKeyAlias must be the same value when both are set."; - // if (self::$logger) { self::$logger->error($msg); } - // throw new \InvalidArgumentException($msg); - // } if ( $this->mleKeyAlias === GlobalParameter::DEFAULT_MLE_ALIAS_FOR_CERT || $this->mleKeyAlias === '' From b35e6545c052dee3cec4d068f177a019d8fd98a1 Mon Sep 17 00:00:00 2001 From: mahmishr Date: Fri, 17 Oct 2025 11:32:10 +0530 Subject: [PATCH 14/20] Update MLEUtility.php --- lib/Authentication/Util/MLEUtility.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/Authentication/Util/MLEUtility.php b/lib/Authentication/Util/MLEUtility.php index bca19fa8..7ae89868 100644 --- a/lib/Authentication/Util/MLEUtility.php +++ b/lib/Authentication/Util/MLEUtility.php @@ -86,7 +86,6 @@ public static function checkIsResponseMLEForAPI($merchantConfig, $operationIds) } } } - echo "[MLE] Response MLE decision for operations [" . implode(',', $operationArray) . "]: " . ($isResponseMLEForAPI ? "true" : "false") . "\n"; return $isResponseMLEForAPI; } @@ -154,7 +153,6 @@ public static function checkIsMleEncryptedResponse($responseBody) if (empty($privateKey)) { throw new MLEException("Response MLE private key not available for decryption."); } - // Cache already handles password decryption and returns unencrypted PEM if ($merchantConfig->getLogConfiguration()->isMaskingEnabled()) { $maskedResponseBody = \CyberSource\Utilities\Helpers\DataMasker::maskData($mleResponseBody); self::$logger->debug("LOG_NETWORK_RESPONSE_BEFORE_MLE_DECRYPTION: " . $maskedResponseBody); From 28d9a9e7f5e3fcb4aad41a63449934c2f68504bd Mon Sep 17 00:00:00 2001 From: mahmishr Date: Fri, 17 Oct 2025 11:35:52 +0530 Subject: [PATCH 15/20] code cleanup --- lib/Authentication/Core/MerchantConfiguration.php | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/lib/Authentication/Core/MerchantConfiguration.php b/lib/Authentication/Core/MerchantConfiguration.php index 1b14f4cf..9a9b7452 100644 --- a/lib/Authentication/Core/MerchantConfiguration.php +++ b/lib/Authentication/Core/MerchantConfiguration.php @@ -1338,11 +1338,7 @@ public function getMleKeyAlias() } /** - * Get requestMleKeyAlias (authoritative in codebase). - * Fallback order: - * 1. requestMleKeyAlias if non-empty - * 2. mleKeyAlias (legacy) if non-empty - * 3. assign default to requestMleKeyAlias and return it + * Get requestMleKeyAlias * * @return string */ @@ -1353,9 +1349,6 @@ public function getRequestMleKeyAlias() /** * Set requestMleKeyAlias. - * If legacy mleKeyAlias already set with a different value -> error. //to do - * - * Empty/blank input is treated as "not set" (kept empty for fallback/default logic). * * @param string $requestMleKeyAlias * @return $this @@ -1372,9 +1365,6 @@ public function setRequestMleKeyAlias($requestMleKeyAlias) /** * Legacy setter for mleKeyAlias. - * If requestMleKeyAlias already set with a different value -> error. //to do - * - * Empty/blank input is treated as "not set". * * @param string $mleKeyAlias * @return $this From c6c4f5fa096b88c479bf784d0dbb2b7878d1bcf6 Mon Sep 17 00:00:00 2001 From: mahmishr Date: Wed, 22 Oct 2025 14:59:51 +0530 Subject: [PATCH 16/20] comments resolved 1 --- lib/ApiClient.php | 4 +- .../Core/MerchantConfiguration.php | 53 ++++++------------- .../Http/HttpSignatureGenerator.php | 2 +- .../OAuth/OAuthTokenGenerator.php | 2 +- lib/Authentication/Util/Cache.php | 4 +- lib/Authentication/Util/MLEUtility.php | 12 +++-- 6 files changed, 29 insertions(+), 48 deletions(-) diff --git a/lib/ApiClient.php b/lib/ApiClient.php index ae1bba28..4296358b 100755 --- a/lib/ApiClient.php +++ b/lib/ApiClient.php @@ -498,7 +498,7 @@ public function callApi($resourcePath, $method, $queryParams, $postData, $header } elseif ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299) { // return raw body if response is a file if ($responseType === '\SplFileObject' || $responseType === 'string') { - self::$logger->close(); + self::$logger->close(); return [$http_body, $response_info['http_code'], $http_header]; } @@ -522,8 +522,6 @@ public function callApi($resourcePath, $method, $queryParams, $postData, $header } else { // Error path: still attempt decryption so error payload can be read if (MLEUtility::checkIsMleEncryptedResponse($http_body)) { - echo "[MLE][ApiClient] isResponseMLEForAPI=" . ($isResponseMLEForAPI ? "true" : "false") . - " authType=" . $this->merchantConfig->getAuthenticationType() . "\n"; try { $http_body = MLEUtility::decryptMleResponsePayload($this->merchantConfig, $http_body); } catch (\Exception $e) { diff --git a/lib/Authentication/Core/MerchantConfiguration.php b/lib/Authentication/Core/MerchantConfiguration.php index 9a9b7452..78309845 100644 --- a/lib/Authentication/Core/MerchantConfiguration.php +++ b/lib/Authentication/Core/MerchantConfiguration.php @@ -329,11 +329,11 @@ class MerchantConfiguration protected $responseMlePrivateKeyFilePath = ''; /** - * Private key (OpenSSL resource/object) used to decrypt Response MLE payloads. - * Provide the OpenSSLAsymmetricKey object (PHP 8+) or OpenSSL key resource (PHP 7). + * Private key object used to decrypt Response MLE payloads. + * Provide an OpenSSLAsymmetricKey object (PHP 8.0+). * Mutually exclusive with responseMlePrivateKeyFilePath. * - * @var \OpenSSLAsymmetricKey|resource|null + * @var \OpenSSLAsymmetricKey|null */ protected $responseMlePrivateKey = null; @@ -1127,14 +1127,12 @@ public function setMapToControlMLEonAPI($mapToControlMLEonAPI) return; } - if (is_object($mapToControlMLEonAPI)) { - $mapToControlMLEonAPI = get_object_vars($mapToControlMLEonAPI); - } - if (!is_array($mapToControlMLEonAPI)) { - $error_message = "mapToControlMLEonAPI must be an associative array or object."; + $error_message = "mapToControlMLEonAPI must be an associative array."; $exception = new AuthException($error_message, 0); - if (self::$logger) { self::$logger->error($error_message); } + if (self::$logger) { + self::$logger->error($error_message); + } throw $exception; } @@ -1154,14 +1152,11 @@ public function setMapToControlMLEonAPI($mapToControlMLEonAPI) } // Validate the map value format - allowed values are true::true, false::false, ::true, true::, ::false, false::, true, false - if ($mapToControlMLEonAPI !== null) { - $this->validateMapToControlMLEonAPIValues($mapToControlMLEonAPI); - } + $this->validateMapToControlMLEonAPIValues($mapToControlMLEonAPI); $this->mapToControlMLEonAPI = $mapToControlMLEonAPI; // Populate internal maps from the main map - if ($mapToControlMLEonAPI !== null) { // Initialize internal maps $this->internalMapToControlRequestMLEonAPI = []; $this->internalMapToControlResponseMLEonAPI = []; @@ -1192,7 +1187,6 @@ public function setMapToControlMLEonAPI($mapToControlMLEonAPI) $this->internalMapToControlRequestMLEonAPI[$apiName] = ($value === 'true'); } } - } } /** @@ -1317,15 +1311,6 @@ public function getResponseMlePrivateKeyFilePassword() { return $this->responseMlePrivateKeyFilePassword; } - - private function isAssocArrayOfStringBool($array) { - foreach ($array as $key => $value) { - if (!is_string($key) || !is_bool($value)) { - return false; - } - } - return true; - } /** * Get the value of mleKeyAlias (legacy) @@ -1531,6 +1516,8 @@ public static function setMerchantCredentials($connectionDet) } elseif (isset($connectionDet->mleKeyAlias) && trim((string) $connectionDet->mleKeyAlias) !== '') { $rawAlias = $connectionDet->mleKeyAlias; $config = $config->setMleKeyAlias($rawAlias); // keep legacy field in sync + }else{ + $rawAlias = GlobalParameter::DEFAULT_MLE_ALIAS_FOR_CERT; } if ($rawAlias !== null) { $config=$config->setRequestMleKeyAlias($rawAlias); @@ -1549,9 +1536,9 @@ public static function setMerchantCredentials($connectionDet) if (isset($connectionDet->responseMlePrivateKeyFilePassword)) { $config = $config->setResponseMlePrivateKeyFilePassword($connectionDet->responseMlePrivateKeyFilePassword); } - // if (isset($connectionDet->responseMlePrivateKey)) { - // $config = $config->setResponseMlePrivateKey($connectionDet->responseMlePrivateKey); - // } + if (isset($connectionDet->responseMlePrivateKey)) { + $config = $config->setResponseMlePrivateKey($connectionDet->responseMlePrivateKey); + } $config->validateMerchantData(); if($error_message != null){ @@ -1721,14 +1708,10 @@ public function validateMerchantData() } private function validateMLEConfiguration(){ - - // Validate mapToControlMLEonAPI format - $this->validateMapToControlMLEonAPIValues($this->mapToControlMLEonAPI); - /* * REQUEST MLE VALIDATION */ - $requestMleConfigured = (bool)$this->enableRequestMLEForOptionalApisGlobally; + $requestMleConfigured = $this->enableRequestMLEForOptionalApisGlobally===true; foreach ($this->internalMapToControlRequestMLEonAPI as $flag) { if ($flag) { $requestMleConfigured = true; break; } } @@ -1806,9 +1789,8 @@ private function validateMLEConfiguration(){ throw $exception; } } else { - // Basic sanity check for in-memory key - if (!is_object($this->responseMlePrivateKey)) { - $error_message = "Response MLE private key object is invalid. Must be OpenSSLAsymmetricKey"; + if (!is_object($this->responseMlePrivateKey) || get_class($this->responseMlePrivateKey) !== 'OpenSSLAsymmetricKey') { + $error_message = "Response MLE private key object is invalid. Expected OpenSSLAsymmetricKey"; $exception = new AuthException($error_message, 0); self::$logger->error($error_message); throw $exception; @@ -1825,9 +1807,6 @@ private function validateMLEConfiguration(){ * @throws AuthException if any value in the map has invalid format */ private function validateMapToControlMLEonAPIValues($mapToControlMLEonAPI) { - if (empty($mapToControlMLEonAPI) || !is_array($mapToControlMLEonAPI)) { - return; // Nothing to validate - } foreach ($mapToControlMLEonAPI as $apiName => $value) { if (is_bool($value)) { diff --git a/lib/Authentication/Http/HttpSignatureGenerator.php b/lib/Authentication/Http/HttpSignatureGenerator.php index ed944591..8ba4ea4f 100644 --- a/lib/Authentication/Http/HttpSignatureGenerator.php +++ b/lib/Authentication/Http/HttpSignatureGenerator.php @@ -24,7 +24,7 @@ public function __construct(\CyberSource\Logging\LogConfiguration $logConfig) } //Signature Creation function - public function generateToken($resourcePath, $payloadData, $method, $merchantConfig, $isResponseMLEForAPI = false) //add + public function generateToken($resourcePath, $payloadData, $method, $merchantConfig, $isResponseMLEForAPI = false) { $host = $merchantConfig->getHost(); $date = date("D, d M Y G:i:s ").GlobalParameter::GMT; diff --git a/lib/Authentication/OAuth/OAuthTokenGenerator.php b/lib/Authentication/OAuth/OAuthTokenGenerator.php index 061d07d0..461df17d 100644 --- a/lib/Authentication/OAuth/OAuthTokenGenerator.php +++ b/lib/Authentication/OAuth/OAuthTokenGenerator.php @@ -22,7 +22,7 @@ public function __construct() } //Generate OAuth Token Function - public function generateToken($resourcePath, $payloadData, $method, $merchantConfig, $isResponseMLEForAPI = false) //add + public function generateToken($resourcePath, $payloadData, $method, $merchantConfig, $isResponseMLEForAPI = false) { $accessToken = $merchantConfig->getAccessToken(); if(isset($accessToken)) diff --git a/lib/Authentication/Util/Cache.php b/lib/Authentication/Util/Cache.php index ec96b72c..86bfb71f 100644 --- a/lib/Authentication/Util/Cache.php +++ b/lib/Authentication/Util/Cache.php @@ -203,7 +203,9 @@ private function setupMLECache($merchantConfig, $cacheKey, $mleCertPath) { } elseif (str_ends_with($lowercaseCacheKey, $p12CertIdentifier)) { $mleCert = $this->loadCertificateFromP12($mleCertPath, $merchantConfig); } else { - self::$logger->warning("Unrecognized MLE cache key pattern: " . $cacheKey); + if (self::$logger) { + self::$logger->warning("Unrecognized MLE cache key pattern: " . $cacheKey); + } return; } diff --git a/lib/Authentication/Util/MLEUtility.php b/lib/Authentication/Util/MLEUtility.php index 7ae89868..c4a01ca5 100644 --- a/lib/Authentication/Util/MLEUtility.php +++ b/lib/Authentication/Util/MLEUtility.php @@ -66,7 +66,7 @@ public static function checkIsResponseMLEForAPI($merchantConfig, $operationIds) $isResponseMLEForAPI = false; // Global flag - if (method_exists($merchantConfig, 'getEnableResponseMleGlobally') && + if (/*method_exists($merchantConfig, 'getEnableResponseMleGlobally') &&*/ $merchantConfig->getEnableResponseMleGlobally()) { $isResponseMLEForAPI = true; } @@ -75,7 +75,7 @@ public static function checkIsResponseMLEForAPI($merchantConfig, $operationIds) $operationArray = array_map('trim', explode(',', (string)$operationIds)); // Per-operation override map (internal response map) - if (method_exists($merchantConfig, 'getInternalMapToControlResponseMLEonAPI')) { + // if (method_exists($merchantConfig, 'getInternalMapToControlResponseMLEonAPI')) { $map = $merchantConfig->getInternalMapToControlResponseMLEonAPI(); if (is_array($map) && !empty($map)) { foreach ($operationArray as $operationId) { @@ -85,7 +85,7 @@ public static function checkIsResponseMLEForAPI($merchantConfig, $operationIds) } } } - } + //} return $isResponseMLEForAPI; } @@ -135,7 +135,9 @@ public static function checkIsMleEncryptedResponse($responseBody) } catch (\Exception $e) { return false; } - } public static function decryptMleResponsePayload($merchantConfig, $mleResponseBody) + } + + public static function decryptMleResponsePayload($merchantConfig, $mleResponseBody) { if (self::$logger === null) { self::$logger = (new LogFactory())->getLogger(\CyberSource\Utilities\Helpers\ClassHelper::getClassName(static::class), $merchantConfig->getLogConfiguration()); @@ -231,7 +233,7 @@ private static function getResponseMleToken($mleResponseBody) $decoded = json_decode($mleResponseBody, true); return $decoded['encryptedResponse'] ?? null; } catch (\Exception $e) { - self::$logger->error("Failed to extract Response MLE token: " + $e->getMessage()); + self::$logger->error("Failed to extract Response MLE token: " . $e->getMessage()); return null; } } From 5c526677236b52e7d89b0380778b469d35d6877d Mon Sep 17 00:00:00 2001 From: mahmishr Date: Wed, 22 Oct 2025 15:39:40 +0530 Subject: [PATCH 17/20] comments resolved 2 --- lib/Authentication/Core/MerchantConfiguration.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/Authentication/Core/MerchantConfiguration.php b/lib/Authentication/Core/MerchantConfiguration.php index 78309845..88d83090 100644 --- a/lib/Authentication/Core/MerchantConfiguration.php +++ b/lib/Authentication/Core/MerchantConfiguration.php @@ -1153,13 +1153,11 @@ public function setMapToControlMLEonAPI($mapToControlMLEonAPI) // Validate the map value format - allowed values are true::true, false::false, ::true, true::, ::false, false::, true, false $this->validateMapToControlMLEonAPIValues($mapToControlMLEonAPI); - - $this->mapToControlMLEonAPI = $mapToControlMLEonAPI; - + // Populate internal maps from the main map // Initialize internal maps - $this->internalMapToControlRequestMLEonAPI = []; - $this->internalMapToControlResponseMLEonAPI = []; + $this->internalMapToControlRequestMLEonAPI = []; + $this->internalMapToControlResponseMLEonAPI = []; foreach ($mapToControlMLEonAPI as $apiName => $value) { // Convert boolean to string for processing @@ -1187,6 +1185,7 @@ public function setMapToControlMLEonAPI($mapToControlMLEonAPI) $this->internalMapToControlRequestMLEonAPI[$apiName] = ($value === 'true'); } } + $this->mapToControlMLEonAPI = $mapToControlMLEonAPI; } /** From be1c4c234269ff4830c0097b31c7553dbf910e47 Mon Sep 17 00:00:00 2001 From: mahmishr Date: Thu, 23 Oct 2025 15:09:58 +0530 Subject: [PATCH 18/20] comment resolved 3 --- .../Core/MerchantConfiguration.php | 33 +++++-------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/lib/Authentication/Core/MerchantConfiguration.php b/lib/Authentication/Core/MerchantConfiguration.php index 88d83090..0a9d00da 100644 --- a/lib/Authentication/Core/MerchantConfiguration.php +++ b/lib/Authentication/Core/MerchantConfiguration.php @@ -1332,7 +1332,8 @@ public function getRequestMleKeyAlias() } /** - * Set requestMleKeyAlias. + * Set requestMleKeyAlias (canonical). Empty or whitespace -> default constant. + * Keeps legacy mleKeyAlias in sync every time. * * @param string $requestMleKeyAlias * @return $this @@ -1340,41 +1341,23 @@ public function getRequestMleKeyAlias() public function setRequestMleKeyAlias($requestMleKeyAlias) { $alias = trim((string) $requestMleKeyAlias); - - if ($alias !== '') { - $this->requestMleKeyAlias = $alias; + if ($alias === '') { + $alias = GlobalParameter::DEFAULT_MLE_ALIAS_FOR_CERT; } + $this->requestMleKeyAlias = $alias; + $this->mleKeyAlias = $alias; // keep legacy field synchronized return $this; } /** * Legacy setter for mleKeyAlias. - * + * Delegates to setRequestMleKeyAlias to ensure synchronization * * @param string $mleKeyAlias * @return $this */ public function setMleKeyAlias($mleKeyAlias) { - $alias = trim((string)$mleKeyAlias); - if ($alias === '') { - return $this; - } - - if ( - $this->mleKeyAlias === GlobalParameter::DEFAULT_MLE_ALIAS_FOR_CERT - || $this->mleKeyAlias === '' - || $this->mleKeyAlias === null - ) { - $this->mleKeyAlias = $alias; - } - if ( - $this->requestMleKeyAlias === GlobalParameter::DEFAULT_MLE_ALIAS_FOR_CERT - || $this->requestMleKeyAlias === '' - || $this->requestMleKeyAlias === null - ) { - $this->requestMleKeyAlias = $alias; - } - return $this; + return $this->setRequestMleKeyAlias($mleKeyAlias); } /** From d5e10b4c66752e87f9cebd7aacc7876776bb3d56 Mon Sep 17 00:00:00 2001 From: mahmishr Date: Tue, 28 Oct 2025 14:43:00 +0530 Subject: [PATCH 19/20] all comments resolved --- lib/Authentication/Util/Cache.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/Authentication/Util/Cache.php b/lib/Authentication/Util/Cache.php index 86bfb71f..eef3d622 100644 --- a/lib/Authentication/Util/Cache.php +++ b/lib/Authentication/Util/Cache.php @@ -11,7 +11,6 @@ class Cache { private static $file_cache = array(); private static $logger = null; - private static $responseMleKeyLoadFailed = false; public function __construct() { @@ -181,13 +180,9 @@ private function setupMLECache($merchantConfig, $cacheKey, $mleCertPath) { 'response_mle_private_key' => $loaded, 'file_mod_time' => $fileModTime ]; - self::$responseMleKeyLoadFailed = false; // reset on success } catch (\Exception $e) { - if (!self::$responseMleKeyLoadFailed) { - self::$responseMleKeyLoadFailed = true; - if (self::$logger) { self::$logger->error("Response MLE private key load failed: ".$e->getMessage()); } - } else { - if (self::$logger) { self::$logger->debug("Response MLE private key load failed again; suppressing repeated error log."); } + if (self::$logger) { + self::$logger->error("Response MLE private key load failed: ".$e->getMessage()); } self::$file_cache[$cacheKey] = [ 'response_mle_private_key' => null, @@ -352,7 +347,6 @@ public function getMleResponsePrivateKeyFromFilePath($merchantConfig) if (!isset(self::$file_cache[$cacheKey]) || self::$file_cache[$cacheKey]['file_mod_time'] !== $modTime) { - $this->setupMLECache($merchantConfig, $cacheKey, $filePath); } else { self::$logger->debug("Response MLE private key retrieved from cache."); From 5f05c41983da002219f97f54e8322ff0c7dd06b1 Mon Sep 17 00:00:00 2001 From: mahmishr Date: Tue, 28 Oct 2025 15:25:44 +0530 Subject: [PATCH 20/20] Update MLEUtility.php --- lib/Authentication/Util/MLEUtility.php | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/lib/Authentication/Util/MLEUtility.php b/lib/Authentication/Util/MLEUtility.php index c4a01ca5..3d77bd7e 100644 --- a/lib/Authentication/Util/MLEUtility.php +++ b/lib/Authentication/Util/MLEUtility.php @@ -66,8 +66,7 @@ public static function checkIsResponseMLEForAPI($merchantConfig, $operationIds) $isResponseMLEForAPI = false; // Global flag - if (/*method_exists($merchantConfig, 'getEnableResponseMleGlobally') &&*/ - $merchantConfig->getEnableResponseMleGlobally()) { + if ($merchantConfig->getEnableResponseMleGlobally()) { $isResponseMLEForAPI = true; } @@ -75,17 +74,15 @@ public static function checkIsResponseMLEForAPI($merchantConfig, $operationIds) $operationArray = array_map('trim', explode(',', (string)$operationIds)); // Per-operation override map (internal response map) - // if (method_exists($merchantConfig, 'getInternalMapToControlResponseMLEonAPI')) { - $map = $merchantConfig->getInternalMapToControlResponseMLEonAPI(); - if (is_array($map) && !empty($map)) { - foreach ($operationArray as $operationId) { - if (array_key_exists($operationId, $map)) { - $isResponseMLEForAPI = (bool)$map[$operationId]; - break; - } + $map = $merchantConfig->getInternalMapToControlResponseMLEonAPI(); + if (is_array($map) && !empty($map)) { + foreach ($operationArray as $operationId) { + if (array_key_exists($operationId, $map)) { + $isResponseMLEForAPI = (bool)$map[$operationId]; + break; } } - //} + } return $isResponseMLEForAPI; }