[英]Paypal - post product to shopping cart from Java Servlet - how to?
I have a product page on my website and for each item there is an encrypted Paypal Add to Cart button. 我的网站上有一个产品页面,每个商品都有一个加密的Paypal添加到购物车按钮。 An example of the
<form>
from Paypal is below : 贝宝(Paypal)的
<form>
的示例如下:
<form target="_self" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="encrypted" value="-----BEGIN PKCS7----------END PKCS7-----
">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_cart_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
I want to add the onSubmit
handler to the form so when a customer clicks the add to cart button they will be shown a form/questionnaire on the product page that they must fill out and submit before the item is added to the cart. 我想将
onSubmit
处理程序添加到表单,以便当客户单击“添加到购物车”按钮时,他们将在产品页面上看到一个表单/调查表,他们必须填写并提交, 然后才能将商品添加到购物车。
Upon a successful submission of the form, of which is processed by my Java Servlet, can I put some sort of code in the Servlet to add the item to the cart? 成功提交表单(该表单由我的Java Servlet处理)后,我可以在Servlet中放入某种代码以将商品添加到购物车中吗? A direct post to Paypal?
直接发到Paypal? Otherwise, the only way I see getting the item into the cart is by requesting that the customer click on the Add to Cart button again.
否则,我看到将物品放入购物车的唯一方法是要求客户再次单击“添加到购物车”按钮。
The flow of my concept would like this - 我的想法流程是这样的-
Product page > 产品页面>
Add to Cart button clicked (onSubmit handler in paypal form code) > 单击添加到购物车按钮(贝宝表单代码中的onSubmit处理程序)>
div with my form, not paypal, has fields for user to fill out, this form isshown on the page > 带有我的表单的div,而不是paypal,具有供用户填写的字段,此表单显示在页面上>
user fills in my form and submits > 用户填写我的表格并提交>
servlet processes form field information > servlet进程表单字段信息>
form successfully filled out and processed > 表格已成功填写并处理>
at this point I need to add the item to the cart and send the user back to the Products page. 此时,我需要将商品添加到购物车,然后将用户送回“产品”页面。
I am assuming you are sending user email id with custom attribute .. 我假设您正在发送具有自定义属性..的用户电子邮件ID。
up on successfull submission .In do post of your servlet 提交成功。在servlet的后期处理中
String emailId = req.getParameter("custom"); 字符串emailId = req.getParameter(“ custom”);
here the magic code you want 这是您想要的魔术码
if (emailId != null && transactionID != null) {
if (!(paymentStatus.equals("Completed")
|| paymentStatus.equals("Processed") || paymentStatus
.equals("Pending"))) {
log.info("Paypal not completed.");
sendInfo("Your process is not completed", req, resp);
} else {
if (transactionType.equals("subscr_cancel")) {
removeClientSubscription(emailId); //This will hit my DB to update user
} else {
log.info("Payment completed with Status - "
+ paymentStatus);
upgradeClient(params, emailId);//this line hit my DB to update user
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.