You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+77-21Lines changed: 77 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,29 +1,82 @@
1
1
java-bitpay-client
2
2
==================
3
3
4
-
This is the Java client library for the BitPay Payment Gateway. This library implements BitPay's new cryptographically-secure API.
4
+
This is the Java client library for the BitPay Payment Gateway. This library implements BitPay's [Cryptographically Secure RESTful API](https://bitpay.com/api).
5
5
6
6
Dependencies
7
7
------------
8
-
BitPay merchant account
8
+
You must have a BitPay merchant account to use this SDK. It's free to [sign-up for a BitPay merchant account](https://bitpay.com/start).
9
9
10
-
ApacheHttpClient
10
+
Getting Started
11
+
---------------
11
12
12
-
java-json
13
+
This SDK provides a convenient abstration of BitPay's [cryptographically-secure API](https://bitpay.com/api) and allows payment gateway developers to focus on payment flow/e-commerce integration rather than on the specific details of client-server interaction using the API. This SDK optionally provides the flexibility for developers to have control over important details, including the handling of private keys needed for client-server communication.
13
14
14
-
json-simple
15
+
This SDK implements BitPay's remote client authentication and authorization strategy. No private or shared-secret information is ever transmitted over the wire.
15
16
16
-
Getting Started
17
-
---------------
17
+
####Handling your client private key
18
+
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.
19
+
20
+
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.
18
21
19
-
Log into your BitPay merchant account and generate a Private Key. Then all you need to do is instantiate a BitPay object, and pass in your private key.
22
+
This Java SDK provides the capability of internally storing the private key on the client local file system. If the local file system is secure then this is a good option. It is also possible to generate the key yourself (using the SDK) and store the key as required. It is not recommended to transmit the private key over any public or unsecure networks.
Your Java 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. There are two pairing modes available; client initiated and server initiated.
44
+
45
+
#####Client initiated pairing
46
+
Pairing is accomplished by having your Java client request a pairing code from the BitPay server. 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.
47
+
48
+
```java
49
+
String clientName ="server 1";
50
+
BitPay bitpay =newBitPay(clientName);
51
+
52
+
if (!bitpay.clientIsAuthorized(BitPay.FACADE_POS))
// Signal the device operator that this client needs to be paired with a merchant account.
58
+
System.out.print("Info: Pair this client with your merchant account using the pairing code: "+ pairingCode);
59
+
thrownewBitPayException("Error: client is not authorized for POS facade.");
60
+
}
61
+
```
62
+
63
+
#####Server initiated pairing
64
+
Pairing is accomplished by obtaining a pairing code from the BitPay server. The pairing code is then injected into your client (typically during client initialization/configuration). Your interactive authentication at https://bitpay.com/login provides the authentication needed to create finalize the client-server pairing request.
65
+
66
+
```java
67
+
// Obtain a pairingCode from your BitPay account administrator.
68
+
String pairingCode ="xxxxxxx";
69
+
String clientName ="server 1";
70
+
BitPay bitpay =newBitPay(clientName);
71
+
72
+
// Is this client already authorized to use the POS facade?
73
+
if (!bitpay.clientIsAuthorized(BitPay.FACADE_POS))
You can retrieve BitPay's [BBB exchange rates](https://bitpay.com/bitcoin-exchange-rates).
43
96
```java
44
97
Rates rates =this.bitpay.getRates();
45
98
@@ -49,16 +102,19 @@ rates.update();
49
102
```
50
103
####Advanced Invoices
51
104
52
-
You can add additional params to the invoice by passing an InvoiceParams object. You don't have to set all of the advanced parameters. It will only use the ones you do set.
105
+
You can add optional attributes to the invoice. Atributes that are not set are ignored or given default values.
0 commit comments