Exemple #1
0
        /// <summary>
        /// Attempts to re-authorize the payment by the most appropriate method.
        /// </summary>
        /// <param name="Payment">The payment to re-authorize</param>
        protected CCResponse DoAuth(Payment Payment)
        {
            // Modified by cognizant 2/7/2005 to validate amount in star transaction.
            foreach (LineItem I in Payment.LineItems)
            {
                if (I.Amount < 0)
                {
                    return(new CCResponse(new BusinessRuleException("Amount should be positive")));
                }
            }
            if (Payment.Amount < 0)
            {
                return(new CCResponse(new BusinessRuleException("Total Amount should be positive")));
            }

            Payment.BillTo.ValidateFields();
            CheckEmail(Payment.Application, Payment.BillTo);

            /*
             * CSR#3937.Ch1 - START : Modified as part of CSR#3937
             * To fix the error, which occurs when we try to process a failed Credit Card transaction again
             * Moved the try statement from the line
             * if (Card.CCType!=string.Empty && Cards_Reversible.Contains.........   to the line
             * if (!Data.CheckReAuth(Payment))..........
             */
            try
            {
                //Check if payment is a candidate for reauth, if not just do auth.
                if (!Data.CheckReAuth(Payment))
                {
                    return(DoRequest(Payment));
                }
                CardInfo Card = Payment.Card;
                Payment.Card = null;

                //Make use of Reverse_Auth where permitted.
                if (Card.CCType != string.Empty && Cards_Reversible.Contains(Card.CCType) && ServiceRequest.Permits(ServiceOperation.Reverse, Payment.Application))
                {
                    Payment.Operation = ServiceOperation.Reverse;
                    CCResponse Response = DoRequest(Payment);
                    if (Response.IsRequestSuccessful)
                    {
                        Payment.Card      = Card;
                        Payment.Operation = ServiceOperation.Auth;
                        return(DoRequest(Payment));
                    }
                    else
                    {
                        return(Response);
                    }
                }
                else
                {
                    Payment.Card      = Card;
                    Payment.Operation = ServiceOperation.ReAuth;
                    Payment.LineItems = Reauth_Items;
                    return(DoRequest(Payment));
                }
            }
            //CSR#3937.Ch1 - END : Handling the failed credit card transactions(resubmission)
            catch (Exception e) { return(new CCResponse(e)); }
        }
Exemple #2
0
        internal CyberResponse(CyberSource.ICSReply csReply, ServiceRequest Request, int ID)
        {
            RequestID     = GetString(csReply, "request_id");
            ReturnCode    = GetString(csReply, "ics_rcode");
            Message       = GetString(csReply, "ics_rmsg");
            ActualMessage = GetString(csReply, "ics_rmsg");
            Flag          = GetString(csReply, "ics_rflag");
            AuthCode      = GetString(csReply, "auth_auth_code");
            switch (Request.Operation)
            {
            case ServiceOperation.Auth:
                _Amount       = GetAmount(csReply, "auth_auth_amount");
                _Trans_Ref_No = GetString(csReply, "auth_trans_ref_no");
                if (!IsRequestSuccessful && !this.IsReauthCandidate)
                {
                    _IsComplete = true;
                }
                break;

            case ServiceOperation.Bill:
                _Amount       = GetAmount(csReply, "bill_bill_amount");
                _Trans_Ref_No = GetString(csReply, "bill_trans_ref_no");
                if (IsRequestSuccessful)
                {
                    _IsComplete = true;
                }
                break;

            case ServiceOperation.Credit:
                _Amount       = GetAmount(csReply, "credit_credit_amount");
                _Trans_Ref_No = GetString(csReply, "credit_trans_ref_no");
                if (IsRequestSuccessful)
                {
                    _IsComplete = true;
                }
                break;

            case ServiceOperation.Process:
                _Amount       = GetAmount(csReply, "bill_bill_amount");
                _Trans_Ref_No = GetString(csReply, "bill_trans_ref_no");
                if (IsRequestSuccessful)
                {
                    _IsComplete = true;
                }
                break;

            case ServiceOperation.ReAuth:
                _Amount       = GetAmount(csReply, "auth_auth_amount");
                _Trans_Ref_No = GetString(csReply, "auth_trans_ref_no");
                break;

            case ServiceOperation.Reverse:
                _Amount       = GetAmount(csReply, "auth_reversal_amount");
                _Trans_Ref_No = "";
                break;
            }
            if (!IsRequestSuccessful)
            {
                string msg = Config.Setting("EM_" + Flag);
                if (msg.Length == 0)
                {
                    msg = Config.Setting("EM_DEFAULT");
                }
                if (msg.Length > 0)
                {
                    Message = msg + "\r\n\r\n(Error Code: " + Flag + ")";
                }
                ReturnCode = String.Empty;
            }
            _ID = ID;
        }