コード例 #1
0
        public ActionResult TryChargeAgain(InvoiceVM model)
        {
            if ((!ModelState.IsValid) && (CastleClub.BusinessLogic.Data.GlobalParameters.TryChargeAgain))
            {
                return(Json(new { Result = false }));
            }

            bool resp = PaymentsManager.ProcessInvoice(model.Id);

            InvoiceDT     invoice     = PaymentsManager.GetInvoice(model.Id);
            TransactionDT transaction = invoice.Transactions.OrderByDescending(x => x.SubmitDate).FirstOrDefault();

            /* InvoiceDT invoice = null;
             * TransactionDT transaction = null;
             * resp = false;
             * return Json(new { Result = false, Info = new { Authorize = "", SubmitDate = DateTime.Now.ToString(), Type = "", Message ="hola", Status = "FAIL", Amount = "222", Parent = string.Empty } }); */
            if (resp)
            {
                return(Json(new { Result = true, Info = new { Authorize = transaction.AuthorizeTransactionId.ToString(), SubmitDate = transaction.SubmitDate.ToString(), Type = transaction.Type.ToString(), Message = transaction.Message, Status = transaction.Status.ToString(), Amount = invoice.Amount.ToString(), Parent = string.Empty } }));
            }
            else
            {
                if (transaction != null)
                {
                    return(Json(new { Result = false, Info = new { Authorize = transaction.AuthorizeTransactionId.ToString(), SubmitDate = transaction.SubmitDate.ToString(), Type = transaction.Type.ToString(), Message = transaction.Message, Status = transaction.Status.ToString(), Amount = invoice.Amount.ToString(), Parent = string.Empty } }));
                }
                else
                {
                    return(Json(new { Result = false }));
                }
            }
        }
コード例 #2
0
        public ActionResult Refund(string customerId, string invoiceId, string refundReason)
        {
            int cId = 0;

            Int32.TryParse(customerId, out cId);
            int iId = 0;

            Int32.TryParse(invoiceId, out iId);
            decimal       amount        = 0;
            TransactionDT transactionDT = CustomersManager.Refund(cId, iId, refundReason, out amount);

            ViewBag.Transaction = transactionDT;
            ViewBag.Amount      = amount;

            return(View("TransactionRow"));
        }
コード例 #3
0
        public TransactionDT GetDT()
        {
            TransactionDT res = new TransactionDT();

            res.Id                     = Id;
            res.InvoiceId              = InvoiceId;
            res.CreditCardId           = CreditCardId;
            res.AuthorizeTransactionId = AuthorizeTransactionId;
            res.Type                   = Type;
            res.Status                 = Status;
            res.SubmitDate             = SubmitDate;
            res.RefundedTransactionId  = RefundedTransactionId.HasValue ? RefundedTransactionId.Value : 0;
            res.RefundedTrnAuthorizeId = RefundedTransactionId.HasValue ? RefundedTransaction.AuthorizeTransactionId : 0;
            res.Message                = Message;
            return(res);
        }
コード例 #4
0
        public static bool CreateCustomerProfileTransactionRefund(SiteDT site, InvoiceDT invoice, TransactionDT transaction, CustomerDT customer, CreditCardDT creditCard, out long transactionId, out string message)
        {
            //This datetime is when system change.
            int deployYear  = CastleClub.BusinessLogic.Data.GlobalParameters.DeployYear;
            int deployMonth = CastleClub.BusinessLogic.Data.GlobalParameters.DeployMonth;
            int deployDay   = CastleClub.BusinessLogic.Data.GlobalParameters.DeployDay;

            if (invoice.BilledDate >= new DateTime(deployYear, deployMonth, deployDay))
            {
                MerchantAuthenticationType merchantAT = new MerchantAuthenticationType();
                merchantAT.name           = site.AuthorizeLoginId;
                merchantAT.transactionKey = site.AuthorizeTransactionKey;

                ProfileTransactionType profileTT  = new ProfileTransactionType();
                ProfileTransRefundType profileTRT = new ProfileTransRefundType();

                OrderExType orderET = new OrderExType();
                orderET.invoiceNumber = invoice.Id.ToString();

                profileTRT.amount                            = invoice.Amount;
                profileTRT.transId                           = transaction.AuthorizeTransactionId.ToString();
                profileTRT.customerProfileId                 = customer.AuthorizeProfileId;
                profileTRT.customerProfileIdSpecified        = true;
                profileTRT.customerPaymentProfileId          = creditCard.AuthorizePaymentProfileId;
                profileTRT.customerPaymentProfileIdSpecified = true;
                profileTRT.order = orderET;


                profileTT.Item = profileTRT;
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
                ServiceSoapClient client = new ServiceSoapClient();
                CreateCustomerProfileTransactionResponseType resp = client.CreateCustomerProfileTransaction(merchantAT, profileTT, String.Empty);

                if (resp.directResponse != null)
                {
                    PaymentGatewayResponse paymentGatewayResponse = new PaymentGatewayResponse(resp.directResponse);
                    transactionId = paymentGatewayResponse.TransactionId;
                    message       = paymentGatewayResponse.ResponseReasonText;
                }
                else
                {
                    transactionId = 0;
                    if (resp.messages.Length > 0)
                    {
                        message = resp.messages[0].text;
                    }
                    else
                    {
                        message = "";
                    }
                }

                return(resp.resultCode == MessageTypeEnum.Ok);
            }
            else
            {
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
                using (ServiceSoapClient client = new ServiceSoapClient())
                {
                    MerchantAuthenticationType merchant = new MerchantAuthenticationType()
                    {
                        name           = site.AuthorizeLoginId,
                        transactionKey = site.AuthorizeTransactionKey
                    };

                    ProfileTransactionType profileTT  = new ProfileTransactionType();
                    ProfileTransRefundType profileTRT = new ProfileTransRefundType();

                    profileTRT.amount  = invoice.Amount;
                    profileTRT.transId = transaction.AuthorizeTransactionId.ToString();
                    profileTRT.creditCardNumberMasked = "XXXX" + creditCard.LastFourDigit;

                    profileTT.Item = profileTRT;

                    var resp = client.CreateCustomerProfileTransaction(merchant, profileTT, string.Empty);
                    if (resp.resultCode == MessageTypeEnum.Ok)
                    {
                        PaymentGatewayResponse paymentGatewayResponse = new PaymentGatewayResponse(resp.directResponse);
                        transactionId = paymentGatewayResponse.TransactionId;
                        message       = paymentGatewayResponse.ResponseReasonText;
                    }
                    else
                    {
                        transactionId = 0;
                        message       = string.Empty;
                        message       = resp.messages != null && resp.messages.Count() > 0 ? resp.messages.Select(a => a.text).Aggregate((a, b) => a + " - " + b) : string.Empty;
                    }

                    return(resp.resultCode == MessageTypeEnum.Ok);
                }
            }
        }