Asp.Net中的Skrill支付网关集成

时间:2015-05-21 11:34:28

标签: c# php asp.net payment-gateway skrill

我正在寻找将skrill支付网关集成到我的应用程序中的示例代码。我尝试使用skrill沙箱帐户和json rpc web方法调用,但每次我得到解析错误或跨域异常。

请帮帮我。

我想注册一张信用卡,后来想要自动付款。

如果您有其他语言平台的示例代码,请在此处分享一些示例。

由于

Richa Shah

首先尝试以下代码:

public static string RegCard()
        {
            var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://psp.sandbox.dev.skrillws.net/v1/json/3e40a821/channelid_register_get/creditcard/");
            httpWebRequest.ContentType = "text/json";
            httpWebRequest.Method = "POST";

            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                string json = "{\"jsonrpc\":\"2.0\",\"method\":\"register\",\"id\":1 ,\"params\":{\"account\":{\"number\":\"4111111111111111\",\"expiry\":\"10/2016\",\"cvv\",\"123\"}}}";
                streamWriter.Write(json);
            }
            var responseText="";
            var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                responseText = streamReader.ReadToEnd();
                //Now you have your response.
                //or false depending on information in the response
                return responseText;
            }
        }

第二次尝试

   function Register2() {
                    $.post("https://psp.sandbox.dev.skrillws.net/v1/json/3e40a821/channelid_register_get/creditcard", "{'jsonrpc\" : \"2.0\",\"method\" : \"register\",\"params\" : {\"account\":{\"number\":\"4444333322221111\",\"expiry\":\"10/2016\",\"cvv\",\"333\"} },\"id\":1 }", function (data, textStatus) {
                        alert(textStatus);
                    }, "json");
                }
                function RegisterCard() {

                    var jsonText = '{"jsonrpc" : "2.0","method" : "register","params" : {"account":{"number":"4444333322221111","expiry":"10/2016","cvv","333"} },"id":1}';
                    // "{'number':" + JSON.stringify(jsonText) + "}"
                    try {
                        $(function () {
                            $.ajax({
                                type: "POST",
                                url: "https://psp.sandbox.dev.skrillws.net/v1/json/3e40a821/channelid_register_get/creditcard?jsoncallback=?",
                                data: jsonText,
                                contentType: "application/json",
                                callback: 'RegisterCardResponse',
                                dataType: "json"
                            });
                        });
                    } catch (e) {
                        alert(e);
                    }
                }
                function RegisterCardResponse(response) {
                    alert(1);
                    document.getElementById("res").innerHTML = response;
                }

第三次尝试

function RegisterCard() {

                    var jsonText = '{"jsonrpc" : "2.0","method" : "register","params" : {"account":{"number":"4444333322221111","expiry":"10/2016","cvv","333"} },"id":1}';
                    try {
                        $(function () {
                            $.ajax({
                                type: "POST",
                                url: "https://psp.sandbox.dev.skrillws.net/v1/json/3e40a821/channelid_register_get/creditcard",
                                data: jsonText,
                                contentType: "application/json",                               
                                dataType: "json",
                                success: function (responseData, textStatus, jqXHR) {
                                    var value = responseData.someKey;
                                    RegisterCardResponse(responseData);
                                },
                                error: function (responseData, textStatus, errorThrown) {
                                    alert(responseData);
                                }
                            });
                        });
                    } catch (e) {
                        alert(e);
                    }
                }
                function RegisterCardResponse(response) {
                    alert(1);
                    document.getElementById("res").innerHTML = response;
                }

1 个答案:

答案 0 :(得分:1)

访问Skrill Json RPC方法的解决方案

在ASPX页面中编写下面的代码在Javascript中:

`<input type="button" onclick="RegCard(); return false;" value="Register" />

<script type="text/javascript">
 function RegCard() {


                    var request = {};
                    request.method = "register";
                    request.params = {};
                    request.params.account = {};
                    request.params.account.number = "Card Number";
                    request.params.account.expiry = "Expiry Date";
                    request.params.account.cvv = "CVV Number";
                    request.id = 1;
                    request.jsonrpc = "2.0";

                    $(function () {
                        $.ajax({
                            type: "GET",
                            url: "SkrillHandler.ashx",
                            data: { 'a': 'register', 'data': JSON.stringify(request) },
                            contentType: "application/json",
                            dataType: "json",
                            success: function (responseData) {
                                alert(responseData.result.account.token);
                            },
                            error: function (responseData) {
                                alert(responseData);
                            }
                        });
                    });
                    //$.getJSON('SkrillHandler.ashx', { data: JSON.stringify(request) }, function (a) {
                    //    //displayTweets(a);
                    //});

                    //$.post(url, JSON.stringify(request), displaySearchResult, "json");
                }
</script>` 

现在创建名为SkrillHandler.ashx的通用处理程序

'public void ProcessRequest(HttpContext context)
        {            
            string responseText = "";
            if (context.Request.QueryString["a"].ToString() == "register")
            {
                responseText = RegisterCard(context.Request.QueryString["data"].ToString());
            }
            context.Response.Write(responseText);
        }

        private string RegisterCard(string data)
        {
            var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://psp.sandbox.dev.skrillws.net/v1/json/3e40a821/channelid_register_get/creditcard/");
            httpWebRequest.ContentType = "text/json";
            httpWebRequest.Method = "POST";

            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                string json = data;
                streamWriter.Write(json);
            }
            var responseText = "";
            var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                responseText = streamReader.ReadToEnd();
                //Now you have your response.
                //or false depending on information in the response
            }
            return responseText;
        }
'

您将从Javascript RegCard Method获得响应。