Beispiel #1
0
        /// <summary>
        /// Returns a constructed CCResponse object with properties filled from
        /// the database Reader.
        /// </summary>
        /// <param name="Reader">Dataset with saved response properties.</param>
        private CyberResponse ReadResponse(SqlDataReader Reader)
        {
            CyberResponse R1 = new CyberResponse();

            CSAAWeb.Serializers.Serializer.CopyFrom(Reader, R1);
            Reader.Close();
            if (R1.Flag == "SOK")
            {
                R1.ReturnCode = "1";
            }
            return(R1);
        }
Beispiel #2
0
        /// <summary>
        /// Creates the records for the payment in the appropriate tables.  Returns
        /// the paymentID.
        /// </summary>
        /// <param name="Payment">
        /// A record with the complete payment information, with properties including the card, billing
        /// address, line items etc.
        /// </param>
        internal CyberResponse Begin_Transaction(PaymentClasses.Payment Payment)
        {
            //Start the transaction.
            if (LogInsert)
            {
                CSAAWeb.AppLogger.Logger.Log(Payment.ToString());
            }
            StartTransaction();
            try
            {
                CyberResponse Result = null;
                bool          IsNew  = false;
                Payment.PaymentId = Insert_Payment(Payment, out IsNew);
                if (IsNew)
                {
                    Insert_Lines(Payment.PaymentId, Payment.LineItems);
                    Insert_Record(GetCommand("PAY_Update_Payment_User"), Payment.PaymentId, Payment.User);
                }
                if (Payment.Card != null)
                {
                    Insert_Record(GetCommand("PAY_Insert_Card_Detail"), Payment.PaymentId, Payment.Card);
                }
                if (Payment.PaymentType == PaymentTypes.CreditCard)
                {
                    Result = InsertCardRequest(Payment);
                }
                else
                {
                    Result = new CyberResponse();
                }
                CompleteTransaction(true);
                Result.ReceiptNumber = Payment.ReceiptNumber;
                return(Result);
            }
            catch (SqlException e)
            {
                //Modified by Cognizant to log the SqlException - on 03-31-2005
                Logger.Log(e);

                CompleteTransaction(false);
                if (e.Number != 50000)
                {
                    throw;
                }
                throw new BusinessRuleException(e);
            }
            catch
            {
                CompleteTransaction(false);
                throw;
            }
        }
Beispiel #3
0
 /// <summary>
 /// Actual code for processing credit card payments.
 /// </summary>
 /// <param name="Payment">The payment to process.</param>
 /// <returns>CCResponse instance with result data.</returns>
 protected CCResponse DoRequest(Payment Payment)
 {
     try
     {
         string RequestID = string.Empty;
         CheckAppAllowed(Payment.Application);
         if (IsMissing(Payment.Reference))
         {
             throw new Exception(EXP_MISSING_MERCHANT);
         }
         CyberResponse Response = null;
         if (Payment.Operation == ServiceOperation.Bill || Payment.Operation == ServiceOperation.Reverse)
         {
             Response  = Data.GetTransactionDetails(Payment);
             RequestID = Response.RequestID;
         }
         else
         {
             Payment.Card.ValidateFields(CreditCards);
         }
         Payment.BillTo.ValidateFields();
         CheckEmail(Payment.Application, Payment.BillTo);
         if (!IsMissing(RequestID))
         {
             Payment.RequestID = RequestID;
         }
         ServiceRequest s = new ServiceRequest(Payment);
         Payment.Function = s.Function;
         if (Response != null)
         {
             s.CheckAuthErrors(Response);
         }
         Response = Data.Begin_Transaction(Payment);
         string ReceiptNumber = Response.ReceiptNumber;
         if (Response.Flag != "New")
         {
             throw s.Ex("Attempted duplicate transaction.");
         }
         //Response = s.Send(Response.ID);
         CCResponse Result = new CCResponse(Response);
         Data.Complete_Transaction(Payment, Result);
         Result.ReceiptNumber = ReceiptNumber;
         return(Result);
     }
     catch (Exception e) { return(new CCResponse(e)); }
 }
Beispiel #4
0
 /// <summary>
 /// Checks to see if there were authorization errors, throws exceptions unders certain conditions.
 /// </summary>
 /// <param name="Response">The Cybersource response.</param>
 public void CheckAuthErrors(CyberResponse Response)
 {
     if (!Response.IsRequestSuccessful)
     {
         if (!Response.IsSoftDecline)
         {
             throw Ex("Attempt to proceed with transaction that was declined.");
         }
         if (Response.Flag == "DCV" && !Card.IgnoreCCCV)
         {
             throw Ex("Authorization failed with CC_CV error, but request requires CC_CV verification.");
         }
         if (Response.Flag == "DAVSNO" && !BillTo.IgnoreAVS)
         {
             throw Ex("Authorization failed with AVS error, but request requires AVS verification.");
         }
     }
 }
Beispiel #5
0
        internal static CyberResponse New(string xml, ServiceRequest Request, int ID)
        {
            // Commented by Cognizant on 10 Jan 2005, for changing namespace from "Payments" to "PaymentService"
            //CyberResponse r = (CyberResponse) Serializer.FromXML(Type.GetType("Payments.CyberResponse"), xml);

            CyberResponse r = (CyberResponse)Serializer.FromXML(Type.GetType("PaymentService.CyberResponse"), xml);

            r.ID = ID;
            switch (Request.Operation)
            {
            case ServiceOperation.Bill:
            case ServiceOperation.Credit:
            case ServiceOperation.Process: if (r.IsRequestSuccessful)
                {
                    r._IsComplete = true;
                }
                break;
            }
            return(r);
        }