예제 #1
0
 public void ProcessRefundTest()
 {
     string requestUrl = string.Empty; // TODO: Initialize to an appropriate value
     string loginId = string.Empty; // TODO: Initialize to an appropriate value
     string transactionKey = string.Empty; // TODO: Initialize to an appropriate value
     ICustomer customer = null; // TODO: Initialize to an appropriate value
     CreditCardInfo card = null; // TODO: Initialize to an appropriate value
     Decimal amount = new Decimal(); // TODO: Initialize to an appropriate value
     bool testTransaction = false; // TODO: Initialize to an appropriate value
     ANetRequest target = new ANetRequest(requestUrl, loginId, transactionKey, customer, card, amount, testTransaction); // TODO: Initialize to an appropriate value
     ANetResponse expected = null; // TODO: Initialize to an appropriate value
     ANetResponse actual;
     actual = target.ProcessRefund();
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
예제 #2
0
 public void ANetRequestConstructorTest()
 {
     string requsetUrl = string.Empty; // TODO: Initialize to an appropriate value
     string loginId = string.Empty; // TODO: Initialize to an appropriate value
     string transactionKey = string.Empty; // TODO: Initialize to an appropriate value
     ICustomer customer = null; // TODO: Initialize to an appropriate value
     CreditCardInfo card = null; // TODO: Initialize to an appropriate value
     string transactionID = string.Empty; // TODO: Initialize to an appropriate value
     TransactionInfo transaction = null; // TODO: Initialize to an appropriate value
     bool testTransaction = false; // TODO: Initialize to an appropriate value
     Decimal amount = new Decimal(); // TODO: Initialize to an appropriate value
     ANetRequest target = new ANetRequest(requsetUrl, loginId, transactionKey, customer, card, transactionID, transaction, testTransaction, amount);
     Assert.Inconclusive("TODO: Implement code to verify target");
 }
예제 #3
0
        public override void Refund(GatewayInfo gateway, GatewayTypeInfo gatewayType, Guid orderId, ICustomer customer, CreditCardInfo card, string refID, TransactionInfo transaction,
            bool testTransaction)
        {
            ANetRequest request = null;
            ANetResponse response = null;

            string requestUrl = testTransaction == true ? gatewayType.TestUrl : gatewayType.LiveUrl;
            string loginId = testTransaction == true ? gatewayType.TestLoginId : gateway.LoginId;
            string transactionKey = testTransaction == true ? gatewayType.TestTransactionKey : gateway.TransactionKey;

            request = new ANetRequest(requestUrl, loginId, transactionKey, customer, card, refID, transaction, testTransaction, transaction.Amount);
           
            response = request.ProcessRefund();

            if (response.Code == ANetResponseCode.Approved)
            {
                transaction.Status = TransactionStatus.Refunded;
            }
        }
예제 #4
0
        public override TransactionInfo ProcessSubscription(ref SubscriptionInfo sub, GatewayInfo gateway, GatewayTypeInfo gatewayType, ICustomer customer, CreditCardInfo card, bool isTrial, bool testTransaction)
        {
            ANetRequest request = null;
            ANetResponse response = null;
            TransactionInfo transactionInfo = new TransactionInfo();

            string requestUrl = testTransaction == true ? gatewayType.TestUrl : gatewayType.LiveUrl;
            string loginId = testTransaction == true ? gatewayType.TestLoginId : gateway.LoginId;
            string transactionKey = testTransaction == true ? gatewayType.TestTransactionKey : gateway.TransactionKey;
            decimal amount = isTrial == true ? sub.TrialAmount : sub.Amount;

            request = new ANetRequest(requestUrl, loginId, transactionKey, customer, card, amount, testTransaction);
            response = request.ProcessAuthCapture();


            sub.LastProcessedDate = DateTime.Now;

            transactionInfo.Id = Guid.NewGuid();
            transactionInfo.SubscriptionId = sub.Id;
            transactionInfo.GatewayId = sub.GatewayId;
            transactionInfo.CreateDate = DateTime.Now;
            transactionInfo.IsTrial = isTrial;
            transactionInfo.Type = TransactionType.Standard;
            transactionInfo.Amount = amount;
            transactionInfo.GatewayAmount = gateway.TransactionFee;
            transactionInfo.OrderId = sub.RefId;
            if (response == null)
            {
                sub.LastProcessingStatus = TransactionStatus.Error;
                transactionInfo.ResponseText = "";
                transactionInfo.Status = TransactionStatus.Error;
            }
            else if (response.Code == ANetResponseCode.Approved)
            {
                sub.LastProcessingStatus = TransactionStatus.Approved;
                if (isTrial)
                    sub.TrialOccurrencesDone += 1;
                else
                    sub.TotalOccurrencesDone += 1;
                transactionInfo.ResponseText = response.ResponseText;
                transactionInfo.Status = TransactionStatus.Approved;
            }
            else
            {
                sub.LastProcessingStatus = TransactionStatus.Error;
                transactionInfo.ResponseText = response.ResponseText;
                transactionInfo.Status = TransactionStatus.Error;
            }
            return transactionInfo;
        }
예제 #5
0
        public override TransactionInfo PreAuthorize(GatewayInfo gateway, GatewayTypeInfo gatewayType, Guid orderId, ICustomer customer, CreditCardInfo card, decimal amount, bool testTransaction)
        {
            ANetRequest request = null;
            ANetResponse response = null;
            TransactionInfo transactionInfo = new TransactionInfo();

            string requestUrl = testTransaction == true ? gatewayType.TestUrl : gatewayType.LiveUrl;
            string loginId = testTransaction == true ? gatewayType.TestLoginId : gateway.LoginId;
            string transactionKey = testTransaction == true ? gatewayType.TestTransactionKey : gateway.TransactionKey;

            request = new ANetRequest(requestUrl, loginId, transactionKey, customer, card, amount, testTransaction);
            response = request.ProcessAuthOnly();

            transactionInfo.Id = Guid.NewGuid();
            //transactionInfo.CustomerName = System.Web.Security.Membership.GetUser(customer.ID).UserName;
            transactionInfo.SubscriptionId = Guid.Empty;
            transactionInfo.GatewayId = gateway.Id;
            transactionInfo.CreateDate = DateTime.Now;
            //transactionInfo.IsTrial = ??;
            transactionInfo.Type = TransactionType.Standard;
            transactionInfo.Amount = amount;
            transactionInfo.GatewayAmount = gateway.TransactionFee;
            transactionInfo.OrderId = orderId;
            if (response == null)
            {
                transactionInfo.ResponseText = "";
                transactionInfo.Status = TransactionStatus.Error;
            }
            else if (response.Code == ANetResponseCode.Approved)
            {
                transactionInfo.ResponseText = response.ResponseText;
                transactionInfo.Status = TransactionStatus.Approved;
            }
            else
            {
                transactionInfo.ResponseText = response.ResponseText;
                transactionInfo.Status = TransactionStatus.Error;
            }
            return transactionInfo;
        }