public static PtsV2PaymentsRefundPost201Response Run()
        {
            var capturePaymentId = CapturePayment.Run().Id;

            var clientReferenceInformationObj = new Ptsv2paymentsClientReferenceInformation("test_refund_capture");

            var amountDetailsObj = new Ptsv2paymentsidcapturesOrderInformationAmountDetails("102.21", "USD");

            var billToObj = new Ptsv2paymentsidcapturesOrderInformationBillTo
            {
                Country            = "US",
                FirstName          = "John",
                LastName           = "Doe",
                Address1           = "1 Market St",
                PostalCode         = "94105",
                Locality           = "San Francisco",
                AdministrativeArea = "CA",
                Email = "*****@*****.**"
            };
            var orderInformationObj = new Ptsv2paymentsidrefundsOrderInformation(amountDetailsObj, billToObj);

            var bankAccountObj = new Ptsv2paymentsPaymentInformationBankAccount
            {
                Number      = "4100",
                Type        = "C",
                CheckNumber = "123456"
            };

            var bankObj = new Ptsv2paymentsPaymentInformationBank
            {
                Account = bankAccountObj
            };

            bankObj.RoutingNumber = "071923284";

            var paymentInformationObj = new Ptsv2paymentsidrefundsPaymentInformation();

            paymentInformationObj.Bank = bankObj;

            var requestBody = new RefundCaptureRequest(clientReferenceInformationObj, null, paymentInformationObj, orderInformationObj);

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

                var result = apiInstance.RefundCapture(requestBody, capturePaymentId);

                Console.WriteLine(result.Id);

                Console.WriteLine(result);
                return(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception on calling the API: " + e.Message);
                return(null);
            }
        }
