コード例 #1
0
ファイル: PayExManager.cs プロジェクト: raphaelivo/a-webshop
    } // End of the CompleteOrderTest method

    /// <summary>
    /// Complete a production order
    /// </summary>
    private static Dictionary<string, string> CompleteOrderProduction(string orderReference, KeyStringList settings)
    {
        // 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 account number
        Int64 accountNumber = 0;
        Int64.TryParse(settings.Get("PAYEX-ACCOUNT-NUMBER"), out accountNumber);

        // Create the hash
        string hash = GetMD5Hash(accountNumber.ToString() + orderReference + settings.Get("PAYEX-ENCRYPTION-KEY"));

        // Get the transaction information
        string xmlResponse = pxOrder.Complete(accountNumber, orderReference, hash);

        // Parse the xml response
        XmlDocument doc = new XmlDocument();

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

            // Get data from the xml response
            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"));
            responseData.Add("already_completed", ParseXmlNode(doc, "/payex/alreadyCompleted"));
            responseData.Add("order_id", ParseXmlNode(doc, "/payex/orderId"));
            responseData.Add("payment_method", ParseXmlNode(doc, "/payex/paymentMethod"));
        }
        catch (Exception ex)
        {
            responseData.Add("exception", ex.Message);
        }

        // Return the response data
        return responseData;

    } // End of the CompleteOrderProduction method