Skip to content

Commit 737b7d1

Browse files
authored
Bump/v0.05 (#4)
* added the get_businesses and generate checkout methods * updated the readme and added type hinting * remove the type hint from postioal args * updated get_businesses method and test cases * updated user links * updated documentation for get_businesseses and generate_checkout methods and bump version to 0.05 * updated python matrices versions for ci/cd pipeline * updated python matrices versions for ci/cd pipeline * removed py.8 from matrix versions
1 parent 4de82f0 commit 737b7d1

File tree

6 files changed

+207
-63
lines changed

6 files changed

+207
-63
lines changed

.github/workflows/pytests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414

1515
strategy:
1616
matrix:
17-
python-version: [3.6, 3.7, 3.8, 3.9]
17+
python-version: ["3.9", "3.10", "3.11"]
1818

1919
steps:
2020
# Checkout the latest code from the repo

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
default_stages: [commit, push]
22
default_language_version:
3-
python: python3.7
3+
python: python3.9
44
repos:
55
- repo: https://github.com/psf/black
66
rev: 22.3.0
77
hooks:
88
- id: black
99
args: [
1010
--line-length=100,
11-
--target-version=py37,
11+
--target-version=py39,
1212
]
1313
exclude: ^(venv/|docs/)
1414
types: ['python']
@@ -20,7 +20,7 @@ repos:
2020
- id: check-docstring-first
2121
- id: check-yaml
2222
- id: debug-statements
23-
- id: name-tests-test
23+
# - id: name-tests-test
2424
- id: requirements-txt-fixer
2525
- repo: https://github.com/PyCQA/flake8
2626
rev: 4.0.1

README.md

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ pip install pythepeer
1616
## Usage
1717
Instantiate ```Thepeer``` class like so:
1818
```python
19-
import thepeer
2019
from thepeer import Thepeer
2120

22-
# create an instance of ThepeerInit class
21+
# create an instance of Thepeer class
2322

2423
thepeer_instance = Thepeer("YOUR_API_KEY_HERE")
2524

@@ -30,8 +29,9 @@ thepeer_instance = Thepeer("YOUR_API_KEY_HERE")
3029
**Note:**
3130
- For more info about the exposed methods, please refer to the general [documentation](https://docs.thepeer.co/)
3231
- Be sure to keep your API Credentials securely in [environment variables](https://www.twilio.com/blog/environment-variables-python)
32+
3333
### Indexing a user
34-
This describes how to index a user on your account (this is usually the first step before using other methods)
34+
This method describes how to index a user on your account (this is usually the first step before using other methods)
3535

3636
```python
3737
test = thepeer_instance.index_user("Osagie Iyayi", "iyayiemmanuel1@gmail.com", "iyayiemmanuel1@gmail.com")
@@ -90,7 +90,7 @@ test = thepeer_instance.all_users(1,15)
9090

9191

9292
### Update an indexed user
93-
This methods helps to update the details of an indexed user
93+
This method helps to update the details of an indexed user
9494

9595
```python
9696
test = thepeer_instance.update_user(reference,**data)
@@ -109,7 +109,7 @@ test = thepeer_instance.update_user("3bbb0fbf-82fa-48a0-80eb-d2c0338fe7dd", iden
109109
email="dwave101@gmail.com")
110110
```
111111
### Remove an indexed user
112-
This methods helps to remove the details of an indexed user from a specific account
112+
This method helps to remove the details of an indexed user from a specific account
113113

114114
```python
115115
test = thepeer_instance.delete_user("3bbb0fbf-82fa-48a0-80eb-d2c0338fe7dd")
@@ -121,9 +121,53 @@ test = thepeer_instance.delete_user("3bbb0fbf-82fa-48a0-80eb-d2c0338fe7dd")
121121
|----------------------|---------------------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
122122
| ```reference``` | ```string``` | ```true``` | ```the unique reference returned when the user was indexed```
123123

124+
125+
126+
127+
### Get Businesses
128+
This method returns businesses based on the API they integrated.
129+
130+
```python
131+
test = thepeer_instance.get_businesses("checkout")
132+
```
133+
134+
#### Parameters supported
135+
136+
137+
| Parameters | Data type | Required | Description |
138+
|----------------------|---------------------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
139+
| ```channel``` | ```string``` | ```true``` | ```The specific API to return businesses of. supported values are send, checkout, and direct_charge```
140+
141+
142+
### Generate a Checkout
143+
This method allows you to generate a link for your customer to make a one-time payment with
144+
```python
145+
test = thepeer_instance.generate_checkout({
146+
"amount": 1000000,
147+
"currency": "NGN",
148+
"redirect_url": "https://esportfolio.netlify.app",
149+
"email": "jevede6918@muzitp.com",
150+
"meta":{
151+
"name": "Eddie Kirsch",
152+
"identifier": "eddiekirsch",
153+
}
154+
})
155+
```
156+
157+
#### Parameters required
158+
159+
| Parameters | Data type | Required | Description |
160+
|----------------------|---------------------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
161+
| ```redirect_url``` | ```string``` | ```false``` | ```The url Thepeer should redirect to after the customer completes payment.```
162+
| ```amount``` | ```integer``` | ```true``` | ```The amount you are debiting the customer. This should be in kobo. The minimum value is 10000```
163+
| ```email``` | ```string``` | ```true``` | ```The customer’s email address``` |
164+
| ```currency``` | ```string``` | ```true``` | ```The currency the transaction should be carried out in. The supported value is NGN.```
165+
| ```meta``` | ```dictionary``` | ```false``` | ```An object containing additional attributes you will like to have in your transaction response.```
166+
167+
124168
### Get user links
125169

126-
This method gets all payment links associated to an indexed user
170+
This method returns all linked accounts of a user, the user’s account details, as well as the business the account is on.
127171
```python
128172
test = thepeer_instance.get_user_links("3bbb0fbf-82fa-48a0-80eb-d2c0338fe7dd")
129173
```
@@ -134,9 +178,9 @@ test = thepeer_instance.get_user_links("3bbb0fbf-82fa-48a0-80eb-d2c0338fe7dd")
134178
| ```reference``` | ```string``` | ```true``` | ```the unique reference returned when the user was indexed```
135179

136180

137-
### Get single link
181+
### Get single link (linked account)
138182

139-
This method gets the payment information located in a payment link
183+
This method returns a user's linked account's details.
140184

141185
```python
142186
test = thepeer_instance.get_single_link("da14a90c-61c2-4cf7-a837-e3112a2d0c3d")
@@ -146,7 +190,7 @@ test = thepeer_instance.get_single_link("da14a90c-61c2-4cf7-a837-e3112a2d0c3d")
146190

147191
| Parameters | Data type | Required | Description |
148192
|----------------------|---------------------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
149-
| ```link_id``` | ```string``` | ```true``` | ```the unique link_id containing the payment information```
193+
| ```link_id``` | ```string``` | ```true``` | ```The link’s identifier```
150194

151195

152196
### Charge a link
@@ -159,7 +203,7 @@ test = thepeer_instance.charge_link(link_id, amount, remark, currency)
159203

160204
| Parameters | Data type | Required | Description |
161205
|----------------------|---------------------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
162-
| ```link_id``` | ```string``` | ```true``` | ```the unique link_id containing the payment information```
206+
| ```link_id``` | ```string``` | ```true``` | ```The link’s identifier```
163207
| ```amount``` | ```integer``` | ```true``` | ```the amount of the whole transaction```
164208
| ```remark``` | ```string``` | ```true``` | ```short detail about the transaction``` |
165209
| ```currency``` | ```string``` | ```false``` | ```The denomination medium of paying (either one of NGN and USD). defaults to NGN```
@@ -177,7 +221,7 @@ test = thepeer_instance.authorize_charge(charge_reference, event)
177221
| ```charge_reference``` | ```string``` | ```true``` | ```the reference associated to a pending charge request```
178222
| ```event``` | ```string``` | ```true``` | ```the type of webhook event``` |
179223

180-
**Pro Tip:** the various types of webhook events are available [here](https://docs.thepeer.co/authorization/process-authorization-requests#supported-events)
224+
**Pro Tip:** the various types of webhook events are available [here](https://docs.thepeer.co/webhooks/overview)
181225

182226

183227
### Get transaction detail

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
setup(
1414
name="pythepeer",
15-
version="0.0.4",
15+
version="0.0.5",
1616
description="official python sdk for interacting with thepeer payment processing \
1717
infrastructure",
1818
author="Osagie Iyayi",
@@ -36,6 +36,7 @@
3636
"Programming Language :: Python :: 3.8",
3737
"Programming Language :: Python :: 3.9",
3838
"Programming Language :: Python :: 3.10",
39+
"Programming Language :: Python :: 3.11",
3940
"Topic :: Software Development :: Libraries",
4041
],
4142
long_description=README,

tests/test_thepeer.py

Lines changed: 95 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ def test_index_user(self):
2626
def test_view_user(self):
2727
self.assertEqual.__self__.maxDiff = None
2828
self.assertEqual(
29-
thepeer_test_suites.view_user("3bbb0fbf-82fa-48a0-80eb-d2c0338fe7dd"),
29+
thepeer_test_suites.view_user("d2cb0c2c-7bd4-40a0-9744-824fbce176b7"),
3030
{
3131
"indexed_user": {
32+
"reference": "d2cb0c2c-7bd4-40a0-9744-824fbce176b7",
3233
"name": "Osagie Iyayi",
3334
"identifier": "iyayiemmanuel1@gmail.com",
3435
"identifier_type": "email",
3536
"email": "iyayiemmanuel1@gmail.com",
36-
"reference": "3bbb0fbf-82fa-48a0-80eb-d2c0338fe7dd",
37-
"created_at": "2022-04-30T21:30:29.000000Z",
38-
"updated_at": "2022-05-04T07:37:45.000000Z",
37+
"created_at": "2022-05-04T07:37:44.000000Z",
38+
"updated_at": "2022-05-04T07:37:44.000000Z",
3939
}
4040
},
4141
)
@@ -48,34 +48,43 @@ def test_all_users(self):
4848
"indexed_users": {
4949
"data": [
5050
{
51-
"name": "Osagie Iyayi",
52-
"identifier": "iyayiemmanuel1@gmail.com",
51+
"reference": "5c4961bf-56ca-4a28-80af-214543cdf382",
52+
"name": "Adesubomi Jaiyeola",
53+
"identifier": "08095743249",
5354
"identifier_type": "email",
54-
"email": "iyayiemmanuel1@gmail.com",
55-
"reference": "3bbb0fbf-82fa-48a0-80eb-d2c0338fe7dd",
56-
"created_at": "2022-04-30T21:30:29.000000Z",
57-
"updated_at": "2022-05-04T07:37:45.000000Z",
55+
"email": "subomi.ja@gmail.com",
56+
"created_at": "2023-04-04T14:49:30.000000Z",
57+
"updated_at": "2023-04-04T14:49:30.000000Z",
5858
},
5959
{
60+
"reference": "d2cb0c2c-7bd4-40a0-9744-824fbce176b7",
6061
"name": "Osagie Iyayi",
6162
"identifier": "iyayiemmanuel1@gmail.com",
6263
"identifier_type": "email",
6364
"email": "iyayiemmanuel1@gmail.com",
64-
"reference": "d2cb0c2c-7bd4-40a0-9744-824fbce176b7",
6565
"created_at": "2022-05-04T07:37:44.000000Z",
6666
"updated_at": "2022-05-04T07:37:44.000000Z",
6767
},
68-
],
69-
"meta": {"page": 1, "total": 2, "pageCount": 1, "perPage": 15},
70-
}
68+
{
69+
"reference": "e9d09152-fb47-4bb7-a162-7a326cd35c32",
70+
"name": "Jenni Madu",
71+
"identifier": "jennifermadu903@gmail.com",
72+
"identifier_type": "email",
73+
"email": "jennifermadu903@gmail.com",
74+
"created_at": "2023-04-13T14:04:32.000000Z",
75+
"updated_at": "2023-04-13T14:04:32.000000Z",
76+
},
77+
]
78+
},
79+
"meta": {"page": 1, "total": 3, "pageCount": 1, "perPage": 15},
7180
},
7281
)
7382

