Esempio n. 1
0
        //Payment
        public PaymentResponse ExecutePayment(PaymentRequest request)
        {
            var response = new PaymentResponse();

            Type type = request.GetType();

            if (type.FullName == "BOA.Types.Banking.PaymentRequest")
            {
                var pr = new BOA.Process.Banking.Payment();
                if (request.MethodName == "AddPayment")
                {
                    response = pr.AddPayment((PaymentRequest)request);
                }
                else if (request.MethodName == "GetPayment")
                {
                    response = pr.GetPayment((PaymentRequest)request);
                }
            }
            return(response);
        }
        /// <summary>
        ///  Create A Payment
        /// </summary>
        /// <exception cref="AuthorizeNet.Rest.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="paymentRequest">charge credit card model</param>
        /// <param name="authorization">The value to provide in the Authorization header of ANET API request (optional)</param>
        /// <returns>Task of ApiResponse (Payment)</returns>
        public async System.Threading.Tasks.Task <ApiResponse <Payment> > CreateAPaymentAsyncWithHttpInfo(PaymentRequest paymentRequest, string authorization = null)
        {
            // verify the required parameter 'paymentRequest' is set
            if (paymentRequest == null)
            {
                throw new ApiException(400, "Missing required parameter 'paymentRequest' when calling PaymentsApi->CreateAPayment");
            }

            var    localVarPath         = "/payments";
            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 (authorization != null)
            {
                localVarHeaderParams.Add("Authorization", Configuration.ApiClient.ParameterToString(authorization));                        // header parameter
            }
            if (paymentRequest != null && paymentRequest.GetType() != typeof(byte[]))
            {
                localVarPostBody = Configuration.ApiClient.Serialize(paymentRequest); // http body (model) parameter
            }
            else
            {
                localVarPostBody = paymentRequest; // 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("CreateAPayment", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

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