Skip to content

Commit cc1bc53

Browse files
committed
Update README and add CONTRIBUTING
1 parent 05a7159 commit cc1bc53

File tree

2 files changed

+137
-28
lines changed

2 files changed

+137
-28
lines changed

CONTRIBUTING.md

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# How to contribute
2+
3+
Thanks for wanting to contribute to the Paddle python API wrapper. This wrapper is intended to be a 'thin' wrapper around the API and include no business logic.
4+
5+
Important Paddle resources:
6+
7+
* [Paddle's Vendors Dashboard](https://vendors.paddle.com/overview) - Please make sure you have registered before you get started
8+
* [Paddle developer API reference](https://developer.paddle.com/api-reference/intro)
9+
10+
11+
Python resources:
12+
13+
* [Poetry](https://python-poetry.org/) for python packaging and dependency management
14+
* [Mypy](https://mypy.readthedocs.io/en/stable/) for static type checking
15+
* [pytest](https://docs.pytest.org/en/latest/) for running test
16+
* [isort](https://timothycrosley.github.io/isort/) to keep all our imports looking nice and easy to follow
17+
* [PEP 8 -- Style Guide for Python Code](https://www.python.org/dev/peps/pep-0008/)
18+
19+
20+
## Testing
21+
22+
This package uses the [Poetry](https://python-poetry.org/) for packaging and dependency management, before you get started please install it.
23+
24+
You will then need:
25+
* Your `Paddle Vendor ID` which can be found on the [Paddle's SDK page](https://vendors.paddle.com/sdk)
26+
* Your `Paddle API key` which is found on the same [Paddle's SDK page](https://vendors.paddle.com/sdk)
27+
28+
At the moment several of the tests also require a few other bits created in Paddle. We are looking at removing these dependencies soon be creating them with fixtures. Please help us do it if you are up for it.
29+
30+
* A `Paddle Product ID` which you can get one by creating a product on [Paddle's product page](https://vendors.paddle.com/products)
31+
* A `Paddle Plan/Subscription ID` which can created on [Paddle's Subscription Plans page](https://vendors.paddle.com/subscriptions/plans)
32+
* A `Paddle Checkout ID` which can be got by going into an order from the [Paddle orders page](https://vendors.paddle.com/orders). If you don't have an orders yet you can create a order for $0.
33+
34+
The tests currently require you to add the above as environmental variables (names below). To make them easier to set these each time the python virtual environment is loaded they can be places into a `.env` file which can be source'd.
35+
36+
```
37+
# Create a file called .env and add the below
38+
export PADDLE_VENDOR_ID=...
39+
export PADDLE_API_KEY="..."
40+
export PADDLE_TEST_DEFAULT_CHECKOUT_ID="..."
41+
export PADDLE_TEST_DEFAULT_PRODUCT_ID=...
42+
export PADDLE_TEST_DEFAULT_PLAN_ID=...
43+
44+
poetry shell
45+
source .env
46+
pytest tests/
47+
# Coverage info is written to htmlcov/
48+
```
49+
50+
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.
51+
52+
53+
### Cleanup
54+
55+
_(These tests are currently not working and marked as skipped so this can be ignored)_
56+
57+
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:
58+
59+
60+
* `tests/test_licenses.py::test_generate_license`
61+
* `tests/test_pay_links.py::test_create_pay_link`
62+
63+
64+
65+
## Submitting changes
66+
67+
Please send a [GitHub Pull Request to paddle-python](https://github.com/pyepye/paddle-python/pull/new/master) with a clear list of what you've done (read more about [pull requests](http://help.github.com/pull-requests/)). All changes should have at least one test to accompany it, either to prove the bug it is fixing has indeed been fixed on to ensure a new feature works as expected.
68+
69+
Please follow our coding conventions (below) and try and make all of your commits atomic (one feature per commit) where possible.
70+
71+
## Coding conventions
72+
73+
* We use [PEP 8](https://www.python.org/dev/peps/pep-0008/) as a guide.
74+
* Please keep to the same style as the code already (single quotes, line length etc).
75+
* We want to keep supporting Python 3.5 for now so no `fstrings` sorry

README.md

+62-28
Original file line numberDiff line numberDiff line change
@@ -2,60 +2,94 @@
22

33
A python (3+) wrapper around the Paddle API
44

5-
This is a work in progress
5+
This is a work in progress, not all of the Paddle endpoints have been implimented yet
66

7+
## Quick start
78

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
1610

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
1914
```
2015

21-
## Running tests
2216

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+
```
2426

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`
2528
```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"
3431
```
3532

36-
### Cleanup
33+
```python
34+
from paddle import Paddle
3735

38-
_(These tests are currently not working and marked as skipped so this can be ignored)_
3936

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+
```
4140

4241

43-
* `tests/test_licenses.py::test_generate_license`
44-
* `tests/test_pay_links.py::test_create_pay_link`
42+
## Working endpoints
4543

4644

47-
## Working endpoints
4845
* [Get Order Details](https://developer.paddle.com/api-reference/checkout-api/order-information/getorder)
4946
* [Get User History](https://checkout.paddle.com/api/2.0/user/history)
5047
* [Get Prices](https://developer.paddle.com/api-reference/checkout-api/prices/getprices)
5148
* [List Coupons](https://developer.paddle.com/api-reference/product-api/coupons/listcoupons)
5249
* [Create Coupon](https://developer.paddle.com/api-reference/product-api/coupons/createcoupon)
5350
* [Delete Coupon](https://developer.paddle.com/api-reference/product-api/coupons/deletecoupon)
5451
* [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)
5653
* [List Plans](https://developer.paddle.com/api-reference/subscription-api/plans/listplans)
5754
* [Get Webhook History](https://developer.paddle.com/api-reference/alert-api/webhooks/webhooks)
5855

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+
5993

6094
## Failing Endpoints
6195

0 commit comments

Comments
 (0)