diff --git a/README.md b/README.md index 1a0b063..a349c92 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,11 @@ Django PayPal ============= +Note +---- + +This is a fork of `dcramer/django-paypal`. This contains few of the fixes which are currently (as of 16Mar12) in the Pull Request queue of dcramer. I felt they were quite good changes, so I did not wait and created my own version; topped with some of my own fixes. + About ----- @@ -15,13 +20,14 @@ PayPal Payments Pro allows you to accept payments on your website. It contains t There is currently an active discussion over the handling of some of the finer points of the PayPal API and the evolution of this code base - check it out over at [Django PayPal on Google Groups](http://groups.google.com/group/django-paypal). +**Note:** When using this module for production code, then set `PAYPAL_TEST` to `False`. If you do not set this then it is assumed to be `True`! When this flag is enabled then all traffics are directed towards [Paypal Sandbox](https://developer.paypal.com). Make sure you have an account on that and have created some test accounts. Using PayPal Payments Standard IPN: ------------------------------- 1. Download the code from GitHub: - git clone git://github.com/johnboxall/django-paypal.git paypal + git clone git://github.com/applegrew/django-paypal.git paypal 1. Edit `settings.py` and add `paypal.standard.ipn` to your `INSTALLED_APPS` and `PAYPAL_RECEIVER_EMAIL`: @@ -66,6 +72,8 @@ Using PayPal Payments Standard IPN: {{ form.render }} + **Note:** Do not use `PayPalPaymentsForm` for production code. Instead at least use `PayPalEncryptedPaymentsForm`. (See the section - Using PayPal Payments Standard with Encrypted Buttons). If that is not possible then generate a [hosted button from Paypal](https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ButtonMgrAPIIntro#id093VD0JE0Y4). + 1. When someone uses this button to buy something PayPal makes a HTTP POST to your "notify_url". PayPal calls this Instant Payment Notification (IPN). The view `paypal.standard.ipn.views.ipn` handles IPN processing. To set the @@ -128,6 +136,7 @@ Paypal Payment Data Transfer (PDT) allows you to display transaction details to INSTALLED_APPS = (... 'paypal.standard.pdt', ...) PAYPAL_IDENTITY_TOKEN = "xxx" + PAYPAL_RECEIVER_EMAIL = "yourpaypalemail@example.com" 1. Create a view that uses `PayPalPaymentsForm` just like in PayPal IPN. @@ -142,6 +151,19 @@ Paypal Payment Data Transfer (PDT) allows you to display transaction details to (r'^paypal/pdt/', include('paypal.standard.pdt.urls')), ... ) + **Alternatively**, you can use the pdt decorator to work with PDT information in one of your own views. + To do this, add the decorator to one of your views. + + # views.py + from paypal.standard.pdt.decorators import pdt + + @pdt + def view_func(request, *args, **kwargs): + ... + The decorator checks for any GET parameters corresponding to a PDT call and adds the keyword arguments `pdt_active`, `pdt_failed` and `pdt` to the view call. + +1. Set `PAYPAL_IGNORE_INVALID_PDT` to `True` to stop saving data about failed transactions. This might save you from an attack of bad inserts. + Using PayPal Payments Standard with Subscriptions: -------------------------------------------------- @@ -195,7 +217,7 @@ Use this method to encrypt your button so sneaky gits don't try to hack it. Than [https://www.paypal.com/us/cgi-bin/webscr?cmd=_profile-website-cert](https://www.paypal.com/us/cgi-bin/webscr?cmd=_profile-website-cert) - [https://www.paypal.com/us/cgi-bin/webscr?cmd=_profile-website-cert](https://www.sandbox.paypal.com/us/cgi-bin/webscr?cmd=_profile-website-cert) + [https://www.sandbox.paypal.com/us/cgi-bin/webscr?cmd=_profile-website-cert](https://www.sandbox.paypal.com/us/cgi-bin/webscr?cmd=_profile-website-cert) 1. Copy your `cert id` - you'll need it in two steps. It's on the screen where you uploaded your public key. diff --git a/paypal/standard/conf.py b/paypal/standard/conf.py index 5c5fd45..66d8bc8 100644 --- a/paypal/standard/conf.py +++ b/paypal/standard/conf.py @@ -5,8 +5,7 @@ class PayPalSettingsError(Exception): TEST = getattr(settings, "PAYPAL_TEST", True) - - +IGNORE_INVALID_PDT = getattr(settings, "PAYPAL_IGNORE_INVALID_PDT", False) RECEIVER_EMAIL = settings.PAYPAL_RECEIVER_EMAIL @@ -15,7 +14,7 @@ class PayPalSettingsError(Exception): SANDBOX_POSTBACK_ENDPOINT = "https://www.sandbox.paypal.com/cgi-bin/webscr" # Images -IMAGE = getattr(settings, "PAYPAL_IMAGE", "http://images.paypal.com/images/x-click-but01.gif") +IMAGE = getattr(settings, "PAYPAL_IMAGE", "https://www.paypal.com/en_US/i/btn/btn_paynowCC_LG.gif") SUBSCRIPTION_IMAGE = getattr(settings, "PAYPAL_SUBSCRIPTION_IMAGE", "https://www.paypal.com/en_US/i/btn/btn_subscribeCC_LG.gif") DONATION_IMAGE = getattr(settings, "PAYPAL_DONATION_IMAGE", "https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif") SANDBOX_IMAGE = getattr(settings, "PAYPAL_SANDBOX_IMAGE", "https://www.sandbox.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif") diff --git a/paypal/standard/forms.py b/paypal/standard/forms.py index e9992a5..68abc97 100644 --- a/paypal/standard/forms.py +++ b/paypal/standard/forms.py @@ -59,6 +59,8 @@ class PayPalPaymentsForm(forms.Form): item_name = forms.CharField(widget=ValueHiddenInput()) item_number = forms.CharField(widget=ValueHiddenInput()) quantity = forms.CharField(widget=ValueHiddenInput()) + tax_rate = forms.FloatField(widget=ValueHiddenInput()) + tax = forms.FloatField(widget=ValueHiddenInput()) # Subscription Related. a1 = forms.CharField(widget=ValueHiddenInput()) # Trial 1 Price @@ -100,6 +102,12 @@ def __init__(self, button_type="buy", *args, **kwargs): self.button_type = button_type def render(self): + if TEST: + return self.sandbox(); + else: + return self.renderProd(); + + def renderProd(self): return mark_safe(u"""