-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #264 from mwarzybok-sumoheavy/feature/SP-752
Feature/sp 752
- Loading branch information
Showing
81 changed files
with
2,470 additions
and
640 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.bitpay.sdk.t; | ||
|
||
import com.bitpay.sdk.Client; | ||
import com.bitpay.sdk.ConfigFilePath; | ||
import com.bitpay.sdk.PosToken; | ||
import com.bitpay.sdk.exceptions.BitPayGenericException; | ||
|
||
public class ClientProvider { | ||
|
||
public static Client create() { | ||
try { | ||
return Client.createClientByConfigFilePath(new ConfigFilePath("some/config/path")); // use BitPaySetup | ||
} catch (BitPayGenericException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
public static Client createPos() { | ||
try { | ||
return new Client(new PosToken("someToken")); | ||
} catch (BitPayGenericException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.bitpay.sdk.examples.General; | ||
|
||
import com.bitpay.sdk.Client; | ||
import com.bitpay.sdk.exceptions.BitPayApiException; | ||
import com.bitpay.sdk.exceptions.BitPayGenericException; | ||
import com.bitpay.sdk.logger.BitPayLogger; | ||
import com.bitpay.sdk.logger.LoggerProvider; | ||
import com.bitpay.sdk.model.invoice.Invoice; | ||
import com.bitpay.sdk.examples.ClientProvider; | ||
|
||
final public class UseLogger { | ||
|
||
public void execute() throws BitPayGenericException, BitPayApiException { | ||
LoggerProvider.setLogger(new BitPayLogger() { | ||
@Override | ||
public void logRequest(String method, String endpoint, String json) { | ||
// some logic | ||
} | ||
|
||
@Override | ||
public void logResponse(String method, String endpoint, String json) { | ||
// some logic | ||
} | ||
|
||
@Override | ||
public void logError(String message) { | ||
// some logic | ||
} | ||
}); | ||
|
||
Client client = ClientProvider.create(); | ||
|
||
Invoice invoice = client.getInvoice("someInvoiceId"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.bitpay.sdk.examples.Merchant; | ||
|
||
import com.bitpay.sdk.Client; | ||
import com.bitpay.sdk.exceptions.BitPayApiException; | ||
import com.bitpay.sdk.exceptions.BitPayGenericException; | ||
import com.bitpay.sdk.model.bill.Bill; | ||
import com.bitpay.sdk.model.bill.Item; | ||
import com.bitpay.sdk.examples.ClientProvider; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class BillRequests { | ||
|
||
public void createBill() throws BitPayGenericException, BitPayApiException { | ||
Client client = ClientProvider.create(); | ||
|
||
Bill bill = new Bill(); | ||
bill.setCurrency("USD"); | ||
bill.setEmail("[email protected]"); | ||
bill.setAddress1("SomeAddress"); | ||
bill.setCity("MyCity"); | ||
// ... | ||
|
||
Bill result = client.createBill(bill); | ||
} | ||
|
||
public void getBill() throws BitPayGenericException, BitPayApiException { | ||
Client client = ClientProvider.create(); | ||
|
||
Bill bill = client.getBill("someBillid"); | ||
|
||
List<Bill> bills = client.getBills("draft"); | ||
} | ||
|
||
public void updateBill() throws BitPayGenericException, BitPayApiException { | ||
Client client = ClientProvider.create(); | ||
|
||
Item item = new Item(); | ||
item.setPrice(12.34); | ||
item.setQuantity(2); | ||
item.setDescription("someDescription"); | ||
|
||
List<Item> items = new ArrayList<>(); | ||
items.add(item); | ||
|
||
Bill bill = new Bill(); | ||
bill.setItems(items); | ||
|
||
client.updateBill(bill, "someBillId"); | ||
} | ||
|
||
public void deliverBillViaEmail() throws BitPayGenericException, BitPayApiException { | ||
Client client = ClientProvider.create(); | ||
|
||
client.deliverBill("someBillId", "myBillToken"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package com.bitpay.sdk.examples.Merchant; | ||
|
||
import com.bitpay.sdk.Client; | ||
import com.bitpay.sdk.exceptions.BitPayApiException; | ||
import com.bitpay.sdk.exceptions.BitPayGenericException; | ||
import com.bitpay.sdk.model.invoice.Buyer; | ||
import com.bitpay.sdk.model.invoice.Invoice; | ||
import com.bitpay.sdk.examples.ClientProvider; | ||
import java.util.List; | ||
|
||
public class InvoiceRequests { | ||
|
||
public void createInvoice() throws BitPayGenericException, BitPayApiException { | ||
Client client = ClientProvider.create(); | ||
|
||
Invoice invoice = new Invoice(); | ||
invoice.setFullNotifications(true); | ||
invoice.setExtendedNotifications(true); | ||
invoice.setNotificationUrl("https://test/lJnJg9WW7MtG9GZlPVdj"); | ||
invoice.setRedirectUrl("https://test/lJnJg9WW7MtG9GZlPVdj"); | ||
invoice.setNotificationEmail("[email protected]"); | ||
invoice.setBuyerSms("+12223334445"); | ||
|
||
Buyer buyer = new Buyer(); | ||
buyer.setName("Test"); | ||
buyer.setEmail("[email protected]"); | ||
buyer.setAddress1("168 General Grove"); | ||
buyer.setCountry("AD"); | ||
buyer.setLocality("Port Horizon"); | ||
buyer.setNotify(true); | ||
buyer.setPhone("+990123456789"); | ||
buyer.setPostalCode("KY7 1TH"); | ||
buyer.setRegion("New Port"); | ||
|
||
invoice.setBuyer(buyer); | ||
|
||
Invoice result = client.createInvoice(invoice); | ||
} | ||
|
||
public void getInvoice() throws BitPayGenericException, BitPayApiException { | ||
Client client = ClientProvider.create(); | ||
|
||
Invoice invoiceById = client.getInvoice("myInvoiceId"); | ||
|
||
Invoice invoiceByGuid = client.getInvoiceByGuid("someGuid"); // we can add a GUID during the invoice creation | ||
|
||
List<Invoice> invoices = client.getInvoices("2023-04-14", "2023-04-17", null, null, null, null); | ||
} | ||
|
||
public void updateInvoice() throws BitPayGenericException, BitPayApiException { | ||
Client client = ClientProvider.create(); | ||
|
||
Invoice invoice = client.updateInvoice("someInvoiceId", "12312321321", null, null, null); | ||
} | ||
|
||
public void cancelInvoice() throws BitPayGenericException, BitPayApiException { | ||
Client client = ClientProvider.create(); | ||
|
||
client.cancelInvoice("invoiceId"); | ||
|
||
client.cancelInvoiceByGuid("invoiceGuid"); | ||
} | ||
|
||
public void requestInvoiceWebhookToBeResent() throws BitPayGenericException, BitPayApiException { | ||
Client client = ClientProvider.create(); | ||
|
||
client.requestInvoiceWebhookToBeResent("someInvoiceId"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.bitpay.sdk.examples.Merchant; | ||
|
||
import com.bitpay.sdk.Client; | ||
import com.bitpay.sdk.exceptions.BitPayApiException; | ||
import com.bitpay.sdk.exceptions.BitPayGenericException; | ||
import com.bitpay.sdk.model.ledger.Ledger; | ||
import com.bitpay.sdk.model.ledger.LedgerEntry; | ||
import com.bitpay.sdk.examples.ClientProvider; | ||
import java.util.List; | ||
|
||
public class LedgerRequests { | ||
|
||
public void getLedgers() throws BitPayGenericException, BitPayApiException { | ||
Client client = ClientProvider.create(); | ||
|
||
List<Ledger> ledgers = client.getLedgers(); | ||
} | ||
|
||
public void getLedgerEntries() throws BitPayGenericException, BitPayApiException { | ||
Client client = ClientProvider.create(); | ||
|
||
List<LedgerEntry> ledgerEntries = client.getLedgerEntries("USD", "2023-08-14", "2023-08-22"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.bitpay.sdk.examples.Merchant; | ||
|
||
import com.bitpay.sdk.Client; | ||
import com.bitpay.sdk.exceptions.BitPayApiException; | ||
import com.bitpay.sdk.exceptions.BitPayGenericException; | ||
import com.bitpay.sdk.model.invoice.Refund; | ||
import com.bitpay.sdk.examples.ClientProvider; | ||
|
||
public class RefundRequests { | ||
|
||
public void createRefund() throws BitPayGenericException, BitPayApiException { | ||
Client client = ClientProvider.create(); | ||
|
||
Refund refund = client.createRefund("myInvoiceId", 12.34, true, true, true, "no"); | ||
} | ||
|
||
public void updateRefund() throws BitPayGenericException, BitPayApiException { | ||
Client client = ClientProvider.create(); | ||
|
||
Refund updateRefund = client.updateRefund("refundId", "created"); | ||
|
||
Refund updateRefundByGuid = client.updateRefundByGuid("someGuid", "created"); | ||
} | ||
|
||
public void getRefund() throws BitPayGenericException, BitPayApiException { | ||
Client client = ClientProvider.create(); | ||
|
||
Refund refund = client.getRefund("someRefundId"); | ||
|
||
Refund refundByGuid = client.getRefundByGuid("someGuid"); | ||
} | ||
|
||
public void cancelRefund() throws BitPayGenericException, BitPayApiException { | ||
Client client = ClientProvider.create(); | ||
|
||
Refund cancelRefund = client.cancelRefund("someRefundId"); | ||
|
||
Refund cancelRefundByGuid = client.cancelRefundByGuid("someGuid"); | ||
} | ||
|
||
public void requestRefundNotificationToBeResent() throws BitPayGenericException, BitPayApiException { | ||
Client client = ClientProvider.create(); | ||
|
||
Boolean result = client.sendRefundNotification("someRefundId"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.bitpay.sdk.examples.Merchant; | ||
|
||
import com.bitpay.sdk.Client; | ||
import com.bitpay.sdk.exceptions.BitPayApiException; | ||
import com.bitpay.sdk.exceptions.BitPayGenericException; | ||
import com.bitpay.sdk.model.settlement.Settlement; | ||
import com.bitpay.sdk.examples.ClientProvider; | ||
import java.util.List; | ||
|
||
public class SettlementRequests { | ||
|
||
public void getSettlement() throws BitPayGenericException, BitPayApiException { | ||
Client client = ClientProvider.create(); | ||
|
||
Settlement settlement = client.getSettlement("someSettlementId"); | ||
|
||
List<Settlement> settlements = client.getSettlements("USD", "2023-08-14", "2023-08-22", null, null, null); | ||
} | ||
|
||
public void fetchReconciliationReport() throws BitPayGenericException, BitPayApiException { | ||
Client client = ClientProvider.create(); | ||
|
||
client.getSettlementReconciliationReport("settlementId", "settlementToken"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.bitpay.sdk.examples.Payout; | ||
|
||
import com.bitpay.sdk.Client; | ||
import com.bitpay.sdk.exceptions.BitPayApiException; | ||
import com.bitpay.sdk.exceptions.BitPayGenericException; | ||
import com.bitpay.sdk.model.payout.Payout; | ||
import com.bitpay.sdk.model.payout.PayoutGroup; | ||
import com.bitpay.sdk.examples.ClientProvider; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class PayoutRequests { | ||
|
||
public void createPayout() throws BitPayGenericException, BitPayApiException { | ||
Client client = ClientProvider.create(); | ||
|
||
Payout payout = new Payout(12.34, "USD", "USD"); | ||
payout.setNotificationEmail("[email protected]"); | ||
payout.setNotificationUrl("https://my-url.com"); | ||
|
||
Payout result = client.submitPayout(payout); | ||
|
||
Collection<Payout> payoutsCollection = Collections.singletonList(result); | ||
PayoutGroup payouts = client.submitPayouts(payoutsCollection); | ||
} | ||
|
||
public void getPayout() throws BitPayGenericException, BitPayApiException { | ||
Client client = ClientProvider.create(); | ||
|
||
Payout payout = client.getPayout("somePayoutId"); | ||
|
||
List<Payout> payouts = client.getPayouts( | ||
"2023-08-14", | ||
"2023-08-22", | ||
null, | ||
null, | ||
null, | ||
null, | ||
null | ||
); | ||
} | ||
|
||
public void cancelPayout() throws BitPayGenericException, BitPayApiException { | ||
Client client = ClientProvider.create(); | ||
|
||
Boolean cancelPayout = client.cancelPayout("somePayoutId"); | ||
|
||
// String groupId = payout.getGroupId(); | ||
PayoutGroup cancelPayouts = client.cancelPayouts("someGroupId"); | ||
} | ||
|
||
public void requestPayoutWebhookToBeResent() throws BitPayGenericException, BitPayApiException { | ||
Client client = ClientProvider.create(); | ||
|
||
client.requestPayoutNotification("somePayoutId"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.bitpay.sdk.examples.Payout; | ||
|
||
import com.bitpay.sdk.Client; | ||
import com.bitpay.sdk.exceptions.BitPayApiException; | ||
import com.bitpay.sdk.exceptions.BitPayGenericException; | ||
import com.bitpay.sdk.model.payout.PayoutRecipient; | ||
import com.bitpay.sdk.model.payout.PayoutRecipients; | ||
import com.bitpay.sdk.examples.ClientProvider; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class RecipientRequests { | ||
|
||
public void inviteRecipients() throws BitPayGenericException, BitPayApiException { | ||
Client client = ClientProvider.create(); | ||
|
||
PayoutRecipient recipient1 = new PayoutRecipient(); | ||
PayoutRecipient recipient2 = new PayoutRecipient(); | ||
recipient1.setEmail("[email protected]"); | ||
recipient1.setLabel("Alice"); | ||
recipient2.setEmail("[email protected]"); | ||
recipient2.setLabel("Bob"); | ||
List<PayoutRecipient> recipients = new ArrayList<>(); | ||
recipients.add(recipient1); | ||
recipients.add(recipient2); | ||
|
||
PayoutRecipients payoutRecipients = new PayoutRecipients(recipients); | ||
|
||
List<PayoutRecipient> result = client.submitPayoutRecipients(payoutRecipients); | ||
} | ||
|
||
public void getRecipient() throws BitPayGenericException, BitPayApiException { | ||
Client client = ClientProvider.create(); | ||
|
||
PayoutRecipient recipient = client.getPayoutRecipient("someRecipientId"); | ||
|
||
List<PayoutRecipient> recipients = client.getPayoutRecipients("invited", null, null); | ||
} | ||
|
||
public void removeRecipient() throws BitPayGenericException, BitPayApiException { | ||
Client client = ClientProvider.create(); | ||
|
||
Boolean result = client.deletePayoutRecipient("somePayoutRecipientId"); | ||
} | ||
|
||
public void updateRecipient() throws BitPayGenericException, BitPayApiException { | ||
Client client = ClientProvider.create(); | ||
|
||
Boolean result = client.deletePayoutRecipient("somePayoutRecipientId"); | ||
} | ||
} |
Oops, something went wrong.