如何通过项目说明和价格贝宝页面asp

本文关键字:asp 何通过 项目 说明 | 更新日期: 2023-09-27 18:13:33

当用户点击"立即购买"按钮重定向到paypal页面时,我试图通过课程描述和价格。我不确定如何为此编码,我是新的asp .net c#。请帮帮我。以下是html和c#代码。

   <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
         ConnectionString="<%$ ConnectionStrings:ASHAConnectionString %>"  
         SelectCommand="SELECT [TEMPLATE_NAME], [Price] FROM [TemplateMaster]">
   </asp:SqlDataSource>
     <asp:GridView ID="gvPayPalPrice" runat="server" DataSourceID="SqlDataSource1"
            AutoGenerateColumns="False" OnRowCommand="gvPayPalPrice_RowCommand"  
            BorderStyle="None" BorderWidth="1px" BackColor="#DEBA84" BorderColor="#DEBA84">
          <RowStyle ForeColor="#8C4510" BackColor="#FFF7E7" />
           <Columns>
               <asp:BoundField DataField="TEMPLATE_NAME" 
                     HeaderText="TEMPLATE_NAME" SortExpression="TEMPLATE_NAME" />
               <asp:BoundField DataField="Price" HeaderText="Price" SortExpression="Price" />
                    <asp:TemplateField HeaderText = "Buy Now">
                        <ItemTemplate>
                           <asp:ImageButton ID="imgbtnBuyNow" runat="server" ImageUrl="~/images/buy_now.png" Width="64" Height="64" CommandName="buy" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" />
                        </ItemTemplate>
                       </asp:TemplateField>
            </Columns>
            <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
            <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
            <SortedAscendingCellStyle BackColor="#FFF1D4" />
            <SortedAscendingHeaderStyle BackColor="#B95C30" />
            <SortedDescendingCellStyle BackColor="#F1E5CE" />
            <SortedDescendingHeaderStyle BackColor="#93451F" />
        </asp:GridView>

这是我的c#代码传递到paypal页面。

protected void gvPayPalPrice_RowCommand(object sender, GridViewCommandEventArgs e)
{
    if (e.CommandName == "buy")
    {
        ImageButton ib = (ImageButton)e.CommandSource;
        int index = Convert.ToInt32(ib.CommandArgument);
        GridViewRow row =gvPayPalPrice.Rows[index];
        //Pay pal process Refer for what are the variable are need to send http://www.paypalobjects.com/IntegrationCenter/ic_std-variable-ref-buy-now.html
        string redirectUrl = "";
        //Mention URL to redirect content to paypal site
        redirectUrl += "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_xclick&business=" + ConfigurationManager.AppSettings["paypalemail"].ToString();
        //First name I assign static based on login details assign this value
        redirectUrl += "&first_name=Joe_Seller";
        //Product Name
       redirectUrl += "&item_name=" + CourseName.Text;
        //Product Amount
        redirectUrl += "&amount=" + CoursePrice.Text;
        //Business contact paypal EmailID
        redirectUrl += "&business=joekhaung@outlook.com";
        //Quantiy of product, Here statically added quantity 1
        redirectUrl += "&quantity=1";
        //If transactioin has been successfully performed, redirect SuccessURL page- this page will be designed by developer
        redirectUrl += "&return=" +      ConfigurationManager.AppSettings["SuccessURL"].ToString();

        //If transactioin has been failed, redirect FailedURL page- this page will be designed by developer
        redirectUrl += "&cancel_return=" + ConfigurationManager.AppSettings["FailedURL"].ToString();
        Response.Redirect(redirectUrl);
    }
}

如何通过项目说明和价格贝宝页面asp

您在这里所做的只是构建一个Payments Standard URL。您所需要做的就是将单个购物车项目参数添加到字符串中,以便按照您的要求显示这些参数。

这里有一个粗略的例子,你想以什么结束…

https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_xclick&business=some@email.com
&first_name=Tester&last_name=Testerson&amount=10.00
&return={your_return_url}&cancel={your_cancel_url}
&item_name_1=Test Widget #1&amount_1=5.00
&item_name_2=Test Widget #2&item_amount=5.00

我已经把它分成了单独的行,使它更容易阅读,但当然,这将只是一个长字符串/URL。

你可能会循环遍历某种类型的项目数组,你能生成URL的那一部分然后把它附加到剩下的部分就像你在这里已经做的那样。