Metadata-Version: 2.1
Name: paddle-python
Version: 0.2.0
Summary: Python wrapper around the Paddle.com API
Home-page: https://github.com/pyepye/paddle-python
License: MIT
Keywords: paddle,paddle.com,payments,billing,commerce,finance,saas
Author: Matt Pye
Author-email: pyematt@gmail.com
Requires-Python: >=3.5,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Requires-Dist: requests (>=2.23.0,<3.0.0)
Project-URL: Repository, https://github.com/pyepye/paddle-python
Description-Content-Type: text/markdown

# Paddle Python

A python (3.5+) wrapper around the [Paddle.com](https://paddle.com/) [API](https://developer.paddle.com/api-reference/intro)

_Note: This is a work in progress, not all of the Paddle endpoints have been implemented yet_

## Quick start

### Installation

```bash
pip install paddle-python
```


### Usage

To use the Paddle API you will need a Paddle Vendor ID and API key which can be found on [Paddle's SDK page](https://vendors.paddle.com/sdk)

```python
from paddle import Paddle


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

If `vendor_id` and `api_key` are not passed through when initalising Paddle will fall back and try and use environmental variables called `PADDLE_VENDOR_ID` and `PADDLE_API_KEY`
```bash
export PADDLE_VENDOR_ID=12345
export PADDLE_API_KEY="myapikey"
```

```python
from paddle import Paddle


paddle = Paddle()
paddle.list_products()
```


## Documentation

Coming soon. Please see `Working endpoints` below for basic usage.


## Contributing

All contributions are welcome and appreciated. Please see [CONTRIBUTING.md](https://github.com/pyepye/paddle-python/blob/master/CONTRIBUTING.md) for more details including details on how to run tests etc.


## Working endpoints
* [Get Order Details](https://developer.paddle.com/api-reference/checkout-api/order-information/getorder)
* [Get User History](https://checkout.paddle.com/api/2.0/user/history)
* [Get Prices](https://developer.paddle.com/api-reference/checkout-api/prices/getprices)
* [List Coupons](https://developer.paddle.com/api-reference/product-api/coupons/listcoupons)
* [Create Coupon](https://developer.paddle.com/api-reference/product-api/coupons/createcoupon)
* [Delete Coupon](https://developer.paddle.com/api-reference/product-api/coupons/deletecoupon)
* [Update Coupon](https://developer.paddle.com/api-reference/product-api/coupons/updatecoupon)
* [List Products](https://developer.paddle.com/api-reference/product-api/products/getproducts)
* [List Transactions](https://developer.paddle.com/api-reference/product-api/transactions/listtransactions)
* [Refund Payment](https://developer.paddle.com/api-reference/product-api/payments/refundpayment)
* [List Plans](https://developer.paddle.com/api-reference/subscription-api/plans/listplans)
* [Get Webhook History](https://developer.paddle.com/api-reference/alert-api/webhooks/webhooks)

```python
paddle.get_order_details(checkout_id=checkout_id)
paddle.get_user_history(email=email)
paddle.get_prices(product_ids=[product_id])
paddle.list_coupons(product_id=product_id)
paddle.create_coupon(
    coupon_type='product',
    discount_type='percentage',
    discount_amount=50,
    allowed_uses=1,
    recurring=False,
    currency='USD',
    product_ids=product_ids,
    coupon_code='50%OFF',
    description='50% off coupon over $10',
    expires=expires,
    minimum_threshold=10,
    group='paddle-python',
)
paddle.delete_coupon(coupon_code=new_coupon_code, product_id=product_id)
paddle.update_coupon(
    coupon_code=coupon_code,
    new_coupon_code='40%OFF',
    new_group='paddle-python-test',
    product_ids=[product_id],
    expires=expires,
    allowed_uses=1,
    currency='USD',
    minimum_threshold=10,
    discount_amount=40,
    recurring=True
)
paddle.list_products()
paddle.list_transactions(entity='subscription', entity_id=subscription_id)
paddle.refund_payment(order_id=order_id, amount=amount, reason=reason)
paddle.list_plans()
paddle.get_webhook_history()
```


## Failing Endpoints

The below endpoints have been implimented but are not working correctly according to the tests. They have been commented out in `paddle/paddle.py` and the tests will skip is the methods do not exist

* [Generate License](https://developer.paddle.com/api-reference/product-api/licenses/createlicense) - `Paddle error 108 - Unable to find requested product`
* [Create pay link](https://developer.paddle.com/api-reference/product-api/pay-links/createpaylink) -  `Paddle error 108 - Unable to find requested product`


## ToDo
* Fix generate license and create pay link endpoints
* Paddle API endpoints
    * [Create Plan](https://developer.paddle.com/api-reference/subscription-api/plans/createplan)
    * [List Users](https://developer.paddle.com/api-reference/subscription-api/subscription-users/listusers)
    * [Cancel Subscription](https://developer.paddle.com/api-reference/subscription-api/subscription-users/canceluser)
    * [Update Subscription](https://developer.paddle.com/api-reference/subscription-api/subscription-users/updateuser)
    * [Preview Subscription Update](https://developer.paddle.com/api-reference/subscription-api/subscription-users/previewupdate)
    * [Add Modifier](https://developer.paddle.com/api-reference/subscription-api/modifiers/createmodifier)
    * [Delete Modifier](https://developer.paddle.com/api-reference/subscription-api/modifiers/deletemodifier)
    * [List Modifiers](https://developer.paddle.com/api-reference/subscription-api/modifiers/listmodifiers)
    * [List Payments](https://developer.paddle.com/api-reference/subscription-api/payments/listpayments)
    * [Reschedule Payment](https://developer.paddle.com/api-reference/subscription-api/payments/updatepayment)
    * [Create One-off Charge](https://developer.paddle.com/api-reference/subscription-api/one-off-charges/createcharge)
* Get test coverage to 100%
* Docs (auto docs?)
* Use `pytest-mock` `Spy` to check params, json, urls etc for test requests
* Have mock which always runs to go along side each `manual_cleanup` test
* How to deal with the manual cleanup?
* Pull request template
* TravisCI?
* Dependabot
* Remove double call for exception error message checking - How to get the exception str from `pytest.raises()`? pytest-mock `Spy`?

