Almost automatic integration between django-plans and django-paypal. This will add subscribe buttons to the order page and automatically confirm the Order after the payment.
Currently it is in experimetal stage, wher only recurring payments (subscribtions) are supported.
The full documentation is at https://django-plans-paypal.readthedocs.io.
Install and configure django-plans
and django-paypal
apps.
Capture mode is not yet supported, so PAYMENT_VARINANTS
with 'capture': False
will not get confirmed.
Install Django plans paypal:
pip install django-plans-paypal
Add it to your INSTALLED_APPS
, before the plans
:
INSTALLED_APPS = (
...
'payments',
'paypal.standard.ipn',
'plans_paypal',
...
)
Add your bussiness account e-mail address to settings:
PAYPAL_BUSSINESS_EMAIL = "foo@bar.com"
# To enable encrypted PayPal form:
PAYPAL_ENCRYPTED_FORM = True
PAYPAL_PRIVATE_CERT = os.path.join(BASE_DIR, 'certs/paypal_private.pem')
PAYPAL_PUBLIC_CERT = os.path.join(BASE_DIR, 'certs/paypal_public.pem')
PAYPAL_CERT = os.path.join(BASE_DIR, 'certs/paypal_cert.pem')
PAYPAL_CERT_ID = 'xxxxx'
Add Django plans_paypal
to the URL patterns:
urlpatterns = [
...
url(r'^plans-paypal', include('plans_paypal.urls')),
...
]
Override django-plans class CreateOrderView so that get_success_url() returns url of paypal-payment view:
def get_success_url(self):
return reverse("paypal-payment", kwargs={'order_id': self.object.id})
Set following settings:
PAYPAL_TEST_BUSSINESS_EMAIL = "foo@bar.com"
PAYPAL_TEST = True
# For encrypted PayPal sandbox form:
PAYPAL_TEST_PRIVATE_CERT = os.path.join(BASE_DIR, 'certs/paypal_private.pem')
PAYPAL_TEST_PUBLIC_CERT = os.path.join(BASE_DIR, 'certs/paypal_public.pem')
PAYPAL_TEST_CERT = os.path.join(BASE_DIR, 'certs/paypal_sandbox_cert.pem')
PAYPAL_TEST_CERT_ID = 'xxxx'
Redirect user to paypal-payment-sandbox instead of paypal-payment view.
- TODO
Does the code actually work?
source <YOURVIRTUALENV>/bin/activate (myenv) $ pip install tox (myenv) $ tox
Tools used in rendering this package: