Skip to content

Commit ade6bb2

Browse files
author
paul
committed
handle multiple tokens in token request
1 parent 8a5b6e0 commit ade6bb2

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
locals/
2+
*.key
3+
java-bitpay-client.xml
4+
java-bitpay-client.properties
5+
untitled folder/
6+
.idea/

src/controller/BitPay.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public class BitPay {
6060
* Constructor for use if the keys and SIN are managed by this library.
6161
* @param clientName - The label for this client.
6262
* @param envUrl - The target server URL.
63-
* @throws BitPayException
63+
* @throws BitPayException
6464
*/
6565
public BitPay(String clientName, String envUrl) throws BitPayException
6666
{
@@ -383,7 +383,7 @@ private Hashtable<String, String> responseToTokenCache(HttpResponse response) th
383383
// we can map to a hashtable.
384384
json = json.replaceAll("\\[", "");
385385
json = json.replaceAll("\\]", "");
386-
386+
json = json.replaceAll("\\},\\{", ",");
387387
if (json.length() > 0) {
388388
_tokenCache = new ObjectMapper().readValue(json, new TypeReference<Hashtable<String,String>>(){});
389389
}
@@ -497,7 +497,7 @@ private HttpResponse get(String uri) throws BitPayException
497497
return this.get(uri, null);
498498
}
499499

500-
private HttpResponse post(String uri, String json, boolean signatureRequired) throws BitPayException
500+
private HttpResponse post(String uri, String json, boolean signatureRequired) throws BitPayException
501501
{
502502
try {
503503
HttpPost post = new HttpPost(_baseUrl + uri);
@@ -526,17 +526,17 @@ private HttpResponse post(String uri, String json, boolean signatureRequired) th
526526
}
527527
}
528528

529-
private HttpResponse post(String uri, String json) throws BitPayException
529+
private HttpResponse post(String uri, String json) throws BitPayException
530530
{
531531
return this.post(uri, json, false);
532532
}
533533

534-
private HttpResponse postWithSignature(String uri, String json) throws BitPayException
534+
private HttpResponse postWithSignature(String uri, String json) throws BitPayException
535535
{
536536
return this.post(uri, json, true);
537537
}
538538

539-
private String responseToJsonString(HttpResponse response) throws BitPayException
539+
private String responseToJsonString(HttpResponse response) throws BitPayException
540540
{
541541
if (response == null) {
542542
throw new BitPayException("Error: HTTP response is null");

src/test/BitPayTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
import static org.junit.Assert.*;
44

5+
import java.security.interfaces.ECKey;
56
import java.util.List;
67

8+
import controller.KeyUtils;
79
import model.Invoice;
810
import model.InvoiceBuyer;
911
import model.Rate;
@@ -31,8 +33,9 @@ public void setUp() throws Exception
3133
{
3234
// This scenario qualifies that this (test) client does not have merchant facade access.
3335
clientName += " on " + java.net.InetAddress.getLocalHost();
34-
bitpay = new BitPay(clientName);
35-
36+
com.google.bitcoin.core.ECKey key = KeyUtils.createEcKeyFromHexStringFile("locals/key");
37+
String testUrl = "https://staging.b-pay.net/";
38+
bitpay = new BitPay(key, clientName, testUrl );
3639
if (!bitpay.clientIsAuthorized(BitPay.FACADE_POS))
3740
{
3841
// Get POS facade authorization.

0 commit comments

Comments
 (0)