예제 #1
0
        public static void Run(IReadOnlyDictionary <string, string> configDictionary)
        {
            var requestObj = new GeneratePublicKeyRequest
            {
                EncryptionType = "None"
            };

            var merchantConfig = new MerchantConfig(configDictionary)
            {
                RequestType     = "POST",
                RequestTarget   = "/flex/v1/keys",
                RequestJsonData = JsonConvert.SerializeObject(requestObj)
            };

            try
            {
                var configurationSwagger = new ApiClient().CallAuthenticationHeader(merchantConfig);
                var apiInstance          = new KeyGenerationApi(configurationSwagger);
                var result = apiInstance.GeneratePublicKey(requestObj);
                generateKeyResult = result;
                Console.WriteLine(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception on calling the API: " + e.Message);
            }
        }
        public static FlexV1KeysPost200Response Run()
        {
            string encryptionType = "None";
            string targetOrigin   = "https://www.test.com";
            var    requestObj     = new GeneratePublicKeyRequest(
                EncryptionType: encryptionType,
                TargetOrigin: targetOrigin
                );

            string format = "legacy";

            try
            {
                var configDictionary = new Configuration().GetConfiguration();
                var clientConfig     = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary);

                var apiInstance = new KeyGenerationApi(clientConfig);
                FlexV1KeysPost200Response result = apiInstance.GeneratePublicKey(format, requestObj);
                Console.WriteLine(result);
                return(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception on calling the API : " + e.Message);
                return(null);
            }
        }
예제 #3
0
        public ActionResult Checkout()
        {
            // Call the .NET CyberSource SDK to generate the Flex Key

            ViewBag.Jwk = "{\"kid\":\"HKJHKJ\"}";

            var requestObj = new GeneratePublicKeyRequest("RsaOaep256", "http://*****:*****@"\", "");
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception on calling the API: " + e.Message);
            }

            return(View());
        }
        /// <summary>
        /// Generate Key Generate a one-time use public key and key ID to encrypt the card number in the follow-on Tokenize Card request. The key used to encrypt the card number on the cardholder’s device or browser is valid for 15 minutes and must be used to verify the signature in the response message. CyberSource recommends creating a new key for each order. Generating a key is an authenticated request initiated from your servers, prior to requesting to tokenize the card data from your customer’s device or browser.
        /// </summary>
        /// <exception cref="CyberSource.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="generatePublicKeyRequest"> (optional)</param>
        /// <returns>Task of ApiResponse (FlexV1KeysPost200Response)</returns>
        public async System.Threading.Tasks.Task <ApiResponse <FlexV1KeysPost200Response> > GeneratePublicKeyAsyncWithHttpInfo(GeneratePublicKeyRequest generatePublicKeyRequest = null)
        {
            var    localVarPath         = "/flex/v1/keys/";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new Dictionary <String, String>();
            var    localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/json;charset=utf-8"
            };
            String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "application/json"
            };
            String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            if (generatePublicKeyRequest != null && generatePublicKeyRequest.GetType() != typeof(byte[]))
            {
                localVarPostBody = Configuration.ApiClient.Serialize(generatePublicKeyRequest); // http body (model) parameter
            }
            else
            {
                localVarPostBody = generatePublicKeyRequest; // byte array
            }


            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)await Configuration.ApiClient.CallApiAsync(localVarPath,
                                                                                                       Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                                       localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("GeneratePublicKey", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <FlexV1KeysPost200Response>(localVarStatusCode,
                                                               localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                                                               (FlexV1KeysPost200Response)Configuration.ApiClient.Deserialize(localVarResponse, typeof(FlexV1KeysPost200Response))));
        }
        /// <summary>
        /// Generate Key Generate a one-time use public key and key ID to encrypt the card number in the follow-on Tokenize Card request. The key used to encrypt the card number on the cardholder’s device or browser is valid for 15 minutes and must be used to verify the signature in the response message. CyberSource recommends creating a new key for each order. Generating a key is an authenticated request initiated from your servers, prior to requesting to tokenize the card data from your customer’s device or browser.
        /// </summary>
        /// <exception cref="CyberSource.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="format">Indicator to enable the receipt of the Keys response in Flex 11+ format (JWT) or legacy (parameter not required)</param>
        /// <param name="generatePublicKeyRequest"></param>
        /// <returns>FlexV1KeysPost200Response</returns>
        public FlexV1KeysPost200Response GeneratePublicKey(string format, GeneratePublicKeyRequest generatePublicKeyRequest)
        {
            logger.Debug("CALLING API \"GeneratePublicKey\" STARTED");
            this.SetStatusCode(null);
            ApiResponse <FlexV1KeysPost200Response> localVarResponse = GeneratePublicKeyWithHttpInfo(format, generatePublicKeyRequest);

            logger.Debug("CALLING API \"GeneratePublicKey\" ENDED");
            this.SetStatusCode(localVarResponse.StatusCode);
            return(localVarResponse.Data);
        }
