Search code examples
c#jqueryasp.net-mvc-4asp.net-ajaxpayumoney

How to Integrate PayUMoney BOLT with MVC4 c#?


Am trying to put a payment gateway in my project,All i need is to Pay on a button click.In the PayUMoney page i got a kit ASP.NET BOLT but it is not in MVC,I have knowlege only in MVC(am a newbie ).I have searched everywhere how to integrate this with MVC4 but i dont get anything. Kindly Help me with this.

<script>
    $(document).ready(function ($) {
        $('#payNowButton').on("click", function () {

              // Have these values in my page(which is needed for BOLT)

                    key: "VOu0fZrK",
                    salt: "rWgjocyTmL",
                    txnid: $('#orderid').val(),
                    amount: $('#grandtotal').val(),
                    fname: $('#fname').val(),
                    email: $('#email').val(),
                    mobile: $('#phone').val(),
                    udf5: $('#udf5').val(),





    </script>

Controller

public ActionResult Demo(Hash h)
        {

            //Code Which am seeking
        }

Dont have the idea about the controller


Solution

  • I Solved It and working Perfectly.I have created hash in the preceding page and store the hash into a session and display on the payment page,and did the following: Added onclick function in Pay Button :

    <script type="text/javascript"><!--
        function launchBOLT() {
            alert($('#txnid').val() + $('#hash').val() + $('#grandtotal').val() + $('#fname').val() + $('#email').val() + $('#phone').val() + $('#oid').val() + $('#udf5').val() + $('#surl').val());
            bolt.launch({
                key: "Key Here",
                txnid: $('#txnid').val(),
                hash: $('#hash').val(),
                amount: $('#grandtotal').val(),
                firstname: $('#fname').val(),
                email: $('#email').val(),
                phone: $('#phone').val(),
                productinfo: $('#oid').val(),
                udf5: $('#udf5').val(),
                surl: $('#surl').val(),
                furl: $('#surl').val()
            }, {
                responseHandler: function (BOLT) {
                    console.log(BOLT.response.txnStatus);
                    if (BOLT.response.txnStatus != 'CANCEL') {
                        //Salt is passd here for demo purpose only. For practical use keep salt at server side only.
                        var fr = '<form action=\"' + $('#surl').val() + '\" method=\"post\">' +
                '<input type=\"hidden\" name=\"key\" value=\"' + BOLT.response.key + '\" />' +
                '<input type=\"hidden\" name=\"salt\" value=\"' + $('#salt').val() + '\" />' +
                '<input type=\"hidden\" name=\"txnid\" value=\"' + BOLT.response.txnid + '\" />' +
                '<input type=\"hidden\" name=\"amount\" value=\"' + BOLT.response.amount + '\" />' +
                '<input type=\"hidden\" name=\"productinfo\" value=\"' + BOLT.response.productinfo + '\" />' +
                '<input type=\"hidden\" name=\"firstname\" value=\"' + BOLT.response.firstname + '\" />' +
                '<input type=\"hidden\" name=\"email\" value=\"' + BOLT.response.email + '\" />' +
                '<input type=\"hidden\" name=\"udf5\" value=\"' + BOLT.response.udf5 + '\" />' +
                '<input type=\"hidden\" name=\"mihpayid\" value=\"' + BOLT.response.mihpayid + '\" />' +
                '<input type=\"hidden\" name=\"status\" value=\"' + BOLT.response.status + '\" />' +
                '<input type=\"hidden\" name=\"hash\" value=\"' + BOLT.response.hash + '\" />' +
                '</form>';
                        var form = jQuery(fr);
                        jQuery('body').append(form);
                        form.submit();
                    }
                },
                catchException: function (BOLT) {
                    alert(BOLT.message);
                }
            });
        }
        //--
    </script>