7483
def test_user_links(self):
7584
self.assertEqual.__self__.maxDiff = None
7685
self.assertEqual(
77-
thepeer_test_suites.get_user_links("3bbb0fbf-82fa-48a0-80eb-d2c0338fe7dd"),
78-
{"links": []},
86+
thepeer_test_suites.get_user_links("d2cb0c2c-7bd4-40a0-9744-824fbce176b7"),
87+
{"links": None},
7988
)
8089

8190
def test_single_link(self):
@@ -92,8 +101,10 @@ def test_charge_link(self):
92101
"3bbb0fbf-82fa-48a0-80eb-d2c0338fe7dd", 2000, "try thepeer"
93102
),
94103
{
95-
"message": "The given data was invalid.",
96-
"errors": {"amount": ["The amount must be at least 10000."]},
104+
"errors": {
105+
"amount": ["The amount field must be numeric value between 10000 and 100000000"]
106+
},
107+
"message": "The given data was invalid",
97108
},
98109
)
99110

@@ -109,25 +120,82 @@ def test_charge_link_2(self):
109120
def test_authorize_charge(self):
110121
self.assertEqual.__self__.maxDiff = None
111122
self.assertEqual(
112-
thepeer_test_suites.authorize_charge("3bbb0fbf-82fa-48a0-80eb-d2c0338fe7dd", "charge"),
113-
{
114-
"message": "The given data was invalid.",
115-
"errors": {"event": ["The selected event is invalid."]},
116-
},
123+
thepeer_test_suites.authorize_charge("3bbb0fbf-82fa-48a0-80eb-d2c0338fe7dd", "success"),
124+
{"message": "resource not found"},
117125
)
118126

