public JsonResult Create([FromBody] CreateCreditRequest model) { var authorization = GetUserWithToken(); if (authorization.Error != null) { return(Json(authorization.Error)); } var credit = new Models.Credit(); credit.Amount = model.Amount; credit.BankName = model.Bank; credit.DurationInMonth = model.Duration; credit.StartCredit = model.StartDate; credit.Name = model.Name; credit.TypeCredit = model.Type; credit.Procent = model.Procent; credit.InitPayment(); credit.UserId = authorization.User.Id; credit.IsPay = false; Context.Add(credit); Context.SaveChanges(); return(Json(new CreateCreditResponce())); }
/// <summary> /// Process a Credit POST to the credit resource to credit funds to a specified credit card. /// </summary> /// <exception cref="CyberSource.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="createCreditRequest"></param> /// <returns>PtsV2CreditsPost201Response</returns> public PtsV2CreditsPost201Response CreateCredit(CreateCreditRequest createCreditRequest) { logger.Debug("CALLING API \"CreateCredit\" STARTED"); this.SetStatusCode(null); ApiResponse <PtsV2CreditsPost201Response> localVarResponse = CreateCreditWithHttpInfo(createCreditRequest); logger.Debug("CALLING API \"CreateCredit\" ENDED"); this.SetStatusCode(localVarResponse.StatusCode); return(localVarResponse.Data); }
public static PtsV2CreditsPost201Response Run() { string clientReferenceInformationCode = "12345678"; Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( Code: clientReferenceInformationCode ); string paymentInformationCustomerId = "AB695DA801DD1BB6E05341588E0A3BDC"; Ptsv2paymentsPaymentInformationCustomer paymentInformationCustomer = new Ptsv2paymentsPaymentInformationCustomer( Id: paymentInformationCustomerId ); Ptsv2paymentsidrefundsPaymentInformation paymentInformation = new Ptsv2paymentsidrefundsPaymentInformation( Customer: paymentInformationCustomer ); string orderInformationAmountDetailsTotalAmount = "200"; string orderInformationAmountDetailsCurrency = "usd"; Ptsv2paymentsidcapturesOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsidcapturesOrderInformationAmountDetails( TotalAmount: orderInformationAmountDetailsTotalAmount, Currency: orderInformationAmountDetailsCurrency ); Ptsv2paymentsidrefundsOrderInformation orderInformation = new Ptsv2paymentsidrefundsOrderInformation( AmountDetails: orderInformationAmountDetails ); var requestObj = new CreateCreditRequest( ClientReferenceInformation: clientReferenceInformation, PaymentInformation: paymentInformation, OrderInformation: orderInformation ); try { var configDictionary = new Configuration().GetConfiguration(); var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new CreditApi(clientConfig); PtsV2CreditsPost201Response result = apiInstance.CreateCredit(requestObj); Console.WriteLine(result); return(result); } catch (Exception e) { Console.WriteLine("Exception on calling the API : " + e.Message); return(null); } }
public static PtsV2CreditsPost201Response Run() { var requestObj = new CreateCreditRequest(); var v2PaymentsClientReferenceInformationObj = new Ptsv2paymentsClientReferenceInformation { Code = "TC46125-1" }; requestObj.ClientReferenceInformation = v2PaymentsClientReferenceInformationObj; var processingInformation = new Ptsv2creditsProcessingInformation { CommerceIndicator = "internet" }; requestObj.ProcessingInformation = processingInformation; var v2PaymentsOrderInformationObj = new Ptsv2paymentsidrefundsOrderInformation(); var v2paymentsOrderInformationBillToCompany = "Visa"; var v2PaymentsOrderInformationBillToObj = new Ptsv2paymentsidcapturesOrderInformationBillTo { Country = "US", FirstName = "John", LastName = "Doe", PhoneNumber = "4158880000", Address1 = "1 Market St", PostalCode = "94105", Locality = "san francisco", AdministrativeArea = "CA", Email = "*****@*****.**" }; v2PaymentsOrderInformationBillToObj.Company = v2paymentsOrderInformationBillToCompany; v2PaymentsOrderInformationObj.BillTo = v2PaymentsOrderInformationBillToObj; var v2PaymentsOrderInformationAmountDetailsObj = new Ptsv2paymentsidcapturesOrderInformationAmountDetails { TotalAmount = "2325.00", Currency = "usd", ServiceFeeAmount = "30.00" }; v2PaymentsOrderInformationObj.AmountDetails = v2PaymentsOrderInformationAmountDetailsObj; requestObj.OrderInformation = v2PaymentsOrderInformationObj; var v2PaymentsPaymentInformationObj = new Ptsv2paymentsidrefundsPaymentInformation(); var v2paymentsPaymentInformationBankAccountObj = new Ptsv2paymentsPaymentInformationBankAccount { Number = "4100", Type = "C", CheckNumber = "123456" }; var v2paymentsPaymentInformationBankObj = new Ptsv2paymentsPaymentInformationBank { RoutingNumber = "071923284" }; v2paymentsPaymentInformationBankObj.Account = v2paymentsPaymentInformationBankAccountObj; v2PaymentsPaymentInformationObj.Bank = v2paymentsPaymentInformationBankObj; requestObj.PaymentInformation = v2PaymentsPaymentInformationObj; try { var configDictionary = new Configuration().GetConfiguration(); var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new CreditApi(clientConfig); var result = apiInstance.CreateCredit(requestObj); Console.WriteLine(result); return(result); } catch (Exception e) { Console.WriteLine("Exception on calling the API: " + e.Message); return(null); } }
public static PtsV2CreditsPost201Response Run() { var requestObj = new CreateCreditRequest(); var v2PaymentsClientReferenceInformationObj = new Ptsv2paymentsClientReferenceInformation { Code = "12345678" }; requestObj.ClientReferenceInformation = v2PaymentsClientReferenceInformationObj; var v2PaymentsOrderInformationObj = new Ptsv2paymentsidrefundsOrderInformation(); var v2paymentsOrderInformationBillToCompany = new Ptsv2paymentsOrderInformationBillToCompany { Name = "Visa" }; var v2PaymentsOrderInformationBillToObj = new Ptsv2paymentsidcapturesOrderInformationBillTo { Country = "US", FirstName = "John", LastName = "Doe", PhoneNumber = "4158880000", Address1 = "1 Market St", PostalCode = "94105", Locality = "san francisco", AdministrativeArea = "CA", Email = "*****@*****.**" }; v2PaymentsOrderInformationBillToObj.Company = v2paymentsOrderInformationBillToCompany; v2PaymentsOrderInformationObj.BillTo = v2PaymentsOrderInformationBillToObj; var v2PaymentsOrderInformationAmountDetailsObj = new Ptsv2paymentsidcapturesOrderInformationAmountDetails { TotalAmount = "2325.00", Currency = "usd", ServiceFeeAmount = "30.00" }; v2PaymentsOrderInformationObj.AmountDetails = v2PaymentsOrderInformationAmountDetailsObj; requestObj.OrderInformation = v2PaymentsOrderInformationObj; var v2PaymentsPaymentInformationObj = new Ptsv2paymentsidrefundsPaymentInformation(); var v2PaymentsPaymentInformationCardObj = new Ptsv2paymentsidrefundsPaymentInformationCard { ExpirationYear = "2031", Number = "4111111111111111", ExpirationMonth = "03" }; v2PaymentsPaymentInformationObj.Card = v2PaymentsPaymentInformationCardObj; requestObj.PaymentInformation = v2PaymentsPaymentInformationObj; try { var configDictionary = new Configuration().GetConfiguration(); var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new CreditApi(clientConfig); var result = apiInstance.CreateCredit(requestObj); Console.WriteLine(result); return(result); } catch (Exception e) { Console.WriteLine("Exception on calling the API: " + e.Message); return(null); } }
/// <summary> /// Process a Credit POST to the credit resource to credit funds to a specified credit card. /// </summary> /// <exception cref="CyberSource.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="createCreditRequest"></param> /// <returns>Task of ApiResponse (PtsV2CreditsPost201Response)</returns> public async System.Threading.Tasks.Task <ApiResponse <PtsV2CreditsPost201Response> > CreateCreditAsyncWithHttpInfo(CreateCreditRequest createCreditRequest) { // verify the required parameter 'createCreditRequest' is set if (createCreditRequest == null) { throw new ApiException(400, "Missing required parameter 'createCreditRequest' when calling CreditApi->CreateCredit"); } var localVarPath = $"/pts/v2/credits"; 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/hal+json;charset=utf-8" }; String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } if (createCreditRequest != null && createCreditRequest.GetType() != typeof(byte[])) { localVarPostBody = Configuration.ApiClient.Serialize(createCreditRequest); // http body (model) parameter } else { localVarPostBody = createCreditRequest; // 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("CreateCredit", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse <PtsV2CreditsPost201Response>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (PtsV2CreditsPost201Response)Configuration.ApiClient.Deserialize(localVarResponse, typeof(PtsV2CreditsPost201Response)))); }
/// <summary> /// Process a Credit POST to the credit resource to credit funds to a specified credit card. /// </summary> /// <exception cref="CyberSource.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="createCreditRequest"></param> /// <returns>Task of PtsV2CreditsPost201Response</returns> public async System.Threading.Tasks.Task <PtsV2CreditsPost201Response> CreateCreditAsync(CreateCreditRequest createCreditRequest) { ApiResponse <PtsV2CreditsPost201Response> localVarResponse = await CreateCreditAsyncWithHttpInfo(createCreditRequest); return(localVarResponse.Data); }
/// <summary> /// Process a Credit POST to the credit resource to credit funds to a specified credit card. /// </summary> /// <exception cref="CyberSource.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="createCreditRequest"></param> /// <returns>PtsV2CreditsPost201Response</returns> public PtsV2CreditsPost201Response CreateCredit(CreateCreditRequest createCreditRequest) { ApiResponse <PtsV2CreditsPost201Response> localVarResponse = CreateCreditWithHttpInfo(createCreditRequest); return(localVarResponse.Data); }
public static PtsV2CreditsPost201Response Run() { string clientReferenceInformationCode = "TC46125-1"; Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( Code: clientReferenceInformationCode ); string paymentInformationBankAccountType = "C"; string paymentInformationBankAccountNumber = "4100"; string paymentInformationBankAccountCheckNumber = "123456"; Ptsv2paymentsPaymentInformationBankAccount paymentInformationBankAccount = new Ptsv2paymentsPaymentInformationBankAccount( Type: paymentInformationBankAccountType, Number: paymentInformationBankAccountNumber, CheckNumber: paymentInformationBankAccountCheckNumber ); string paymentInformationBankRoutingNumber = "071923284"; Ptsv2paymentsPaymentInformationBank paymentInformationBank = new Ptsv2paymentsPaymentInformationBank( Account: paymentInformationBankAccount, RoutingNumber: paymentInformationBankRoutingNumber ); string paymentInformationPaymentTypeName = "CHECK"; Ptsv2paymentsPaymentInformationPaymentType paymentInformationPaymentType = new Ptsv2paymentsPaymentInformationPaymentType( Name: paymentInformationPaymentTypeName ); Ptsv2paymentsidrefundsPaymentInformation paymentInformation = new Ptsv2paymentsidrefundsPaymentInformation( Bank: paymentInformationBank, PaymentType: paymentInformationPaymentType ); string orderInformationAmountDetailsTotalAmount = "100"; string orderInformationAmountDetailsCurrency = "USD"; Ptsv2paymentsidcapturesOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsidcapturesOrderInformationAmountDetails( TotalAmount: orderInformationAmountDetailsTotalAmount, Currency: orderInformationAmountDetailsCurrency ); string orderInformationBillToFirstName = "John"; string orderInformationBillToLastName = "Doe"; string orderInformationBillToAddress1 = "1 Market St"; string orderInformationBillToLocality = "san francisco"; string orderInformationBillToAdministrativeArea = "CA"; string orderInformationBillToPostalCode = "94105"; string orderInformationBillToCountry = "US"; string orderInformationBillToEmail = "*****@*****.**"; string orderInformationBillToPhoneNumber = "4158880000"; Ptsv2paymentsidcapturesOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsidcapturesOrderInformationBillTo( FirstName: orderInformationBillToFirstName, LastName: orderInformationBillToLastName, Address1: orderInformationBillToAddress1, Locality: orderInformationBillToLocality, AdministrativeArea: orderInformationBillToAdministrativeArea, PostalCode: orderInformationBillToPostalCode, Country: orderInformationBillToCountry, Email: orderInformationBillToEmail, PhoneNumber: orderInformationBillToPhoneNumber ); Ptsv2paymentsidrefundsOrderInformation orderInformation = new Ptsv2paymentsidrefundsOrderInformation( AmountDetails: orderInformationAmountDetails, BillTo: orderInformationBillTo ); var requestObj = new CreateCreditRequest( ClientReferenceInformation: clientReferenceInformation, PaymentInformation: paymentInformation, OrderInformation: orderInformation ); try { var configDictionary = new Configuration().GetConfiguration(); var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new CreditApi(clientConfig); PtsV2CreditsPost201Response result = apiInstance.CreateCredit(requestObj); Console.WriteLine(result); return(result); } catch (Exception e) { Console.WriteLine("Exception on calling the API : " + e.Message); return(null); } }
public static PtsV2CreditsPost201Response Run() { string clientReferenceInformationCode = "12345678"; Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( Code: clientReferenceInformationCode ); string paymentInformationCardExpirationMonth = "03"; string paymentInformationCardExpirationYear = "2031"; string paymentInformationCardType = "001"; Ptsv2paymentsidrefundsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsidrefundsPaymentInformationCard( ExpirationMonth: paymentInformationCardExpirationMonth, ExpirationYear: paymentInformationCardExpirationYear, Type: paymentInformationCardType ); string paymentInformationInstrumentIdentifierId = "7010000000016241111"; Ptsv2paymentsPaymentInformationInstrumentIdentifier paymentInformationInstrumentIdentifier = new Ptsv2paymentsPaymentInformationInstrumentIdentifier( Id: paymentInformationInstrumentIdentifierId ); Ptsv2paymentsidrefundsPaymentInformation paymentInformation = new Ptsv2paymentsidrefundsPaymentInformation( Card: paymentInformationCard, InstrumentIdentifier: paymentInformationInstrumentIdentifier ); string orderInformationAmountDetailsTotalAmount = "200"; string orderInformationAmountDetailsCurrency = "usd"; Ptsv2paymentsidcapturesOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsidcapturesOrderInformationAmountDetails( TotalAmount: orderInformationAmountDetailsTotalAmount, Currency: orderInformationAmountDetailsCurrency ); string orderInformationBillToFirstName = "John"; string orderInformationBillToLastName = "Deo"; string orderInformationBillToAddress1 = "900 Metro Center Blvd"; string orderInformationBillToLocality = "Foster City"; string orderInformationBillToAdministrativeArea = "CA"; string orderInformationBillToPostalCode = "48104-2201"; string orderInformationBillToCountry = "US"; string orderInformationBillToEmail = "*****@*****.**"; string orderInformationBillToPhoneNumber = "9321499232"; Ptsv2paymentsidcapturesOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsidcapturesOrderInformationBillTo( FirstName: orderInformationBillToFirstName, LastName: orderInformationBillToLastName, Address1: orderInformationBillToAddress1, Locality: orderInformationBillToLocality, AdministrativeArea: orderInformationBillToAdministrativeArea, PostalCode: orderInformationBillToPostalCode, Country: orderInformationBillToCountry, Email: orderInformationBillToEmail, PhoneNumber: orderInformationBillToPhoneNumber ); Ptsv2paymentsidrefundsOrderInformation orderInformation = new Ptsv2paymentsidrefundsOrderInformation( AmountDetails: orderInformationAmountDetails, BillTo: orderInformationBillTo ); var requestObj = new CreateCreditRequest( ClientReferenceInformation: clientReferenceInformation, PaymentInformation: paymentInformation, OrderInformation: orderInformation ); try { var configDictionary = new Configuration().GetConfiguration(); var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new CreditApi(clientConfig); PtsV2CreditsPost201Response result = apiInstance.CreateCredit(requestObj); Console.WriteLine(result); return(result); } catch (Exception e) { Console.WriteLine("Exception on calling the API : " + e.Message); return(null); } }
public static PtsV2CreditsPost201Response Run() { string clientReferenceInformationCode = "demomerchant"; Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( Code: clientReferenceInformationCode ); string processingInformationCommerceIndicator = "retail"; Ptsv2creditsProcessingInformation processingInformation = new Ptsv2creditsProcessingInformation( CommerceIndicator: processingInformationCommerceIndicator ); string paymentInformationCardExpirationMonth = "12"; string paymentInformationCardExpirationYear = "2050"; Ptsv2paymentsidrefundsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsidrefundsPaymentInformationCard( ExpirationMonth: paymentInformationCardExpirationMonth, ExpirationYear: paymentInformationCardExpirationYear ); string paymentInformationFluidDataDescriptor = "Ymx1ZWZpbg=="; string paymentInformationFluidDataValue = "02d700801f3c20008383252a363031312a2a2a2a2a2a2a2a303030395e46444d53202020202020202020202020202020202020202020205e323231322a2a2a2a2a2a2a2a3f2a3b363031312a2a2a2a2a2a2a2a303030393d323231322a2a2a2a2a2a2a2a3f2a7a75ad15d25217290c54b3d9d1c3868602136c68d339d52d98423391f3e631511d548fff08b414feac9ff6c6dede8fb09bae870e4e32f6f462d6a75fa0a178c3bd18d0d3ade21bc7a0ea687a2eef64551751e502d97cb98dc53ea55162cdfa395431323439323830303762994901000001a000731a8003"; Ptsv2paymentsPaymentInformationFluidData paymentInformationFluidData = new Ptsv2paymentsPaymentInformationFluidData( Descriptor: paymentInformationFluidDataDescriptor, Value: paymentInformationFluidDataValue ); Ptsv2paymentsidrefundsPaymentInformation paymentInformation = new Ptsv2paymentsidrefundsPaymentInformation( Card: paymentInformationCard, FluidData: paymentInformationFluidData ); string orderInformationAmountDetailsTotalAmount = "100.00"; string orderInformationAmountDetailsCurrency = "USD"; Ptsv2paymentsidcapturesOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsidcapturesOrderInformationAmountDetails( TotalAmount: orderInformationAmountDetailsTotalAmount, Currency: orderInformationAmountDetailsCurrency ); string orderInformationBillToFirstName = "John"; string orderInformationBillToLastName = "Deo"; string orderInformationBillToAddress1 = "201 S. Division St."; string orderInformationBillToLocality = "Ann Arbor"; string orderInformationBillToAdministrativeArea = "MI"; string orderInformationBillToPostalCode = "48104-2201"; string orderInformationBillToCountry = "US"; string orderInformationBillToEmail = "*****@*****.**"; string orderInformationBillToPhoneNumber = "999999999"; Ptsv2paymentsidcapturesOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsidcapturesOrderInformationBillTo( FirstName: orderInformationBillToFirstName, LastName: orderInformationBillToLastName, Address1: orderInformationBillToAddress1, Locality: orderInformationBillToLocality, AdministrativeArea: orderInformationBillToAdministrativeArea, PostalCode: orderInformationBillToPostalCode, Country: orderInformationBillToCountry, Email: orderInformationBillToEmail, PhoneNumber: orderInformationBillToPhoneNumber ); Ptsv2paymentsidrefundsOrderInformation orderInformation = new Ptsv2paymentsidrefundsOrderInformation( AmountDetails: orderInformationAmountDetails, BillTo: orderInformationBillTo ); int pointOfSaleInformationCatLevel = 1; string pointOfSaleInformationEntryMode = "keyed"; int pointOfSaleInformationTerminalCapability = 2; Ptsv2paymentsPointOfSaleInformation pointOfSaleInformation = new Ptsv2paymentsPointOfSaleInformation( CatLevel: pointOfSaleInformationCatLevel, EntryMode: pointOfSaleInformationEntryMode, TerminalCapability: pointOfSaleInformationTerminalCapability ); var requestObj = new CreateCreditRequest( ClientReferenceInformation: clientReferenceInformation, ProcessingInformation: processingInformation, PaymentInformation: paymentInformation, OrderInformation: orderInformation, PointOfSaleInformation: pointOfSaleInformation ); try { var configDictionary = new Configuration().GetConfiguration(); var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new CreditApi(clientConfig); PtsV2CreditsPost201Response result = apiInstance.CreateCredit(requestObj); Console.WriteLine(result); return(result); } catch (Exception e) { Console.WriteLine("Exception on calling the API : " + e.Message); return(null); } }
/// <summary> /// Process a Credit POST to the credit resource to credit funds to a specified credit card. /// </summary> /// <exception cref="CyberSource.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="createCreditRequest"></param> /// <returns>Task of PtsV2CreditsPost201Response</returns> public async System.Threading.Tasks.Task <PtsV2CreditsPost201Response> CreateCreditAsync(CreateCreditRequest createCreditRequest) { logger.Debug("CALLING API \"CreateCreditAsync\" STARTED"); this.SetStatusCode(null); ApiResponse <PtsV2CreditsPost201Response> localVarResponse = await CreateCreditAsyncWithHttpInfo(createCreditRequest); logger.Debug("CALLING API \"CreateCreditAsync\" ENDED"); this.SetStatusCode(localVarResponse.StatusCode); return(localVarResponse.Data); }
/// <summary> /// Process a Credit POST to the credit resource to credit funds to a specified credit card. /// </summary> /// <exception cref="CyberSource.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="createCreditRequest"></param> /// <returns>ApiResponse of PtsV2CreditsPost201Response</returns> public ApiResponse <PtsV2CreditsPost201Response> CreateCreditWithHttpInfo(CreateCreditRequest createCreditRequest) { LogUtility logUtility = new LogUtility(); // verify the required parameter 'createCreditRequest' is set if (createCreditRequest == null) { logger.Error("ApiException : Missing required parameter 'createCreditRequest' when calling CreditApi->CreateCredit"); throw new ApiException(400, "Missing required parameter 'createCreditRequest' when calling CreditApi->CreateCredit"); } var localVarPath = $"/pts/v2/credits"; 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/hal+json;charset=utf-8" }; string localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } if (createCreditRequest != null && createCreditRequest.GetType() != typeof(byte[])) { localVarPostBody = Configuration.ApiClient.Serialize(createCreditRequest); // http body (model) parameter } else { localVarPostBody = createCreditRequest; // 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)Configuration.ApiClient.CallApi(localVarPath, Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (ExceptionFactory != null) { Exception exception = ExceptionFactory("CreateCredit", localVarResponse); if (exception != null) { logger.Error($"Exception : {exception.Message}"); throw exception; } } return(new ApiResponse <PtsV2CreditsPost201Response>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (PtsV2CreditsPost201Response)Configuration.ApiClient.Deserialize(localVarResponse, typeof(PtsV2CreditsPost201Response)))); // Return statement }
public static void Run(IReadOnlyDictionary <string, string> configDictionary) { var requestObj = new CreateCreditRequest(); var clientReferenceInformationObj = new V2paymentsClientReferenceInformation { Code = "TC12345" }; requestObj.ClientReferenceInformation = clientReferenceInformationObj; var buyerInformationObj = new V2paymentsidcapturesBuyerInformation { MerchantCustomerId = "123456abcd" }; requestObj.BuyerInformation = buyerInformationObj; var subMerchantObj = new V2paymentsidcapturesAggregatorInformationSubMerchant { Country = "US", PhoneNumber = "650-432-0000", Address1 = "900 Metro Center", PostalCode = "94404-2775", Locality = "Foster City", Name = "Visa Inc", AdministrativeArea = "CA", Email = "*****@*****.**" // subMerchantObj.CardAcceptorId = "1234567890"; // subMerchantObj.Region = "PEN"; }; var aggregatorInformationObj = new V2paymentsidcapturesAggregatorInformation { SubMerchant = subMerchantObj, Name = "V-Internatio", AggregatorId = "123456789" }; requestObj.AggregatorInformation = aggregatorInformationObj; var orderInformationObj = new V2paymentsidrefundsOrderInformation(); var shippingDetailsObj = new V2paymentsidcapturesOrderInformationShippingDetails { ShipFromPostalCode = "47404" }; orderInformationObj.ShippingDetails = shippingDetailsObj; var billToObj = new V2paymentsidcapturesOrderInformationBillTo { Country = "US", FirstName = "John", LastName = "Test", PhoneNumber = "9999999", Address2 = "test2credit", Address1 = "testcredit", PostalCode = "48104-2201", Locality = "Ann Arbor", Company = "Visa", AdministrativeArea = "MI", Email = "*****@*****.**" }; orderInformationObj.BillTo = billToObj; var invoiceDetailsObj = new V2paymentsidcapturesOrderInformationInvoiceDetails { PurchaseOrderDate = "20111231", PurchaseOrderNumber = "CREDIT US" }; orderInformationObj.InvoiceDetails = invoiceDetailsObj; var amountDetailsObj = new V2paymentsidcapturesOrderInformationAmountDetails { TotalAmount = "100", ExchangeRate = "0.5", ExchangeRateTimeStamp = "2.01304E+13", Currency = "usd" }; orderInformationObj.AmountDetails = amountDetailsObj; requestObj.OrderInformation = orderInformationObj; var merchantInformationObj = new V2paymentsidrefundsMerchantInformation { CategoryCode = 1234 }; requestObj.MerchantInformation = merchantInformationObj; var paymentInformationObj = new V2paymentsidrefundsPaymentInformation(); var cardObj = new V2paymentsidrefundsPaymentInformationCard { ExpirationYear = "2031", Number = "5555555555554444", ExpirationMonth = "12", Type = "002" // cardObj.SecurityCode = "123"; }; paymentInformationObj.Card = cardObj; requestObj.PaymentInformation = paymentInformationObj; var merchantConfig = new MerchantConfig(configDictionary) { RequestType = "POST", RequestTarget = "/pts/v2/credits/", RequestJsonData = JsonConvert.SerializeObject(requestObj) }; try { var configurationSwagger = new ApiClient().CallAuthenticationHeader(merchantConfig); var apiInstance = new CreditApi(configurationSwagger); var result = apiInstance.CreateCredit(requestObj); Console.WriteLine(result); } catch (Exception e) { Console.WriteLine("Exception on calling the API: " + e.Message); } }
public static PtsV2CreditsPost201Response Run() { string clientReferenceInformationCode = "12345678"; Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( Code: clientReferenceInformationCode ); string paymentInformationCardNumber = "4111111111111111"; string paymentInformationCardExpirationMonth = "03"; string paymentInformationCardExpirationYear = "2031"; Ptsv2paymentsidrefundsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsidrefundsPaymentInformationCard( Number: paymentInformationCardNumber, ExpirationMonth: paymentInformationCardExpirationMonth, ExpirationYear: paymentInformationCardExpirationYear ); Ptsv2paymentsidrefundsPaymentInformation paymentInformation = new Ptsv2paymentsidrefundsPaymentInformation( Card: paymentInformationCard ); string orderInformationAmountDetailsTotalAmount = "2325.00"; string orderInformationAmountDetailsCurrency = "usd"; string orderInformationAmountDetailsServiceFeeAmount = "30.0"; Ptsv2paymentsidcapturesOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsidcapturesOrderInformationAmountDetails( TotalAmount: orderInformationAmountDetailsTotalAmount, Currency: orderInformationAmountDetailsCurrency, ServiceFeeAmount: orderInformationAmountDetailsServiceFeeAmount ); string orderInformationBillToFirstName = "John"; string orderInformationBillToLastName = "Doe"; string orderInformationBillToAddress1 = "1 Market St"; string orderInformationBillToLocality = "san francisco"; string orderInformationBillToAdministrativeArea = "CA"; string orderInformationBillToPostalCode = "94105"; string orderInformationBillToCountry = "US"; string orderInformationBillToEmail = "*****@*****.**"; string orderInformationBillToPhoneNumber = "4158880000"; Ptsv2paymentsidcapturesOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsidcapturesOrderInformationBillTo( FirstName: orderInformationBillToFirstName, LastName: orderInformationBillToLastName, Address1: orderInformationBillToAddress1, Locality: orderInformationBillToLocality, AdministrativeArea: orderInformationBillToAdministrativeArea, PostalCode: orderInformationBillToPostalCode, Country: orderInformationBillToCountry, Email: orderInformationBillToEmail, PhoneNumber: orderInformationBillToPhoneNumber ); Ptsv2paymentsidrefundsOrderInformation orderInformation = new Ptsv2paymentsidrefundsOrderInformation( AmountDetails: orderInformationAmountDetails, BillTo: orderInformationBillTo ); var requestObj = new CreateCreditRequest( ClientReferenceInformation: clientReferenceInformation, PaymentInformation: paymentInformation, OrderInformation: orderInformation ); try { var configDictionary = new Configuration().GetConfiguration(); var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new CreditApi(clientConfig); PtsV2CreditsPost201Response result = apiInstance.CreateCredit(requestObj); Console.WriteLine(result); return(result); } catch (Exception e) { Console.WriteLine("Exception on calling the API : " + e.Message); return(null); } }