Пример #1
0
        public void RefundPaymentTest()
        {
            var request = new TransparentRedirectRequest("http://www.eway.com.au", TransactionType.Purchase);

            request = SetupRequest(request) as TransparentRedirectRequest;

            var response = client.ProcessPayment <TransparentRedirectResponse>(request);

            Assert.IsNotNull(response.AccessCode);
            Assert.IsNotNull(response.FormActionURL);
            Assert.IsNull(response.Errors);

            SubmitPaymentForm(response.FormActionURL, response.AccessCode);

            var accessResponse = client.GetAccessCodeResult(response.AccessCode);

            Assert.IsNull(accessResponse.Errors);
            Assert.IsTrue((bool)accessResponse.TransactionStatus);

            var refundClient = new TransactionClient(CredentialUtils.GetTestCredentials(), true);

            var refundRequest = new RefundRequest();

            refundRequest = SetupRequest(refundRequest) as RefundRequest;

            var refundResponse = refundClient.RefundTransaction(refundRequest, accessResponse.TransactionID.ToString());

            Assert.IsNull(refundResponse.Errors);

            var queryResponse = refundClient.QueryTransaction(accessResponse.TransactionID.ToString());

            Assert.AreEqual(1, queryResponse.Transactions.Count);
            Assert.AreEqual(string.Empty, queryResponse.Errors);
        }
Пример #2
0
        public static bool Refund(Cashflow.Message.Data.Transaction transaction, string username, string password)
        {
            if (transaction == null)
            {
                return(false);
            }

            TransactionClient transactionClient = new TransactionClient();

            RefundTransactionRequest refundTransactionRequest =
                new RefundTransactionRequest(RequestMode.Synchronous,
                                             transaction.TransactionID.ToString(),
                                             username,
                                             password,
                                             transaction.TransactionID,
                                             RefundReason.Custom,
                                             "MP: Refunding our payments!",
                                             null);

            RefundTransactionResponse refundTransactionResponse = transactionClient.RefundTransaction(refundTransactionRequest, null);

            return(refundTransactionResponse.Status.Code == MessageStatusCode.Success);
        }