Salesman PayPal
PayPal payment integration for Salesman.
Installation
Install the package using pip:
pip install django-salesman-paypal
Add to your setting file:
INSTALLED_APPS = ['salesman_paypal']
SALESMAN_PAYMENT_METHODS = ['salesman_paypal.payment.PayPalPayment']
SALESMAN_PAYPAL_CLIENT_ID = '<paypal-client-id>'
SALESMAN_PAYPAL_CLIENT_SECRET = '<paypal-client-secret>'
SALESMAN_PAYPAL_SANDBOX_MODE = True # Disable in production
Usage guide
To use this payment on your website, checkout the official PayPal server integration guide.
See example directory in this repository for integration example using JavaScript.
Additional settings
Optional additional settings that you can override:
# Payment method label used when displayed in the basket.
SALESMAN_PAYPAL_PAYMENT_LABEL = 'Pay with PayPal'
# Default PayPal currency used for payments (https://developer.paypal.com/docs/reports/reference/paypal-supported-currencies/)
SALESMAN_PAYPAL_DEFAULT_CURRENCY = 'USD'
# URL to redirect to when PayPal payment is approved.
SALESMAN_PAYPAL_RETURN_URL = '/paypal/return/'
# URL to redirect to when PayPal payment is cancelled.
SALESMAN_PAYPAL_CANCEL_URL = '/paypal/cancel/'
# Default paid status for fullfiled orders.
SALESMAN_PAYPAL_PAID_STATUS = 'PROCESSING'
Advanced usage
To gain more control feel free to extend the PayPalPayment class with your custom functionality:
# shop/payment.py
from salesman_paypal.payment import PayPalPayment
from salesman_paypal.conf import app_settings
class MyPayPalPayment(StripePayment):
def get_paypal_payer_data(self, obj, request):
# https://developer.paypal.com/api/orders/v2/#definition-payer
data = super().get_paypal_payer_data(obj, request)
if obj.user and obj.user.birth_date:
data['birth_date'] = obj.user.birth_date.strftime('%Y-%m-%d')
return data
def get_currency(self, request):
currency = request.GET.get('currency', None)
# Check currency is valid for PayPal...
return currency or app_settings.SALESMAN_PAYPAL_DEFAULT_CURRENCY
Make sure to use your payment method in settings.py:
SALESMAN_PAYMENT_METHODS = ['shop.payment.MyPayPalPayment']
The PayPalPayment class is setup with extending in mind, feel free to explore other methods.
Metadata
Release files for django-salesman-paypal 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django-salesman-paypal-0.1.6.tar.gz | 8.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_salesman_paypal-0.1.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.3 kB
Release files / django-salesman-paypal-0.1.6.tar.gz
| Download URL | django-salesman-paypal-0.1.6.tar.gz |
|---|---|
| Size | 8.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
898ce4ac2faef6d9ea86d3dfaa32351086d3077f12e425fe1f2034383dea5723
|
|
BLAKE2b-256 checksum How to use checksums |
90fca7f9fb71b555815e51525d88955cd4946e24d245561c10b6de805c4940d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.15 CPython/3.11.2 Linux/5.15.0-1033-azure
|
Release files / django_salesman_paypal-0.1.6-py3-none-any.whl
| Download URL | django_salesman_paypal-0.1.6-py3-none-any.whl |
|---|---|
| Size | 9.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b456cb36259c9207696e791dce24da3fcb1bac1ff2b222a346a70ab263bcbc96
|
|
BLAKE2b-256 checksum How to use checksums |
ece6401414b17a40b2a48e90a19b9cb5b1b5ad5f9f7207c1aedfcec8aff5aa7b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.15 CPython/3.11.2 Linux/5.15.0-1033-azure
|