8
8
- Void transactions
9
9
- Update a customer's payment setup in PayWay
10
10
11
- # Install
11
+ ## Install
12
12
13
- ```
13
+ ``` bash
14
14
pip install python-payway
15
15
```
16
16
17
- # Take payment using a stored credit card
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,16 +74,16 @@ 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
82
82
if not errors and transaction.status == ' approved' :
83
83
# process successful response
84
84
```
85
85
86
- # Take payment using a credit card token only
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
- # Handling errors
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
- # Lookup transaction
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
- # Process and capture a pre-authorisation
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
- # Refunds
174
+ ## Refunds
174
175
175
176
Refund a transaction by supplying a PayWay transaction ID and the refund amount.
176
177
@@ -181,34 +182,44 @@ refund, errors = client.refund_transaction(
181
182
)
182
183
```
183
184
184
- # Voiding a transaction
185
+ ## Voiding a transaction
185
186
186
187
Void a transaction by supplying a PayWay transaction ID.
187
188
188
189
``` python
189
190
void_transaction, errors = client.void_transaction(transaction.transaction_id)
190
191
```
191
192
192
- # Update Payment Setup
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
196
197
``` python
197
198
payment_setup, errors = client.update_payment_setup(new_token, payway_customer.customer_number)
198
199
```
199
200
200
- # Additional notes
201
- PayWay API documentation
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
- # Fraud
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
- Please follow PayWay's advice about reducing your risk of fraudulent transactions.
210
- https://www.payway.com.au/docs/card-testing.html#card-testing
212
+ ## Running the project
211
213
212
- # Testing
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
- 1 . Run the tests using ` python -m unittest discover tests `
223
+ ``` bash
224
+ python -m unittest discover tests
225
+ ```
0 commit comments