cybersource_rest_client__WEBPACK_IMPORTED_MODULE_0__.KeyGenerationApi is not a constructor

126 Views Asked by At

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();

1

There are 1 best solutions below

1
Gopinath Kaliappan On BEST ANSWER

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) {