django-bursar / docs / paypal.rst

Full commit

PayPal Gateway

Enabling the module

Add "bursar.gateways.paypal_gateway" to your INSTALLED_APPS. Configure the settings you need for PayPal in your BURSAR_SETTINGS.


You can configure any of the following settings:

# Currency code for Paypal transactions.

# 'The Paypal URL for real transaction posting'
'POST_URL' : "",

# The Paypal URL for test transaction posting

#a named view where the customer will
#be returned after a successful purchase

# Accept real payments
'LIVE' : False,

# use SSL for checkout
'SSL' : False,

'LOCALE' : 'US',

# Reattempt on fail

'LABEL' : _('PayPal'),

'ENCRYPT' : False,

# Path to the public key from PayPal, get this at:

# Path to your paypal private key

# Path to your paypal public key

# Your Cert ID, copied from the PayPal website after uploading your public key
'PUBLIC_CERT_ID' = 'get-from-paypal-website'

Encrypted Forms

The Bursar PayPal Gateway will automatically encrypt the form if you set "ENCRYPT" to True, and you enter values for the "PAYPAL_PUBKEY", "PRIVATE_KEY", "PUBLIC_KEY", and "PUBLIC_CERT_ID".

Thanks to John Boxall's Django-Paypal project for the encryption method and for the instructions about how to create a PayPal public key:

  1. Encrypted forms require the M2Crypto library:

    easy_install M2Crypto

  2. Encrypted buttons require certificates. Create a private key:

    openssl genrsa -out paypal.pem 1024

  3. Create a public key:

    openssl req -new -key paypal.pem -x509 -days 365 -out pubpaypal.pem

  4. Upload your public key to the paypal website (sandbox or live). On the "Encrypted payment settings" section of your profile

  5. Copy your "cert id". It's on the screen where you uploaded your public key.

  6. Download PayPal's public certificate from that screen.

  7. Edit your to include cert information:

        'PAYPAL' : {
            'ENCRYPT': True,
            'PAYPAL_PRIVATE_CERT': '/path/to/paypal.pem',
            'PAYPAL_PUBLIC_CERT': '/path/to/pubpaypal.pem',
            'PAYPAL_CERT': '/path/to/paypal_cert.pem',
            'PAYPAL_CERT_ID': 'copied in step 5',
            # add any or all of the other settings for PayPal here