Пример #1
0
        public void CanCreateTransaction()
        {
            SendPipelineWrapper pipeline =
                PipelineFactory.CreateSendPipeline(typeof(XMLTransmit));

            using (TransactionControl control = pipeline.EnableTransactions())
            {
                // Create the input message to pass through the pipeline
                Stream       stream       = DocLoader.LoadStream("SampleDocument.xml");
                IBaseMessage inputMessage = MessageHelper.CreateFromStream(stream);

                // Add the necessary schemas to the pipeline, so that
                // disassembling works
                pipeline.AddDocSpec(typeof(Schema1_NPP));
                pipeline.AddDocSpec(typeof(Schema2_WPP));

                MessageCollection inputMessages = new MessageCollection();
                inputMessages.Add(inputMessage);

                // Execute the pipeline, and check the output
                IBaseMessage outputMessage = pipeline.Execute(inputMessages);

                Assert.IsNotNull(outputMessage);
                control.SetComplete();
            }
        }
Пример #2
0
        public TransactionDetailsWindow(TransactionJSON[] transactionJSONs)
        {
            InitializeComponent();

            foreach (TransactionJSON transactionJSON in transactionJSONs)
            {
                TransactionControl transactionControl = new TransactionControl(transactionJSON);
                gTransactionList.Children.Add(transactionControl);
            }
        }
