paddle-python-sdk


Namepaddle-python-sdk JSON
Version 1.3.1 PyPI version JSON
download
home_pagehttps://developer.paddle.com/api-reference/overview
SummaryPaddle's Python SDK for Paddle Billing
upload_time2024-12-17 21:26:34
maintainerNone
docs_urlNone
authorPaddle and contributors
requires_python>=3.11
licenseApache-2.0
keywords paddle sdk python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Build Status](https://img.shields.io/github/actions/workflow/status/PaddleHQ/paddle-python-sdk/publish_to_pypi.yml)](https://github.com/PaddleHQ/paddle-python-sdk/actions/?query=branch%3Amain)
[![PyPI](https://img.shields.io/pypi/v/paddle-python-sdk.svg)](https://pypi.python.org/pypi/paddle-python-sdk)
[![PyPI pyversions](https://img.shields.io/pypi/pyversions/paddle-python-sdk.svg)](https://pypi.python.org/pypi/paddle-python-sdk/)
[![License: Apache 2.0](https://img.shields.io/github/license/PaddleHQ/paddle-python-sdk)](http://www.apache.org/licenses/LICENSE-2.0)


# paddle-python-sdk
[Paddle Billing](https://www.paddle.com/billing?utm_source=dx&utm_medium=paddle-python-sdk) is a complete digital product sales and subscription management platform, designed for modern software businesses. It helps you increase your revenue, retain customers, and scale your operations.

This is a [Python](https://www.python.org/) SDK that you can use to integrate Paddle Billing with applications written in Python.

For working with Paddle in your frontend, use [Paddle.js](https://developer.paddle.com/paddlejs/overview?utm_source=dx&utm_medium=paddle-python-sdk). You can open checkouts, securely collect payment information, build pricing pages, and integrate with Paddle Retain.

> **Important:** This package works with Paddle Billing. It does not support Paddle Classic. To work with Paddle Classic, see: [Paddle Classic API reference](https://developer.paddle.com/classic/api-reference/1384a288aca7a-api-reference?utm_source=dx&utm_medium=paddle-python-sdk)


## Table of contents
- [Requirements](#Requirements)
- [Install](#Install)
- [Usage](#Usage)
- [Examples](#Examples)
- [Resources](#Resources)

## Requirements
Python>=3.11 (for native type hinting, StrEnum, trailing commas, f-strings)

**Project dependencies** (automatically installed by pip):
- requests>=2.31
- urllib3>=2.1.0


## Install
Because `paddle-python-sdk` is [available on PyPi](https://pypi.org/project/paddle-python-sdk/), installation is as simple as running the following `pip` command: 

`pip install paddle-python-sdk`



## Usage
To authenticate, you'll need an API key. You can create and manage API keys in **Paddle > Developer tools > Authentication**.

Pass your API key while initializing a new Paddle client:
``` python
from paddle_billing import Client

paddle = Client('PADDLE_API_SECRET_KEY')
```

You can pass your Paddle API secret key into the SDK from an environment variable:
``` python
from os             import getenv
from paddle_billing import Client

paddle = Client(getenv('PADDLE_API_SECRET_KEY'))
```

You can also pass an environment to work with Paddle's sandbox:
``` python
from paddle_billing import Client, Environment, Options

paddle = Client('PADDLE_API_SECRET_KEY', options=Options(Environment.SANDBOX))
```

Keep in mind that API keys are separate for your sandbox and live accounts, so you'll need to generate keys for each environment.



## Examples
There are examples included in the [examples folder](https://github.com/PaddleHQ/paddle-python-sdk/tree/main/examples). To prevent leaking errors we recommend encapsulating Paddle operations inside Try/Except blocks. For brevity, most of the examples below do not do this.

### List entities
You can list supported entities with the `list()` method in the resource. It returns an iterator to help when working with multiple pages.
``` python
from paddle_billing import Client

paddle = Client('PADDLE_API_SECRET_KEY')

products = paddle.products.list()

# list() returns an iterable, so pagination is automatically handled
for product in products:
    print(f"Product's id: {product.id}")
```

### Get an entity
You can get an entity with the `get()` method in the resource. It accepts the `id` of the entity to get. The entity is returned.
``` python
from paddle_billing import Client

paddle = Client('PADDLE_API_SECRET_KEY')

product = paddle.products.get('PRODUCT_ID')
```

### Create an entity
You can create a supported entity with the `create()` method in the resource. It accepts the resource's corresponding `CreateOperation` e.g. `CreateProduct`. The created entity is returned.

``` python
from paddle_billing                               import Client
from paddle_billing.Entities.Shared.TaxCategory   import TaxCategory
from paddle_billing.Resources.Products.Operations import CreateProduct

paddle = Client('PADDLE_API_SECRET_KEY')

created_product = paddle.products.create(CreateProduct(
    name         = 'My Product',
    tax_category = TaxCategory.Standard,
))
```

### Update an entity
You can update a supported entity with the `update()` method in the resource. It accepts the `id` of the entity to update and the corresponding `UpdateOperation` e.g. `UpdateProduct`. The updated entity is returned.
``` python
from paddle_billing                        import Client
from paddle_billing.Resources.Products.Operations import UpdateProduct

paddle = Client('PADDLE_API_SECRET_KEY')

# Update the name of the product
updated_product = paddle.products.update('PRODUCT_ID', UpdateProduct(
    name = 'My Improved Product'
))
```

Where operations require more than one `id`, the `update()` method accepts multiple arguments. For example, to update an address for a customer, pass the `customerId` and the `addressId`:
``` python
updated_address = paddle.addresses.update(
    'CUSTOMER_ID',
    'ADDRESS_ID',
    operation_goes_here,
)
```

### Delete an entity
You can delete an entity with the `delete()` method in the resource. It accepts the `id` of the entity to delete. The deleted entity is returned.
``` python
from paddle_billing import Client

paddle = Client('PADDLE_API_SECRET_KEY')

deleted_product = paddle.products.delete('PRODUCT_ID')
```


## Resources

### Webhook signature verification
The SDK includes a helper class to verify webhook signatures sent by Notifications from Paddle.

``` python
from paddle_billing.Notifications import Secret, Verifier

integrity_check = Verifier().verify(request, Secret('WEBHOOK_SECRET_KEY'))
```

## Learn more
- [Paddle API reference](https://developer.paddle.com/api-reference/overview?utm_source=dx&utm_medium=paddle-python-sdk)
- [Sign up for Paddle Billing](https://login.paddle.com/signup?utm_source=dx&utm_medium=paddle-python-sdk)

            

Raw data

            {
    "_id": null,
    "home_page": "https://developer.paddle.com/api-reference/overview",
    "name": "paddle-python-sdk",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": "paddle, sdk, python",
    "author": "Paddle and contributors",
    "author_email": "team-dx@paddle.com",
    "download_url": "https://files.pythonhosted.org/packages/ea/b8/13ec868dceeb6d0f52ca1ea0cddf02f0aa61c0c5da07f021603b7a0613bf/paddle_python_sdk-1.3.1.tar.gz",
    "platform": null,
    "description": "[![Build Status](https://img.shields.io/github/actions/workflow/status/PaddleHQ/paddle-python-sdk/publish_to_pypi.yml)](https://github.com/PaddleHQ/paddle-python-sdk/actions/?query=branch%3Amain)\n[![PyPI](https://img.shields.io/pypi/v/paddle-python-sdk.svg)](https://pypi.python.org/pypi/paddle-python-sdk)\n[![PyPI pyversions](https://img.shields.io/pypi/pyversions/paddle-python-sdk.svg)](https://pypi.python.org/pypi/paddle-python-sdk/)\n[![License: Apache 2.0](https://img.shields.io/github/license/PaddleHQ/paddle-python-sdk)](http://www.apache.org/licenses/LICENSE-2.0)\n\n\n# paddle-python-sdk\n[Paddle Billing](https://www.paddle.com/billing?utm_source=dx&utm_medium=paddle-python-sdk) is a complete digital product sales and subscription management platform, designed for modern software businesses. It helps you increase your revenue, retain customers, and scale your operations.\n\nThis is a [Python](https://www.python.org/) SDK that you can use to integrate Paddle Billing with applications written in Python.\n\nFor working with Paddle in your frontend, use [Paddle.js](https://developer.paddle.com/paddlejs/overview?utm_source=dx&utm_medium=paddle-python-sdk). You can open checkouts, securely collect payment information, build pricing pages, and integrate with Paddle Retain.\n\n> **Important:** This package works with Paddle Billing. It does not support Paddle Classic. To work with Paddle Classic, see: [Paddle Classic API reference](https://developer.paddle.com/classic/api-reference/1384a288aca7a-api-reference?utm_source=dx&utm_medium=paddle-python-sdk)\n\n\n## Table of contents\n- [Requirements](#Requirements)\n- [Install](#Install)\n- [Usage](#Usage)\n- [Examples](#Examples)\n- [Resources](#Resources)\n\n## Requirements\nPython>=3.11 (for native type hinting, StrEnum, trailing commas, f-strings)\n\n**Project dependencies** (automatically installed by pip):\n- requests>=2.31\n- urllib3>=2.1.0\n\n\n## Install\nBecause `paddle-python-sdk` is [available on PyPi](https://pypi.org/project/paddle-python-sdk/), installation is as simple as running the following `pip` command: \n\n`pip install paddle-python-sdk`\n\n\n\n## Usage\nTo authenticate, you'll need an API key. You can create and manage API keys in **Paddle > Developer tools > Authentication**.\n\nPass your API key while initializing a new Paddle client:\n``` python\nfrom paddle_billing import Client\n\npaddle = Client('PADDLE_API_SECRET_KEY')\n```\n\nYou can pass your Paddle API secret key into the SDK from an environment variable:\n``` python\nfrom os             import getenv\nfrom paddle_billing import Client\n\npaddle = Client(getenv('PADDLE_API_SECRET_KEY'))\n```\n\nYou can also pass an environment to work with Paddle's sandbox:\n``` python\nfrom paddle_billing import Client, Environment, Options\n\npaddle = Client('PADDLE_API_SECRET_KEY', options=Options(Environment.SANDBOX))\n```\n\nKeep in mind that API keys are separate for your sandbox and live accounts, so you'll need to generate keys for each environment.\n\n\n\n## Examples\nThere are examples included in the [examples folder](https://github.com/PaddleHQ/paddle-python-sdk/tree/main/examples). To prevent leaking errors we recommend encapsulating Paddle operations inside Try/Except blocks. For brevity, most of the examples below do not do this.\n\n### List entities\nYou can list supported entities with the `list()` method in the resource. It returns an iterator to help when working with multiple pages.\n``` python\nfrom paddle_billing import Client\n\npaddle = Client('PADDLE_API_SECRET_KEY')\n\nproducts = paddle.products.list()\n\n# list() returns an iterable, so pagination is automatically handled\nfor product in products:\n    print(f\"Product's id: {product.id}\")\n```\n\n### Get an entity\nYou can get an entity with the `get()` method in the resource. It accepts the `id` of the entity to get. The entity is returned.\n``` python\nfrom paddle_billing import Client\n\npaddle = Client('PADDLE_API_SECRET_KEY')\n\nproduct = paddle.products.get('PRODUCT_ID')\n```\n\n### Create an entity\nYou can create a supported entity with the `create()` method in the resource. It accepts the resource's corresponding `CreateOperation` e.g. `CreateProduct`. The created entity is returned.\n\n``` python\nfrom paddle_billing                               import Client\nfrom paddle_billing.Entities.Shared.TaxCategory   import TaxCategory\nfrom paddle_billing.Resources.Products.Operations import CreateProduct\n\npaddle = Client('PADDLE_API_SECRET_KEY')\n\ncreated_product = paddle.products.create(CreateProduct(\n    name         = 'My Product',\n    tax_category = TaxCategory.Standard,\n))\n```\n\n### Update an entity\nYou can update a supported entity with the `update()` method in the resource. It accepts the `id` of the entity to update and the corresponding `UpdateOperation` e.g. `UpdateProduct`. The updated entity is returned.\n``` python\nfrom paddle_billing                        import Client\nfrom paddle_billing.Resources.Products.Operations import UpdateProduct\n\npaddle = Client('PADDLE_API_SECRET_KEY')\n\n# Update the name of the product\nupdated_product = paddle.products.update('PRODUCT_ID', UpdateProduct(\n    name = 'My Improved Product'\n))\n```\n\nWhere operations require more than one `id`, the `update()` method accepts multiple arguments. For example, to update an address for a customer, pass the `customerId` and the `addressId`:\n``` python\nupdated_address = paddle.addresses.update(\n    'CUSTOMER_ID',\n    'ADDRESS_ID',\n    operation_goes_here,\n)\n```\n\n### Delete an entity\nYou can delete an entity with the `delete()` method in the resource. It accepts the `id` of the entity to delete. The deleted entity is returned.\n``` python\nfrom paddle_billing import Client\n\npaddle = Client('PADDLE_API_SECRET_KEY')\n\ndeleted_product = paddle.products.delete('PRODUCT_ID')\n```\n\n\n## Resources\n\n### Webhook signature verification\nThe SDK includes a helper class to verify webhook signatures sent by Notifications from Paddle.\n\n``` python\nfrom paddle_billing.Notifications import Secret, Verifier\n\nintegrity_check = Verifier().verify(request, Secret('WEBHOOK_SECRET_KEY'))\n```\n\n## Learn more\n- [Paddle API reference](https://developer.paddle.com/api-reference/overview?utm_source=dx&utm_medium=paddle-python-sdk)\n- [Sign up for Paddle Billing](https://login.paddle.com/signup?utm_source=dx&utm_medium=paddle-python-sdk)\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Paddle's Python SDK for Paddle Billing",
    "version": "1.3.1",
    "project_urls": {
        "Homepage": "https://developer.paddle.com/api-reference/overview"
    },
    "split_keywords": [
        "paddle",
        " sdk",
        " python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fca1265762b84e7d9a4237af34771ab8e5b31ce94de0c6f4dea15ad4bfc7e484",
                "md5": "80d2f1f5d31ee6db503f3a5b525d1537",
                "sha256": "6d45c087f2dfc12096478cbdbbf6bcaa5abc521268e973d233f4fe53f5e406f8"
            },
            "downloads": -1,
            "filename": "paddle_python_sdk-1.3.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "80d2f1f5d31ee6db503f3a5b525d1537",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 327104,
            "upload_time": "2024-12-17T21:26:31",
            "upload_time_iso_8601": "2024-12-17T21:26:31.026012Z",
            "url": "https://files.pythonhosted.org/packages/fc/a1/265762b84e7d9a4237af34771ab8e5b31ce94de0c6f4dea15ad4bfc7e484/paddle_python_sdk-1.3.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "eab813ec868dceeb6d0f52ca1ea0cddf02f0aa61c0c5da07f021603b7a0613bf",
                "md5": "a29a2fe8207780cc89f38d42eba76618",
                "sha256": "753a0c407e3146d62fb52882941d9210497f50ccc106c59ec26ac244a9dc0bdd"
            },
            "downloads": -1,
            "filename": "paddle_python_sdk-1.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "a29a2fe8207780cc89f38d42eba76618",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 127166,
            "upload_time": "2024-12-17T21:26:34",
            "upload_time_iso_8601": "2024-12-17T21:26:34.194037Z",
            "url": "https://files.pythonhosted.org/packages/ea/b8/13ec868dceeb6d0f52ca1ea0cddf02f0aa61c0c5da07f021603b7a0613bf/paddle_python_sdk-1.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-17 21:26:34",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "paddle-python-sdk"
}
        
Elapsed time: 0.38392s