gpt4 book ai didi

c# - Asp.net Paypal 返回 Url 要求

转载 作者:太空宇宙 更新时间:2023-11-03 15:53:36 27 4
gpt4 key购买 nike

我正在为我的测试程序使用 asp.net。

//string Server_URL = "https://www.paypal.com/ph/cgi-bin/webscr?";
string Server_URL = ConfigurationManager.AppSettings["URL"].ToString();

//Assigning Cmd Path as Statically to Parameter
string cmd = "_xclick";

//Assigning business Id as Statically to Parameter
string business = ConfigurationManager.AppSettings["BusinessName"].ToString();

//Assigning item name as Statically to Parameter
string item_name = lblProductCode.Text;

//Passing Amount as Statically to parameter
double amount = Convert.ToDouble(_lblPrice.Text);
Session["Amount"] = amount;

//Passing Currency as Statically to parameter
string currency_code = "PHP";

string redirect = "";

//Pass your Server_Url,cmd,business,item_name,amount,currency_code variable.
redirect += Server_URL;
redirect += "cmd=" + cmd;
redirect += "&business=" + business;
redirect += "&first_name=" + Session["id"].ToString();
redirect += "&item_name=" + item_name;
redirect += "&amount=" + amount;
redirect += "&quantity=1";
redirect += "&currency_code=" + currency_code;

redirect += "&return=http://localhost:49457/Fun/Success.aspx";
redirect += "&cancel_return=" + ConfigurationManager.AppSettings["FailedURL"].ToString();

Session["Redirect"] = redirect;

Response.Redirect(redirect);

现在在网站支付首选项中我在我的代码中将返回 URL 设置为相同。它说“我们无法验证您输入的 URL。请检查您的输入并重试。”

是否可以在返回 url 中插入本地主机 url???

最佳答案

我曾经这样做过,它适用于本地服务器测试:

protected void imgBtnBuyNow_Clicked(object sender, EventArgs e)
{
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=ehsan";

//City i assign static based on login user detail you change this value
redirecturl += "&city=rawalpindi";

//State i assign static based on login user detail you change this value
redirecturl += "&state=punjab";

//Product Name
redirecturl += "&item_name=" + packageName.Value.ToString();

//Product Amount
redirecturl += "&amount=" + tdPrice.InnerHtml;
//Business contact id
//redirecturl += "&business=nravindranmca@gmail.com";

//Shipping charges if any
redirecturl += "&shipping=5";

//Handling charges if any
redirecturl += "&handling=5";

//Tax amount if any
redirecturl += "&tax=5";

//Add quatity i added one only statically
redirecturl += "&quantity=1";

//Currency code
redirecturl += "&currency=USD";

redirecturl += "&invoice=" + packageID.Value.ToString();

redirecturl += "&custom=" + Session["userid"].ToString() + "," + packageID.Value.ToString() + "," + Session["purchaseType"].ToString();


//Success return page url
redirecturl += "&return=" + ConfigurationManager.AppSettings["SuccessURL"].ToString();

//Failed return page url
redirecturl += "&cancel_return=" + ConfigurationManager.AppSettings["FailedURL"].ToString();

Response.Redirect(redirecturl);
}

这是 web.config 中的设置:

<add key="token" value="Jlt89XcvKKNRyLICXJCaWBlYoXxPify22EQlz3ZaColy51HdwJz05rILtd4" />
<add key="paypalemail" value="biznes_1357901741_biz@yahoo.com" />
<add key="PayPalSubmitUrl" value="https://www.sandbox.paypal.com/cgi-bin/webscr" />
<add key="FailedURL" value="http://localhost:4076/OpenLearningSolutions/Failed.aspx" />
<add key="SuccessURL" value="http://localhost:4076/OpenLearningSolutions/Success.aspx" />

关于c# - Asp.net Paypal 返回 Url 要求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18393693/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com