예제 #6
0
        public static FlexV1KeysPost200Response Run()
        {
            var requestObj = new GeneratePublicKeyRequest("None");

            try
            {
                var configDictionary = new Configuration().GetConfiguration();
                var clientConfig     = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary);
                var apiInstance      = new KeyGenerationApi(clientConfig);

                var result = apiInstance.GeneratePublicKey(requestObj);
                Console.WriteLine(result);
                return(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception on calling the API: " + e.Message);
                return(null);
            }
        }
예제 #7
0
        public ActionResult Checkout()
        {
            // Call the .NET CyberSource SDK to generate the Flex Key

            ViewBag.Jwk = "{\"kid\":\"HKJHKJ\"}";



            /**
             * Generating Capture Context Request Payload
             * Defining Encryption Type = RsaOaep
             * Defining TargetOrigin = http://localhost:65309
             *
             */
            var requestObj = new GeneratePublicKeyRequest("RsaOaep256", "http://localhost:65309");

            try
            {
                var configDictionary = new Configuration().GetConfiguration();
                var clientConfig     = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary);
                var apiInstance      = new KeyGenerationApi(clientConfig);

                /**
                 * Initiating public Key request
                 * query paramiter set to format=JWT for Flex 11
                 */
                var result = apiInstance.GeneratePublicKey(requestObj, "JWT");
                Console.WriteLine(result);
                Console.WriteLine(result.KeyId);
                ViewBag.Jwk = result.KeyId;
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception on calling the API: " + e.Message);
            }

            return(View());
        }
예제 #8
0
        /// <summary>
        /// Generate Key Generate a one-time use public key and key ID to encrypt the card number in the follow-on Tokenize Card request. The key used to encrypt the card number on the cardholder’s device or browser is valid for 15 minutes and must be used to verify the signature in the response message. CyberSource recommends creating a new key for each order. Generating a key is an authenticated request initiated from your servers, prior to requesting to tokenize the card data from your customer’s device or browser.
        /// </summary>
        /// <exception cref="CyberSource.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="format">Indicator to enable the receipt of the Keys response in Flex 11+ format (JWT) or legacy (parameter not required)</param>
        /// <param name="generatePublicKeyRequest"></param>
        /// <returns>Task of FlexV1KeysPost200Response</returns>
        public async System.Threading.Tasks.Task <FlexV1KeysPost200Response> GeneratePublicKeyAsync(string format, GeneratePublicKeyRequest generatePublicKeyRequest)
        {
            ApiResponse <FlexV1KeysPost200Response> localVarResponse = await GeneratePublicKeyAsyncWithHttpInfo(format, generatePublicKeyRequest);

            return(localVarResponse.Data);
        }
예제 #9
0
        /// <summary>
        /// Generate Key Generate a one-time use public key and key ID to encrypt the card number in the follow-on Tokenize Card request. The key used to encrypt the card number on the cardholder’s device or browser is valid for 15 minutes and must be used to verify the signature in the response message. CyberSource recommends creating a new key for each order. Generating a key is an authenticated request initiated from your servers, prior to requesting to tokenize the card data from your customer’s device or browser.
        /// </summary>
        /// <exception cref="CyberSource.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="format">Indicator to enable the receipt of the Keys response in Flex 11+ format (JWT) or legacy (parameter not required)</param>
        /// <param name="generatePublicKeyRequest"></param>
        /// <returns>ApiResponse of FlexV1KeysPost200Response</returns>
        public ApiResponse <FlexV1KeysPost200Response> GeneratePublicKeyWithHttpInfo(string format, GeneratePublicKeyRequest generatePublicKeyRequest)
        {
            // verify the required parameter 'format' is set
            if (format == null)
            {
                throw new ApiException(400, "Missing required parameter 'format' when calling KeyGenerationApi->GeneratePublicKey");
            }
            // verify the required parameter 'generatePublicKeyRequest' is set
            if (generatePublicKeyRequest == null)
            {
                throw new ApiException(400, "Missing required parameter 'generatePublicKeyRequest' when calling KeyGenerationApi->GeneratePublicKey");
            }

            var    localVarPath         = $"/flex/v1/keys";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new Dictionary <String, String>();
            var    localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/json;charset=utf-8"
            };
            String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "application/json"
            };
            String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            if (format != null)
            {
                localVarQueryParams.Add("format", Configuration.ApiClient.ParameterToString(format));                 // query parameter
            }
            if (generatePublicKeyRequest != null && generatePublicKeyRequest.GetType() != typeof(byte[]))
            {
                localVarPostBody = Configuration.ApiClient.Serialize(generatePublicKeyRequest); // http body (model) parameter
            }
            else
            {
                localVarPostBody = generatePublicKeyRequest; // byte array
            }


            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)Configuration.ApiClient.CallApi(localVarPath,
                                                                                            Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                            localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("GeneratePublicKey", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <FlexV1KeysPost200Response>(localVarStatusCode,
                                                               localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                                                               (FlexV1KeysPost200Response)Configuration.ApiClient.Deserialize(localVarResponse, typeof(FlexV1KeysPost200Response)))); // Return statement
        }
