|
2 | 2 |
|
3 | 3 | A python (3+) wrapper around the Paddle API
|
4 | 4 |
|
5 |
| -This is a work in progress |
| 5 | +This is a work in progress, not all of the Paddle endpoints have been implimented yet |
6 | 6 |
|
| 7 | +## Quick start |
7 | 8 |
|
8 |
| -## Setup |
9 |
| -```bash |
10 |
| -curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3 |
11 |
| -poetry install |
12 |
| - |
13 |
| -# Create a file called .env and add the below |
14 |
| -export PADDLE_VENDOR_ID=... |
15 |
| -export PADDLE_API_KEY="..." |
| 9 | +### Installation |
16 | 10 |
|
17 |
| -poetry shell |
18 |
| -source .env |
| 11 | +This package is not yet on Pypi (as the name `paddle` name it taken and we can't think of anything better right now) so until then you can install it straight from Github: |
| 12 | +``` |
| 13 | +pip install git+https://github.com/pyepye/paddle-python |
19 | 14 | ```
|
20 | 15 |
|
21 |
| -## Running tests |
22 | 16 |
|
23 |
| -All tests are currently run against Paddle's API directly. No mocks are used as this is meant to be a thin wrapper. This does mean you need to set a few environmental variables specific to your Paddle account for the tests to run correctly. |
| 17 | +### Usage |
| 18 | + |
| 19 | +```python |
| 20 | +from paddle import Paddle |
| 21 | + |
| 22 | + |
| 23 | +paddle = Paddle(vendor_id=12345, api_key='myapikey') |
| 24 | +paddle.list_products() |
| 25 | +``` |
24 | 26 |
|
| 27 | +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` |
25 | 28 | ```bash
|
26 |
| -poetry shell |
27 |
| -# Add the below to .env |
28 |
| -export PADDLE_TEST_DEFAULT_CHECKOUT_ID="..." |
29 |
| -export PADDLE_TEST_DEFAULT_PRODUCT_ID=... |
30 |
| -export PADDLE_TEST_DEFAULT_PLAN_ID=... |
31 |
| -source .env |
32 |
| -pytest tests/ |
33 |
| -# Coverage info is written to htmlcov/ |
| 29 | +export PADDLE_VENDOR_ID=12345 |
| 30 | +export PADDLE_API_KEY="myfakeapikey" |
34 | 31 | ```
|
35 | 32 |
|
36 |
| -### Cleanup |
| 33 | +```python |
| 34 | +from paddle import Paddle |
37 | 35 |
|
38 |
| -_(These tests are currently not working and marked as skipped so this can be ignored)_ |
39 | 36 |
|
40 |
| -Parts of the Paddle API have create endpoints but not delete endpoints. Because of this several tests need to be cleaned up manually after they are run: |
| 37 | +paddle = Paddle() |
| 38 | +paddle.list_products() |
| 39 | +``` |
41 | 40 |
|
42 | 41 |
|
43 |
| -* `tests/test_licenses.py::test_generate_license` |
44 |
| -* `tests/test_pay_links.py::test_create_pay_link` |
| 42 | +## Working endpoints |
45 | 43 |
|
46 | 44 |
|
47 |
| -## Working endpoints |
48 | 45 | * [Get Order Details](https://developer.paddle.com/api-reference/checkout-api/order-information/getorder)
|
49 | 46 | * [Get User History](https://checkout.paddle.com/api/2.0/user/history)
|
50 | 47 | * [Get Prices](https://developer.paddle.com/api-reference/checkout-api/prices/getprices)
|
51 | 48 | * [List Coupons](https://developer.paddle.com/api-reference/product-api/coupons/listcoupons)
|
52 | 49 | * [Create Coupon](https://developer.paddle.com/api-reference/product-api/coupons/createcoupon)
|
53 | 50 | * [Delete Coupon](https://developer.paddle.com/api-reference/product-api/coupons/deletecoupon)
|
54 | 51 | * [Update Coupon](https://developer.paddle.com/api-reference/product-api/coupons/updatecoupon)
|
55 |
| -* [List products](https://developer.paddle.com/api-reference/product-api/products/getproducts) |
| 52 | +* [List Products](https://developer.paddle.com/api-reference/product-api/products/getproducts) |
56 | 53 | * [List Plans](https://developer.paddle.com/api-reference/subscription-api/plans/listplans)
|
57 | 54 | * [Get Webhook History](https://developer.paddle.com/api-reference/alert-api/webhooks/webhooks)
|
58 | 55 |
|
| 56 | +```python |
| 57 | +paddle.get_order_details(checkout_id=checkout_id) |
| 58 | +paddle.get_user_history(email=email) |
| 59 | +paddle.get_prices(product_ids=[product_id]) |
| 60 | +paddle.list_coupons(product_id=product_id) |
| 61 | +paddle.create_coupon( |
| 62 | + coupon_type=coupon_type, |
| 63 | + discount_type=discount_type, |
| 64 | + discount_amount=discount_amount, |
| 65 | + allowed_uses=allowed_uses, |
| 66 | + recurring=recurring, |
| 67 | + currency=currency, |
| 68 | + product_ids=product_ids, |
| 69 | + coupon_code=coupon_code, |
| 70 | + description=description, |
| 71 | + expires=expires, |
| 72 | + minimum_threshold=minimum_threshold, |
| 73 | + group=group, |
| 74 | +) |
| 75 | +paddle.delete_coupon(coupon_code=new_coupon_code, product_id=product_id) |
| 76 | +paddle.update_coupon( |
| 77 | + coupon_code=coupon_code, |
| 78 | + new_coupon_code=new_coupon_code, |
| 79 | + new_group='paddle-python-test', |
| 80 | + product_ids=[product_id], |
| 81 | + expires=expires, |
| 82 | + allowed_uses=allowed_uses, |
| 83 | + currency=currency, |
| 84 | + minimum_threshold=9998, |
| 85 | + discount_amount=discount_amount, |
| 86 | + recurring=True |
| 87 | +) |
| 88 | +paddle.list_products() |
| 89 | +paddle.list_plans() |
| 90 | +paddle.get_webhook_history() |
| 91 | +``` |
| 92 | + |
59 | 93 |
|
60 | 94 | ## Failing Endpoints
|
61 | 95 |
|
|
0 commit comments