ProductPromotion
Logo

Elixir

made by https://0x3d.site

GitHub - bitpay/elixir-client: Elixir core library for connecting to bitpay.com
Elixir core library for connecting to bitpay.com. Contribute to bitpay/elixir-client development by creating an account on GitHub.
Visit Site

GitHub - bitpay/elixir-client: Elixir core library for connecting to bitpay.com

GitHub - bitpay/elixir-client: Elixir core library for connecting to bitpay.com

GitHub license Travis Hex.pm Coveralls

BitPay Library for Elixir or Erlang

Powerful, flexible, lightweight interface to the BitPay Bitcoin Payment Gateway API. Can be used in an Elixir project or directly in an Erlang project as described in the Elixir Crash Course. This document assumes that you are using Elixir.

Installation

using hex, add to mixfile: { :bitpay, "~> 0.2.4" }

otherwise: { :bitpay, github: "bitpay/elixir-client", tag: "v0.2.4" }

Basic Usage

The bitpay library allows authenticating with BitPay, creating invoices, and retrieving invoices.

Pairing with Bitpay.com

Before pairing with BitPay.com, you'll need to log in to your BitPay account and navigate to /api-tokens. Generate a new pairing code and use it in the next step. If you want to test against

> pem = BitPay.KeyUtils.generate_pem
> webclient = %BitPay.WebClient{pem: pem} #or %BitPay.WebClient{pem: pem, uri: "https://test.bitpay.com"}
> token = BitPay.WebClient.pair_pos_client(pairingcode, webclient)

You'll need to know the pem file and the token in order to create invoices.

To create an invoice with a paired client:

Assuming that you have both a token object and a webclient as shown in the last step:

> webclient = %BitPay.WebClient{pem: pem, uri: "https://test.bitpay.com"}
> params = %{price: 100, currency: "USD", token: token.pos}
> invoice = BitPay.WebClient.create_invoice(params, webclient)

That will return a map representing the invoice, and create an invoice on BitPays servers. Other parameters can be sent, see the BitPay REST API documentation for details.

Testnet Usage

To use testnet, add a uri parameter when creating the webclient struct %BitPay.WebClient{uri: "https://test.bitpay.com"}

API Documentation

API Documentation is available on the BitPay site.

Running the Tests

The tests depend on a custom fork of elixir-webdriver and require that you have phantomjs installed.

Before running the tests, get a test.bitpay.com account. After this, you'll need to use the shell to approve a merchant token. Using iex -S mix:

(iex 1)> pem = BitPay.KeyUtils.generate_pem
(iex 2)> api = "https://test.bitpay.com"
(iex 3)> client = %BitPay.WebClient{pem: pem, uri: api}
(iex 4)> {:ok, pairingCode} = BitPay.WebClient.get_pairing_code(client)

Then log in to your dashboard and use the pairing code to create a "merchant" token. Once this is set, you'll need to create two environment variables, BITPAYPEM and BITPAYAPI, set to the values you used in the shell session. It's a good idea to save the pem to a file so that you can retrieve it later, the tests don't take care of that for you.

Once that's done you should be able to run: mix test and see the tests run.

Found a bug?

Let us know! Send a pull request or a patch. Questions? Ask! We're here to help. We will respond to all filed issues.

Contributors

Click here to see a list of the contributors to this library.

Articles
to learn more about the elixir concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here 🔥.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here 🔥.

Queries
or most google FAQ's about Elixir.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory