Exemple #1
0
        public void CreateAForcedCaptureTest()
        {
            Init();

            // Credit Card
            CreditCard creditCard = new CreditCard("4111111111111111", "0718", "VISA", "123");

            // Bank Account
            BankAccount bankAccount = new BankAccount(null, "325070760", "4111111", "demo acount", null, "bank anme", null);

            //Base AddressBillTo
            BaseAddress baseAdressBillTo = new BaseAddress
            {
                Address1    = " Demo Adress",
                Company     = "XXXXCOMAPNAY",
                Country     = "India",
                FirstName   = "Demo first",
                LastName    = "Demo Second",
                PhoneNumber = "1123456987",
                PostalCode  = "192123"
            };

            //Payment Instrunment
            PaymentInstrument paymentInstrument = new PaymentInstrument(null, bankAccount, null, null, true);

            ForcedCaptureRequest body = new ForcedCaptureRequest("10", "", paymentInstrument);
            string authorization      = "Basic asdadsa";

            mockRestClient.Expects.One.Method(v => v.Execute(new RestRequest())).With(NMock.Is.TypeOf(typeof(RestRequest))).WillReturn(paymentResponse);
            ApiClient apiClient = new ApiClient(mockRestClient.MockObject);

            apiClient.Configuration = null;

            Configuration configuration = new Configuration
            {
                ApiClient      = apiClient,
                Username       = "******",
                Password       = "******",
                AccessToken    = null,
                ApiKey         = null,
                ApiKeyPrefix   = null,
                TempFolderPath = null,
                DateTimeFormat = null,
                Timeout        = 60000,
                UserAgent      = "asdasd"
            };

            instance = new ForcedCapturesApi(configuration);
            var response = instance.CreateAForcedCapture(body, authorization);

            Assert.IsInstanceOf <Payment>(response, "response is Payment");
        }
Exemple #2
0
        /// <summary>
        ///  Create A Forced Capture
        /// </summary>
        /// <exception cref="AuthorizeNet.Rest.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="body"></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> > CreateAForcedCaptureAsyncWithHttpInfo(ForcedCaptureRequest body, string authorization = null)
        {
            // verify the required parameter 'body' is set
            if (body == null)
            {
                throw new ApiException(400, "Missing required parameter 'body' when calling ForcedCapturesApi->CreateAForcedCapture");
            }

            var    localVarPath         = "/forcedcaptures";
            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[] {
            };
            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 (body != null && 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 (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("CreateAForcedCapture", 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))));
        }
Exemple #3
0
        /// <summary>
        ///  Create A Forced Capture
        /// </summary>
        /// <exception cref="AuthorizeNet.Rest.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="body"></param>
        /// <param name="authorization">The value to provide in the Authorization header of ANET API request (optional)</param>
        /// <returns>Task of Payment</returns>
        public async System.Threading.Tasks.Task <Payment> CreateAForcedCaptureAsync(ForcedCaptureRequest body, string authorization = null)
        {
            ApiResponse <Payment> localVarResponse = await CreateAForcedCaptureAsyncWithHttpInfo(body, authorization);

            return(localVarResponse.Data);
        }
Exemple #4
0
        /// <summary>
        ///  Create A Forced Capture
        /// </summary>
        /// <exception cref="AuthorizeNet.Rest.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="body"></param>
        /// <param name="authorization">The value to provide in the Authorization header of ANET API request (optional)</param>
        /// <returns>Payment</returns>
        public Payment CreateAForcedCapture(ForcedCaptureRequest body, string authorization = null)
        {
            ApiResponse <Payment> localVarResponse = CreateAForcedCaptureWithHttpInfo(body, authorization);

            return(localVarResponse.Data);
        }