Skip to content

Commit 6ef1ef3

Browse files
authored
Merge pull request #96 from ppatidar2021/fixed_payInvoice
Fixed pay invoice
2 parents 3abac5d + 8d1052e commit 6ef1ef3

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/main/java/com/bitpay/sdk/Client.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -468,15 +468,12 @@ public Invoice updateInvoice(String invoiceId, String buyerSms, String smsCode,
468468
* @throws BitPayException BitPayException class
469469
* @throws InvoiceUpdateException InvoiceUpdateException class
470470
*/
471-
public Invoice payInvoice(String invoiceId, Boolean complete) throws BitPayException, InvoiceUpdateException {
471+
public Invoice payInvoice(String invoiceId, String status) throws BitPayException, InvoiceUpdateException {
472472
final Map<String, Object> params = new HashMap<>();
473473
params.put("token", this.getAccessToken(Facade.Merchant));
474-
if (complete == null) {
475-
throw new InvoiceUpdateException(null, "It is required to define the whether the invoice will be set to \"complete\" or \"confirmed\".");
474+
if (status != null) {
475+
params.put("status", status);
476476
}
477-
478-
params.put("complete", complete);
479-
480477
ObjectMapper mapper = new ObjectMapper();
481478
String json;
482479
Invoice invoice;

src/test/java/test/BitPayTestMerchant.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,14 +311,14 @@ public void testShouldCreateAndPayInvoice() {
311311
Invoice invoice = new Invoice(1.0, "USD");
312312
try {
313313
basicInvoice = bitpay.createInvoice(invoice);
314-
paidInvoice = bitpay.payInvoice(basicInvoice.getId(), true);
314+
paidInvoice = bitpay.payInvoice(basicInvoice.getId(), "confirmed");
315315
} catch (Exception e) {
316316
e.printStackTrace();
317317
fail(e.getMessage());
318318
}
319319
assertNotNull(basicInvoice.getId());
320320
assertNotNull(paidInvoice.getId());
321-
assertEquals(paidInvoice.getStatus(), InvoiceStatus.Complete);
321+
assertEquals(paidInvoice.getStatus(), InvoiceStatus.Confirmed);
322322
}
323323

324324
@Test

0 commit comments

Comments
 (0)