Skip to main content

A simplified wrapper for PayPal's Python Server SDK

Project description

README.md

PayPal Easy

A simplified, developer-friendly wrapper around PayPal's Python Server SDK.

Why PayPal Easy?

PayPal's official Python SDK can be challenging to work with due to:

  • Missing or inconsistent class imports
  • Complex parameter structures
  • Inconsistent documentation
  • Verbose API calls

PayPal Easy solves these problems by providing:

  • ✅ Clean, consistent API
  • ✅ Proper error handling
  • ✅ Type hints and IDE support
  • ✅ Simplified method signatures
  • ✅ Django integration helpers

Installation

pip install paypal-easy

Quick Start

from paypal_easy import PayPalEasyClient, Environment, Currency
from decimal import Decimal

# Initialize client
client = PayPalEasyClient(
    client_id="your_client_id",
    client_secret="your_client_secret",
    environment=Environment.SANDBOX
)

# Create an order
result = client.create_order(
    amount=Decimal("29.99"),
    currency=Currency.USD,
    description="Premium subscription",
    return_url="https://yoursite.com/success",
    cancel_url="https://yoursite.com/cancel"
)

if hasattr(result, 'id'):  # Success
    print(f"Order created: {result.id}")
    print(f"Approval URL: {result.approval_url}")
else:  # Error
    print(f"Error: {result.message}")

Django Integration

# views.py
from paypal_easy.django_integration import PayPalEasyDjangoMixin
from django.views import View

class CreatePaymentView(PayPalEasyDjangoMixin, View):
    def post(self, request):
        client = self.get_paypal_client()
        
        result = client.create_order(
            amount=request.POST.get('amount'),
            description="Order payment"
        )
        
        if hasattr(result, 'id'):
            return self.paypal_success_response(result)
        else:
            return self.paypal_error_response(result)

Features

  • Simple Order Creation: Create orders with minimal code
  • Automatic URL Handling: Easy approval flow setup
  • Error Handling: Consistent error responses
  • Django Integration: Ready-to-use Django mixins
  • Type Safety: Full type hints for better IDE support
  • Logging: Built-in logging for debugging

Comparison

Before (Official SDK)

from paypalserversdk.paypal_serversdk_client import PaypalServersdkClient
from paypalserversdk.configuration import Environment
from paypalserversdk.http.auth.o_auth_2 import ClientCredentialsAuthCredentials
from paypalserversdk.models.order_request import OrderRequest

credentials = ClientCredentialsAuthCredentials(
    o_auth_client_id=client_id,
    o_auth_client_secret=client_secret
)

client = PaypalServersdkClient(
    environment=Environment.SANDBOX,
    client_credentials_auth_credentials=credentials
)

order_request = OrderRequest({
    "intent": "CAPTURE",
    "purchase_units": [{
        "amount": {
            "currency_code": "USD", 
            "value": "29.99"
        }
    }]
})

response = client.orders.create_order({'body': order_request})

After (PayPal Easy)

from paypal_easy import PayPalEasyClient, Environment, Currency

client = PayPalEasyClient(client_id, client_secret, Environment.SANDBOX)
result = client.create_order(amount="29.99", currency=Currency.USD)

Contributing

Contributions welcome! Please feel free to submit issues and enhancement requests.

Donations

Would you like to support the work we do?

Click Here to Donate - Donate Link

License

MIT License - see LICENSE file for details.

Maintainers

William Mabotja - Portfolio Site

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

paypal_easy-0.1.4.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

paypal_easy-0.1.4-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file paypal_easy-0.1.4.tar.gz.

File metadata

  • Download URL: paypal_easy-0.1.4.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for paypal_easy-0.1.4.tar.gz
Algorithm Hash digest
SHA256 6f0cc908139b2d2f15ad89980ba3cb9f153023edd646b2f26535a3b91f6f9018
MD5 53ca759153b120b6d799730d186a0547
BLAKE2b-256 fd0c9bcaa093ca29bad3d6f8ebfb5eb83e0da0a2c69ef7268aead6262bfad637

See more details on using hashes here.

File details

Details for the file paypal_easy-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: paypal_easy-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for paypal_easy-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 aa7c037222f186afcb873db9e0e22852f620ccd9eaf9a4b6f24412f884c08fdd
MD5 9cf41edb57e8c633a7052e3e8e133469
BLAKE2b-256 6a534a355f7e559ee3c1b4f93adb84d92f10c04d9fa250e3cf3d4d01e929886e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page