paypal系列三:支付代码

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了paypal系列三:支付代码相关的知识,希望对你有一定的参考价值。

一: form提交


function paypalSubmit()
var paypalform;
var formMain;
var paypalendingUrl = "<% =HostUrl%>pay/Paypalending.aspx";
var PaypalCancelUrl = "<% =HostUrl%>pay/PaypalCancel.aspx"
if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1)
paypalform = document.formPaypal;
formMain = document.Form1;
paypalform.all.item("cmd").value = "_xclick";
paypalform.all.item("business").value = "​​​youraccount@163.com​​​";
paypalform.all.item("return").value = paypalendingUrl+"?PayPal=1&LangTypeID=<%=LangTypeID%>";
paypalform.all.item("undefinded_quantity").value = "1";
var itemname = <% =PaypalItemNumber %>;
if(itemname.length>4)

paypalform.all.item("item_name").value = "<% =PaypalItemNumber %>";

paypalform.all.item("item_number").value = "<% =PaypalItemNumber %>";
paypalform.all.item("no_shipping").value = "2";
paypalform.all.item("cancel_return").value = paypalendingUrl+"?PayPal=2&LangTypeID=<%=LangTypeID%>";
paypalform.all.item("no_note").value = "0";
paypalform.all.item("payer_id").value = formMain.all.item("ucCheckOutResult_lblOrderNumber").innerText;
paypalform.all.item("custom").value = formMain.all.item("ucCheckOutResult_lblOrderNumber").innerText;
paypalform.all.item("invoice").value = "<% =Invoice %>";//票据
paypalform.all.item("notify_url").value = paypalendingUrl+"?PayPal=3&LangTypeID=<%=LangTypeID%>";
paypalform.all.item("currency_code").value = "<%=CartCurrency%>";
paypalform.all.item("amount").value = 200.99;
paypalform.all.item("bn").value = "web.Shop.0.4";
paypalform.submit();

else
paypalform = document.forms["formPaypal"];
formMain = document.forms["Form1"];
paypalform.elements["cmd"].value = "_xclick";
paypalform.elements["business"].value = "​​​youraccountemail@163.com​​​";
paypalform.elements["return"].value = paypalendingUrl+"?PayPal=1&LangTypeID=<%=LangTypeID%>";
paypalform.elements["item_number"].value = "<% =PaypalItemNumber %>";
paypalform.elements["undefinded_quantity"].value = "1";
var itemname2 = <% =PaypalItemNumber %>;
if(itemname2.length>4)

paypalform.elements["item_name"].value = "<% =PaypalItemNumber %>";

paypalform.elements["no_shipping"].value = "2";
paypalform.elements["cancel_return"].value = paypalendingUrl+"?PayPal=2&LangTypeID=<%=LangTypeID%>";
paypalform.elements["no_note"].value = "0";
if(formMain.elements["ucCheckOutResult_txtOrderNumber"]!=null)

paypalform.elements["payer_id"].value = formMain.elements["ucCheckOutResult_txtOrderNumber"].value;

else

paypalform.elements["payer_id"].value = "";


if(formMain.elements["ucCheckOutResult_txtOrderNumber"] != null)

paypalform.elements["custom"].value = formMain.elements["ucCheckOutResult_txtOrderNumber"].value;


else

paypalform.elements["custom"].value = "";

paypalform.elements["invoice"].value = "<% =Invoice %>";//票据
paypalform.elements["notify_url"].value = paypalendingUrl+"?PayPal=3&LangTypeID=<%=LangTypeID%>";
paypalform.elements["currency_code"].value = "<%=CartCurrency%>";

if(formMain.elements["ucCartInfo_txtLevelingAmount"]!=null)

levelingAmount = formMain.elements["ucCartInfo_txtLevelingAmount"].value;


paypalform.elements["amount"].value = 100.99;
paypalform.elements["bn"].value = "web.Shop.0.4";
paypalform.submit();


-------------------
c#里也可以用服务端代码提交
private void Button1_Click(object sender, System.EventArgs e)

string postData = "";
postData += "currency_code=USD";
  postData += "&cmd=_xclick";
  postData += ​​​&business=youraccountemail@163.com​​​;
  postData += "&upload=1";
  postData += "&cancel_return="+HostUrl +"pay/Paypalending.aspx";
postData += "&item_name=wowgn000255555";
postData += "&quantity=1";
postData += "&amount=280.23";
postData += "&no_shipping=2";
  byte[] data = Encoding.ASCII.GetBytes(postData);
Response.Redirect("​​​https://www.paypal.com/cgi-bin/webscr?"+postData​​​);
<form name="formPaypal" οnsubmit="return check()" action="​​https://www.paypal.com/cgi-bin/webscr​​​"
method="post">
<input id="cmd" type="hidden" name="cmd"><input type="hidden" name="redirect_cmd"><input type="hidden" name="business"><input type="hidden" name="return"><input type="hidden" name="undefinded_quantity"><input type="hidden" name="item_name"><input type="hidden" name="item_number"><input type="hidden" name="no_shipping"><input type="hidden" name="cancel_return"><input type="hidden" name="no_note"><input type="hidden" name="payer_id"><input type="hidden" name="custom"><input type="hidden" name="invoice"><input type="hidden" name="first_name"><input type="hidden" name="last_name"><input type="hidden" name="address1"><input type="hidden" name="address2"><input type="hidden" name="city"><input type="hidden" name="state"><input type="hidden" name="zip"><input type="hidden" name="notify_url"><input type="hidden" name="amount"><input type="hidden" name="currency_code"><input type="hidden" name="bn"><input type="hidden" name="lc" value="US">
</form>
提交js

以上是关于paypal系列三:支付代码的主要内容,如果未能解决你的问题,请参考以下文章

paypal支付--平行支付

paypal支付--平行支付

PayPal 直接支付 PHP 代码

使用 PayPal PHP SDK 在 PayPal Sandbox 上执行支付时,得到 Http 响应代码 400

如何在我的个人网店上实现PAYPAL的支付链接?

paypal 支付网关链接,用于直接支付