Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Bitpay with Java

I found this post about BitPay but it's not very clear how I can use it.

https://help.bitpay.com/development/how-do-i-use-the-bitpay-java-client-library

I implemented this code:

public void createInvoice() throws BitPayException
    {
        ECKey key = KeyUtils.createEcKey();
        BitPay bitpay = new BitPay(key);
        InvoiceBuyer buyer = new InvoiceBuyer();
        buyer.setName("Satoshi");
        buyer.setEmail("[email protected]");

        Invoice invoice = new Invoice(100.0, "USD");
        invoice.setBuyer(buyer);
        invoice.setFullNotifications(true);
        invoice.setNotificationEmail("[email protected]");
        invoice.setPosData("ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890");

        Invoice createInvoice = bitpay.createInvoice(invoice);
    }

How should I implement the private key?

like image 931
Peter Penzov Avatar asked Mar 01 '26 18:03

Peter Penzov


1 Answers

You need to go through the client pairing process: https://developer.bitpay.com/reference/getting-access

This will output a file/ json object containing the private key. You can save the json object in your application's resource folder and load it into your client like this:

val configFilePath = ConfigFilePath("src/main/resources/BitPay.config.json")
val bitpayClient = Client.createClientByConfigFilePath(configFilePath)
like image 160
Justin Avatar answered Mar 04 '26 06:03

Justin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!