コード例 #1
0
        public static string ProcessCard(int orderNumber, int customerId, decimal orderTotal, long paymentProfileId, string transactionMode,
                                         bool useLiveTransactions, out string AVSResult, out string AuthorizationResult,
                                         out string AuthorizationCode, out string AuthorizationTransID, out string TransactionCommandOut, out string TransactionResponse)
        {
            AVSResult             = string.Empty;
            AuthorizationResult   = string.Empty;
            AuthorizationCode     = string.Empty;
            AuthorizationTransID  = string.Empty;
            TransactionCommandOut = string.Empty;
            TransactionResponse   = string.Empty;

            var status = ERROR;

            var         paymentProcessor = new PaymentProcessor();
            CIMResponse processStatus    = null;
            long        profileId        = DataUtility.GetProfileId(customerId);

            if (profileId > 0)
            {
                if (paymentProfileId > 0)
                {
                    if (transactionMode.ToUpperInvariant() == "AUTH")
                    {
                        processStatus = paymentProcessor.Authorize(profileId, paymentProfileId, orderNumber, orderTotal);
                    }
                    else if (transactionMode.ToUpperInvariant() == "AUTHCAPTURE")
                    {
                        processStatus = paymentProcessor.AuthCapture(profileId, paymentProfileId, orderNumber, orderTotal);
                    }
                }
            }
            if (processStatus != null)
            {
                if (processStatus.Success)
                {
                    status               = OK;
                    AVSResult            = processStatus.AvsCode;
                    AuthorizationResult  = processStatus.AuthMessage;
                    AuthorizationCode    = processStatus.AuthCode;
                    AuthorizationTransID = processStatus.TransactionId;
                }
                else
                {
                    status = processStatus.AuthMessage;

                    if (string.IsNullOrEmpty(status))
                    {
                        status = "There was an error processing your payment. Please try again, choose a different payment method, or contact customer support.";
                    }
                }
            }
            return(status);
        }