python-payway 0.0.3__tar.gz → 0.0.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python-payway-0.0.3 → python_payway-0.0.5}/PKG-INFO +46 -32
- {python-payway-0.0.3 → python_payway-0.0.5}/README.md +38 -27
- {python-payway-0.0.3 → python_payway-0.0.5}/payway/client.py +112 -98
- {python-payway-0.0.3 → python_payway-0.0.5}/payway/conf.py +2 -0
- {python-payway-0.0.3 → python_payway-0.0.5}/payway/constants.py +2 -3
- {python-payway-0.0.3 → python_payway-0.0.5}/payway/customers.py +31 -20
- python_payway-0.0.5/payway/exceptions.py +22 -0
- {python-payway-0.0.3 → python_payway-0.0.5}/payway/model.py +138 -139
- python_payway-0.0.5/payway/test_utils.py +11 -0
- {python-payway-0.0.3 → python_payway-0.0.5}/payway/transactions.py +4 -2
- {python-payway-0.0.3 → python_payway-0.0.5}/payway/utils.py +7 -3
- python_payway-0.0.5/pyproject.toml +133 -0
- {python-payway-0.0.3 → python_payway-0.0.5}/python_payway.egg-info/PKG-INFO +46 -32
- {python-payway-0.0.3 → python_payway-0.0.5}/python_payway.egg-info/SOURCES.txt +2 -1
- python_payway-0.0.5/python_payway.egg-info/requires.txt +6 -0
- {python-payway-0.0.3 → python_payway-0.0.5}/python_payway.egg-info/top_level.txt +0 -1
- python_payway-0.0.5/tests/test_client.py +259 -0
- {python-payway-0.0.3 → python_payway-0.0.5}/tests/test_customers.py +14 -26
- python_payway-0.0.5/tests/test_transactions.py +32 -0
- python-payway-0.0.3/payway/exceptions.py +0 -29
- python-payway-0.0.3/python_payway.egg-info/requires.txt +0 -1
- python-payway-0.0.3/setup.py +0 -28
- python-payway-0.0.3/tests/test_client.py +0 -477
- python-payway-0.0.3/tests/test_transactions.py +0 -48
- {python-payway-0.0.3 → python_payway-0.0.5}/LICENSE +0 -0
- {python-payway-0.0.3 → python_payway-0.0.5}/payway/__init__.py +0 -0
- {python-payway-0.0.3 → python_payway-0.0.5}/python_payway.egg-info/dependency_links.txt +0 -0
- {python-payway-0.0.3 → python_payway-0.0.5}/setup.cfg +0 -0
- {python-payway-0.0.3 → python_payway-0.0.5}/tests/__init__.py +0 -0
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: python-payway
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.5
|
|
4
4
|
Summary: Python client for working with Westpac's PayWay REST API
|
|
5
|
-
|
|
6
|
-
Author: Ben Napper
|
|
7
|
-
Author-email: reppan197@gmail.com
|
|
5
|
+
Author-email: Ben Napper <reppan197@gmail.com>
|
|
8
6
|
License: MIT
|
|
7
|
+
Keywords: payway,westpac,api,client
|
|
9
8
|
Classifier: Programming Language :: Python :: 3
|
|
10
9
|
Classifier: License :: OSI Approved :: MIT License
|
|
11
10
|
Classifier: Operating System :: OS Independent
|
|
12
|
-
Requires-Python: >=
|
|
11
|
+
Requires-Python: >=3.8
|
|
13
12
|
Description-Content-Type: text/markdown
|
|
14
13
|
License-File: LICENSE
|
|
15
14
|
Requires-Dist: requests>=2.20.0
|
|
15
|
+
Provides-Extra: dev
|
|
16
|
+
Requires-Dist: pre-commit>=3.5.0; extra == "dev"
|
|
17
|
+
Requires-Dist: ruff==0.6.6; extra == "dev"
|
|
18
|
+
Requires-Dist: mypy>=0.971; extra == "dev"
|
|
16
19
|
|
|
17
20
|
# PayWay REST API - Python
|
|
18
21
|
|
|
@@ -24,13 +27,13 @@ Requires-Dist: requests>=2.20.0
|
|
|
24
27
|
- Void transactions
|
|
25
28
|
- Update a customer's payment setup in PayWay
|
|
26
29
|
|
|
27
|
-
|
|
30
|
+
## Install
|
|
28
31
|
|
|
29
|
-
```
|
|
32
|
+
```bash
|
|
30
33
|
pip install python-payway
|
|
31
34
|
```
|
|
32
35
|
|
|
33
|
-
|
|
36
|
+
## Take payment using a stored credit card
|
|
34
37
|
|
|
35
38
|
Create a Client class with your PayWay API credentials
|
|
36
39
|
|
|
@@ -57,7 +60,7 @@ customer = PayWayCustomer(custom_id='c981a',
|
|
|
57
60
|
state='NSW',
|
|
58
61
|
postal_code='2000')
|
|
59
62
|
```
|
|
60
|
-
|
|
63
|
+
|
|
61
64
|
Create a PayWayCard class with your customer's card details
|
|
62
65
|
|
|
63
66
|
```python
|
|
@@ -78,7 +81,7 @@ payway_customer, customer_errors = client.create_customer(customer)
|
|
|
78
81
|
```
|
|
79
82
|
|
|
80
83
|
Note the 'payway_customer' object contains the full customer response fields from PayWay.
|
|
81
|
-
|
|
84
|
+
|
|
82
85
|
Create a Payment class with the payment details and process the transaction
|
|
83
86
|
|
|
84
87
|
```python
|
|
@@ -90,8 +93,8 @@ payment = PayWayPayment(customer_number=customer_number,
|
|
|
90
93
|
order_number='',
|
|
91
94
|
ip_address='')
|
|
92
95
|
transaction, errors = client.process_payment(payment)
|
|
93
|
-
```
|
|
94
|
-
|
|
96
|
+
```
|
|
97
|
+
|
|
95
98
|
Check the `transaction` for the result
|
|
96
99
|
|
|
97
100
|
```python
|
|
@@ -99,7 +102,7 @@ if not errors and transaction.status == 'approved':
|
|
|
99
102
|
# process successful response
|
|
100
103
|
```
|
|
101
104
|
|
|
102
|
-
|
|
105
|
+
## Take payment using a credit card token only
|
|
103
106
|
|
|
104
107
|
```python
|
|
105
108
|
client = Client(merchant_id='',
|
|
@@ -125,10 +128,10 @@ payment = PayWayPayment(customer_number=customer_number,
|
|
|
125
128
|
transaction, errors = client.process_payment(payment)
|
|
126
129
|
```
|
|
127
130
|
|
|
128
|
-
|
|
131
|
+
## Handling errors
|
|
129
132
|
|
|
130
133
|
Documented errors (such as 422 Unprocessable entity) are parsed into an PaymentError class that you can use in an customer error message.
|
|
131
|
-
https://www.payway.com.au/docs/rest.html#http-response-codes
|
|
134
|
+
For more info, visit <https://www.payway.com.au/docs/rest.html#http-response-codes>
|
|
132
135
|
|
|
133
136
|
```python
|
|
134
137
|
if errors:
|
|
@@ -138,9 +141,10 @@ if errors:
|
|
|
138
141
|
print(error.field_name)
|
|
139
142
|
# or use a method
|
|
140
143
|
PaymentError().list_to_message(errors)
|
|
141
|
-
```
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Direct Debit
|
|
142
147
|
|
|
143
|
-
# Direct Debit
|
|
144
148
|
Direct debit transactions are possible by creating a token from a bank account:
|
|
145
149
|
|
|
146
150
|
```python
|
|
@@ -153,15 +157,15 @@ Store the token with a customer in PayWay using the same process as the card out
|
|
|
153
157
|
|
|
154
158
|
Note: direct debit transactions take days to process so they must be polled regularly for the latest transaction status from the customer's bank.
|
|
155
159
|
|
|
156
|
-
|
|
160
|
+
## Lookup transaction
|
|
157
161
|
|
|
158
162
|
Poll a transaction using the `get_transaction` method.
|
|
159
163
|
|
|
160
164
|
```python
|
|
161
165
|
transaction, errors = client.get_transaction(transaction.transaction_id)
|
|
162
|
-
```
|
|
166
|
+
```
|
|
163
167
|
|
|
164
|
-
|
|
168
|
+
## Process and capture a pre-authorisation
|
|
165
169
|
|
|
166
170
|
To process a credit card pre-authorisation using a credit card stored against a customer use `preAuth` as the `transaction_type` along with the customer's PayWay number, amount and currency.
|
|
167
171
|
|
|
@@ -186,7 +190,7 @@ capture_payment = PayWayPayment(transaction_type='capture',
|
|
|
186
190
|
transaction, errors = client.process_payment(capture_payment)
|
|
187
191
|
```
|
|
188
192
|
|
|
189
|
-
|
|
193
|
+
## Refunds
|
|
190
194
|
|
|
191
195
|
Refund a transaction by supplying a PayWay transaction ID and the refund amount.
|
|
192
196
|
|
|
@@ -197,7 +201,7 @@ refund, errors = client.refund_transaction(
|
|
|
197
201
|
)
|
|
198
202
|
```
|
|
199
203
|
|
|
200
|
-
|
|
204
|
+
## Voiding a transaction
|
|
201
205
|
|
|
202
206
|
Void a transaction by supplying a PayWay transaction ID.
|
|
203
207
|
|
|
@@ -205,7 +209,7 @@ Void a transaction by supplying a PayWay transaction ID.
|
|
|
205
209
|
void_transaction, errors = client.void_transaction(transaction.transaction_id)
|
|
206
210
|
```
|
|
207
211
|
|
|
208
|
-
|
|
212
|
+
## Update Payment Setup
|
|
209
213
|
|
|
210
214
|
Update a customer's payment setup with a new credit card or bank account in PayWay. Supply the new token and an existing PayWay customer number.
|
|
211
215
|
|
|
@@ -213,18 +217,28 @@ Update a customer's payment setup with a new credit card or bank account in PayW
|
|
|
213
217
|
payment_setup, errors = client.update_payment_setup(new_token, payway_customer.customer_number)
|
|
214
218
|
```
|
|
215
219
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
https://www.payway.com.au/docs/rest.html
|
|
220
|
+
## Additional notes
|
|
221
|
+
|
|
222
|
+
PayWay API documentation <https://www.payway.com.au/docs/rest.html>
|
|
219
223
|
|
|
220
|
-
It is recommended to use PayWay's Trusted Frame https://www.payway.com.au/docs/rest.html#trusted-frame
|
|
224
|
+
It is recommended to use PayWay's Trusted Frame <https://www.payway.com.au/docs/rest.html#trusted-frame>
|
|
221
225
|
when creating a single use token of a card or bank account so your PCI-compliance scope is reduced.
|
|
222
226
|
|
|
223
|
-
|
|
227
|
+
## Fraud
|
|
228
|
+
|
|
229
|
+
Please follow PayWay's advice about reducing your risk of fraudulent transactions. <https://www.payway.com.au/docs/card-testing.html#card-testing>
|
|
224
230
|
|
|
225
|
-
|
|
226
|
-
https://www.payway.com.au/docs/card-testing.html#card-testing
|
|
231
|
+
## Running the project
|
|
227
232
|
|
|
228
|
-
|
|
233
|
+
```bash
|
|
234
|
+
uv python install 3.8.19
|
|
235
|
+
uv venv
|
|
236
|
+
source .venv/bin/activate
|
|
237
|
+
uv sync --extra dev
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Testing
|
|
229
241
|
|
|
230
|
-
|
|
242
|
+
```bash
|
|
243
|
+
python -m unittest discover tests
|
|
244
|
+
```
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
- Void transactions
|
|
9
9
|
- Update a customer's payment setup in PayWay
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
## Install
|
|
12
12
|
|
|
13
|
-
```
|
|
13
|
+
```bash
|
|
14
14
|
pip install python-payway
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
## Take payment using a stored credit card
|
|
18
18
|
|
|
19
19
|
Create a Client class with your PayWay API credentials
|
|
20
20
|
|
|
@@ -41,7 +41,7 @@ customer = PayWayCustomer(custom_id='c981a',
|
|
|
41
41
|
state='NSW',
|
|
42
42
|
postal_code='2000')
|
|
43
43
|
```
|
|
44
|
-
|
|
44
|
+
|
|
45
45
|
Create a PayWayCard class with your customer's card details
|
|
46
46
|
|
|
47
47
|
```python
|
|
@@ -62,7 +62,7 @@ payway_customer, customer_errors = client.create_customer(customer)
|
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
Note the 'payway_customer' object contains the full customer response fields from PayWay.
|
|
65
|
-
|
|
65
|
+
|
|
66
66
|
Create a Payment class with the payment details and process the transaction
|
|
67
67
|
|
|
68
68
|
```python
|
|
@@ -74,8 +74,8 @@ payment = PayWayPayment(customer_number=customer_number,
|
|
|
74
74
|
order_number='',
|
|
75
75
|
ip_address='')
|
|
76
76
|
transaction, errors = client.process_payment(payment)
|
|
77
|
-
```
|
|
78
|
-
|
|
77
|
+
```
|
|
78
|
+
|
|
79
79
|
Check the `transaction` for the result
|
|
80
80
|
|
|
81
81
|
```python
|
|
@@ -83,7 +83,7 @@ if not errors and transaction.status == 'approved':
|
|
|
83
83
|
# process successful response
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
## Take payment using a credit card token only
|
|
87
87
|
|
|
88
88
|
```python
|
|
89
89
|
client = Client(merchant_id='',
|
|
@@ -109,10 +109,10 @@ payment = PayWayPayment(customer_number=customer_number,
|
|
|
109
109
|
transaction, errors = client.process_payment(payment)
|
|
110
110
|
```
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
## Handling errors
|
|
113
113
|
|
|
114
114
|
Documented errors (such as 422 Unprocessable entity) are parsed into an PaymentError class that you can use in an customer error message.
|
|
115
|
-
https://www.payway.com.au/docs/rest.html#http-response-codes
|
|
115
|
+
For more info, visit <https://www.payway.com.au/docs/rest.html#http-response-codes>
|
|
116
116
|
|
|
117
117
|
```python
|
|
118
118
|
if errors:
|
|
@@ -122,9 +122,10 @@ if errors:
|
|
|
122
122
|
print(error.field_name)
|
|
123
123
|
# or use a method
|
|
124
124
|
PaymentError().list_to_message(errors)
|
|
125
|
-
```
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Direct Debit
|
|
126
128
|
|
|
127
|
-
# Direct Debit
|
|
128
129
|
Direct debit transactions are possible by creating a token from a bank account:
|
|
129
130
|
|
|
130
131
|
```python
|
|
@@ -137,15 +138,15 @@ Store the token with a customer in PayWay using the same process as the card out
|
|
|
137
138
|
|
|
138
139
|
Note: direct debit transactions take days to process so they must be polled regularly for the latest transaction status from the customer's bank.
|
|
139
140
|
|
|
140
|
-
|
|
141
|
+
## Lookup transaction
|
|
141
142
|
|
|
142
143
|
Poll a transaction using the `get_transaction` method.
|
|
143
144
|
|
|
144
145
|
```python
|
|
145
146
|
transaction, errors = client.get_transaction(transaction.transaction_id)
|
|
146
|
-
```
|
|
147
|
+
```
|
|
147
148
|
|
|
148
|
-
|
|
149
|
+
## Process and capture a pre-authorisation
|
|
149
150
|
|
|
150
151
|
To process a credit card pre-authorisation using a credit card stored against a customer use `preAuth` as the `transaction_type` along with the customer's PayWay number, amount and currency.
|
|
151
152
|
|
|
@@ -170,7 +171,7 @@ capture_payment = PayWayPayment(transaction_type='capture',
|
|
|
170
171
|
transaction, errors = client.process_payment(capture_payment)
|
|
171
172
|
```
|
|
172
173
|
|
|
173
|
-
|
|
174
|
+
## Refunds
|
|
174
175
|
|
|
175
176
|
Refund a transaction by supplying a PayWay transaction ID and the refund amount.
|
|
176
177
|
|
|
@@ -181,7 +182,7 @@ refund, errors = client.refund_transaction(
|
|
|
181
182
|
)
|
|
182
183
|
```
|
|
183
184
|
|
|
184
|
-
|
|
185
|
+
## Voiding a transaction
|
|
185
186
|
|
|
186
187
|
Void a transaction by supplying a PayWay transaction ID.
|
|
187
188
|
|
|
@@ -189,7 +190,7 @@ Void a transaction by supplying a PayWay transaction ID.
|
|
|
189
190
|
void_transaction, errors = client.void_transaction(transaction.transaction_id)
|
|
190
191
|
```
|
|
191
192
|
|
|
192
|
-
|
|
193
|
+
## Update Payment Setup
|
|
193
194
|
|
|
194
195
|
Update a customer's payment setup with a new credit card or bank account in PayWay. Supply the new token and an existing PayWay customer number.
|
|
195
196
|
|
|
@@ -197,18 +198,28 @@ Update a customer's payment setup with a new credit card or bank account in PayW
|
|
|
197
198
|
payment_setup, errors = client.update_payment_setup(new_token, payway_customer.customer_number)
|
|
198
199
|
```
|
|
199
200
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
https://www.payway.com.au/docs/rest.html
|
|
201
|
+
## Additional notes
|
|
202
|
+
|
|
203
|
+
PayWay API documentation <https://www.payway.com.au/docs/rest.html>
|
|
203
204
|
|
|
204
|
-
It is recommended to use PayWay's Trusted Frame https://www.payway.com.au/docs/rest.html#trusted-frame
|
|
205
|
+
It is recommended to use PayWay's Trusted Frame <https://www.payway.com.au/docs/rest.html#trusted-frame>
|
|
205
206
|
when creating a single use token of a card or bank account so your PCI-compliance scope is reduced.
|
|
206
207
|
|
|
207
|
-
|
|
208
|
+
## Fraud
|
|
209
|
+
|
|
210
|
+
Please follow PayWay's advice about reducing your risk of fraudulent transactions. <https://www.payway.com.au/docs/card-testing.html#card-testing>
|
|
208
211
|
|
|
209
|
-
|
|
210
|
-
https://www.payway.com.au/docs/card-testing.html#card-testing
|
|
212
|
+
## Running the project
|
|
211
213
|
|
|
212
|
-
|
|
214
|
+
```bash
|
|
215
|
+
uv python install 3.8.19
|
|
216
|
+
uv venv
|
|
217
|
+
source .venv/bin/activate
|
|
218
|
+
uv sync --extra dev
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## Testing
|
|
213
222
|
|
|
214
|
-
|
|
223
|
+
```bash
|
|
224
|
+
python -m unittest discover tests
|
|
225
|
+
```
|