Esempio n. 1
0
        /// <summary>
        /// Generates Credit group.
        /// </summary>
        /// <returns></returns>
        static private XElement GenerateCreditGroup(SepaRowElement data)
        {
            XElement el = new XElement("CdtTrfTxInf",
                                       new XElement("PmtId",
                                                    new XElement("EndToEndId", string.Empty)
                                                    ),
                                       new XElement("Amt",
                                                    new XElement("InstdAmt", new XAttribute("Ccy", Ccy), data.RefundAmount)
                                                    ),
                                       new XElement("CdtrAgt",
                                                    new XElement("FinInstnId",
                                                                 new XElement("BIC", data.BIC)
                                                                 )
                                                    ),
                                       new XElement("Cdtr",
                                                    new XElement("Nm", data.AccountName),
                                                    new XElement("PstlAdr",
                                                                 new XElement("Ctry", data.Country),
                                                                 new XElement("AdrLine", data.Address),
                                                                 new XElement("AdrLine", string.Empty)
                                                                 )
                                                    ),
                                       new XElement("CdtrAcct",
                                                    new XElement("Id",
                                                                 new XElement("IBAN", data.IBAN)
                                                                 )
                                                    ),
                                       new XElement("RmtInf",
                                                    new XElement("Ustrd", data.OrderDescription)
                                                    ));

            return(el);
        }
Esempio n. 2
0
        /// <summary>
        /// This method does all the validation, retrieving data and writing to sepa and marking as handle for the given <paramref name="order"/>
        /// </summary>
        /// <param name="order"></param>
        /// <returns></returns>
        private RefundQueueElement ProcessRefundOrder(RefundQueueElement order, Func <RefundQueueElement, CustomerInfo> httpReuest,
                                                      Action <SepaRowElement> AddToSepaCollection)
        {
            // Retrieve customer info + refund data for this order
            Task <CustomerInfo> httpRequestToMagento = Task <CustomerInfo> .Factory.StartNew(() => httpReuest(order));

            httpRequestToMagento.Wait();
            CustomerInfo customerData = httpRequestToMagento.Result;

            currentCustomer.ValidationFailures.Clear();

            // Validate customer info + refund data.
            customerData.Validate();

            // Found the correct customer!!!
            if (order.OrderID == currentCustomer.OrderID)
            {
                // if both "processingOrder" and "customerData" objects are validated,
                // Merge "processingOrder" and "customerData" in a SepaRowElement object and write to Sepa document.
                if (order.IsValid && customerData.IsValid)
                {
                    SepaRowElement sepaRow = new SepaRowElement
                    {
                        OrderDescription = order.OrderDescription,
                        OrderID          = currentCustomer.OrderID, // This customer order ID came back from Magento.
                        AccountName      = customerData.AccountName,
                        ConnectorID      = order.ConnectorID,
                        Email            = customerData.Email,
                        IBAN             = customerData.IBAN,
                        RefundAmount     = customerData.RefundAmount,
                        OrderResponseID  = order.OrderResponseID,
                        BIC     = currentCustomer.BIC,
                        Address = currentCustomer.Address,
                        Country = currentCustomer.CountryCode
                    };

                    // Log valid order data
                    if (!test)
                    {
                        TraceListenerObject.TraceInformation("OrderID: {0} description: {1}, from connector: {2}, state: {3} is being added to the Sepa collection to be processed.", order.OrderID, order.OrderDescription, order.ConnectorID, order.IsValid);
                    }

                    // Send to Sepa colllection
                    AddToSepaCollection(sepaRow);
                }
                else // Log failures
                {
                }
            }
            else
            {
                // Logging the wrong customer data is retrieved from Magento.
                if (!test)
                {
                    TraceListenerObject.TraceWarning(string.Format("Request of OrderID {0} has resulted in a Customer info mismatch. Customer info OrderID {1}.", order.OrderID, currentCustomer.OrderID));
                }
            }
            return(order);
        }
Esempio n. 3
0
 /// <summary>
 /// Store validated Order and custmer info into a collection.
 /// </summary>
 /// <param name="validatedData"></param>
 private void AddToSepaCollection(SepaRowElement validatedData)
 {
     ValidatedSepaData.Add(validatedData);
 }
        //=========================================================================
        // Class variables
        //=========================================================================

        #region Class variables

        #endregion

        //=========================================================================
        // Class constructors, Load/ Shown events
        //=========================================================================

        #region Class constructors

        /// <summary>
        ///
        /// </summary>
        /// <param name="message"></param>
        public WriteSepaOrderEventArgs(SepaRowElement order)
        {
            // Do additional work here otherwise you can leave it empty
        }