mybitcoin-sci-0.2: Binding to mybitcoin.com's Shopping Cart Interface.

Network.MyBitcoin

Description

Interface to mybitcoin.com's shopping cart interface.

After entering your credentials into the config structure, you should be able to use the library like this:

Behold my glorious fortune:

 *Network.MyBitcoin> mbcGetBalance myConfig
 [("SCI Version","1.0"),("SCI Code","1"),("SCI Reason","OK"),("SCI Balance","0.49000000000")]

Well, how much are 0.49 bitcoins worth?

 *Network.MyBitcoin> fmap (lookup "SCI Currency USD Rate") $ mbcGetRates myConfig 
 Just "17.113100"

Can we be sure the responses are authentic?

 *Network.MyBitcoin> mbcPostProcess myConfig "response"
 *** Exception: GPG Signature failure!

This library is shaped after the PHP interface to mybitcoin.com. It uses libcurl and verifies responses with GPG. To enable verification, you need to add the mybitcoin public key to your GPG keychain.

Synopsis

Documentation

mbcSpendSource

Arguments

:: Config 
-> String

Bitcoin address of the receiver.

-> Rational

Amount of bitcoins to send.

-> String

Text associated with the payment so you can remember what it was for. The receiver will not see this note.

-> String

Baggage. MyBitcoin will send this string back to you as part of their two-step commit procedure.

-> IO [(String, String)] 

This method is used for sending bitcoins to other bitcoin addresses. Mybitcoin.com uses a two-step commit procedure where you have to confirm a receipt before the transaction is final.

mbcGetBalance :: Config -> IO [(String, String)]Source

Returns the key "SCI Balance" with your account balance.

mbcGetRates :: Config -> IO [(String, String)]Source

Lists bitcoin exchange rates for various currencies. Presumably taken from Mt. Gox.

mbcEncryptFormData :: Config -> String -> IO [(String, String)]Source

This function is used for receiving payments. You receive payments by redirecting customers to the mybitcoin pay page with your bitcoin address in the query arguments. This method lets you do that without revealing your bitcoin address. See the Merchant Tools at mybitcoin.com for more information.

mbcPostProcess :: Config -> String -> IO [(String, String)]Source

Parse and verify (if enabled) a message from mybitcoin.com. This method is used when processing receipts. See mbcSpend.