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,550 points
58 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,170 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,550 points
43 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,550 points
51 views
+1 vote
1 answer

How to deploy ethereum smart contracts on a website?

There are many ways to do this: 1 ...READ MORE

answered Mar 26, 2018 in Blockchain by Johnathon
• 9,080 points
99 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,550 points
66 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
169 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,550 points
4,354 views
0 votes
1 answer
0 votes
1 answer