Giter VIP home page Giter VIP logo

paddle-client's Introduction

Paddle Client

A python (3.5+) wrapper around the Paddle.com API

If you are looking at integrating Paddle with Django check out dj-paddle

The full documentation is available at: https://paddle-client.readthedocs.io

Note: Several of the Paddle Endpoints are currently not working as expected. See Failing endpoints below.

Quick start

Installation

pip install paddle-client

Basic Usage

To use the Paddle API you will need a Paddle Vendor ID and API key which can be found on Paddle's authentication page

from paddle import PaddleClient


paddle = PaddleClient(vendor_id=12345, api_key='myapikey')
paddle.list_products()

If vendor_id and api_key are not passed through when initialising Paddle will fall back and try and use environmental variables called PADDLE_VENDOR_ID and PADDLE_API_KEY

export PADDLE_VENDOR_ID=12345
export PADDLE_API_KEY="myapikey"
from paddle import PaddleClient


paddle = PaddleClient()
paddle.list_products()

Paddle sandbox environment

The Paddle sandbox environment is a separate Paddle environment which can be used for development and testing. You are required to create a new account in this environment, different to your production account.

Once you have this account setup and configured you can user the sandbox account by passing sandbox=True when initialising the Paddle Client. This will send all API calls to the Paddle sandbox URLs instead of the production URLs

from paddle import PaddleClient


paddle = PaddleClient(vendor_id=12345, api_key='myapikey', sandbox=True)

It is also possible to turn the sandbox environment on using an environmental variable called PADDLE_SANDBOX:

export PADDLE_SANDBOX="true"
from paddle import PaddleClient


paddle = PaddleClient(vendor_id=12345, api_key='myapikey')

Documentation

The full documentation is available on Read the Docs: https://paddle-client.readthedocs.io

Contributing

All contributions are welcome and appreciated. Please see CONTRIBUTING.md for more details including details on how to run tests etc.

Paddle Endpoints

The below endpoints from the Paddle API Reference have been implemented

For full details see the API Reference in the docs. This includes details on parameters and return types for all the different methods as well as other helper methods around the Paddle.com API.

See Usage below for quick examples.

Checkout API

Product API

Subscription API

Alert API

Usage

See the API Reference in the docs for full usage with param are return details.

# Checkout API
paddle.get_order_details(checkout_id='aaaa-bbbb-cccc-1234')
paddle.get_user_history(email='[email protected]')
paddle.get_prices(product_ids=[1234])

# Product API
paddle.list_coupons(product_id=1234)
paddle.create_coupon(
    coupon_type='product',
    discount_type='percentage',
    discount_amount=50,
    allowed_uses=1,
    recurring=False,
    currency='USD',
    product_ids=[1234],
    coupon_code='50%OFF',
    description='50% off coupon over $10',
    expires='2030-01-01 10:00:00',
    minimum_threshold=10,
    group='paddle-python',
)
paddle.delete_coupon(coupon_code='mycoupon', product_id=1234)
paddle.update_coupon(
    coupon_code='mycoupon',
    new_coupon_code='40%OFF',
    new_group='paddle-python-test',
    product_ids=[1234],
    expires='2030-01-01 10:00:00',
    allowed_uses=1,
    currency='USD',
    minimum_threshold=10,
    discount_amount=40,
    recurring=True
)
paddle.list_products()
paddle.list_transactions(entity='subscription', entity_id=1234)
paddle.refund_product_payment(order_id=1234, amount=0.01, reason='reason')

# Subscription API
paddle.list_plans()
paddle.get_plan(plan=123)
paddle.create_plan(
    plan_name='plan_name',
    plan_trial_days=14,
    plan_length=1,
    plan_type='month',
    main_currency_code='USD',
    initial_price_usd=50,
    recurring_price_usd=50,
)
paddle.list_subscription_users()
paddle.cancel_subscription(subscription_id=1234)
paddle.update_subscription(subscription_id=1234, pause=True)
paddle.update_subscription(
    subscription_id=1234,
    quantity=10.00,
    currency='USD',
    recurring_price=10.00,
    bill_immediately=False,
    plan_id=123,
    prorate=True,
    keep_modifiers=True,
    passthrough='passthrough',
)
paddle.pause_subscription(subscription_id=1234)
paddle.resume_subscription(subscription_id=1234)
paddle.add_modifier(subscription_id=1234, modifier_amount=10.5)
paddle.delete_modifier(modifier_id=10)
paddle.list_modifiers()
paddle.list_subscription_payments()
paddle.reschedule_subscription_payment(payment_id=4567, date='2030-01-01')
paddle.create_one_off_charge(
    subscription_id=1234,
    amount=0.0,
    charge_name="Add X on top of subscription"
)

# Alert API
paddle.get_webhook_history()

paddle-client's People

Contributors

agmathew avatar pyepye avatar rejoc avatar wolf-byte avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

paddle-client's Issues

Unable to use Paddle Library.

While importing Paddle library from paddle OCR getting an error since we do not have permission to create path in Home directory
on analysis noticed that within common.py the below code snippet is causing the issue. Is there an alternate way to inject the path via a wrapper.

site-packages/paddle/dataset/common.py

HOME = os.path.expanduser('~')
DATA_HOME = os.path.join(HOME, '.cache', 'paddle', 'dataset')

Error Logs as follows
[ERROR] OSError: [Errno 30] Read-only file system: '/home/sbx_user1051' Traceback (most recent call last): File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 843, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed from paddleocr import PaddleOCR File "/ABCD/xyz/paddleocr/__init__.py", line 14, in <module> from .paddleocr import * File "/ABCD/xyz/paddleocr/paddleocr.py", line 21, in <module> import paddle File "/ABCD/xyz/paddle/__init__.py", line 71, in <module> import paddle.dataset # noqa: F401 File "/ABCD/xyz/paddle/dataset/__init__.py", line 18, in <module> import paddle.dataset.mnist # noqa: F401 File "/ABCD/xyz/paddle/dataset/mnist.py", line 23, in <module> import paddle.dataset.common File "/ABCD/xyz/paddle/dataset/common.py", line 50, in <module> must_mkdirs(DATA_HOME) File "/ABCD/xyz/paddle/dataset/common.py", line 43, in must_mkdirs os.makedirs(DATA_HOME) File "/usr/local/lib/python3.8/os.py", line 213, in makedirs makedirs(head, exist_ok=exist_ok) File "/usr/local/lib/python3.8/os.py", line 213, in makedirs makedirs(head, exist_ok=exist_ok) File "/usr/local/lib/python3.8/os.py", line 213, in makedirs makedirs(head, exist_ok=exist_ok) File "/usr/local/lib/python3.8/os.py", line 223, in makedirs mkdir(name, mode)

create_plan initial_price check bug

Hi. I realized that there is a bug in client's initial_price existence logic. I would want to create a PR for it but I don't have any access to a Paddle account. I would be happy to contribute if any Paddle account is given for testing, otherwise I'm okay to see that fixed. Thanks for your time.

    if main_currency_code == 'USD' and initial_price_usd is None:
        raise ValueError('main_currency_code is USD so initial_price_usd must be set')  # NOQA: E501
    if main_currency_code == 'GBP' and initial_price_gbp is None:
        raise ValueError('main_currency_code is USD so initial_price_gbp must be set')  # NOQA: E501
    if main_currency_code == 'USD' and initial_price_eur is None:
        raise ValueError('main_currency_code is USD so initial_price_eur must be set')  # NOQA: E501
    if main_currency_code == 'USD' and recurring_price_usd is None:
        raise ValueError('main_currency_code is USD so recurring_price_usd must be set')  # NOQA: E501
    if main_currency_code == 'GBP' and recurring_price_gbp is None:
        raise ValueError('main_currency_code is USD so recurring_price_gbp must be set')  # NOQA: E501
    if main_currency_code == 'USD' and recurring_price_eur is None:
        raise ValueError('main_currency_code is USD so recurring_price_eur must be set')  # NOQA: E501

Add 'deleted' state in _subscription_users.py

Hello,

as documented in https://developer.paddle.com/api-reference/subscription-api/users/listusers and https://developer.paddle.com/reference/platform-parameters/event-statuses , there is also the "deleted" status - useful to retrieve informations about cancelled subscriptions.

At the moment is impossible to call the list_subscription_users() function with state='deleted', because it's not listed in the states list on line 25 of _subscription_users.py

Can you please add it?

Thank you

HI

Hello, I am from Baidu PaddlePaddle team. I learned from giuhub that you have begun to use PaddlePaddle and we would like to offer you more support including technical help and others. Would you like to join PaddlePaddle community and have fun? If interested, you can conntact me via Wechat, my ID is paddlehelp, or you can contact me via email [email protected]. Looking forward to your reply :)

Looking forward to your reply~

Documentation Enhancement

It's not really clear how to create a subscription and let a user approve it. I see there are only update_subscription and cancel_subscription. So how can I create a subscription first? A code sample would be appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.