payment-gatewaycybersourcecybersource-rest-client

cybersource_rest_client__WEBPACK_IMPORTED_MODULE_0__.KeyGenerationApi is not a constructor


When we update cybersource-rest-client version to ^0.0.40 to ^0.0.51 getting the below error

{
"errorCode": "FAILED",
"errorMessage": "TypeError: cybersource_rest_client__WEBPACK_IMPORTED_MODULE_0__.KeyGenerationApi is not a constructor"}

Code What we tried

import { ApiClient, KeyGenerationApi, GeneratePublicKeyRequest } from 'cybersource-rest-client';
 const config = configuration(merchantDetails);
const apiClient = new ApiClient();
const instance = await new KeyGenerationApi(config, apiClient);
const request = await new GeneratePublicKeyRequest();


Solution

  • After version 0.0.41, KeyGenerationApi and GeneratePublicKeyRequest are removed and replaced by the below methods

    import { ApiClient, MicroformIntegrationApi, GenerateCaptureContextRequest } from 'cybersource-rest-client';
    

    const instance = await new KeyGenerationApi(config, apiClient);
    
    to
    
    const instance = new MicroformIntegrationApi(config, apiClient);
    

    const request = await new GeneratePublicKeyRequest();
    
    to
    
    const request = await new GenerateCaptureContextRequest();
    

    Key Generation

    instance.generateCaptureContext(request, function (error, data) {