예제 #1
0
    } // End of the CreateInvoicePrivateTest method

    /// <summary>
    /// Create a production invoice for a person
    /// </summary>
    private static Dictionary<string, string> CreateInvoicePrivateProduction(string orderReference, Order order, Domain domain, KeyStringList settings, KeyStringList tt)
    {
        // Create the dictionary to return
        Dictionary<string, string> responseData = new Dictionary<string, string>(10);

        // Create the PayEx order
        Annytab.Webshop.Payex.Production.PxOrder pxOrder = new Annytab.Webshop.Payex.Production.PxOrder();

        // Get the data that we need for a credit check
        Int64 accountNumber = 0;
        Int64.TryParse(settings.Get("PAYEX-ACCOUNT-NUMBER"), out accountNumber);
        string country = order.country_code;
        string socialSecurityNumber = order.customer_org_number;
        string orderRef = orderReference;
        string customerRef = order.customer_id.ToString();
        string customerName = order.invoice_name;
        string streetAddress = order.invoice_address_1;
        string coAddress = "";
        string postalCode = order.invoice_post_code.Replace(" ", "");
        string city = order.invoice_city;
        string phoneNumber = order.customer_mobile_phone;
        string email = order.customer_email;
        string productCode = "";
        string creditCheckRef = "";
        Int32 mediaDistribution = 11;
        string invoiceDate = "";
        Int16 invoiceDueDays = 0;
        Int32 invoiceNumber = 0;
        string invoiceLayout = "";
        string invoiceText = tt.Get("order") + " " + order.id.ToString() + " - " + domain.webshop_name;

        // Create the md5 hash
        string hash = GetMD5Hash(accountNumber.ToString() + orderRef + customerRef + customerName + streetAddress + coAddress
            + postalCode + city + country + socialSecurityNumber + phoneNumber + email + productCode + creditCheckRef + mediaDistribution.ToString()
            + invoiceText + invoiceDate + invoiceDueDays.ToString() + invoiceNumber + invoiceLayout + settings.Get("PAYEX-ENCRYPTION-KEY"));

        // Create the invoice
        string xmlResponse = pxOrder.PurchaseInvoicePrivate(accountNumber, orderRef, customerRef, customerName, streetAddress, coAddress,
            postalCode, city, country, socialSecurityNumber, phoneNumber, email, productCode, creditCheckRef, mediaDistribution, invoiceText,
            invoiceDate, invoiceDueDays, invoiceNumber, invoiceLayout, hash);

        // Create the xml document
        XmlDocument doc = new XmlDocument();

        try
        {
            // Load the xml document
            doc.LoadXml(xmlResponse);

            // Add data from the xml
            responseData.Add("error_code", ParseXmlNode(doc, "/payex/status/errorCode"));
            responseData.Add("description", ParseXmlNode(doc, "/payex/status/description"));
            responseData.Add("transaction_status", ParseXmlNode(doc, "/payex/transactionStatus"));
            responseData.Add("transaction_number", ParseXmlNode(doc, "/payex/transactionNumber"));

        }
        catch (Exception ex)
        {
            responseData.Add("exception", ex.Message);
        }

        // Return the response data
        return responseData;

    } // End of the CreateInvoicePrivateProduction method