示例#1
0
        public void RefundTest()
        {
            Transaction transaction = this.TransactionService.ProcessWithoutUserInteraction(this.SpaceId, this.Transaction.Id);

            Console.WriteLine(transaction.Id);
            TransactionState[] TransactionStates =
            {
                TransactionState.FAILED,
                TransactionState.FULFILL
            };
            for (var i = 1; i <= 5; i++)
            {
                Console.WriteLine(transaction.State);

                if (Array.Exists(TransactionStates, element => element == transaction.State))
                {
                    break;
                }
                System.Threading.Thread.Sleep(i * 30);
                transaction = this.TransactionService.Read(this.SpaceId, transaction.Id);
            }

            if (transaction.State == TransactionState.FULFILL)
            {
                TransactionCompletion transactionCompletion = this.TransactionCompletionService.CompleteOffline(this.SpaceId, transaction.Id);
                Assert.AreEqual(transactionCompletion.State, TransactionCompletionState.SUCCESSFUL);
                transaction = this.TransactionService.Read(this.SpaceId, transactionCompletion.LinkedTransaction);  // fetch the latest transaction data
                RefundCreate refundPayload = this.GetRefundPayload(transaction);
                Refund       refund        = this.RefundService.Refund(this.SpaceId, refundPayload);
                Assert.AreEqual(refund.State, RefundState.SUCCESSFUL);
            }
        }
示例#2
0
        // <summary>
        // Get refund payload
        // <summary>
        private RefundCreate GetRefundPayload(Transaction transaction)
        {
            RefundCreate refundPayload = new RefundCreate(transaction.Id.ToString(), RefundType.MERCHANT_INITIATED_ONLINE)
            {
                Amount            = transaction.AuthorizationAmount,
                Transaction       = transaction.Id,
                MerchantReference = transaction.MerchantReference
            };

            return(refundPayload);
        }
示例#3
0
        /// <summary>
        /// create This operation creates and executes a refund of a particular transaction.
        /// </summary>
        /// <exception cref="Wallee.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="spaceId"></param>
        /// <param name="refund">The refund object which should be created.</param>
        /// <returns>ApiResponse of Refund</returns>
        public ApiResponse <Refund> RefundWithHttpInfo(long?spaceId, RefundCreate refund)
        {
            // verify the required parameter 'spaceId' is set
            if (spaceId == null)
            {
                throw new ApiException(400, "Missing required parameter 'spaceId' when calling RefundService->Refund");
            }
            // verify the required parameter 'refund' is set
            if (refund == null)
            {
                throw new ApiException(400, "Missing required parameter 'refund' when calling RefundService->Refund");
            }

            var    localVarPath         = "/refund/refund";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new List <KeyValuePair <String, String> >();
            var    localVarHeaderParams = new Dictionary <String, String>(this.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 = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "application/json;charset=utf-8"
            };
            String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            if (spaceId != null)
            {
                localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("", "spaceId", spaceId));                  // query parameter
            }
            if (refund != null && refund.GetType() != typeof(byte[]))
            {
                localVarPostBody = this.Configuration.ApiClient.Serialize(refund); // http body (model) parameter
            }
            else
            {
                localVarPostBody = refund; // byte array
            }


            this.Configuration.ApiClient.ResetTimeout();
            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)this.Configuration.ApiClient.CallApi(localVarPath,
                                                                                                 Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                                 localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("Refund", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <Refund>(localVarStatusCode,
                                            localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                                            (Refund)this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(Refund))));
        }
示例#4
0
        /// <summary>
        /// create This operation creates and executes a refund of a particular transaction.
        /// </summary>
        /// <exception cref="Wallee.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="spaceId"></param>
        /// <param name="refund">The refund object which should be created.</param>
        /// <returns>Refund</returns>
        public Refund Refund(long?spaceId, RefundCreate refund)
        {
            ApiResponse <Refund> localVarResponse = RefundWithHttpInfo(spaceId, refund);

            return(localVarResponse.Data);
        }