访问quickpay API没有权利

时间:2014-12-24 22:30:39

标签: c# vb.net payment-gateway payment

我很遗憾英语非常糟糕,但我尽力让你理解我。

这就是我遇到的问题,就像我无法访问Quickpay的API一样。

protected void Page_Load(object sender, EventArgs e)
{

            var datoIdag = DateTime.Today.ToString("dd/MM/yyyy");

            var chars = "123456789";
            var randomA = new Random();
            var result = new string(
            Enumerable.Repeat(chars, 3)
            .Select(s => s[randomA.Next(s.Length)])
            .ToArray());

            var chars2 = "abcdefghijklmno";
            var randomA2 = new Random();
            var result2 = new string(
            Enumerable.Repeat(chars2, 2)
            .Select(s => s[randomA2.Next(s.Length)])
            .ToArray());

            Session["orderId"] = result2 + result + "-" + datoIdag;


            string protocol_value = "1";
            string msgtype_value = "authorize";
            string language_value = "da";
            string autocapture_value = "0";
            string ordernum_value = Session["orderId"].ToString();
            //generate an arbitrary ordernumber
            string merchant_value = "89898978";
            string amount_value = readerPriser["priser"].ToString();
            string qp_currency_value = "DKK";
            //[check available parameters on quickpay.net]
            string okpage_value = "~/PayContinue";
            string errorPage_value = "~/PayCallback";
            string resultpage_value = "~/PayError";
            string md5secret_value = "29p61DveBZ79c3144LW61lVz1qrwk2gfAFCxPyi5sn49m3Y3IRK5M6SN5d8a68u7";
            string md5check_value = GenerateHash(string.Concat(protocol_value.ToString(), msgtype_value, merchant_value, language_value, ordernum_value, amount_value.ToString(), qp_currency_value, okpage_value, errorPage_value, resultpage_value,
            autocapture_value.ToString(), md5secret_value));

            protocol.Value = protocol_value;
            msgtype.Value = msgtype_value;
            language.Value = language_value;
            autocapture.Value = autocapture_value;
            ordernumber.Value = ordernum_value;
            merchant.Value = merchant_value;
            amount.Value = amount_value;
            currency.Value = qp_currency_value;
            continueurl.Value = okpage_value;
            cancelurl.Value = errorPage_value;
            callbackurl.Value = resultpage_value;
            md5check.Value = md5check_value;


    }
}

private string GenerateHash(string Input)
{
    System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider();
    byte[] bs = System.Text.Encoding.UTF8.GetBytes(Input);
    bs = x.ComputeHash(bs);
    System.Text.StringBuilder s = new System.Text.StringBuilder();
    foreach (byte b in bs) {
        s.Append(b.ToString("x2").ToLower());
    }
    dynamic outstr = s.ToString();
    return outstr;
}
public _Default()
{
    Load += Page_Load;
}

每当我尝试调试代码并查看我对她的错误时,它就会回来并告诉我这一点。 http://billedeupload.dk/?v=PWNbK.png

如果我写www.blabla.com/PayContinue,那么似乎不会继续快速支付api。

如果我写了正确的地址,那么handelsbetingelserContinue.aspx那么它会这样,它出现在Null。它没有。

Quickpay只进入了vb.net,你可以在这里看到完全相同的文件,我将其从vb.net转换为c#

    Imports System.Security.Cryptography

Partial Class _Default
    Inherits System.Web.UI.Page

    Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load

        Dim protocol_value As Integer = 7
        Dim msgtype_value As String = "authorize"
        Dim language_value As String = "da"
        Dim autocapture_value As Integer = 0
        Dim ordernum_value As String = Now.Ticks 'generate an arbitrary ordernumber
        Dim merchant_value As Integer = 89898978
        Dim amount_value As Integer = 100
        Dim qp_currency_value As String = "DKK" '[check available parameters on quickpay.net]
        Dim okpage_value As String = "http://xprospects.local/continue.aspx"
        Dim errorPage_value As String = "http://xprospects.local/cancel.aspx"
        Dim resultpage_value As String = "http://xprospects.local/callback.aspx"
        Dim md5secret_value As String = "29p61DveBZ79c3144LW61lVz1qrwk2gfAFCxPyi5sn49m3Y3IRK5M6SN5d8a68u7"
        Dim md5check_value As String = GenerateHash(String.Concat(protocol_value.ToString, msgtype_value, merchant_value, language_value, ordernum_value, amount_value.ToString, qp_currency_value, okpage_value, errorPage_value, resultpage_value, autocapture_value.ToString, md5secret_value))

        protocol.Value = protocol_value
        msgtype.Value = msgtype_value
        language.Value = language_value
        autocapture.Value = autocapture_value
        ordernumber.Value = ordernum_value
        merchant.Value = merchant_value
        amount.Value = amount_value
        currency.Value = qp_currency_value
        continueurl.Value = okpage_value
        cancelurl.Value = errorPage_value
        callbackurl.Value = resultpage_value
        md5check.Value = md5check_value

    End Sub

    Private Function GenerateHash(ByVal Input As String) As String
        Dim x As System.Security.Cryptography.MD5CryptoServiceProvider = New System.Security.Cryptography.MD5CryptoServiceProvider()
        Dim bs As Byte() = System.Text.Encoding.UTF8.GetBytes(Input)
        bs = x.ComputeHash(bs)
        Dim s As System.Text.StringBuilder = New System.Text.StringBuilder()
        For Each b As Byte In bs
            s.Append(b.ToString("x2").ToLower())
        Next
        Dim outstr = s.ToString()
        Return outstr
    End Function



End Class

0 个答案:

没有答案