How to add Bitcoin as currency for my website

0 votes

I have a website for shopping and I want to add Bitcoin as the currency for payment but when I try to implement this, I get IllegalArgumentException error. I am using java.util.Currency.getInstance("BTC") to set Bitcoin as currency.

How can I make this happen?

Aug 17, 2018 in Blockchain by digger
• 26,740 points
839 views

1 answer to this question.

0 votes

You cannot use BTC as the currency code for bitcoins under ISO 4217: (https://en.wikipedia.org/wiki/ISO_4217#Code_formation ). Unofficially, the wiki for ISO 4217 lists XBT (https://en.wikipedia.org/wiki/ISO_4217#Without_currency_code) as a currency code for bitcoins.

Locale.Builder b = new Locale.Builder();
b.setRegion("XB");
Locale xb = b.build();
Currency bitcoin = Currency.getInstance(xb);

Your currency.properties file will look like:

XB=XBT,000,3

Note that the parsing for java.util.Currencyonly handles a minor unit of 0-3:

Pattern propertiesPattern = Pattern.compile("([A-Z]{3})\\s*,\\s*(\\d{3})\\s*,\\s*([0-3])");
answered Aug 17, 2018 by slayer
• 29,350 points

Related Questions In Blockchain

0 votes
1 answer

How to add https security for Node js?

You need to add the key and cert to the createServer function. const options ...READ MORE

answered Aug 10, 2018 in Blockchain by digger
• 26,740 points
533 views
0 votes
1 answer

How to use bitcoin price as place holder in php?

You can do it by providing an ...READ MORE

answered Aug 21, 2018 in Blockchain by digger
• 26,740 points
546 views
0 votes
0 answers

How to get Bitcoin value for corresponding USD value in ASP.NET C#?

I want to get the Bitcoin value ...READ MORE

Mar 1, 2022 in Blockchain by Soham
• 9,700 points
676 views
0 votes
1 answer

How to compute SHA256 hash for bitcoin header

header_hex = "02000000aaf8ab82362344f49083ee4edef795362cf135293564c4070000000000000000c009bb6222e9bc4cdb8f26b2e8a2f8d163509691a4038fa692abf9a474c9b21476800755c02e17181fe6c1c3" # Decode header hex into ...READ MORE

answered Aug 31, 2018 in Blockchain by digger
• 26,740 points
1,318 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,709 views
+1 vote
3 answers

Removing double quotes from a string from JSON response in PHP

Just remove the json_encode call, and it should work: $resp ...READ MORE

answered Sep 12, 2018 in Blockchain by digger
• 26,740 points
44,016 views
0 votes
1 answer
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP