Skip to content

Commit ad477de

Browse files
committed
Updated doc and setup file
1 parent a38f7d8 commit ad477de

File tree

130 files changed

+345
-621
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+345
-621
lines changed

GUIDE.md

Lines changed: 0 additions & 312 deletions
This file was deleted.

docs/GUIDE.md

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,31 +37,58 @@ For more information about testing, please see https://bitpay.com/docs/testing
3737

3838
## Installation
3939

40-
You can find and download this package from pip
41-
Make sure you have the latest version to avoid implementation and security issues.
40+
1. Download the package and extract it into a local directory or clone the repo.
41+
2. cd into the root directory where setup.py is located
42+
3. Enter: python setup.py install
43+
44+
4245

4346
### Handling your client private key
4447

45-
Each client paired with the BitPay server requires a ECDSA key. This key provides the security mechanism for all client interaction with the BitPay server. The public key is used to derive the specific client identity that is displayed on your BitPay dashboard. The public key is also used for securely signing all API requests from the client. See the [BitPay API](https://bitpay.com/api) for more information.
48+
Each client paired with the BitPay server requires a ECDSA key. This key provides the security mechanism for all client interaction with the BitPay server. The public key is used to derive the specific client identity that is displayed on your BitPay dashboard. The public key is also used for securely signing all API requests from the client. See the [BitPay API](https://bitpay.com/api/) for more information.
49+
50+
The private key should be stored in the client environment such that it cannot be compromised. If your private key is compromised you should revoke the compromised client identity from the BitPay server and re-pair your client, see the [API tokens](https://bitpay.com/api-tokens) for more information.
51+
52+
To generate the configuration file required to load the SDK:
4653

47-
The private key should be stored in the client environment such that it cannot be compromised. If your private key is compromised you should revoke the compromised client identity from the BitPay server and re-pair your client, see the [API tokens](https://bitpay.com/api-tokens) for more information.
54+
The [BitPay Config Generator](setup/bitpay_setup.py) helps to generate the private key, as well as a environment file formatted in JSON or YML which contains all configuration requirements, that should be stored in the client local file system. It is not recommended to transmit the private key over any public or unsecure networks.
4855

49-
The [BitPay.Net Setup utility](https://github.com/bitpay/csharp-bitpay-client/releases/download/v3.1.1912/BitPay.Net_Setup_utility_3.1.1912.zip) helps to generate the private key, as well as a environment file formatted in JSON which contains all configuration requirements, that should be stored in the client local file system. It is not recommended to transmit the private key over any public or unsecure networks.
56+
The comments in this script will assist you to create the environment file which you will be able to modify it later.
5057

51-
Follow the guide [BitPay.Net Setup utility guide](https://github.com/bitpay/csharp-bitpay-client/blob/master/BitPaySetup/README.md) that assist you to create the environment file which you will be able to modify it, either manually or by using the BitPay.Net Setup utility, later on by asking you to provide the path to your existing JSON file.
58+
Once the Config Generator has run and generated the Json/Yml correctly, read the console output and follow the instructions in order to pair your new tokens.
59+
60+
```json
61+
62+
{
63+
"BitPayConfiguration": {
64+
"Environment": "",
65+
"EnvConfig": {
66+
"Test": {
67+
"PrivateKeyPath": "",
68+
"PrivateKey": "",
69+
"ApiTokens": {
70+
"merchant": "",
71+
"payout": ""
72+
},
73+
"proxy": ""
74+
}
75+
}
76+
}
77+
}
78+
```
5279

5380
### Initializing your BitPay client
5481

5582
Once you have the environment file (JSON previously generated) you can initialize the client in two ways:
5683

5784
```python
58-
from bitpay_sdk.client import Client
85+
from bitpay.client import Client
5986

6087
bitpay = Client(config_file_path)
6188
```
6289

6390
```python
64-
from bitpay_sdk.client import Client
91+
from bitpay.client import Client
6592

6693
bitpay = Client(None, environment, private_key_path, tokens)
6794
```
@@ -70,8 +97,8 @@ bitpay = Client(None, environment, private_key_path, tokens)
7097

7198
Your client must be paired with the BitPay server. The pairing initializes authentication and authorization for your client to communicate with BitPay for your specific merchant account.
7299

73-
Pairing is accomplished by having the BitPay.Net Setup utility request a pairing code from the BitPay server.
74-
Meanwhile a new pairing code is generated, the BitPay.Net Setup utility will ask you to activate it in your BitPay account. It will also store the paired token in the environment file.
100+
Pairing is accomplished by running the bitpay [python Setup]((setup/bitpay_setup.py)) utility request a pairing code from the BitPay server.
101+
Meanwhile a new pairing code is generated, the python Setup utility will ask you to activate it in your BitPay account. It will also store the paired token in the environment file.
75102

76103
The pairing code is then entered into the BitPay merchant dashboard for the desired merchant. Your interactive authentication at https://bitpay.com/login provides the authentication needed to create finalize the client-server pairing request.
77104

docs/bill.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ Facade **`MERCHANT`**
130130
| X-Signature | header is the ECDSA signature of the full request URL concatenated with the request body, signed with your private key. This header is required when using tokens with higher privileges (merchant facade). When using standard pos facade token directly from the BitPay dashboard (with "Require Authentication" disabled), this header is not needed. | **Mandatory** |
131131

132132
```python
133-
get_bill = bitpay.get_bill(create_bill.get_id())
133+
get_bill = bitpay.get_bill(bill_id)
134134
```
135135

136136
### HTTP Response
@@ -445,6 +445,24 @@ Facade **`MERCHANT`**
445445
| token | The resource token for the billId you want to deliver via email. You need to retrieve this token from the bill object itself (see section Retrieve a bill). | `string` | **Mandatory** |
446446

447447
```python
448+
items = []
449+
450+
item = Item()
451+
item.set_price(30.0)
452+
item.set_quantity(9)
453+
item.set_description("product-a")
454+
items.append(item)
455+
456+
item = Item()
457+
item.set_price(14.0)
458+
item.set_quantity(16)
459+
item.set_description("product-b")
460+
items.append(item)
461+
462+
463+
bill = Bill("1001", Currency.USD, "[email protected]")
464+
bill.set_items(items)
465+
create_bill = bitpay.create_bill(bill)
448466
deliver_bill = bitpay.deliver_bill(create_bill.get_id(), create_bill.get_token())
449467
```
450468

docs/invoice.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,18 @@ An example code of the create invoice
4747
// Setting mandatory parameters in invoice i.e price and currency.
4848
Invoice invoice = new Invoice(100.0, "USD");
4949

50-
// Setting invoice optional parameters
51-
invoice.setOrderId("98e572ea-910e-415d-b6de-65f5090680f6");
52-
invoice.setFullNotifications(true);
53-
invoice.setExtendedNotifications(true);
54-
invoice.setTransactionSpeed("medium");
55-
invoice.setNotificationURL("https://hookbin.com/lJnJg9WW7MtG9GZlPVdj");
56-
invoice.setRedirectURL("https://hookbin.com/lJnJg9WW7MtG9GZlPVdj");
57-
invoice.setPosData("98e572ea35hj356xft8y8cgh56h5090680f6");
58-
invoice.setItemDesc("Ab tempora sed ut.");
59-
invoice.setNotificationEmail("");
60-
61-
// Creating Invoice
50+
# Setting invoice optional parameters
51+
invoice.setOrderId("98e572ea-910e-415d-b6de-65f5090680f6")
52+
invoice.setFullNotifications(True)
53+
invoice.setExtendedNotifications(True)
54+
invoice.setTransactionSpeed("medium")
55+
invoice.setNotificationURL("https://hookbin.com/lJnJg9WW7MtG9GZlPVdj")
56+
invoice.setRedirectURL("https://hookbin.com/lJnJg9WW7MtG9GZlPVdj")
57+
invoice.setPosData("98e572ea35hj356xft8y8cgh56h5090680f6")
58+
invoice.setItemDesc("Ab tempora sed ut.")
59+
invoice.setNotificationEmail("")
60+
61+
# Creating Invoice
6262
invoice = Invoice(2.16, "eur")
6363
invoice.set_order_id("98e572ea-910e-415d-b6de-65f5090680f6")
6464
invoice.set_full_notifications(True)
@@ -684,7 +684,7 @@ Facade **`POS` `MERCHANT`**
684684
To get the generated invoice details, pass the Invoice Id with URL parameter
685685

686686
```python
687-
retrieve_invoice = bitpay.get_invoice(basic_invoice.get_id())
687+
retrieve_invoice = bitpay.get_invoice(invoice_id)
688688
```
689689

690690
## Retrieve invoices filtered by query
@@ -717,7 +717,7 @@ Facade **`MERCHANT`**
717717
To get the generated invoices filtered by query parameters
718718

719719
```python
720-
get_invoices = bitpay.get_invoices('YYYY-MM-DD', 'YYYY-MM-DD', InvoiceStatus.Complete, null, 10); //Always use the included InvoiceStatus model to avoid typos
720+
get_invoices = bitpay.get_invoices('YYYY-MM-DD', 'YYYY-MM-DD', InvoiceStatus.Complete, None, 10); //Always use the included InvoiceStatus model to avoid typos
721721
```
722722

723723
## Update an invoice
@@ -756,6 +756,7 @@ Facades **`POS` `MERCHANT`**
756756
| X-Signature | header is the ECDSA signature of the full request URL concatenated with the request body, signed with your private key. This header is required when using tokens with higher privileges (merchant facade). When using standard pos facade token directly from the BitPay dashboard (with "Require Authentication" disabled), this header is not needed. | C |
757757

758758
```python
759+
retrieved_invoice = bitpay.get_invoice(invoice_id)
759760
updated_invoice = bitpay.update_invoice(retrieved_invoice.get_id(),
760761
761762
```
@@ -788,7 +789,7 @@ Facades **`POS` `MERCHANT`**
788789
| X-Signature | header is the ECDSA signature of the full request URL concatenated with the request body, signed with your private key. This header is required when using tokens with higher privileges (merchant facade). When using standard pos facade token directly from the BitPay dashboard (with "Require Authentication" disabled), this header is not needed. | **Mandatory** |
789790

790791
```python
791-
cancel_invoice = bitpay.cancel_invoice(updated_invoice.get_id())
792+
cancel_invoice = bitpay.cancel_invoice(invoice_id)
792793
```
793794
### HTTP Response
794795

@@ -799,7 +800,7 @@ cancel_invoice = bitpay.cancel_invoice(updated_invoice.get_id())
799800
## Request an invoice notification
800801

801802
```python
802-
invoice_status = bitpay.request_invoice_notifications(basic_invoice.get_id())
803+
invoice_status = bitpay.request_invoice_notifications(invoice_id)
803804
```
804805

805806
### Error Scenarios & Format:

docs/payout_batch.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ Facades **`PAYOUT`**
189189
An example code to fetch single payout by `payoutId`
190190

191191
```python
192-
batch1 = bitpay.get_payout_batch(submit_batch.get_id())
192+
batch1 = bitpay.get_payout_batch(payout_batch_id)
193193
```
194194

195195
### HTTP Response
@@ -417,7 +417,7 @@ Headers
417417
An example code to cancel payout batch
418418

419419
```python
420-
cancel_batch = bitpay.cancel_payout_batch(batch1.get_id())
420+
cancel_batch = bitpay.cancel_payout_batch(payout_batch_id)
421421
```
422422

423423
**Response Body Fields**
@@ -472,7 +472,7 @@ Facades **`PAYOUT`**
472472
An example code to request payout batch notification
473473

474474
```python
475-
notify_batch = bitpay.request_payout_batch_notification(batch.get_id())
475+
notify_batch = bitpay.request_payout_batch_notification(payout_batch_id)
476476
```
477477

478478
**Response Body Fields**

docs/payout_recipients.md

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,27 @@ Facades **`PAYOUT`**
152152
An example code to fetch single payout recipient by `recipientId`
153153

154154
```python
155+
recipients_list = []
156+
157+
payout_recipient = PayoutRecipient()
158+
payout_recipient.set_email("[email protected]")
159+
payout_recipient.set_label("recipient1")
160+
payout_recipient.set_notification_url("https://hookb.in/QJOPBdMgRkukpp2WO60o")
161+
recipients_list.append(payout_recipient)
162+
163+
payout_recipient = PayoutRecipient()
164+
payout_recipient.set_email("[email protected]")
165+
payout_recipient.set_label("recipient2")
166+
payout_recipient.set_notification_url("https://hookb.in/QJOPBdMgRkukpp2WO60o")
167+
recipients_list.append(payout_recipient)
168+
169+
payout_recipient = PayoutRecipient()
170+
payout_recipient.set_email("[email protected]")
171+
payout_recipient.set_label("recipient3")
172+
payout_recipient.set_notification_url("https://hookb.in/QJOPBdMgRkukpp2WO60o")
173+
recipients_list.append(payout_recipient)
174+
175+
recipients_obj = PayoutRecipients(recipients_list)
155176
recipients = bitpay.submit_payout_recipients(recipients_obj)
156177
first_recipient = recipients[0]
157178
retrieved_recipient = bitpay.get_payout_recipient(first_recipient.get_id())
@@ -280,6 +301,27 @@ Facades **`PAYOUT`**
280301
An example to update the existing payout recipient details
281302

282303
```python
304+
recipients_list = []
305+
306+
payout_recipient = PayoutRecipient()
307+
payout_recipient.set_email("[email protected]")
308+
payout_recipient.set_label("recipient1")
309+
payout_recipient.set_notification_url("https://hookb.in/QJOPBdMgRkukpp2WO60o")
310+
recipients_list.append(payout_recipient)
311+
312+
payout_recipient = PayoutRecipient()
313+
payout_recipient.set_email("[email protected]")
314+
payout_recipient.set_label("recipient2")
315+
payout_recipient.set_notification_url("https://hookb.in/QJOPBdMgRkukpp2WO60o")
316+
recipients_list.append(payout_recipient)
317+
318+
payout_recipient = PayoutRecipient()
319+
payout_recipient.set_email("[email protected]")
320+
payout_recipient.set_label("recipient3")
321+
payout_recipient.set_notification_url("https://hookb.in/QJOPBdMgRkukpp2WO60o")
322+
recipients_list.append(payout_recipient)
323+
324+
recipients_obj = PayoutRecipients(recipients_list)
283325
recipients = bitpay.submit_payout_recipients(recipients_obj)
284326
first_recipient = recipients[0]
285327
retrieved_recipient = bitpay.get_payout_recipient(first_recipient.get_id())
@@ -346,7 +388,7 @@ Facades **`PAYOUT`**
346388
An example code to delete payout recipient
347389

348390
```python
349-
delete_recipient = bitpay.delete_payout_recipient(retrieved_recipient.get_id())
391+
delete_recipient = bitpay.delete_payout_recipient(recipient_id)
350392
```
351393

352394
**HTTP Response**
@@ -390,6 +432,27 @@ Facades **`PAYOUT`**
390432
An example code to request payout recipient notification
391433

392434
```python
435+
recipients_list = []
436+
437+
payout_recipient = PayoutRecipient()
438+
payout_recipient.set_email("[email protected]")
439+
payout_recipient.set_label("recipient1")
440+
payout_recipient.set_notification_url("https://hookb.in/QJOPBdMgRkukpp2WO60o")
441+
recipients_list.append(payout_recipient)
442+
443+
payout_recipient = PayoutRecipient()
444+
payout_recipient.set_email("[email protected]")
445+
payout_recipient.set_label("recipient2")
446+
payout_recipient.set_notification_url("https://hookb.in/QJOPBdMgRkukpp2WO60o")
447+
recipients_list.append(payout_recipient)
448+
449+
payout_recipient = PayoutRecipient()
450+
payout_recipient.set_email("[email protected]")
451+
payout_recipient.set_label("recipient3")
452+
payout_recipient.set_notification_url("https://hookb.in/QJOPBdMgRkukpp2WO60o")
453+
recipients_list.append(payout_recipient)
454+
455+
recipients_obj = PayoutRecipients(recipients_list)
393456
recipients = bitpay.submit_payout_recipients(recipients_obj)
394457
first_recipient = recipients[0]
395458
retrieved_recipient = bitpay.get_payout_recipient(first_recipient.get_id())

docs/payouts.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ Facades **`PAYOUT`**
191191
An example code to fetch single payout by `payoutId`
192192

193193
```python
194-
retrieved_payout = bitpay.get_payout(submit_payout.get_id())
194+
retrieved_payout = bitpay.get_payout(payout_id)
195195
```
196196

197197
### HTTP Response
@@ -371,7 +371,7 @@ Facades **`PAYOUT`**
371371
An example code to cancel payout
372372

373373
```python
374-
cancelled_payout = bitpay.cancel_payout(create_payout.get_id())
374+
cancelled_payout = bitpay.cancel_payout(payout_id)
375375
```
376376

377377
**Response Body Fields**
@@ -426,7 +426,7 @@ Facades **`PAYOUT`**
426426
An example code to request payout recipient notification
427427

428428
```python
429-
result = bitpay.request_payout_notification(create_payout.get_id())
429+
result = bitpay.request_payout_notification(payout_id)
430430
```
431431

432432
**Response Body Fields**

docs/refund.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Facades **`MERCHANT`**
3131
An example code of the create a new refund request
3232

3333
```python
34-
create_refund = bitpay.create_refund(invoice.get_id(), 1.0, None, True, False, False)
34+
create_refund = bitpay.create_refund(invoice_id, 1.0, None, True, False, False)
3535
```
3636

3737
**Response Body Fields**
@@ -102,7 +102,7 @@ Facades **`MERCHANT`**
102102

103103

104104
```python
105-
retieve_refund = bitpay.get_refund(create_refund.get_id())
105+
retieve_refund = bitpay.get_refund(refund_id)
106106
```
107107

108108
**Response Body Fields**
@@ -164,7 +164,7 @@ Facades **`MERCHANT`**
164164
To get all refund requesta for an invoice, pass the Invoice Id with URL parameter
165165

166166
```python
167-
retrieved_refunds = bitpay.get_refunds(invoice.get_id())
167+
retrieved_refunds = bitpay.get_refunds(invoice_id)
168168
```
169169

170170
Response body fields same as `POST /refunds`
@@ -232,7 +232,7 @@ Facades **`MERCHANT`**
232232
| status | set to ‘created’ in order to confirm the refund request and initiate the flow to send it to shopper | `string` | - |
233233

234234
```python
235-
update_refund = bitpay.update_refund(invoice.get_id(), RefundStatus.Created);
235+
update_refund = bitpay.update_refund(refund_id, RefundStatus.Created);
236236
```
237237

238238

@@ -263,7 +263,7 @@ cancel_refund = bitpay.cancel_refund(create_refund.get_id())
263263
Facades **`MERCHANT`**
264264

265265
```python
266-
result = bitpay.request_refund_notification(create_refund.get_id())
266+
result = bitpay.request_refund_notification(refund_id)
267267
```
268268

269269
### HTTP Response

0 commit comments

Comments
 (0)