Maulik Shah
Maulik Shah

Reputation: 1

Skrill Payment Gateway Integration in Asp.Net

I am looking for sample code to integrate skrill payment gateway into my application. I tried with skrill sandbox account and json rpc web method calling, but everytime I got the parse error or cross domain exception.

Please help me out.

I want to register a credit card and later want to make automated payment.

If you have sample code with other language platform than also please share some sample here.

Thanks

Richa Shah

First Tried with below code:

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;
            }
        }

Second Try with

   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;
                }

Third Try with

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;
                }

Upvotes: -1

Views: 2024

Answers (1)

Maulik Shah
Maulik Shah

Reputation: 1

Solution to Access Skrill Json RPC Method

In ASPX Page Write Below code In 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>` 

Now Create Generic Handler Named 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;
        }
'

You will get the response from Javascript RegCard Method.

Upvotes: 0

Related Questions