119127
def test_transaction_detail(self):
120128
self.assertEqual.__self__.maxDiff = None
121129
self.assertEqual(
122-
thepeer_test_suites.get_transaction_detail("3bbb0fbf-82fa-48a0-80eb-d2c0338fe7dd"),
123-
{"message": "transaction not found"},
130+
thepeer_test_suites.get_transaction_detail("d761e113-1e6d-456d-8341-79a963234511"),
131+
{
132+
"transaction": {
133+
"id": "d761e113-1e6d-456d-8341-79a963234511",
134+
"amount": 1000000,
135+
"channel": "checkout",
136+
"refund": False,
137+
"checkout": {
138+
"id": "402bc104-b17e-4046-bef5-4e3df34aac5c",
139+
"amount": 1000000,
140+
"email": "iyayiemmanuel1@gmail.com",
141+
"currency": "NGN",
142+
"status": "paid",
143+
"linked_account": {
144+
"user": {
145+
"name": "Trojan Okoh",
146+
"identifier": "trojan",
147+
"identifier_type": "username",
148+
},
149+
"business": {
150+
"name": "Cash App",
151+
"logo": "https://palaciodepeer.s3.us-east-2.amazonaws.com/business_logos/UJimBqYOu7KQIM3DwCWOuKjkDbBbVLYRuYRTgxKh.png", # noqa: E501
152+
"logo_colour": "#77cc33",
153+
},
154+
},
155+
"meta": {},
156+
"updated_at": "2023-07-22T23:55:21.000000Z",
157+
"created_at": "2023-07-22T23:48:15.000000Z",
158+
},
159+
"user": {
160+
"reference": "2992e5b4-acb7-49b4-848d-f5a7ca225413",
161+
"name": "Checkout",
162+
"identifier": "checkout",
163+
"identifier_type": "email",
164+
"email": "iyayiemmanuel1@gmail.com",
165+
"created_at": "2023-07-22T23:55:19.000000Z",
166+
"updated_at": "2023-07-22T23:55:19.000000Z",
167+
},
168+
"charge": 10000,
169+
"currency": "NGN",
170+
"mode": "credit",
171+
"reference": "c3f0a7b1ec0dbb3242eeaea7f380e96e",
172+
"remark": "checkout",
173+
"status": "success",
174+
"type": "peer",
175+
"meta": None,
176+
"peer": {
177+
"business": {
178+
"name": "Cash App",
179+
"logo": "https://palaciodepeer.s3.us-east-2.amazonaws.com/business_logos/UJimBqYOu7KQIM3DwCWOuKjkDbBbVLYRuYRTgxKh.png", # noqa: E501
180+
"logo_colour": "#77cc33",
181+
},
182+
"user": {
183+
"name": "Trojan Okoh",
184+
"identifier": "trojan",
185+
"identifier_type": "username",
186+
},
187+
},
188+
"updated_at": "2023-07-22T23:55:20.000000Z",
189+
"created_at": "2023-07-22T23:55:20.000000Z",
190+
}
191+
},
124192
)
125193

126194
def test_refund_transaction(self):
127195
self.assertEqual.__self__.maxDiff = None
128196
self.assertEqual(
129197
thepeer_test_suites.refund_transaction(
130-
"3bbb0fbf-82fa-48a0-80eb-d2c0338fe7dd", "possibly fraudulent"
198+
"d761e113-1e6d-456d-8341-79a963234511", "possibly fraudulent"
131199
),
132-
{"message": "this feature is only available on live mode"},
200+
{"message": "transactions can only be refunded on live mode"},
133201
)

0 commit comments

Comments
 (0)