I don't have the typical shop in which you know what you are selling beforehand. I create custom products on the go (need to fill a couple forms) that people can buy, so before they leave to paypal payment website (I'm using Paypal Standard with django-paypal without issues) I need to store the product in the DB, so if the pay, it gets associated to the IPN using the invoice number.
I could store every combination a user makes even if they don't press t开发者_运维百科he "Buy Now" button, but then the DB would grow too fast. I know I can make a cron process delete those products not payed. But sincerely I'm quite new with paypal, and IPN fails from time to time, so I could end up with a product payed, that I don't have in the DB anymore, so a refund would be the only choice, that means lost business.
Anyone has any idea on how to resolve this? Only thing I can think of is manipulating the django-paypal's form to call a view of my own, that stores the product and then manually POSTs the form to paypal.
I have a similar issue myself. Here is the path I am following:
I create a page that has the paypal button image which however just submits the final product info to my site. At that point I save in the DB what the user asked and respond back with a page that contains the paypal form, and an auto-submit on load. ie.sth like that
<head>
<script src="{{ STATIC_URL }}js/jquery.js"></script>
<script>
$(document).ready(function () {
$("#paypalform").submit()
});
</script>
</head>
<form id="paypalform" name="_xclick" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="boo_1300035015_biz@foo.com">
<input type="hidden" name="amount" value="0.20">
<input type="hidden" name="custom" value="{{translation.id}}">
<input type="hidden" id="quantity" name="quantity" value="{{translation.cnt_words}}">
<input type="hidden" name="item_name" value="Some Name">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
</script>
Looking at django_paypal - it seems that form.render() would allow me to replace all the paypal form stuff above with its output. The only problem may be that I would rather that there isn't anything visible in the page (besides a "click here if this form doesn't redirect you to paypal..) which means that I may need to either modify the render function so as it optionally allows for overriding of the button display.... or maybe remove the button with some js on document load..
Sorry for the lack of details but I don't have yet a finished code/product).
Let me know if that helps.
diomedes
精彩评论