/// <summary>
        /// CreateRefund Initiates a refund for a previously charged tender.
        /// </summary>
        /// <exception cref="ApiV2Exception">Thrown when fails to make API call</exception>
        /// <param name="authorization">The value to provide in the Authorization header of\nyour request. This value should follow the format `Bearer YOUR_ACCESS_TOKEN_HERE`.</param>
        /// <param name="locationId">The ID of the original transaction&#39;s associated location.</param>
        /// <param name="transactionId"></param>
        /// <param name="body">An object containing the fields to POST for the request.\n\nSee the corresponding object definition for field details.</param>
        /// <returns>Task of ApiResponse (CreateRefundResponse)</returns>
        public async System.Threading.Tasks.Task <ApiResponse <CreateRefundResponse> > CreateRefundAsyncWithHttpInfo(string authorization, string locationId, string transactionId, CreateRefundRequest body)
        {
            // verify the required parameter 'authorization' is set
            if (authorization == null)
            {
                throw new ApiV2Exception(400, "Missing required parameter 'authorization' when calling CreateRefund");
            }
            // verify the required parameter 'locationId' is set
            if (locationId == null)
            {
                throw new ApiV2Exception(400, "Missing required parameter 'locationId' when calling CreateRefund");
            }
            // verify the required parameter 'transactionId' is set
            if (transactionId == null)
            {
                throw new ApiV2Exception(400, "Missing required parameter 'transactionId' when calling CreateRefund");
            }
            // verify the required parameter 'body' is set
            if (body == null)
            {
                throw new ApiV2Exception(400, "Missing required parameter 'body' when calling CreateRefund");
            }


            var localVarPath = "/v2/locations/{location_id}/transactions/{transaction_id}/refund";

            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"
            };
            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);
            }

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            localVarPathParams.Add("format", "json");
            if (locationId != null)
            {
                localVarPathParams.Add("location_id", Configuration.ApiClient.ParameterToString(locationId));                     // path parameter
            }
            if (transactionId != null)
            {
                localVarPathParams.Add("transaction_id", Configuration.ApiClient.ParameterToString(transactionId));                        // path parameter
            }
            if (authorization != null)
            {
                localVarHeaderParams.Add("Authorization", Configuration.ApiClient.ParameterToString(authorization));                        // header parameter
            }
            if (body.GetType() != typeof(byte[]))
            {
                localVarPostBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter
            }
            else
            {
                localVarPostBody = body; // 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 (localVarStatusCode >= 400)
            {
                throw new ApiV2Exception(localVarStatusCode, "Error calling CreateRefund: " + localVarResponse.Content, localVarResponse.Content);
            }
            else if (localVarStatusCode == 0)
            {
                throw new ApiV2Exception(localVarStatusCode, "Error calling CreateRefund: " + localVarResponse.ErrorMessage, localVarResponse.ErrorMessage);
            }

            return(new ApiResponse <CreateRefundResponse>(localVarStatusCode,
                                                          localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                                                          (CreateRefundResponse)Configuration.ApiClient.Deserialize(localVarResponse, typeof(CreateRefundResponse))));
        }
Beispiel #2
0
        /// <summary>
        /// Create a Order Creates a zipMoney Order.  During the Order process a customer can apply for credit decisioning in real-time. This means the Order needs to represent a good picture of known customer details along with order information and the Order entity represents this as a resource.  For more information on how to Order with zipMoney see the #model:Z2QcrzRGHACY8wM6G guide.
        /// </summary>
        /// <exception cref="MerchantApi.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="body"> (optional)</param>
        /// <returns>ApiResponse of Order</returns>
        public ApiResponse <RefundOrder> OrderRefundWithHttpInfo(string id, CreateRefundRequest body = null)
        {
            var    localVarPath         = GetBasePath() + "/Order/" + id + "/refund";
            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"
            };
            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);
            }

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            localVarPathParams.Add("format", "json");
            if (body != null && body.GetType() != typeof(byte[]))
            {
                localVarPostBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter
            }
            else
            {
                localVarPostBody = body; // byte array
            }

            // authentication (Authorization) required
            if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("Authorization")))
            {
                localVarHeaderParams["Authorization"] = Configuration.GetApiKeyWithPrefix("Authorization");
            }

            // authentication (Idempotency-Key) required
            if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("Idempotency-Key")))
            {
                localVarHeaderParams["Idempotency-Key"] = Configuration.GetApiKeyWithPrefix("Idempotency-Key");
            }

            // 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("OrderRefund", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

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