├── .github ├── dependabot.yml └── workflows │ ├── build.yml │ └── documentation.yml ├── .gitignore ├── .vscode └── settings.json ├── LICENSE.md ├── README.md ├── config └── checkstyle │ ├── checkstyle.xml │ └── suppressions.xml ├── docs ├── BitPaySetup.html ├── allclasses-frame.html ├── allclasses-noframe.html ├── class-use │ └── BitPaySetup.html ├── com │ └── bitpay │ │ └── sdk │ │ ├── Client.html │ │ ├── Config.html │ │ ├── ConfigFilePath.html │ │ ├── Environment.html │ │ ├── PosToken.html │ │ ├── PrivateKey.html │ │ ├── class-use │ │ ├── Client.html │ │ ├── Config.html │ │ ├── ConfigFilePath.html │ │ ├── Environment.html │ │ ├── PosToken.html │ │ └── PrivateKey.html │ │ ├── client │ │ ├── AuthorizationClient.html │ │ ├── BillClient.html │ │ ├── BitPayClient.html │ │ ├── CurrencyClient.html │ │ ├── HttpRequestFactory.html │ │ ├── HttpResponse.html │ │ ├── HttpResponseProvider.html │ │ ├── InvoiceClient.html │ │ ├── LedgerClient.html │ │ ├── PayoutClient.html │ │ ├── PayoutGroupClient.html │ │ ├── PayoutRecipientsClient.html │ │ ├── RateClient.html │ │ ├── RefundClient.html │ │ ├── ResourceClient.html │ │ ├── ResponseParser.html │ │ ├── SettlementClient.html │ │ ├── WalletClient.html │ │ ├── class-use │ │ │ ├── AuthorizationClient.html │ │ │ ├── BillClient.html │ │ │ ├── BitPayClient.html │ │ │ ├── CurrencyClient.html │ │ │ ├── HttpRequestFactory.html │ │ │ ├── HttpResponse.html │ │ │ ├── HttpResponseProvider.html │ │ │ ├── InvoiceClient.html │ │ │ ├── LedgerClient.html │ │ │ ├── PayoutClient.html │ │ │ ├── PayoutGroupClient.html │ │ │ ├── PayoutRecipientsClient.html │ │ │ ├── RateClient.html │ │ │ ├── RefundClient.html │ │ │ ├── ResourceClient.html │ │ │ ├── ResponseParser.html │ │ │ ├── SettlementClient.html │ │ │ └── WalletClient.html │ │ ├── package-frame.html │ │ ├── package-summary.html │ │ ├── package-tree.html │ │ └── package-use.html │ │ ├── exceptions │ │ ├── BitPayApiException.html │ │ ├── BitPayException.html │ │ ├── BitPayExceptionProvider.html │ │ ├── BitPayGenericException.html │ │ ├── BitPayValidationException.html │ │ ├── class-use │ │ │ ├── BitPayApiException.html │ │ │ ├── BitPayException.html │ │ │ ├── BitPayExceptionProvider.html │ │ │ ├── BitPayGenericException.html │ │ │ └── BitPayValidationException.html │ │ ├── package-frame.html │ │ ├── package-summary.html │ │ ├── package-tree.html │ │ └── package-use.html │ │ ├── logger │ │ ├── BitPayLogger.html │ │ ├── EmptyLogger.html │ │ ├── LoggerProvider.html │ │ ├── class-use │ │ │ ├── BitPayLogger.html │ │ │ ├── EmptyLogger.html │ │ │ └── LoggerProvider.html │ │ ├── package-frame.html │ │ ├── package-summary.html │ │ ├── package-tree.html │ │ └── package-use.html │ │ ├── model │ │ ├── Currency.html │ │ ├── Facade.html │ │ ├── ModelConfiguration.html │ │ ├── Policy.html │ │ ├── Token.html │ │ ├── bill │ │ │ ├── Bill.html │ │ │ ├── BillStatus.html │ │ │ ├── Item.html │ │ │ ├── class-use │ │ │ │ ├── Bill.html │ │ │ │ ├── BillStatus.html │ │ │ │ └── Item.html │ │ │ ├── package-frame.html │ │ │ ├── package-summary.html │ │ │ ├── package-tree.html │ │ │ └── package-use.html │ │ ├── class-use │ │ │ ├── Currency.html │ │ │ ├── Facade.html │ │ │ ├── ModelConfiguration.html │ │ │ ├── Policy.html │ │ │ └── Token.html │ │ ├── invoice │ │ │ ├── Buyer.html │ │ │ ├── Invoice.html │ │ │ ├── InvoiceBuyerProvidedInfo.html │ │ │ ├── InvoiceEventToken.html │ │ │ ├── InvoiceItemizedDetails.html │ │ │ ├── InvoiceRefundAddress.html │ │ │ ├── InvoiceStatus.html │ │ │ ├── InvoiceTransaction.html │ │ │ ├── InvoiceUniversalCodes.html │ │ │ ├── MinerFees.html │ │ │ ├── MinerFeesItem.html │ │ │ ├── Refund.html │ │ │ ├── RefundInfo.html │ │ │ ├── RefundStatus.html │ │ │ ├── RefundWebhook.html │ │ │ ├── Shopper.html │ │ │ ├── SupportedTransactionCurrencies.html │ │ │ ├── SupportedTransactionCurrency.html │ │ │ ├── class-use │ │ │ │ ├── Buyer.html │ │ │ │ ├── Invoice.html │ │ │ │ ├── InvoiceBuyerProvidedInfo.html │ │ │ │ ├── InvoiceEventToken.html │ │ │ │ ├── InvoiceItemizedDetails.html │ │ │ │ ├── InvoiceRefundAddress.html │ │ │ │ ├── InvoiceStatus.html │ │ │ │ ├── InvoiceTransaction.html │ │ │ │ ├── InvoiceUniversalCodes.html │ │ │ │ ├── MinerFees.html │ │ │ │ ├── MinerFeesItem.html │ │ │ │ ├── Refund.html │ │ │ │ ├── RefundInfo.html │ │ │ │ ├── RefundStatus.html │ │ │ │ ├── RefundWebhook.html │ │ │ │ ├── Shopper.html │ │ │ │ ├── SupportedTransactionCurrencies.html │ │ │ │ └── SupportedTransactionCurrency.html │ │ │ ├── package-frame.html │ │ │ ├── package-summary.html │ │ │ ├── package-tree.html │ │ │ └── package-use.html │ │ ├── ledger │ │ │ ├── Buyer.html │ │ │ ├── Ledger.html │ │ │ ├── LedgerEntry.html │ │ │ ├── class-use │ │ │ │ ├── Buyer.html │ │ │ │ ├── Ledger.html │ │ │ │ └── LedgerEntry.html │ │ │ ├── package-frame.html │ │ │ ├── package-summary.html │ │ │ ├── package-tree.html │ │ │ └── package-use.html │ │ ├── package-frame.html │ │ ├── package-summary.html │ │ ├── package-tree.html │ │ ├── package-use.html │ │ ├── payout │ │ │ ├── Payout.html │ │ │ ├── PayoutGroup.html │ │ │ ├── PayoutGroupFailed.html │ │ │ ├── PayoutRecipient.html │ │ │ ├── PayoutRecipients.html │ │ │ ├── PayoutStatus.html │ │ │ ├── PayoutTransaction.html │ │ │ ├── RecipientStatus.html │ │ │ ├── class-use │ │ │ │ ├── Payout.html │ │ │ │ ├── PayoutGroup.html │ │ │ │ ├── PayoutGroupFailed.html │ │ │ │ ├── PayoutRecipient.html │ │ │ │ ├── PayoutRecipients.html │ │ │ │ ├── PayoutStatus.html │ │ │ │ ├── PayoutTransaction.html │ │ │ │ └── RecipientStatus.html │ │ │ ├── package-frame.html │ │ │ ├── package-summary.html │ │ │ ├── package-tree.html │ │ │ └── package-use.html │ │ ├── rate │ │ │ ├── Rate.html │ │ │ ├── Rates.html │ │ │ ├── class-use │ │ │ │ ├── Rate.html │ │ │ │ └── Rates.html │ │ │ ├── package-frame.html │ │ │ ├── package-summary.html │ │ │ ├── package-tree.html │ │ │ └── package-use.html │ │ ├── settlement │ │ │ ├── InvoiceData.html │ │ │ ├── PayoutInfo.html │ │ │ ├── RefundInfo.html │ │ │ ├── Settlement.html │ │ │ ├── SettlementLedgerEntry.html │ │ │ ├── WithHoldings.html │ │ │ ├── class-use │ │ │ │ ├── InvoiceData.html │ │ │ │ ├── PayoutInfo.html │ │ │ │ ├── RefundInfo.html │ │ │ │ ├── Settlement.html │ │ │ │ ├── SettlementLedgerEntry.html │ │ │ │ └── WithHoldings.html │ │ │ ├── package-frame.html │ │ │ ├── package-summary.html │ │ │ ├── package-tree.html │ │ │ └── package-use.html │ │ └── wallet │ │ │ ├── Currencies.html │ │ │ ├── CurrencyQr.html │ │ │ ├── Wallet.html │ │ │ ├── class-use │ │ │ ├── Currencies.html │ │ │ ├── CurrencyQr.html │ │ │ └── Wallet.html │ │ │ ├── package-frame.html │ │ │ ├── package-summary.html │ │ │ ├── package-tree.html │ │ │ └── package-use.html │ │ ├── package-frame.html │ │ ├── package-summary.html │ │ ├── package-tree.html │ │ ├── package-use.html │ │ └── util │ │ ├── BitPayLogger.html │ │ ├── GuidGenerator.html │ │ ├── JsonMapperFactory.html │ │ ├── KeyUtils.html │ │ ├── ParameterAdder.html │ │ ├── TokenContainer.html │ │ ├── class-use │ │ ├── BitPayLogger.html │ │ ├── GuidGenerator.html │ │ ├── JsonMapperFactory.html │ │ ├── KeyUtils.html │ │ ├── ParameterAdder.html │ │ └── TokenContainer.html │ │ ├── package-frame.html │ │ ├── package-summary.html │ │ ├── package-tree.html │ │ ├── package-use.html │ │ └── serializer │ │ ├── Iso8601ToZonedDateTimeDeserializer.html │ │ ├── ZonedDateTimeToIso8601Serializer.html │ │ ├── class-use │ │ ├── Iso8601ToZonedDateTimeDeserializer.html │ │ └── ZonedDateTimeToIso8601Serializer.html │ │ ├── package-frame.html │ │ ├── package-summary.html │ │ ├── package-tree.html │ │ └── package-use.html ├── constant-values.html ├── deprecated-list.html ├── help-doc.html ├── index-all.html ├── index.html ├── overview-frame.html ├── overview-summary.html ├── overview-tree.html ├── package-frame.html ├── package-list ├── package-summary.html ├── package-tree.html ├── package-use.html ├── script.js ├── serialized-form.html └── stylesheet.css ├── examples ├── ClientProvider.java ├── General │ └── UseLogger.java ├── Merchant │ ├── BillRequests.java │ ├── InvoiceRequests.java │ ├── LedgerRequests.java │ ├── RefundRequests.java │ └── SettlementRequests.java ├── Payout │ ├── PayoutRequests.java │ └── RecipientRequests.java ├── Pos │ ├── BillRequests.java │ └── InvoiceRequests.java └── Public │ ├── RateRequests.java │ └── WalletRequests.java ├── java-bitpay-client.iml ├── pom.xml └── src ├── main └── java │ └── com │ └── bitpay │ └── sdk │ ├── Client.java │ ├── Config.java │ ├── ConfigFilePath.java │ ├── Environment.java │ ├── PosToken.java │ ├── PrivateKey.java │ ├── client │ ├── AuthorizationClient.java │ ├── BillClient.java │ ├── BitPayClient.java │ ├── CurrencyClient.java │ ├── HttpRequestFactory.java │ ├── HttpResponse.java │ ├── HttpResponseProvider.java │ ├── InvoiceClient.java │ ├── LedgerClient.java │ ├── PayoutClient.java │ ├── PayoutGroupClient.java │ ├── PayoutRecipientsClient.java │ ├── RateClient.java │ ├── RefundClient.java │ ├── ResourceClient.java │ ├── ResponseParser.java │ ├── SettlementClient.java │ └── WalletClient.java │ ├── exceptions │ ├── BitPayApiException.java │ ├── BitPayException.java │ ├── BitPayExceptionProvider.java │ ├── BitPayGenericException.java │ ├── BitPayValidationException.java │ └── package-info.java │ ├── logger │ ├── BitPayLogger.java │ ├── EmptyLogger.java │ ├── LoggerProvider.java │ └── Slf4jLogger.java │ ├── model │ ├── Currency.java │ ├── Facade.java │ ├── ModelConfiguration.java │ ├── Policy.java │ ├── Token.java │ ├── bill │ │ ├── Bill.java │ │ ├── BillStatus.java │ │ ├── Item.java │ │ └── package-info.java │ ├── invoice │ │ ├── Buyer.java │ │ ├── BuyerFields.java │ │ ├── Invoice.java │ │ ├── InvoiceBuyerProvidedInfo.java │ │ ├── InvoiceEventToken.java │ │ ├── InvoiceItemizedDetails.java │ │ ├── InvoiceRefundAddress.java │ │ ├── InvoiceStatus.java │ │ ├── InvoiceTransaction.java │ │ ├── InvoiceUniversalCodes.java │ │ ├── InvoiceWebhook.java │ │ ├── MinerFees.java │ │ ├── MinerFeesItem.java │ │ ├── Refund.java │ │ ├── RefundInfo.java │ │ ├── RefundStatus.java │ │ ├── RefundWebhook.java │ │ ├── Shopper.java │ │ ├── SupportedTransactionCurrencies.java │ │ ├── SupportedTransactionCurrency.java │ │ └── package-info.java │ ├── ledger │ │ ├── Buyer.java │ │ ├── Ledger.java │ │ ├── LedgerEntry.java │ │ └── package-info.java │ ├── package-info.java │ ├── payout │ │ ├── Payout.java │ │ ├── PayoutGroup.java │ │ ├── PayoutGroupFailed.java │ │ ├── PayoutRecipient.java │ │ ├── PayoutRecipients.java │ │ ├── PayoutStatus.java │ │ ├── PayoutTransaction.java │ │ ├── PayoutWebhook.java │ │ ├── RecipientStatus.java │ │ ├── RecipientWebhook.java │ │ └── package-info.java │ ├── rate │ │ ├── Rate.java │ │ ├── Rates.java │ │ └── package-info.java │ ├── settlement │ │ ├── InvoiceData.java │ │ ├── PayoutInfo.java │ │ ├── RefundInfo.java │ │ ├── Settlement.java │ │ ├── SettlementLedgerEntry.java │ │ ├── WithHoldings.java │ │ └── package-info.java │ └── wallet │ │ ├── Currencies.java │ │ ├── CurrencyQr.java │ │ ├── Wallet.java │ │ └── package-info.java │ ├── package-info.java │ └── util │ ├── BitPayLogger.java │ ├── GuidGenerator.java │ ├── JsonMapperFactory.java │ ├── KeyUtils.java │ ├── ParameterAdder.java │ ├── TokenContainer.java │ ├── package-info.java │ └── serializer │ ├── Iso8601ToZonedDateTimeDeserializer.java │ └── ZonedDateTimeToIso8601Serializer.java ├── setup └── java │ └── BitPaySetup.java └── test └── java └── com └── bitpay └── sdk ├── BitPay.config.json ├── ClientTest.java ├── ConfigTest.java ├── EnvironmentTest.java ├── ResourceClientsCleaner.java ├── client ├── AbstractClientTest.java ├── AuthorizationClientTest.java ├── BillClientTest.java ├── BitPayClientTest.java ├── CurrencyClientTest.java ├── HttpRequestFactoryTest.java ├── HttpResponseTest.java ├── InvoiceClientTest.java ├── LedgerClientTest.java ├── PayoutClientTest.java ├── PayoutRecipientsClientTest.java ├── RateClientTest.java ├── RefundClientTest.java ├── ResponseParserTest.java ├── SettlementClientTest.java ├── WalletClientTest.java └── json │ ├── authorizeClientByFacadeRequest.json │ ├── authorizeClientByFacadeResponse.json │ ├── cancelInvoiceErrorResponse.json │ ├── cancelInvoiceSuccessResponse.json │ ├── cancelPayoutResponse.json │ ├── cancelRefundResponse.json │ ├── createBillRequest.json │ ├── createBillResponse.json │ ├── createInvoiceRequest.json │ ├── createInvoiceResponse.json │ ├── createPayoutRequest.json │ ├── createPayoutResponse.json │ ├── createRefundRequest.json │ ├── createRefundResponse.json │ ├── deletePayoutRecipientResponse.json │ ├── deliverBillRequest.json │ ├── deliverBillResponse.json │ ├── getBillsResponse.json │ ├── getCurrenciesResponse.json │ ├── getInvoiceEventToken.json │ ├── getInvoiceResponse.json │ ├── getInvoicesResponse.json │ ├── getLedgerEntriesResponse.json │ ├── getLedgersResponse.json │ ├── getPayoutRecipientResponse.json │ ├── getPayoutRecipientsResponse.json │ ├── getPayoutResponse.json │ ├── getPayoutsResponse.json │ ├── getRateResponse.json │ ├── getRatesResponse.json │ ├── getRefundResponse.json │ ├── getRefundsByInvoiceId.json │ ├── getSettlementReconciliationReportResponse.json │ ├── getSettlementResponse.json │ ├── getSettlementsResponse.json │ ├── getSupportedWallets.json │ ├── invoiceWebhookResponse.json │ ├── payInvoiceRequest.json │ ├── payInvoiceResponse.json │ ├── sendPayoutNotificationRequest.json │ ├── sendPayoutNotificationResponse.json │ ├── sendRefundNotificationRequest.json │ ├── sendRefundNotificationResponse.json │ ├── submitPayoutRecipientsRequest.json │ ├── submitPayoutRecipientsResponse.json │ ├── updateBillResponse.json │ ├── updateInvoiceRequest.json │ ├── updateInvoiceResponse.json │ ├── updatePayoutRecipientResponse.json │ ├── updateRefundRequest.json │ └── updateRefundResponse.json ├── functional ├── .gitignore ├── ClientFunctionalTest.java └── client │ └── HttpResponseProviderTest.java ├── json ├── cancelPayoutGroupResponse.json ├── createBillPosResponse.json ├── createBillRequest.json ├── createBillResponse.json ├── createInvoiceRequest.json ├── createInvoiceResponse.json ├── createRefundRequest.json ├── createRefundResponse.json ├── currencies.json ├── getBill.json ├── getBills.json ├── getCancelledInvoice.json ├── getInvoice.json ├── getInvoiceEventToken.json ├── getInvoices.json ├── getLedgerBalances.json ├── getLedgers.json ├── getPayouts.json ├── getRates.json ├── getRefund.json ├── getRefunds.json ├── getSettlementReconciliationReportResponse.json ├── getSettlementResponse.json ├── getSettlementsResponse.json ├── getSupportedWalletsResponse.json ├── payInvoiceRequest.json ├── payInvoiceResponse.json ├── refundNotificationResponse.json ├── retrieveRecipientResponse.json ├── retrieveRecipientsResponse.json ├── submitPayoutGroupRequest.json ├── submitPayoutGroupResponse.json ├── submitPayoutRecipientsRequest.json ├── submitPayoutRecipientsResponse.json ├── submitPayoutRequest.json ├── submitPayoutResponse.json ├── success.json ├── updateBillRequest.json ├── updatePayoutRecipientRequest.json └── updatePayoutRecipientResponse.json ├── model ├── CurrencyTest.java ├── FacadeTest.java ├── PolicyTest.java ├── TokenTest.java ├── bill │ ├── BillTest.java │ └── ItemTest.java ├── invoice │ ├── BuyerFieldsTest.java │ ├── BuyerTest.java │ ├── InvoiceBuyerProvidedInfoTest.java │ ├── InvoiceEventTokenTest.java │ ├── InvoiceItemizedDetailsTest.java │ ├── InvoiceRefundAddressTest.java │ ├── InvoiceStatusTest.java │ ├── InvoiceTest.java │ ├── InvoiceTransactionTest.java │ ├── InvoiceUniversalCodesTest.java │ ├── InvoiceWebhookTest.java │ ├── MinerFeesItemTest.java │ ├── MinerFeesTest.java │ ├── RefundInfoTest.java │ ├── RefundStatusTest.java │ ├── RefundTest.java │ ├── RefundWebhookTest.java │ ├── ShopperTest.java │ ├── SupportedTransactionCurrenciesTest.java │ └── SupportedTransactionCurrencyTest.java ├── ledger │ ├── BuyerTest.java │ ├── LedgerEntryTest.java │ └── LedgerTest.java ├── payout │ ├── PayoutInstructionTransactionTest.java │ ├── PayoutRecipientTest.java │ ├── PayoutRecipientsTest.java │ ├── PayoutStatusTest.java │ ├── PayoutTest.java │ ├── PayoutWebhookTest.java │ ├── RecipientStatusTest.java │ └── RecipientWebhookTest.java ├── rate │ ├── RateTest.java │ └── RatesTest.java ├── settlement │ ├── InvoiceDataTest.java │ ├── PayoutInfoTest.java │ ├── RefundInfoTest.java │ ├── SettlementLedgerEntryTest.java │ ├── SettlementTest.java │ └── WithHoldingsTest.java └── wallet │ ├── CurrenciesTest.java │ ├── CurrencyQrTest.java │ └── WalletTest.java └── util ├── GuidGeneratorTest.java ├── Iso8601ToZonedDateTimeDeserializerTest.java ├── JsonMapperFactoryTest.java ├── KeyUtilsTest.java ├── TokenContainerTest.java └── ZonedDateTimeToIso8601SerializerTest.java /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "maven" 9 | directory: "/" 10 | schedule: 11 | interval: "daily" 12 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build-and-test: 7 | runs-on: ubuntu-latest 8 | 9 | strategy: 10 | matrix: 11 | java-version: [8, 11, 17, 21, 23] 12 | 13 | steps: 14 | - uses: actions/checkout@v4 15 | - uses: actions/setup-java@v4 16 | with: 17 | java-version: ${{ matrix.java-version }} 18 | distribution: 'corretto' 19 | - name: Run mvn compile 20 | run: mvn --batch-mode -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn compile 21 | - name: Run mvn test 22 | run: mvn --batch-mode -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn test 23 | - name: Run mvn checkstyle check 24 | run: mvn --batch-mode -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn checkstyle:check 25 | -------------------------------------------------------------------------------- /.github/workflows/documentation.yml: -------------------------------------------------------------------------------- 1 | name: Documentation 2 | 3 | on: 4 | push: 5 | branches: 6 | - '*.*.x' 7 | 8 | concurrency: 9 | group: documentation 10 | cancel-in-progress: true 11 | 12 | jobs: 13 | javadoc: 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - uses: actions/checkout@v4 18 | - uses: actions/setup-java@v4 19 | with: 20 | java-version: 8 21 | distribution: 'corretto' 22 | - name: generate docs 23 | run: | 24 | rm -rf docs 25 | mkdir docs 26 | mvn javadoc:javadoc 27 | mv target/site/apidocs/* docs/ 28 | - name: git commit 29 | run: | 30 | git config user.name "GitHub Actions" 31 | git config user.email "" 32 | git add docs/ 33 | git commit -m "Update javadoc" || echo "No changes to commit" 34 | git push -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | locals/ 2 | *.key 3 | java-bitpay-client.xml 4 | java-bitpay-client.properties 5 | untitled folder/ 6 | .idea/ 7 | target 8 | out 9 | lib 10 | bin 11 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.configuration.updateBuildConfiguration": "automatic", 3 | "java.compile.nullAnalysis.mode": "automatic" 4 | } -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 BitPay 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # BitPay Java client 4 | [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) ![Build](https://github.com/bitpay/java-bitpay-client/actions/workflows/build.yml/badge.svg) 5 | 6 | Full implementation of the BitPay Payment Gateway. This library implements BitPay's [Cryptographically Secure RESTful API](https://developer.bitpay.com/reference/concepts). 7 | 8 | ## Getting Started 9 | 10 | To get up and running with our Java library quickly, check out our [documentation](https://developer.bitpay.com/reference/java-full-sdk-getting-started). 11 | 12 | ## Support 13 | 14 | * https://github.com/bitpay/java-bitpay-client/issues 15 | * https://support.bitpay.com 16 | 17 | ## Contribute 18 | 19 | To contribute to this project, please fork and submit a pull request. 20 | 21 | ## License 22 | 23 | MIT License 24 | 25 | Copyright (c) 2019 BitPay 26 | 27 | Permission is hereby granted, free of charge, to any person obtaining a copy 28 | of this software and associated documentation files (the "Software"), to deal 29 | in the Software without restriction, including without limitation the rights 30 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 31 | copies of the Software, and to permit persons to whom the Software is 32 | furnished to do so, subject to the following conditions: 33 | 34 | The above copyright notice and this permission notice shall be included in all 35 | copies or substantial portions of the Software. 36 | 37 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 38 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 39 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 40 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 41 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 42 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 43 | SOFTWARE. 44 | -------------------------------------------------------------------------------- /config/checkstyle/suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /docs/com/bitpay/sdk/exceptions/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.bitpay.sdk.exceptions (BitPay 10.2.0 API) 8 | 9 | 10 | 11 | 12 |

com.bitpay.sdk.exceptions

13 |
14 |

Classes

15 | 18 |

Exceptions

19 | 25 |
26 | 27 | 28 | -------------------------------------------------------------------------------- /docs/com/bitpay/sdk/logger/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.bitpay.sdk.logger (BitPay 10.2.0 API) 8 | 9 | 10 | 11 | 12 |

com.bitpay.sdk.logger

13 |
14 |

Interfaces

15 | 18 |

Classes

19 | 23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /docs/com/bitpay/sdk/model/bill/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.bitpay.sdk.model.bill (BitPay 10.2.0 API) 8 | 9 | 10 | 11 | 12 |

com.bitpay.sdk.model.bill

13 |
14 |

Classes

15 | 20 |
21 | 22 | 23 | -------------------------------------------------------------------------------- /docs/com/bitpay/sdk/model/ledger/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.bitpay.sdk.model.ledger (BitPay 10.2.0 API) 8 | 9 | 10 | 11 | 12 |

com.bitpay.sdk.model.ledger

13 |
14 |

Classes

15 | 20 |
21 | 22 | 23 | -------------------------------------------------------------------------------- /docs/com/bitpay/sdk/model/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.bitpay.sdk.model (BitPay 10.2.0 API) 8 | 9 | 10 | 11 | 12 |

com.bitpay.sdk.model

13 |
14 |

Interfaces

15 | 18 |

Classes

19 | 24 |

Enums

25 | 28 |
29 | 30 | 31 | -------------------------------------------------------------------------------- /docs/com/bitpay/sdk/model/payout/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.bitpay.sdk.model.payout (BitPay 10.2.0 API) 8 | 9 | 10 | 11 | 12 |

com.bitpay.sdk.model.payout

13 |
14 |

Classes

15 | 25 |
26 | 27 | 28 | -------------------------------------------------------------------------------- /docs/com/bitpay/sdk/model/rate/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.bitpay.sdk.model.rate (BitPay 10.2.0 API) 8 | 9 | 10 | 11 | 12 |

com.bitpay.sdk.model.rate

13 |
14 |

Classes

15 | 19 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /docs/com/bitpay/sdk/model/settlement/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.bitpay.sdk.model.settlement (BitPay 10.2.0 API) 8 | 9 | 10 | 11 | 12 |

com.bitpay.sdk.model.settlement

13 |
14 |

Classes

15 | 23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /docs/com/bitpay/sdk/model/wallet/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.bitpay.sdk.model.wallet (BitPay 10.2.0 API) 8 | 9 | 10 | 11 | 12 |

com.bitpay.sdk.model.wallet

13 |
14 |

Classes

15 | 20 |
21 | 22 | 23 | -------------------------------------------------------------------------------- /docs/com/bitpay/sdk/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.bitpay.sdk (BitPay 10.2.0 API) 8 | 9 | 10 | 11 | 12 |

com.bitpay.sdk

13 |
14 |

Classes

15 | 22 |

Enums

23 | 26 |
27 | 28 | 29 | -------------------------------------------------------------------------------- /docs/com/bitpay/sdk/util/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.bitpay.sdk.util (BitPay 10.2.0 API) 8 | 9 | 10 | 11 | 12 |

com.bitpay.sdk.util

13 |
14 |

Classes

15 | 23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /docs/com/bitpay/sdk/util/serializer/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.bitpay.sdk.util.serializer (BitPay 10.2.0 API) 8 | 9 | 10 | 11 | 12 |

com.bitpay.sdk.util.serializer

13 |
14 |

Classes

15 | 19 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /docs/overview-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Overview List (BitPay 10.2.0 API) 8 | 9 | 10 | 11 | 12 |
All Classes
13 |
14 |

Packages

15 | 32 |
33 |

 

34 | 35 | 36 | -------------------------------------------------------------------------------- /docs/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | <Unnamed> (BitPay 10.2.0 API) 8 | 9 | 10 | 11 | 12 |

<Unnamed>

13 |
14 |

Classes

15 | 18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /docs/package-list: -------------------------------------------------------------------------------- 1 | 2 | com.bitpay.sdk 3 | com.bitpay.sdk.client 4 | com.bitpay.sdk.exceptions 5 | com.bitpay.sdk.logger 6 | com.bitpay.sdk.model 7 | com.bitpay.sdk.model.bill 8 | com.bitpay.sdk.model.invoice 9 | com.bitpay.sdk.model.ledger 10 | com.bitpay.sdk.model.payout 11 | com.bitpay.sdk.model.rate 12 | com.bitpay.sdk.model.settlement 13 | com.bitpay.sdk.model.wallet 14 | com.bitpay.sdk.util 15 | com.bitpay.sdk.util.serializer 16 | -------------------------------------------------------------------------------- /docs/script.js: -------------------------------------------------------------------------------- 1 | function show(type) 2 | { 3 | count = 0; 4 | for (var key in methods) { 5 | var row = document.getElementById(key); 6 | if ((methods[key] & type) != 0) { 7 | row.style.display = ''; 8 | row.className = (count++ % 2) ? rowColor : altColor; 9 | } 10 | else 11 | row.style.display = 'none'; 12 | } 13 | updateTabs(type); 14 | } 15 | 16 | function updateTabs(type) 17 | { 18 | for (var value in tabs) { 19 | var sNode = document.getElementById(tabs[value][0]); 20 | var spanNode = sNode.firstChild; 21 | if (value == type) { 22 | sNode.className = activeTableTab; 23 | spanNode.innerHTML = tabs[value][1]; 24 | } 25 | else { 26 | sNode.className = tableTab; 27 | spanNode.innerHTML = "" + tabs[value][1] + ""; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /examples/ClientProvider.java: -------------------------------------------------------------------------------- 1 | package com.bitpay.sdk.t; 2 | 3 | import com.bitpay.sdk.Client; 4 | import com.bitpay.sdk.ConfigFilePath; 5 | import com.bitpay.sdk.PosToken; 6 | import com.bitpay.sdk.exceptions.BitPayGenericException; 7 | 8 | public class ClientProvider { 9 | 10 | public static Client create() { 11 | try { 12 | return Client.createClientByConfigFilePath(new ConfigFilePath("some/config/path")); // use BitPaySetup 13 | } catch (BitPayGenericException e) { 14 | throw new RuntimeException(e); 15 | } 16 | } 17 | 18 | public static Client createPos() { 19 | try { 20 | return new Client(new PosToken("someToken")); 21 | } catch (BitPayGenericException e) { 22 | throw new RuntimeException(e); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /examples/General/UseLogger.java: -------------------------------------------------------------------------------- 1 | package com.bitpay.sdk.examples.General; 2 | 3 | import com.bitpay.sdk.Client; 4 | import com.bitpay.sdk.exceptions.BitPayApiException; 5 | import com.bitpay.sdk.exceptions.BitPayGenericException; 6 | import com.bitpay.sdk.logger.BitPayLogger; 7 | import com.bitpay.sdk.logger.LoggerProvider; 8 | import com.bitpay.sdk.model.invoice.Invoice; 9 | import com.bitpay.sdk.examples.ClientProvider; 10 | 11 | final public class UseLogger { 12 | 13 | public void execute() throws BitPayGenericException, BitPayApiException { 14 | LoggerProvider.setLogger(new BitPayLogger() { 15 | @Override 16 | public void logRequest(String method, String endpoint, String json) { 17 | // some logic 18 | } 19 | 20 | @Override 21 | public void logResponse(String method, String endpoint, String json) { 22 | // some logic 23 | } 24 | 25 | @Override 26 | public void logError(String message) { 27 | // some logic 28 | } 29 | }); 30 | 31 | Client client = ClientProvider.create(); 32 | 33 | Invoice invoice = client.getInvoice("someInvoiceId"); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /examples/Merchant/BillRequests.java: -------------------------------------------------------------------------------- 1 | package com.bitpay.sdk.examples.Merchant; 2 | 3 | import com.bitpay.sdk.Client; 4 | import com.bitpay.sdk.exceptions.BitPayApiException; 5 | import com.bitpay.sdk.exceptions.BitPayGenericException; 6 | import com.bitpay.sdk.model.bill.Bill; 7 | import com.bitpay.sdk.model.bill.Item; 8 | import com.bitpay.sdk.examples.ClientProvider; 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | public class BillRequests { 13 | 14 | public void createBill() throws BitPayGenericException, BitPayApiException { 15 | Client client = ClientProvider.create(); 16 | 17 | Bill bill = new Bill(); 18 | bill.setCurrency("USD"); 19 | bill.setEmail("some@email.com"); 20 | bill.setAddress1("SomeAddress"); 21 | bill.setCity("MyCity"); 22 | // ... 23 | 24 | Bill result = client.createBill(bill); 25 | } 26 | 27 | public void getBill() throws BitPayGenericException, BitPayApiException { 28 | Client client = ClientProvider.create(); 29 | 30 | Bill bill = client.getBill("someBillid"); 31 | 32 | List bills = client.getBills("draft"); 33 | } 34 | 35 | public void updateBill() throws BitPayGenericException, BitPayApiException { 36 | Client client = ClientProvider.create(); 37 | 38 | Item item = new Item(); 39 | item.setPrice(12.34); 40 | item.setQuantity(2); 41 | item.setDescription("someDescription"); 42 | 43 | List items = new ArrayList<>(); 44 | items.add(item); 45 | 46 | Bill bill = new Bill(); 47 | bill.setItems(items); 48 | 49 | client.updateBill(bill, "someBillId"); 50 | } 51 | 52 | public void deliverBillViaEmail() throws BitPayGenericException, BitPayApiException { 53 | Client client = ClientProvider.create(); 54 | 55 | client.deliverBill("someBillId", "myBillToken"); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /examples/Merchant/LedgerRequests.java: -------------------------------------------------------------------------------- 1 | package com.bitpay.sdk.examples.Merchant; 2 | 3 | import com.bitpay.sdk.Client; 4 | import com.bitpay.sdk.exceptions.BitPayApiException; 5 | import com.bitpay.sdk.exceptions.BitPayGenericException; 6 | import com.bitpay.sdk.model.ledger.Ledger; 7 | import com.bitpay.sdk.model.ledger.LedgerEntry; 8 | import com.bitpay.sdk.examples.ClientProvider; 9 | import java.util.List; 10 | 11 | public class LedgerRequests { 12 | 13 | public void getLedgers() throws BitPayGenericException, BitPayApiException { 14 | Client client = ClientProvider.create(); 15 | 16 | List ledgers = client.getLedgers(); 17 | } 18 | 19 | public void getLedgerEntries() throws BitPayGenericException, BitPayApiException { 20 | Client client = ClientProvider.create(); 21 | 22 | List ledgerEntries = client.getLedgerEntries("USD", "2023-08-14", "2023-08-22"); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /examples/Merchant/RefundRequests.java: -------------------------------------------------------------------------------- 1 | package com.bitpay.sdk.examples.Merchant; 2 | 3 | import com.bitpay.sdk.Client; 4 | import com.bitpay.sdk.exceptions.BitPayApiException; 5 | import com.bitpay.sdk.exceptions.BitPayGenericException; 6 | import com.bitpay.sdk.model.invoice.Refund; 7 | import com.bitpay.sdk.examples.ClientProvider; 8 | 9 | public class RefundRequests { 10 | 11 | public void createRefund() throws BitPayGenericException, BitPayApiException { 12 | Client client = ClientProvider.create(); 13 | 14 | Refund refund = client.createRefund("myInvoiceId", 12.34, true, true, true, "no"); 15 | } 16 | 17 | public void updateRefund() throws BitPayGenericException, BitPayApiException { 18 | Client client = ClientProvider.create(); 19 | 20 | Refund updateRefund = client.updateRefund("refundId", "created"); 21 | 22 | Refund updateRefundByGuid = client.updateRefundByGuid("someGuid", "created"); 23 | } 24 | 25 | public void getRefund() throws BitPayGenericException, BitPayApiException { 26 | Client client = ClientProvider.create(); 27 | 28 | Refund refund = client.getRefund("someRefundId"); 29 | 30 | Refund refundByGuid = client.getRefundByGuid("someGuid"); 31 | } 32 | 33 | public void cancelRefund() throws BitPayGenericException, BitPayApiException { 34 | Client client = ClientProvider.create(); 35 | 36 | Refund cancelRefund = client.cancelRefund("someRefundId"); 37 | 38 | Refund cancelRefundByGuid = client.cancelRefundByGuid("someGuid"); 39 | } 40 | 41 | public void requestRefundNotificationToBeResent() throws BitPayGenericException, BitPayApiException { 42 | Client client = ClientProvider.create(); 43 | 44 | Boolean result = client.sendRefundNotification("someRefundId"); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /examples/Merchant/SettlementRequests.java: -------------------------------------------------------------------------------- 1 | package com.bitpay.sdk.examples.Merchant; 2 | 3 | import com.bitpay.sdk.Client; 4 | import com.bitpay.sdk.exceptions.BitPayApiException; 5 | import com.bitpay.sdk.exceptions.BitPayGenericException; 6 | import com.bitpay.sdk.model.settlement.Settlement; 7 | import com.bitpay.sdk.examples.ClientProvider; 8 | import java.util.List; 9 | 10 | public class SettlementRequests { 11 | 12 | public void getSettlement() throws BitPayGenericException, BitPayApiException { 13 | Client client = ClientProvider.create(); 14 | 15 | Settlement settlement = client.getSettlement("someSettlementId"); 16 | 17 | List settlements = client.getSettlements("USD", "2023-08-14", "2023-08-22", null, null, null); 18 | } 19 | 20 | public void fetchReconciliationReport() throws BitPayGenericException, BitPayApiException { 21 | Client client = ClientProvider.create(); 22 | 23 | client.getSettlementReconciliationReport("settlementId", "settlementToken"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /examples/Payout/PayoutRequests.java: -------------------------------------------------------------------------------- 1 | package com.bitpay.sdk.examples.Payout; 2 | 3 | import com.bitpay.sdk.Client; 4 | import com.bitpay.sdk.exceptions.BitPayApiException; 5 | import com.bitpay.sdk.exceptions.BitPayGenericException; 6 | import com.bitpay.sdk.model.payout.Payout; 7 | import com.bitpay.sdk.model.payout.PayoutGroup; 8 | import com.bitpay.sdk.examples.ClientProvider; 9 | import java.util.Collection; 10 | import java.util.Collections; 11 | import java.util.List; 12 | 13 | public class PayoutRequests { 14 | 15 | public void createPayout() throws BitPayGenericException, BitPayApiException { 16 | Client client = ClientProvider.create(); 17 | 18 | Payout payout = new Payout(12.34, "USD", "USD"); 19 | payout.setNotificationEmail("myEmail@email.com"); 20 | payout.setNotificationUrl("https://my-url.com"); 21 | 22 | Payout result = client.submitPayout(payout); 23 | 24 | Collection payoutsCollection = Collections.singletonList(result); 25 | PayoutGroup payouts = client.submitPayouts(payoutsCollection); 26 | } 27 | 28 | public void getPayout() throws BitPayGenericException, BitPayApiException { 29 | Client client = ClientProvider.create(); 30 | 31 | Payout payout = client.getPayout("somePayoutId"); 32 | 33 | List payouts = client.getPayouts( 34 | "2023-08-14", 35 | "2023-08-22", 36 | null, 37 | null, 38 | null, 39 | null, 40 | null 41 | ); 42 | } 43 | 44 | public void cancelPayout() throws BitPayGenericException, BitPayApiException { 45 | Client client = ClientProvider.create(); 46 | 47 | Boolean cancelPayout = client.cancelPayout("somePayoutId"); 48 | 49 | // String groupId = payout.getGroupId(); 50 | PayoutGroup cancelPayouts = client.cancelPayouts("someGroupId"); 51 | } 52 | 53 | public void requestPayoutWebhookToBeResent() throws BitPayGenericException, BitPayApiException { 54 | Client client = ClientProvider.create(); 55 | 56 | client.requestPayoutNotification("somePayoutId"); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /examples/Payout/RecipientRequests.java: -------------------------------------------------------------------------------- 1 | package com.bitpay.sdk.examples.Payout; 2 | 3 | import com.bitpay.sdk.Client; 4 | import com.bitpay.sdk.exceptions.BitPayApiException; 5 | import com.bitpay.sdk.exceptions.BitPayGenericException; 6 | import com.bitpay.sdk.model.payout.PayoutRecipient; 7 | import com.bitpay.sdk.model.payout.PayoutRecipients; 8 | import com.bitpay.sdk.examples.ClientProvider; 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | public class RecipientRequests { 13 | 14 | public void inviteRecipients() throws BitPayGenericException, BitPayApiException { 15 | Client client = ClientProvider.create(); 16 | 17 | PayoutRecipient recipient1 = new PayoutRecipient(); 18 | PayoutRecipient recipient2 = new PayoutRecipient(); 19 | recipient1.setEmail("alice@email.com"); 20 | recipient1.setLabel("Alice"); 21 | recipient2.setEmail("bob@email.com"); 22 | recipient2.setLabel("Bob"); 23 | List recipients = new ArrayList<>(); 24 | recipients.add(recipient1); 25 | recipients.add(recipient2); 26 | 27 | PayoutRecipients payoutRecipients = new PayoutRecipients(recipients); 28 | 29 | List result = client.submitPayoutRecipients(payoutRecipients); 30 | } 31 | 32 | public void getRecipient() throws BitPayGenericException, BitPayApiException { 33 | Client client = ClientProvider.create(); 34 | 35 | PayoutRecipient recipient = client.getPayoutRecipient("someRecipientId"); 36 | 37 | List recipients = client.getPayoutRecipients("invited", null, null); 38 | } 39 | 40 | public void removeRecipient() throws BitPayGenericException, BitPayApiException { 41 | Client client = ClientProvider.create(); 42 | 43 | Boolean result = client.deletePayoutRecipient("somePayoutRecipientId"); 44 | } 45 | 46 | public void updateRecipient() throws BitPayGenericException, BitPayApiException { 47 | Client client = ClientProvider.create(); 48 | 49 | Boolean result = client.deletePayoutRecipient("somePayoutRecipientId"); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /examples/Pos/BillRequests.java: -------------------------------------------------------------------------------- 1 | package com.bitpay.sdk.examples.Pos; 2 | 3 | import com.bitpay.sdk.Client; 4 | import com.bitpay.sdk.exceptions.BitPayApiException; 5 | import com.bitpay.sdk.exceptions.BitPayGenericException; 6 | import com.bitpay.sdk.model.bill.Bill; 7 | import com.bitpay.sdk.examples.ClientProvider; 8 | 9 | public class BillRequests { 10 | 11 | public void createBill() throws BitPayGenericException, BitPayApiException { 12 | Client client = ClientProvider.createPos(); 13 | 14 | Bill bill = new Bill(); 15 | bill.setCurrency("USD"); 16 | bill.setEmail("some@email.com"); 17 | bill.setAddress1("SomeAddress"); 18 | bill.setCity("MyCity"); 19 | // ... 20 | 21 | Bill result = client.createBill(bill); 22 | } 23 | 24 | public void getBill() throws BitPayGenericException, BitPayApiException { 25 | Client client = ClientProvider.createPos(); 26 | 27 | Bill bill = client.getBill("someBillid"); 28 | } 29 | 30 | public void deliverBillViaEmail() throws BitPayGenericException, BitPayApiException { 31 | Client client = ClientProvider.createPos(); 32 | 33 | client.deliverBill("someBillId", "myBillToken"); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /examples/Pos/InvoiceRequests.java: -------------------------------------------------------------------------------- 1 | package com.bitpay.sdk.examples.Pos; 2 | 3 | import com.bitpay.sdk.Client; 4 | import com.bitpay.sdk.exceptions.BitPayApiException; 5 | import com.bitpay.sdk.exceptions.BitPayGenericException; 6 | import com.bitpay.sdk.model.invoice.Buyer; 7 | import com.bitpay.sdk.model.invoice.Invoice; 8 | import com.bitpay.sdk.examples.ClientProvider; 9 | 10 | public class InvoiceRequests { 11 | 12 | public void createInvoice() throws BitPayGenericException, BitPayApiException { 13 | Client client = ClientProvider.createPos(); 14 | 15 | Invoice invoice = new Invoice(); 16 | invoice.setFullNotifications(true); 17 | invoice.setExtendedNotifications(true); 18 | invoice.setNotificationUrl("https://test/lJnJg9WW7MtG9GZlPVdj"); 19 | invoice.setRedirectUrl("https://test/lJnJg9WW7MtG9GZlPVdj"); 20 | invoice.setNotificationEmail("my@email.com"); 21 | invoice.setBuyerSms("+12223334445"); 22 | 23 | Buyer buyer = new Buyer(); 24 | buyer.setName("Test"); 25 | buyer.setEmail("test@email.com"); 26 | buyer.setAddress1("168 General Grove"); 27 | buyer.setCountry("AD"); 28 | buyer.setLocality("Port Horizon"); 29 | buyer.setNotify(true); 30 | buyer.setPhone("+990123456789"); 31 | buyer.setPostalCode("KY7 1TH"); 32 | buyer.setRegion("New Port"); 33 | 34 | invoice.setBuyer(buyer); 35 | 36 | Invoice result = client.createInvoice(invoice); 37 | } 38 | 39 | public void getInvoice() throws BitPayGenericException, BitPayApiException { 40 | Client client = ClientProvider.createPos(); 41 | 42 | Invoice invoiceById = client.getInvoice("myInvoiceId"); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /examples/Public/RateRequests.java: -------------------------------------------------------------------------------- 1 | package com.bitpay.sdk.examples.Public; 2 | 3 | import com.bitpay.sdk.Client; 4 | import com.bitpay.sdk.exceptions.BitPayApiException; 5 | import com.bitpay.sdk.exceptions.BitPayGenericException; 6 | import com.bitpay.sdk.model.rate.Rate; 7 | import com.bitpay.sdk.model.rate.Rates; 8 | import com.bitpay.sdk.examples.ClientProvider; 9 | 10 | public class RateRequests { 11 | 12 | public void getRate() throws BitPayGenericException, BitPayApiException { 13 | Client client = ClientProvider.create(); 14 | 15 | Rates rates = client.getRates(); 16 | 17 | Rates currencyRates = client.getRates("BTC"); 18 | 19 | Rate currencyPairRate = client.getRate("BTC", "USD"); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /examples/Public/WalletRequests.java: -------------------------------------------------------------------------------- 1 | package com.bitpay.sdk.examples.Public; 2 | 3 | import com.bitpay.sdk.Client; 4 | import com.bitpay.sdk.exceptions.BitPayApiException; 5 | import com.bitpay.sdk.exceptions.BitPayGenericException; 6 | import com.bitpay.sdk.model.wallet.Wallet; 7 | import com.bitpay.sdk.examples.ClientProvider; 8 | import java.util.List; 9 | 10 | public class WalletRequests { 11 | 12 | public void getSupportedWallets() throws BitPayGenericException, BitPayApiException { 13 | Client client = ClientProvider.create(); 14 | 15 | List wallets = client.getSupportedWallets(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/ConfigFilePath.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk; 7 | 8 | /** 9 | * The type Config file path. 10 | */ 11 | public class ConfigFilePath { 12 | 13 | private final String value; 14 | 15 | /** 16 | * Instantiates a new Config file path. 17 | * 18 | * @param configFilePath the configFilePath 19 | */ 20 | public ConfigFilePath(final String configFilePath) { 21 | this.value = configFilePath; 22 | } 23 | 24 | /** 25 | * Value of config file path. 26 | * 27 | * @return the string 28 | */ 29 | public String value() { 30 | return this.value; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/Environment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk; 7 | 8 | import com.fasterxml.jackson.annotation.JsonValue; 9 | import java.util.Objects; 10 | 11 | /** 12 | * The enum Environment. 13 | */ 14 | public enum Environment { 15 | 16 | /** 17 | * Test environment. 18 | */ 19 | TEST("Test"), 20 | 21 | /** 22 | * Prod environment. 23 | */ 24 | PROD("Prod"); 25 | 26 | @JsonValue 27 | private final String value; 28 | 29 | Environment(String value) { 30 | this.value = value; 31 | } 32 | 33 | /** 34 | * Get Environment from value. 35 | * 36 | * @param text the text 37 | * @return the environment 38 | */ 39 | public static Environment fromValue(final String text) { 40 | if (Objects.isNull(text)) { 41 | return null; 42 | } 43 | 44 | for (final Environment item : values()) { 45 | if (String.valueOf(item.value).equalsIgnoreCase(text)) { 46 | return item; 47 | } 48 | } 49 | 50 | return null; 51 | } 52 | 53 | public String toString() { 54 | return String.valueOf(this.value); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/PosToken.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk; 7 | 8 | /** 9 | * The type Pos token. 10 | */ 11 | public class PosToken { 12 | 13 | private final String value; 14 | 15 | /** 16 | * Instantiates a new Pos token. 17 | * 18 | * @param value the value 19 | */ 20 | public PosToken(final String value) { 21 | this.value = value; 22 | } 23 | 24 | /** 25 | * Get Pos token value. 26 | * 27 | * @return the string 28 | */ 29 | public String value() { 30 | return this.value; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/PrivateKey.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk; 7 | 8 | /** 9 | * The type Private key. 10 | */ 11 | public class PrivateKey { 12 | 13 | private final String value; 14 | 15 | /** 16 | * Instantiates a new Private key. 17 | * 18 | * @param value the value 19 | */ 20 | public PrivateKey(final String value) { 21 | this.value = value; 22 | } 23 | 24 | /** 25 | * Get Private Key value. 26 | * 27 | * @return the string 28 | */ 29 | public String value() { 30 | return this.value; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/client/HttpRequestFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.client; 7 | 8 | import org.apache.http.client.methods.HttpDelete; 9 | import org.apache.http.client.methods.HttpGet; 10 | import org.apache.http.client.methods.HttpPost; 11 | import org.apache.http.client.methods.HttpPut; 12 | 13 | /** 14 | * The type Http request factory. 15 | */ 16 | public class HttpRequestFactory { 17 | 18 | /** 19 | * Create http get. 20 | * 21 | * @param fullUrl the full url 22 | * @return the http get 23 | */ 24 | public HttpGet createHttpGet(String fullUrl) { 25 | return new HttpGet(fullUrl); 26 | } 27 | 28 | /** 29 | * Create http delete. 30 | * 31 | * @param fullUrl the full url 32 | * @return the http delete 33 | */ 34 | public HttpDelete createHttpDelete(String fullUrl) { 35 | return new HttpDelete(fullUrl); 36 | } 37 | 38 | /** 39 | * Create http post. 40 | * 41 | * @param fullUrl the full url 42 | * @return the http post 43 | */ 44 | public HttpPost createHttpPost(String fullUrl) { 45 | return new HttpPost(fullUrl); 46 | } 47 | 48 | /** 49 | * Create http put. 50 | * 51 | * @param fullUrl the full url 52 | * @return the http put 53 | */ 54 | public HttpPut createHttpPut(String fullUrl) { 55 | return new HttpPut(fullUrl); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/client/HttpResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.client; 7 | 8 | import java.util.Map; 9 | 10 | public class HttpResponse { 11 | 12 | private final Integer code; 13 | private final String body; 14 | private final Map headers; 15 | private final String locale; 16 | private final String httpVersion; 17 | 18 | public HttpResponse( 19 | Integer code, 20 | String body, 21 | Map headers, 22 | String locale, 23 | String httpVersion 24 | ) { 25 | this.code = code; 26 | this.body = body; 27 | this.headers = headers; 28 | this.locale = locale; 29 | this.httpVersion = httpVersion; 30 | } 31 | 32 | public Integer getCode() { 33 | return this.code; 34 | } 35 | 36 | public String getBody() { 37 | return this.body; 38 | } 39 | 40 | public Map getHeaders() { 41 | return this.headers; 42 | } 43 | 44 | public String getLocale() { 45 | return this.locale; 46 | } 47 | 48 | public String getHttpVersion() { 49 | return this.httpVersion; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/client/HttpResponseProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.client; 7 | 8 | import com.bitpay.sdk.exceptions.BitPayApiException; 9 | import com.bitpay.sdk.exceptions.BitPayExceptionProvider; 10 | import java.io.IOException; 11 | import java.util.Arrays; 12 | import java.util.stream.Collectors; 13 | import org.apache.http.Header; 14 | import org.apache.http.HttpEntity; 15 | import org.apache.http.util.EntityUtils; 16 | 17 | public class HttpResponseProvider { 18 | 19 | public static HttpResponse fromApacheHttpResponse(org.apache.http.HttpResponse apacheHttpResponse) 20 | throws BitPayApiException { 21 | try { 22 | final HttpEntity entity = apacheHttpResponse.getEntity(); 23 | String body = EntityUtils.toString(entity, "UTF-8"); 24 | 25 | return new HttpResponse( 26 | apacheHttpResponse.getStatusLine().getStatusCode(), 27 | body, 28 | Arrays.stream(apacheHttpResponse.getAllHeaders()) 29 | .collect(Collectors.toMap(Header::getName, Header::getValue)), 30 | apacheHttpResponse.getLocale().toString(), 31 | apacheHttpResponse.getStatusLine().getProtocolVersion().toString() 32 | ); 33 | 34 | } catch (IOException e) { 35 | BitPayExceptionProvider.throwApiExceptionWithMessage(e.getMessage()); 36 | throw new RuntimeException(e.getMessage()); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/client/ResourceClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.client; 7 | 8 | public interface ResourceClient { 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/client/WalletClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.client; 7 | 8 | import com.bitpay.sdk.exceptions.BitPayApiException; 9 | import com.bitpay.sdk.exceptions.BitPayExceptionProvider; 10 | import com.bitpay.sdk.exceptions.BitPayGenericException; 11 | import com.bitpay.sdk.model.wallet.Wallet; 12 | import com.bitpay.sdk.util.JsonMapperFactory; 13 | import com.fasterxml.jackson.core.JsonProcessingException; 14 | import java.util.Arrays; 15 | import java.util.List; 16 | import java.util.Objects; 17 | 18 | /** 19 | * The type Wallet client. 20 | */ 21 | public class WalletClient implements ResourceClient { 22 | 23 | private static WalletClient instance; 24 | private final BitPayClient bitPayClient; 25 | 26 | /** 27 | * Instantiates a new Wallet client. 28 | * 29 | * @param bitPayClient the bit pay client 30 | */ 31 | private WalletClient(BitPayClient bitPayClient) { 32 | this.bitPayClient = bitPayClient; 33 | } 34 | 35 | /** 36 | * Factory method for Wallet Client. 37 | * 38 | * @param bitPayClient BitPay Client 39 | * @return WalletClient 40 | */ 41 | public static WalletClient getInstance(BitPayClient bitPayClient) { 42 | if (Objects.isNull(instance)) { 43 | instance = new WalletClient(bitPayClient); 44 | } 45 | 46 | return instance; 47 | } 48 | 49 | /** 50 | * Retrieve all supported wallets. 51 | * 52 | * @return A list of wallet objets. 53 | * @throws BitPayGenericException BitPayGenericException class 54 | * @throws BitPayApiException BitPayApiException class 55 | */ 56 | public List getSupportedWallets() throws BitPayApiException, BitPayGenericException { 57 | List wallets = null; 58 | 59 | HttpResponse response = this.bitPayClient.get("supportedwallets"); 60 | String jsonResponse = ResponseParser.getJsonDataFromJsonResponse(response.getBody()); 61 | 62 | try { 63 | wallets = Arrays.asList( 64 | JsonMapperFactory.create().readValue(jsonResponse, Wallet[].class) 65 | ); 66 | } catch (JsonProcessingException e) { 67 | BitPayExceptionProvider.throwDeserializeResourceException("Wallet", e.getMessage()); 68 | } 69 | 70 | return wallets; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/exceptions/BitPayApiException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.exceptions; 7 | 8 | public class BitPayApiException extends BitPayException { 9 | 10 | private static final long serialVersionUID = 8211452784073681895L; 11 | 12 | private final String code; 13 | 14 | public BitPayApiException(String message, String code) { 15 | super(message); 16 | this.code = code; 17 | } 18 | 19 | /** 20 | *

An error code consists of 6 digits.

21 | *

The first two digits of an error code represent the HTTP method that was used to call it.

22 | *

The next two digits refer to the resource that was impacted.

23 | *

The last two digits refer to the specific error.

24 | *

eg. 010103 - Missing parameters for Invoice POST request.

25 | * 26 | * @return String 27 | */ 28 | public String getCode() { 29 | return this.code; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/exceptions/BitPayException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.exceptions; 7 | 8 | /** 9 | * General BitPay Exception which is inherited by all other exceptions. 10 | * 11 | * @see Rest API Error Codes 12 | */ 13 | public class BitPayException extends Exception { 14 | 15 | private static final long serialVersionUID = -5407556346434827903L; 16 | 17 | /** 18 | * Construct the BitPayException. 19 | * 20 | * @param message String [optional] The Exception message. 21 | */ 22 | public BitPayException(String message) { 23 | super(message); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/exceptions/BitPayGenericException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.exceptions; 7 | 8 | public class BitPayGenericException extends BitPayException { 9 | 10 | private static final long serialVersionUID = -4496707441469582396L; 11 | 12 | public BitPayGenericException(String message) { 13 | super(message); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/exceptions/BitPayValidationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.exceptions; 7 | 8 | public class BitPayValidationException extends BitPayGenericException { 9 | 10 | private static final long serialVersionUID = -6721535639566485766L; 11 | 12 | public BitPayValidationException(String message) { 13 | super(message); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/exceptions/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | /** 7 | * BitPay SDK Exceptions. 8 | */ 9 | package com.bitpay.sdk.exceptions; 10 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/logger/BitPayLogger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.logger; 7 | 8 | public interface BitPayLogger { 9 | 10 | void logRequest( 11 | String method, 12 | String endpoint, 13 | String json 14 | ); 15 | 16 | void logResponse( 17 | String method, 18 | String endpoint, 19 | String json 20 | ); 21 | 22 | void logError(String message); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/logger/EmptyLogger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.logger; 7 | 8 | public class EmptyLogger implements BitPayLogger { 9 | 10 | @Override 11 | public void logRequest(String method, String endpoint, String json) { 12 | } 13 | 14 | @Override 15 | public void logResponse(String method, String endpoint, String json) { 16 | } 17 | 18 | @Override 19 | public void logError(String message) { 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/logger/LoggerProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.logger; 7 | 8 | import java.util.Objects; 9 | 10 | public class LoggerProvider { 11 | 12 | private static BitPayLogger logger = null; 13 | 14 | private LoggerProvider() { 15 | } 16 | 17 | public static BitPayLogger getLogger() { 18 | if (Objects.isNull(logger)) { 19 | logger = new EmptyLogger(); 20 | } 21 | 22 | return logger; 23 | } 24 | 25 | /** 26 | * Set BitPayLogger. 27 | * 28 | * @param bitPayLogger BitPayLogger 29 | */ 30 | public static void setLogger(BitPayLogger bitPayLogger) { 31 | logger = bitPayLogger; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/logger/Slf4jLogger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | //package com.bitpay.sdk.logger; 7 | // 8 | //import org.slf4j.LoggerFactory; 9 | // 10 | //public class Slf4jLogger implements BitPayLogger { 11 | // 12 | // private static final org.slf4j.Logger logger = LoggerFactory.getLogger(Slf4jLogger.class); 13 | // 14 | // @Override 15 | // public void logRequest(String method, String endpoint, String json) { 16 | // logger.info("Request method: " + method + " Endpoint: " + endpoint + " Json: " + json); 17 | // } 18 | // 19 | // @Override 20 | // public void logResponse(String method, String endpoint, String json) { 21 | // logger.info("Response method: " + method + " Endpoint: " + endpoint + " Json: " + json); 22 | // } 23 | // 24 | // @Override 25 | // public void logError(String message) { 26 | // logger.error(message); 27 | // } 28 | //} 29 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/model/Facade.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.model; 7 | 8 | import java.util.Objects; 9 | 10 | /** 11 | * Facades named collections of capabilities that can be granted, 12 | * such as the ability to create invoices or grant refunds. 13 | * In the ticket analogy, this corresponds to the ticket 'level', 14 | * where a 'VIP' ticket would confer broader access than a 'Standard' level ticket. When registering an Identity, 15 | * it is against a specific facade. 16 | * Best practices suggest that the requested facade should be limited to the minimum level that 17 | * grants the required capabilities. 18 | * 19 | * @see REST API facades 20 | */ 21 | public enum Facade { 22 | /** 23 | * The broadest set of capabilities against a merchant organization. 24 | * Allows for create, search, and view actions for Invoices and Bills; ledger download, 25 | * as well as the creation of new merchant or pos tokens associated with the account. 26 | */ 27 | MERCHANT("merchant"), 28 | /** 29 | * This is the facade which allows merchant to access the Payouts related resources and corresponding endpoints. 30 | * Access to this facade is not enabled by default, for more information please contact our support channel. 31 | */ 32 | PAYOUT("payout"), 33 | /** 34 | * Limited to creating new invoice or bills and search specific invoices or bills based on their id for 35 | * the merchant's organization. 36 | */ 37 | POS("pos"); 38 | 39 | protected final String value; 40 | 41 | Facade(String value) { 42 | this.value = value; 43 | } 44 | 45 | /** 46 | * Get Facade from value. 47 | * 48 | * @param text the text 49 | * @return the facade 50 | */ 51 | public static Facade fromValue(final String text) { 52 | if (Objects.isNull(text)) { 53 | return null; 54 | } 55 | 56 | for (final Facade item : values()) { 57 | if (String.valueOf(item.value).equalsIgnoreCase(text)) { 58 | return item; 59 | } 60 | } 61 | 62 | return null; 63 | } 64 | 65 | public String toString() { 66 | return String.valueOf(this.value); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/model/ModelConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.model; 7 | 8 | public interface ModelConfiguration { 9 | 10 | /** 11 | * Used for json mapping. We want to give possibility to change specific field for null (eg. update model) 12 | * together with @JsonInclude(JsonInclude.Include.NON_DEFAULT) 13 | */ 14 | String DEFAULT_NON_SENT_VALUE = ""; 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/model/Policy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.model; 7 | 8 | import com.fasterxml.jackson.annotation.JsonIgnore; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonProperty; 11 | import java.util.List; 12 | 13 | /** 14 | * The type Policy. 15 | * 16 | * @see Tokens concept 17 | */ 18 | @JsonIgnoreProperties(ignoreUnknown = true) 19 | public class Policy { 20 | 21 | protected String policy; 22 | protected String method; 23 | protected List params; 24 | 25 | /** 26 | * Instantiates a new Policy. 27 | */ 28 | public Policy() { 29 | } 30 | 31 | /** 32 | * Gets policy. Can be "sin", "access", "events", "id", or "session". 33 | * 34 | * @return the policy 35 | */ 36 | @JsonIgnore 37 | public String getPolicy() { 38 | return this.policy; 39 | } 40 | 41 | /** 42 | * Sets policy. Can be "sin", "access", "events", "id", or "session". 43 | * 44 | * @param policy the policy 45 | */ 46 | @JsonProperty("policy") 47 | public void setPolicy(final String policy) { 48 | this.policy = policy; 49 | } 50 | 51 | /** 52 | * Gets method. Can be "requireSin", "requireFacadeAccess", "allowEventStream", "invalidated", "inactive", 53 | * "unclaimed", "requireSession". 54 | * 55 | * @return the method 56 | */ 57 | @JsonIgnore 58 | public String getMethod() { 59 | return this.method; 60 | } 61 | 62 | /** 63 | * Sets method. Can be "requireSin", "requireFacadeAccess", "allowEventStream", "invalidated", "inactive", 64 | * "unclaimed", "requireSession". 65 | * 66 | * @param method the method 67 | */ 68 | @JsonProperty("method") 69 | public void setMethod(final String method) { 70 | this.method = method; 71 | } 72 | 73 | /** 74 | * Gets params. Can be "support", SIN value, or null. 75 | * 76 | * @return the params 77 | */ 78 | @JsonIgnore 79 | public List getParams() { 80 | return this.params; 81 | } 82 | 83 | /** 84 | * Sets params. Can be "support", SIN value, or null. 85 | * 86 | * @param params the params 87 | */ 88 | @JsonProperty("params") 89 | public void setParams(final List params) { 90 | this.params = params; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/model/bill/BillStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.model.bill; 7 | 8 | /** 9 | * The type Bill status. 10 | * 11 | * @see REST API Bills 12 | */ 13 | public class BillStatus { 14 | 15 | /** 16 | * The constant Draft. 17 | */ 18 | public static final String Draft = "draft"; 19 | /** 20 | * The constant Sent. 21 | */ 22 | public static final String Sent = "sent"; 23 | /** 24 | * The constant New. 25 | */ 26 | public static final String New = "new"; 27 | /** 28 | * The constant Paid. 29 | */ 30 | public static final String Paid = "paid"; 31 | /** 32 | * The constant Complete. 33 | */ 34 | public static final String Complete = "complete"; 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/model/bill/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | /** 7 | * BitPay SDK Bill. 8 | */ 9 | package com.bitpay.sdk.model.bill; 10 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/model/invoice/InvoiceItemizedDetails.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.model.invoice; 7 | 8 | import com.bitpay.sdk.model.ModelConfiguration; 9 | import com.fasterxml.jackson.annotation.JsonIgnore; 10 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 11 | import com.fasterxml.jackson.annotation.JsonProperty; 12 | 13 | /** 14 | * The type Invoice itemized details. 15 | * 16 | * @see REST API Invoices 17 | */ 18 | @JsonIgnoreProperties(ignoreUnknown = true) 19 | public class InvoiceItemizedDetails { 20 | protected Double amount; 21 | protected String description = ModelConfiguration.DEFAULT_NON_SENT_VALUE; 22 | protected Boolean isFee; 23 | 24 | /** 25 | * Instantiates a new Invoice itemized details. 26 | */ 27 | public InvoiceItemizedDetails() { 28 | } 29 | 30 | /** 31 | * Gets the amount of currency. 32 | * 33 | * @return the amount 34 | */ 35 | @JsonIgnore 36 | public Double getAmount() { 37 | return this.amount; 38 | } 39 | 40 | /** 41 | * Sets the amount of currency. 42 | * 43 | * @param amount the amount 44 | */ 45 | @JsonProperty("amount") 46 | public void setAmount(Double amount) { 47 | this.amount = amount; 48 | } 49 | 50 | /** 51 | * Gets description. Display string for the item. 52 | * 53 | * @return the description 54 | */ 55 | @JsonIgnore 56 | public String getDescription() { 57 | return this.description; 58 | } 59 | 60 | /** 61 | * Sets description. Display string for the item. 62 | * 63 | * @param description the description 64 | */ 65 | @JsonProperty("description") 66 | public void setDescription(String description) { 67 | this.description = description; 68 | } 69 | 70 | /** 71 | * Gets is fee. Indicates whether or not the item is considered a fee/tax or part of the main purchase. 72 | * 73 | * @return the is fee 74 | */ 75 | @JsonIgnore 76 | public Boolean getIsFee() { 77 | return this.isFee; 78 | } 79 | 80 | /** 81 | * Sets is fee. Indicates whether or not the item is considered a fee/tax or part of the main purchase. 82 | * 83 | * @param isFee the is fee 84 | */ 85 | @JsonProperty("IsFee") 86 | public void setIsFee(Boolean isFee) { 87 | this.isFee = isFee; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/model/invoice/InvoiceRefundAddress.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.model.invoice; 7 | 8 | import java.time.ZonedDateTime; 9 | 10 | public class InvoiceRefundAddress { 11 | 12 | protected String type; 13 | protected ZonedDateTime date; 14 | protected Integer tag; 15 | protected String email; 16 | 17 | public String getType() { 18 | return this.type; 19 | } 20 | 21 | public void setType(String type) { 22 | this.type = type; 23 | } 24 | 25 | public ZonedDateTime getDate() { 26 | return this.date; 27 | } 28 | 29 | public void setDate(ZonedDateTime date) { 30 | this.date = date; 31 | } 32 | 33 | public Integer getTag() { 34 | return this.tag; 35 | } 36 | 37 | public void setTag(Integer tag) { 38 | this.tag = tag; 39 | } 40 | 41 | public String getEmail() { 42 | return this.email; 43 | } 44 | 45 | public void setEmail(String email) { 46 | this.email = email; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/model/invoice/InvoiceUniversalCodes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.model.invoice; 7 | 8 | import com.bitpay.sdk.model.ModelConfiguration; 9 | import com.fasterxml.jackson.annotation.JsonIgnore; 10 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 11 | import com.fasterxml.jackson.annotation.JsonProperty; 12 | 13 | /** 14 | * Object containing wallet-specific URLs for payment protocol. 15 | * 16 | * @see REST API Invoices 17 | */ 18 | @JsonIgnoreProperties(ignoreUnknown = true) 19 | public class InvoiceUniversalCodes { 20 | 21 | protected String paymentString = ModelConfiguration.DEFAULT_NON_SENT_VALUE; 22 | protected String verificationLink = ModelConfiguration.DEFAULT_NON_SENT_VALUE; 23 | 24 | /** 25 | * Instantiates a new Invoice universal codes. 26 | */ 27 | public InvoiceUniversalCodes() { 28 | } 29 | 30 | /** 31 | * Gets payment protocol URL for selected wallet, defaults to BitPay URL if no wallet selected. 32 | * 33 | * @return the bitpay 34 | */ 35 | @JsonIgnore 36 | public String getBitpay() { 37 | return this.paymentString; 38 | } 39 | 40 | /** 41 | * Sets payment protocol URL for selected wallet, defaults to BitPay URL if no wallet selected. 42 | * 43 | * @param paymentString the payment string 44 | */ 45 | @JsonProperty("paymentString") 46 | public void setBitpay(String paymentString) { 47 | this.paymentString = paymentString; 48 | } 49 | 50 | /** 51 | * Gets link to bring user to BitPay ID flow, only present when bitpayIdRequired is true. 52 | * 53 | * @return the verification link 54 | */ 55 | @JsonIgnore 56 | public String getVerificationLink() { 57 | return this.verificationLink; 58 | } 59 | 60 | /** 61 | * Sets link to bring user to BitPay ID flow, only present when bitpayIdRequired is true. 62 | * 63 | * @param verificationLink the verification link 64 | */ 65 | @JsonProperty("verificationLink") 66 | public void setVerificationLink(String verificationLink) { 67 | this.verificationLink = verificationLink; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/model/invoice/MinerFeesItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.model.invoice; 7 | 8 | import com.fasterxml.jackson.annotation.JsonIgnore; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonProperty; 11 | 12 | /** 13 | * The type Miner fees item. 14 | * 15 | * @see REST API Invoice 16 | */ 17 | @JsonIgnoreProperties(ignoreUnknown = true) 18 | public class MinerFeesItem { 19 | 20 | protected Double satoshisPerByte; 21 | protected Integer totalFee; 22 | protected Double fiatAmount; 23 | 24 | /** 25 | * Instantiates a new Miner fees item. 26 | */ 27 | public MinerFeesItem() { 28 | } 29 | 30 | /** 31 | * Gets satoshis per byte. 32 | * 33 | * @return the satoshis per byte 34 | */ 35 | @JsonIgnore 36 | public Double getSatoshisPerByte() { 37 | return this.satoshisPerByte; 38 | } 39 | 40 | /** 41 | * Sets satoshis per byte. 42 | * 43 | * @param satoshisPerByte the satoshis per byte 44 | */ 45 | @JsonProperty("satoshisPerByte") 46 | public void setSatoshisPerByte(Double satoshisPerByte) { 47 | this.satoshisPerByte = satoshisPerByte; 48 | } 49 | 50 | /** 51 | * Gets total fee. 52 | * 53 | * @return the total fee 54 | */ 55 | @JsonIgnore 56 | public Integer getTotalFee() { 57 | return this.totalFee; 58 | } 59 | 60 | /** 61 | * Sets total fee. 62 | * 63 | * @param totalFee the total fee 64 | */ 65 | @JsonProperty("totalFee") 66 | public void setTotalFee(Integer totalFee) { 67 | this.totalFee = totalFee; 68 | } 69 | 70 | /** 71 | * Gets fiat amount. 72 | * 73 | * @return the fiat amount 74 | */ 75 | @JsonIgnore 76 | public Double getFiatAmount() { 77 | return this.fiatAmount; 78 | } 79 | 80 | /** 81 | * Sets fiat amount. 82 | * 83 | * @param fiatAmount the fiat amount 84 | */ 85 | @JsonProperty("fiatAmount") 86 | public void setFiatAmount(Double fiatAmount) { 87 | this.fiatAmount = fiatAmount; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/model/invoice/RefundStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.model.invoice; 7 | 8 | /** 9 | * The type Refund status. 10 | * 11 | * @see REST API Refunds 12 | */ 13 | public class RefundStatus { 14 | 15 | /** 16 | * No funds deducted, refund will not proceed automatically - 17 | * the status must be changed via Update a Refund Request. 18 | */ 19 | public static final String PREVIEW = "preview"; 20 | /** 21 | * Funds deducted/allocated if immediate, 22 | * will proceed when transactions are confirmed and the required data is collected. 23 | */ 24 | public static final String CREATED = "created"; 25 | /** 26 | * Refund is in process of being fulfilled. 27 | */ 28 | public static final String PENDING = "pending"; 29 | /** 30 | * Refund was canceled by merchant action. Immediate refunds cannot be canceled outside of preview state. 31 | */ 32 | public static final String CANCELED = "canceled"; 33 | /** 34 | * Refund was successfully processed. 35 | */ 36 | public static final String SUCCESS = "success"; 37 | /** 38 | * Refund failed during processing (this is really more of an internal state). 39 | */ 40 | public static final String FAILURE = "failure"; 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/model/invoice/Shopper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.model.invoice; 7 | 8 | import com.bitpay.sdk.model.ModelConfiguration; 9 | import com.fasterxml.jackson.annotation.JsonIgnore; 10 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 11 | import com.fasterxml.jackson.annotation.JsonInclude; 12 | import com.fasterxml.jackson.annotation.JsonProperty; 13 | 14 | /** 15 | * The type Shopper. 16 | * 17 | * @see REST API Invoices 18 | */ 19 | @JsonIgnoreProperties(ignoreUnknown = true) 20 | public class Shopper { 21 | 22 | protected String user = ModelConfiguration.DEFAULT_NON_SENT_VALUE; 23 | 24 | /** 25 | * Instantiates a new Shopper. 26 | */ 27 | public Shopper() { 28 | } 29 | 30 | /** 31 | * Gets name. 32 | * 33 | * @return the name 34 | */ 35 | @JsonIgnore 36 | @JsonInclude(JsonInclude.Include.NON_DEFAULT) 37 | public String getName() { 38 | return this.user; 39 | } 40 | 41 | /** 42 | * Sets name. 43 | * 44 | * @param user the user 45 | */ 46 | @JsonProperty("user") 47 | public void setName(String user) { 48 | this.user = user; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/model/invoice/SupportedTransactionCurrency.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.model.invoice; 7 | 8 | import com.bitpay.sdk.model.ModelConfiguration; 9 | import com.fasterxml.jackson.annotation.JsonIgnore; 10 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 11 | import com.fasterxml.jackson.annotation.JsonInclude; 12 | import com.fasterxml.jackson.annotation.JsonProperty; 13 | 14 | /** 15 | * The currency that may be used to pay this invoice. The values are objects with an "enabled" boolean and option. 16 | * An extra "reason" parameter is added in the object if a cryptocurrency is disabled on a specific invoice. 17 | * 18 | * @see REST API Invoices 19 | */ 20 | @JsonIgnoreProperties(ignoreUnknown = true) 21 | public class SupportedTransactionCurrency { 22 | 23 | protected Boolean enabled; 24 | protected String reason = ModelConfiguration.DEFAULT_NON_SENT_VALUE; 25 | 26 | /** 27 | * Instantiates a new Supported transaction currency. 28 | */ 29 | public SupportedTransactionCurrency() { 30 | } 31 | 32 | /** 33 | * Gets enabled. 34 | * 35 | * @return the enabled 36 | */ 37 | @JsonIgnore 38 | @JsonInclude(JsonInclude.Include.NON_DEFAULT) 39 | public Boolean getEnabled() { 40 | return this.enabled; 41 | } 42 | 43 | /** 44 | * Sets enabled. 45 | * 46 | * @param enabled the enabled 47 | */ 48 | @JsonProperty("enabled") 49 | public void setEnabled(Boolean enabled) { 50 | this.enabled = enabled; 51 | } 52 | 53 | /** 54 | * Gets reason. 55 | * 56 | * @return the reason 57 | */ 58 | @JsonIgnore 59 | @JsonInclude(JsonInclude.Include.NON_DEFAULT) 60 | public String getReason() { 61 | return this.reason; 62 | } 63 | 64 | /** 65 | * Sets reason. 66 | * 67 | * @param reason the reason 68 | */ 69 | @JsonProperty("reason") 70 | public void setReason(String reason) { 71 | this.reason = reason; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/model/invoice/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | /** 7 | * BitPay SDK Invoice. 8 | */ 9 | package com.bitpay.sdk.model.invoice; 10 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/model/ledger/Ledger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.model.ledger; 7 | 8 | import com.bitpay.sdk.model.ModelConfiguration; 9 | import com.fasterxml.jackson.annotation.JsonIgnore; 10 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 11 | import com.fasterxml.jackson.annotation.JsonInclude; 12 | import com.fasterxml.jackson.annotation.JsonProperty; 13 | 14 | /** 15 | * Ledgers are records of money movement. 16 | * 17 | * @see REST API Ledgers 18 | */ 19 | @JsonIgnoreProperties(ignoreUnknown = true) 20 | public class Ledger { 21 | 22 | protected String currency = ModelConfiguration.DEFAULT_NON_SENT_VALUE; 23 | protected Double balance; 24 | 25 | /** 26 | * Instantiates a new Ledger. 27 | */ 28 | public Ledger() { 29 | } 30 | 31 | /** 32 | * Gets ISO 4217 3-character currency code for your merchant account. 33 | * 34 | * @return the currency 35 | */ 36 | @JsonIgnore 37 | @JsonInclude(JsonInclude.Include.NON_DEFAULT) 38 | public String getCurrency() { 39 | return this.currency; 40 | } 41 | 42 | /** 43 | * Sets ISO 4217 3-character currency code for your merchant account. 44 | * 45 | * @param currency the currency 46 | */ 47 | @JsonProperty("currency") 48 | public void setCurrency(String currency) { 49 | this.currency = currency; 50 | } 51 | 52 | /** 53 | * Gets balance of the ledger. 54 | * 55 | * @return the balance 56 | */ 57 | @JsonIgnore 58 | @JsonInclude(JsonInclude.Include.NON_DEFAULT) 59 | public Double getBalance() { 60 | return this.balance; 61 | } 62 | 63 | /** 64 | * Sets balance of the ledger. 65 | * 66 | * @param balance the balance 67 | */ 68 | @JsonProperty("balance") 69 | public void setBalance(Double balance) { 70 | this.balance = balance; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/model/ledger/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | /** 7 | * BitPay SDK Exceptions. 8 | */ 9 | package com.bitpay.sdk.model.ledger; 10 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/model/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | /** 7 | * BitPay SDK Model. 8 | */ 9 | package com.bitpay.sdk.model; 10 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/model/payout/PayoutGroup.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.model.payout; 7 | 8 | import com.fasterxml.jackson.annotation.JsonAlias; 9 | import com.fasterxml.jackson.annotation.JsonProperty; 10 | import java.util.Collections; 11 | import java.util.List; 12 | 13 | /** 14 | * The Payout group response for create and cancel. 15 | * 16 | * @see REST API Create Payouts 17 | * @see REST API Cancel Payouts 18 | */ 19 | public class PayoutGroup { 20 | 21 | @JsonProperty("created") 22 | @JsonAlias("cancelled") 23 | protected List payouts = Collections.emptyList(); 24 | protected List failed = Collections.emptyList(); 25 | 26 | public PayoutGroup() { 27 | } 28 | 29 | public PayoutGroup( 30 | final List payouts, 31 | final List failed 32 | ) { 33 | this.payouts = payouts; 34 | this.failed = failed; 35 | } 36 | 37 | public List getPayouts() { 38 | return this.payouts; 39 | } 40 | 41 | public List getFailed() { 42 | return this.failed; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/model/payout/PayoutGroupFailed.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.model.payout; 7 | 8 | /** 9 | * The object with information about not created/cancelled payout. 10 | * 11 | * @see REST API Create Payouts 12 | * @see REST API Cancel Payouts 13 | */ 14 | public class PayoutGroupFailed { 15 | 16 | public String errMessage; 17 | public String payoutId; 18 | public String payee; 19 | 20 | public PayoutGroupFailed() { 21 | } 22 | 23 | public PayoutGroupFailed( 24 | final String errMessage, 25 | final String payoutId, 26 | final String payee 27 | ) { 28 | this.errMessage = errMessage; 29 | this.payoutId = payoutId; 30 | this.payee = payee; 31 | } 32 | 33 | public String getErrMessage() { 34 | return this.errMessage; 35 | } 36 | 37 | public String getPayoutId() { 38 | return this.payoutId; 39 | } 40 | 41 | public String getPayee() { 42 | return this.payee; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/model/payout/PayoutStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.model.payout; 7 | 8 | /** 9 | * The type Payout status. 10 | * 11 | * @see REST API Payouts 12 | */ 13 | public class PayoutStatus { 14 | /** 15 | * The constant New. 16 | */ 17 | public static final String New = "new"; 18 | /** 19 | * The constant Funded. 20 | */ 21 | public static final String Funded = "funded"; 22 | /** 23 | * The constant Processing. 24 | */ 25 | public static final String Processing = "processing"; 26 | /** 27 | * The constant Complete. 28 | */ 29 | public static final String Complete = "complete"; 30 | /** 31 | * The constant Failed. 32 | */ 33 | public static final String Failed = "failed"; 34 | /** 35 | * The constant Cancelled. 36 | */ 37 | public static final String Cancelled = "cancelled"; 38 | /** 39 | * The constant Paid. 40 | */ 41 | public static final String Paid = "paid"; 42 | /** 43 | * The constant Unpaid. 44 | */ 45 | public static final String Unpaid = "unpaid"; 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/model/payout/RecipientStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.model.payout; 7 | 8 | /** 9 | * The type Recipient status. 10 | * 11 | * @see REST API Payouts 12 | */ 13 | public class RecipientStatus { 14 | 15 | /** 16 | * The constant INVITED. 17 | */ 18 | public static final String INVITED = "invited"; 19 | /** 20 | * The constant UNVERIFIED. 21 | */ 22 | public static final String UNVERIFIED = "unverified"; 23 | /** 24 | * The constant VERIFIED. 25 | */ 26 | public static final String VERIFIED = "verified"; 27 | /** 28 | * The constant ACTIVE. 29 | */ 30 | public static final String ACTIVE = "active"; 31 | /** 32 | * The constant PAUSED. 33 | */ 34 | public static final String PAUSED = "paused"; 35 | /** 36 | * The constant REMOVED. 37 | */ 38 | public static final String REMOVED = "removed"; 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/model/payout/RecipientWebhook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.model.payout; 7 | 8 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 9 | 10 | /** 11 | * The type Recipient webhook. 12 | * 13 | * @see Recipient Webhook 14 | */ 15 | @JsonIgnoreProperties(ignoreUnknown = true) 16 | class RecipientWebhook { 17 | 18 | protected String email; 19 | protected String label; 20 | protected String status; 21 | protected String id; 22 | protected String shopperId; 23 | 24 | public String getEmail() { 25 | return this.email; 26 | } 27 | 28 | public void setEmail(String email) { 29 | this.email = email; 30 | } 31 | 32 | public String getLabel() { 33 | return this.label; 34 | } 35 | 36 | public void setLabel(String label) { 37 | this.label = label; 38 | } 39 | 40 | public String getStatus() { 41 | return this.status; 42 | } 43 | 44 | public void setStatus(String status) { 45 | this.status = status; 46 | } 47 | 48 | public String getId() { 49 | return this.id; 50 | } 51 | 52 | public void setId(String id) { 53 | this.id = id; 54 | } 55 | 56 | public String getShopperId() { 57 | return this.shopperId; 58 | } 59 | 60 | public void setShopperId(String shopperId) { 61 | this.shopperId = shopperId; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/model/payout/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | /** 7 | * BitPay SDK Payout. 8 | */ 9 | package com.bitpay.sdk.model.payout; 10 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/model/rate/Rates.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.model.rate; 7 | 8 | import com.bitpay.sdk.client.RateClient; 9 | import com.bitpay.sdk.exceptions.BitPayApiException; 10 | import com.bitpay.sdk.exceptions.BitPayGenericException; 11 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 12 | import java.util.List; 13 | 14 | /** 15 | * Rates are exchange rates, representing the number of fiat currency units equivalent to one BTC. 16 | * 17 | * @see REST API Rates 18 | */ 19 | @JsonIgnoreProperties(ignoreUnknown = true) 20 | public class Rates { 21 | 22 | protected List rates; 23 | 24 | /** 25 | * Instantiates a new Rates. 26 | * 27 | * @param rates the rates 28 | */ 29 | public Rates(List rates) { 30 | this.rates = rates; 31 | } 32 | 33 | /** 34 | * Gets rates. 35 | * 36 | * @return the rates 37 | */ 38 | public List getRates() { 39 | return this.rates; 40 | } 41 | 42 | /** 43 | * Update rates. 44 | * 45 | * @param rateClient the rate client 46 | * @throws BitPayGenericException BitPayGenericException class 47 | * @throws BitPayApiException BitPayApiException class 48 | */ 49 | public void update(RateClient rateClient) throws BitPayGenericException, BitPayApiException { 50 | this.rates = rateClient.getRates().getRates(); 51 | } 52 | 53 | /** 54 | * Gets rate for the requested baseCurrency /currency pair. 55 | * 56 | * @param currencyCode the currency code 57 | * @return the rate 58 | */ 59 | public double getRate(String currencyCode) { 60 | double val = 0; 61 | for (Rate rateObj : this.rates) { 62 | if (rateObj.getCode().equals(currencyCode)) { 63 | val = rateObj.getValue(); 64 | break; 65 | } 66 | } 67 | return val; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/model/rate/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | /** 7 | * BitPay SDK Rate. 8 | */ 9 | package com.bitpay.sdk.model.rate; 10 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/model/settlement/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | /** 7 | * BitPay SDK Settlement. 8 | */ 9 | package com.bitpay.sdk.model.settlement; 10 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/model/wallet/CurrencyQr.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.model.wallet; 7 | 8 | import com.fasterxml.jackson.annotation.JsonIgnore; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonProperty; 11 | 12 | /** 13 | * The type Currency qr. 14 | * 15 | * @see Wallets 16 | */ 17 | @JsonIgnoreProperties(ignoreUnknown = true) 18 | public class CurrencyQr { 19 | protected String type; 20 | protected Boolean collapsed; 21 | 22 | /** 23 | * Instantiates a new Currency qr. 24 | */ 25 | public CurrencyQr() { 26 | } 27 | 28 | /** 29 | * Gets the type of QR code to use (ex. BIP21, ADDRESS, BIP72b, BIP681, BIP681b, etc). 30 | * 31 | * @return the type 32 | */ 33 | @JsonIgnore 34 | public String getType() { 35 | return this.type; 36 | } 37 | 38 | /** 39 | * Sets the type of QR code to use (ex. BIP21, ADDRESS, BIP72b, BIP681, BIP681b, etc). 40 | * 41 | * @param type the type 42 | */ 43 | @JsonProperty("type") 44 | public void setType(String type) { 45 | this.type = type; 46 | } 47 | 48 | /** 49 | * Gets UI hint for BitPay invoice, generally not relevant to customer integrations. 50 | * 51 | * @return the collapsed 52 | */ 53 | @JsonIgnore 54 | public Boolean getCollapsed() { 55 | return this.collapsed; 56 | } 57 | 58 | /** 59 | * Sets UI hint for BitPay invoice, generally not relevant to customer integrations. 60 | * 61 | * @param collapsed the collapsed 62 | */ 63 | @JsonProperty("collapsed") 64 | public void setCollapsed(Boolean collapsed) { 65 | this.collapsed = collapsed; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/model/wallet/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | /** 7 | * BitPay SDK Wallet. 8 | */ 9 | package com.bitpay.sdk.model.wallet; 10 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | /** 7 | * BitPay SDK. 8 | */ 9 | package com.bitpay.sdk; 10 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/util/GuidGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.util; 7 | 8 | import java.util.UUID; 9 | 10 | /** 11 | * The type Guid generator. 12 | */ 13 | public class GuidGenerator { 14 | 15 | /** 16 | * Generate GUID string based on UUID. 17 | * 18 | * @return the string 19 | */ 20 | public String execute() { 21 | UUID uuid = UUID.randomUUID(); 22 | 23 | return uuid.toString(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/util/JsonMapperFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.util; 7 | 8 | import com.fasterxml.jackson.databind.DeserializationFeature; 9 | import com.fasterxml.jackson.databind.MapperFeature; 10 | import com.fasterxml.jackson.databind.json.JsonMapper; 11 | import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; 12 | 13 | /** 14 | * The type Json mapper factory. 15 | */ 16 | public class JsonMapperFactory { 17 | 18 | /** 19 | * Create json mapper. 20 | * 21 | * @return the json mapper 22 | */ 23 | public static JsonMapper create() { 24 | return JsonMapper 25 | .builder() 26 | .addModule(new JavaTimeModule()) 27 | .configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true) 28 | .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) 29 | .build(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/util/ParameterAdder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.util; 7 | 8 | import java.util.List; 9 | import java.util.Objects; 10 | import org.apache.http.message.BasicNameValuePair; 11 | 12 | public class ParameterAdder { 13 | 14 | public static void execute( 15 | final List params, 16 | final String name, 17 | final String value 18 | ) { 19 | if (Objects.isNull(value)) { 20 | return; 21 | } 22 | 23 | params.add(new BasicNameValuePair(name, value)); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/util/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | /** 7 | * BitPay SDK Util. 8 | */ 9 | package com.bitpay.sdk.util; 10 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/util/serializer/Iso8601ToZonedDateTimeDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.util.serializer; 7 | 8 | import com.fasterxml.jackson.core.JsonParser; 9 | import com.fasterxml.jackson.databind.DeserializationContext; 10 | import com.fasterxml.jackson.databind.JsonDeserializer; 11 | import com.fasterxml.jackson.databind.node.TextNode; 12 | import java.io.IOException; 13 | import java.time.ZonedDateTime; 14 | 15 | public class Iso8601ToZonedDateTimeDeserializer extends JsonDeserializer { 16 | @Override 17 | public ZonedDateTime deserialize( 18 | JsonParser jsonParser, 19 | DeserializationContext deserializationContext 20 | ) throws IOException { 21 | TextNode node = jsonParser.getCodec().readTree(jsonParser); 22 | String dateAsString = node.asText(); 23 | 24 | return ZonedDateTime.parse(dateAsString); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/bitpay/sdk/util/serializer/ZonedDateTimeToIso8601Serializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.util.serializer; 7 | 8 | import com.fasterxml.jackson.core.JsonGenerator; 9 | import com.fasterxml.jackson.databind.JsonSerializer; 10 | import com.fasterxml.jackson.databind.SerializerProvider; 11 | import java.io.IOException; 12 | import java.time.ZonedDateTime; 13 | import java.time.format.DateTimeFormatter; 14 | 15 | public class ZonedDateTimeToIso8601Serializer extends JsonSerializer { 16 | 17 | private static final DateTimeFormatter DATE_TIME_FORMATTER = 18 | DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSX"); 19 | 20 | /** 21 | * This method deserialize ZonedDateTime to format yyyy-mm-ddThh:mm:ssZ. 22 | * 23 | * @param zonedDateTime ZonedDateTime 24 | * @param jsonGenerator JsonGenerator 25 | * @param serializerProvider SerializerProvider 26 | * @throws IOException IOException 27 | */ 28 | @Override 29 | public void serialize( 30 | ZonedDateTime zonedDateTime, 31 | JsonGenerator jsonGenerator, 32 | SerializerProvider serializerProvider 33 | ) throws IOException { 34 | jsonGenerator.writeString(zonedDateTime.format(DATE_TIME_FORMATTER)); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/BitPay.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "BitPayConfiguration" : { 3 | "Environment" : "Test", 4 | "EnvConfig" : { 5 | "Test" : { 6 | "PrivateKeyPath" : "", 7 | "PrivateKey" : "3082013102010104208ae30afbc7e93cb10cb983f70863e546b53f0b2c6158b1a71b576fd09790cff3a081e33081e0020101302c06072a8648ce3d0101022100fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f3044042000000000000000000000000000000000000000000000000000000000000000000420000000000000000000000000000000000000000000000000000000000000000704410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8022100fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141020101a124032200035d6a7e38d7c08b8a626e2390d0360a72a58bd1c5e1348e0eb810d4bbab3d3adf", 8 | "ApiTokens" : { 9 | "payout" : "payoutToken", 10 | "merchant" : "merchantToken" 11 | } 12 | } 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/ConfigTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay 3 | */ 4 | package com.bitpay.sdk; 5 | 6 | import com.fasterxml.jackson.databind.JsonNode; 7 | import org.junit.jupiter.api.Assertions; 8 | import org.junit.jupiter.api.Test; 9 | import org.mockito.Mockito; 10 | 11 | public class ConfigTest { 12 | 13 | @Test 14 | public void it_should_get_environment() { 15 | // given 16 | Config testedClass = getTestedClass(); 17 | Environment expectedValue = Environment.PROD; 18 | 19 | // when 20 | testedClass.setEnvironment(expectedValue); 21 | 22 | // then 23 | Assertions.assertEquals(expectedValue, testedClass.getEnvironment()); 24 | } 25 | 26 | @Test 27 | public void it_should_get_env_config() { 28 | // given 29 | Config testedClass = getTestedClass(); 30 | final Environment env = Environment.TEST; 31 | JsonNode config = Mockito.mock(JsonNode.class); 32 | JsonNode nestedNode = Mockito.mock(JsonNode.class); 33 | Mockito.when(config.path(env.toString())).thenReturn(nestedNode); 34 | 35 | // when 36 | testedClass.setEnvConfig(config); 37 | 38 | // then 39 | Assertions.assertEquals(nestedNode, testedClass.getEnvConfig(env)); 40 | } 41 | 42 | @Test 43 | public void it_should_returns_environments() { 44 | Assertions.assertEquals("Test", Environment.TEST.toString()); 45 | Assertions.assertEquals("Prod", Environment.PROD.toString()); 46 | } 47 | 48 | @Test 49 | public void it_should_returns_env_urls() { 50 | Assertions.assertEquals("https://test.bitpay.com/", Config.TEST_URL); 51 | Assertions.assertEquals("https://bitpay.com/", Config.PROD_URL); 52 | } 53 | 54 | @Test 55 | public void it_should_returns_bitpay_api_version() { 56 | Assertions.assertEquals("2.0.0", Config.BITPAY_API_VERSION); 57 | } 58 | 59 | @Test 60 | public void it_should_returns_bitpay_plugin_info() { 61 | Assertions.assertTrue(Config.BITPAY_PLUGIN_INFO.contains("BitPay_Java_Client_v10.2.0")); 62 | } 63 | 64 | @Test 65 | public void it_should_returns_bitpay_api_frame() { 66 | Assertions.assertEquals("std", Config.BITPAY_API_FRAME); 67 | } 68 | 69 | @Test 70 | public void it_should_returns_bitpay_api_frame_version() { 71 | Assertions.assertEquals("1.0.0", Config.BITPAY_API_FRAME_VERSION); 72 | } 73 | 74 | private Config getTestedClass() { 75 | return new Config(); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/EnvironmentTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay 3 | */ 4 | 5 | package com.bitpay.sdk; 6 | 7 | import org.junit.jupiter.api.Assertions; 8 | import org.junit.jupiter.api.Test; 9 | 10 | public class EnvironmentTest { 11 | 12 | @Test 13 | public void it_should_return_environment_from_env_value() { 14 | Assertions.assertEquals(Environment.PROD, Environment.fromValue("Prod")); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/ResourceClientsCleaner.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay 3 | */ 4 | 5 | package com.bitpay.sdk; 6 | 7 | import com.bitpay.sdk.client.BillClient; 8 | import com.bitpay.sdk.client.CurrencyClient; 9 | import com.bitpay.sdk.client.InvoiceClient; 10 | import com.bitpay.sdk.client.LedgerClient; 11 | import com.bitpay.sdk.client.PayoutClient; 12 | import com.bitpay.sdk.client.PayoutGroupClient; 13 | import com.bitpay.sdk.client.PayoutRecipientsClient; 14 | import com.bitpay.sdk.client.RateClient; 15 | import com.bitpay.sdk.client.RefundClient; 16 | import com.bitpay.sdk.client.ResourceClient; 17 | import com.bitpay.sdk.client.SettlementClient; 18 | import com.bitpay.sdk.client.WalletClient; 19 | import java.lang.reflect.Field; 20 | import java.util.Arrays; 21 | import java.util.List; 22 | 23 | public class ResourceClientsCleaner { 24 | 25 | /** 26 | * This method cleans all resource client singletons. 27 | */ 28 | public static void execute() { 29 | List> classes = Arrays 30 | .asList(BillClient.class, CurrencyClient.class, InvoiceClient.class, 31 | LedgerClient.class, PayoutClient.class, PayoutGroupClient.class, PayoutRecipientsClient.class, 32 | RateClient.class, RefundClient.class, SettlementClient.class, WalletClient.class); 33 | classes.forEach(singleClass -> { 34 | try { 35 | Field field = singleClass.getDeclaredField("instance"); 36 | field.setAccessible(true); 37 | field.set(null, null); 38 | } catch (NoSuchFieldException | IllegalAccessException ignored) { 39 | } 40 | }); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/AuthorizationClientTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay 3 | */ 4 | 5 | package com.bitpay.sdk.client; 6 | 7 | import com.bitpay.sdk.exceptions.BitPayApiException; 8 | import com.bitpay.sdk.exceptions.BitPayGenericException; 9 | import com.bitpay.sdk.model.Facade; 10 | import com.bitpay.sdk.util.TokenContainer; 11 | import java.io.IOException; 12 | import org.junit.jupiter.api.Assertions; 13 | import org.junit.jupiter.api.Test; 14 | import org.mockito.Mockito; 15 | 16 | public class AuthorizationClientTest extends AbstractClientTest { 17 | 18 | public AuthorizationClientTest() throws IOException { 19 | } 20 | 21 | @Test 22 | public void it_should_authorize_client_by_facade() throws BitPayGenericException, BitPayApiException { 23 | // given 24 | Mockito.when(this.uuidGenerator.execute()).thenReturn(AbstractClientTest.EXAMPLE_UUID); 25 | this.addServerJsonResponse( 26 | "/tokens", 27 | "POST", 28 | getPreparedJsonDataFromFile("authorizeClientByFacadeRequest.json"), 29 | getPreparedJsonDataFromFile("authorizeClientByFacadeResponse.json") 30 | ); 31 | 32 | final TokenContainer accessToken = new TokenContainer(); 33 | AuthorizationClient authorizationClient = getAuthorizationClient(accessToken); 34 | 35 | String token = authorizationClient.authorizeClient(Facade.MERCHANT); 36 | 37 | Assertions.assertEquals("C4Lg7oW", token); 38 | Assertions.assertEquals(accessToken.getAccessToken(Facade.MERCHANT), 39 | "G7XM9fcM1gtCN7DUr8ZWtPGVFLTKiYWanHR4kvqsnjP3"); 40 | } 41 | 42 | private AuthorizationClient getAuthorizationClient(TokenContainer accessToken) { 43 | return new AuthorizationClient( 44 | getBitPayClient(), 45 | this.uuidGenerator, 46 | accessToken, 47 | "someIdentity" 48 | ); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/CurrencyClientTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay 3 | */ 4 | 5 | package com.bitpay.sdk.client; 6 | 7 | import com.bitpay.sdk.exceptions.BitPayException; 8 | import java.util.Map; 9 | import org.junit.jupiter.api.Assertions; 10 | import org.junit.jupiter.api.Test; 11 | 12 | public class CurrencyClientTest extends AbstractClientTest { 13 | 14 | @Test 15 | public void it_should_get_currency_info() throws BitPayException { 16 | // given 17 | CurrencyClient client = this.getCurrencyClient(); 18 | this.addServerJsonResponse( 19 | "/currencies", 20 | "GET", 21 | null, 22 | getPreparedJsonDataFromFile("getCurrenciesResponse.json") 23 | ); 24 | 25 | // when 26 | Map result = client.getInfo("USD"); 27 | 28 | // then 29 | Assertions.assertEquals("USD", result.get("code")); 30 | Assertions.assertEquals("$", result.get("symbol")); 31 | Assertions.assertEquals(2, result.get("precision")); 32 | Assertions.assertEquals("US Dollar", result.get("name")); 33 | Assertions.assertEquals("US Dollars", result.get("plural")); 34 | Assertions.assertEquals("usd bucks", result.get("alts")); 35 | Assertions.assertEquals(0.01, result.get("minimum")); 36 | Assertions.assertEquals(false, result.get("sanctioned")); 37 | Assertions.assertEquals(2, result.get("decimals")); 38 | } 39 | 40 | private CurrencyClient getCurrencyClient() throws BitPayException { 41 | return CurrencyClient.getInstance(this.getBitPayClient()); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/HttpRequestFactoryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay 3 | */ 4 | 5 | package com.bitpay.sdk.client; 6 | 7 | import org.apache.http.client.methods.HttpDelete; 8 | import org.apache.http.client.methods.HttpGet; 9 | import org.apache.http.client.methods.HttpPost; 10 | import org.apache.http.client.methods.HttpPut; 11 | import org.junit.jupiter.api.Assertions; 12 | import org.junit.jupiter.api.Test; 13 | 14 | public class HttpRequestFactoryTest { 15 | 16 | protected static final String FULL_URL = "anyString"; 17 | 18 | @Test 19 | public void it_should_create_httpGet_object() { 20 | Assertions.assertSame(HttpGet.class, this.getTestedClass().createHttpGet(FULL_URL).getClass()); 21 | } 22 | 23 | @Test 24 | public void it_should_create_httpDelete_object() { 25 | Assertions.assertSame(HttpDelete.class, this.getTestedClass().createHttpDelete(FULL_URL).getClass()); 26 | } 27 | 28 | @Test 29 | public void it_should_create_httpPost_object() { 30 | Assertions.assertSame(HttpPost.class, this.getTestedClass().createHttpPost(FULL_URL).getClass()); 31 | } 32 | 33 | @Test 34 | public void it_should_create_httpPut_object() { 35 | Assertions.assertSame(HttpPut.class, this.getTestedClass().createHttpPut(FULL_URL).getClass()); 36 | } 37 | 38 | private HttpRequestFactory getTestedClass() { 39 | return new HttpRequestFactory(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/HttpResponseTest.java: -------------------------------------------------------------------------------- 1 | package com.bitpay.sdk.client; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | import org.junit.jupiter.api.Assertions; 6 | import org.junit.jupiter.api.Test; 7 | import org.junit.jupiter.api.extension.ExtendWith; 8 | import org.mockito.junit.jupiter.MockitoExtension; 9 | 10 | @ExtendWith(MockitoExtension.class) 11 | public class HttpResponseTest { 12 | 13 | private static final int CODE = 200; 14 | private static final String BODY = "anyBody"; 15 | private static final String LOCALE = "en_US"; 16 | private static final String HTTP_VERSION = "HTTP/1.1"; 17 | 18 | @Test 19 | public void it_should_returns_code() { 20 | Assertions.assertEquals(CODE, this.getTestedClass().getCode()); 21 | } 22 | 23 | @Test 24 | public void it_should_returns_body() { 25 | Assertions.assertSame(BODY, this.getTestedClass().getBody()); 26 | } 27 | 28 | @Test 29 | public void it_should_returns_headers() { 30 | Assertions.assertSame("application/json", this.getTestedClass().getHeaders().get("Content-Type")); 31 | } 32 | 33 | @Test 34 | public void it_should_returns_locale() { 35 | Assertions.assertSame(LOCALE, this.getTestedClass().getLocale()); 36 | } 37 | 38 | @Test 39 | public void it_should_returns_httpVersion() { 40 | Assertions.assertSame(HTTP_VERSION, this.getTestedClass().getHttpVersion()); 41 | } 42 | 43 | private HttpResponse getTestedClass() { 44 | Map headers = new HashMap<>(); 45 | headers.put("Content-Type", "application/json"); 46 | 47 | return new HttpResponse(CODE, BODY, headers, LOCALE, HTTP_VERSION); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/RateClientTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay 3 | */ 4 | 5 | package com.bitpay.sdk.client; 6 | 7 | import com.bitpay.sdk.exceptions.BitPayApiException; 8 | import com.bitpay.sdk.exceptions.BitPayGenericException; 9 | import com.bitpay.sdk.model.rate.Rate; 10 | import com.bitpay.sdk.model.rate.Rates; 11 | import org.junit.jupiter.api.Assertions; 12 | import org.junit.jupiter.api.Test; 13 | 14 | public class RateClientTest extends AbstractClientTest { 15 | 16 | @Test 17 | public void it_should_get_rate() throws BitPayGenericException, BitPayApiException { 18 | // given 19 | this.addServerJsonResponse( 20 | "/rates/BCH/USD", 21 | "GET", 22 | null, 23 | getPreparedJsonDataFromFile("getRateResponse.json") 24 | ); 25 | 26 | // when 27 | Rate rate = this.getTestedClass().get("BCH", "USD"); 28 | 29 | // then 30 | Assertions.assertEquals(100.99, rate.getValue()); 31 | } 32 | 33 | @Test 34 | public void it_should_get_rates() throws BitPayGenericException, BitPayApiException { 35 | // given 36 | this.addServerJsonResponse( 37 | "/rates", 38 | "GET", 39 | null, 40 | getPreparedJsonDataFromFile("getRatesResponse.json") 41 | ); 42 | 43 | // when 44 | Rates rates = this.getTestedClass().getRates(); 45 | 46 | // then 47 | Assertions.assertEquals(183, rates.getRates().size()); 48 | Assertions.assertEquals(17725.64, rates.getRate("USD")); 49 | } 50 | 51 | @Test 52 | public void it_should_get_rates_by_base_currency() throws BitPayGenericException, BitPayApiException { 53 | // given 54 | this.addServerJsonResponse( 55 | "/rates/BTC", 56 | "GET", 57 | null, 58 | getPreparedJsonDataFromFile("getRatesResponse.json") 59 | ); 60 | 61 | // when 62 | Rates rates = this.getTestedClass().getRates("BTC"); 63 | 64 | // then 65 | Assertions.assertEquals(183, rates.getRates().size()); 66 | Assertions.assertEquals(17725.64, rates.getRate("USD")); 67 | } 68 | 69 | private RateClient getTestedClass() { 70 | return RateClient.getInstance(this.getBitPayClient()); 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/WalletClientTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay 3 | */ 4 | 5 | package com.bitpay.sdk.client; 6 | 7 | import com.bitpay.sdk.exceptions.BitPayException; 8 | import com.bitpay.sdk.model.wallet.Wallet; 9 | import java.util.List; 10 | import org.junit.jupiter.api.Assertions; 11 | import org.junit.jupiter.api.Test; 12 | 13 | public class WalletClientTest extends AbstractClientTest { 14 | 15 | @Test 16 | public void it_should_get_supported_wallets() throws BitPayException { 17 | // given 18 | this.addServerJsonResponse( 19 | "/supportedwallets", 20 | "GET", 21 | null, 22 | getPreparedJsonDataFromFile("getSupportedWallets.json") 23 | ); 24 | WalletClient client = WalletClient.getInstance(this.getBitPayClient()); 25 | 26 | // when 27 | List result = client.getSupportedWallets(); 28 | 29 | // then 30 | Assertions.assertEquals(7, result.size()); 31 | Assertions.assertEquals("bitpay", result.get(0).getKey()); 32 | Assertions.assertEquals("BitPay", result.get(0).getDisplayName()); 33 | Assertions.assertEquals(true, result.get(0).getPayPro()); 34 | Assertions.assertEquals("bitpay-wallet.png", result.get(0).getAvatar()); 35 | Assertions.assertEquals("https://bitpay.com/img/wallet-logos/bitpay-wallet.png", result.get(0).getImage()); 36 | Assertions.assertEquals(15, result.get(0).getCurrencies().size()); 37 | Assertions.assertEquals("BTC", result.get(0).getCurrencies().get(0).getCode()); 38 | Assertions.assertEquals(true, result.get(0).getCurrencies().get(0).getPayPro()); 39 | Assertions.assertEquals("BIP72b", result.get(0).getCurrencies().get(0).getQr().getType()); 40 | Assertions.assertEquals("https://bitpay.com/img/icon/currencies/BTC.svg", result.get(0).getCurrencies().get(0).getImage()); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/authorizeClientByFacadeRequest.json: -------------------------------------------------------------------------------- 1 | {"count":1,"facade":"merchant","guid":"ee26b5e0-9185-493e-bc12-e846d5fcf07c","id":"someIdentity"} -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/authorizeClientByFacadeResponse.json: -------------------------------------------------------------------------------- 1 | {"data":[{"policies":[{"policy":"id","method":"inactive","params":["Tf2yXsY49iFyDfxt3b2kf9VPRMwPxxAyCRW"]}],"token":"G7XM9fcM1gtCN7DUr8ZWtPGVFLTKiYWanHR4kvqsnjP3","facade":"merchant","label":"merchantwebsite.com","dateCreated":1621340364865,"pairingExpiration":1621426764865,"pairingCode":"C4Lg7oW"}]} -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/cancelInvoiceErrorResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "status": "error", 3 | "code": "040107", 4 | "data": null, 5 | "error": "Invalid invoice state for cancel" 6 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/cancelPayoutResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "status": "success", 3 | "data": {}, 4 | "message": null 5 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/cancelRefundResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "id": "WoE46gSLkJQS48RJEiNw3L", 4 | "invoice": "Hpqc63wvE1ZjzeeH4kEycF", 5 | "reference": "Test refund", 6 | "status": "cancelled", 7 | "amount": 10, 8 | "transactionCurrency": "BTC", 9 | "transactionAmount": 0.000594, 10 | "transactionRefundFee": 0.000002, 11 | "currency": "USD", 12 | "lastRefundNotification": "2021-08-29T20:45:35.368Z", 13 | "refundFee": 0.04, 14 | "immediate": false, 15 | "buyerPaysRefundFee": false, 16 | "requestDate": "2021-08-29T20:45:34.000Z" 17 | } 18 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/createBillRequest.json: -------------------------------------------------------------------------------- 1 | {"address1":"2630 Hegal Place","address2":"Apt 42","cc":["jane@doe.com"],"city":"Alexandria","country":"US","currency":"USD","dueDate":"2021-05-21T09:48:02.37Z","email":"23242","items":[{"description":"Test Item 1","price":6.0,"quantity":1},{"description":"Test Item 2","price":4.0,"quantity":1}],"name":"John Doe","number":"bill1234-ABCD","passProcessingFee":true,"phone":"555-123-456","state":"VA","token":"someMerchantToken","zip":"23242"} -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/createBillResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "facade": "merchant/bill", 3 | "data": { 4 | "status": "draft", 5 | "url": "https://bitpay.com/bill?id=3Zpmji8bRKxWJo2NJbWX5H&resource=bills", 6 | "number": "bill1234-EFGH", 7 | "createdDate": "2021-05-21T09:51:04.126Z", 8 | "dueDate": "2021-05-31T00:00:00.000Z", 9 | "currency": "USD", 10 | "name": "John Doe", 11 | "address1": "2630 Hegal Place", 12 | "address2": "Apt 42", 13 | "city": "Alexandria", 14 | "state": "VA", 15 | "zip": "23242", 16 | "country": "US", 17 | "email": "john@doe.com", 18 | "cc": [ 19 | "jane@doe.com" 20 | ], 21 | "phone": "555-123-456", 22 | "passProcessingFee": true, 23 | "emailBill": true, 24 | "id": "3Zpmji8bRKxWJo2NJbWX5H", 25 | "merchant": "7HyKWn3d4xdhAMQYAEVxVq", 26 | "items": [ 27 | { 28 | "id": "NV35GRWtrdB2cmGEjY4LKY", 29 | "description": "Test Item 1", 30 | "price": 6, 31 | "quantity": 1 32 | }, 33 | { 34 | "id": "Apy3i2TpzHRYP8tJCkrZMT", 35 | "description": "Test Item 2", 36 | "price": 4, 37 | "quantity": 1 38 | } 39 | ], 40 | "token": "6EBQR37MgDJPfEiLY3jtRq7eTP2aodR5V5wmXyyZhru5FM5yF4RCGKYQtnT7nhwHjA" 41 | } 42 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/createInvoiceRequest.json: -------------------------------------------------------------------------------- 1 | {"autoRedirect":true,"buyer":{"address1":"SomeStreet","address2":"911","country":"USA","email":"buyer@buyeremaildomain.com","locality":"Washington","name":"Marcin","notify":true,"postalCode":"20000","region":"District of Columbia"},"currency":"USD","extendedNotifications":true,"forcedBuyerSelectedWallet":"bitpay","fullNotifications":true,"itemDesc":"Example","notificationEmail":"m.warzybok@sumoheavy.com","notificationURL":"https://notification.url/aaa","orderId":"ee26b5e0-9185-493e-bc12-e846d5fcf07c","price":10.0,"token":"someMerchantToken","transactionSpeed":"medium"} -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/createPayoutRequest.json: -------------------------------------------------------------------------------- 1 | {"amount":10.0,"currency":"USD","email":"john@doe.com","ledgerCurrency":"GBP","notificationEmail":"merchant@email.com","notificationURL":"https://yournotiticationURL.com/wed3sa0wx1rz5bg0bv97851eqx","reference":"payout_20210527","token":"somePayoutToken"} -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/createPayoutResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "facade": "payout/payout", 3 | "data": { 4 | "id": "JMwv8wQCXANoU2ZZQ9a9GH", 5 | "recipientId": "LDxRZCGq174SF8AnQpdBPB", 6 | "accountId": "SJcWZCFq344DL8QnXpdBNM", 7 | "shopperId": "7qohDf2zZnQK5Qanj8oyC2", 8 | "amount": 10, 9 | "currency": "USD", 10 | "ledgerCurrency": "GBP", 11 | "email": "john@doe.com", 12 | "reference": "payout_20210527", 13 | "label": "John Doe", 14 | "notificationURL": "https://yournotiticationURL.com/wed3sa0wx1rz5bg0bv97851eqx", 15 | "notificationEmail": "merchant@email.com", 16 | "effectiveDate": "2021-05-27T09:00:00.000Z", 17 | "requestDate": "2021-05-27T10:47:37.834Z", 18 | "status": "new", 19 | "transactions": [], 20 | "token": "6RZSTPtnzEaroAe2X4YijenRiqteRDNvzbT8NjtcHjUVd9FUFwa7dsX8RFgRDDC5SL" 21 | }, 22 | "status": "success", 23 | "message": null 24 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/createRefundRequest.json: -------------------------------------------------------------------------------- 1 | {"amount":10.0,"guid":"ee26b5e0-9185-493e-bc12-e846d5fcf07c","invoiceId":"Hpqc63wvE1ZjzeeH4kEycF","token":"someMerchantToken"} -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/createRefundResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "guid": "ee26b5e0-9185-493e-bc12-e846d5fcf07c", 4 | "id": "WoE46gSLkJQS48RJEiNw3L", 5 | "invoice": "Hpqc63wvE1ZjzeeH4kEycF", 6 | "reference": "Test refund", 7 | "status": "created", 8 | "amount": 10, 9 | "transactionCurrency": "BTC", 10 | "transactionAmount": 0.000594, 11 | "transactionRefundFee": 0.000002, 12 | "currency": "USD", 13 | "lastRefundNotification": "2021-08-29T20:45:35.368Z", 14 | "refundFee": 0.04, 15 | "immediate": false, 16 | "buyerPaysRefundFee": false, 17 | "requestDate": "2021-08-29T20:45:34.000Z" 18 | } 19 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/deletePayoutRecipientResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "status": "success", 3 | "data": {}, 4 | "message": null 5 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/deliverBillRequest.json: -------------------------------------------------------------------------------- 1 | {"token":"6EBQR37MgDJPfEiLY3jtRq7eTP2aodR5V5wmXyyZhru5FM5yF4RCGKYQtnT7nhwHjA"} -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/deliverBillResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": "Success" 3 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/getCurrenciesResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": [ 3 | { 4 | "code": "BTC", 5 | "symbol": "฿", 6 | "precision": 6, 7 | "name": "Bitcoin", 8 | "plural": "Bitcoin", 9 | "alts": "btc", 10 | "minimum": 0.000006, 11 | "sanctioned": false, 12 | "decimals": 8, 13 | "chain": "BTC" 14 | }, 15 | { 16 | "code": "XRP", 17 | "symbol": "Ʀ", 18 | "precision": 6, 19 | "name": "Ripple", 20 | "plural": "Ripple", 21 | "alts": "xrp", 22 | "minimum": 0.000006, 23 | "sanctioned": false, 24 | "decimals": 6, 25 | "chain": "XRP" 26 | }, 27 | { 28 | "code": "EUR", 29 | "symbol": "€", 30 | "precision": 2, 31 | "name": "Eurozone Euro", 32 | "plural": "Eurozone Euros", 33 | "alts": "eur", 34 | "minimum": 0.01, 35 | "sanctioned": false, 36 | "decimals": 2 37 | }, 38 | { 39 | "code": "USD", 40 | "symbol": "$", 41 | "precision": 2, 42 | "name": "US Dollar", 43 | "plural": "US Dollars", 44 | "alts": "usd bucks", 45 | "minimum": 0.01, 46 | "sanctioned": false, 47 | "decimals": 2 48 | }, 49 | { 50 | "code": "USDC", 51 | "symbol": "$", 52 | "precision": 2, 53 | "name": "Circle USD Coin", 54 | "plural": "Circle USD Coin", 55 | "alts": "", 56 | "minimum": 0.01, 57 | "sanctioned": false, 58 | "decimals": 6, 59 | "chain": "ETH" 60 | } 61 | ] 62 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/getInvoiceEventToken.json: -------------------------------------------------------------------------------- 1 | { 2 | "facade": "merchant/invoice", 3 | "data": { 4 | "url": "https://bitpay.com/events", 5 | "token": "4MuqDPt93i9Xbf8SnAPniwbGeNLW8A3ScgAmukFMgFUFRqTLuuhVdAFfePPysVqL2P", 6 | "events": [ 7 | "payment", 8 | "confirmation" 9 | ], 10 | "actions": [ 11 | "subscribe", 12 | "unsubscribe" 13 | ] 14 | } 15 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/getLedgersResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": [ 3 | { 4 | "currency": "EUR", 5 | "balance": 0 6 | }, 7 | { 8 | "currency": "USD", 9 | "balance": 2389.82 10 | }, 11 | { 12 | "currency": "BTC", 13 | "balance": 0.000287 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/getPayoutRecipientResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "facade": "payout/recipient", 3 | "data": { 4 | "email": "john.smith@email.com", 5 | "label": "John Smith", 6 | "status": "invited", 7 | "id": "JA4cEtmBxCp5cybtnh1rds", 8 | "shopperId": null, 9 | "token": "2LVBntm7z92rnuVjVX5ZVaDoUEaoY4LxhZMMzPAMGyXcejgPXVmZ4Ae3oGaCGBFKQf" 10 | } 11 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/getPayoutRecipientsResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "facade": "payout/recipient", 3 | "data": [ 4 | { 5 | "email": "alice@email.com", 6 | "label": "Alice", 7 | "status": "invited", 8 | "id": "JA4cEtmBxCp5cybtnh1rds", 9 | "shopperId": null, 10 | "token": "2LVBntm7z92rnuVjVX5ZVaDoUEaoY4LxhZMMzPAMGyXcejgPXVmZ4Ae3oGaCGBFKQf" 11 | }, 12 | { 13 | "email": "bob@email.com", 14 | "label": "Bob", 15 | "status": "invited", 16 | "id": "X3icwc4tE8KJ5hEPNPpDXW", 17 | "shopperId": null, 18 | "token": "2LVBntm7z92rnuVjVX5ZVaDoUEaoY4LxhZMMzPAMGyXrrBAB9vRY3BVxGLbAa6uEx7" 19 | } 20 | ] 21 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/getPayoutResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "facade": "payout/payout", 3 | "data": { 4 | "id": "JMwv8wQCXANoU2ZZQ9a9GH", 5 | "recipientId": "LDxRZCGq174SF8AnQpdBPB", 6 | "accountId": "SJcWZCFq344DL8QnXpdBNM", 7 | "shopperId": "7qohDf2zZnQK5Qanj8oyC2", 8 | "amount": 10, 9 | "currency": "USD", 10 | "ledgerCurrency": "GBP", 11 | "exchangeRates": { 12 | "BTC": { 13 | "USD": 39390.47, 14 | "GBP": 27883.962246420004 15 | } 16 | }, 17 | "email": "john@doe.com", 18 | "reference": "payout_20210527", 19 | "label": "John Doe", 20 | "notificationURL": "https://yournotiticationURL.com/wed3sa0wx1rz5bg0bv97851eqx", 21 | "notificationEmail": "merchant@email.com", 22 | "effectiveDate": "2021-05-27T09:00:00.000Z", 23 | "requestDate": "2021-05-27T10:47:37.834Z", 24 | "dateExecuted": "2021-05-27T09:00:00.000Z", 25 | "status": "complete", 26 | "transactions": [ 27 | { 28 | "txid": "db53d7e2bf3385a31257ce09396202d9c2823370a5ca186db315c45e24594057", 29 | "amount": 0.000254, 30 | "date": "2021-05-27T11:04:23.155Z", 31 | "confirmations": 6 32 | } 33 | ], 34 | "token": "6RZSTPtnzEaroAe2X4YijenRiqteRDNvzbT8NjtcHjUVd9FUFwa7dsX8RFgRDDC5SL" 35 | }, 36 | "status": "success", 37 | "message": null 38 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/getPayoutsResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "facade": "payout/payout", 3 | "data": [ 4 | { 5 | "id": "JMwv8wQCXANoU2ZZQ9a9GH", 6 | "recipientId": "LDxRZCGq174SF8AnQpdBPB", 7 | "shopperId": "7qohDf2zZnQK5Qanj8oyC2", 8 | "amount": 10, 9 | "currency": "USD", 10 | "ledgerCurrency": "GBP", 11 | "exchangeRates": { 12 | "BTC": { 13 | "USD": 39390.47, 14 | "GBP": 27883.962246420004 15 | } 16 | }, 17 | "email": "john@doe.com", 18 | "reference": "payout_20210527", 19 | "label": "John Doe", 20 | "notificationURL": "https://yournotiticationURL.com/wed3sa0wx1rz5bg0bv97851eqx", 21 | "notificationEmail": "merchant@email.com", 22 | "effectiveDate": "2021-05-27T09:00:00.000Z", 23 | "requestDate": "2021-05-27T10:47:37.834Z", 24 | "status": "complete", 25 | "transactions": [ 26 | { 27 | "txid": "db53d7e2bf3385a31257ce09396202d9c2823370a5ca186db315c45e24594057", 28 | "amount": 0.000254, 29 | "date": "2021-05-27T11:04:23.155Z" 30 | } 31 | ], 32 | "token": "9pVLfvdjt59q1JiY2JEsf2uzeeEpSqDwwfRAzuFr9CcrxZX25rTnP6HdRhsMBGLArz" 33 | }, 34 | { 35 | "id": "KMXZeQigXG6T5abzCJmTcH", 36 | "recipientId": "LDxRZCGq174SF8AnQpdBPB", 37 | "shopperId": "7qohDf2zZnQK5Qanj8oyC2", 38 | "amount": 10, 39 | "currency": "USD", 40 | "ledgerCurrency": "GBP", 41 | "email": "jane@doe.com", 42 | "reference": "payout_20210528", 43 | "label": "Jane Doe", 44 | "notificationURL": "https://yournotiticationURL.com/wed3sa0wx1rz5bg0bv97851eqx", 45 | "notificationEmail": "merchant@email.com", 46 | "effectiveDate": "2021-05-28T09:00:00.000Z", 47 | "requestDate": "2021-05-28T10:23:43.765Z", 48 | "status": "cancelled", 49 | "transactions": [], 50 | "token": "9pVLfvdjt59q1JiY2JEsf2hr5FsjimfY4qRLFi85tMiXSCkJ9mQ2oSQqYKVangKaro" 51 | } 52 | ], 53 | "status": "success", 54 | "message": null 55 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/getRateResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "code": "USD", 4 | "name": "US Dollar", 5 | "rate": 100.99 6 | } 7 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/getRefundResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "guid": "ee26b5e0-9185-493e-bc12-e846d5fcf07c", 4 | "id": "WoE46gSLkJQS48RJEiNw3L", 5 | "invoice": "Hpqc63wvE1ZjzeeH4kEycF", 6 | "reference": "Test refund", 7 | "status": "created", 8 | "amount": 10, 9 | "transactionCurrency": "BTC", 10 | "transactionAmount": 0.000594, 11 | "transactionRefundFee": 0.000002, 12 | "currency": "USD", 13 | "lastRefundNotification": "2021-08-29T20:45:35.368Z", 14 | "refundFee": 0.04, 15 | "immediate": false, 16 | "buyerPaysRefundFee": false, 17 | "requestDate": "2021-08-29T20:45:34.000Z" 18 | } 19 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/getRefundsByInvoiceId.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": [ 3 | { 4 | "id": "WoE46gSLkJQS48RJEiNw3L", 5 | "invoice": "Hpqc63wvE1ZjzeeH4kEycF", 6 | "reference": "Test refund", 7 | "status": "canceled", 8 | "amount": 5, 9 | "transactionCurrency": "BTC", 10 | "transactionAmount": 0.000297, 11 | "transactionRefundFee": 0.000001, 12 | "currency": "USD", 13 | "lastRefundNotification": "2021-08-28T22:49:33.368Z", 14 | "refundFee": 0.02, 15 | "immediate": false, 16 | "buyerPaysRefundFee": false, 17 | "requestDate": "2021-08-28T22:49:33.000Z" 18 | }, 19 | { 20 | "id": "WoE46gSLkJQS48RJEiNw3L", 21 | "invoice": "Hpqc63wvE1ZjzeeH4kEycF", 22 | "reference": "Test refund 2", 23 | "status": "created", 24 | "amount": 10, 25 | "transactionCurrency": "BTC", 26 | "transactionAmount": 0.000594, 27 | "transactionRefundFee": 0.000002, 28 | "currency": "USD", 29 | "lastRefundNotification": "2021-08-29T20:45:35.368Z", 30 | "refundFee": 0.04, 31 | "immediate": false, 32 | "buyerPaysRefundFee": false, 33 | "requestDate": "2021-08-29T20:45:34.000Z" 34 | } 35 | ] 36 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/getSettlementResponse.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "facade": "merchant/settlement", 4 | "data": { 5 | "id": "RPWTabW8urd3xWv2To989v", 6 | "accountId": "YJCgTf3jrXHkUVzLQ7y4eg", 7 | "status": "processing", 8 | "currency": "EUR", 9 | "payoutInfo": { 10 | "label": "Corporate account", 11 | "bankCountry": "Netherlands", 12 | "name": "Test Organization", 13 | "bank": "Test", 14 | "swift": "RABONL2U", 15 | "account": "NL85ABNA0000000000" 16 | }, 17 | "dateCreated": "2021-05-11T09:05:00.176Z", 18 | "dateExecuted": "2021-05-11T11:52:29.681Z", 19 | "openingDate": "2021-05-10T09:00:00.000Z", 20 | "closingDate": "2021-05-11T09:00:00.000Z", 21 | "openingBalance": 23.27, 22 | "ledgerEntriesSum": 20.82, 23 | "withholdings": [ 24 | { 25 | "amount": 8.21, 26 | "code": "W005", 27 | "description": "Pending Refunds" 28 | } 29 | ], 30 | "withholdingsSum": 8.21, 31 | "totalAmount": 35.88, 32 | "token": "2GrR6GDeYxUFYM9sDKViy6nFFTy4Rjvm1SYdLBjK46jkeJdgUTRccRfhtwkhNcuZky" 33 | } 34 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/getSettlementsResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "facade": "merchant/settlement", 3 | "data": [ 4 | { 5 | "id": "KBkdURgmE3Lsy9VTnavZHX", 6 | "accountId": "YJCgTf3jrXHkUVzLQ7y4eg", 7 | "status": "processing", 8 | "currency": "EUR", 9 | "payoutInfo": { 10 | "label": "Corporate account", 11 | "bankCountry": "Netherlands", 12 | "name": "Test Organization", 13 | "bank": "Test", 14 | "swift": "RABONL2U", 15 | "account": "NL85ABNA0000000000" 16 | }, 17 | "dateCreated": "2021-05-10T09:05:00.176Z", 18 | "dateExecuted": "2021-05-10T11:52:29.681Z", 19 | "openingDate": "2021-05-09T09:00:00.000Z", 20 | "closingDate": "2021-05-10T09:00:00.000Z", 21 | "openingBalance": 1.27, 22 | "ledgerEntriesSum": 20.82, 23 | "withholdings": [], 24 | "withholdingsSum": 0, 25 | "totalAmount": 22.09, 26 | "token": "2gBtViSiBWSEJGo1LfaMFHoaBRzE2jek2VitKAYeenj2SRiTVSCgRvs1WTN8w4w8Lc" 27 | }, 28 | { 29 | "id": "RPWTabW8urd3xWv2To989v", 30 | "accountId": "YJCgTf3jrXHkUVzLQ7y4eg", 31 | "status": "processing", 32 | "currency": "EUR", 33 | "payoutInfo": { 34 | "label": "Corporate account", 35 | "bankCountry": "Netherlands", 36 | "name": "Test Organization", 37 | "bank": "Test", 38 | "swift": "RABONL2U", 39 | "account": "NL85ABNA0000000000" 40 | }, 41 | "dateCreated": "2021-05-11T09:05:00.176Z", 42 | "dateExecuted": "2021-05-11T11:52:29.681Z", 43 | "openingDate": "2021-05-10T09:00:00.000Z", 44 | "closingDate": "2021-05-11T09:00:00.000Z", 45 | "openingBalance": 23.27, 46 | "ledgerEntriesSum": 20.82, 47 | "withholdings": [ 48 | { 49 | "amount": 8.21, 50 | "code": "W005", 51 | "description": "Pending Refunds" 52 | } 53 | ], 54 | "withholdingsSum": 8.21, 55 | "totalAmount": 35.88, 56 | "token": "2gBtViSiBWSEJitKAYSCgRvs1WTN8w4Go1Leenj2SRiTVFHoaBRzE2jek2VfaMw8Lc" 57 | } 58 | ] 59 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/invoiceWebhookResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": "Success" 3 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/payInvoiceRequest.json: -------------------------------------------------------------------------------- 1 | {"token":"someMerchantToken","status":"complete"} -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/sendPayoutNotificationRequest.json: -------------------------------------------------------------------------------- 1 | {"token":"somePayoutToken"} -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/sendPayoutNotificationResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "status": "success", 3 | "data": {}, 4 | "message": null 5 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/sendRefundNotificationRequest.json: -------------------------------------------------------------------------------- 1 | {"token":"cM78LHk17Q8fktDE6QLBBFfvH1QKBhRkHibTLcxhgzsu3VDRvSyu3CGi17DuwYxhT"} -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/sendRefundNotificationResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "status": "success", 3 | "data": {}, 4 | "message": null 5 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/submitPayoutRecipientsRequest.json: -------------------------------------------------------------------------------- 1 | {"recipients":[{"email":"alice@email.com","label":"Alice"},{"email":"bob@email.com","label":"Bob"}],"token":"somePayoutToken"} -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/submitPayoutRecipientsResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "facade": "payout/recipient", 3 | "data": [ 4 | { 5 | "email": "alice@email.com", 6 | "label": "Alice", 7 | "status": "invited", 8 | "id": "JA4cEtmBxCp5cybtnh1rds", 9 | "shopperId": null, 10 | "token": "2LVBntm7z92rnuVjVX5ZVaDoUEaoY4LxhZMMzPAMGyXcejgPXVmZ4Ae3oGaCGBFKQf" 11 | }, 12 | { 13 | "email": "bob@email.com", 14 | "label": "Bob", 15 | "status": "invited", 16 | "id": "X3icwc4tE8KJ5hEPNPpDXW", 17 | "shopperId": null, 18 | "token": "2LVBntm7z92rnuVjVX5ZVaDoUEaoY4LxhZMMzPAMGyXrrBAB9vRY3BVxGLbAa6uEx7" 19 | } 20 | ] 21 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/updateBillResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "facade": "merchant/bill", 3 | "data": { 4 | "url": "https://bitpay.com/bill?id=3Zpmji8bRKxWJo2NJbWX5H&resource=bills", 5 | "number": "bill1234-EFGH", 6 | "createdDate": "2021-05-21T09:51:04.126Z", 7 | "dueDate": "2021-05-31T00:00:00.000Z", 8 | "currency": "USD", 9 | "name": "John Doe", 10 | "address1": "2630 Hegal Place", 11 | "address2": "Apt 42", 12 | "city": "Alexandria", 13 | "state": "VA", 14 | "zip": "23242", 15 | "country": "US", 16 | "email": "john@doe.com", 17 | "cc": [ 18 | "jane@doe.com" 19 | ], 20 | "phone": "555-123-456", 21 | "passProcessingFee": true, 22 | "emailBill": true, 23 | "id": "3Zpmji8bRKxWJo2NJbWX5H", 24 | "merchant": "7HyKWn3d4xdhAMQYAEVxVq", 25 | "items": [ 26 | { 27 | "id": "8vXbhqWDL1A9F66ZwJAiyJ", 28 | "description": "Test Item 1", 29 | "price": 6, 30 | "quantity": 1 31 | }, 32 | { 33 | "id": "WmgAaPiyuY9L6vBX7KvF2R", 34 | "description": "Test Item 2", 35 | "price": 4, 36 | "quantity": 1 37 | }, 38 | { 39 | "id": "89xhSLYPnLDBczsQHCvJ2D", 40 | "description": "Test Item 3", 41 | "price": 5, 42 | "quantity": 1 43 | } 44 | ], 45 | "token": "7dnoyMe27VDKY1WNrCTqgK5RWbEi4XkvBSUTTwET6XnNYfWKYdrnSyg7myn7oc3vms" 46 | } 47 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/updateInvoiceRequest.json: -------------------------------------------------------------------------------- 1 | {"buyerSms":"+12223334444","token":"someMerchantToken"} -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/updatePayoutRecipientResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "facade": "payout/recipient", 3 | "data": { 4 | "email": "bob@email.com", 5 | "label": "Bob123", 6 | "status": "invited", 7 | "id": "X3icwc4tE8KJ5hEPNPpDXW", 8 | "shopperId": null, 9 | "token": "2LVBntm7z92rnuVjVX5ZVaDoUEaoY4LxhZMMzPAMGyXrrBAB9vRY3BVxGLbAa6uEx7" 10 | } 11 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/updateRefundRequest.json: -------------------------------------------------------------------------------- 1 | {"token":"someMerchantToken","status":"created"} -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/client/json/updateRefundResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "guid": "ee26b5e0-9185-493e-bc12-e846d5fcf07c", 4 | "id": "WoE46gSLkJQS48RJEiNw3L", 5 | "invoice": "Hpqc63wvE1ZjzeeH4kEycF", 6 | "reference": "Test refund", 7 | "status": "created", 8 | "amount": 10, 9 | "transactionCurrency": "BTC", 10 | "transactionAmount": 0.000594, 11 | "transactionRefundFee": 0.000002, 12 | "currency": "USD", 13 | "lastRefundNotification": "2021-08-29T20:45:35.368Z", 14 | "refundFee": 0.04, 15 | "immediate": false, 16 | "buyerPaysRefundFee": false, 17 | "requestDate": "2021-08-29T20:45:34.000Z" 18 | } 19 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/functional/.gitignore: -------------------------------------------------------------------------------- 1 | BitPay.config.json 2 | bitpay_private_prod.key 3 | email.txt -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/functional/client/HttpResponseProviderTest.java: -------------------------------------------------------------------------------- 1 | package com.bitpay.sdk.functional.client; 2 | 3 | import com.bitpay.sdk.client.HttpResponse; 4 | import com.bitpay.sdk.client.HttpResponseProvider; 5 | import com.bitpay.sdk.exceptions.BitPayApiException; 6 | import java.io.IOException; 7 | import org.apache.http.client.HttpClient; 8 | import org.apache.http.client.methods.HttpGet; 9 | import org.apache.http.impl.client.HttpClientBuilder; 10 | import org.junit.jupiter.api.Assertions; 11 | import org.junit.jupiter.api.Test; 12 | import org.junit.jupiter.api.extension.ExtendWith; 13 | import org.mockito.junit.jupiter.MockitoExtension; 14 | 15 | @ExtendWith(MockitoExtension.class) 16 | public class HttpResponseProviderTest { 17 | 18 | @Test 19 | public void it_should_correct_transfer_apache_response_to_bitpay_response() throws IOException, BitPayApiException { 20 | 21 | HttpClient apacheClient = HttpClientBuilder.create().build(); 22 | HttpGet httpGet = new HttpGet("https://jsonplaceholder.typicode.com/posts/1"); 23 | org.apache.http.HttpResponse apacheResponse = apacheClient.execute(httpGet); 24 | 25 | HttpResponse httpResponse = HttpResponseProvider.fromApacheHttpResponse(apacheResponse); 26 | 27 | Assertions.assertEquals(200, httpResponse.getCode()); 28 | Assertions.assertEquals("{\n" + 29 | " \"userId\": 1,\n" + 30 | " \"id\": 1,\n" + 31 | " \"title\": \"sunt aut facere repellat provident occaecati excepturi optio reprehenderit\",\n" + 32 | " \"body\": \"quia et suscipit\\nsuscipit recusandae consequuntur expedita et cum\\nreprehenderit molestiae ut ut quas totam\\nnostrum rerum est autem sunt rem eveniet architecto\"\n" + 33 | "}", httpResponse.getBody()); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/json/cancelPayoutGroupResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "cancelled": [ 3 | { 4 | "id": "JMwv8wQCXANoU2ZZQ9a9GH", 5 | "recipientId": "LDxRZCGq174SF8AnQpdBPB", 6 | "accountId": "2tRxwvX5JkVbhqBLGyanmF", 7 | "shopperId": "7qohDf2zZnQK5Qanj8oyC2", 8 | "amount": 10, 9 | "currency": "USD", 10 | "ledgerCurrency": "GBP", 11 | "email": "john@doe.com", 12 | "reference": "payout_20210527", 13 | "label": "John Doe", 14 | "notificationURL": "https://yournotiticationURL.com/wed3sa0wx1rz5bg0bv97851eqx", 15 | "notificationEmail": "merchant@email.com", 16 | "effectiveDate": "2021-05-27T09:00:00.000Z", 17 | "requestDate": "2021-05-27T10:47:37.834Z", 18 | "status": "cancelled", 19 | "transactions": [] 20 | }, 21 | { 22 | "id": "JMwv8wQCXANoU2ZZQ9a9GH", 23 | "recipientId": "LDxRZCGq174SF8AnQpdBPB", 24 | "accountId": "2tRxwvX5JkVbhqBLGyanmF", 25 | "shopperId": "7qohDf2zZnQK5Qanj8oyC2", 26 | "amount": 20, 27 | "currency": "USD", 28 | "ledgerCurrency": "GBP", 29 | "email": "john@doe.com", 30 | "reference": "payout_20210527", 31 | "label": "John Doe 2", 32 | "notificationURL": "https://yournotiticationURL.com/wed3sa0wx1rz5bg0bv97851eqx", 33 | "notificationEmail": "merchant@email.com", 34 | "effectiveDate": "2021-05-27T09:00:00.000Z", 35 | "requestDate": "2021-05-27T10:47:37.834Z", 36 | "status": "cancelled", 37 | "transactions": [] 38 | } 39 | ], 40 | "failed": [ 41 | { 42 | "errMessage": "PayoutId is missing or invalid", 43 | "payoutId": "D8tgWzn1psUua4NYWW1vYo" 44 | } 45 | ] 46 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/json/createBillPosResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "status": "draft", 3 | "url": "https://bitpay.com/bill?id=X6KJbe9RxAGWNReCwd1xRw&resource=bills", 4 | "number": "bill1234-ABCD", 5 | "createdDate": "2021-05-21T09:48:02.373Z", 6 | "dueDate": "2021-05-31T00:00:00.000Z", 7 | "currency": "USD", 8 | "email": "john@doe.com", 9 | "cc": [ 10 | "jane@doe.com" 11 | ], 12 | "passProcessingFee": true, 13 | "id": "X6KJbe9RxAGWNReCwd1xRw", 14 | "items": [ 15 | { 16 | "id": "EL4vx41Nxc5RYhbqDthjE", 17 | "description": "Test Item 1", 18 | "price": 6, 19 | "quantity": 1 20 | }, 21 | { 22 | "id": "6spPADZ2h6MfADvnhfsuBt", 23 | "description": "Test Item 2", 24 | "price": 4, 25 | "quantity": 1 26 | } 27 | ], 28 | "token": "qVVgRARN6fKtNZ7Tcq6qpoPBBE3NxdrmdMD883RyMK4Pf8EHENKVxCXhRwyynWveo" 29 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/json/createBillRequest.json: -------------------------------------------------------------------------------- 1 | {"address1":"2630 Hegal Place","address2":"Apt 42","cc":["jane@doe.com"],"city":"Alexandria","country":"US","currency":"USD","dueDate":"2021-05-21T09:48:02.37Z","email":"23242","items":[{"description":"Test Item 1","price":6.0,"quantity":1},{"description":"Test Item 2","price":4.0,"quantity":1}],"name":"John Doe","number":"bill1234-ABCD","passProcessingFee":true,"phone":"555-123-456","state":"VA","token":"AKnJyeLF1BjAfgfDbVUzHXk64N1WuDq3R9xtZouQFhSv","zip":"23242"} -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/json/createBillResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "status": "draft", 3 | "url": "https://bitpay.com/bill?id=X6KJbe9RxAGWNReCwd1xRw&resource=bills", 4 | "number": "bill1234-ABCD", 5 | "createdDate": "2021-05-21T09:48:02.373Z", 6 | "dueDate": "2021-05-31T00:00:00.000Z", 7 | "currency": "USD", 8 | "email": "john@doe.com", 9 | "cc": [ 10 | "jane@doe.com" 11 | ], 12 | "passProcessingFee": true, 13 | "id": "X6KJbe9RxAGWNReCwd1xRw", 14 | "items": [ 15 | { 16 | "id": "EL4vx41Nxc5RYhbqDthjE", 17 | "description": "Test Item 1", 18 | "price": 6, 19 | "quantity": 1 20 | }, 21 | { 22 | "id": "6spPADZ2h6MfADvnhfsuBt", 23 | "description": "Test Item 2", 24 | "price": 4, 25 | "quantity": 1 26 | } 27 | ], 28 | "token": "qVVgRARN6fKtNZ7Tcq6qpoPBBE3NxdrmdMD883RyMK4Pf8EHENKVxCXhRwyynWveo" 29 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/json/createInvoiceRequest.json: -------------------------------------------------------------------------------- 1 | {"autoRedirect":true,"buyer":{"address1":"SomeStreet","address2":"911","country":"USA","email":"buyer@buyeremaildomain.com","locality":"Washington","name":"Marcin","notify":true,"postalCode":"20000","region":"District of Columbia"},"currency":"USD","extendedNotifications":true,"forcedBuyerSelectedWallet":"bitpay","fullNotifications":true,"itemDesc":"Example","notificationEmail":"m.warzybok@sumoheavy.com","notificationURL":"https://notification.url/aaa","orderId":"37bd36bd-6fcb-409c-a907-47f9244302aa","price":10.0,"token":"someToken","transactionSpeed":"medium"} -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/json/createRefundRequest.json: -------------------------------------------------------------------------------- 1 | {"preview":true,"reference":"someReference","amount":10.0,"immediate":false,"guid":"37bd36bd-6fcb-409c-a907-47f9244302aa","invoiceId":"UZjwcYkWAKfTMn9J1yyfs4","buyerPaysRefundFee":false,"token":"merchantToken"} -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/json/createRefundResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "guid":"37bd36bd-6fcb-409c-a907-47f9244302aa", 3 | "id": "Eso8srxKJR5U71ahCspAAA", 4 | "invoice": "UZjwcYkWAKfTMn9J1yyfs4", 5 | "reference": "someReference", 6 | "status": "preview", 7 | "amount": 10, 8 | "transactionCurrency": "BTC", 9 | "transactionAmount": 7.19E-4, 10 | "transactionRefundFee": 2.0E-6, 11 | "currency": "USD", 12 | "refundFee": 0.03, 13 | "immediate": false, 14 | "buyerPaysRefundFee": false, 15 | "requestDate": "2022-11-14T12:20:47.000Z" 16 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/json/getBill.json: -------------------------------------------------------------------------------- 1 | { 2 | "status": "draft", 3 | "url": "https://bitpay.com/bill?id=3Zpmji8bRKxWJo2NJbWX5H&resource=bills", 4 | "number": "bill1234-EFGH", 5 | "createdDate": "2021-05-21T09:51:04.126Z", 6 | "dueDate": "2021-05-31T00:00:00.000Z", 7 | "currency": "USD", 8 | "name": "John Doe", 9 | "address1": "2630 Hegal Place", 10 | "address2": "Apt 42", 11 | "city": "Alexandria", 12 | "state": "VA", 13 | "zip": "23242", 14 | "country": "US", 15 | "email": "john@doe.com", 16 | "cc": [ 17 | "jane@doe.com" 18 | ], 19 | "phone": "555-123-456", 20 | "passProcessingFee": true, 21 | "emailBill": true, 22 | "id": "X6KJbe9RxAGWNReCwd1xRw", 23 | "merchant": "7HyKWn3d4xdhAMQYAEVxVq", 24 | "items": [ 25 | { 26 | "id": "NV35GRWtrdB2cmGEjY4LKY", 27 | "description": "Test Item 1", 28 | "price": 6, 29 | "quantity": 1 30 | }, 31 | { 32 | "id": "Apy3i2TpzHRYP8tJCkrZMT", 33 | "description": "Test Item 2", 34 | "price": 4, 35 | "quantity": 1 36 | } 37 | ], 38 | "token": "6EBQR37MgDJPfEiLY3jtRq7eTP2aodR5V5wmXyyZhru5FM5yF4RCGKYQtnT7nhwHjA" 39 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/json/getBills.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "status": "draft", 4 | "url": "https://bitpay.com/bill?id=X6KJbe9RxAGWNReCwd1xRw&resource=bills", 5 | "number": "bill1234-ABCD", 6 | "createdDate": "2021-05-21T09:48:02.373Z", 7 | "dueDate": "2021-05-31T00:00:00.000Z", 8 | "currency": "USD", 9 | "name": "John Doe", 10 | "address1": "2630 Hegal Place", 11 | "address2": "Apt 42", 12 | "city": "Alexandria", 13 | "state": "VA", 14 | "zip": "23242", 15 | "country": "US", 16 | "email": "john@doe.com", 17 | "cc": [ 18 | "jane@doe.com" 19 | ], 20 | "phone": "555-123-456", 21 | "passProcessingFee": true, 22 | "emailBill": true, 23 | "id": "X6KJbe9RxAGWNReCwd1xRw", 24 | "merchant": "7HyKWn3d4xdhAMQYAEVxVq", 25 | "items": [ 26 | { 27 | "id": "EL4vx41Nxc5RYhbqDthjE", 28 | "description": "Test Item 1", 29 | "price": 6, 30 | "quantity": 1 31 | }, 32 | { 33 | "id": "6spPADZ2h6MfADvnhfsuBt", 34 | "description": "Test Item 2", 35 | "price": 4, 36 | "quantity": 1 37 | } 38 | ], 39 | "token": "6EBQR37MgDJPfEiLY3jtRqBMYLg8XSDqhp2kp7VSDqCMHGHnsw4bqnnwQmtehzCvSo" 40 | }, 41 | { 42 | "status": "draft", 43 | "url": "https://bitpay.com/bill?id=3Zpmji8bRKxWJo2NJbWX5H&resource=bills", 44 | "number": "bill1234-EFGH", 45 | "createdDate": "2021-05-21T09:51:04.126Z", 46 | "dueDate": "2021-05-31T00:00:00.000Z", 47 | "currency": "USD", 48 | "name": "John Doe", 49 | "address1": "2630 Hegal Place", 50 | "address2": "Apt 42", 51 | "city": "Alexandria", 52 | "state": "VA", 53 | "zip": "23242", 54 | "country": "US", 55 | "email": "john@doe.com", 56 | "cc": [ 57 | "jane@doe.com" 58 | ], 59 | "phone": "555-123-456", 60 | "passProcessingFee": true, 61 | "emailBill": true, 62 | "id": "3Zpmji8bRKxWJo2NJbWX5H", 63 | "merchant": "7HyKWn3d4xdhAMQYAEVxVq", 64 | "items": [ 65 | { 66 | "id": "NV35GRWtrdB2cmGEjY4LKY", 67 | "description": "Test Item 1", 68 | "price": 6, 69 | "quantity": 1 70 | }, 71 | { 72 | "id": "Apy3i2TpzHRYP8tJCkrZMT", 73 | "description": "Test Item 2", 74 | "price": 4, 75 | "quantity": 1 76 | } 77 | ], 78 | "token": "6EBQR37MgDJPfEiLY3jtRq7eTP2aodR5V5wmXyyZhru5FM5yF4RCGKYQtnT7nhwHjA" 79 | } 80 | ] -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/json/getInvoiceEventToken.json: -------------------------------------------------------------------------------- 1 | { 2 | "url": "https://bitpay.com/events", 3 | "token": "4MuqDPt93i9Xbf8SnAPniwbGeNLW8A3ScgAmukFMgFUFRqTLuuhVdAFfePPysVqL2P", 4 | "events": [ 5 | "payment", 6 | "confirmation" 7 | ], 8 | "actions": [ 9 | "subscribe", 10 | "unsubscribe" 11 | ] 12 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/json/getLedgerBalances.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "currency": "EUR", 4 | "balance": 0 5 | }, 6 | { 7 | "currency": "USD", 8 | "balance": 2389.82 9 | }, 10 | { 11 | "currency": "BTC", 12 | "balance": 0.000287 13 | } 14 | ] -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/json/getLedgers.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "Invoice", 4 | "amount": 823000000, 5 | "code": 1000, 6 | "description": "20210510_fghij", 7 | "timestamp": "2021-05-10T20:08:52.919Z", 8 | "txType": "sale", 9 | "scale": 100000000, 10 | "invoiceId": "Hpqc63wvE1ZjzeeH4kEycF", 11 | "buyerFields": { 12 | "buyerName": "John Doe", 13 | "buyerAddress1": "2630 Hegal Place", 14 | "buyerAddress2": "Apt 42", 15 | "buyerCity": "Alexandria", 16 | "buyerState": "VA", 17 | "buyerZip": "23242", 18 | "buyerCountry": "US", 19 | "buyerPhone": "555-123-456", 20 | "buyerNotify": true, 21 | "buyerEmail": "john@doe.com" 22 | }, 23 | "invoiceAmount": 10, 24 | "invoiceCurrency": "USD", 25 | "transactionCurrency": "BCH", 26 | "id": "FR4rgfADCRNmAhtz1Ci4kU" 27 | }, 28 | { 29 | "type": "Invoice Fee", 30 | "amount": -8000000, 31 | "code": 1023, 32 | "description": "Invoice Fee", 33 | "timestamp": "2021-05-10T20:08:52.919Z", 34 | "txType": "Invoice Fee", 35 | "scale": 100000000, 36 | "invoiceId": "Hpqc63wvE1ZjzeeH4kEycF", 37 | "buyerFields": { 38 | "buyerName": "John Doe", 39 | "buyerAddress1": "2630 Hegal Place", 40 | "buyerAddress2": "Apt 42", 41 | "buyerCity": "Alexandria", 42 | "buyerState": "VA", 43 | "buyerZip": "23242", 44 | "buyerCountry": "US", 45 | "buyerPhone": "555-123-456", 46 | "buyerNotify": true, 47 | "buyerEmail": "john@doe.com" 48 | }, 49 | "invoiceAmount": 10, 50 | "invoiceCurrency": "USD", 51 | "transactionCurrency": "BCH", 52 | "id": "XCkhgHKP2pSme4qszMpM3B" 53 | }, 54 | { 55 | "type": "Invoice Refund", 56 | "supportRequest": "SYyrnbRCJ78V1DknHakKPo", 57 | "amount": -823000000, 58 | "code": 1020, 59 | "description": "Invoice Refund", 60 | "timestamp": "2021-05-12T13:00:45.063Z", 61 | "txType": "Invoice Refund", 62 | "scale": 100000000, 63 | "invoiceId": "Hpqc63wvE1ZjzeeH4kEycF", 64 | "buyerFields": { 65 | "buyerName": "John Doe", 66 | "buyerAddress1": "2630 Hegal Place", 67 | "buyerAddress2": "Apt 42", 68 | "buyerCity": "Alexandria", 69 | "buyerState": "VA", 70 | "buyerZip": "23242", 71 | "buyerCountry": "US", 72 | "buyerPhone": "555-123-456", 73 | "buyerNotify": true, 74 | "buyerEmail": "john@doe.com" 75 | }, 76 | "invoiceAmount": 10, 77 | "invoiceCurrency": "USD", 78 | "transactionCurrency": "BCH", 79 | "id": "PBqakmWMZ2H3RwhGq9vCsg" 80 | } 81 | ] -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/json/getPayouts.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "JMwv8wQCXANoU2ZZQ9a9GH", 4 | "recipientId": "LDxRZCGq174SF8AnQpdBPB", 5 | "shopperId": "7qohDf2zZnQK5Qanj8oyC2", 6 | "amount": 10, 7 | "currency": "USD", 8 | "ledgerCurrency": "GBP", 9 | "exchangeRates": { 10 | "BTC": { 11 | "USD": 39390.47, 12 | "GBP": 27883.962246420004 13 | } 14 | }, 15 | "email": "john@doe.com", 16 | "reference": "payout_20210527", 17 | "label": "John Doe", 18 | "notificationURL": "https://yournotiticationURL.com/wed3sa0wx1rz5bg0bv97851eqx", 19 | "notificationEmail": "merchant@email.com", 20 | "effectiveDate": "2021-05-27T09:00:00.000Z", 21 | "requestDate": "2021-05-27T10:47:37.834Z", 22 | "status": "complete", 23 | "transactions": [ 24 | { 25 | "txid": "db53d7e2bf3385a31257ce09396202d9c2823370a5ca186db315c45e24594057", 26 | "amount": 0.000254, 27 | "date": "2021-05-27T11:04:23.155Z" 28 | } 29 | ], 30 | "token": "9pVLfvdjt59q1JiY2JEsf2uzeeEpSqDwwfRAzuFr9CcrxZX25rTnP6HdRhsMBGLArz" 31 | }, 32 | { 33 | "id": "KMXZeQigXG6T5abzCJmTcH", 34 | "recipientId": "LDxRZCGq174SF8AnQpdBPB", 35 | "shopperId": "7qohDf2zZnQK5Qanj8oyC2", 36 | "amount": 10, 37 | "currency": "USD", 38 | "ledgerCurrency": "GBP", 39 | "email": "jane@doe.com", 40 | "reference": "payout_20210528", 41 | "label": "Jane Doe", 42 | "notificationURL": "https://yournotiticationURL.com/wed3sa0wx1rz5bg0bv97851eqx", 43 | "notificationEmail": "merchant@email.com", 44 | "effectiveDate": "2021-05-28T09:00:00.000Z", 45 | "requestDate": "2021-05-28T10:23:43.765Z", 46 | "status": "cancelled", 47 | "transactions": [], 48 | "token": "9pVLfvdjt59q1JiY2JEsf2hr5FsjimfY4qRLFi85tMiXSCkJ9mQ2oSQqYKVangKaro" 49 | } 50 | ] -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/json/getRates.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "code":"BTC", 4 | "name":"Bitcoin", 5 | "rate":1 6 | }, 7 | { 8 | "code":"BCH", 9 | "name":"Bitcoin Cash", 10 | "rate":50.77 11 | }, 12 | { 13 | "code":"USD", 14 | "name":"US Dollar", 15 | "rate":41248.11 16 | }, 17 | { 18 | "code":"EUR", 19 | "name":"Eurozone Euro", 20 | "rate":33823.04 21 | }, 22 | { 23 | "code":"GBP", 24 | "name":"Pound Sterling", 25 | "rate":29011.49 26 | }, 27 | { 28 | "code":"JPY", 29 | "name":"Japanese Yen", 30 | "rate":4482741 31 | }, 32 | { 33 | "code":"CAD", 34 | "name":"Canadian Dollar", 35 | "rate":49670.85 36 | }, 37 | { 38 | "code":"AUD", 39 | "name":"Australian Dollar", 40 | "rate":53031.99 41 | }, 42 | { 43 | "code":"CNY", 44 | "name":"Chinese Yuan", 45 | "rate":265266.57 46 | } 47 | ] -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/json/getRefund.json: -------------------------------------------------------------------------------- 1 | { 2 | "guid": "37bd36bd-6fcb-409c-a907-47f9244302aa", 3 | "id": "WoE46gSLkJQS48RJEiNw3L", 4 | "invoice": "Hpqc63wvE1ZjzeeH4kEycF", 5 | "reference": "Test refund", 6 | "status": "created", 7 | "amount": 10, 8 | "transactionCurrency": "BTC", 9 | "transactionAmount": 0.000594, 10 | "transactionRefundFee": 0.000002, 11 | "currency": "USD", 12 | "lastRefundNotification": "2021-08-29T20:45:35.368Z", 13 | "refundFee": 0.04, 14 | "immediate": false, 15 | "buyerPaysRefundFee": false, 16 | "requestDate": "2021-08-29T20:45:34.000Z" 17 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/json/getRefunds.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "WoE46gSLkJQS48RJEiNw3L", 4 | "invoice": "Hpqc63wvE1ZjzeeH4kEycF", 5 | "reference": "Test refund", 6 | "status": "created", 7 | "amount": 10, 8 | "transactionCurrency": "BTC", 9 | "transactionAmount": 0.000594, 10 | "transactionRefundFee": 0.000002, 11 | "currency": "USD", 12 | "lastRefundNotification": "2021-08-29T20:45:35.368Z", 13 | "refundFee": 0.04, 14 | "immediate": false, 15 | "buyerPaysRefundFee": false, 16 | "requestDate": "2021-08-29T20:45:34.000Z" 17 | } 18 | ] -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/json/getSettlementResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "RPWTabW8urd3xWv2To989v", 3 | "accountId": "YJCgTf3jrXHkUVzLQ7y4eg", 4 | "status": "processing", 5 | "currency": "EUR", 6 | "payoutInfo": { 7 | "label": "Corporate account", 8 | "bankCountry": "Netherlands", 9 | "name": "Test Organization", 10 | "bank": "Test", 11 | "swift": "RABONL2U", 12 | "account": "NL85ABNA0000000000" 13 | }, 14 | "dateCreated": "2021-05-11T09:05:00.176Z", 15 | "dateExecuted": "2021-05-11T11:52:29.681Z", 16 | "openingDate": "2021-05-10T09:00:00.000Z", 17 | "closingDate": "2021-05-11T09:00:00.000Z", 18 | "openingBalance": 23.27, 19 | "ledgerEntriesSum": 20.82, 20 | "withholdings": [ 21 | { 22 | "amount": 8.21, 23 | "code": "W005", 24 | "description": "Pending Refunds" 25 | } 26 | ], 27 | "withholdingsSum": 8.21, 28 | "totalAmount": 35.88, 29 | "token": "2GrR6GDeYxUFYM9sDKViy6nFFTy4Rjvm1SYdLBjK46jkeJdgUTRccRfhtwkhNcuZky" 30 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/json/getSettlementsResponse.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "KBkdURgmE3Lsy9VTnavZHX", 4 | "accountId": "YJCgTf3jrXHkUVzLQ7y4eg", 5 | "status": "processing", 6 | "currency": "EUR", 7 | "payoutInfo": { 8 | "label": "Corporate account", 9 | "bankCountry": "Netherlands", 10 | "name": "Test Organization", 11 | "bank": "Test", 12 | "swift": "RABONL2U", 13 | "account": "NL85ABNA0000000000" 14 | }, 15 | "dateCreated": "2021-05-10T09:05:00.176Z", 16 | "dateExecuted": "2021-05-10T11:52:29.681Z", 17 | "openingDate": "2021-05-09T09:00:00.000Z", 18 | "closingDate": "2021-05-10T09:00:00.000Z", 19 | "openingBalance": 1.27, 20 | "ledgerEntriesSum": 20.82, 21 | "withholdings": [], 22 | "withholdingsSum": 0, 23 | "totalAmount": 22.09, 24 | "token": "2gBtViSiBWSEJGo1LfaMFHoaBRzE2jek2VitKAYeenj2SRiTVSCgRvs1WTN8w4w8Lc" 25 | }, 26 | { 27 | "id": "RPWTabW8urd3xWv2To989v", 28 | "accountId": "YJCgTf3jrXHkUVzLQ7y4eg", 29 | "status": "processing", 30 | "currency": "EUR", 31 | "payoutInfo": { 32 | "label": "Corporate account", 33 | "bankCountry": "Netherlands", 34 | "name": "Test Organization", 35 | "bank": "Test", 36 | "swift": "RABONL2U", 37 | "account": "NL85ABNA0000000000" 38 | }, 39 | "dateCreated": "2021-05-11T09:05:00.176Z", 40 | "dateExecuted": "2021-05-11T11:52:29.681Z", 41 | "openingDate": "2021-05-10T09:00:00.000Z", 42 | "closingDate": "2021-05-11T09:00:00.000Z", 43 | "openingBalance": 23.27, 44 | "ledgerEntriesSum": 20.82, 45 | "withholdings": [ 46 | { 47 | "amount": 8.21, 48 | "code": "W005", 49 | "description": "Pending Refunds" 50 | } 51 | ], 52 | "withholdingsSum": 8.21, 53 | "totalAmount": 35.88, 54 | "token": "2gBtViSiBWSEJitKAYSCgRvs1WTN8w4Go1Leenj2SRiTVFHoaBRzE2jek2VfaMw8Lc" 55 | } 56 | ] -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/json/payInvoiceRequest.json: -------------------------------------------------------------------------------- 1 | {"token":"F7uTfepHfSyCepeffoA8uj2oeHGoE7w6HgCadXUHXWQJ","status":"complete"} -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/json/refundNotificationResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "status": "success", 3 | "data": {}, 4 | "message": null 5 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/json/retrieveRecipientResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "email": "john.smith@email.com", 3 | "label": "Bob123", 4 | "status": "invited", 5 | "id": "JA4cEtmBxCp5cybtnh1rds", 6 | "shopperId": null, 7 | "token": "2LVBntm7z92rnuVjVX5ZVaDoUEaoY4LxhZMMzPAMGyXcejgPXVmZ4Ae3oGaCGBFKQf" 8 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/json/retrieveRecipientsResponse.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "email": "alice@email.com", 4 | "label": "Alice", 5 | "status": "invited", 6 | "id": "JA4cEtmBxCp5cybtnh1rds", 7 | "shopperId": null, 8 | "token": "2LVBntm7z92rnuVjVX5ZVaDoUEaoY4LxhZMMzPAMGyXcejgPXVmZ4Ae3oGaCGBFKQf" 9 | }, 10 | { 11 | "email": "bob@email.com", 12 | "label": "Bob", 13 | "status": "invited", 14 | "id": "X3icwc4tE8KJ5hEPNPpDXW", 15 | "shopperId": null, 16 | "token": "2LVBntm7z92rnuVjVX5ZVaDoUEaoY4LxhZMMzPAMGyXrrBAB9vRY3BVxGLbAa6uEx7" 17 | } 18 | ] -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/json/submitPayoutGroupRequest.json: -------------------------------------------------------------------------------- 1 | {"instructions":[{"amount":10.0,"currency":"USD","email":"john@doe.com","ledgerCurrency":"GBP","notificationEmail":"merchant@email.com","notificationURL":"https://yournotiticationURL.com/wed3sa0wx1rz5bg0bv97851eqx","reference":"payout_20210527","token":"3tDEActqHSjbc3Hn5MoLH7XTn4hMdGSp6YbmvNDXTr5Y"},{"amount":10.0,"currency":"USD","email":"john@doe.com","ledgerCurrency":"GBP","notificationEmail":"merchant@email.com","notificationURL":"https://yournotiticationURL.com/wed3sa0wx1rz5bg0bv97851eqx","reference":"payout_20210527","token":"3tDEActqHSjbc3Hn5MoLH7XTn4hMdGSp6YbmvNDXTr5Y"}],"token":"3LKKrrNB2BcVAu2Y24QQ78GrKUk2ANLK4eLo85Q1a2HU"} -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/json/submitPayoutGroupResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "created": [ 3 | { 4 | "id": "JMwv8wQCXANoU2ZZQ9a9GH", 5 | "recipientId": "LDxRZCGq174SF8AnQpdBPB", 6 | "accountId": "SJcWZCFq344DL8QnXpdBNM", 7 | "shopperId": "7qohDf2zZnQK5Qanj8oyC2", 8 | "amount": 10, 9 | "currency": "USD", 10 | "ledgerCurrency": "GBP", 11 | "email": "john@doe.com", 12 | "reference": "payout_20210527", 13 | "label": "John Doe", 14 | "notificationURL": "https://yournotiticationURL.com/wed3sa0wx1rz5bg0bv97851eqx", 15 | "notificationEmail": "merchant@email.com", 16 | "effectiveDate": "2021-05-27T09:00:00.000Z", 17 | "requestDate": "2021-05-27T10:47:37.834Z", 18 | "status": "new", 19 | "groupId": "SxKRk4MdW8Ae3vsoR6UPQE", 20 | "transactions": [] 21 | }, 22 | { 23 | "id": "JMwv8wQCXANoU2ZZQ9a9GH", 24 | "recipientId": "LDxRZCGq174SF8AnQpdBPB", 25 | "accountId": "2tRxwvX5JkVbhqBLGyanmF", 26 | "shopperId": "7qohDf2zZnQK5Qanj8oyC2", 27 | "amount": 20, 28 | "currency": "USD", 29 | "ledgerCurrency": "GBP", 30 | "email": "john@doe.com", 31 | "reference": "payout_20210527", 32 | "label": "John Doe 2", 33 | "notificationURL": "https://yournotiticationURL.com/wed3sa0wx1rz5bg0bv97851eqx", 34 | "notificationEmail": "merchant@email.com", 35 | "effectiveDate": "2021-05-27T09:00:00.000Z", 36 | "requestDate": "2021-05-27T10:47:37.834Z", 37 | "status": "new", 38 | "groupId": "SxKRk4MdW8Ae3vsoR6UPQE", 39 | "transactions": [] 40 | } 41 | ], 42 | "failed": [ 43 | { 44 | "errMessage": "Ledger currency is required", 45 | "payee": "john@doe.com" 46 | } 47 | ] 48 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/json/submitPayoutRecipientsRequest.json: -------------------------------------------------------------------------------- 1 | {"recipients":[{"email":"alice@email.com","label":"Alice"},{"email":"bob@email.com","label":"Bob"}],"token":"3LKKrrNB2BcVAu2Y24QQ78GrKUk2ANLK4eLo85Q1a2HU"} -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/json/submitPayoutRecipientsResponse.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "email": "alice@email.com", 4 | "label": "Alice", 5 | "status": "invited", 6 | "id": "JA4cEtmBxCp5cybtnh1rds", 7 | "shopperId": null, 8 | "token": "2LVBntm7z92rnuVjVX5ZVaDoUEaoY4LxhZMMzPAMGyXcejgPXVmZ4Ae3oGaCGBFKQf" 9 | }, 10 | { 11 | "email": "bob@email.com", 12 | "label": "Bob", 13 | "status": "invited", 14 | "id": "X3icwc4tE8KJ5hEPNPpDXW", 15 | "shopperId": null, 16 | "token": "2LVBntm7z92rnuVjVX5ZVaDoUEaoY4LxhZMMzPAMGyXrrBAB9vRY3BVxGLbAa6uEx7" 17 | } 18 | ] -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/json/submitPayoutRequest.json: -------------------------------------------------------------------------------- 1 | {"amount":10.0,"currency":"USD","email":"john@doe.com","ledgerCurrency":"GBP","notificationEmail":"merchant@email.com","notificationURL":"https://yournotiticationURL.com/wed3sa0wx1rz5bg0bv97851eqx","reference":"payout_20210527","token":"3LKKrrNB2BcVAu2Y24QQ78GrKUk2ANLK4eLo85Q1a2HU"} -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/json/submitPayoutResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "JMwv8wQCXANoU2ZZQ9a9GH", 3 | "recipientId": "LDxRZCGq174SF8AnQpdBPB", 4 | "accountId": "SJcWZCFq344DL8QnXpdBNM", 5 | "shopperId": "7qohDf2zZnQK5Qanj8oyC2", 6 | "amount": 10, 7 | "currency": "USD", 8 | "ledgerCurrency": "GBP", 9 | "email": "john@doe.com", 10 | "reference": "payout_20210527", 11 | "label": "John Doe", 12 | "notificationURL": "https://yournotiticationURL.com/wed3sa0wx1rz5bg0bv97851eqx", 13 | "notificationEmail": "merchant@email.com", 14 | "effectiveDate": "2021-05-27T09:00:00.000Z", 15 | "requestDate": "2021-05-27T10:47:37.834Z", 16 | "status": "new", 17 | "transactions": [], 18 | "token": "6RZSTPtnzEaroAe2X4YijenRiqteRDNvzbT8NjtcHjUVd9FUFwa7dsX8RFgRDDC5SL" 19 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/json/success.json: -------------------------------------------------------------------------------- 1 | { 2 | "status": "success", 3 | "data": {}, 4 | "message": null 5 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/json/updateBillRequest.json: -------------------------------------------------------------------------------- 1 | {"address1":"2630 Hegal Place","address2":"Apt 42","cc":["jane@doe.com"],"city":"Alexandria","country":"US","currency":"USD","dueDate":"2021-05-21T09:48:02.37Z","email":"23242","items":[{"description":"Test Item 1","price":6.0,"quantity":1},{"description":"Test Item 2","price":4.0,"quantity":1}],"name":"John Doe","number":"bill1234-ABCD","passProcessingFee":true,"phone":"555-123-456","state":"VA","token":"AKnJyeLF1BjAfgfDbVUzHXk64N1WuDq3R9xtZouQFhSv","zip":"23242"} -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/json/updatePayoutRecipientRequest.json: -------------------------------------------------------------------------------- 1 | {"guid":"37bd36bd-6fcb-409c-a907-47f9244302aa","label":"Bob123","token":"3LKKrrNB2BcVAu2Y24QQ78GrKUk2ANLK4eLo85Q1a2HU"} -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/json/updatePayoutRecipientResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "email": "bob@email.com", 3 | "label": "Bob123", 4 | "status": "invited", 5 | "id": "X3icwc4tE8KJ5hEPNPpDXW", 6 | "shopperId": null, 7 | "token": "2LVBntm7z92rnuVjVX5ZVaDoUEaoY4LxhZMMzPAMGyXrrBAB9vRY3BVxGLbAa6uEx7" 8 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/model/CurrencyTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay 3 | */ 4 | package com.bitpay.sdk.model; 5 | 6 | import org.junit.jupiter.api.Test; 7 | 8 | import static org.junit.jupiter.api.Assertions.assertFalse; 9 | import static org.junit.jupiter.api.Assertions.assertTrue; 10 | 11 | public class CurrencyTest { 12 | @Test 13 | public void it_should_validate() { 14 | String currency = "BTC"; 15 | Boolean isValid = Currency.isValid(currency); 16 | 17 | assertTrue(isValid); 18 | } 19 | 20 | @Test 21 | public void it_should_not_validate() { 22 | String currency = "FAKECURRENCY"; 23 | Boolean isValid = Currency.isValid(currency); 24 | 25 | assertFalse(isValid); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/model/FacadeTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay 3 | */ 4 | package com.bitpay.sdk.model; 5 | 6 | import org.junit.jupiter.api.Assertions; 7 | import org.junit.jupiter.api.Test; 8 | 9 | public class FacadeTest { 10 | 11 | @Test 12 | public void it_should_returns_merchant_string() { 13 | Assertions.assertEquals("merchant", Facade.MERCHANT.toString()); 14 | } 15 | 16 | @Test 17 | public void it_should_returns_payout_string() { 18 | Assertions.assertEquals("payout", Facade.PAYOUT.toString()); 19 | } 20 | } -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/model/PolicyTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay 3 | */ 4 | package com.bitpay.sdk.model; 5 | 6 | import static org.junit.jupiter.api.Assertions.assertEquals; 7 | 8 | import org.junit.jupiter.api.Test; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | public class PolicyTest { 14 | @Test 15 | public void it_should_get_policy() { 16 | String expectedPolicy = "sin"; 17 | 18 | Policy policy = new Policy(); 19 | policy.setPolicy(expectedPolicy); 20 | 21 | String actualPolicy = policy.getPolicy(); 22 | 23 | assertEquals(expectedPolicy, actualPolicy); 24 | } 25 | 26 | @Test 27 | public void it_should_get_method() { 28 | String expectedMethod = "requireSin"; 29 | 30 | Policy policy = new Policy(); 31 | policy.setMethod(expectedMethod); 32 | 33 | String actualMethod = policy.getMethod(); 34 | 35 | assertEquals(expectedMethod, actualMethod); 36 | } 37 | 38 | @Test 39 | public void it_should_get_params() { 40 | List expectedParams = new ArrayList(); 41 | String sin = "Tf1XQVBRPxVeQEQXUb7NTtcoB1qbAzGYBQ9"; 42 | expectedParams.add(sin); 43 | 44 | Policy policy = new Policy(); 45 | policy.setParams(expectedParams); 46 | 47 | List actualParams = policy.getParams(); 48 | 49 | assertEquals(expectedParams, actualParams); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/model/bill/ItemTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay 3 | */ 4 | package com.bitpay.sdk.model.bill; 5 | 6 | import org.junit.jupiter.api.Assertions; 7 | import org.junit.jupiter.api.Test; 8 | 9 | public class ItemTest { 10 | 11 | @Test 12 | public void it_should_manipulate_id() { 13 | String id = "1"; 14 | 15 | Item testedClass = this.getTestedClass(); 16 | testedClass.setId(id); 17 | 18 | Assertions.assertSame(id, testedClass.getId()); 19 | } 20 | 21 | @Test 22 | public void it_should_manipulate_description() { 23 | String description = "someDescription"; 24 | 25 | Item testedClass = this.getTestedClass(); 26 | testedClass.setDescription(description); 27 | 28 | Assertions.assertSame(description, testedClass.getDescription()); 29 | } 30 | 31 | @Test 32 | public void it_should_manipulate_price() { 33 | Double price = 2.00; 34 | 35 | Item testedClass = this.getTestedClass(); 36 | testedClass.setPrice(price); 37 | 38 | Assertions.assertSame(price, testedClass.getPrice()); 39 | } 40 | 41 | @Test 42 | public void it_should_manipulate_quantity() { 43 | Integer quantity = 4; 44 | 45 | Item testedClass = this.getTestedClass(); 46 | testedClass.setQuantity(quantity); 47 | 48 | Assertions.assertSame(quantity, testedClass.getQuantity()); 49 | } 50 | 51 | private Item getTestedClass() { 52 | return new Item(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/model/invoice/InvoiceEventTokenTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay 3 | */ 4 | 5 | package com.bitpay.sdk.model.invoice; 6 | 7 | import java.util.Arrays; 8 | import org.junit.jupiter.api.Assertions; 9 | import org.junit.jupiter.api.Test; 10 | 11 | public class InvoiceEventTokenTest { 12 | 13 | @Test 14 | public void it_should_return_token() { 15 | // given 16 | InvoiceEventToken testedClass = this.getTestedClass(); 17 | 18 | // then 19 | Assertions.assertEquals("4MuqDPt93i9Xbf8SnAPniwbGeNLW8A3ScgAmukFMgFUFRqTLuuhVdAFfePPysVqL2P", testedClass.getToken()); 20 | } 21 | 22 | @Test 23 | public void it_should_return_events() { 24 | // given 25 | InvoiceEventToken testedClass = this.getTestedClass(); 26 | 27 | // then 28 | Assertions.assertEquals(Arrays.asList("payment", "confirmation"), testedClass.getEvents()); 29 | } 30 | 31 | @Test 32 | public void it_should_return_actions() { 33 | // given 34 | InvoiceEventToken testedClass = this.getTestedClass(); 35 | 36 | // then 37 | Assertions.assertEquals(Arrays.asList("subscribe", "unsubscribe"), testedClass.getActions()); 38 | } 39 | 40 | private InvoiceEventToken getTestedClass() { 41 | return new InvoiceEventToken( 42 | "4MuqDPt93i9Xbf8SnAPniwbGeNLW8A3ScgAmukFMgFUFRqTLuuhVdAFfePPysVqL2P", 43 | Arrays.asList("payment", "confirmation"), 44 | Arrays.asList("subscribe", "unsubscribe") 45 | ); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/model/invoice/InvoiceItemizedDetailsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay 3 | */ 4 | 5 | package com.bitpay.sdk.model.invoice; 6 | 7 | import org.junit.jupiter.api.Assertions; 8 | import org.junit.jupiter.api.Test; 9 | 10 | public class InvoiceItemizedDetailsTest { 11 | 12 | @Test 13 | public void it_should_manipulate_id_amount() { 14 | // given 15 | InvoiceItemizedDetails testedClass = this.getTestedClass(); 16 | double expected = 12.34; 17 | 18 | // when 19 | testedClass.setAmount(expected); 20 | 21 | // then 22 | Assertions.assertEquals(expected, testedClass.getAmount()); 23 | } 24 | 25 | @Test 26 | public void it_should_manipulate_id_description() { 27 | // given 28 | InvoiceItemizedDetails testedClass = this.getTestedClass(); 29 | String expected = "SomeDescription"; 30 | 31 | // when 32 | testedClass.setDescription(expected); 33 | 34 | // then 35 | Assertions.assertSame(expected, testedClass.getDescription()); 36 | } 37 | 38 | @Test 39 | public void it_should_manipulate_id_isFee() { 40 | // given 41 | InvoiceItemizedDetails testedClass = this.getTestedClass(); 42 | Boolean expected = true; 43 | 44 | // when 45 | testedClass.setIsFee(expected); 46 | 47 | // then 48 | Assertions.assertSame(expected, testedClass.getIsFee()); 49 | } 50 | 51 | private InvoiceItemizedDetails getTestedClass() { 52 | return new InvoiceItemizedDetails(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/model/invoice/InvoiceRefundAddressTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.bitpay.sdk.model.invoice; 7 | 8 | import java.time.ZonedDateTime; 9 | import org.junit.jupiter.api.Assertions; 10 | import org.junit.jupiter.api.Test; 11 | 12 | public class InvoiceRefundAddressTest { 13 | 14 | @Test 15 | public void it_should_manipulate_type() { 16 | String expected = "exampleType"; 17 | InvoiceRefundAddress testedClass = this.getTestedClass(); 18 | 19 | testedClass.setType(expected); 20 | Assertions.assertSame(expected, testedClass.getType()); 21 | } 22 | 23 | @Test 24 | public void it_should_manipulate_date() { 25 | ZonedDateTime expected = ZonedDateTime.now(); 26 | InvoiceRefundAddress testedClass = this.getTestedClass(); 27 | 28 | testedClass.setDate(expected); 29 | Assertions.assertSame(expected, testedClass.getDate()); 30 | } 31 | 32 | @Test 33 | public void it_should_manipulate_tag() { 34 | Integer expected = 123; 35 | InvoiceRefundAddress testedClass = this.getTestedClass(); 36 | 37 | testedClass.setTag(expected); 38 | Assertions.assertSame(expected, testedClass.getTag()); 39 | } 40 | 41 | @Test 42 | public void it_should_manipulate_email() { 43 | String expected = "example@email.com"; 44 | InvoiceRefundAddress testedClass = this.getTestedClass(); 45 | 46 | testedClass.setEmail(expected); 47 | Assertions.assertSame(expected, testedClass.getEmail()); 48 | } 49 | 50 | private InvoiceRefundAddress getTestedClass() { 51 | return new InvoiceRefundAddress(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/model/invoice/InvoiceStatusTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay 3 | */ 4 | 5 | package com.bitpay.sdk.model.invoice; 6 | 7 | import org.junit.jupiter.api.Assertions; 8 | import org.junit.jupiter.api.Test; 9 | 10 | public class InvoiceStatusTest { 11 | 12 | @Test 13 | public void it_should_return_new_status() { 14 | Assertions.assertSame("new", InvoiceStatus.New); 15 | } 16 | 17 | @Test 18 | public void it_should_return_paid_status() { 19 | Assertions.assertSame("paid", InvoiceStatus.Paid); 20 | } 21 | 22 | @Test 23 | public void it_should_return_confirmed_status() { 24 | Assertions.assertSame("confirmed", InvoiceStatus.Confirmed); 25 | } 26 | 27 | @Test 28 | public void it_should_return_complete_status() { 29 | Assertions.assertSame("complete", InvoiceStatus.Complete); 30 | } 31 | 32 | @Test 33 | public void it_should_return_expired_status() { 34 | Assertions.assertSame("expired", InvoiceStatus.Expired); 35 | } 36 | 37 | @Test 38 | public void it_should_return_invalid_status() { 39 | Assertions.assertSame("invalid", InvoiceStatus.Invalid); 40 | } 41 | 42 | @Test 43 | public void it_should_return_declined_status() { 44 | Assertions.assertSame("declined", InvoiceStatus.Declined); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/model/invoice/InvoiceUniversalCodesTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay 3 | */ 4 | 5 | package com.bitpay.sdk.model.invoice; 6 | 7 | import org.junit.jupiter.api.Assertions; 8 | import org.junit.jupiter.api.Test; 9 | 10 | public class InvoiceUniversalCodesTest { 11 | 12 | @Test 13 | public void it_should_manipulate_paymentString() { 14 | // given 15 | InvoiceUniversalCodes testedClass = this.getTestedClass(); 16 | String expected = "SomePaymentString"; 17 | 18 | // when 19 | testedClass.setBitpay(expected); 20 | 21 | // then 22 | Assertions.assertSame(expected, testedClass.getBitpay()); 23 | } 24 | 25 | @Test 26 | public void it_should_manipulate_verificationLink() { 27 | // given 28 | InvoiceUniversalCodes testedClass = this.getTestedClass(); 29 | String expected = "https://some-url.com"; 30 | 31 | // when 32 | testedClass.setVerificationLink(expected); 33 | 34 | // then 35 | Assertions.assertSame(expected, testedClass.getVerificationLink()); 36 | } 37 | 38 | private InvoiceUniversalCodes getTestedClass() { 39 | return new InvoiceUniversalCodes(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/model/invoice/MinerFeesItemTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay 3 | */ 4 | 5 | package com.bitpay.sdk.model.invoice; 6 | 7 | import java.math.BigDecimal; 8 | import org.junit.jupiter.api.Assertions; 9 | import org.junit.jupiter.api.Test; 10 | 11 | public class MinerFeesItemTest { 12 | 13 | @Test 14 | public void it_should_manipulate_satoshisPerByte() { 15 | // given 16 | Double expected = 765.1; 17 | MinerFeesItem testedClass = this.getTestedClass(); 18 | 19 | // when 20 | testedClass.setSatoshisPerByte(expected); 21 | 22 | // then 23 | Assertions.assertEquals(expected, testedClass.getSatoshisPerByte()); 24 | } 25 | 26 | @Test 27 | public void it_should_manipulate_totalFee() { 28 | // given 29 | Integer expected = 654; 30 | MinerFeesItem testedClass = this.getTestedClass(); 31 | 32 | // when 33 | testedClass.setTotalFee(expected); 34 | 35 | // then 36 | Assertions.assertEquals(expected, testedClass.getTotalFee()); 37 | } 38 | 39 | @Test 40 | public void it_should_manipulate_fiatAmount() { 41 | // given 42 | double expected = 21.23; 43 | MinerFeesItem testedClass = this.getTestedClass(); 44 | 45 | // when 46 | testedClass.setFiatAmount(expected); 47 | 48 | // then 49 | Assertions.assertEquals(expected, testedClass.getFiatAmount()); 50 | } 51 | 52 | private MinerFeesItem getTestedClass() { 53 | return new MinerFeesItem(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/model/invoice/RefundInfoTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay 3 | */ 4 | 5 | package com.bitpay.sdk.model.invoice; 6 | 7 | import com.bitpay.sdk.exceptions.BitPayException; 8 | import java.util.Hashtable; 9 | import org.junit.jupiter.api.Assertions; 10 | import org.junit.jupiter.api.Test; 11 | 12 | public class RefundInfoTest { 13 | 14 | @Test 15 | public void it_should_manipulate_supportRequest() { 16 | // given 17 | String expected = "expectedString"; 18 | RefundInfo testedClass = this.getTestedClass(); 19 | 20 | // when 21 | testedClass.setSupportRequest(expected); 22 | 23 | // then 24 | Assertions.assertEquals(expected, testedClass.getSupportRequest()); 25 | } 26 | 27 | @Test 28 | public void it_should_manipulate_currency() throws BitPayException { 29 | // given 30 | String expected = "BTC"; 31 | RefundInfo testedClass = this.getTestedClass(); 32 | 33 | // when 34 | testedClass.setCurrency(expected); 35 | 36 | // then 37 | Assertions.assertEquals(expected, testedClass.getCurrency()); 38 | } 39 | 40 | @Test 41 | public void it_should_not_allow_to_set_invalid_currency() { 42 | Assertions.assertThrows(BitPayException.class, () -> { 43 | final String invalidCurrency = "INVALID_CURRENCY"; 44 | RefundInfo testedClass = this.getTestedClass(); 45 | 46 | testedClass.setCurrency(invalidCurrency); 47 | }); 48 | } 49 | 50 | @Test 51 | public void it_should_manipulate_amounts() { 52 | // given 53 | Hashtable expected = new Hashtable(); 54 | expected.put("someKey", 12.45); 55 | RefundInfo testedClass = this.getTestedClass(); 56 | 57 | // when 58 | testedClass.setAmounts(expected); 59 | 60 | // then 61 | Assertions.assertSame(expected, testedClass.getAmounts()); 62 | } 63 | 64 | private RefundInfo getTestedClass() { 65 | return new RefundInfo(); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/model/invoice/RefundStatusTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay 3 | */ 4 | 5 | package com.bitpay.sdk.model.invoice; 6 | 7 | import org.junit.jupiter.api.Assertions; 8 | import org.junit.jupiter.api.Test; 9 | 10 | public class RefundStatusTest { 11 | 12 | @Test 13 | public void it_should_return_preview_status() { 14 | Assertions.assertSame("preview", RefundStatus.PREVIEW); 15 | } 16 | 17 | @Test 18 | public void it_should_return_created_status() { 19 | Assertions.assertSame("created", RefundStatus.CREATED); 20 | } 21 | 22 | @Test 23 | public void it_should_return_pending_status() { 24 | Assertions.assertSame("pending", RefundStatus.PENDING); 25 | } 26 | 27 | @Test 28 | public void it_should_return_canceled_status() { 29 | Assertions.assertSame("canceled", RefundStatus.CANCELED); 30 | } 31 | 32 | @Test 33 | public void it_should_return_success_status() { 34 | Assertions.assertSame("success", RefundStatus.SUCCESS); 35 | } 36 | 37 | @Test 38 | public void it_should_return_failure_status() { 39 | Assertions.assertSame("failure", RefundStatus.FAILURE); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/model/invoice/ShopperTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay 3 | */ 4 | 5 | package com.bitpay.sdk.model.invoice; 6 | 7 | import org.junit.jupiter.api.Assertions; 8 | import org.junit.jupiter.api.Test; 9 | 10 | public class ShopperTest { 11 | 12 | @Test 13 | public void it_should_change_name() { 14 | // given 15 | String expectedName = "expectedName"; 16 | Shopper testedClass = new Shopper(); 17 | 18 | // when 19 | testedClass.setName(expectedName); 20 | 21 | // then 22 | Assertions.assertEquals(expectedName, testedClass.getName()); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/model/invoice/SupportedTransactionCurrencyTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay 3 | */ 4 | 5 | package com.bitpay.sdk.model.invoice; 6 | 7 | import org.junit.jupiter.api.Assertions; 8 | import org.junit.jupiter.api.Test; 9 | 10 | public class SupportedTransactionCurrencyTest { 11 | 12 | @Test 13 | public void it_should_change_enabled() { 14 | // given 15 | boolean expected = true; 16 | SupportedTransactionCurrency testedClass = this.getTestedClass(); 17 | 18 | // when 19 | testedClass.setEnabled(expected); 20 | 21 | // then 22 | Assertions.assertSame(expected, testedClass.getEnabled()); 23 | } 24 | 25 | @Test 26 | public void it_should_change_reason() { 27 | // given 28 | String expected = "expectedString"; 29 | SupportedTransactionCurrency testedClass = this.getTestedClass(); 30 | 31 | // when 32 | testedClass.setReason(expected); 33 | 34 | // then 35 | Assertions.assertSame(expected, testedClass.getReason()); 36 | } 37 | 38 | private SupportedTransactionCurrency getTestedClass() { 39 | return new SupportedTransactionCurrency(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/model/ledger/LedgerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay 3 | */ 4 | 5 | package com.bitpay.sdk.model.ledger; 6 | 7 | import org.junit.jupiter.api.Assertions; 8 | import org.junit.jupiter.api.Test; 9 | 10 | public class LedgerTest { 11 | 12 | @Test 13 | public void it_should_change_currency() { 14 | // given 15 | String expected = "expectedString"; 16 | Ledger testedClass = this.getTestedClass(); 17 | 18 | // when 19 | testedClass.setCurrency(expected); 20 | 21 | // then 22 | Assertions.assertEquals(expected, testedClass.getCurrency()); 23 | } 24 | 25 | @Test 26 | public void it_should_change_balance() { 27 | // given 28 | Double expected = 12.34; 29 | Ledger testedClass = this.getTestedClass(); 30 | 31 | // when 32 | testedClass.setBalance(expected); 33 | 34 | // then 35 | Assertions.assertEquals(expected, testedClass.getBalance()); 36 | } 37 | 38 | private Ledger getTestedClass() { 39 | return new Ledger(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/model/payout/PayoutInstructionTransactionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay 3 | */ 4 | 5 | package com.bitpay.sdk.model.payout; 6 | 7 | import java.time.ZonedDateTime; 8 | import org.junit.jupiter.api.Assertions; 9 | import org.junit.jupiter.api.Test; 10 | 11 | public class PayoutInstructionTransactionTest { 12 | 13 | @Test 14 | public void it_should_change_txid() { 15 | // given 16 | String expected = "expectedString"; 17 | PayoutTransaction testedClass = this.getTestedClass(); 18 | 19 | // when 20 | testedClass.setTxid(expected); 21 | 22 | // then 23 | Assertions.assertEquals(expected, testedClass.getTxid()); 24 | } 25 | 26 | @Test 27 | public void it_should_change_amount() { 28 | // given 29 | Double expected = 12.34; 30 | PayoutTransaction testedClass = this.getTestedClass(); 31 | 32 | // when 33 | testedClass.setAmount(expected); 34 | 35 | // then 36 | Assertions.assertEquals(expected, testedClass.getAmount()); 37 | } 38 | 39 | @Test 40 | public void it_should_change_date() { 41 | // given 42 | ZonedDateTime expected = ZonedDateTime.now(); 43 | PayoutTransaction testedClass = this.getTestedClass(); 44 | 45 | // when 46 | testedClass.setDate(expected); 47 | 48 | // then 49 | Assertions.assertEquals(expected, testedClass.getDate()); 50 | } 51 | 52 | 53 | private PayoutTransaction getTestedClass() { 54 | return new PayoutTransaction(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/model/payout/PayoutRecipientsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay 3 | */ 4 | 5 | package com.bitpay.sdk.model.payout; 6 | 7 | import java.util.Collections; 8 | import java.util.List; 9 | import org.junit.jupiter.api.Assertions; 10 | import org.junit.jupiter.api.Test; 11 | import org.mockito.Mockito; 12 | 13 | public class PayoutRecipientsTest { 14 | 15 | @Test 16 | public void it_should_set_default_values() { 17 | // given 18 | List expected = Collections.singletonList(Mockito.mock(PayoutRecipient.class)); 19 | PayoutRecipients testedClass = this.getTestedClass(expected); 20 | 21 | // then 22 | Assertions.assertEquals(expected, testedClass.getInstructions()); 23 | } 24 | 25 | @Test 26 | public void it_should_change_guid() { 27 | // given 28 | String expected = "expectedString"; 29 | PayoutRecipients testedClass = this.getTestedClass(); 30 | 31 | // when 32 | testedClass.setGuid(expected); 33 | 34 | // then 35 | Assertions.assertEquals(expected, testedClass.getGuid()); 36 | } 37 | 38 | @Test 39 | public void it_should_change_recipients() { 40 | // given 41 | List expected = Collections.singletonList(Mockito.mock(PayoutRecipient.class)); 42 | PayoutRecipients testedClass = this.getTestedClass(); 43 | 44 | // when 45 | testedClass.setInstructions(expected); 46 | 47 | // then 48 | Assertions.assertEquals(expected, testedClass.getInstructions()); 49 | } 50 | 51 | @Test 52 | public void it_should_change_token() { 53 | // given 54 | String expected = "expectedString"; 55 | PayoutRecipients testedClass = this.getTestedClass(); 56 | 57 | // when 58 | testedClass.setToken(expected); 59 | 60 | // then 61 | Assertions.assertEquals(expected, testedClass.getToken()); 62 | } 63 | 64 | private PayoutRecipients getTestedClass() { 65 | return new PayoutRecipients(Collections.singletonList(Mockito.mock(PayoutRecipient.class))); 66 | } 67 | 68 | private PayoutRecipients getTestedClass(List recipients) { 69 | return new PayoutRecipients(recipients); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/model/payout/PayoutStatusTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay 3 | */ 4 | 5 | package com.bitpay.sdk.model.payout; 6 | 7 | import org.junit.jupiter.api.Assertions; 8 | import org.junit.jupiter.api.Test; 9 | 10 | public class PayoutStatusTest { 11 | 12 | @Test 13 | public void it_should_return_new_payout_status() { 14 | Assertions.assertEquals("new", PayoutStatus.New); 15 | } 16 | 17 | @Test 18 | public void it_should_return_funded_payout_status() { 19 | Assertions.assertEquals("funded", PayoutStatus.Funded); 20 | } 21 | 22 | @Test 23 | public void it_should_return_processing_payout_status() { 24 | Assertions.assertEquals("processing", PayoutStatus.Processing); 25 | } 26 | 27 | @Test 28 | public void it_should_return_complete_payout_status() { 29 | Assertions.assertEquals("complete", PayoutStatus.Complete); 30 | } 31 | 32 | @Test 33 | public void it_should_return_failed_payout_status() { 34 | Assertions.assertEquals("failed", PayoutStatus.Failed); 35 | } 36 | 37 | @Test 38 | public void it_should_return_cancelled_payout_status() { 39 | Assertions.assertEquals("cancelled", PayoutStatus.Cancelled); 40 | } 41 | 42 | @Test 43 | public void it_should_return_paid_payout_status() { 44 | Assertions.assertEquals("paid", PayoutStatus.Paid); 45 | } 46 | 47 | @Test 48 | public void it_should_return_unpaid_payout_status() { 49 | Assertions.assertEquals("unpaid", PayoutStatus.Unpaid); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/model/payout/RecipientStatusTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay 3 | */ 4 | 5 | package com.bitpay.sdk.model.payout; 6 | 7 | import org.junit.jupiter.api.Assertions; 8 | import org.junit.jupiter.api.Test; 9 | 10 | public class RecipientStatusTest { 11 | 12 | @Test 13 | public void it_should_return_invited_status() { 14 | Assertions.assertEquals("invited", RecipientStatus.INVITED); 15 | } 16 | 17 | @Test 18 | public void it_should_return_unverified_status() { 19 | Assertions.assertEquals("unverified", RecipientStatus.UNVERIFIED); 20 | } 21 | 22 | @Test 23 | public void it_should_return_verified_status() { 24 | Assertions.assertEquals("verified", RecipientStatus.VERIFIED); 25 | } 26 | 27 | @Test 28 | public void it_should_return_active_status() { 29 | Assertions.assertEquals("active", RecipientStatus.ACTIVE); 30 | } 31 | 32 | @Test 33 | public void it_should_return_paused_status() { 34 | Assertions.assertEquals("paused", RecipientStatus.PAUSED); 35 | } 36 | 37 | @Test 38 | public void it_should_return_removed_status() { 39 | Assertions.assertEquals("removed", RecipientStatus.REMOVED); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/model/payout/RecipientWebhookTest.java: -------------------------------------------------------------------------------- 1 | package com.bitpay.sdk.model.payout; 2 | 3 | import org.junit.jupiter.api.Assertions; 4 | import org.junit.jupiter.api.Test; 5 | 6 | class RecipientWebhookTest { 7 | 8 | @Test 9 | public void testManipulateEmail() { 10 | RecipientWebhook testedClass = this.getTestedClass(); 11 | String expected = "someValue"; 12 | testedClass.setEmail(expected); 13 | 14 | Assertions.assertSame(expected, testedClass.getEmail()); 15 | } 16 | 17 | @Test 18 | public void testManipulateLabel() { 19 | RecipientWebhook testedClass = this.getTestedClass(); 20 | String expected = "someValue"; 21 | testedClass.setLabel(expected); 22 | 23 | Assertions.assertSame(expected, testedClass.getLabel()); 24 | } 25 | 26 | @Test 27 | public void testManipulateStatus() { 28 | RecipientWebhook testedClass = this.getTestedClass(); 29 | String expected = "someValue"; 30 | testedClass.setStatus(expected); 31 | 32 | Assertions.assertSame(expected, testedClass.getStatus()); 33 | } 34 | 35 | @Test 36 | public void testManipulateId() { 37 | RecipientWebhook testedClass = this.getTestedClass(); 38 | String expected = "someValue"; 39 | testedClass.setId(expected); 40 | 41 | Assertions.assertSame(expected, testedClass.getId()); 42 | } 43 | 44 | @Test 45 | public void testManipulateShopperId() { 46 | RecipientWebhook testedClass = this.getTestedClass(); 47 | String expected = "someValue"; 48 | testedClass.setShopperId(expected); 49 | 50 | Assertions.assertSame(expected, testedClass.getShopperId()); 51 | } 52 | 53 | private RecipientWebhook getTestedClass() { 54 | return new RecipientWebhook(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/model/rate/RateTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay 3 | */ 4 | package com.bitpay.sdk.model.rate; 5 | 6 | import static org.junit.jupiter.api.Assertions.assertEquals; 7 | 8 | import org.junit.jupiter.api.Test; 9 | 10 | public class RateTest { 11 | @Test 12 | public void it_should_get_name() { 13 | String expectedName = "Bitcoin"; 14 | 15 | Rate rate = new Rate(); 16 | rate.setName(expectedName); 17 | 18 | String actualName = rate.getName(); 19 | 20 | assertEquals(expectedName, actualName); 21 | } 22 | 23 | @Test 24 | public void it_should_get_code() { 25 | String expectedCode = "BTC"; 26 | 27 | Rate rate = new Rate(); 28 | rate.setCode(expectedCode); 29 | 30 | String actualCode = rate.getCode(); 31 | 32 | assertEquals(expectedCode, actualCode); 33 | } 34 | 35 | @Test 36 | public void it_should_vet_value() { 37 | Double expectedValue = 1.0; 38 | 39 | Rate rate = new Rate(); 40 | rate.setValue(expectedValue); 41 | 42 | Double actualValue = rate.getValue(); 43 | 44 | assertEquals(expectedValue, actualValue); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/model/settlement/RefundInfoTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay 3 | */ 4 | 5 | package com.bitpay.sdk.model.settlement; 6 | 7 | import java.util.Hashtable; 8 | import org.junit.jupiter.api.Assertions; 9 | import org.junit.jupiter.api.Test; 10 | 11 | public class RefundInfoTest { 12 | 13 | @Test 14 | public void it_should_change_supportRequest() { 15 | // given 16 | String expected = "expectedString"; 17 | RefundInfo testedClass = this.getTestedClass(); 18 | 19 | // when 20 | testedClass.setSupportRequest(expected); 21 | 22 | // then 23 | Assertions.assertEquals(expected, testedClass.getSupportRequest()); 24 | } 25 | 26 | @Test 27 | public void it_should_change_currency() { 28 | // given 29 | String expected = "expectedString"; 30 | RefundInfo testedClass = this.getTestedClass(); 31 | 32 | // when 33 | testedClass.setCurrency(expected); 34 | 35 | // then 36 | Assertions.assertEquals(expected, testedClass.getCurrency()); 37 | } 38 | 39 | @Test 40 | public void it_should_change_amounts() { 41 | // given 42 | Hashtable expected = new Hashtable(); 43 | RefundInfo testedClass = this.getTestedClass(); 44 | 45 | // when 46 | testedClass.setAmount(expected); 47 | 48 | // then 49 | Assertions.assertSame(expected, testedClass.getAmount()); 50 | } 51 | 52 | private RefundInfo getTestedClass() { 53 | return new RefundInfo(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/model/wallet/CurrencyQrTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay 3 | */ 4 | package com.bitpay.sdk.model.wallet; 5 | 6 | import static org.junit.jupiter.api.Assertions.assertEquals; 7 | 8 | import org.junit.jupiter.api.Test; 9 | 10 | public class CurrencyQrTest { 11 | @Test 12 | public void it_should_get_collapsed() { 13 | Boolean expectedCollapsed = true; 14 | 15 | CurrencyQr currencyQr = new CurrencyQr(); 16 | currencyQr.setCollapsed(expectedCollapsed); 17 | 18 | Boolean actualCollapsed = currencyQr.getCollapsed(); 19 | 20 | assertEquals(expectedCollapsed, actualCollapsed); 21 | } 22 | 23 | @Test 24 | public void it_should_get_type() { 25 | String expectedType = "ADDRESS"; 26 | 27 | CurrencyQr currencyQr = new CurrencyQr(); 28 | currencyQr.setType(expectedType); 29 | 30 | String actualType = currencyQr.getType(); 31 | 32 | assertEquals(expectedType, actualType); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/util/GuidGeneratorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay 3 | */ 4 | 5 | package com.bitpay.sdk.util; 6 | 7 | import org.junit.jupiter.api.Assertions; 8 | import org.junit.jupiter.api.Test; 9 | 10 | public class GuidGeneratorTest { 11 | 12 | @Test 13 | public void it_should_generate_uuid() { 14 | // given 15 | final int uuid4length = 36; 16 | GuidGenerator testedClass = this.getTestedClass(); 17 | 18 | String uuid1 = testedClass.execute(); 19 | String uuid2 = testedClass.execute(); 20 | 21 | Assertions.assertNotEquals(uuid1, uuid2); 22 | Assertions.assertEquals(uuid4length, uuid1.length()); 23 | Assertions.assertEquals(uuid4length, uuid2.length()); 24 | } 25 | 26 | private GuidGenerator getTestedClass() { 27 | return new GuidGenerator(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/util/Iso8601ToZonedDateTimeDeserializerTest.java: -------------------------------------------------------------------------------- 1 | package com.bitpay.sdk.util; 2 | 3 | import com.bitpay.sdk.util.serializer.Iso8601ToZonedDateTimeDeserializer; 4 | import com.fasterxml.jackson.core.JsonParser; 5 | import com.fasterxml.jackson.databind.DeserializationContext; 6 | import com.fasterxml.jackson.databind.json.JsonMapper; 7 | import com.fasterxml.jackson.databind.node.TextNode; 8 | import java.io.IOException; 9 | import java.time.ZonedDateTime; 10 | import org.junit.jupiter.api.Assertions; 11 | import org.junit.jupiter.api.Test; 12 | import org.mockito.Mockito; 13 | 14 | public class Iso8601ToZonedDateTimeDeserializerTest { 15 | 16 | @Test 17 | public void it_should_deserialize_date() throws IOException { 18 | // given 19 | Iso8601ToZonedDateTimeDeserializer testedClass = new Iso8601ToZonedDateTimeDeserializer(); 20 | JsonParser jsonParser = Mockito.mock(JsonParser.class); 21 | JsonMapper jsonMapper = Mockito.mock(JsonMapper.class); 22 | TextNode textNode = Mockito.mock(TextNode.class); 23 | DeserializationContext deserializationContext = Mockito.mock(DeserializationContext.class); 24 | Mockito.when(jsonParser.getCodec()).thenReturn(jsonMapper); 25 | Mockito.when(jsonMapper.readTree(jsonParser)).thenReturn(textNode); 26 | Mockito.when(textNode.asText()).thenReturn("1977-05-24T18:07:03.232Z"); 27 | 28 | // when 29 | ZonedDateTime result = testedClass.deserialize(jsonParser, deserializationContext); 30 | 31 | // then 32 | Assertions.assertEquals("1977-05-24T18:07:03.232Z", result.toString()); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/util/JsonMapperFactoryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay 3 | */ 4 | 5 | package com.bitpay.sdk.util; 6 | 7 | import com.fasterxml.jackson.databind.json.JsonMapper; 8 | import org.junit.jupiter.api.Assertions; 9 | import org.junit.jupiter.api.Test; 10 | import org.junit.jupiter.api.extension.ExtendWith; 11 | import org.mockito.junit.jupiter.MockitoExtension; 12 | 13 | @ExtendWith(MockitoExtension.class) 14 | public class JsonMapperFactoryTest { 15 | 16 | @Test 17 | public void it_should_test_create_object_mapper() { 18 | Assertions.assertSame(JsonMapper.class, JsonMapperFactory.create().getClass()); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/util/KeyUtilsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay 3 | */ 4 | package com.bitpay.sdk.util; 5 | 6 | import static org.junit.jupiter.api.Assertions.assertArrayEquals; 7 | import static org.junit.jupiter.api.Assertions.assertEquals; 8 | import static org.junit.jupiter.api.Assertions.assertNotNull; 9 | 10 | 11 | import com.bitpay.sdk.exceptions.BitPayGenericException; 12 | import org.bitcoinj.core.ECKey; 13 | import org.junit.jupiter.api.Test; 14 | 15 | public class KeyUtilsTest { 16 | 17 | @Test 18 | public void it_should_not_be_null() { 19 | KeyUtils keyUtils = new KeyUtils(); 20 | assertNotNull(keyUtils); 21 | } 22 | 23 | @Test 24 | public void it_should_be_correct_class() { 25 | ECKey expectedClass = new ECKey(); 26 | 27 | ECKey actualClass = KeyUtils.createEcKey(); 28 | 29 | assertEquals(expectedClass.getClass(), actualClass.getClass()); 30 | } 31 | 32 | @Test 33 | public void it_should_be_not_null() { 34 | ECKey actualKey = KeyUtils.createEcKey(); 35 | 36 | assertNotNull(actualKey); 37 | } 38 | 39 | @Test 40 | public void it_should_convert_hex_to_bytes() throws BitPayGenericException { 41 | String hex = "0123456789abcdef"; 42 | byte[] expectedBytes = { 1, 35, 69, 103, -119, -85, -51, -17 }; 43 | 44 | byte[] actualBytes = KeyUtils.hexToBytes(hex); 45 | 46 | assertArrayEquals(expectedBytes, actualBytes); 47 | } 48 | 49 | @Test 50 | public void it_should_convert_bytes_to_hex() { 51 | byte[] bytes = { 1, 35, 69, 103, -119, -85, -51, -17 }; 52 | String expectedHex = "0123456789abcdef"; 53 | 54 | String actualHex = KeyUtils.bytesToHex(bytes); 55 | 56 | assertEquals(expectedHex, actualHex); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/util/TokenContainerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 BitPay 3 | */ 4 | 5 | package com.bitpay.sdk.util; 6 | 7 | import com.bitpay.sdk.exceptions.BitPayException; 8 | import com.bitpay.sdk.model.Facade; 9 | import org.junit.jupiter.api.Assertions; 10 | import org.junit.jupiter.api.Test; 11 | import org.junit.jupiter.api.extension.ExtendWith; 12 | import org.mockito.junit.jupiter.MockitoExtension; 13 | 14 | @ExtendWith(MockitoExtension.class) 15 | public class TokenContainerTest { 16 | 17 | @Test 18 | public void it_should_throws_exception_for_non_existing_access_token() { 19 | Assertions.assertThrows(BitPayException.class, () -> { 20 | TokenContainer testedClass = this.getTestedClass(); 21 | testedClass.getAccessToken("nonExisting"); 22 | }); 23 | } 24 | 25 | @Test 26 | public void it_should_test_getAccessToken() throws BitPayException { 27 | // given 28 | TokenContainer testedClass = this.getTestedClass(); 29 | String key = "someKey"; 30 | String value = "someValue"; 31 | 32 | // when 33 | testedClass.put(key, value); 34 | 35 | // then 36 | Assertions.assertEquals(value, testedClass.getAccessToken(key)); 37 | } 38 | 39 | @Test 40 | public void it_should_test_tokenExist() { 41 | // given 42 | TokenContainer testedClass = this.getTestedClass(); 43 | String value = "someValue"; 44 | 45 | // when 46 | testedClass.put(Facade.PAYOUT.toString(), value); 47 | 48 | // then 49 | Assertions.assertFalse(testedClass.tokenExists("nonExistingFacade")); 50 | Assertions.assertTrue(testedClass.tokenExists(Facade.PAYOUT.toString())); 51 | Assertions.assertTrue(testedClass.tokenExists(Facade.PAYOUT)); 52 | } 53 | 54 | private TokenContainer getTestedClass() { 55 | return new TokenContainer(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/test/java/com/bitpay/sdk/util/ZonedDateTimeToIso8601SerializerTest.java: -------------------------------------------------------------------------------- 1 | package com.bitpay.sdk.util; 2 | 3 | import com.bitpay.sdk.util.serializer.ZonedDateTimeToIso8601Serializer; 4 | import com.fasterxml.jackson.core.JsonGenerator; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | import java.io.IOException; 7 | import java.time.ZonedDateTime; 8 | import java.time.format.DateTimeFormatter; 9 | import org.junit.jupiter.api.Test; 10 | import org.mockito.Mockito; 11 | 12 | public class ZonedDateTimeToIso8601SerializerTest { 13 | 14 | @Test 15 | public void it_should_serialize_date() throws IOException { 16 | // given 17 | ZonedDateTimeToIso8601Serializer testedClass = new ZonedDateTimeToIso8601Serializer(); 18 | JsonGenerator jsonGenerator = Mockito.mock(JsonGenerator.class); 19 | SerializerProvider serializerProvider = Mockito.mock(SerializerProvider.class); 20 | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSX"); 21 | ZonedDateTime value = ZonedDateTime.parse("2021-05-21T09:48:02.373Z", formatter); 22 | 23 | // when 24 | testedClass.serialize(value, jsonGenerator, serializerProvider); 25 | 26 | // then 27 | Mockito.verify(jsonGenerator, Mockito.times(1)).writeString("2021-05-21T09:48:02.37Z"); 28 | } 29 | } 30 | --------------------------------------------------------------------------------