From 8d42402776fc04f8d35e8ffffe8b16f001e388ff Mon Sep 17 00:00:00 2001 From: gaubansa Date: Fri, 31 Jan 2025 12:50:25 +0530 Subject: [PATCH 01/23] adding MLE parameters in merchantConfig --- .../Core/MerchantConfiguration.php | 137 +++++++++++++++++- lib/Authentication/Util/GlobalParameter.php | 2 + 2 files changed, 138 insertions(+), 1 deletion(-) diff --git a/lib/Authentication/Core/MerchantConfiguration.php b/lib/Authentication/Core/MerchantConfiguration.php index aec719afb..22a1b1c89 100644 --- a/lib/Authentication/Core/MerchantConfiguration.php +++ b/lib/Authentication/Core/MerchantConfiguration.php @@ -8,6 +8,7 @@ use CyberSource\Authentication\Util\GlobalParameter as GlobalParameter; use CyberSource\Logging\LogFactory as LogFactory; use CyberSource\Logging\LogConfiguration as LogConfiguration; +use \InvalidArgumentException; class MerchantConfiguration { @@ -198,6 +199,27 @@ class MerchantConfiguration */ protected $IntermediateHost=""; + /** + * Curl useMLEGlobally + * + * @var bool + */ + protected $useMLEGlobally=false; + + /** + * Curl mapToControlMLEonAPI + * + * @var array + */ + protected $mapToControlMLEonAPI = []; + + /** + * Curl mleKeyAlias + * + * @var string + */ + protected $mleKeyAlias = GlobalParameter::DEFAULT_MLE_ALIAS_FOR_CERT; + /** * Curl DefaultDeveloperId * @@ -931,6 +953,85 @@ public function setJwePEMFileDirectory(string $jwePEMFileDirectory) $this->jwePEMFileDirectory = $jwePEMFileDirectory; } + /** + * Get the value of useMLEGlobally + * + * @return bool + */ + public function getUseMLEGlobally() + { + return $this->useMLEGlobally; + } + + /** + * Set the value of useMLEGlobally + * + * @param bool $useMLEGlobally + */ + public function setUseMLEGlobally($useMLEGlobally) + { + $this->useMLEGlobally = $useMLEGlobally; + } + + /** + * Get the value of mapToControlMLEonAPI + * + * @return array + */ + public function getMapToControlMLEonAPI() + { + return $this->mapToControlMLEonAPI; + } + + /** + * Set the value of mapToControlMLEonAPI + * + * @param array $mapToControlMLEonAPI + */ + 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."); + } + } + } + + 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 + * + * @return string + */ + public function getMleKeyAlias() + { + return $this->mleKeyAlias; + } + + /** + * Set the value of mleKeyAlias + * + * @param string $mleKeyAlias + */ + public function setMleKeyAlias($mleKeyAlias) + { + if (!is_null($mleKeyAlias) & !empty(trim($mleKeyAlias)) ) { + $this->mleKeyAlias = $mleKeyAlias; + }else{ + $this->mleKeyAlias = GlobalParameter::DEFAULT_MLE_ALIAS_FOR_CERT; + } + } + /** * Gets the essential information for debugging * @@ -1037,7 +1138,19 @@ public static function setMerchantCredentials($connectionDet) if (isset($connectionDet->jwePEMFileDirectory)) { $config = $config->setJwePEMFileDirectory($connectionDet->jwePEMFileDirectory); } - + + if (isset($connectionDet->useMLEGlobally)) { + $config = $config->setUseMLEGlobally($connectionDet->useMLEGlobally); + } + + if (isset($connectionDet->mapToControlMLEonAPI)) { + $config = $config->setMapToControlMLEonAPI($connectionDet->mapToControlMLEonAPI); + } + + if (isset($connectionDet->mleKeyAlias)) { + $config = $config->setMleKeyAlias($connectionDet->mleKeyAlias); + } + $config->validateMerchantData(); if($error_message != null){ $error_message = GlobalParameter::NOT_ENTERED. $error_message; @@ -1196,11 +1309,33 @@ public function validateMerchantData() throw $exception; } + $this->validateMLEConfiguration(); + if(!empty($warning_message)){ self::$logger->warning($warning_message); } self::$logger->close(); } + + private function validateMLEConfiguration(){ + $mleConfigured = $this->useMLEGlobally; + if ($this->mapToControlMLEonAPI !== null && !empty($this->mapToControlMLEonAPI)) { + foreach ($this->mapToControlMLEonAPI as $value) { + if ($value) { + $mleConfigured = true; + break; + } + } + } + // if MLE=true then check for auth Type + if ($mleConfigured && strcasecmp($this->authenticationType, GlobalParameter::JWT) !== 0) { + $error_message = GlobalParameter::MLE_AUTH_ERROR; + $exception = new AuthException($error_message, 0); + self::$logger->error($error_message); + throw $exception; + } + } + } ?> \ No newline at end of file diff --git a/lib/Authentication/Util/GlobalParameter.php b/lib/Authentication/Util/GlobalParameter.php index 07f9f8346..f75969fe5 100644 --- a/lib/Authentication/Util/GlobalParameter.php +++ b/lib/Authentication/Util/GlobalParameter.php @@ -103,5 +103,7 @@ class GlobalParameter const LOGFILENAME = "LogFilename "; const REQTYPE = "RequestType "; const KEYFILEFIELDDIR = "keysDirectory "; + const DEFAULT_MLE_ALIAS_FOR_CERT = "CyberSource_SJC_US"; + const MLE_AUTH_ERROR = "MLE is only supported in JWT auth type"; } ?> \ No newline at end of file From d8f3a4adab44cb56624ded2c0f09fd0ee5736972 Mon Sep 17 00:00:00 2001 From: gaubansa Date: Fri, 31 Jan 2025 12:50:42 +0530 Subject: [PATCH 02/23] adding MLE Utility --- lib/Authentication/Util/MLEUtility.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 lib/Authentication/Util/MLEUtility.php diff --git a/lib/Authentication/Util/MLEUtility.php b/lib/Authentication/Util/MLEUtility.php new file mode 100644 index 000000000..695221053 --- /dev/null +++ b/lib/Authentication/Util/MLEUtility.php @@ -0,0 +1,24 @@ + \ No newline at end of file From 46ddb40f7807e825617463221d81e49ba3037b09 Mon Sep 17 00:00:00 2001 From: gaubansa Date: Fri, 31 Jan 2025 12:59:09 +0530 Subject: [PATCH 03/23] adding mle req body encryption in payment api --- lib/Api/PaymentsApi.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/Api/PaymentsApi.php b/lib/Api/PaymentsApi.php index c38041c32..06c2ca899 100644 --- a/lib/Api/PaymentsApi.php +++ b/lib/Api/PaymentsApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * PaymentsApi Class Doc Comment @@ -285,6 +287,18 @@ public function createPaymentWithHttpInfo($createPaymentRequest) $httpBody = $formParams; // for HTTP post (form) } + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = true; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "createPayment,createPaymentWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + + // Logging self::$logger->debug("Resource : POST $resourcePath"); if (isset($httpBody)) { From f3f5068a711e075d8203b83729e47adeb4ce1a29 Mon Sep 17 00:00:00 2001 From: gaubansa Date: Fri, 31 Jan 2025 13:04:26 +0530 Subject: [PATCH 04/23] adding mle encryption logic in api.mustache --- generator/cybersource-php-template/api.mustache | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/generator/cybersource-php-template/api.mustache b/generator/cybersource-php-template/api.mustache index 4cb610b9d..0c21fa6f3 100644 --- a/generator/cybersource-php-template/api.mustache +++ b/generator/cybersource-php-template/api.mustache @@ -23,6 +23,8 @@ use \{{invokerPackage}}\ApiException; use \{{invokerPackage}}\Configuration; use \{{invokerPackage}}\ObjectSerializer; use \{{invokerPackage}}\Logging\LogFactory as LogFactory; +use \{{invokerPackage}}\Authentication\Util\MLEUtility; +use \Exception; /** * {{classname}} Class Doc Comment @@ -233,6 +235,18 @@ use \{{invokerPackage}}\Logging\LogFactory as LogFactory; } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = {{#vendorExtensions.x-devcenter-metaData.isMLEsupported}}true;{{/vendorExtensions.x-devcenter-metaData.isMLEsupported}}{{^vendorExtensions.x-devcenter-metaData.isMLEsupported}}false;{{/vendorExtensions.x-devcenter-metaData.isMLEsupported}} + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "{{operationId}},{{operationId}}WithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + {{#authMethods}} {{#isApiKey}} // this endpoint requires API key authentication From 30bbb86cba3c89ed650987458673e7b2ad4c22a2 Mon Sep 17 00:00:00 2001 From: gaubansa Date: Fri, 31 Jan 2025 13:04:50 +0530 Subject: [PATCH 05/23] adding mle encryption logic call to api classes --- lib/Api/BatchesApi.php | 50 ++++++++++ lib/Api/BillingAgreementsApi.php | 38 +++++++ lib/Api/BinLookupApi.php | 14 +++ lib/Api/CaptureApi.php | 14 +++ lib/Api/ChargebackDetailsApi.php | 14 +++ lib/Api/ChargebackSummariesApi.php | 14 +++ lib/Api/ConversionDetailsApi.php | 14 +++ lib/Api/CreateNewWebhooksApi.php | 38 +++++++ lib/Api/CreditApi.php | 14 +++ lib/Api/CustomerApi.php | 50 ++++++++++ lib/Api/CustomerPaymentInstrumentApi.php | 62 ++++++++++++ lib/Api/CustomerShippingAddressApi.php | 62 ++++++++++++ lib/Api/DecisionManagerApi.php | 62 ++++++++++++ lib/Api/DownloadDTDApi.php | 14 +++ lib/Api/DownloadXSDApi.php | 14 +++ lib/Api/EMVTagDetailsApi.php | 26 +++++ lib/Api/FlexAPIApi.php | 14 +++ lib/Api/InstrumentIdentifierApi.php | 74 ++++++++++++++ .../InterchangeClearingLevelDetailsApi.php | 14 +++ lib/Api/InvoiceSettingsApi.php | 26 +++++ lib/Api/InvoicesApi.php | 74 ++++++++++++++ lib/Api/ManageWebhooksApi.php | 62 ++++++++++++ lib/Api/MerchantBoardingApi.php | 26 +++++ lib/Api/MicroformIntegrationApi.php | 14 +++ lib/Api/NetFundingsApi.php | 14 +++ lib/Api/NotificationOfChangesApi.php | 14 +++ lib/Api/OrdersApi.php | 26 +++++ lib/Api/PayerAuthenticationApi.php | 38 +++++++ lib/Api/PaymentBatchSummariesApi.php | 14 +++ lib/Api/PaymentInstrumentApi.php | 50 ++++++++++ lib/Api/PaymentsApi.php | 64 +++++++++++- lib/Api/PayoutsApi.php | 14 +++ lib/Api/PlansApi.php | 98 +++++++++++++++++++ lib/Api/PurchaseAndRefundDetailsApi.php | 14 +++ lib/Api/PushFundsApi.php | 14 +++ lib/Api/RefundApi.php | 26 +++++ lib/Api/ReplayWebhooksApi.php | 14 +++ lib/Api/ReportDefinitionsApi.php | 26 +++++ lib/Api/ReportDownloadsApi.php | 14 +++ lib/Api/ReportSubscriptionsApi.php | 62 ++++++++++++ lib/Api/ReportsApi.php | 38 +++++++ lib/Api/RetrievalDetailsApi.php | 14 +++ lib/Api/RetrievalSummariesApi.php | 14 +++ lib/Api/ReversalApi.php | 26 +++++ lib/Api/SearchTransactionsApi.php | 26 +++++ lib/Api/SecureFileShareApi.php | 26 +++++ lib/Api/SubscriptionsApi.php | 98 +++++++++++++++++++ lib/Api/TaxesApi.php | 26 +++++ lib/Api/TokenApi.php | 14 +++ lib/Api/TransactionBatchesApi.php | 38 +++++++ lib/Api/TransactionDetailsApi.php | 14 +++ lib/Api/TransientTokenDataApi.php | 26 +++++ lib/Api/UnifiedCheckoutCaptureContextApi.php | 14 +++ lib/Api/UserManagementApi.php | 14 +++ lib/Api/UserManagementSearchApi.php | 14 +++ lib/Api/VerificationApi.php | 26 +++++ lib/Api/VoidApi.php | 62 ++++++++++++ 57 files changed, 1794 insertions(+), 2 deletions(-) diff --git a/lib/Api/BatchesApi.php b/lib/Api/BatchesApi.php index 7732283d6..7a938facb 100644 --- a/lib/Api/BatchesApi.php +++ b/lib/Api/BatchesApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * BatchesApi Class Doc Comment @@ -157,6 +159,18 @@ public function getBatchReportWithHttpInfo($batchId) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getBatchReport,getBatchReportWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); @@ -267,6 +281,18 @@ public function getBatchStatusWithHttpInfo($batchId) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getBatchStatus,getBatchStatusWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); @@ -386,6 +412,18 @@ public function getBatchesListWithHttpInfo($offset = '0', $limit = '20', $fromDa } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getBatchesList,getBatchesListWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); @@ -503,6 +541,18 @@ public function postBatchWithHttpInfo($body) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "postBatch,postBatchWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); diff --git a/lib/Api/BillingAgreementsApi.php b/lib/Api/BillingAgreementsApi.php index 5369e5a67..4944db0f6 100644 --- a/lib/Api/BillingAgreementsApi.php +++ b/lib/Api/BillingAgreementsApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * BillingAgreementsApi Class Doc Comment @@ -171,6 +173,18 @@ public function billingAgreementsDeRegistrationWithHttpInfo($modifyBillingAgreem } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = true; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "billingAgreementsDeRegistration,billingAgreementsDeRegistrationWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : PATCH $resourcePath"); @@ -299,6 +313,18 @@ public function billingAgreementsIntimationWithHttpInfo($intimateBillingAgreemen } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = true; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "billingAgreementsIntimation,billingAgreementsIntimationWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -412,6 +438,18 @@ public function billingAgreementsRegistrationWithHttpInfo($createBillingAgreemen } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = true; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "billingAgreementsRegistration,billingAgreementsRegistrationWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); diff --git a/lib/Api/BinLookupApi.php b/lib/Api/BinLookupApi.php index 812a779ee..1b9dabc9d 100644 --- a/lib/Api/BinLookupApi.php +++ b/lib/Api/BinLookupApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * BinLookupApi Class Doc Comment @@ -158,6 +160,18 @@ public function getAccountInfoWithHttpInfo($createBinLookupRequest) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getAccountInfo,getAccountInfoWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); diff --git a/lib/Api/CaptureApi.php b/lib/Api/CaptureApi.php index 60e549353..c42c23da6 100644 --- a/lib/Api/CaptureApi.php +++ b/lib/Api/CaptureApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * CaptureApi Class Doc Comment @@ -171,6 +173,18 @@ public function capturePaymentWithHttpInfo($capturePaymentRequest, $id) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = true; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "capturePayment,capturePaymentWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); diff --git a/lib/Api/ChargebackDetailsApi.php b/lib/Api/ChargebackDetailsApi.php index 1de588d06..a64104147 100644 --- a/lib/Api/ChargebackDetailsApi.php +++ b/lib/Api/ChargebackDetailsApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * ChargebackDetailsApi Class Doc Comment @@ -170,6 +172,18 @@ public function getChargebackDetailsWithHttpInfo($startTime, $endTime, $organiza } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getChargebackDetails,getChargebackDetailsWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); diff --git a/lib/Api/ChargebackSummariesApi.php b/lib/Api/ChargebackSummariesApi.php index 3a0bc3ebe..3d8343af9 100644 --- a/lib/Api/ChargebackSummariesApi.php +++ b/lib/Api/ChargebackSummariesApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * ChargebackSummariesApi Class Doc Comment @@ -170,6 +172,18 @@ public function getChargebackSummariesWithHttpInfo($startTime, $endTime, $organi } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getChargebackSummaries,getChargebackSummariesWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); diff --git a/lib/Api/ConversionDetailsApi.php b/lib/Api/ConversionDetailsApi.php index e863a2a86..404174b84 100644 --- a/lib/Api/ConversionDetailsApi.php +++ b/lib/Api/ConversionDetailsApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * ConversionDetailsApi Class Doc Comment @@ -170,6 +172,18 @@ public function getConversionDetailWithHttpInfo($startTime, $endTime, $organizat } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getConversionDetail,getConversionDetailWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); diff --git a/lib/Api/CreateNewWebhooksApi.php b/lib/Api/CreateNewWebhooksApi.php index 262356c65..09886c988 100644 --- a/lib/Api/CreateNewWebhooksApi.php +++ b/lib/Api/CreateNewWebhooksApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * CreateNewWebhooksApi Class Doc Comment @@ -153,6 +155,18 @@ public function createWebhookSubscriptionWithHttpInfo($createWebhookRequest = nu } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "createWebhookSubscription,createWebhookSubscriptionWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -261,6 +275,18 @@ public function findProductsToSubscribeWithHttpInfo($organizationId) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "findProductsToSubscribe,findProductsToSubscribeWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); @@ -391,6 +417,18 @@ public function saveSymEgressKeyWithHttpInfo($vCSenderOrganizationId, $vCPermiss } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "saveSymEgressKey,saveSymEgressKeyWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); diff --git a/lib/Api/CreditApi.php b/lib/Api/CreditApi.php index 20e344443..920be5466 100644 --- a/lib/Api/CreditApi.php +++ b/lib/Api/CreditApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * CreditApi Class Doc Comment @@ -156,6 +158,18 @@ public function createCreditWithHttpInfo($createCreditRequest) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = true; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "createCredit,createCreditWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); diff --git a/lib/Api/CustomerApi.php b/lib/Api/CustomerApi.php index 20f96b1e0..31a50f418 100644 --- a/lib/Api/CustomerApi.php +++ b/lib/Api/CustomerApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * CustomerApi Class Doc Comment @@ -163,6 +165,18 @@ public function deleteCustomerWithHttpInfo($customerId, $profileId = null) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "deleteCustomer,deleteCustomerWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : DELETE $resourcePath"); @@ -295,6 +309,18 @@ public function getCustomerWithHttpInfo($customerId, $profileId = null) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getCustomer,getCustomerWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); @@ -451,6 +477,18 @@ public function patchCustomerWithHttpInfo($customerId, $patchCustomerRequest, $p } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "patchCustomer,patchCustomerWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : PATCH $resourcePath"); @@ -590,6 +628,18 @@ public function postCustomerWithHttpInfo($postCustomerRequest, $profileId = null } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "postCustomer,postCustomerWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); diff --git a/lib/Api/CustomerPaymentInstrumentApi.php b/lib/Api/CustomerPaymentInstrumentApi.php index eae84e1c5..1a2a108f9 100644 --- a/lib/Api/CustomerPaymentInstrumentApi.php +++ b/lib/Api/CustomerPaymentInstrumentApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * CustomerPaymentInstrumentApi Class Doc Comment @@ -178,6 +180,18 @@ public function deleteCustomerPaymentInstrumentWithHttpInfo($customerId, $paymen } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "deleteCustomerPaymentInstrument,deleteCustomerPaymentInstrumentWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : DELETE $resourcePath"); @@ -329,6 +343,18 @@ public function getCustomerPaymentInstrumentWithHttpInfo($customerId, $paymentIn } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getCustomerPaymentInstrument,getCustomerPaymentInstrumentWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); @@ -477,6 +503,18 @@ public function getCustomerPaymentInstrumentsListWithHttpInfo($customerId, $prof } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getCustomerPaymentInstrumentsList,getCustomerPaymentInstrumentsListWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); @@ -650,6 +688,18 @@ public function patchCustomersPaymentInstrumentWithHttpInfo($customerId, $paymen } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "patchCustomersPaymentInstrument,patchCustomersPaymentInstrumentWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : PATCH $resourcePath"); @@ -804,6 +854,18 @@ public function postCustomerPaymentInstrumentWithHttpInfo($customerId, $postCust } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "postCustomerPaymentInstrument,postCustomerPaymentInstrumentWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); diff --git a/lib/Api/CustomerShippingAddressApi.php b/lib/Api/CustomerShippingAddressApi.php index bc051893c..2a49d42b9 100644 --- a/lib/Api/CustomerShippingAddressApi.php +++ b/lib/Api/CustomerShippingAddressApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * CustomerShippingAddressApi Class Doc Comment @@ -178,6 +180,18 @@ public function deleteCustomerShippingAddressWithHttpInfo($customerId, $shipping } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "deleteCustomerShippingAddress,deleteCustomerShippingAddressWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : DELETE $resourcePath"); @@ -329,6 +343,18 @@ public function getCustomerShippingAddressWithHttpInfo($customerId, $shippingAdd } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getCustomerShippingAddress,getCustomerShippingAddressWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); @@ -477,6 +503,18 @@ public function getCustomerShippingAddressesListWithHttpInfo($customerId, $profi } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getCustomerShippingAddressesList,getCustomerShippingAddressesListWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); @@ -650,6 +688,18 @@ public function patchCustomersShippingAddressWithHttpInfo($customerId, $shipping } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "patchCustomersShippingAddress,patchCustomersShippingAddressWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : PATCH $resourcePath"); @@ -804,6 +854,18 @@ public function postCustomerShippingAddressWithHttpInfo($customerId, $postCustom } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "postCustomerShippingAddress,postCustomerShippingAddressWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); diff --git a/lib/Api/DecisionManagerApi.php b/lib/Api/DecisionManagerApi.php index cce08adbe..93e8cf2c5 100644 --- a/lib/Api/DecisionManagerApi.php +++ b/lib/Api/DecisionManagerApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * DecisionManagerApi Class Doc Comment @@ -171,6 +173,18 @@ public function actionDecisionManagerCaseWithHttpInfo($id, $caseManagementAction } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "actionDecisionManagerCase,actionDecisionManagerCaseWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -315,6 +329,18 @@ public function addNegativeWithHttpInfo($type, $addNegativeListRequest) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "addNegative,addNegativeWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -439,6 +465,18 @@ public function commentDecisionManagerCaseWithHttpInfo($id, $caseManagementComme } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "commentDecisionManagerCase,commentDecisionManagerCaseWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -568,6 +606,18 @@ public function createBundledDecisionManagerCaseWithHttpInfo($createBundledDecis } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "createBundledDecisionManagerCase,createBundledDecisionManagerCaseWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -696,6 +746,18 @@ public function fraudUpdateWithHttpInfo($id, $fraudMarkingActionRequest) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "fraudUpdate,fraudUpdateWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); diff --git a/lib/Api/DownloadDTDApi.php b/lib/Api/DownloadDTDApi.php index b178d9c9c..4af287c10 100644 --- a/lib/Api/DownloadDTDApi.php +++ b/lib/Api/DownloadDTDApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * DownloadDTDApi Class Doc Comment @@ -157,6 +159,18 @@ public function getDTDV2WithHttpInfo($reportDefinitionNameVersion) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getDTDV2,getDTDV2WithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); diff --git a/lib/Api/DownloadXSDApi.php b/lib/Api/DownloadXSDApi.php index 0fc6bb6cc..1bcde8d4e 100644 --- a/lib/Api/DownloadXSDApi.php +++ b/lib/Api/DownloadXSDApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * DownloadXSDApi Class Doc Comment @@ -157,6 +159,18 @@ public function getXSDV2WithHttpInfo($reportDefinitionNameVersion) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getXSDV2,getXSDV2WithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); diff --git a/lib/Api/EMVTagDetailsApi.php b/lib/Api/EMVTagDetailsApi.php index aa4c618e5..26301f3fd 100644 --- a/lib/Api/EMVTagDetailsApi.php +++ b/lib/Api/EMVTagDetailsApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * EMVTagDetailsApi Class Doc Comment @@ -142,6 +144,18 @@ public function getEmvTagsWithHttpInfo() } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getEmvTags,getEmvTagsWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); @@ -247,6 +261,18 @@ public function parseEmvTagsWithHttpInfo($body) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "parseEmvTags,parseEmvTagsWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); diff --git a/lib/Api/FlexAPIApi.php b/lib/Api/FlexAPIApi.php index ee68d0bd8..91ecca045 100644 --- a/lib/Api/FlexAPIApi.php +++ b/lib/Api/FlexAPIApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * FlexAPIApi Class Doc Comment @@ -156,6 +158,18 @@ public function generateFlexAPICaptureContextWithHttpInfo($generateFlexAPICaptur } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "generateFlexAPICaptureContext,generateFlexAPICaptureContextWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); diff --git a/lib/Api/InstrumentIdentifierApi.php b/lib/Api/InstrumentIdentifierApi.php index 03c7c2195..089c383e4 100644 --- a/lib/Api/InstrumentIdentifierApi.php +++ b/lib/Api/InstrumentIdentifierApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * InstrumentIdentifierApi Class Doc Comment @@ -163,6 +165,18 @@ public function deleteInstrumentIdentifierWithHttpInfo($instrumentIdentifierId, } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "deleteInstrumentIdentifier,deleteInstrumentIdentifierWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : DELETE $resourcePath"); @@ -301,6 +315,18 @@ public function getInstrumentIdentifierWithHttpInfo($instrumentIdentifierId, $pr } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getInstrumentIdentifier,getInstrumentIdentifierWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); @@ -456,6 +482,18 @@ public function getInstrumentIdentifierPaymentInstrumentsListWithHttpInfo($instr } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getInstrumentIdentifierPaymentInstrumentsList,getInstrumentIdentifierPaymentInstrumentsListWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); @@ -621,6 +659,18 @@ public function patchInstrumentIdentifierWithHttpInfo($instrumentIdentifierId, $ } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "patchInstrumentIdentifier,patchInstrumentIdentifierWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : PATCH $resourcePath"); @@ -767,6 +817,18 @@ public function postInstrumentIdentifierWithHttpInfo($postInstrumentIdentifierRe } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "postInstrumentIdentifier,postInstrumentIdentifierWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -918,6 +980,18 @@ public function postInstrumentIdentifierEnrollmentWithHttpInfo($instrumentIdenti } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "postInstrumentIdentifierEnrollment,postInstrumentIdentifierEnrollmentWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); diff --git a/lib/Api/InterchangeClearingLevelDetailsApi.php b/lib/Api/InterchangeClearingLevelDetailsApi.php index e10bbe018..4165ab651 100644 --- a/lib/Api/InterchangeClearingLevelDetailsApi.php +++ b/lib/Api/InterchangeClearingLevelDetailsApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * InterchangeClearingLevelDetailsApi Class Doc Comment @@ -170,6 +172,18 @@ public function getInterchangeClearingLevelDetailsWithHttpInfo($startTime, $endT } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getInterchangeClearingLevelDetails,getInterchangeClearingLevelDetailsWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); diff --git a/lib/Api/InvoiceSettingsApi.php b/lib/Api/InvoiceSettingsApi.php index 732a43c88..83853a178 100644 --- a/lib/Api/InvoiceSettingsApi.php +++ b/lib/Api/InvoiceSettingsApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * InvoiceSettingsApi Class Doc Comment @@ -142,6 +144,18 @@ public function getInvoiceSettingsWithHttpInfo() } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getInvoiceSettings,getInvoiceSettingsWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); @@ -255,6 +269,18 @@ public function updateInvoiceSettingsWithHttpInfo($invoiceSettingsRequest) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "updateInvoiceSettings,updateInvoiceSettingsWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : PUT $resourcePath"); diff --git a/lib/Api/InvoicesApi.php b/lib/Api/InvoicesApi.php index 863f19730..69ad555c1 100644 --- a/lib/Api/InvoicesApi.php +++ b/lib/Api/InvoicesApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * InvoicesApi Class Doc Comment @@ -156,6 +158,18 @@ public function createInvoiceWithHttpInfo($createInvoiceRequest) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "createInvoice,createInvoiceWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -291,6 +305,18 @@ public function getAllInvoicesWithHttpInfo($offset, $limit, $status = null) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getAllInvoices,getAllInvoicesWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); @@ -412,6 +438,18 @@ public function getInvoiceWithHttpInfo($id) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getInvoice,getInvoiceWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); @@ -530,6 +568,18 @@ public function performCancelActionWithHttpInfo($id) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "performCancelAction,performCancelActionWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -648,6 +698,18 @@ public function performSendActionWithHttpInfo($id) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "performSendAction,performSendActionWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -780,6 +842,18 @@ public function updateInvoiceWithHttpInfo($id, $updateInvoiceRequest) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "updateInvoice,updateInvoiceWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : PUT $resourcePath"); diff --git a/lib/Api/ManageWebhooksApi.php b/lib/Api/ManageWebhooksApi.php index cc6da1da9..9bb4d7a8d 100644 --- a/lib/Api/ManageWebhooksApi.php +++ b/lib/Api/ManageWebhooksApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * ManageWebhooksApi Class Doc Comment @@ -159,6 +161,18 @@ public function deleteWebhookSubscriptionWithHttpInfo($webhookId) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "deleteWebhookSubscription,deleteWebhookSubscriptionWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : DELETE $resourcePath"); @@ -263,6 +277,18 @@ public function getWebhookSubscriptionByIdWithHttpInfo($webhookId) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getWebhookSubscriptionById,getWebhookSubscriptionByIdWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); @@ -389,6 +415,18 @@ public function getWebhookSubscriptionsByOrgWithHttpInfo($organizationId, $produ } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getWebhookSubscriptionsByOrg,getWebhookSubscriptionsByOrgWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); @@ -527,6 +565,18 @@ public function saveAsymEgressKeyWithHttpInfo($vCSenderOrganizationId, $vCPermis } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "saveAsymEgressKey,saveAsymEgressKeyWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -644,6 +694,18 @@ public function updateWebhookSubscriptionWithHttpInfo($webhookId, $updateWebhook } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "updateWebhookSubscription,updateWebhookSubscriptionWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : PATCH $resourcePath"); diff --git a/lib/Api/MerchantBoardingApi.php b/lib/Api/MerchantBoardingApi.php index 7cf5a2c8a..b1dbfdc77 100644 --- a/lib/Api/MerchantBoardingApi.php +++ b/lib/Api/MerchantBoardingApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * MerchantBoardingApi Class Doc Comment @@ -157,6 +159,18 @@ public function getRegistrationWithHttpInfo($registrationId) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getRegistration,getRegistrationWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); @@ -280,6 +294,18 @@ public function postRegistrationWithHttpInfo($postRegistrationBody, $vCIdempoten } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "postRegistration,postRegistrationWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); diff --git a/lib/Api/MicroformIntegrationApi.php b/lib/Api/MicroformIntegrationApi.php index b183337c1..9eecd3612 100644 --- a/lib/Api/MicroformIntegrationApi.php +++ b/lib/Api/MicroformIntegrationApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * MicroformIntegrationApi Class Doc Comment @@ -156,6 +158,18 @@ public function generateCaptureContextWithHttpInfo($generateCaptureContextReques } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "generateCaptureContext,generateCaptureContextWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); diff --git a/lib/Api/NetFundingsApi.php b/lib/Api/NetFundingsApi.php index d6d40ec57..a9e5c563a 100644 --- a/lib/Api/NetFundingsApi.php +++ b/lib/Api/NetFundingsApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * NetFundingsApi Class Doc Comment @@ -176,6 +178,18 @@ public function getNetFundingDetailsWithHttpInfo($startTime, $endTime, $organiza } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getNetFundingDetails,getNetFundingDetailsWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); diff --git a/lib/Api/NotificationOfChangesApi.php b/lib/Api/NotificationOfChangesApi.php index 8f584c9bd..42f4c898f 100644 --- a/lib/Api/NotificationOfChangesApi.php +++ b/lib/Api/NotificationOfChangesApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * NotificationOfChangesApi Class Doc Comment @@ -164,6 +166,18 @@ public function getNotificationOfChangeReportWithHttpInfo($startTime, $endTime) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getNotificationOfChangeReport,getNotificationOfChangeReportWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); diff --git a/lib/Api/OrdersApi.php b/lib/Api/OrdersApi.php index 2729c0172..6eef2097e 100644 --- a/lib/Api/OrdersApi.php +++ b/lib/Api/OrdersApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * OrdersApi Class Doc Comment @@ -156,6 +158,18 @@ public function createOrderWithHttpInfo($createOrderRequest) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "createOrder,createOrderWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -284,6 +298,18 @@ public function updateOrderWithHttpInfo($id, $updateOrderRequest) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "updateOrder,updateOrderWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : PATCH $resourcePath"); diff --git a/lib/Api/PayerAuthenticationApi.php b/lib/Api/PayerAuthenticationApi.php index 248609e81..e75c20e84 100644 --- a/lib/Api/PayerAuthenticationApi.php +++ b/lib/Api/PayerAuthenticationApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * PayerAuthenticationApi Class Doc Comment @@ -156,6 +158,18 @@ public function checkPayerAuthEnrollmentWithHttpInfo($checkPayerAuthEnrollmentRe } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = true; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "checkPayerAuthEnrollment,checkPayerAuthEnrollmentWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -269,6 +283,18 @@ public function payerAuthSetupWithHttpInfo($payerAuthSetupRequest) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = true; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "payerAuthSetup,payerAuthSetupWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -382,6 +408,18 @@ public function validateAuthenticationResultsWithHttpInfo($validateRequest) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = true; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "validateAuthenticationResults,validateAuthenticationResultsWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); diff --git a/lib/Api/PaymentBatchSummariesApi.php b/lib/Api/PaymentBatchSummariesApi.php index a1ddd0bf7..eb5a2f66c 100644 --- a/lib/Api/PaymentBatchSummariesApi.php +++ b/lib/Api/PaymentBatchSummariesApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * PaymentBatchSummariesApi Class Doc Comment @@ -188,6 +190,18 @@ public function getPaymentBatchSummaryWithHttpInfo($startTime, $endTime, $organi } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getPaymentBatchSummary,getPaymentBatchSummaryWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); diff --git a/lib/Api/PaymentInstrumentApi.php b/lib/Api/PaymentInstrumentApi.php index 9d3333161..407eba497 100644 --- a/lib/Api/PaymentInstrumentApi.php +++ b/lib/Api/PaymentInstrumentApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * PaymentInstrumentApi Class Doc Comment @@ -163,6 +165,18 @@ public function deletePaymentInstrumentWithHttpInfo($paymentInstrumentId, $profi } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "deletePaymentInstrument,deletePaymentInstrumentWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : DELETE $resourcePath"); @@ -297,6 +311,18 @@ public function getPaymentInstrumentWithHttpInfo($paymentInstrumentId, $profileI } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getPaymentInstrument,getPaymentInstrumentWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); @@ -460,6 +486,18 @@ public function patchPaymentInstrumentWithHttpInfo($paymentInstrumentId, $patchP } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "patchPaymentInstrument,patchPaymentInstrumentWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : PATCH $resourcePath"); @@ -606,6 +644,18 @@ public function postPaymentInstrumentWithHttpInfo($postPaymentInstrumentRequest, } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "postPaymentInstrument,postPaymentInstrumentWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); diff --git a/lib/Api/PaymentsApi.php b/lib/Api/PaymentsApi.php index 06c2ca899..28d0d6347 100644 --- a/lib/Api/PaymentsApi.php +++ b/lib/Api/PaymentsApi.php @@ -173,6 +173,18 @@ public function createOrderRequestWithHttpInfo($orderPaymentRequest, $id) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = true; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "createOrderRequest,createOrderRequestWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -286,7 +298,7 @@ public function createPaymentWithHttpInfo($createPaymentRequest) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } - + //MLE check and mle encryption for req body $isMLESupportedByCybsForApi = true; if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "createPayment,createPaymentWithHttpInfo")) { @@ -298,7 +310,7 @@ public function createPaymentWithHttpInfo($createPaymentRequest) } } - + // Logging self::$logger->debug("Resource : POST $resourcePath"); if (isset($httpBody)) { @@ -411,6 +423,18 @@ public function createSessionRequestWithHttpInfo($createSessionReq) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = true; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "createSessionRequest,createSessionRequestWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -539,6 +563,18 @@ public function incrementAuthWithHttpInfo($id, $incrementAuthRequest) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = true; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "incrementAuth,incrementAuthWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : PATCH $resourcePath"); @@ -667,6 +703,18 @@ public function refreshPaymentStatusWithHttpInfo($id, $refreshPaymentStatusReque } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = true; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "refreshPaymentStatus,refreshPaymentStatusWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -795,6 +843,18 @@ public function updateSessionReqWithHttpInfo($createSessionRequest, $id) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = true; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "updateSessionReq,updateSessionReqWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : PATCH $resourcePath"); diff --git a/lib/Api/PayoutsApi.php b/lib/Api/PayoutsApi.php index 2930cc156..c9f7c787f 100644 --- a/lib/Api/PayoutsApi.php +++ b/lib/Api/PayoutsApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * PayoutsApi Class Doc Comment @@ -156,6 +158,18 @@ public function octCreatePaymentWithHttpInfo($octCreatePaymentRequest) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = true; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "octCreatePayment,octCreatePaymentWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); diff --git a/lib/Api/PlansApi.php b/lib/Api/PlansApi.php index b148cfce6..87d57c1d9 100644 --- a/lib/Api/PlansApi.php +++ b/lib/Api/PlansApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * PlansApi Class Doc Comment @@ -157,6 +159,18 @@ public function activatePlanWithHttpInfo($id) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "activatePlan,activatePlanWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -274,6 +288,18 @@ public function createPlanWithHttpInfo($createPlanRequest) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "createPlan,createPlanWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -388,6 +414,18 @@ public function deactivatePlanWithHttpInfo($id) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "deactivatePlan,deactivatePlanWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -506,6 +544,18 @@ public function deletePlanWithHttpInfo($id) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "deletePlan,deletePlanWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : DELETE $resourcePath"); @@ -624,6 +674,18 @@ public function getPlanWithHttpInfo($id) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getPlan,getPlanWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); @@ -727,6 +789,18 @@ public function getPlanCodeWithHttpInfo() } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getPlanCode,getPlanCodeWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); @@ -856,6 +930,18 @@ public function getPlansWithHttpInfo($offset = null, $limit = null, $code = null } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getPlans,getPlansWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); @@ -989,6 +1075,18 @@ public function updatePlanWithHttpInfo($id, $updatePlanRequest) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "updatePlan,updatePlanWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : PATCH $resourcePath"); diff --git a/lib/Api/PurchaseAndRefundDetailsApi.php b/lib/Api/PurchaseAndRefundDetailsApi.php index 8d065db76..2b61e903d 100644 --- a/lib/Api/PurchaseAndRefundDetailsApi.php +++ b/lib/Api/PurchaseAndRefundDetailsApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * PurchaseAndRefundDetailsApi Class Doc Comment @@ -200,6 +202,18 @@ public function getPurchaseAndRefundDetailsWithHttpInfo($startTime, $endTime, $o } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getPurchaseAndRefundDetails,getPurchaseAndRefundDetailsWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); diff --git a/lib/Api/PushFundsApi.php b/lib/Api/PushFundsApi.php index 302989416..f6c6f0005 100644 --- a/lib/Api/PushFundsApi.php +++ b/lib/Api/PushFundsApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * PushFundsApi Class Doc Comment @@ -222,6 +224,18 @@ public function createPushFundsTransferWithHttpInfo($pushFundsRequest, $contentT } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = true; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "createPushFundsTransfer,createPushFundsTransferWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); diff --git a/lib/Api/RefundApi.php b/lib/Api/RefundApi.php index 45005905f..43b6249b6 100644 --- a/lib/Api/RefundApi.php +++ b/lib/Api/RefundApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * RefundApi Class Doc Comment @@ -171,6 +173,18 @@ public function refundCaptureWithHttpInfo($refundCaptureRequest, $id) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = true; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "refundCapture,refundCaptureWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -299,6 +313,18 @@ public function refundPaymentWithHttpInfo($refundPaymentRequest, $id) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = true; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "refundPayment,refundPaymentWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); diff --git a/lib/Api/ReplayWebhooksApi.php b/lib/Api/ReplayWebhooksApi.php index 71bff8e91..4d3fc0bb8 100644 --- a/lib/Api/ReplayWebhooksApi.php +++ b/lib/Api/ReplayWebhooksApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * ReplayWebhooksApi Class Doc Comment @@ -168,6 +170,18 @@ public function replayPreviousWebhooksWithHttpInfo($webhookId, $replayWebhooksRe } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "replayPreviousWebhooks,replayPreviousWebhooksWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); diff --git a/lib/Api/ReportDefinitionsApi.php b/lib/Api/ReportDefinitionsApi.php index 7aa7d638a..ee40ea70d 100644 --- a/lib/Api/ReportDefinitionsApi.php +++ b/lib/Api/ReportDefinitionsApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * ReportDefinitionsApi Class Doc Comment @@ -175,6 +177,18 @@ public function getResourceInfoByReportDefinitionWithHttpInfo($reportDefinitionN } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getResourceInfoByReportDefinition,getResourceInfoByReportDefinitionWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); @@ -285,6 +299,18 @@ public function getResourceV2InfoWithHttpInfo($subscriptionType = null, $organiz } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getResourceV2Info,getResourceV2InfoWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); diff --git a/lib/Api/ReportDownloadsApi.php b/lib/Api/ReportDownloadsApi.php index 0b34079bc..147063d58 100644 --- a/lib/Api/ReportDownloadsApi.php +++ b/lib/Api/ReportDownloadsApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * ReportDownloadsApi Class Doc Comment @@ -170,6 +172,18 @@ public function downloadReportWithHttpInfo($reportDate, $reportName, $organizati } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "downloadReport,downloadReportWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); diff --git a/lib/Api/ReportSubscriptionsApi.php b/lib/Api/ReportSubscriptionsApi.php index 253d8102e..2561f944c 100644 --- a/lib/Api/ReportSubscriptionsApi.php +++ b/lib/Api/ReportSubscriptionsApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * ReportSubscriptionsApi Class Doc Comment @@ -162,6 +164,18 @@ public function createStandardOrClassicSubscriptionWithHttpInfo($predefinedSubsc } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "createStandardOrClassicSubscription,createStandardOrClassicSubscriptionWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : PUT $resourcePath"); @@ -274,6 +288,18 @@ public function createSubscriptionWithHttpInfo($createReportSubscriptionRequest, } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "createSubscription,createSubscriptionWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : PUT $resourcePath"); @@ -387,6 +413,18 @@ public function deleteSubscriptionWithHttpInfo($reportName, $organizationId = nu } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "deleteSubscription,deleteSubscriptionWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : DELETE $resourcePath"); @@ -489,6 +527,18 @@ public function getAllSubscriptionsWithHttpInfo($organizationId = null) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getAllSubscriptions,getAllSubscriptionsWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); @@ -606,6 +656,18 @@ public function getSubscriptionWithHttpInfo($reportName, $organizationId = null) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getSubscription,getSubscriptionWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); diff --git a/lib/Api/ReportsApi.php b/lib/Api/ReportsApi.php index 7e419350b..f9689cf0b 100644 --- a/lib/Api/ReportsApi.php +++ b/lib/Api/ReportsApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * ReportsApi Class Doc Comment @@ -162,6 +164,18 @@ public function createReportWithHttpInfo($createAdhocReportRequest, $organizatio } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "createReport,createReportWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -275,6 +289,18 @@ public function getReportByReportIdWithHttpInfo($reportId, $organizationId = nul } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getReportByReportId,getReportByReportIdWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); @@ -440,6 +466,18 @@ public function searchReportsWithHttpInfo($startTime, $endTime, $timeQueryType, } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "searchReports,searchReportsWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); diff --git a/lib/Api/RetrievalDetailsApi.php b/lib/Api/RetrievalDetailsApi.php index 832d7ae40..e26a6e23c 100644 --- a/lib/Api/RetrievalDetailsApi.php +++ b/lib/Api/RetrievalDetailsApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * RetrievalDetailsApi Class Doc Comment @@ -170,6 +172,18 @@ public function getRetrievalDetailsWithHttpInfo($startTime, $endTime, $organizat } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getRetrievalDetails,getRetrievalDetailsWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); diff --git a/lib/Api/RetrievalSummariesApi.php b/lib/Api/RetrievalSummariesApi.php index 1a03bd7e1..65971b460 100644 --- a/lib/Api/RetrievalSummariesApi.php +++ b/lib/Api/RetrievalSummariesApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * RetrievalSummariesApi Class Doc Comment @@ -170,6 +172,18 @@ public function getRetrievalSummaryWithHttpInfo($startTime, $endTime, $organizat } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getRetrievalSummary,getRetrievalSummaryWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); diff --git a/lib/Api/ReversalApi.php b/lib/Api/ReversalApi.php index 56cb79aaf..b90dfc3d8 100644 --- a/lib/Api/ReversalApi.php +++ b/lib/Api/ReversalApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * ReversalApi Class Doc Comment @@ -171,6 +173,18 @@ public function authReversalWithHttpInfo($id, $authReversalRequest) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = true; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "authReversal,authReversalWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -284,6 +298,18 @@ public function mitReversalWithHttpInfo($mitReversalRequest) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = true; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "mitReversal,mitReversalWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); diff --git a/lib/Api/SearchTransactionsApi.php b/lib/Api/SearchTransactionsApi.php index 8f7fc0afb..c6efdc5e2 100644 --- a/lib/Api/SearchTransactionsApi.php +++ b/lib/Api/SearchTransactionsApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * SearchTransactionsApi Class Doc Comment @@ -156,6 +158,18 @@ public function createSearchWithHttpInfo($createSearchRequest) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "createSearch,createSearchWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -270,6 +284,18 @@ public function getSearchWithHttpInfo($searchId) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getSearch,getSearchWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); diff --git a/lib/Api/SecureFileShareApi.php b/lib/Api/SecureFileShareApi.php index b2ff2cec5..7420236d6 100644 --- a/lib/Api/SecureFileShareApi.php +++ b/lib/Api/SecureFileShareApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * SecureFileShareApi Class Doc Comment @@ -163,6 +165,18 @@ public function getFileWithHttpInfo($fileId, $organizationId = null) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getFile,getFileWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); @@ -289,6 +303,18 @@ public function getFileDetailWithHttpInfo($startDate, $endDate, $organizationId } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getFileDetail,getFileDetailWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); diff --git a/lib/Api/SubscriptionsApi.php b/lib/Api/SubscriptionsApi.php index 2cd452fae..139bce9fe 100644 --- a/lib/Api/SubscriptionsApi.php +++ b/lib/Api/SubscriptionsApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * SubscriptionsApi Class Doc Comment @@ -157,6 +159,18 @@ public function activateSubscriptionWithHttpInfo($id) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "activateSubscription,activateSubscriptionWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -275,6 +289,18 @@ public function cancelSubscriptionWithHttpInfo($id) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "cancelSubscription,cancelSubscriptionWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -392,6 +418,18 @@ public function createSubscriptionWithHttpInfo($createSubscriptionRequest) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "createSubscription,createSubscriptionWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -515,6 +553,18 @@ public function getAllSubscriptionsWithHttpInfo($offset = null, $limit = null, $ } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getAllSubscriptions,getAllSubscriptionsWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); @@ -633,6 +683,18 @@ public function getSubscriptionWithHttpInfo($id) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getSubscription,getSubscriptionWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); @@ -736,6 +798,18 @@ public function getSubscriptionCodeWithHttpInfo() } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getSubscriptionCode,getSubscriptionCodeWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); @@ -850,6 +924,18 @@ public function suspendSubscriptionWithHttpInfo($id) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "suspendSubscription,suspendSubscriptionWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -982,6 +1068,18 @@ public function updateSubscriptionWithHttpInfo($id, $updateSubscription) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "updateSubscription,updateSubscriptionWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : PATCH $resourcePath"); diff --git a/lib/Api/TaxesApi.php b/lib/Api/TaxesApi.php index f05101ac6..4b5809a84 100644 --- a/lib/Api/TaxesApi.php +++ b/lib/Api/TaxesApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * TaxesApi Class Doc Comment @@ -156,6 +158,18 @@ public function calculateTaxWithHttpInfo($taxRequest) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "calculateTax,calculateTaxWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -284,6 +298,18 @@ public function voidTaxWithHttpInfo($voidTaxRequest, $id) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "voidTax,voidTaxWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : PATCH $resourcePath"); diff --git a/lib/Api/TokenApi.php b/lib/Api/TokenApi.php index 16db649a4..a035a9d7d 100644 --- a/lib/Api/TokenApi.php +++ b/lib/Api/TokenApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * TokenApi Class Doc Comment @@ -177,6 +179,18 @@ public function postTokenPaymentCredentialsWithHttpInfo($tokenId, $postPaymentCr } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "postTokenPaymentCredentials,postTokenPaymentCredentialsWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); diff --git a/lib/Api/TransactionBatchesApi.php b/lib/Api/TransactionBatchesApi.php index 49cee3d3e..66397f4a3 100644 --- a/lib/Api/TransactionBatchesApi.php +++ b/lib/Api/TransactionBatchesApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * TransactionBatchesApi Class Doc Comment @@ -169,6 +171,18 @@ public function getTransactionBatchDetailsWithHttpInfo($id, $uploadDate = null, } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getTransactionBatchDetails,getTransactionBatchDetailsWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); @@ -293,6 +307,18 @@ public function getTransactionBatchIdWithHttpInfo($id) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getTransactionBatchId,getTransactionBatchIdWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); @@ -426,6 +452,18 @@ public function getTransactionBatchesWithHttpInfo($startTime, $endTime) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getTransactionBatches,getTransactionBatchesWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); diff --git a/lib/Api/TransactionDetailsApi.php b/lib/Api/TransactionDetailsApi.php index 00693dd31..9032ac5a3 100644 --- a/lib/Api/TransactionDetailsApi.php +++ b/lib/Api/TransactionDetailsApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * TransactionDetailsApi Class Doc Comment @@ -157,6 +159,18 @@ public function getTransactionWithHttpInfo($id) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getTransaction,getTransactionWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); diff --git a/lib/Api/TransientTokenDataApi.php b/lib/Api/TransientTokenDataApi.php index 64ac8b2e5..6636118fa 100644 --- a/lib/Api/TransientTokenDataApi.php +++ b/lib/Api/TransientTokenDataApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * TransientTokenDataApi Class Doc Comment @@ -157,6 +159,18 @@ public function getPaymentCredentialsForTransientTokenWithHttpInfo($paymentCrede } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getPaymentCredentialsForTransientToken,getPaymentCredentialsForTransientTokenWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); @@ -263,6 +277,18 @@ public function getTransactionForTransientTokenWithHttpInfo($transientToken) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getTransactionForTransientToken,getTransactionForTransientTokenWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); diff --git a/lib/Api/UnifiedCheckoutCaptureContextApi.php b/lib/Api/UnifiedCheckoutCaptureContextApi.php index 5e22f4ac4..b24e274d6 100644 --- a/lib/Api/UnifiedCheckoutCaptureContextApi.php +++ b/lib/Api/UnifiedCheckoutCaptureContextApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * UnifiedCheckoutCaptureContextApi Class Doc Comment @@ -156,6 +158,18 @@ public function generateUnifiedCheckoutCaptureContextWithHttpInfo($generateUnifi } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "generateUnifiedCheckoutCaptureContext,generateUnifiedCheckoutCaptureContextWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); diff --git a/lib/Api/UserManagementApi.php b/lib/Api/UserManagementApi.php index 269587f53..eea9bf047 100644 --- a/lib/Api/UserManagementApi.php +++ b/lib/Api/UserManagementApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * UserManagementApi Class Doc Comment @@ -166,6 +168,18 @@ public function getUsersWithHttpInfo($organizationId = null, $userName = null, $ } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "getUsers,getUsersWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : GET $resourcePath"); diff --git a/lib/Api/UserManagementSearchApi.php b/lib/Api/UserManagementSearchApi.php index 43dd41802..ee6909f19 100644 --- a/lib/Api/UserManagementSearchApi.php +++ b/lib/Api/UserManagementSearchApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * UserManagementSearchApi Class Doc Comment @@ -156,6 +158,18 @@ public function searchUsersWithHttpInfo($searchRequest) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "searchUsers,searchUsersWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); diff --git a/lib/Api/VerificationApi.php b/lib/Api/VerificationApi.php index dc2ab6046..f95bd475d 100644 --- a/lib/Api/VerificationApi.php +++ b/lib/Api/VerificationApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * VerificationApi Class Doc Comment @@ -156,6 +158,18 @@ public function validateExportComplianceWithHttpInfo($validateExportComplianceRe } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "validateExportCompliance,validateExportComplianceWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -269,6 +283,18 @@ public function verifyCustomerAddressWithHttpInfo($verifyCustomerAddressRequest) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = false; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "verifyCustomerAddress,verifyCustomerAddressWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); diff --git a/lib/Api/VoidApi.php b/lib/Api/VoidApi.php index bddbf83e1..f27617367 100644 --- a/lib/Api/VoidApi.php +++ b/lib/Api/VoidApi.php @@ -32,6 +32,8 @@ use \CyberSource\Configuration; use \CyberSource\ObjectSerializer; use \CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Authentication\Util\MLEUtility; +use \Exception; /** * VoidApi Class Doc Comment @@ -156,6 +158,18 @@ public function mitVoidWithHttpInfo($mitVoidRequest) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = true; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "mitVoid,mitVoidWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -284,6 +298,18 @@ public function voidCaptureWithHttpInfo($voidCaptureRequest, $id) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = true; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "voidCapture,voidCaptureWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -412,6 +438,18 @@ public function voidCreditWithHttpInfo($voidCreditRequest, $id) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = true; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "voidCredit,voidCreditWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -540,6 +578,18 @@ public function voidPaymentWithHttpInfo($voidPaymentRequest, $id) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = true; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "voidPayment,voidPaymentWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); @@ -668,6 +718,18 @@ public function voidRefundWithHttpInfo($voidRefundRequest, $id) } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } + + //MLE check and mle encryption for req body + $isMLESupportedByCybsForApi = true; + if (MLEUtility::checkIsMLEForAPI($this->apiClient->merchantConfig, $isMLESupportedByCybsForApi, "voidRefund,voidRefundWithHttpInfo")) { + try { + $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); + } catch (Exception $e) { + self::$logger->error("Failed to encrypt request body: $e"); + throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + } + } + // Logging self::$logger->debug("Resource : POST $resourcePath"); From be1177a11b61b4c0d9f7595b6377f3d0f5f0aa00 Mon Sep 17 00:00:00 2001 From: gaubansa Date: Fri, 31 Jan 2025 13:23:24 +0530 Subject: [PATCH 06/23] adding checkIsMLEForAPI implementation --- lib/Authentication/Util/MLEUtility.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/Authentication/Util/MLEUtility.php b/lib/Authentication/Util/MLEUtility.php index 695221053..3094a8cb0 100644 --- a/lib/Authentication/Util/MLEUtility.php +++ b/lib/Authentication/Util/MLEUtility.php @@ -10,7 +10,23 @@ class MLEUtility public static function checkIsMLEForAPI($merchantConfig, $isMLESupportedByCybsForApi, $operationIds) { $isMLEForAPI = false; - //complete the function logic + // Check here useMLEGlobally True or False + if ($isMLESupportedByCybsForApi && $merchantConfig->getUseMLEGlobally()) { + $isMLEForAPI = true; + } + + // Operation IDs are array as there are multiple public functions for apiCallFunction such as apiCall, apiCallAsync .. + $operationArray = array_map('trim', explode(',', $operationIds)); + + // Control the MLE only from map + if (!empty($merchantConfig->getMapToControlMLEonAPI())) { + foreach ($operationArray as $operationId) { + if (array_key_exists($operationId, $merchantConfig->getMapToControlMLEonAPI())) { + $isMLEForAPI = $merchantConfig->getMapToControlMLEonAPI()[$operationId]; + break; + } + } + } return $isMLEForAPI; } From 8e4b7b82dc9942fe5c40c164ed301ff220f22ad9 Mon Sep 17 00:00:00 2001 From: gaubansa Date: Fri, 31 Jan 2025 13:26:29 +0530 Subject: [PATCH 07/23] correcting comment --- lib/Authentication/Util/MLEUtility.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Authentication/Util/MLEUtility.php b/lib/Authentication/Util/MLEUtility.php index 3094a8cb0..07a212a7f 100644 --- a/lib/Authentication/Util/MLEUtility.php +++ b/lib/Authentication/Util/MLEUtility.php @@ -15,7 +15,7 @@ public static function checkIsMLEForAPI($merchantConfig, $isMLESupportedByCybsFo $isMLEForAPI = true; } - // Operation IDs are array as there are multiple public functions for apiCallFunction such as apiCall, apiCallAsync .. + // Operation IDs are array as there are multiple public functions for apiCallFunction such as apiCall, apiCallWithHttpInfo .. $operationArray = array_map('trim', explode(',', $operationIds)); // Control the MLE only from map From 73542f3b9d41743800ec0503ca08f8b737660c8f Mon Sep 17 00:00:00 2001 From: mahmishr Date: Thu, 20 Feb 2025 11:44:31 +0530 Subject: [PATCH 08/23] "python SDK MLE implementation" --- lib/Authentication/Util/GlobalParameter.php | 1 + lib/Authentication/Util/MLEException.php | 20 +++ lib/Authentication/Util/MLEUtility.php | 179 +++++++++++++++++++- lib/Authentication/Util/Utility.php | 60 +++++++ 4 files changed, 253 insertions(+), 7 deletions(-) create mode 100644 lib/Authentication/Util/MLEException.php create mode 100644 lib/Authentication/Util/Utility.php diff --git a/lib/Authentication/Util/GlobalParameter.php b/lib/Authentication/Util/GlobalParameter.php index f75969fe5..ce4f25b2f 100644 --- a/lib/Authentication/Util/GlobalParameter.php +++ b/lib/Authentication/Util/GlobalParameter.php @@ -104,6 +104,7 @@ class GlobalParameter const REQTYPE = "RequestType "; const KEYFILEFIELDDIR = "keysDirectory "; const DEFAULT_MLE_ALIAS_FOR_CERT = "CyberSource_SJC_US"; + const CERTIFICATE_EXPIRY_DATE_WARNING_DAYS = 90; const MLE_AUTH_ERROR = "MLE is only supported in JWT auth type"; } ?> \ No newline at end of file diff --git a/lib/Authentication/Util/MLEException.php b/lib/Authentication/Util/MLEException.php new file mode 100644 index 000000000..1c86968af --- /dev/null +++ b/lib/Authentication/Util/MLEException.php @@ -0,0 +1,20 @@ +getLogger(\CyberSource\Utilities\Helpers\ClassHelper::getClassName(get_class()), $logConfig); + } + + } + public static function checkIsMLEForAPI($merchantConfig, $isMLESupportedByCybsForApi, $operationIds) { $isMLEForAPI = false; - // Check here useMLEGlobally True or False + if ($isMLESupportedByCybsForApi && $merchantConfig->getUseMLEGlobally()) { $isMLEForAPI = true; } - // Operation IDs are array as there are multiple public functions for apiCallFunction such as apiCall, apiCallWithHttpInfo .. $operationArray = array_map('trim', explode(',', $operationIds)); - // Control the MLE only from map - if (!empty($merchantConfig->getMapToControlMLEonAPI())) { + if (!empty($merchantConfig->getMapToControlMLEonAPI()) && is_array($merchantConfig->getMapToControlMLEonAPI())) { foreach ($operationArray as $operationId) { if (array_key_exists($operationId, $merchantConfig->getMapToControlMLEonAPI())) { $isMLEForAPI = $merchantConfig->getMapToControlMLEonAPI()[$operationId]; @@ -31,10 +54,152 @@ public static function checkIsMLEForAPI($merchantConfig, $isMLESupportedByCybsFo } public static function encryptRequestPayload($merchantConfig, $requestBody) { - // implement encrpty payload function - return $requestBody; + if (self::$logger === null) { + self::initializeLogger($merchantConfig->getLogConfiguration()); + } + + $cert = self::getMLECert($merchantConfig); + + if ($merchantConfig->getLogConfiguration()->isMaskingEnabled()) { + $printRequestBody = \CyberSource\Utilities\Helpers\DataMasker::maskData($requestBody); + } else { + $printRequestBody = $requestBody; + } + + self::$logger->debug("Request before MLE:\n" . print_r($printRequestBody, true)); + + $jweToken = self::generateToken($cert, $requestBody); + $mleRequest = json_encode(['encryptedRequest' => $jweToken]); + + self::$logger->debug("Request after MLE:\n" . print_r($mleRequest, true)); + // self::$logger->close(); + return $mleRequest; + } + + + private static function generateToken($cert, $requestBody) { + try { + $serialNumber = self::extractSerialNumber($cert); + + $publicKey = openssl_pkey_get_details(openssl_pkey_get_public($cert))['key']; + + $jwk = JWKFactory::createFromKey($publicKey, null, [ + 'kid' => $serialNumber, + ]); + + $header = [ + 'alg' => 'RSA-OAEP-256', + 'enc' => 'A256GCM', + 'cty' => 'JWT', + 'kid' => $serialNumber, + 'iat' => time(), + ]; + + $algorithmManager = new AlgorithmManager([ + new RSAOAEP256(), + new A256GCM() + ]); + + $compressionManager = new CompressionMethodManager([ + new Deflate() + ]); + + $jweBuilder = new JWEBuilder( + $algorithmManager, + $algorithmManager, + $compressionManager + ); + + $jwe = $jweBuilder + ->create() + ->withPayload($requestBody) + ->withSharedProtectedHeader($header) + ->addRecipient($jwk) + ->build(); + + $serializer = new CompactSerializer(); + return $serializer->serialize($jwe); + } catch (\Exception $e) { + self::$logger->error("Error encrypting request payload: " . $e->getMessage()); + throw new MLEException("Error encrypting request payload: " . $e->getMessage()); + } + } + + public static function getMLECert($merchantConfig) + { + try { + if (!isset(self::$cache)) { + self::$cache = new Cache(); + } + + $keyPass = $merchantConfig->getKeyPassword(); + if (empty($keyPass)) { + $keyPass = $merchantID; + } + $mleKeyAlias = $merchantConfig->getMleKeyAlias(); + + $cacheCertStore = Utility::fetchCertFromCache(self::$cache, $merchantConfig); + + $certs = []; + $x509Cert = null; + if (openssl_pkcs12_read($cacheCertStore, $certs, $keyPass)) { + $x509Cert = Utility::findCertByAlias($certs, $mleKeyAlias); + } + + if ($x509Cert) { + self::validateCertificateExpiry($x509Cert, $merchantConfig->getMleKeyAlias()); + return $x509Cert; + } else { + throw new MLEException("Certificate with alias $mleKeyAlias not found."); + } + } catch (\Exception $e) { + self::$logger->error("Error fetching MLE certificate: " . $e->getMessage()); + throw new MLEException("Error fetching MLE certificate: " . $e->getMessage()); + } } + public static function extractSerialNumber($cert) + { + try { + $certDetails = openssl_x509_parse($cert); + $serialNumber = null; + if (isset($certDetails['subject']['serialNumber'])) { + $serialNumber = $certDetails['subject']['serialNumber']; + } + + if ($serialNumber === null) { + self::$logger->warning("Serial number not found in MLE certificate for alias."); + // this will be in hexdec is it fine? + $serialNumber = $certDetails['serialNumber']; + } + return $serialNumber; + } catch (\Exception $e) { + self::$logger->error("Error extracting serial number from certificate: " . $e->getMessage()); + throw new MLEException("Error extracting serial number from certificate: " . $e->getMessage()); + } + } + + public static function validateCertificateExpiry($certificate, $keyAlias) { + try { + $certDetails = openssl_x509_parse($certificate); + $notValidAfter = $certDetails['validTo_time_t']; + + if ($notValidAfter < time()) { + self::$logger->warning("Certificate with MLE alias $keyAlias is expired as of " . date('Y-m-d H:i:s', $notValidAfter) . ". Please update p12 file."); + // throw new MLEException("Certificate with MLE alias $keyAlias is expired."); + } else { + $timeToExpire = $notValidAfter - time(); + $warningPeriod = GlobalLabelParameters::CERTIFICATE_EXPIRY_DATE_WARNING_DAYS * 24 * 60 * 60; + + if ($timeToExpire < $warningPeriod) { + self::$logger->warning("Certificate for MLE with alias $keyAlias is going to expire on " . date('Y-m-d H:i:s', $notValidAfter) . ". Please update p12 file before that."); + } + } + } catch (Exception $e) { + self::$logger->error("Error while checking certificate expiry: " . $e->getMessage()); + throw new MLEException("Error while checking certificate expiry: " . $e->getMessage()); + } + } } ?> \ No newline at end of file diff --git a/lib/Authentication/Util/Utility.php b/lib/Authentication/Util/Utility.php new file mode 100644 index 000000000..bb85cb727 --- /dev/null +++ b/lib/Authentication/Util/Utility.php @@ -0,0 +1,60 @@ +getMerchantID(); + $keyFileName = $merchantConfig->getKeyFileName(); + $keyDir = $merchantConfig->getKeysDirectory(); + + if (empty($keyFileName)) { + $keyFileName = $merchantID; + } + + if (empty($keyDir)) { + $keyDir = GlobalParameter::KEY_DIR_PATH_DEFAULT; + } + + $filePath = $keyDir . $keyFileName . ".p12"; + + // Get certificate from p12 + if (file_exists($filePath)) { + $certStore = file_get_contents($filePath); + $cacheKey = $keyFileName . "_" . strtotime(date("F d Y H:i:s", filemtime($filePath))); + } else { + throw new AuthException(GlobalParameter::KEY_FILE_INCORRECT, 0); + } + + $cacheCertStore = $cache->fetchFromCache($cacheKey); + if ($cacheCertStore == false) { + $cache->storeInCache($cacheKey, $certStore); + $cacheCertStore = $cache->fetchFromCache($cacheKey); + } + return $cacheCertStore; + } + + public static function findCertByAlias($certs, $keyAlias) + { + if (isset($certs['cert'])) { + $certData = openssl_x509_parse($certs['cert'], 1); + if (isset($certData['subject']['CN']) && $certData['subject']['CN'] === $keyAlias) { + return $certs['cert']; + } + } + + if (isset($certs['extracerts']) && is_array($certs['extracerts'])) { + foreach ($certs['extracerts'] as $cert) { + $certData = openssl_x509_parse($cert, 1); + if (isset($certData['subject']['CN']) && $certData['subject']['CN'] === $keyAlias) { + return $cert; + } + } + } + + throw new \Exception("Certificate with alias $keyAlias not found."); + } +} +?> \ No newline at end of file From e1a7030fbc06037f6c8a1c2e42c93bafe6ff7668 Mon Sep 17 00:00:00 2001 From: mahmishr Date: Thu, 20 Feb 2025 12:25:44 +0530 Subject: [PATCH 09/23] "loggers" --- lib/Authentication/Util/MLEUtility.php | 49 +++++++++++--------------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/lib/Authentication/Util/MLEUtility.php b/lib/Authentication/Util/MLEUtility.php index cf93643bb..037afccbd 100644 --- a/lib/Authentication/Util/MLEUtility.php +++ b/lib/Authentication/Util/MLEUtility.php @@ -22,17 +22,9 @@ class MLEUtility { - private static $logger = null; + private $logger = null; private static $cache = null; - private static function initializeLogger(LogConfiguration $logConfig) - { - if (self::$logger === null) { - self::$logger = (new LogFactory())->getLogger(\CyberSource\Utilities\Helpers\ClassHelper::getClassName(get_class()), $logConfig); - } - - } - public static function checkIsMLEForAPI($merchantConfig, $isMLESupportedByCybsForApi, $operationIds) { $isMLEForAPI = false; @@ -54,11 +46,10 @@ public static function checkIsMLEForAPI($merchantConfig, $isMLESupportedByCybsFo } public static function encryptRequestPayload($merchantConfig, $requestBody) { - if (self::$logger === null) { - self::initializeLogger($merchantConfig->getLogConfiguration()); - } - $cert = self::getMLECert($merchantConfig); + $logger = (new LogFactory())->getLogger(\CyberSource\Utilities\Helpers\ClassHelper::getClassName(get_class()), $merchantConfig->getLogConfiguration()); + + $cert = self::getMLECert($merchantConfig, $logger); if ($merchantConfig->getLogConfiguration()->isMaskingEnabled()) { $printRequestBody = \CyberSource\Utilities\Helpers\DataMasker::maskData($requestBody); @@ -66,20 +57,20 @@ public static function encryptRequestPayload($merchantConfig, $requestBody) { $printRequestBody = $requestBody; } - self::$logger->debug("Request before MLE:\n" . print_r($printRequestBody, true)); + $logger->debug("Request before MLE:\n" . print_r($printRequestBody, true)); - $jweToken = self::generateToken($cert, $requestBody); + $jweToken = self::generateToken($cert, $requestBody, $logger); $mleRequest = json_encode(['encryptedRequest' => $jweToken]); - self::$logger->debug("Request after MLE:\n" . print_r($mleRequest, true)); + $logger->debug("Request after MLE:\n" . print_r($mleRequest, true)); // self::$logger->close(); return $mleRequest; } - private static function generateToken($cert, $requestBody) { + private static function generateToken($cert, $requestBody, $logger) { try { - $serialNumber = self::extractSerialNumber($cert); + $serialNumber = self::extractSerialNumber($cert, $logger); $publicKey = openssl_pkey_get_details(openssl_pkey_get_public($cert))['key']; @@ -120,12 +111,12 @@ private static function generateToken($cert, $requestBody) { $serializer = new CompactSerializer(); return $serializer->serialize($jwe); } catch (\Exception $e) { - self::$logger->error("Error encrypting request payload: " . $e->getMessage()); + $logger->error("Error encrypting request payload: " . $e->getMessage()); throw new MLEException("Error encrypting request payload: " . $e->getMessage()); } } - public static function getMLECert($merchantConfig) + public static function getMLECert($merchantConfig, $logger) { try { if (!isset(self::$cache)) { @@ -147,18 +138,18 @@ public static function getMLECert($merchantConfig) } if ($x509Cert) { - self::validateCertificateExpiry($x509Cert, $merchantConfig->getMleKeyAlias()); + self::validateCertificateExpiry($x509Cert, $merchantConfig->getMleKeyAlias(), $logger); return $x509Cert; } else { throw new MLEException("Certificate with alias $mleKeyAlias not found."); } } catch (\Exception $e) { - self::$logger->error("Error fetching MLE certificate: " . $e->getMessage()); + $logger->error("Error fetching MLE certificate: " . $e->getMessage()); throw new MLEException("Error fetching MLE certificate: " . $e->getMessage()); } } - public static function extractSerialNumber($cert) + public static function extractSerialNumber($cert, $logger) { try { $certDetails = openssl_x509_parse($cert); @@ -169,35 +160,35 @@ public static function extractSerialNumber($cert) } if ($serialNumber === null) { - self::$logger->warning("Serial number not found in MLE certificate for alias."); + $logger->warning("Serial number not found in MLE certificate for alias."); // this will be in hexdec is it fine? $serialNumber = $certDetails['serialNumber']; } return $serialNumber; } catch (\Exception $e) { - self::$logger->error("Error extracting serial number from certificate: " . $e->getMessage()); + $logger->error("Error extracting serial number from certificate: " . $e->getMessage()); throw new MLEException("Error extracting serial number from certificate: " . $e->getMessage()); } } - public static function validateCertificateExpiry($certificate, $keyAlias) { + public static function validateCertificateExpiry($certificate, $keyAlias, $logger) { try { $certDetails = openssl_x509_parse($certificate); $notValidAfter = $certDetails['validTo_time_t']; if ($notValidAfter < time()) { - self::$logger->warning("Certificate with MLE alias $keyAlias is expired as of " . date('Y-m-d H:i:s', $notValidAfter) . ". Please update p12 file."); + $logger->warning("Certificate with MLE alias $keyAlias is expired as of " . date('Y-m-d H:i:s', $notValidAfter) . ". Please update p12 file."); // throw new MLEException("Certificate with MLE alias $keyAlias is expired."); } else { $timeToExpire = $notValidAfter - time(); $warningPeriod = GlobalLabelParameters::CERTIFICATE_EXPIRY_DATE_WARNING_DAYS * 24 * 60 * 60; if ($timeToExpire < $warningPeriod) { - self::$logger->warning("Certificate for MLE with alias $keyAlias is going to expire on " . date('Y-m-d H:i:s', $notValidAfter) . ". Please update p12 file before that."); + $logger->warning("Certificate for MLE with alias $keyAlias is going to expire on " . date('Y-m-d H:i:s', $notValidAfter) . ". Please update p12 file before that."); } } } catch (Exception $e) { - self::$logger->error("Error while checking certificate expiry: " . $e->getMessage()); + $logger->error("Error while checking certificate expiry: " . $e->getMessage()); throw new MLEException("Error while checking certificate expiry: " . $e->getMessage()); } } From c457290e31acefbcaad26fbd43e44b20d5b832f1 Mon Sep 17 00:00:00 2001 From: mahmishr Date: Thu, 20 Feb 2025 14:26:05 +0530 Subject: [PATCH 10/23] Update MLEUtility.php --- lib/Authentication/Util/MLEUtility.php | 58 ++++++++++++++------------ 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/lib/Authentication/Util/MLEUtility.php b/lib/Authentication/Util/MLEUtility.php index 037afccbd..4e8bb6241 100644 --- a/lib/Authentication/Util/MLEUtility.php +++ b/lib/Authentication/Util/MLEUtility.php @@ -1,7 +1,7 @@ getUseMLEGlobally()) { $isMLEForAPI = true; } @@ -45,11 +46,11 @@ public static function checkIsMLEForAPI($merchantConfig, $isMLESupportedByCybsFo return $isMLEForAPI; } - public static function encryptRequestPayload($merchantConfig, $requestBody) { - + public static function encryptRequestPayload($merchantConfig, $requestBody) + { $logger = (new LogFactory())->getLogger(\CyberSource\Utilities\Helpers\ClassHelper::getClassName(get_class()), $merchantConfig->getLogConfiguration()); - $cert = self::getMLECert($merchantConfig, $logger); + $mleCert = self::getMLECert($merchantConfig, $logger); if ($merchantConfig->getLogConfiguration()->isMaskingEnabled()) { $printRequestBody = \CyberSource\Utilities\Helpers\DataMasker::maskData($requestBody); @@ -59,7 +60,7 @@ public static function encryptRequestPayload($merchantConfig, $requestBody) { $logger->debug("Request before MLE:\n" . print_r($printRequestBody, true)); - $jweToken = self::generateToken($cert, $requestBody, $logger); + $jweToken = self::generateToken($mleCert, $requestBody, $logger); $mleRequest = json_encode(['encryptedRequest' => $jweToken]); $logger->debug("Request after MLE:\n" . print_r($mleRequest, true)); @@ -67,8 +68,8 @@ public static function encryptRequestPayload($merchantConfig, $requestBody) { return $mleRequest; } - - private static function generateToken($cert, $requestBody, $logger) { + private static function generateToken($cert, $requestBody, $logger) + { try { $serialNumber = self::extractSerialNumber($cert, $logger); @@ -171,26 +172,31 @@ public static function extractSerialNumber($cert, $logger) } } - public static function validateCertificateExpiry($certificate, $keyAlias, $logger) { - try { - $certDetails = openssl_x509_parse($certificate); - $notValidAfter = $certDetails['validTo_time_t']; + public static function validateCertificateExpiry($certificate, $keyAlias, $logger) + { + try { + $certDetails = openssl_x509_parse($certificate); + $notValidAfter = isset($certDetails['validTo_time_t']) ? $certDetails['validTo_time_t'] : null; + + if ($notValidAfter === null) { + $logger->warning("Certificate with MLE alias $keyAlias does not have a valid expiry date."); + throw new MLEException("Certificate with MLE alias $keyAlias does not have a valid expiry date."); + } - if ($notValidAfter < time()) { - $logger->warning("Certificate with MLE alias $keyAlias is expired as of " . date('Y-m-d H:i:s', $notValidAfter) . ". Please update p12 file."); - // throw new MLEException("Certificate with MLE alias $keyAlias is expired."); - } else { - $timeToExpire = $notValidAfter - time(); - $warningPeriod = GlobalLabelParameters::CERTIFICATE_EXPIRY_DATE_WARNING_DAYS * 24 * 60 * 60; + if ($notValidAfter < time()) { + $logger->warning("Certificate with MLE alias $keyAlias is expired as of " . date('Y-m-d H:i:s', $notValidAfter) . ". Please update p12 file."); + // throw new MLEException("Certificate with MLE alias $keyAlias is expired."); + } else { + $timeToExpire = $notValidAfter - time(); + $warningPeriod = GlobalLabelParameters::CERTIFICATE_EXPIRY_DATE_WARNING_DAYS * 24 * 60 * 60; - if ($timeToExpire < $warningPeriod) { - $logger->warning("Certificate for MLE with alias $keyAlias is going to expire on " . date('Y-m-d H:i:s', $notValidAfter) . ". Please update p12 file before that."); + if ($timeToExpire < $warningPeriod) { + $logger->warning("Certificate for MLE with alias $keyAlias is going to expire on " . date('Y-m-d H:i:s', $notValidAfter) . ". Please update p12 file before that."); + } } - } - } catch (Exception $e) { + } catch (\Exception $e) { $logger->error("Error while checking certificate expiry: " . $e->getMessage()); - throw new MLEException("Error while checking certificate expiry: " . $e->getMessage()); - } + } } } ?> \ No newline at end of file From 7dd409bc123ecb4de9a3dcc5fe3884028aa0fa39 Mon Sep 17 00:00:00 2001 From: mahmishr Date: Thu, 20 Feb 2025 15:45:17 +0530 Subject: [PATCH 11/23] "readme updated" --- MLE.md | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 7 ++++ 2 files changed, 106 insertions(+) create mode 100644 MLE.md diff --git a/MLE.md b/MLE.md new file mode 100644 index 000000000..e24884258 --- /dev/null +++ b/MLE.md @@ -0,0 +1,99 @@ +[![Generic badge](https://img.shields.io/badge/MLE-NEW-GREEN.svg)](https://shields.io/) + +# Message Level Encryption (MLE) Feature + +This feature provides an implementation of Message Level Encryption (MLE) for APIs provided by CyberSource, integrated within our SDK. This feature ensures secure communication by encrypting messages at the application level before they are sent over the network. + +## Configuration + +### Global MLE Configuration + +In the `merchantConfig` object, set the `useMLEGlobally` variable to enable or disable MLE for all supported APIs for the Rest SDK. + +- **Variable**: `useMLEGlobally` +- **Type**: `boolean` +- **Default**: `false` +- **Description**: Enables MLE globally for all APIs when set to `true`. If set to `true`, it will enable MLE for all API calls that support MLE by CyberSource, unless overridden by `mapToControlMLEonAPI`. + +### API-level MLE Control + +Optionally, you can control the MLE feature at the API level using the `mapToControlMLEonAPI` variable in the `merchantConfig` object. + +- **Variable**: `mapToControlMLEonAPI` +- **Type**: `array(string, boolean)` +- **Description**: Overrides the global MLE setting for specific APIs. The key is the function name of the API in the SDK, and the value is a boolean indicating whether MLE should be enabled (`true`) or disabled (`false`) for that specific API call. + +### MLE Key Alias + +Another optional parameter for MLE is `mleKeyAlias`, which specifies the key alias used to retrieve the MLE certificate from the JWT P12 file. + +- **Variable**: `mleKeyAlias` +- **Type**: `string` +- **Default**: `CyberSource_SJC_US` +- **Description**: By default, CyberSource uses the `CyberSource_SJC_US` public certificate to encrypt the payload. However, users can override this default value by setting their own key alias. + +## Notes +- If `useMLEGlobally` is set to true, it will enable MLE for all API calls that support MLE by CyberSource, unless overridden by mapToControlMLEonAPI. +- If `mapToControlMLEonAPI` is not provided or does not contain a specific API function name, the global useMLEGlobally setting will be applied. +- The `mleKeyAlias` parameter is optional and defaults to CyberSource_SJC_US if not specified by the user. Users can override this default value by setting their own key alias. + +## Example Configuration + +```php +// Enable MLE globally for all supported APIs +$merchantConfig->setUseMLEGlobally(true); +``` + +Or + +```php +// Enable MLE globally for all supported APIs +$merchantConfig->setUseMLEGlobally(true); + +// Optionally, control MLE at the API level +$merchantConfig->setMapToControlMLEonAPI([ + 'apiFunctionName1' => false, // Disable MLE for this specific API + 'apiFunctionName2' => true // Enable MLE for this specific API +]); + +// Optionally, set a custom MLE key alias +$merchantConfig->setMleKeyAlias('Custom_Key_Alias'); +``` + +Or + +```php +// Disable MLE globally for all supported APIs +$merchantConfig->setUseMLEGlobally(false); + +// Optionally, enable MLE for some APIs +$merchantConfig->setMapToControlMLEonAPI([ + 'apiFunctionName1' => true, // Enable MLE for this specific API + 'apiFunctionName2' => true // Enable MLE for this specific API +]); + +// Optionally, set a custom MLE key alias +$merchantConfig->setMleKeyAlias('Custom_Key_Alias'); +``` + +In the above examples: +- MLE is enabled/disabled globally (`useMLEGlobally` is true/false). +- `apiFunctionName1` will have MLE disabled/enabled based on value provided. +- `apiFunctionName2` will have MLE enabled. +- `mleKeyAlias` is set to `Custom_Key_Alias`, overriding the default value. + +Please refer given link for sample codes with MLE: + + +## Additional Information + +### API Support +- MLE is initially designed to support a few APIs. +- It can be extended to support more APIs in the future based on requirements and updates. +### Authentication Type +- MLE is only supported with `JWT (JSON Web Token)` authentication type within the SDK. +### Using the SDK +To use the MLE feature in the SDK, configure the `merchantConfig` object as shown above and pass it to the SDK initialization. + +## Contact +For any issues or further assistance, please open an issue on the GitHub repository or contact our support team. \ No newline at end of file diff --git a/README.md b/README.md index 2b3f0c549..286ecd819 100755 --- a/README.md +++ b/README.md @@ -100,6 +100,13 @@ More information about this new logging framework can be found in this file : [L ## Features +### Message Level Encryption (MLE) Feature +[![Generic badge](https://img.shields.io/badge/MLE-NEW-GREEN.svg)](https://shields.io/) + +This feature provides an implementation of Message Level Encryption (MLE) for APIs provided by CyberSource, integrated within our SDK. This feature ensures secure communication by encrypting messages at the application level before they are sent over the network. + +More information about this new MLE feature can be found in this file : [MLE.md](MLE.md) + ### MetaKey Support A Meta Key is a single key that can be used by one, some, or all merchants (or accounts, if created by a Portfolio user) in the portfolio. From 57be30033de33626ebf22da27867bbb246ec1fd8 Mon Sep 17 00:00:00 2001 From: mahmishr Date: Thu, 20 Feb 2025 16:06:51 +0530 Subject: [PATCH 12/23] "map type" --- MLE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MLE.md b/MLE.md index e24884258..fd8ef468c 100644 --- a/MLE.md +++ b/MLE.md @@ -20,7 +20,7 @@ In the `merchantConfig` object, set the `useMLEGlobally` variable to enable or d Optionally, you can control the MLE feature at the API level using the `mapToControlMLEonAPI` variable in the `merchantConfig` object. - **Variable**: `mapToControlMLEonAPI` -- **Type**: `array(string, boolean)` +- **Type**: `map = [string, boolean]` - **Description**: Overrides the global MLE setting for specific APIs. The key is the function name of the API in the SDK, and the value is a boolean indicating whether MLE should be enabled (`true`) or disabled (`false`) for that specific API call. ### MLE Key Alias From 5573b7f2cdc895a16e0d0f6862aee255317edddb Mon Sep 17 00:00:00 2001 From: mahmishr Date: Fri, 21 Feb 2025 01:59:35 +0530 Subject: [PATCH 13/23] "MLE exception fix" --- lib/Authentication/Util/MLEException.php | 2 +- lib/Authentication/Util/MLEUtility.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Authentication/Util/MLEException.php b/lib/Authentication/Util/MLEException.php index 1c86968af..e659bb98a 100644 --- a/lib/Authentication/Util/MLEException.php +++ b/lib/Authentication/Util/MLEException.php @@ -1,6 +1,6 @@ Date: Tue, 25 Feb 2025 09:11:50 +0530 Subject: [PATCH 14/23] "caching update" --- lib/Authentication/Jwt/JsonWebTokenHeader.php | 74 +++----------- lib/Authentication/Util/Cache.php | 99 ++++++++++++++++++- lib/Authentication/Util/JWE/JWEUtility.php | 10 +- lib/Authentication/Util/MLEUtility.php | 17 +--- lib/Authentication/Util/Utility.php | 31 ------ 5 files changed, 120 insertions(+), 111 deletions(-) diff --git a/lib/Authentication/Jwt/JsonWebTokenHeader.php b/lib/Authentication/Jwt/JsonWebTokenHeader.php index f2015bbee..465a89c19 100644 --- a/lib/Authentication/Jwt/JsonWebTokenHeader.php +++ b/lib/Authentication/Jwt/JsonWebTokenHeader.php @@ -33,10 +33,8 @@ public function __construct(\CyberSource\Logging\LogConfiguration $logConfig) public function getJsonWebToken($jwtBody, $merchantConfig) { $merchantID = $merchantConfig->getMerchantID(); - $keyPass = $merchantConfig->getKeyPassword(); $keyalias = $merchantConfig->getKeyAlias(); - $keyDir = $merchantConfig->getKeysDirectory(); - $keyFileName = $merchantConfig->getKeyFileName(); + if(empty($keyalias)){ $keyalias = $merchantID; } @@ -45,74 +43,32 @@ public function getJsonWebToken($jwtBody, $merchantConfig) $keyalias = $merchantID; $warning_msg = GlobalParameter::KEY_ALIAS_INCORRECT; } - if(empty($keyFileName)){ - $keyFileName = $merchantID; - } - - if(empty($keyDir)){ - $keyDir = GlobalParameter::KEY_DIR_PATH_DEFAULT; - } - if(empty($keyPass)){ - $keyPass = $merchantID; - } if(!empty($warning_msg)){ trigger_error($warning_msg, E_USER_WARNING); self::$logger->warning($warning_msg); } - $filePath = $keyDir.$keyFileName.".p12"; - //get certificate from p12 - if (file_exists($filePath)) - { - $cert_store = file_get_contents($filePath); - $cacheKey = $keyFileName."_".strtotime(date("F d Y H:i:s", filemtime($filePath))); - } - else - { - $exception = new AuthException(GlobalParameter::KEY_FILE_INCORRECT, 0); - self::$logger->error("AuthException : " . GlobalParameter::KEY_FILE_INCORRECT); + $cacheData = self::$cache->grabFileFromP12($merchantConfig); + + if (!empty($cacheData['private_key']) && !empty($cacheData['publicKey'])) { + $privateKey = $cacheData['private_key']; + $publicKey = $cacheData['publicKey']; + } else { + //which exception would be best to be thrown here? + $exception = new AuthException(GlobalParameter::INCORRECT_KEY_PASSWORD, 0); + self::$logger->error("AuthException : " . GlobalParameter::INCORRECT_KEY_PASSWORD); self::$logger->close(); throw $exception; } - if(!empty($cacheKey)) { - $cache_cert_store = self::$cache->fetchFromCache($cacheKey); // apcu_fetch($cacheKey); - } - if($cache_cert_store == false){ - $cache_cert_store = ""; - $result = self::$cache->storeInCache("$cacheKey", $cert_store); //apcu_store("$cacheKey", $cert_store); - $cache_cert_store = self::$cache->fetchFromCache($cacheKey); // apcu_fetch($cacheKey); - } - //read the certificate from cert obj - if (openssl_pkcs12_read($cache_cert_store, $cert_info, $keyPass)) - { - //Creating public key using certificate Not working in decryption - $certdata= openssl_x509_parse($cert_info['cert'],1); - $privateKey = $cert_info['pkey']; - $publicKey = $this->PemToDer($cert_info['cert']); - $x5cArray = array($publicKey); - $headers = array( + $x5cArray = array($publicKey); + $headers = array( "v-c-merchant-id" => $keyalias, "x5c" => $x5cArray ); - - self::$logger->close(); - return JWT::encode($jwtBody, $privateKey, GlobalParameter::RS256, "", $headers); - } - else - { - $exception = new AuthException(GlobalParameter::INCORRECT_KEY_PASSWORD, 0); - self::$logger->error("AuthException : " . GlobalParameter::INCORRECT_KEY_PASSWORD); - self::$logger->close(); - throw $exception; - } + self::$logger->close(); + return JWT::encode($jwtBody, $privateKey, GlobalParameter::RS256, "", $headers); } - - public function PemToDer($Pem){ - $lines = explode("\n", trim($Pem ?? '')); - unset($lines[count($lines)-1]); - unset($lines[0]); - return implode("\n", $lines); - } + } ?> diff --git a/lib/Authentication/Util/Cache.php b/lib/Authentication/Util/Cache.php index 9fc4b92f4..fcb00cc0c 100644 --- a/lib/Authentication/Util/Cache.php +++ b/lib/Authentication/Util/Cache.php @@ -1,6 +1,9 @@ getKeyPassword(); + if (empty($keyPass)) { + $keyPass = $merchantConfig->getMerchantID(); + } + + $certStore = file_get_contents($filePath); + $privateKey = null; + $publicKey = null; + $mleCert = null; + + if (openssl_pkcs12_read($certStore, $certs, $keyPass)) { + $privateKey = $certs['pkey']; + $publicKey = $this->PemToDer($certs['cert']); + } + + if (!empty($merchantConfig->getMleKeyAlias())) { + $mleCert = Utility::findCertByAlias($certs, $merchantConfig->getMleKeyAlias()); + } + + $this->file_cache[$fileName] = [ + 'private_key' => $privateKey, + 'publicKey' => $publicKey, + 'file_mod_time' => $fileModTime, + 'mle_cert' => $mleCert, + ]; + } + + public function grabFileFromP12($merchantConfig) + { + $filePath = $this->getFilePath($merchantConfig); + + $fileName = basename($filePath); + $fileModTime = filemtime($filePath); + + if (!isset($this->file_cache[$fileName]) || $this->file_cache[$fileName]['file_mod_time'] !== $fileModTime) { + $this->updateCache($filePath, $merchantConfig); + } + + return $this->fetchFromCache($fileName); + } + + private function getFilePath($merchantConfig) + { + $keyDir = $merchantConfig->getKeysDirectory(); + $keyFileName = $merchantConfig->getKeyFileName(); + if (empty($keyFileName)) { + $keyFileName = $merchantConfig->getMerchantID(); + } + if (empty($keyDir)) { + $keyDir = GlobalParameter::KEY_DIR_PATH_DEFAULT; + } + + return $keyDir . $keyFileName . ".p12"; + } + + private function loadKeyFromPEMFile($path) + { + return JWKFactory::createFromKeyFile( + $path, + '', // Secret if the key is encrypted + [ + 'use' => 'enc', // Additional parameters + ] + ); + } + + public function grabKeyFromPEM($filePath) + { + $fileName = basename($filePath); + $fileModTime = filemtime($filePath); + + if (!isset($this->file_cache[$fileName]) || $this->file_cache[$fileName]['file_mod_time'] !== $fileModTime) { + $privateKeyFromPEMFile = self::loadKeyFromPEMFile($filePath); + $this->file_cache[$fileName] = [ + 'private_key' => $privateKeyFromPEMFile, + 'file_mod_time' => $fileModTime, + ]; + } + + return $this->file_cache[$fileName]['private_key']; + } + + private function PemToDer($Pem) + { + $lines = explode("\n", trim($Pem ?? '')); + unset($lines[count($lines) - 1]); + unset($lines[0]); + return implode("\n", $lines); + } +} \ No newline at end of file diff --git a/lib/Authentication/Util/JWE/JWEUtility.php b/lib/Authentication/Util/JWE/JWEUtility.php index 24010b777..b6d788057 100644 --- a/lib/Authentication/Util/JWE/JWEUtility.php +++ b/lib/Authentication/Util/JWE/JWEUtility.php @@ -38,13 +38,9 @@ public static function decryptJWEUsingPEM(MerchantConfiguration $merchantConfig, if (!file_exists($filePath)) { return null; } - $cacheKey = 'privateKeyFromPEMFile' . '_' . strtotime(date("F d Y H:i:s", filemtime($filePath))); - $cached_key = self::$cache->checkIfExistInCache($cacheKey); // apcu_exists($cacheKey); - if (!$cached_key) { - $privateKeyFromPEMFile = self::loadKeyFromPEMFile($merchantConfig->getJwePEMFileDirectory()); - self::$cache->storeInCache($cacheKey, $privateKeyFromPEMFile); // apcu_store($cacheKey, $privateKeyFromPEMFile); - } - $jweKey = self::$cache->fetchFromCache($cacheKey); // apcu_fetch($cacheKey); + + $jweKey = self::$cache->grabKeyFromPEM($filePath); + $serializerManager = new JWESerializerManager([ new CompactSerializer(), ]); diff --git a/lib/Authentication/Util/MLEUtility.php b/lib/Authentication/Util/MLEUtility.php index 13e167f5f..fba9bd855 100644 --- a/lib/Authentication/Util/MLEUtility.php +++ b/lib/Authentication/Util/MLEUtility.php @@ -24,6 +24,7 @@ class MLEUtility { private $logger = null; + private static $cache = null; public static function checkIsMLEForAPI($merchantConfig, $isMLESupportedByCybsForApi, $operationIds) @@ -36,7 +37,7 @@ public static function checkIsMLEForAPI($merchantConfig, $isMLESupportedByCybsFo $operationArray = array_map('trim', explode(',', $operationIds)); - if (!empty($merchantConfig->getMapToControlMLEonAPI()) && is_array($merchantConfig->getMapToControlMLEonAPI())) { + if (!empty($merchantConfig->getMapToControlMLEonAPI())) { foreach ($operationArray as $operationId) { if (array_key_exists($operationId, $merchantConfig->getMapToControlMLEonAPI())) { $isMLEForAPI = $merchantConfig->getMapToControlMLEonAPI()[$operationId]; @@ -125,19 +126,9 @@ public static function getMLECert($merchantConfig, $logger) self::$cache = new Cache(); } - $keyPass = $merchantConfig->getKeyPassword(); - if (empty($keyPass)) { - $keyPass = $merchantID; - } - $mleKeyAlias = $merchantConfig->getMleKeyAlias(); - - $cacheCertStore = Utility::fetchCertFromCache(self::$cache, $merchantConfig); + $fileCache = self::$cache->grabFileFromP12($merchantConfig); - $certs = []; - $x509Cert = null; - if (openssl_pkcs12_read($cacheCertStore, $certs, $keyPass)) { - $x509Cert = Utility::findCertByAlias($certs, $mleKeyAlias); - } + $x509Cert = $fileCache['mle_cert']; if ($x509Cert) { self::validateCertificateExpiry($x509Cert, $merchantConfig->getMleKeyAlias(), $logger); diff --git a/lib/Authentication/Util/Utility.php b/lib/Authentication/Util/Utility.php index bb85cb727..e1ce23ea9 100644 --- a/lib/Authentication/Util/Utility.php +++ b/lib/Authentication/Util/Utility.php @@ -4,37 +4,6 @@ class Utility { - public static function fetchCertFromCache($cache, $merchantConfig) - { - $merchantID = $merchantConfig->getMerchantID(); - $keyFileName = $merchantConfig->getKeyFileName(); - $keyDir = $merchantConfig->getKeysDirectory(); - - if (empty($keyFileName)) { - $keyFileName = $merchantID; - } - - if (empty($keyDir)) { - $keyDir = GlobalParameter::KEY_DIR_PATH_DEFAULT; - } - - $filePath = $keyDir . $keyFileName . ".p12"; - - // Get certificate from p12 - if (file_exists($filePath)) { - $certStore = file_get_contents($filePath); - $cacheKey = $keyFileName . "_" . strtotime(date("F d Y H:i:s", filemtime($filePath))); - } else { - throw new AuthException(GlobalParameter::KEY_FILE_INCORRECT, 0); - } - - $cacheCertStore = $cache->fetchFromCache($cacheKey); - if ($cacheCertStore == false) { - $cache->storeInCache($cacheKey, $certStore); - $cacheCertStore = $cache->fetchFromCache($cacheKey); - } - return $cacheCertStore; - } public static function findCertByAlias($certs, $keyAlias) { From bb2d7ed9d3ebfdc1c622d38371799d73125ca20f Mon Sep 17 00:00:00 2001 From: mahmishr Date: Tue, 25 Feb 2025 10:45:08 +0530 Subject: [PATCH 15/23] "refactoring" --- lib/Authentication/Util/Cache.php | 39 +++---------------------------- 1 file changed, 3 insertions(+), 36 deletions(-) diff --git a/lib/Authentication/Util/Cache.php b/lib/Authentication/Util/Cache.php index fcb00cc0c..9c87460ee 100644 --- a/lib/Authentication/Util/Cache.php +++ b/lib/Authentication/Util/Cache.php @@ -14,42 +14,9 @@ public function __construct() } - public function fetchFromCache($key) - { - if ($this->checkIfExistInCache($key)) - { - return $this->file_cache[$key]; - } - - return false; - } - - public function storeInCache($key, $value) - { - if (!$this->checkIfExistInCache($key)) - { - $this->file_cache[$key] = $value; - return true; - } - - return false; - } - - public function checkIfExistInCache($key) - { - foreach ($this->file_cache as $cache_key => $cache_value) - { - if (isset($cache_value)) - { - return true; - } - } - - return false; - } - public function updateCache($filePath, $merchantConfig) { + echo "update call"; $fileName = basename($filePath); $fileModTime = filemtime($filePath); $keyPass = $merchantConfig->getKeyPassword(); @@ -89,8 +56,8 @@ public function grabFileFromP12($merchantConfig) if (!isset($this->file_cache[$fileName]) || $this->file_cache[$fileName]['file_mod_time'] !== $fileModTime) { $this->updateCache($filePath, $merchantConfig); } - - return $this->fetchFromCache($fileName); + echo "just returning"; + return $this->file_cache[$fileName]; } private function getFilePath($merchantConfig) From b1efb706ef83dab9acdaf843227f6969afb372b4 Mon Sep 17 00:00:00 2001 From: mahmishr Date: Tue, 25 Feb 2025 14:17:41 +0530 Subject: [PATCH 16/23] "refactoring" --- lib/Authentication/Util/Cache.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/Authentication/Util/Cache.php b/lib/Authentication/Util/Cache.php index 9c87460ee..f70f9c953 100644 --- a/lib/Authentication/Util/Cache.php +++ b/lib/Authentication/Util/Cache.php @@ -7,7 +7,7 @@ class Cache { - private $file_cache = array(); + private static $file_cache = array(); public function __construct() { @@ -16,7 +16,6 @@ public function __construct() public function updateCache($filePath, $merchantConfig) { - echo "update call"; $fileName = basename($filePath); $fileModTime = filemtime($filePath); $keyPass = $merchantConfig->getKeyPassword(); @@ -38,7 +37,7 @@ public function updateCache($filePath, $merchantConfig) $mleCert = Utility::findCertByAlias($certs, $merchantConfig->getMleKeyAlias()); } - $this->file_cache[$fileName] = [ + self::$file_cache[$fileName] = [ 'private_key' => $privateKey, 'publicKey' => $publicKey, 'file_mod_time' => $fileModTime, @@ -53,10 +52,9 @@ public function grabFileFromP12($merchantConfig) $fileName = basename($filePath); $fileModTime = filemtime($filePath); - if (!isset($this->file_cache[$fileName]) || $this->file_cache[$fileName]['file_mod_time'] !== $fileModTime) { + if (!isset(self::$file_cache[$fileName]) || self::$file_cache[$fileName]['file_mod_time'] !== $fileModTime) { $this->updateCache($filePath, $merchantConfig); } - echo "just returning"; return $this->file_cache[$fileName]; } @@ -90,15 +88,15 @@ public function grabKeyFromPEM($filePath) $fileName = basename($filePath); $fileModTime = filemtime($filePath); - if (!isset($this->file_cache[$fileName]) || $this->file_cache[$fileName]['file_mod_time'] !== $fileModTime) { + if (!isset(self::$file_cache[$fileName]) || self::$file_cache[$fileName]['file_mod_time'] !== $fileModTime) { $privateKeyFromPEMFile = self::loadKeyFromPEMFile($filePath); - $this->file_cache[$fileName] = [ + self::$file_cache[$fileName] = [ 'private_key' => $privateKeyFromPEMFile, 'file_mod_time' => $fileModTime, ]; } - return $this->file_cache[$fileName]['private_key']; + return self::$file_cache[$fileName]['private_key']; } private function PemToDer($Pem) From 282cbe097bd68ae584fc8d65358b919212d633f2 Mon Sep 17 00:00:00 2001 From: mahmishr Date: Fri, 7 Mar 2025 10:36:00 +0530 Subject: [PATCH 17/23] "comments resolved" --- lib/Api/PaymentsApi.php | 2 +- lib/Authentication/Util/Cache.php | 30 ++++++++------ lib/Authentication/Util/MLEUtility.php | 56 +++++++++++++------------- 3 files changed, 46 insertions(+), 42 deletions(-) diff --git a/lib/Api/PaymentsApi.php b/lib/Api/PaymentsApi.php index 28d0d6347..97ab38238 100644 --- a/lib/Api/PaymentsApi.php +++ b/lib/Api/PaymentsApi.php @@ -306,7 +306,7 @@ public function createPaymentWithHttpInfo($createPaymentRequest) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Authentication/Util/Cache.php b/lib/Authentication/Util/Cache.php index f70f9c953..d9e2724ea 100644 --- a/lib/Authentication/Util/Cache.php +++ b/lib/Authentication/Util/Cache.php @@ -19,9 +19,7 @@ public function updateCache($filePath, $merchantConfig) $fileName = basename($filePath); $fileModTime = filemtime($filePath); $keyPass = $merchantConfig->getKeyPassword(); - if (empty($keyPass)) { - $keyPass = $merchantConfig->getMerchantID(); - } + $cacheKey = $fileName . '_' . "jwt"; $certStore = file_get_contents($filePath); $privateKey = null; @@ -30,14 +28,17 @@ public function updateCache($filePath, $merchantConfig) if (openssl_pkcs12_read($certStore, $certs, $keyPass)) { $privateKey = $certs['pkey']; - $publicKey = $this->PemToDer($certs['cert']); + if (!empty($merchantConfig->getKeyAlias())) { + $publicKey = Utility::findCertByAlias($certs, $merchantConfig->getKeyAlias()); + } else { + $publicKey = $certs['cert']; + } + $publicKey = $this->PemToDer($publicKey); } - if (!empty($merchantConfig->getMleKeyAlias())) { - $mleCert = Utility::findCertByAlias($certs, $merchantConfig->getMleKeyAlias()); - } + $mleCert = Utility::findCertByAlias($certs, $merchantConfig->getMleKeyAlias()); - self::$file_cache[$fileName] = [ + self::$file_cache[$cacheKey] = [ 'private_key' => $privateKey, 'publicKey' => $publicKey, 'file_mod_time' => $fileModTime, @@ -51,11 +52,13 @@ public function grabFileFromP12($merchantConfig) $fileName = basename($filePath); $fileModTime = filemtime($filePath); + $cacheKey = $fileName . '_' . "jwt"; - if (!isset(self::$file_cache[$fileName]) || self::$file_cache[$fileName]['file_mod_time'] !== $fileModTime) { + if (!isset(self::$file_cache[$cacheKey]) || self::$file_cache[$cacheKey]['file_mod_time'] !== $fileModTime) { $this->updateCache($filePath, $merchantConfig); } - return $this->file_cache[$fileName]; + + return self::$file_cache[$cacheKey]; } private function getFilePath($merchantConfig) @@ -87,16 +90,17 @@ public function grabKeyFromPEM($filePath) { $fileName = basename($filePath); $fileModTime = filemtime($filePath); + $cacheKey = $fileName . '_' . "jwe"; - if (!isset(self::$file_cache[$fileName]) || self::$file_cache[$fileName]['file_mod_time'] !== $fileModTime) { + if (!isset(self::$file_cache[$cacheKey]) || self::$file_cache[$cacheKey]['file_mod_time'] !== $fileModTime) { $privateKeyFromPEMFile = self::loadKeyFromPEMFile($filePath); - self::$file_cache[$fileName] = [ + self::$file_cache[$cacheKey] = [ 'private_key' => $privateKeyFromPEMFile, 'file_mod_time' => $fileModTime, ]; } - return self::$file_cache[$fileName]['private_key']; + return self::$file_cache[$cacheKey]['private_key']; } private function PemToDer($Pem) diff --git a/lib/Authentication/Util/MLEUtility.php b/lib/Authentication/Util/MLEUtility.php index fba9bd855..c9fd7447d 100644 --- a/lib/Authentication/Util/MLEUtility.php +++ b/lib/Authentication/Util/MLEUtility.php @@ -4,7 +4,7 @@ use Cybersource\GlobalParameter; use CyberSource\Authentication\Util\Cache as Cache; -use CyberSource\Logging\LogFactory as LogFactory; +use \CyberSource\Logging\LogFactory as LogFactory; use CyberSource\Logging\LogConfiguration; use Jose\Component\Core\JWK; use Jose\Component\Core\AlgorithmManager; @@ -23,7 +23,7 @@ class MLEUtility { - private $logger = null; + private static $logger = null; private static $cache = null; @@ -50,9 +50,10 @@ public static function checkIsMLEForAPI($merchantConfig, $isMLESupportedByCybsFo public static function encryptRequestPayload($merchantConfig, $requestBody) { - $logger = (new LogFactory())->getLogger(\CyberSource\Utilities\Helpers\ClassHelper::getClassName(get_class()), $merchantConfig->getLogConfiguration()); - - $mleCert = self::getMLECert($merchantConfig, $logger); + if (self::$logger === null) { + self::$logger = (new LogFactory())->getLogger(\CyberSource\Utilities\Helpers\ClassHelper::getClassName(get_class()), $merchantConfig->getLogConfiguration()); + } + $mleCert = self::getMLECert($merchantConfig); if ($merchantConfig->getLogConfiguration()->isMaskingEnabled()) { $printRequestBody = \CyberSource\Utilities\Helpers\DataMasker::maskData($requestBody); @@ -60,20 +61,19 @@ public static function encryptRequestPayload($merchantConfig, $requestBody) $printRequestBody = $requestBody; } - $logger->debug("Request before MLE:\n" . print_r($printRequestBody, true)); + self::$logger->debug("Request before MLE:\n" . print_r($printRequestBody, true)); - $jweToken = self::generateToken($mleCert, $requestBody, $logger); + $jweToken = self::generateToken($mleCert, $requestBody); $mleRequest = json_encode(['encryptedRequest' => $jweToken]); - $logger->debug("Request after MLE:\n" . print_r($mleRequest, true)); - // self::$logger->close(); + self::$logger->debug("Request after MLE:\n" . print_r($mleRequest, true)); return $mleRequest; } - private static function generateToken($cert, $requestBody, $logger) + private static function generateToken($cert, $requestBody) { try { - $serialNumber = self::extractSerialNumber($cert, $logger); + $serialNumber = self::extractSerialNumber($cert); $publicKey = openssl_pkey_get_details(openssl_pkey_get_public($cert))['key']; @@ -114,12 +114,12 @@ private static function generateToken($cert, $requestBody, $logger) $serializer = new CompactSerializer(); return $serializer->serialize($jwe); } catch (\Exception $e) { - $logger->error("Error encrypting request payload: " . $e->getMessage()); + self::$logger->error("Error encrypting request payload: " . $e->getMessage()); throw new MLEException("Error encrypting request payload: " . $e->getMessage()); } } - public static function getMLECert($merchantConfig, $logger) + public static function getMLECert($merchantConfig) { try { if (!isset(self::$cache)) { @@ -131,18 +131,19 @@ public static function getMLECert($merchantConfig, $logger) $x509Cert = $fileCache['mle_cert']; if ($x509Cert) { - self::validateCertificateExpiry($x509Cert, $merchantConfig->getMleKeyAlias(), $logger); + self::validateCertificateExpiry($x509Cert, $merchantConfig->getMleKeyAlias()); + // throw new MLEException("Certificate with MLE alias $keyAlias is expired."); return $x509Cert; } else { - throw new MLEException("Certificate with alias $mleKeyAlias not found."); + throw new MLEException("Certificate with alias " . $merchantConfig->getMleKeyAlias() . " not found"); } } catch (\Exception $e) { - $logger->error("Error fetching MLE certificate: " . $e->getMessage()); + self::$logger->error("Error fetching MLE certificate: " . $e->getMessage()); throw new MLEException("Error fetching MLE certificate: " . $e->getMessage()); } } - public static function extractSerialNumber($cert, $logger) + public static function extractSerialNumber($cert) { try { $certDetails = openssl_x509_parse($cert); @@ -153,42 +154,41 @@ public static function extractSerialNumber($cert, $logger) } if ($serialNumber === null) { - $logger->warning("Serial number not found in MLE certificate for alias."); - // this will be in hexdec is it fine? + self::$logger->warning("Serial number not found in MLE certificate for alias."); $serialNumber = $certDetails['serialNumber']; } return $serialNumber; } catch (\Exception $e) { - $logger->error("Error extracting serial number from certificate: " . $e->getMessage()); + self::$logger->error("Error extracting serial number from certificate: " . $e->getMessage()); throw new MLEException("Error extracting serial number from certificate: " . $e->getMessage()); } } - public static function validateCertificateExpiry($certificate, $keyAlias, $logger) + public static function validateCertificateExpiry($certificate, $keyAlias) { try { $certDetails = openssl_x509_parse($certificate); $notValidAfter = isset($certDetails['validTo_time_t']) ? $certDetails['validTo_time_t'] : null; if ($notValidAfter === null) { - $logger->warning("Certificate with MLE alias $keyAlias does not have a valid expiry date."); - throw new MLEException("Certificate with MLE alias $keyAlias does not have a valid expiry date."); + self::$logger->warning("Certificate with MLE alias $keyAlias does not have a valid expiry date."); } if ($notValidAfter < time()) { - $logger->warning("Certificate with MLE alias $keyAlias is expired as of " . date('Y-m-d H:i:s', $notValidAfter) . ". Please update p12 file."); - // throw new MLEException("Certificate with MLE alias $keyAlias is expired."); + self::$logger->warning("Certificate with MLE alias $keyAlias is expired as of " . date('Y-m-d H:i:s', $notValidAfter) . ". Please update p12 file."); + // throw new MLEException("Certificate with MLE alias $keyAlias is expired."); } else { $timeToExpire = $notValidAfter - time(); $warningPeriod = GlobalLabelParameters::CERTIFICATE_EXPIRY_DATE_WARNING_DAYS * 24 * 60 * 60; if ($timeToExpire < $warningPeriod) { - $logger->warning("Certificate for MLE with alias $keyAlias is going to expire on " . date('Y-m-d H:i:s', $notValidAfter) . ". Please update p12 file before that."); + self::$logger->warning("Certificate for MLE with alias $keyAlias is going to expire on " . date('Y-m-d H:i:s', $notValidAfter) . ". Please update p12 file before that."); } } } catch (\Exception $e) { - $logger->error("Error while checking certificate expiry: " . $e->getMessage()); - } + self::$logger->error("Error validating certificate expiry: " . $e->getMessage()); + // throw new MLEException("Error validating certificate expiry: " . $e->getMessage()); + } } } ?> \ No newline at end of file From 0070f3397f7ccd09a190cdaed2a6d1399be230a4 Mon Sep 17 00:00:00 2001 From: mahmishr Date: Fri, 7 Mar 2025 13:00:09 +0530 Subject: [PATCH 18/23] "refactoring" --- lib/Authentication/Util/Cache.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Authentication/Util/Cache.php b/lib/Authentication/Util/Cache.php index d9e2724ea..55e7c2c26 100644 --- a/lib/Authentication/Util/Cache.php +++ b/lib/Authentication/Util/Cache.php @@ -28,11 +28,11 @@ public function updateCache($filePath, $merchantConfig) if (openssl_pkcs12_read($certStore, $certs, $keyPass)) { $privateKey = $certs['pkey']; - if (!empty($merchantConfig->getKeyAlias())) { - $publicKey = Utility::findCertByAlias($certs, $merchantConfig->getKeyAlias()); - } else { - $publicKey = $certs['cert']; + $keyAlias = $merchantConfig->getKeyAlias(); + if (empty($keyAlias)) { + $keyAlias = $merchantConfig->getMerchantID(); } + $publicKey = Utility::findCertByAlias($certs, $keyAlias); $publicKey = $this->PemToDer($publicKey); } From 0fe600ec5071f1005d8bf9706a833bde27c613de Mon Sep 17 00:00:00 2001 From: mahmishr Date: Fri, 7 Mar 2025 14:08:26 +0530 Subject: [PATCH 19/23] "error handling refactored" --- lib/Authentication/Jwt/JsonWebTokenHeader.php | 14 +++++++----- lib/Authentication/Util/Cache.php | 22 ++++++++++++++++--- lib/Authentication/Util/GlobalParameter.php | 1 + 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/lib/Authentication/Jwt/JsonWebTokenHeader.php b/lib/Authentication/Jwt/JsonWebTokenHeader.php index 465a89c19..5f0a8a097 100644 --- a/lib/Authentication/Jwt/JsonWebTokenHeader.php +++ b/lib/Authentication/Jwt/JsonWebTokenHeader.php @@ -48,17 +48,19 @@ public function getJsonWebToken($jwtBody, $merchantConfig) self::$logger->warning($warning_msg); } - $cacheData = self::$cache->grabFileFromP12($merchantConfig); + try { + $cacheData = self::$cache->grabFileFromP12($merchantConfig); + } catch (AuthException $e) { + self::$logger->error("Failed to grab file from P12: " . $e->getMessage()); + throw $e; + } if (!empty($cacheData['private_key']) && !empty($cacheData['publicKey'])) { $privateKey = $cacheData['private_key']; $publicKey = $cacheData['publicKey']; } else { - //which exception would be best to be thrown here? - $exception = new AuthException(GlobalParameter::INCORRECT_KEY_PASSWORD, 0); - self::$logger->error("AuthException : " . GlobalParameter::INCORRECT_KEY_PASSWORD); - self::$logger->close(); - throw $exception; + self::$logger->error("AuthException: " . GlobalParameter::EMPTY_PRIVATE_OR_PUBLIC_KEY_ERROR); + throw new AuthException("AuthException: " . GlobalParameter::EMPTY_PRIVATE_OR_PUBLIC_KEY_ERROR); } $x5cArray = array($publicKey); diff --git a/lib/Authentication/Util/Cache.php b/lib/Authentication/Util/Cache.php index 55e7c2c26..a8bd087a3 100644 --- a/lib/Authentication/Util/Cache.php +++ b/lib/Authentication/Util/Cache.php @@ -4,14 +4,19 @@ use Jose\Component\KeyManagement\JWKFactory; use CyberSource\Authentication\Util\GlobalParameter as GlobalParameter; use CyberSource\Authentication\Core\AuthException as AuthException; +use CyberSource\Logging\LogFactory as LogFactory; class Cache { private static $file_cache = array(); + private static $logger = null; + public function __construct() { - + if (self::$logger === null) { + self::$logger = (new LogFactory())->getLogger(\CyberSource\Utilities\Helpers\ClassHelper::getClassName(get_class($this)), new \CyberSource\Logging\LogConfiguration()); + } } public function updateCache($filePath, $merchantConfig) @@ -20,8 +25,15 @@ public function updateCache($filePath, $merchantConfig) $fileModTime = filemtime($filePath); $keyPass = $merchantConfig->getKeyPassword(); $cacheKey = $fileName . '_' . "jwt"; + $certStore = null; + if (file_exists($filePath)) { + $certStore = file_get_contents($filePath); + } else { + $exception = new AuthException(GlobalParameter::KEY_FILE_INCORRECT, 0); + self::$logger->error("AuthException : " . GlobalParameter::KEY_FILE_INCORRECT); + throw $exception; + } - $certStore = file_get_contents($filePath); $privateKey = null; $publicKey = null; $mleCert = null; @@ -34,6 +46,10 @@ public function updateCache($filePath, $merchantConfig) } $publicKey = Utility::findCertByAlias($certs, $keyAlias); $publicKey = $this->PemToDer($publicKey); + } else { + $exception = new AuthException(GlobalParameter::INCORRECT_KEY_PASSWORD, 0); + self::$logger->error("AuthException : " . GlobalParameter::INCORRECT_KEY_PASSWORD); + throw $exception; } $mleCert = Utility::findCertByAlias($certs, $merchantConfig->getMleKeyAlias()); @@ -110,4 +126,4 @@ private function PemToDer($Pem) unset($lines[0]); return implode("\n", $lines); } -} \ No newline at end of file +} diff --git a/lib/Authentication/Util/GlobalParameter.php b/lib/Authentication/Util/GlobalParameter.php index ce4f25b2f..2645b4c7b 100644 --- a/lib/Authentication/Util/GlobalParameter.php +++ b/lib/Authentication/Util/GlobalParameter.php @@ -106,5 +106,6 @@ class GlobalParameter const DEFAULT_MLE_ALIAS_FOR_CERT = "CyberSource_SJC_US"; const CERTIFICATE_EXPIRY_DATE_WARNING_DAYS = 90; const MLE_AUTH_ERROR = "MLE is only supported in JWT auth type"; + const EMPTY_PRIVATE_OR_PUBLIC_KEY_ERROR = "Private key or public key is empty"; } ?> \ No newline at end of file From 5902861da333e434f421b8aa32ca1f1b333b63ec Mon Sep 17 00:00:00 2001 From: mahmishr Date: Fri, 7 Mar 2025 15:12:27 +0530 Subject: [PATCH 20/23] "updated api.mustache" --- generator/cybersource-php-template/api.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generator/cybersource-php-template/api.mustache b/generator/cybersource-php-template/api.mustache index 0c21fa6f3..5ff2d788a 100644 --- a/generator/cybersource-php-template/api.mustache +++ b/generator/cybersource-php-template/api.mustache @@ -243,7 +243,7 @@ use \Exception; $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } From dd6292e758d9f1908fe3ff493055b3f7acb45d28 Mon Sep 17 00:00:00 2001 From: mahmishr Date: Fri, 7 Mar 2025 15:19:29 +0530 Subject: [PATCH 21/23] "generating apis based on mustache" --- lib/Api/BatchesApi.php | 8 ++++---- lib/Api/BillingAgreementsApi.php | 6 +++--- lib/Api/BinLookupApi.php | 2 +- lib/Api/CaptureApi.php | 2 +- lib/Api/ChargebackDetailsApi.php | 2 +- lib/Api/ChargebackSummariesApi.php | 2 +- lib/Api/ConversionDetailsApi.php | 2 +- lib/Api/CreateNewWebhooksApi.php | 6 +++--- lib/Api/CreditApi.php | 2 +- lib/Api/CustomerApi.php | 8 ++++---- lib/Api/CustomerPaymentInstrumentApi.php | 10 +++++----- lib/Api/CustomerShippingAddressApi.php | 10 +++++----- lib/Api/DecisionManagerApi.php | 10 +++++----- lib/Api/DownloadDTDApi.php | 2 +- lib/Api/DownloadXSDApi.php | 2 +- lib/Api/EMVTagDetailsApi.php | 4 ++-- lib/Api/FlexAPIApi.php | 2 +- lib/Api/InstrumentIdentifierApi.php | 12 ++++++------ lib/Api/InterchangeClearingLevelDetailsApi.php | 2 +- lib/Api/InvoiceSettingsApi.php | 4 ++-- lib/Api/InvoicesApi.php | 12 ++++++------ lib/Api/ManageWebhooksApi.php | 10 +++++----- lib/Api/MerchantBoardingApi.php | 4 ++-- lib/Api/MicroformIntegrationApi.php | 2 +- lib/Api/NetFundingsApi.php | 2 +- lib/Api/NotificationOfChangesApi.php | 2 +- lib/Api/OrdersApi.php | 4 ++-- lib/Api/PayerAuthenticationApi.php | 6 +++--- lib/Api/PaymentBatchSummariesApi.php | 2 +- lib/Api/PaymentInstrumentApi.php | 8 ++++---- lib/Api/PaymentsApi.php | 10 +++++----- lib/Api/PayoutsApi.php | 2 +- lib/Api/PlansApi.php | 16 ++++++++-------- lib/Api/PurchaseAndRefundDetailsApi.php | 2 +- lib/Api/PushFundsApi.php | 2 +- lib/Api/RefundApi.php | 4 ++-- lib/Api/ReplayWebhooksApi.php | 2 +- lib/Api/ReportDefinitionsApi.php | 4 ++-- lib/Api/ReportDownloadsApi.php | 2 +- lib/Api/ReportSubscriptionsApi.php | 10 +++++----- lib/Api/ReportsApi.php | 6 +++--- lib/Api/RetrievalDetailsApi.php | 2 +- lib/Api/RetrievalSummariesApi.php | 2 +- lib/Api/ReversalApi.php | 4 ++-- lib/Api/SearchTransactionsApi.php | 4 ++-- lib/Api/SecureFileShareApi.php | 4 ++-- lib/Api/SubscriptionsApi.php | 16 ++++++++-------- lib/Api/TaxesApi.php | 4 ++-- lib/Api/TokenApi.php | 2 +- lib/Api/TransactionBatchesApi.php | 6 +++--- lib/Api/TransactionDetailsApi.php | 2 +- lib/Api/TransientTokenDataApi.php | 4 ++-- lib/Api/UnifiedCheckoutCaptureContextApi.php | 2 +- lib/Api/UserManagementApi.php | 2 +- lib/Api/UserManagementSearchApi.php | 2 +- lib/Api/VerificationApi.php | 4 ++-- lib/Api/VoidApi.php | 10 +++++----- .../Core/MerchantConfiguration.php | 2 +- 58 files changed, 141 insertions(+), 141 deletions(-) diff --git a/lib/Api/BatchesApi.php b/lib/Api/BatchesApi.php index 7a938facb..74f19f51e 100644 --- a/lib/Api/BatchesApi.php +++ b/lib/Api/BatchesApi.php @@ -167,7 +167,7 @@ public function getBatchReportWithHttpInfo($batchId) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -289,7 +289,7 @@ public function getBatchStatusWithHttpInfo($batchId) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -420,7 +420,7 @@ public function getBatchesListWithHttpInfo($offset = '0', $limit = '20', $fromDa $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -549,7 +549,7 @@ public function postBatchWithHttpInfo($body) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/BillingAgreementsApi.php b/lib/Api/BillingAgreementsApi.php index 4944db0f6..66f008809 100644 --- a/lib/Api/BillingAgreementsApi.php +++ b/lib/Api/BillingAgreementsApi.php @@ -181,7 +181,7 @@ public function billingAgreementsDeRegistrationWithHttpInfo($modifyBillingAgreem $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -321,7 +321,7 @@ public function billingAgreementsIntimationWithHttpInfo($intimateBillingAgreemen $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -446,7 +446,7 @@ public function billingAgreementsRegistrationWithHttpInfo($createBillingAgreemen $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/BinLookupApi.php b/lib/Api/BinLookupApi.php index 1b9dabc9d..e86a15eb7 100644 --- a/lib/Api/BinLookupApi.php +++ b/lib/Api/BinLookupApi.php @@ -168,7 +168,7 @@ public function getAccountInfoWithHttpInfo($createBinLookupRequest) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/CaptureApi.php b/lib/Api/CaptureApi.php index c42c23da6..220a8a072 100644 --- a/lib/Api/CaptureApi.php +++ b/lib/Api/CaptureApi.php @@ -181,7 +181,7 @@ public function capturePaymentWithHttpInfo($capturePaymentRequest, $id) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/ChargebackDetailsApi.php b/lib/Api/ChargebackDetailsApi.php index a64104147..604bcb303 100644 --- a/lib/Api/ChargebackDetailsApi.php +++ b/lib/Api/ChargebackDetailsApi.php @@ -180,7 +180,7 @@ public function getChargebackDetailsWithHttpInfo($startTime, $endTime, $organiza $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/ChargebackSummariesApi.php b/lib/Api/ChargebackSummariesApi.php index 3d8343af9..eba293e4d 100644 --- a/lib/Api/ChargebackSummariesApi.php +++ b/lib/Api/ChargebackSummariesApi.php @@ -180,7 +180,7 @@ public function getChargebackSummariesWithHttpInfo($startTime, $endTime, $organi $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/ConversionDetailsApi.php b/lib/Api/ConversionDetailsApi.php index 404174b84..5f31e0ae8 100644 --- a/lib/Api/ConversionDetailsApi.php +++ b/lib/Api/ConversionDetailsApi.php @@ -180,7 +180,7 @@ public function getConversionDetailWithHttpInfo($startTime, $endTime, $organizat $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/CreateNewWebhooksApi.php b/lib/Api/CreateNewWebhooksApi.php index 09886c988..b57cb010f 100644 --- a/lib/Api/CreateNewWebhooksApi.php +++ b/lib/Api/CreateNewWebhooksApi.php @@ -163,7 +163,7 @@ public function createWebhookSubscriptionWithHttpInfo($createWebhookRequest = nu $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -283,7 +283,7 @@ public function findProductsToSubscribeWithHttpInfo($organizationId) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -425,7 +425,7 @@ public function saveSymEgressKeyWithHttpInfo($vCSenderOrganizationId, $vCPermiss $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/CreditApi.php b/lib/Api/CreditApi.php index 920be5466..bab6ee410 100644 --- a/lib/Api/CreditApi.php +++ b/lib/Api/CreditApi.php @@ -166,7 +166,7 @@ public function createCreditWithHttpInfo($createCreditRequest) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/CustomerApi.php b/lib/Api/CustomerApi.php index 31a50f418..9f10d6c3b 100644 --- a/lib/Api/CustomerApi.php +++ b/lib/Api/CustomerApi.php @@ -173,7 +173,7 @@ public function deleteCustomerWithHttpInfo($customerId, $profileId = null) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -317,7 +317,7 @@ public function getCustomerWithHttpInfo($customerId, $profileId = null) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -485,7 +485,7 @@ public function patchCustomerWithHttpInfo($customerId, $patchCustomerRequest, $p $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -636,7 +636,7 @@ public function postCustomerWithHttpInfo($postCustomerRequest, $profileId = null $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/CustomerPaymentInstrumentApi.php b/lib/Api/CustomerPaymentInstrumentApi.php index 1a2a108f9..9ba9cf261 100644 --- a/lib/Api/CustomerPaymentInstrumentApi.php +++ b/lib/Api/CustomerPaymentInstrumentApi.php @@ -188,7 +188,7 @@ public function deleteCustomerPaymentInstrumentWithHttpInfo($customerId, $paymen $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -351,7 +351,7 @@ public function getCustomerPaymentInstrumentWithHttpInfo($customerId, $paymentIn $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -511,7 +511,7 @@ public function getCustomerPaymentInstrumentsListWithHttpInfo($customerId, $prof $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -696,7 +696,7 @@ public function patchCustomersPaymentInstrumentWithHttpInfo($customerId, $paymen $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -862,7 +862,7 @@ public function postCustomerPaymentInstrumentWithHttpInfo($customerId, $postCust $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/CustomerShippingAddressApi.php b/lib/Api/CustomerShippingAddressApi.php index 2a49d42b9..7e55946cb 100644 --- a/lib/Api/CustomerShippingAddressApi.php +++ b/lib/Api/CustomerShippingAddressApi.php @@ -188,7 +188,7 @@ public function deleteCustomerShippingAddressWithHttpInfo($customerId, $shipping $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -351,7 +351,7 @@ public function getCustomerShippingAddressWithHttpInfo($customerId, $shippingAdd $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -511,7 +511,7 @@ public function getCustomerShippingAddressesListWithHttpInfo($customerId, $profi $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -696,7 +696,7 @@ public function patchCustomersShippingAddressWithHttpInfo($customerId, $shipping $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -862,7 +862,7 @@ public function postCustomerShippingAddressWithHttpInfo($customerId, $postCustom $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/DecisionManagerApi.php b/lib/Api/DecisionManagerApi.php index 93e8cf2c5..c813a41f5 100644 --- a/lib/Api/DecisionManagerApi.php +++ b/lib/Api/DecisionManagerApi.php @@ -181,7 +181,7 @@ public function actionDecisionManagerCaseWithHttpInfo($id, $caseManagementAction $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -337,7 +337,7 @@ public function addNegativeWithHttpInfo($type, $addNegativeListRequest) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -473,7 +473,7 @@ public function commentDecisionManagerCaseWithHttpInfo($id, $caseManagementComme $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -614,7 +614,7 @@ public function createBundledDecisionManagerCaseWithHttpInfo($createBundledDecis $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -754,7 +754,7 @@ public function fraudUpdateWithHttpInfo($id, $fraudMarkingActionRequest) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/DownloadDTDApi.php b/lib/Api/DownloadDTDApi.php index 4af287c10..d944b7d49 100644 --- a/lib/Api/DownloadDTDApi.php +++ b/lib/Api/DownloadDTDApi.php @@ -167,7 +167,7 @@ public function getDTDV2WithHttpInfo($reportDefinitionNameVersion) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/DownloadXSDApi.php b/lib/Api/DownloadXSDApi.php index 1bcde8d4e..10d86b616 100644 --- a/lib/Api/DownloadXSDApi.php +++ b/lib/Api/DownloadXSDApi.php @@ -167,7 +167,7 @@ public function getXSDV2WithHttpInfo($reportDefinitionNameVersion) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/EMVTagDetailsApi.php b/lib/Api/EMVTagDetailsApi.php index 26301f3fd..0aa0ab24b 100644 --- a/lib/Api/EMVTagDetailsApi.php +++ b/lib/Api/EMVTagDetailsApi.php @@ -152,7 +152,7 @@ public function getEmvTagsWithHttpInfo() $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -269,7 +269,7 @@ public function parseEmvTagsWithHttpInfo($body) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/FlexAPIApi.php b/lib/Api/FlexAPIApi.php index 91ecca045..dc79edbdb 100644 --- a/lib/Api/FlexAPIApi.php +++ b/lib/Api/FlexAPIApi.php @@ -166,7 +166,7 @@ public function generateFlexAPICaptureContextWithHttpInfo($generateFlexAPICaptur $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/InstrumentIdentifierApi.php b/lib/Api/InstrumentIdentifierApi.php index 089c383e4..fe949f139 100644 --- a/lib/Api/InstrumentIdentifierApi.php +++ b/lib/Api/InstrumentIdentifierApi.php @@ -173,7 +173,7 @@ public function deleteInstrumentIdentifierWithHttpInfo($instrumentIdentifierId, $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -323,7 +323,7 @@ public function getInstrumentIdentifierWithHttpInfo($instrumentIdentifierId, $pr $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -490,7 +490,7 @@ public function getInstrumentIdentifierPaymentInstrumentsListWithHttpInfo($instr $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -667,7 +667,7 @@ public function patchInstrumentIdentifierWithHttpInfo($instrumentIdentifierId, $ $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -825,7 +825,7 @@ public function postInstrumentIdentifierWithHttpInfo($postInstrumentIdentifierRe $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -988,7 +988,7 @@ public function postInstrumentIdentifierEnrollmentWithHttpInfo($instrumentIdenti $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/InterchangeClearingLevelDetailsApi.php b/lib/Api/InterchangeClearingLevelDetailsApi.php index 4165ab651..e1ce751c1 100644 --- a/lib/Api/InterchangeClearingLevelDetailsApi.php +++ b/lib/Api/InterchangeClearingLevelDetailsApi.php @@ -180,7 +180,7 @@ public function getInterchangeClearingLevelDetailsWithHttpInfo($startTime, $endT $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/InvoiceSettingsApi.php b/lib/Api/InvoiceSettingsApi.php index 83853a178..d95684ba2 100644 --- a/lib/Api/InvoiceSettingsApi.php +++ b/lib/Api/InvoiceSettingsApi.php @@ -152,7 +152,7 @@ public function getInvoiceSettingsWithHttpInfo() $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -277,7 +277,7 @@ public function updateInvoiceSettingsWithHttpInfo($invoiceSettingsRequest) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/InvoicesApi.php b/lib/Api/InvoicesApi.php index 69ad555c1..41675204e 100644 --- a/lib/Api/InvoicesApi.php +++ b/lib/Api/InvoicesApi.php @@ -166,7 +166,7 @@ public function createInvoiceWithHttpInfo($createInvoiceRequest) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -313,7 +313,7 @@ public function getAllInvoicesWithHttpInfo($offset, $limit, $status = null) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -446,7 +446,7 @@ public function getInvoiceWithHttpInfo($id) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -576,7 +576,7 @@ public function performCancelActionWithHttpInfo($id) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -706,7 +706,7 @@ public function performSendActionWithHttpInfo($id) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -850,7 +850,7 @@ public function updateInvoiceWithHttpInfo($id, $updateInvoiceRequest) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/ManageWebhooksApi.php b/lib/Api/ManageWebhooksApi.php index 9bb4d7a8d..6bd0bf930 100644 --- a/lib/Api/ManageWebhooksApi.php +++ b/lib/Api/ManageWebhooksApi.php @@ -169,7 +169,7 @@ public function deleteWebhookSubscriptionWithHttpInfo($webhookId) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -285,7 +285,7 @@ public function getWebhookSubscriptionByIdWithHttpInfo($webhookId) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -423,7 +423,7 @@ public function getWebhookSubscriptionsByOrgWithHttpInfo($organizationId, $produ $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -573,7 +573,7 @@ public function saveAsymEgressKeyWithHttpInfo($vCSenderOrganizationId, $vCPermis $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -702,7 +702,7 @@ public function updateWebhookSubscriptionWithHttpInfo($webhookId, $updateWebhook $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/MerchantBoardingApi.php b/lib/Api/MerchantBoardingApi.php index b1dbfdc77..ba417cdf8 100644 --- a/lib/Api/MerchantBoardingApi.php +++ b/lib/Api/MerchantBoardingApi.php @@ -167,7 +167,7 @@ public function getRegistrationWithHttpInfo($registrationId) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -302,7 +302,7 @@ public function postRegistrationWithHttpInfo($postRegistrationBody, $vCIdempoten $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/MicroformIntegrationApi.php b/lib/Api/MicroformIntegrationApi.php index 9eecd3612..4c9af24eb 100644 --- a/lib/Api/MicroformIntegrationApi.php +++ b/lib/Api/MicroformIntegrationApi.php @@ -166,7 +166,7 @@ public function generateCaptureContextWithHttpInfo($generateCaptureContextReques $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/NetFundingsApi.php b/lib/Api/NetFundingsApi.php index a9e5c563a..13695278d 100644 --- a/lib/Api/NetFundingsApi.php +++ b/lib/Api/NetFundingsApi.php @@ -186,7 +186,7 @@ public function getNetFundingDetailsWithHttpInfo($startTime, $endTime, $organiza $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/NotificationOfChangesApi.php b/lib/Api/NotificationOfChangesApi.php index 42f4c898f..836ef8be9 100644 --- a/lib/Api/NotificationOfChangesApi.php +++ b/lib/Api/NotificationOfChangesApi.php @@ -174,7 +174,7 @@ public function getNotificationOfChangeReportWithHttpInfo($startTime, $endTime) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/OrdersApi.php b/lib/Api/OrdersApi.php index 6eef2097e..349fa7bdc 100644 --- a/lib/Api/OrdersApi.php +++ b/lib/Api/OrdersApi.php @@ -166,7 +166,7 @@ public function createOrderWithHttpInfo($createOrderRequest) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -306,7 +306,7 @@ public function updateOrderWithHttpInfo($id, $updateOrderRequest) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/PayerAuthenticationApi.php b/lib/Api/PayerAuthenticationApi.php index e75c20e84..f4b3aa9ab 100644 --- a/lib/Api/PayerAuthenticationApi.php +++ b/lib/Api/PayerAuthenticationApi.php @@ -166,7 +166,7 @@ public function checkPayerAuthEnrollmentWithHttpInfo($checkPayerAuthEnrollmentRe $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -291,7 +291,7 @@ public function payerAuthSetupWithHttpInfo($payerAuthSetupRequest) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -416,7 +416,7 @@ public function validateAuthenticationResultsWithHttpInfo($validateRequest) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/PaymentBatchSummariesApi.php b/lib/Api/PaymentBatchSummariesApi.php index eb5a2f66c..1af3aab5c 100644 --- a/lib/Api/PaymentBatchSummariesApi.php +++ b/lib/Api/PaymentBatchSummariesApi.php @@ -198,7 +198,7 @@ public function getPaymentBatchSummaryWithHttpInfo($startTime, $endTime, $organi $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/PaymentInstrumentApi.php b/lib/Api/PaymentInstrumentApi.php index 407eba497..2563ea5c1 100644 --- a/lib/Api/PaymentInstrumentApi.php +++ b/lib/Api/PaymentInstrumentApi.php @@ -173,7 +173,7 @@ public function deletePaymentInstrumentWithHttpInfo($paymentInstrumentId, $profi $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -319,7 +319,7 @@ public function getPaymentInstrumentWithHttpInfo($paymentInstrumentId, $profileI $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -494,7 +494,7 @@ public function patchPaymentInstrumentWithHttpInfo($paymentInstrumentId, $patchP $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -652,7 +652,7 @@ public function postPaymentInstrumentWithHttpInfo($postPaymentInstrumentRequest, $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/PaymentsApi.php b/lib/Api/PaymentsApi.php index 97ab38238..267b046da 100644 --- a/lib/Api/PaymentsApi.php +++ b/lib/Api/PaymentsApi.php @@ -181,7 +181,7 @@ public function createOrderRequestWithHttpInfo($orderPaymentRequest, $id) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -431,7 +431,7 @@ public function createSessionRequestWithHttpInfo($createSessionReq) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -571,7 +571,7 @@ public function incrementAuthWithHttpInfo($id, $incrementAuthRequest) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -711,7 +711,7 @@ public function refreshPaymentStatusWithHttpInfo($id, $refreshPaymentStatusReque $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -851,7 +851,7 @@ public function updateSessionReqWithHttpInfo($createSessionRequest, $id) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/PayoutsApi.php b/lib/Api/PayoutsApi.php index c9f7c787f..912b2d2c8 100644 --- a/lib/Api/PayoutsApi.php +++ b/lib/Api/PayoutsApi.php @@ -166,7 +166,7 @@ public function octCreatePaymentWithHttpInfo($octCreatePaymentRequest) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/PlansApi.php b/lib/Api/PlansApi.php index 87d57c1d9..d93cccdbe 100644 --- a/lib/Api/PlansApi.php +++ b/lib/Api/PlansApi.php @@ -167,7 +167,7 @@ public function activatePlanWithHttpInfo($id) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -296,7 +296,7 @@ public function createPlanWithHttpInfo($createPlanRequest) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -422,7 +422,7 @@ public function deactivatePlanWithHttpInfo($id) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -552,7 +552,7 @@ public function deletePlanWithHttpInfo($id) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -682,7 +682,7 @@ public function getPlanWithHttpInfo($id) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -797,7 +797,7 @@ public function getPlanCodeWithHttpInfo() $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -938,7 +938,7 @@ public function getPlansWithHttpInfo($offset = null, $limit = null, $code = null $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -1083,7 +1083,7 @@ public function updatePlanWithHttpInfo($id, $updatePlanRequest) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/PurchaseAndRefundDetailsApi.php b/lib/Api/PurchaseAndRefundDetailsApi.php index 2b61e903d..db32bb1d4 100644 --- a/lib/Api/PurchaseAndRefundDetailsApi.php +++ b/lib/Api/PurchaseAndRefundDetailsApi.php @@ -210,7 +210,7 @@ public function getPurchaseAndRefundDetailsWithHttpInfo($startTime, $endTime, $o $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/PushFundsApi.php b/lib/Api/PushFundsApi.php index f6c6f0005..40c6a61b3 100644 --- a/lib/Api/PushFundsApi.php +++ b/lib/Api/PushFundsApi.php @@ -232,7 +232,7 @@ public function createPushFundsTransferWithHttpInfo($pushFundsRequest, $contentT $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/RefundApi.php b/lib/Api/RefundApi.php index 43b6249b6..1767094d6 100644 --- a/lib/Api/RefundApi.php +++ b/lib/Api/RefundApi.php @@ -181,7 +181,7 @@ public function refundCaptureWithHttpInfo($refundCaptureRequest, $id) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -321,7 +321,7 @@ public function refundPaymentWithHttpInfo($refundPaymentRequest, $id) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/ReplayWebhooksApi.php b/lib/Api/ReplayWebhooksApi.php index 4d3fc0bb8..0eaa31905 100644 --- a/lib/Api/ReplayWebhooksApi.php +++ b/lib/Api/ReplayWebhooksApi.php @@ -178,7 +178,7 @@ public function replayPreviousWebhooksWithHttpInfo($webhookId, $replayWebhooksRe $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/ReportDefinitionsApi.php b/lib/Api/ReportDefinitionsApi.php index ee40ea70d..7833ea065 100644 --- a/lib/Api/ReportDefinitionsApi.php +++ b/lib/Api/ReportDefinitionsApi.php @@ -185,7 +185,7 @@ public function getResourceInfoByReportDefinitionWithHttpInfo($reportDefinitionN $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -307,7 +307,7 @@ public function getResourceV2InfoWithHttpInfo($subscriptionType = null, $organiz $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/ReportDownloadsApi.php b/lib/Api/ReportDownloadsApi.php index 147063d58..c75a221f2 100644 --- a/lib/Api/ReportDownloadsApi.php +++ b/lib/Api/ReportDownloadsApi.php @@ -180,7 +180,7 @@ public function downloadReportWithHttpInfo($reportDate, $reportName, $organizati $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/ReportSubscriptionsApi.php b/lib/Api/ReportSubscriptionsApi.php index 2561f944c..649395986 100644 --- a/lib/Api/ReportSubscriptionsApi.php +++ b/lib/Api/ReportSubscriptionsApi.php @@ -172,7 +172,7 @@ public function createStandardOrClassicSubscriptionWithHttpInfo($predefinedSubsc $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -296,7 +296,7 @@ public function createSubscriptionWithHttpInfo($createReportSubscriptionRequest, $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -421,7 +421,7 @@ public function deleteSubscriptionWithHttpInfo($reportName, $organizationId = nu $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -535,7 +535,7 @@ public function getAllSubscriptionsWithHttpInfo($organizationId = null) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -664,7 +664,7 @@ public function getSubscriptionWithHttpInfo($reportName, $organizationId = null) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/ReportsApi.php b/lib/Api/ReportsApi.php index f9689cf0b..ecec3873e 100644 --- a/lib/Api/ReportsApi.php +++ b/lib/Api/ReportsApi.php @@ -172,7 +172,7 @@ public function createReportWithHttpInfo($createAdhocReportRequest, $organizatio $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -297,7 +297,7 @@ public function getReportByReportIdWithHttpInfo($reportId, $organizationId = nul $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -474,7 +474,7 @@ public function searchReportsWithHttpInfo($startTime, $endTime, $timeQueryType, $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/RetrievalDetailsApi.php b/lib/Api/RetrievalDetailsApi.php index e26a6e23c..c37962e75 100644 --- a/lib/Api/RetrievalDetailsApi.php +++ b/lib/Api/RetrievalDetailsApi.php @@ -180,7 +180,7 @@ public function getRetrievalDetailsWithHttpInfo($startTime, $endTime, $organizat $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/RetrievalSummariesApi.php b/lib/Api/RetrievalSummariesApi.php index 65971b460..84f9e284b 100644 --- a/lib/Api/RetrievalSummariesApi.php +++ b/lib/Api/RetrievalSummariesApi.php @@ -180,7 +180,7 @@ public function getRetrievalSummaryWithHttpInfo($startTime, $endTime, $organizat $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/ReversalApi.php b/lib/Api/ReversalApi.php index b90dfc3d8..51547cdca 100644 --- a/lib/Api/ReversalApi.php +++ b/lib/Api/ReversalApi.php @@ -181,7 +181,7 @@ public function authReversalWithHttpInfo($id, $authReversalRequest) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -306,7 +306,7 @@ public function mitReversalWithHttpInfo($mitReversalRequest) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/SearchTransactionsApi.php b/lib/Api/SearchTransactionsApi.php index c6efdc5e2..6860c017a 100644 --- a/lib/Api/SearchTransactionsApi.php +++ b/lib/Api/SearchTransactionsApi.php @@ -166,7 +166,7 @@ public function createSearchWithHttpInfo($createSearchRequest) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -292,7 +292,7 @@ public function getSearchWithHttpInfo($searchId) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/SecureFileShareApi.php b/lib/Api/SecureFileShareApi.php index 7420236d6..bd1ad7c22 100644 --- a/lib/Api/SecureFileShareApi.php +++ b/lib/Api/SecureFileShareApi.php @@ -173,7 +173,7 @@ public function getFileWithHttpInfo($fileId, $organizationId = null) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -311,7 +311,7 @@ public function getFileDetailWithHttpInfo($startDate, $endDate, $organizationId $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/SubscriptionsApi.php b/lib/Api/SubscriptionsApi.php index 139bce9fe..d9e742788 100644 --- a/lib/Api/SubscriptionsApi.php +++ b/lib/Api/SubscriptionsApi.php @@ -167,7 +167,7 @@ public function activateSubscriptionWithHttpInfo($id) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -297,7 +297,7 @@ public function cancelSubscriptionWithHttpInfo($id) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -426,7 +426,7 @@ public function createSubscriptionWithHttpInfo($createSubscriptionRequest) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -561,7 +561,7 @@ public function getAllSubscriptionsWithHttpInfo($offset = null, $limit = null, $ $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -691,7 +691,7 @@ public function getSubscriptionWithHttpInfo($id) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -806,7 +806,7 @@ public function getSubscriptionCodeWithHttpInfo() $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -932,7 +932,7 @@ public function suspendSubscriptionWithHttpInfo($id) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -1076,7 +1076,7 @@ public function updateSubscriptionWithHttpInfo($id, $updateSubscription) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/TaxesApi.php b/lib/Api/TaxesApi.php index 4b5809a84..644a14be0 100644 --- a/lib/Api/TaxesApi.php +++ b/lib/Api/TaxesApi.php @@ -166,7 +166,7 @@ public function calculateTaxWithHttpInfo($taxRequest) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -306,7 +306,7 @@ public function voidTaxWithHttpInfo($voidTaxRequest, $id) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/TokenApi.php b/lib/Api/TokenApi.php index a035a9d7d..b3612e5e3 100644 --- a/lib/Api/TokenApi.php +++ b/lib/Api/TokenApi.php @@ -187,7 +187,7 @@ public function postTokenPaymentCredentialsWithHttpInfo($tokenId, $postPaymentCr $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/TransactionBatchesApi.php b/lib/Api/TransactionBatchesApi.php index 66397f4a3..18978ddc7 100644 --- a/lib/Api/TransactionBatchesApi.php +++ b/lib/Api/TransactionBatchesApi.php @@ -179,7 +179,7 @@ public function getTransactionBatchDetailsWithHttpInfo($id, $uploadDate = null, $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -315,7 +315,7 @@ public function getTransactionBatchIdWithHttpInfo($id) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -460,7 +460,7 @@ public function getTransactionBatchesWithHttpInfo($startTime, $endTime) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/TransactionDetailsApi.php b/lib/Api/TransactionDetailsApi.php index 9032ac5a3..9b74011af 100644 --- a/lib/Api/TransactionDetailsApi.php +++ b/lib/Api/TransactionDetailsApi.php @@ -167,7 +167,7 @@ public function getTransactionWithHttpInfo($id) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/TransientTokenDataApi.php b/lib/Api/TransientTokenDataApi.php index 6636118fa..96ed31093 100644 --- a/lib/Api/TransientTokenDataApi.php +++ b/lib/Api/TransientTokenDataApi.php @@ -167,7 +167,7 @@ public function getPaymentCredentialsForTransientTokenWithHttpInfo($paymentCrede $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -285,7 +285,7 @@ public function getTransactionForTransientTokenWithHttpInfo($transientToken) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/UnifiedCheckoutCaptureContextApi.php b/lib/Api/UnifiedCheckoutCaptureContextApi.php index b24e274d6..2d3124ffa 100644 --- a/lib/Api/UnifiedCheckoutCaptureContextApi.php +++ b/lib/Api/UnifiedCheckoutCaptureContextApi.php @@ -166,7 +166,7 @@ public function generateUnifiedCheckoutCaptureContextWithHttpInfo($generateUnifi $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/UserManagementApi.php b/lib/Api/UserManagementApi.php index eea9bf047..1654ab4aa 100644 --- a/lib/Api/UserManagementApi.php +++ b/lib/Api/UserManagementApi.php @@ -176,7 +176,7 @@ public function getUsersWithHttpInfo($organizationId = null, $userName = null, $ $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/UserManagementSearchApi.php b/lib/Api/UserManagementSearchApi.php index ee6909f19..b407e0347 100644 --- a/lib/Api/UserManagementSearchApi.php +++ b/lib/Api/UserManagementSearchApi.php @@ -166,7 +166,7 @@ public function searchUsersWithHttpInfo($searchRequest) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/VerificationApi.php b/lib/Api/VerificationApi.php index f95bd475d..7b6e3ff4e 100644 --- a/lib/Api/VerificationApi.php +++ b/lib/Api/VerificationApi.php @@ -166,7 +166,7 @@ public function validateExportComplianceWithHttpInfo($validateExportComplianceRe $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -291,7 +291,7 @@ public function verifyCustomerAddressWithHttpInfo($verifyCustomerAddressRequest) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Api/VoidApi.php b/lib/Api/VoidApi.php index f27617367..59def1818 100644 --- a/lib/Api/VoidApi.php +++ b/lib/Api/VoidApi.php @@ -166,7 +166,7 @@ public function mitVoidWithHttpInfo($mitVoidRequest) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -306,7 +306,7 @@ public function voidCaptureWithHttpInfo($voidCaptureRequest, $id) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -446,7 +446,7 @@ public function voidCreditWithHttpInfo($voidCreditRequest, $id) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -586,7 +586,7 @@ public function voidPaymentWithHttpInfo($voidPaymentRequest, $id) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } @@ -726,7 +726,7 @@ public function voidRefundWithHttpInfo($voidRefundRequest, $id) $httpBody = MLEUtility::encryptRequestPayload($this->apiClient->merchantConfig, $httpBody); } catch (Exception $e) { self::$logger->error("Failed to encrypt request body: $e"); - throw new ApiException("Failed to encrypt request body : " + $e->getMessage()); + throw new ApiException("Failed to encrypt request body : " . $e->getMessage()); } } diff --git a/lib/Authentication/Core/MerchantConfiguration.php b/lib/Authentication/Core/MerchantConfiguration.php index 22a1b1c89..2b7d83be1 100644 --- a/lib/Authentication/Core/MerchantConfiguration.php +++ b/lib/Authentication/Core/MerchantConfiguration.php @@ -1225,7 +1225,7 @@ public function validateMerchantData() } if(empty($this->getKeyPassword()) && $this->getAuthenticationType() == GlobalParameter::JWT){ - $warning_message .= GlobalParameter::KEY_PASSWORD_EMPTY . PHP_EOL; + $error_message .= GlobalParameter::KEY_PASSWORD_EMPTY . PHP_EOL; } if(empty($this->getKeysDirectory()) && $this->getAuthenticationType() == GlobalParameter::JWT){ From 07c86d2e96bf086392e95721e9e6ee6446f1ff10 Mon Sep 17 00:00:00 2001 From: mahmishr Date: Mon, 10 Mar 2025 12:08:42 +0530 Subject: [PATCH 22/23] Update MLE.md --- MLE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MLE.md b/MLE.md index fd8ef468c..bfbbba1da 100644 --- a/MLE.md +++ b/MLE.md @@ -83,7 +83,7 @@ In the above examples: - `mleKeyAlias` is set to `Custom_Key_Alias`, overriding the default value. Please refer given link for sample codes with MLE: - +https://github.com/CyberSource/cybersource-rest-samples-php/tree/master/Samples/MLEFeature ## Additional Information From 67caeb38510efea780fe2ca2492926e3d8183608 Mon Sep 17 00:00:00 2001 From: mahmishr Date: Mon, 10 Mar 2025 15:23:15 +0530 Subject: [PATCH 23/23] "null request body check" --- lib/Authentication/Util/MLEUtility.php | 4 +++- lib/Authentication/Util/Utility.php | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Authentication/Util/MLEUtility.php b/lib/Authentication/Util/MLEUtility.php index c9fd7447d..e11586799 100644 --- a/lib/Authentication/Util/MLEUtility.php +++ b/lib/Authentication/Util/MLEUtility.php @@ -50,6 +50,9 @@ public static function checkIsMLEForAPI($merchantConfig, $isMLESupportedByCybsFo public static function encryptRequestPayload($merchantConfig, $requestBody) { + if ($requestBody === null || $requestBody === '') { + return $requestBody; + } if (self::$logger === null) { self::$logger = (new LogFactory())->getLogger(\CyberSource\Utilities\Helpers\ClassHelper::getClassName(get_class()), $merchantConfig->getLogConfiguration()); } @@ -132,7 +135,6 @@ public static function getMLECert($merchantConfig) if ($x509Cert) { self::validateCertificateExpiry($x509Cert, $merchantConfig->getMleKeyAlias()); - // throw new MLEException("Certificate with MLE alias $keyAlias is expired."); return $x509Cert; } else { throw new MLEException("Certificate with alias " . $merchantConfig->getMleKeyAlias() . " not found"); diff --git a/lib/Authentication/Util/Utility.php b/lib/Authentication/Util/Utility.php index e1ce23ea9..5e84df2e4 100644 --- a/lib/Authentication/Util/Utility.php +++ b/lib/Authentication/Util/Utility.php @@ -7,6 +7,7 @@ class Utility public static function findCertByAlias($certs, $keyAlias) { + $keyAlias = trim($keyAlias); if (isset($certs['cert'])) { $certData = openssl_x509_parse($certs['cert'], 1); if (isset($certData['subject']['CN']) && $certData['subject']['CN'] === $keyAlias) {