重定向到ASP.NET MVC3中的支付网关

时间:2014-06-26 16:12:03

标签: asp.net-mvc asp.net-mvc-3 paypal payment-gateway

我正在通过MVC3应用程序付款。我的问题是如何使用来自MVC应用程序的一些隐藏输入重定向到外部支付网关(用于网上银行)。

我有查看页面,其中包含基于单选按钮选择的信用卡和网上银行选项。

@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)
    @Html.AntiForgeryToken()
    @Html.HiddenFor(m => m.newPolicyDetails.ReferenceNumber, new Dictionary<string, object> { { "id", "hdReferenceNumber" }, { "name", "hdReferenceNumber" } })    

    </article>
    <!-- Start Code  -     payment page - Payment Option Selection section  -->
    <article>
        <section>
            <div>               
                <p>Please select your payment option.</p>
                <table cellpadding="0" cellspacing="10">
                    <tr>
                        <td>
                            @Html.RadioButton("PaymentOption", "1", "Credit Card", false, Model.PaymentOption, new Dictionary<string, object> { { "id", "RdCreditCard" }, { "name", "PaymentoptionSelection" }, { "value", "Credit Card" }, { "list", "{'1:Credit Card'}" } })
                        </td>
                    </tr>
                    <tr>
                        <td>
                                @Html.RadioButton("PaymentOption", "2", "Netbanking", false, Model.PaymentOption, new Dictionary<string, object> { { "id", "RdNetbanking" }, { "name", "PaymentoptionSelection" }, { "value", "Netbanking" }, { "list", "{'2:Netbanking'}" } }) 
                        </td>
                    </tr>
                </table>

            </div>
        </section>
    </article>
    <!-- End Code  -     payment page - Payment Option Selection section  -->

    <!-- Start Code  -     payment page - Credit Card Details Entry Section -->
    <article id="creditCard">
        <section>
            <div>
                <h1>Credit Card</h1>               
                <p>Please enter credit card information.</p>                
                <table cellpadding="0" cellspacing="2">
                    <tr>
                        <td>Card Number</td>
                        <td>
                            @Html.TextBoxFor(m => m.CardNumberCol1, new Dictionary<string, object> { { "id", "txtCardNumberCol1" }, { "name", "CardNumberCol1" }, { "maxLength", "4" }, { "onkeyup", "movetoNext(this, 'txtCardNumberCol2')" } })
                        </td>
                        <td>
                            @Html.TextBoxFor(m => m.CardNumberCol2, new Dictionary<string, object> { { "id", "txtCardNumberCol2" }, { "name", "CardNumberCol2" }, { "maxLength", "4" }, { "onkeyup", "movetoNext(this, 'txtCardNumberCol3')" } })
                        </td>
                        <td>
                            @Html.TextBoxFor(m => m.CardNumberCol3, new Dictionary<string, object> { { "id", "txtCardNumberCol3" }, { "name", "CardNumberCol3" }, { "maxLength", "4" }, { "onkeyup", "movetoNext(this, 'txtCardNumberCol4')" } })
                        </td>
                        <td>
                            @Html.TextBoxFor(m => m.CardNumberCol4, new Dictionary<string, object> { { "id", "txtCardNumberCol4" }, { "name", "CardNumberCol4" }, { "maxLength", "4" }, { "onkeyup", "movetoNext(this, 'monthPicker')" } })
                        </td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td colspan="4">Please enter card number by 4 digits, left-aligned</td>
                    </tr>
                    <tr>
                        <td>Month/Year</td>
                        <td>
                            @Html.DropDownListFor(m => m.ValidMonth, new List<SelectListItem> { }, new Dictionary<string, object> { { "id", "monthPicker" },  })
                        </td>
                        <td>
                            @Html.DropDownListFor(m => m.ValidYear, new List<SelectListItem> { }, new Dictionary<string, object> { { "id", "yearPicker" }, { } })
                        </td>                        
                    </tr>                    
                </table>
                <ul>
                    <li>
                        <input type="submit"  id="Settle" name="Settle"  value="PaymentScreen_Settle"/>
                    </li>
                    <li>
                        <a href="#" id="LnkCCardCancel">Cancel</a>
                    </li>
                </ul>

            </div>
        </section>
    </article>
    <!-- End Code  -     payment page - Credit Card Details Entry Section -->

    <!-- Start Code  -    payment page - Netbanking Section -->     
    <article id="netbanking">
        <section">
            <div">
                <h1>Netbanking</h1>               
                <p>You will be directed to your bank site.</p>
                @Html.Hidden("ver","abcd")
                @Html.Hidden("bill", "abcd")
                @Html.Hidden("shop", "abcd")
                @Html.Hidden("success", "http://www.abcd.com/abcd/success")
                @Html.Hidden("failure", "http://www.abcd.com/abcd/failure")
                @Html.Action("https://www.netbankingsite.com/abcdefgh12345")
                <ul>
                    @*@Html.ActionLink("Next", "PolicyDetailsScreen", "PolicyDetailsUC", null, new Dictionary<string, object> { { "id", "btnNext" }, { "name", "btnNext" }, { "value", "btnNext" },})*@
                    <li>                   
                    <input type="submit" id="BtnNext" name="BtnNext" value="Next" data-action="@Url.Action("https://https://www.netbankingsite.com/abcdefgh12345")" />
                    </li>
                    <li>
                        <a href="#" id="LnkCStoreCancel">Cancel</a>
                    </li>
                </ul>
            </div>
        </section>
    </article>
    <!-- End Code -     payment page - Netbanking  Section -->

    <!-- Start Code  -     payment page - Back Button section  -->
    <section>
        @Html.ActionLink("Back", "AgreementScreen", "PaymentUC", new { policyNumber = Model.newPolicyDetails.ReferenceNumber }, new { id = "btnBack", name = "btnBack"})
    </section>
    <!-- End Code  -     payment page - Back Button section  -->  
}

我完全完成了信用卡付款。现在我需要做网上银行代码。问题是我有付款网址

https://https://www.netbankingsite.com/abcdefgh12345

abov URL的隐藏输入很少,必须使用POST方法重定向到

第一个问题 我正在努力如何从MVC3重定向到该网站。

第二个问题: 由于我在同一个视图页面中有信用卡和网上银行,如果我点击相应的付款按钮,则会调用信用卡控制器。有没有办法在视图页面中使用2 @html.begin表单,以便我可以单独发布信用卡和网上银行。

第三个问题 我必须在同一个视图页面中同时拥有信用卡和网上银行服务。如果我选择网络银行单选按钮,则网页银行部分查看页面部分将显示在用户的单选按钮下方,信用卡页面将隐藏给用户。此隐藏部分通过使用jquery完成。我从DB获取详细信息并指定它通过模型查看页面html控件。

那么如何在不影响信用卡的情况下从视图页面进行网上银行重定向,只通过POST操作将隐藏的输入传递给URL。如果我使用信用卡付款,那么我不应该向网上银行网址发布任何输入,不应该重定向。处理它我感到有点困惑。所以与其他技术人员联系......!我知道这必须作为Web服务完成,但在mvc中做是必需的。

感谢您帮助和耐心阅读这个大问题。

0 个答案:

没有答案