|
1 | | -# thepeer python sdk |
2 | | -A soon to be API wrapper (or SDK) as you may call it for thepeer |
| 1 | +# thepeer python-sdk |
| 2 | + |
| 3 | +> Thepeer's official python sdk for developers to use in their project. |
| 4 | +
|
| 5 | +- To begin, create an account at https://thepeer.co/ if you haven't already. |
| 6 | +- You can also retrieve your API keys from your [dashboard](https://dashboard.thepeer.co/) |
| 7 | + |
| 8 | +## Installation |
| 9 | +To install, run: |
| 10 | +```bash |
| 11 | +pip install pythepeer |
| 12 | +``` |
| 13 | + |
| 14 | +## Usage |
| 15 | +Instantiate the ThePeerInit class like so: |
| 16 | +```python |
| 17 | +from thepeer.main import ThePeerInit |
| 18 | + |
| 19 | +# create an instance of ThePeerInit class |
| 20 | + |
| 21 | +thepeer_instance = ThePeerInit("YOUR_API_KEY_HERE") |
| 22 | + |
| 23 | +``` |
| 24 | + |
| 25 | +## Available Methods Exposed By the Library |
| 26 | + |
| 27 | +**Note:** |
| 28 | + - For More info, please refer to the general [documentation](https://docs.thepeer.co/) |
| 29 | +#### ```Indexing A User``` |
| 30 | +This describes how to index a user on your account (this is usually the first step before using other methods) |
| 31 | + |
| 32 | +```python |
| 33 | +test = thepeer.index_user("Osagie Iyayi", "iyayiemmanuel1@gmail.com", "iyayiemmanuel1@gmail.com") |
| 34 | +``` |
| 35 | + |
| 36 | +#### Parameters supported |
| 37 | + |
| 38 | +| Parameters | Data Type | Required | Description | |
| 39 | +|----------------------|---------------------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
| 40 | +| name | string | true | The name of user to be indexed. |
| 41 | +| identifier | string | true | the identifier of the account(either email or username). |
| 42 | +| email | string | true | the email of the user | |
| 43 | + |
| 44 | +#### ```Validating a HMAC signature``` |
| 45 | +This method validates incoming an [hmac](https://www.okta.com/identity-101/hmac/) signature with the payload and credentials that was passed with it |
| 46 | + |
| 47 | +**Pro Tip:** it is used to verify that an incoming webhook event/response is coming from thepeer's servers |
| 48 | + |
| 49 | +```python |
| 50 | +test = thepeer.validate_signature(data,signature) |
| 51 | +``` |
| 52 | +#### Parameters supported |
| 53 | + |
| 54 | +| Parameters | Data Type | Required | Description | |
| 55 | +|----------------------|---------------------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
| 56 | +| data | dictionary | true | the payload containing the data to be authenticated |
| 57 | +| signature | string | true | The HMAC signature | |
| 58 | + |
| 59 | +#### ```Get an Indexed User``` |
| 60 | +This method gets the information of an indexed user |
| 61 | + |
| 62 | +```python |
| 63 | +test = thepeer.view_user("3bbb0fbf-82fa-48a0-80eb-d2c0338fe7dd") |
| 64 | +``` |
| 65 | + |
| 66 | +#### Parameters supported |
| 67 | + |
| 68 | + |
| 69 | +| Parameters | Data Type | Required | Description | |
| 70 | +|----------------------|---------------------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
| 71 | +| reference | string | true | the unique reference returned when the user was indexed |
| 72 | + |
| 73 | +#### ```Get All Indexed Users``` |
| 74 | +This method returns all indexed users for a specific account |
| 75 | + |
| 76 | +```python |
| 77 | +test = thepeer.all_users(1,15) |
| 78 | +``` |
| 79 | + |
| 80 | +#### Parameters supported |
| 81 | + |
| 82 | +| Parameters | Data Type | Required | Description | |
| 83 | +|----------------------|---------------------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
| 84 | +| page | integer | false | the first page displaying all the indexed users. defaults to 1 |
| 85 | +| per_page | integer | false | The number of users to display per page. defaults to 15 | |
| 86 | + |
| 87 | + |
| 88 | +#### ```Update an Indexed User``` |
| 89 | +This methods helps to update the details of an indexed user |
| 90 | + |
| 91 | +```python |
| 92 | +test = thepeer.update_user(reference,**data) |
| 93 | +``` |
| 94 | +#### Parameters supported |
| 95 | + |
| 96 | +| Parameters | Data Type | Required | Description | |
| 97 | +|----------------------|---------------------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
| 98 | +| reference | string | true | the unique reference returned when the user was indexed |
| 99 | +| data | Any | true | A keyword argument which contains on or more of the indexed user's email, name or identifier | |
| 100 | + |
| 101 | +### Sample |
| 102 | +```python |
| 103 | +test = thepeer.update_user("3bbb0fbf-82fa-48a0-80eb-d2c0338fe7dd", identifier="iyayiemmanuel1@gmail.com", |
| 104 | + name="Osagie Iyayi", |
| 105 | + email="iyayiemmanuel1@gmail.com") |
| 106 | +``` |
| 107 | +#### ```Remove an Indexed User``` |
| 108 | +This methods helps to remove the details of an indexed user from a specific account |
| 109 | + |
| 110 | +```python |
| 111 | +test = thepeer.delete_user("3bbb0fbf-82fa-48a0-80eb-d2c0338fe7dd") |
| 112 | +``` |
| 113 | + |
| 114 | +#### Parameters supported |
| 115 | + |
| 116 | +| Parameters | Data Type | Required | Description | |
| 117 | +|----------------------|---------------------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
| 118 | +| reference | string | true | the unique reference returned when the user was indexed |
| 119 | + |
| 120 | +#### ```Get User Links``` |
| 121 | + |
| 122 | +This method gets all payment links associated to an indexed user |
| 123 | +```python |
| 124 | +test = thepeer.get_user_links("3bbb0fbf-82fa-48a0-80eb-d2c0338fe7dd") |
| 125 | +``` |
| 126 | +#### Parameters Required |
| 127 | + |
| 128 | +| Parameters | Data Type | Required | Description | |
| 129 | +|----------------------|---------------------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
| 130 | +| reference | string | true | the unique reference returned when the user was indexed |
| 131 | + |
| 132 | + |
| 133 | +### ```Get Single Link``` |
| 134 | + |
| 135 | +This method gets the payment information located in a payment link |
| 136 | + |
| 137 | +```python |
| 138 | +test = thepeer.get_single_link("da14a90c-61c2-4cf7-a837-e3112a2d0c3d") |
| 139 | +``` |
| 140 | + |
| 141 | +#### Parameters Required |
| 142 | + |
| 143 | +| Parameters | Data Type | Required | Description | |
| 144 | +|----------------------|---------------------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
| 145 | +| link_id | string | true | the unique link_id containing the payment information |
| 146 | + |
| 147 | + |
| 148 | +### ``` Charge A Link``` |
| 149 | +This method allows a business to charge a user via their linked account |
| 150 | +```python |
| 151 | +test = thepeer.charge_link(link_id, amount, remark, currency) |
| 152 | +``` |
| 153 | + |
| 154 | +#### Parameters Required |
| 155 | + |
| 156 | +| Parameters | Data Type | Required | Description | |
| 157 | +|----------------------|---------------------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
| 158 | +| link_id | string | true | the unique link_id containing the payment information |
| 159 | +| amount | integer | true | the amount of the whole transaction |
| 160 | +| remark | string | true | short detail about the transaction | |
| 161 | +| currency | string | false | The denomination medium of paying (either one of NGN and USD). defaults to NGN |
| 162 | + |
| 163 | +### ```Authorize Direct Charge``` |
| 164 | +This method allows a business to authorize a direct charge request made by a user |
| 165 | + |
| 166 | +```python |
| 167 | +test = thepeer.authorize_direct_charge(auth_charge_reference, event) |
| 168 | +``` |
| 169 | +#### Parameters Required |
| 170 | + |
| 171 | +| Parameters | Data Type | Required | Description | |
| 172 | +|----------------------|---------------------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
| 173 | +| auth_charge_reference | string | true | the reference associated to a pending charge request |
| 174 | +| event | string | true | the type of webhook event | |
| 175 | + |
| 176 | +**Pro Tip:** the various types of webhook events are available [here](https://docs.thepeer.co/authorization/process-authorization-requests#supported-events) |
| 177 | + |
| 178 | + |
| 179 | +### ```Get Transaction Detail``` |
| 180 | +This method gets the details of a transaction |
| 181 | +```python |
| 182 | +test = thepeer.get_transaction_detail("eda58ee3-4f2c-4aa4-9da7-10a2b8ced453") |
| 183 | +``` |
| 184 | + |
| 185 | +#### Parameters Required |
| 186 | + |
| 187 | +| Parameters | Data Type | Required | Description | |
| 188 | +|----------------------|---------------------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
| 189 | +| transaction_id | string | true | the unique transaction identifier |
| 190 | + |
| 191 | +### ```Refund Transaction``` |
| 192 | +This method allows a business to refund a transaction back to the user for obvious reasons |
| 193 | +```python |
| 194 | +test = thepeer.refund_transaction("28e52edf-16d9-4921-8a54-ef34d7029707", "possible threat actor"): |
| 195 | +``` |
| 196 | + |
| 197 | +#### Parameters Required |
| 198 | +| Parameters | Data Type | Required | Description | |
| 199 | +|----------------------|---------------------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
| 200 | +| transaction_id | string | true | the unique transaction identifier |
| 201 | +| reason | string | false | a short sentence explaining reasons for the refund | |
| 202 | + |
| 203 | + |
| 204 | + |
| 205 | + ## License |
| 206 | +This project is MIT Licensed (MIT). Please see the [License File](LICENSE) for more information. |
0 commit comments