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

    /// <summary>
    /// Cancel an authorized production transaction
    /// </summary>
    public static Dictionary<string, string> CancelTransactionProduction(Order order, 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 data
        Int64 accountNumber = 0;
        Int64.TryParse(settings.Get("PAYEX-ACCOUNT-NUMBER"), out accountNumber);
        Int32 transactionNumber = 0;
        Int32.TryParse(order.payment_token, out transactionNumber);

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

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

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

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

            // Get data from the xml response paramName
            responseData.Add("error_code", ParseXmlNode(doc, "/payex/status/errorCode"));
            responseData.Add("description", ParseXmlNode(doc, "/payex/status/description"));
            responseData.Add("parameter_name", ParseXmlNode(doc, "/payex/paramName"));
            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 CancelTransactionProduction method