Пример #3
0
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            string                       szMessage = null;
            bool                         boTransactionSuccessful = false;
            StringBuilder                sbString;
            int                          nCount = 0;
            int                          nTemp;
            CardDetailsTransaction       cdtCardDetailsTransaction;
            RequestGatewayEntryPointList lrgepRequestGatewayEntryPoints;
            GatewayOutput                goGatewayOutput;
            TransactionOutputMessage     tomTransactionOutputMessage;
            TransactionControl           tcTransactionControl;
            CardDetails                  cdCardDetails;
            CreditCardDate               ccdExpiryDate                = null;
            CreditCardDate               ccdStartDate                 = null;
            CustomerDetails              cdCustomerDetails            = null;
            NullableInt                  nCountryCode                 = null;
            NullableInt                  nExpiryDateMonth             = null;
            NullableInt                  nExpiryDateYear              = null;
            NullableInt                  nStartDateMonth              = null;
            NullableInt                  nStartDateYear               = null;
            string                       szPreviousTransactionMessage = null;
            bool                         boDuplicateTransaction       = false;

            lrgepRequestGatewayEntryPoints = new RequestGatewayEntryPointList();
            // you need to put the correct gateway entry point urls in here
            // contact support to get the correct urls

            // The actual values to use for the entry points can be established in a number of ways
            // 1) By periodically issuing a call to GetGatewayEntryPoints
            // 2) By storing the values for the entry points returned with each transaction
            // 3) Speculatively firing transactions at https://gw1.xxx followed by gw2, gw3, gw4....
            // The lower the metric (2nd parameter) means that entry point will be attempted first,
            // EXCEPT if it is -1 - in this case that entry point will be skipped
            // NOTE: You do NOT have to add the entry points in any particular order - the list is sorted
            // by metric value before the transaction sumbitting process begins
            // The 3rd parameter is a retry attempt, so it is possible to try that entry point that number of times
            // before failing over onto the next entry point in the list
            lrgepRequestGatewayEntryPoints.Add(new RequestGatewayEntryPoint("https://gw1." + Global.PaymentProcessorFullDomain, 100, 2));
            lrgepRequestGatewayEntryPoints.Add(new RequestGatewayEntryPoint("https://gw2." + Global.PaymentProcessorFullDomain, 200, 2));
            lrgepRequestGatewayEntryPoints.Add(new RequestGatewayEntryPoint("https://gw3." + Global.PaymentProcessorFullDomain, 300, 2));

            tcTransactionControl = new TransactionControl(new NullableBool(true),
                                                          new NullableBool(true),
                                                          new NullableBool(true),
                                                          new NullableBool(true),
                                                          new NullableInt(60),
                                                          null,
                                                          null,
                                                          null,
                                                          null,
                                                          null,
                                                          null);

            if (!String.IsNullOrEmpty(ddExpiryDateMonth.SelectedValue))
            {
                nExpiryDateMonth = new NullableInt(System.Convert.ToInt32(ddExpiryDateMonth.SelectedValue));
            }
            if (!String.IsNullOrEmpty(ddExpiryDateYear.SelectedValue))
            {
                nExpiryDateYear = new NullableInt(System.Convert.ToInt32(ddExpiryDateYear.SelectedValue));
            }
            ccdExpiryDate = new CreditCardDate(nExpiryDateMonth, nExpiryDateYear);

            if (!String.IsNullOrEmpty(ddStartDateMonth.SelectedValue))
            {
                nStartDateMonth = new NullableInt(System.Convert.ToInt32(ddStartDateMonth.SelectedValue));
            }
            if (!String.IsNullOrEmpty(ddStartDateYear.SelectedValue))
            {
                nStartDateYear = new NullableInt(System.Convert.ToInt32(ddStartDateYear.SelectedValue));
            }
            ccdStartDate = new CreditCardDate(nStartDateMonth, nStartDateYear);

            cdCardDetails = new CardDetails(tbCardName.Text, tbCardNumber.Text, ccdExpiryDate, ccdStartDate, tbIssueNumber.Text, tbCV2.Text);

            if (!String.IsNullOrEmpty(ddCountries.SelectedValue))
            {
                nTemp = System.Convert.ToInt32(ddCountries.SelectedValue);
                if (nTemp != -1)
                {
                    nCountryCode = new NullableInt(nTemp);
                }
            }
            cdCustomerDetails = new CustomerDetails(new AddressDetails(tbAddress1.Text, tbAddress2.Text, tbAddress3.Text, tbAddress4.Text, tbCity.Text, tbState.Text, tbPostCode.Text, nCountryCode),
                                                    "*****@*****.**", "123456789", Request.UserHostAddress);

            cdtCardDetailsTransaction = new CardDetailsTransaction(lrgepRequestGatewayEntryPoints,
                                                                   new MerchantDetails(Global.MerchantID, Global.Password),
                                                                   new TransactionDetails(TRANSACTION_TYPE.SALE, new NullableInt(System.Convert.ToInt32(hfAmount.Value)), new NullableInt(System.Convert.ToInt32(hfCurrencyISOCode.Value)), hfOrderID.Value, hfOrderDescription.Value, tcTransactionControl, new ThreeDSecureBrowserDetails(new NullableInt(0), "*/*", Request.UserAgent)),
                                                                   cdCardDetails,
                                                                   cdCustomerDetails,
                                                                   null);

            // send the SOAP request
            if (!cdtCardDetailsTransaction.ProcessTransaction(out goGatewayOutput, out tomTransactionOutputMessage))
            {
                szMessage = "Couldn't communicate with payment gateway";
                boTransactionSuccessful = false;
            }
            else
            {
                switch (goGatewayOutput.StatusCode)
                {
                case 0:
                    // status code of 0 - means transaction successful
                    boTransactionSuccessful = true;
                    m_fmFormMode            = FORM_MODE.RESULTS;
                    szMessage = goGatewayOutput.Message;
                    break;

                case 3:
                    // status code of 3 - means 3D Secure authentication required
                    m_fmFormMode       = FORM_MODE.THREE_D_SECURE;
                    m_szTermURL        = Global.SiteSecureBaseURL + "ThreeDSecureLandingPage.aspx";
                    m_szPaREQ          = tomTransactionOutputMessage.ThreeDSecureOutputData.PaREQ;
                    m_szACSURL         = tomTransactionOutputMessage.ThreeDSecureOutputData.ACSURL;
                    m_szCrossReference = tomTransactionOutputMessage.CrossReference;
                    break;

                case 5:
                    // status code of 5 - means transaction declined
                    boTransactionSuccessful = false;
                    m_fmFormMode            = FORM_MODE.RESULTS;
                    szMessage = goGatewayOutput.Message;
                    break;

                case 20:
                    // status code of 20 - means duplicate transaction
                    m_fmFormMode = FORM_MODE.RESULTS;
                    szMessage    = goGatewayOutput.Message;
                    if (goGatewayOutput.PreviousTransactionResult.StatusCode.Value == 0)
                    {
                        boTransactionSuccessful = true;
                    }
                    else
                    {
                        boTransactionSuccessful = false;
                    }
                    szPreviousTransactionMessage = goGatewayOutput.PreviousTransactionResult.Message;
                    boDuplicateTransaction       = true;
                    break;

                case 30:
                    // status code of 30 - means an error occurred
                    boTransactionSuccessful = false;
                    m_fmFormMode            = FORM_MODE.PAYMENT_FORM;

                    sbString = new StringBuilder();

                    // get any additional messages
                    if (goGatewayOutput.ErrorMessages.Count > 0)
                    {
                        sbString.Append("<br /><ul>");

                        for (nCount = 0; nCount < goGatewayOutput.ErrorMessages.Count; nCount++)
                        {
                            sbString.AppendFormat("<li>{0}</li>", goGatewayOutput.ErrorMessages[nCount]);
                        }
                        sbString.Append("</ul>");
                    }

                    szMessage = goGatewayOutput.Message + sbString.ToString();
                    break;

                default:
                    // unhandled status code
                    boTransactionSuccessful = false;
                    m_fmFormMode            = FORM_MODE.PAYMENT_FORM;
                    szMessage = goGatewayOutput.Message;
                    break;
                }
            }

            if (m_fmFormMode == FORM_MODE.PAYMENT_FORM)
            {
                pnMessagePanel.CssClass           = "ErrorMessage";
                pnMessagePanel.Visible            = true;
                lbMessageLabel.Text               = szMessage;
                pnTransactionResultsPanel.Visible = false;
            }
            else
            {
                pnTransactionResultsPanel.Visible = true;
                pnMessagePanel.Visible            = false;

                if (!boTransactionSuccessful)
                {
                    pnTransactionResultsPanel.CssClass = "ErrorMessage";
                }
                else
                {
                    pnTransactionResultsPanel.CssClass = "SuccessMessage";
                }

                lbGatewayResponse.Text = szMessage;

                // sort out the duplicate transaction reporting
                if (boDuplicateTransaction)
                {
                    pnDuplicateTransactionPanel.Visible = true;
                    lbPreviousTransactionMessage.Text   = szPreviousTransactionMessage;
                }

                // the process another link
                if (boTransactionSuccessful == true)
                {
                    Response.Redirect("Thankyou.aspx?id=" + szMessage);
                }
                else
                {
                    hlProcessAnother.NavigateUrl = Global.SiteSecureBaseURL + "PaymentForm.aspx";
                }
            }
        }