예제 #10
0
        /// <summary>
        /// Generate Key Generate a one-time use public key and key ID to encrypt the card number in the follow-on Tokenize Card request. The key used to encrypt the card number on the cardholder’s device or browser is valid for 15 minutes and must be used to verify the signature in the response message. CyberSource recommends creating a new key for each order. Generating a key is an authenticated request initiated from your servers, prior to requesting to tokenize the card data from your customer’s device or browser.
        /// </summary>
        /// <exception cref="CyberSource.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="format">Indicator to enable the receipt of the Keys response in Flex 11+ format (JWT) or legacy (parameter not required)</param>
        /// <param name="generatePublicKeyRequest"></param>
        /// <returns>FlexV1KeysPost200Response</returns>
        public FlexV1KeysPost200Response GeneratePublicKey(string format, GeneratePublicKeyRequest generatePublicKeyRequest)
        {
            ApiResponse <FlexV1KeysPost200Response> localVarResponse = GeneratePublicKeyWithHttpInfo(format, generatePublicKeyRequest);

            return(localVarResponse.Data);
        }
예제 #11
0
 public Task <PublicKeyResponse> GeneratePublicKeyAsync(GeneratePublicKeyRequest Secret)
 => PostSimpleJsonAsync <PublicKeyResponse, GeneratePublicKeyRequest>(Secret, Api.PostGeneratePublicKey);
