• Stars
    star
    2
  • Language
    PHP
  • License
    GNU General Publi...
  • Created almost 11 years ago
  • Updated about 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An OOP PHP client for interacting with the BitPay API

BitPayClient

The purpose of this library is to be an object orientated alternative to the official BitPay PHP library.

The library is designed to make it easier to integrate BitPay in to more heavy PHP frameworks that use composer as a package manager such as Symfony2 and Laravel.

The library is written by myself, Peter Fox.

Version

1.1.0 - 16th March 2014 - Allows for throwing exception when an error api response is returned 1.0.0 - 5th Feburary 2014

Installation

Add to your projects composer.json

{
    "require": {
        "peterfox/bitpayclient":"1.0.*"
    }
}

Then run composer install or composer update to install this package.

Usage

The most basic use is as follows:

$client = new BitPayClient('YOUR-API-KEY');

$invoiceResponse = $client->createInvoice(0.0001, 'BTC');

You can supply further parameters for creating an invoice via a third array parameter (to see all possible parameters read the BitPay API):

$client = new BitPayClient('YOUR-API-KEY');

$invoiceResponse = $client->createInvoice(0.0001, 'BTC', ['redirectUrl' => 'http://somewhere']);

You can also supply a PosData value as an array and it will be sent as a Base64 encoded string (please note that other data will be modified to be base64 as well):

$client = new BitPayClient('YOUR-API-KEY');

$invoiceResponse = $client->createInvoice(0.0001, 'BTC', ['posData' => ['some_id' => 100]]);

The library also allows for making responses from Array (like from a $_POST):

$client = new BitPayClient('YOUR-API-KEY');

$invoiceData = [
            'id'=> 'CNRWBUPUZs9foP2ysZBBc',
            'url'=> 'https://bitpay.com/invoice?CNRWBUPUZs9foP2ysZBBc',
            'status' => 'new',
            'btcPrice' => '0.0001',
            'price' => 0.0001,
            'currency' => 'BTC',
            'invoiceTime' => 1391301679184,
            'expirationTime' => 1391302579184,
            'currentTime' => 1391302121888
            ];

$invoiceResponse = $client->getInvoiceFromArray($invoiceData);

There's also the functionality of getting an invoice from BitPay's API if you so wish:

$client = new BitPayClient('YOUR-API-KEY');

$invoiceGetResponse = $client->getInvoice('CNRWBUPUZs9foP2ysZBBc');

Testing

After cloning and installing this repo you can run /vendor/bin/phpunit in the root of the project and test it.

You will have to create a file called apikey.txt in the root directory of the project containing your api to actually run these tests.

The testing of this project uses PHP-VCR which is useful for running the tests multiple times as testCreateInvoice_LimitExceeded() test will cause BitPay to send you an email as a warning which can be a bit tedious. The fixtures are all stored in test/fixtures/.

License

GNU GPL Version 3

More Repositories

1

laravel-webhook-demo

The example code for the article https://medium.com/@SlyFireFox/laravel-innovations-making-your-own-webhook-mechanism-through-notifications-96e75e99a2b1
PHP
17
star
2

laravel-elixir-mjml

A task plugin for running MJML templates in Laravel Elixir
JavaScript
11
star
3

hexavel

A modified version of the Laravel Framework
PHP
7
star
4

openai-laravel-demo

A demo app for using OpenAI with Laravel
PHP
7
star
5

macros-demo

A Demo for Macros
PHP
7
star
6

nova-social-login-demo

A demo for how to implement Social Logins for Laravel Nova
PHP
5
star
7

laravel-runscope

A PHP library for making it easy to use Runscope with your web hooks and external API calls
PHP
5
star
8

notifications-demo

The code in this project is an example of how to create a simple streamlined email unsubscribe mechanism for Laravel's notification system
PHP
5
star
9

hieroglyph

A package to simplify changing between different icon sets
PHP
3
star
10

roadrunner-plugin-template

Template project for a RoadRunner plugin
Go
3
star
11

validation-rule-demo

The example code for the article https://medium.com/@SlyFireFox/test-driven-development-for-custom-laravel-validation-rules-669d01e34a65
PHP
2
star
12

seo-demo

The code in this project is an example of how to create root level URLs for dynamic content without causing wildcard clashes
PHP
2
star
13

make-command-demo

A demo for making new Make commands in Laravel
PHP
2
star
14

laravel-incident-logs-demo

The example code for the article https://medium.com/@SlyFireFox/laravel-how-to-make-incident-logs-d7fa88e48490
PHP
2
star
15

hexavel-spark

A library for making installs of Spark compatible with Laravel Spark
PHP
1
star
16

torino

An example of a simple Onion address generator
JavaScript
1
star
17

graphaware-reco-client-php

A configurable PHP library for fetching recommendations from a GraphAware Recommendation setup
PHP
1
star
18

waitformysql

A mini golang util for waiting for a mysql database to be up
Go
1
star
19

laravel-casts-examples

A demo for Laravel Custom Casts with common examples for Money, Location/Address and Date Intervals
PHP
1
star
20

testing-trait-hooks-demo

Demo for Trait hooks to use in Test Cases
PHP
1
star
21

custom-make-model-command

A demo for customising the Laravel make model command to use singular table names.
PHP
1
star