Пример #4
0
        public QuotationResponse EditQuotationAll(QuotationRequest datosCotizacion)
        {
            CultureInfo       cultureInfo = Thread.CurrentThread.CurrentCulture;
            TextInfo          textInfo    = cultureInfo.TextInfo;
            QuotationResponse respuesta   = new QuotationResponse();
            var cotizacion = _context.Quotation.SingleOrDefault(c => c.Id == datosCotizacion.Id);

            respuesta.FechaVuelta = "No definido";
            if (datosCotizacion.ViajeId != null)
            {
                var viaje       = _context.Trip.SingleOrDefault(c => c.Id == datosCotizacion.ViajeId);
                var transaccion = _context.TransactionControl.SingleOrDefault(c => c.Id == datosCotizacion.Id);
                if (transaccion == null)
                {
                    TransactionControl nuevaTransaccion = new TransactionControl();
                    nuevaTransaccion.QuotationId    = datosCotizacion.Id;
                    nuevaTransaccion.TripId         = datosCotizacion.ViajeId;
                    nuevaTransaccion.UserId         = cotizacion.User.Id;
                    nuevaTransaccion.TravelerUserId = viaje.UserId;
                    _context.TransactionControl.Add(nuevaTransaccion);
                }
                else
                {
                    transaccion.TripId         = datosCotizacion.ViajeId;
                    transaccion.TravelerUserId = viaje.UserId;
                }

                cotizacion.TripId      = viaje.Id;
                cotizacion.FechaVuelta = viaje.Vuelta.Date;
            }

            if (datosCotizacion.EstadoCotizacion == 3)
            {
                cotizacion.FechaVentaExitosa = DateTime.Now;
            }
            cotizacion.QuotationStatusId = datosCotizacion.EstadoCotizacion;
            cotizacion.TackingNumber     = datosCotizacion.TrackingNumber;
            cotizacion.Url        = datosCotizacion.URL;
            cotizacion.NombreItem = textInfo.ToTitleCase(datosCotizacion.NombreItem);
            cotizacion.Precio     = datosCotizacion.Precio;
            cotizacion.Largo      = datosCotizacion.Largo;
            cotizacion.Ancho      = datosCotizacion.Ancho;
            cotizacion.Alto       = datosCotizacion.Alto;
            cotizacion.CategoryId = datosCotizacion.CategoryId;
            cotizacion.Peso       = datosCotizacion.Peso;
            Double precioIsd = datosCotizacion.Precio * 0.05;

            cotizacion.ISD = Math.Round(precioIsd, 2);
            Double volumen = datosCotizacion.Largo * datosCotizacion.Ancho * datosCotizacion.Alto;

            cotizacion.Volumen = volumen;
            Double volumetrico = volumen / 5000;

            cotizacion.PesoVolumetrico = volumetrico;
            cotizacion.VentaExitosa    = false;
            switch (datosCotizacion.CategoryId)
            {
            case 1:

                cotizacion.ComisionViajero = 100;
                cotizacion.ComisionTraigo  = 50;
                Double precioPesoLaptop = datosCotizacion.Peso * 6;
                if (precioPesoLaptop > 100)
                {
                    cotizacion.ComisionViajero = Math.Round(precioPesoLaptop, 2);
                    cotizacion.ComisionTraigo  = Math.Round(cotizacion.ComisionViajero * 0.50, 2);
                }
                break;


            case 2:
                cotizacion.ComisionViajero = 60;
                cotizacion.ComisionTraigo  = 30;
                Double precioPesoConsola = datosCotizacion.Peso * 6;
                if (precioPesoConsola > 60)
                {
                    cotizacion.ComisionViajero = Math.Round(precioPesoConsola, 2);
                    cotizacion.ComisionTraigo  = Math.Round(cotizacion.ComisionViajero * 0.50, 2);
                }
                break;

            case 3:
                cotizacion.ComisionViajero = 10;
                cotizacion.ComisionTraigo  = 5;
                Double precioPesoPerfumes = datosCotizacion.Peso * 6;
                if (precioPesoPerfumes > 10)
                {
                    cotizacion.ComisionViajero = Math.Round(precioPesoPerfumes, 2);
                    cotizacion.ComisionTraigo  = Math.Round(cotizacion.ComisionViajero * 0.50, 2);
                }
                break;


            case 4:
                cotizacion.ComisionViajero = 50;
                cotizacion.ComisionTraigo  = 20;
                Double precioPesoMonitorComputadora = datosCotizacion.Peso * 6;
                if (precioPesoMonitorComputadora > 50)
                {
                    cotizacion.ComisionViajero = Math.Round(precioPesoMonitorComputadora, 2);
                    cotizacion.ComisionTraigo  = Math.Round(cotizacion.ComisionViajero * 0.50, 2);
                }
                break;

            case 5:
                cotizacion.ComisionViajero = 50;
                cotizacion.ComisionTraigo  = 25;
                Double precioPesoCelular = datosCotizacion.Peso * 6;
                if (precioPesoCelular > 50)
                {
                    cotizacion.ComisionViajero = Math.Round(precioPesoCelular, 2);
                    cotizacion.ComisionTraigo  = Math.Round(cotizacion.ComisionViajero * 0.50, 2);
                }
                break;

            default:
            {
                cotizacion.ComisionViajero = Math.Round(datosCotizacion.Peso * 6, 2);
                cotizacion.ComisionTraigo  = Math.Round(datosCotizacion.Precio * 0.10, 2);
            }
            break;
            }

            cotizacion.ComisionTraigoIva = Math.Round(cotizacion.ComisionTraigo * 1.12, 2);
            _context.SaveChanges();
            if (cotizacion.TripId != null)
            {
                respuesta.FechaVuelta = cotizacion.Trip.User.Nombre + " / " + cotizacion.Trip.Vuelta.ToString("dd/MM/yyyy");
            }
            else
            {
                respuesta.FechaVuelta = "No definido";
            }
            respuesta.ComisionTraigo  = Math.Round(cotizacion.ComisionTraigoIva, 2);
            respuesta.ComisionViajero = Math.Round(cotizacion.ComisionViajero, 2);
            respuesta.Peso            = cotizacion.Peso;
            respuesta.Precio          = cotizacion.Precio;
            respuesta.URL             = cotizacion.Url;
            respuesta.Id             = cotizacion.Id;
            respuesta.Estado         = cotizacion.QuotationStatus.Nombre;
            respuesta.TrackingNumber = cotizacion.TackingNumber;
            respuesta.NombreItem     = cotizacion.NombreItem;
            Double costoTraer = Math.Round(cotizacion.ComisionViajero + cotizacion.ComisionTraigoIva, 2);
            Double costoTotal = Math.Round(cotizacion.ComisionViajero + cotizacion.Precio + cotizacion.ComisionTraigoIva, 2);

            respuesta.ComisionTotal  = costoTotal;
            respuesta.TextoResultado = "Estimado usuario, su cotización de " + cotizacion.NombreItem + " de peso " + cotizacion.Peso + " lbs. El valor a pagar es " + costoTraer + " USD.";
            return(respuesta);
        }
Пример #5
0
 public override void TransactionAccess(TransactionControl control)
 {
     VerifyResult(_cco.TransactionAccess((int)control));
 }