예제 #12
0
 public PublicKeyResponse GeneratePublicKey(GeneratePublicKeyRequest Secret)
 => GeneratePublicKeyAsync(Secret).ConfigureAwait(false).GetAwaiter().GetResult();
        /// <summary>
        /// Generate Key Generate a one-time use public key and key ID to encrypt the card number in the follow-on Tokenize Card request. The key used to encrypt the card number on the cardholder’s device or browser is valid for 15 minutes and must be used to verify the signature in the response message. CyberSource recommends creating a new key for each order. Generating a key is an authenticated request initiated from your servers, prior to requesting to tokenize the card data from your customer’s device or browser.
        /// </summary>
        /// <exception cref="CyberSource.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="generatePublicKeyRequest"> (optional)</param>
        /// <returns>FlexV1KeysPost200Response</returns>
        public FlexV1KeysPost200Response GeneratePublicKey(GeneratePublicKeyRequest generatePublicKeyRequest = null)
        {
            ApiResponse <FlexV1KeysPost200Response> localVarResponse = GeneratePublicKeyWithHttpInfo(generatePublicKeyRequest);

            return(localVarResponse.Data);
        }
        /// <summary>
        /// Generate Key Generate a one-time use public key and key ID to encrypt the card number in the follow-on Tokenize Card request. The key used to encrypt the card number on the cardholder’s device or browser is valid for 15 minutes and must be used to verify the signature in the response message. CyberSource recommends creating a new key for each order. Generating a key is an authenticated request initiated from your servers, prior to requesting to tokenize the card data from your customer’s device or browser.
        /// </summary>
        /// <exception cref="CyberSource.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="format">Indicator to enable the receipt of the Keys response in Flex 11+ format (JWT) or legacy (parameter not required)</param>
        /// <param name="generatePublicKeyRequest"></param>
        /// <returns>Task of ApiResponse (FlexV1KeysPost200Response)</returns>
        public async System.Threading.Tasks.Task <ApiResponse <FlexV1KeysPost200Response> > GeneratePublicKeyAsyncWithHttpInfo(string format, GeneratePublicKeyRequest generatePublicKeyRequest)
        {
            LogUtility logUtility = new LogUtility();

            // verify the required parameter 'format' is set
            if (format == null)
            {
                logger.Error("ApiException : Missing required parameter 'format' when calling KeyGenerationApi->GeneratePublicKey");
                throw new ApiException(400, "Missing required parameter 'format' when calling KeyGenerationApi->GeneratePublicKey");
            }
            // verify the required parameter 'generatePublicKeyRequest' is set
            if (generatePublicKeyRequest == null)
            {
                logger.Error("ApiException : Missing required parameter 'generatePublicKeyRequest' when calling KeyGenerationApi->GeneratePublicKey");
                throw new ApiException(400, "Missing required parameter 'generatePublicKeyRequest' when calling KeyGenerationApi->GeneratePublicKey");
            }

            var    localVarPath         = $"/flex/v1/keys";
            var    localVarPathParams   = new Dictionary <string, string>();
            var    localVarQueryParams  = new Dictionary <string, string>();
            var    localVarHeaderParams = new Dictionary <string, string>(Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <string, string>();
            var    localVarFileParams   = new Dictionary <string, FileParameter>();
            object localVarPostBody     = null;

            // to determine the Content-Type header
            string[] localVarHttpContentTypes = new string[] {
                "application/json;charset=utf-8"
            };
            string localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            string[] localVarHttpHeaderAccepts = new string[] {
                "application/json"
            };
            string localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            if (format != null)
            {
                localVarQueryParams.Add("format", Configuration.ApiClient.ParameterToString(format)); // query parameter
            }
            logger.Debug($"HTTP Request Body :\n{logUtility.ConvertDictionaryToString(localVarQueryParams)}");
            if (generatePublicKeyRequest != null && generatePublicKeyRequest.GetType() != typeof(byte[]))
            {
                localVarPostBody = Configuration.ApiClient.Serialize(generatePublicKeyRequest); // http body (model) parameter
            }
            else
            {
                localVarPostBody = generatePublicKeyRequest; // byte array
            }

            if (logUtility.IsMaskingEnabled(logger))
            {
                logger.Debug($"HTTP Request Body :\n{logUtility.MaskSensitiveData(localVarPostBody.ToString())}");
            }
            else
            {
                logger.Debug($"HTTP Request Body :\n{localVarPostBody}");
            }


            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)await Configuration.ApiClient.CallApiAsync(localVarPath,
                                                                                                       Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                                       localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("GeneratePublicKey", localVarResponse);
                if (exception != null)
                {
                    logger.Error($"Exception : {exception.Message}");
                    throw exception;
                }
            }

            return(new ApiResponse <FlexV1KeysPost200Response>(localVarStatusCode,
                                                               localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                                                               (FlexV1KeysPost200Response)Configuration.ApiClient.Deserialize(localVarResponse, typeof(FlexV1KeysPost200Response)))); // Return statement
        }
        /// <summary>
        /// Generate Key Generate a one-time use public key and key ID to encrypt the card number in the follow-on Tokenize Card request. The key used to encrypt the card number on the cardholder’s device or browser is valid for 15 minutes and must be used to verify the signature in the response message. CyberSource recommends creating a new key for each order. Generating a key is an authenticated request initiated from your servers, prior to requesting to tokenize the card data from your customer’s device or browser.
        /// </summary>
        /// <exception cref="CyberSource.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="format">Indicator to enable the receipt of the Keys response in Flex 11+ format (JWT) or legacy (parameter not required)</param>
        /// <param name="generatePublicKeyRequest"></param>
        /// <returns>Task of FlexV1KeysPost200Response</returns>
        public async System.Threading.Tasks.Task <FlexV1KeysPost200Response> GeneratePublicKeyAsync(string format, GeneratePublicKeyRequest generatePublicKeyRequest)
        {
            logger.Debug("CALLING API \"GeneratePublicKeyAsync\" STARTED");
            this.SetStatusCode(null);
            ApiResponse <FlexV1KeysPost200Response> localVarResponse = await GeneratePublicKeyAsyncWithHttpInfo(format, generatePublicKeyRequest);

            logger.Debug("CALLING API \"GeneratePublicKeyAsync\" ENDED");
            this.SetStatusCode(localVarResponse.StatusCode);
            return(localVarResponse.Data);
        }
        /// <summary>
        /// Generate Key Generate a one-time use public key and key ID to encrypt the card number in the follow-on Tokenize Card request. The key used to encrypt the card number on the cardholder’s device or browser is valid for 15 minutes and must be used to verify the signature in the response message. CyberSource recommends creating a new key for each order. Generating a key is an authenticated request initiated from your servers, prior to requesting to tokenize the card data from your customer’s device or browser.
        /// </summary>
        /// <exception cref="CyberSource.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="generatePublicKeyRequest"> (optional)</param>
        /// <returns>Task of FlexV1KeysPost200Response</returns>
        public async Task <FlexV1KeysPost200Response> GeneratePublicKeyAsync(GeneratePublicKeyRequest generatePublicKeyRequest = null)
        {
            ApiResponse <FlexV1KeysPost200Response> localVarResponse = await GeneratePublicKeyAsyncWithHttpInfo(generatePublicKeyRequest);

            return(localVarResponse.Data);
        }