Example #2
0
        public static void Run(IReadOnlyDictionary <string, string> configDictionary)
        {
            var clientReferenceInformationObj = new V2paymentsClientReferenceInformation("Testing");
            var amountDetailsObj    = new V2paymentsidcapturesOrderInformationAmountDetails("102.21", "USD");
            var orderInformationObj = new V2paymentsidrefundsOrderInformation(amountDetailsObj);
            var requestBody         = new RefundCaptureRequest(clientReferenceInformationObj, null, null, orderInformationObj);

            var merchantConfig = new MerchantConfig(configDictionary)
            {
                RequestType     = "POST",
                RequestTarget   = "/pts/v2/captures/5336232827876732903529/refunds",
                RequestJsonData = JsonConvert.SerializeObject(requestBody)
            };

            try
            {
                var configurationSwagger = new ApiClient().CallAuthenticationHeader(merchantConfig);
                var apiInstance          = new RefundApi(configurationSwagger);
                var result = apiInstance.RefundCapture(requestBody, "5336232827876732903529");
                Console.WriteLine(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception on calling the API: " + e.Message);
            }
        }
Example #3
0
        /// <summary>
        /// Refund a Capture Refund a capture API is only used, if you have requested Capture independenlty using [/pts/v2/payments/{id}/captures](https://developer.cybersource.com/api-reference-assets/index.html#payments_capture) API call. Include the capture ID in the POST request to refund the captured amount.
        /// </summary>
        /// <exception cref="CyberSource.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="refundCaptureRequest"></param>
        /// <param name="id">The capture ID. This ID is returned from a previous capture request.</param>
        /// <returns>PtsV2PaymentsRefundPost201Response</returns>
        public PtsV2PaymentsRefundPost201Response RefundCapture(RefundCaptureRequest refundCaptureRequest, string id)
        {
            logger.Debug("CALLING API \"RefundCapture\" STARTED");
            this.SetStatusCode(null);
            ApiResponse <PtsV2PaymentsRefundPost201Response> localVarResponse = RefundCaptureWithHttpInfo(refundCaptureRequest, id);

            logger.Debug("CALLING API \"RefundCapture\" ENDED");
            this.SetStatusCode(localVarResponse.StatusCode);
            return(localVarResponse.Data);
        }
Example #4
0
        public static PtsV2PaymentsRefundPost201Response Run()
        {
            var id = CapturePayment.Run().Id;

            string clientReferenceInformationCode = "TC50171_3";
            Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation(
                Code: clientReferenceInformationCode
                );

            string orderInformationAmountDetailsTotalAmount = "102.21";
            string orderInformationAmountDetailsCurrency    = "USD";
            Ptsv2paymentsidcapturesOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsidcapturesOrderInformationAmountDetails(
                TotalAmount: orderInformationAmountDetailsTotalAmount,
                Currency: orderInformationAmountDetailsCurrency
                );

            Ptsv2paymentsidrefundsOrderInformation orderInformation = new Ptsv2paymentsidrefundsOrderInformation(
                AmountDetails: orderInformationAmountDetails
                );

            var requestObj = new RefundCaptureRequest(
                ClientReferenceInformation: clientReferenceInformation,
                OrderInformation: orderInformation
                );

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

                var apiInstance = new RefundApi(clientConfig);
                PtsV2PaymentsRefundPost201Response result = apiInstance.RefundCapture(requestObj, id);
                Console.WriteLine(result);
                return(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception on calling the API : " + e.Message);
                return(null);
            }
        }
Example #5
0
        public static void Run()
        {
            var capturePaymentId = CapturePayment.Run().Id;

            var clientReferenceInformationObj = new Ptsv2paymentsClientReferenceInformation("test_refund_capture");
            var amountDetailsObj    = new Ptsv2paymentsidcapturesOrderInformationAmountDetails("102.21", "USD");
            var orderInformationObj = new Ptsv2paymentsidrefundsOrderInformation(amountDetailsObj);
            var requestBody         = new RefundCaptureRequest(clientReferenceInformationObj, null, null, orderInformationObj);

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

                var result = apiInstance.RefundCapture(requestBody, capturePaymentId);
                Console.WriteLine(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception on calling the API: " + e.Message);
            }
        }
Example #6
0
        public static void Run(IReadOnlyDictionary <string, string> configDictionary)
        {
            var requestObj = new RefundCaptureRequest();

            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 merchantConfig = new MerchantConfig(configDictionary)
            {
                RequestType     = "POST",
                RequestTarget   = "/pts/v2/captures/5336232827876732903529/refunds",
                RequestJsonData = JsonConvert.SerializeObject(requestObj)
            };

            try
            {
                var configurationSwagger = new ApiClient().CallAuthenticationHeader(merchantConfig);
                var apiInstance          = new RefundApi(configurationSwagger);
                var result = apiInstance.RefundCapture(requestObj, "5336232827876732903529");
                Console.WriteLine(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception on calling the API: " + e.Message);
            }
        }
Example #7
0
        /// <summary>
        /// Refund a Capture Include the capture ID in the POST request to refund the captured amount.
        /// </summary>
        /// <exception cref="CyberSource.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="refundCaptureRequest"></param>
        /// <param name="id">The capture ID. This ID is returned from a previous capture request.</param>
        /// <returns>Task of ApiResponse (PtsV2PaymentsRefundPost201Response)</returns>
        public async System.Threading.Tasks.Task <ApiResponse <PtsV2PaymentsRefundPost201Response> > RefundCaptureAsyncWithHttpInfo(RefundCaptureRequest refundCaptureRequest, string id)
        {
            // verify the required parameter 'refundCaptureRequest' is set
            if (refundCaptureRequest == null)
            {
                throw new ApiException(400, "Missing required parameter 'refundCaptureRequest' when calling RefundApi->RefundCapture");
            }
            // verify the required parameter 'id' is set
            if (id == null)
            {
                throw new ApiException(400, "Missing required parameter 'id' when calling RefundApi->RefundCapture");
            }

            var    localVarPath         = $"/pts/v2/captures/{id}/refunds";
            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 (id != null)
            {
                localVarPathParams.Add("id", Configuration.ApiClient.ParameterToString(id));             // path parameter
            }
            if (refundCaptureRequest != null && refundCaptureRequest.GetType() != typeof(byte[]))
            {
                localVarPostBody = Configuration.ApiClient.Serialize(refundCaptureRequest); // http body (model) parameter
            }
            else
            {
                localVarPostBody = refundCaptureRequest; // 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("RefundCapture", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <PtsV2PaymentsRefundPost201Response>(localVarStatusCode,
                                                                        localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                                                                        (PtsV2PaymentsRefundPost201Response)Configuration.ApiClient.Deserialize(localVarResponse, typeof(PtsV2PaymentsRefundPost201Response))));
        }
Example #8
0
        /// <summary>
        /// Refund a Capture Include the capture ID in the POST request to refund the captured amount.
        /// </summary>
        /// <exception cref="CyberSource.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="refundCaptureRequest"></param>
        /// <param name="id">The capture ID. This ID is returned from a previous capture request.</param>
        /// <returns>Task of PtsV2PaymentsRefundPost201Response</returns>
        public async System.Threading.Tasks.Task <PtsV2PaymentsRefundPost201Response> RefundCaptureAsync(RefundCaptureRequest refundCaptureRequest, string id)
        {
            ApiResponse <PtsV2PaymentsRefundPost201Response> localVarResponse = await RefundCaptureAsyncWithHttpInfo(refundCaptureRequest, id);

            return(localVarResponse.Data);
        }
Example #9
0
        /// <summary>
        /// Refund a Capture Include the capture ID in the POST request to refund the captured amount.
        /// </summary>
        /// <exception cref="CyberSource.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="refundCaptureRequest"></param>
        /// <param name="id">The capture ID. This ID is returned from a previous capture request.</param>
        /// <returns>PtsV2PaymentsRefundPost201Response</returns>
        public PtsV2PaymentsRefundPost201Response RefundCapture(RefundCaptureRequest refundCaptureRequest, string id)
        {
            ApiResponse <PtsV2PaymentsRefundPost201Response> localVarResponse = RefundCaptureWithHttpInfo(refundCaptureRequest, id);

            return(localVarResponse.Data);
        }
Example #10
0
        /// <summary>
        /// Refund a Capture Refund a capture API is only used, if you have requested Capture independenlty using [/pts/v2/payments/{id}/captures](https://developer.cybersource.com/api-reference-assets/index.html#payments_capture) API call. Include the capture ID in the POST request to refund the captured amount.
        /// </summary>
        /// <exception cref="CyberSource.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="refundCaptureRequest"></param>
        /// <param name="id">The capture ID. This ID is returned from a previous capture request.</param>
        /// <returns>Task of PtsV2PaymentsRefundPost201Response</returns>
        public async System.Threading.Tasks.Task <PtsV2PaymentsRefundPost201Response> RefundCaptureAsync(RefundCaptureRequest refundCaptureRequest, string id)
        {
            logger.Debug("CALLING API \"RefundCaptureAsync\" STARTED");
            this.SetStatusCode(null);
            ApiResponse <PtsV2PaymentsRefundPost201Response> localVarResponse = await RefundCaptureAsyncWithHttpInfo(refundCaptureRequest, id);

            logger.Debug("CALLING API \"RefundCaptureAsync\" ENDED");
            this.SetStatusCode(localVarResponse.StatusCode);
            return(localVarResponse.Data);
        }
Example #11
0
        /// <summary>
        /// Refund a Capture Refund a capture API is only used, if you have requested Capture independenlty using [/pts/v2/payments/{id}/captures](https://developer.cybersource.com/api-reference-assets/index.html#payments_capture) API call. Include the capture ID in the POST request to refund the captured amount.
        /// </summary>
        /// <exception cref="CyberSource.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="refundCaptureRequest"></param>
        /// <param name="id">The capture ID. This ID is returned from a previous capture request.</param>
        /// <returns>ApiResponse of PtsV2PaymentsRefundPost201Response</returns>
        public ApiResponse <PtsV2PaymentsRefundPost201Response> RefundCaptureWithHttpInfo(RefundCaptureRequest refundCaptureRequest, string id)
        {
            LogUtility logUtility = new LogUtility();

            // verify the required parameter 'refundCaptureRequest' is set
            if (refundCaptureRequest == null)
            {
                logger.Error("ApiException : Missing required parameter 'refundCaptureRequest' when calling RefundApi->RefundCapture");
                throw new ApiException(400, "Missing required parameter 'refundCaptureRequest' when calling RefundApi->RefundCapture");
            }
            // verify the required parameter 'id' is set
            if (id == null)
            {
                logger.Error("ApiException : Missing required parameter 'id' when calling RefundApi->RefundCapture");
                throw new ApiException(400, "Missing required parameter 'id' when calling RefundApi->RefundCapture");
            }

            var    localVarPath         = $"/pts/v2/captures/{id}/refunds";
            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 (id != null)
            {
                localVarPathParams.Add("id", Configuration.ApiClient.ParameterToString(id)); // path parameter
            }
            logger.Debug($"HTTP Request Body :\n{logUtility.ConvertDictionaryToString(localVarPathParams)}");
            if (refundCaptureRequest != null && refundCaptureRequest.GetType() != typeof(byte[]))
            {
                localVarPostBody = Configuration.ApiClient.Serialize(refundCaptureRequest); // http body (model) parameter
            }
            else
            {
                localVarPostBody = refundCaptureRequest; // 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("RefundCapture", localVarResponse);
                if (exception != null)
                {
                    logger.Error($"Exception : {exception.Message}");
                    throw exception;
                }
            }

            return(new ApiResponse <PtsV2PaymentsRefundPost201Response>(localVarStatusCode,
                                                                        localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                                                                        (PtsV2PaymentsRefundPost201Response)Configuration.ApiClient.Deserialize(localVarResponse, typeof(PtsV2PaymentsRefundPost201Response)))); // Return statement
        }