Compare commits
185 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
57922eea0c | ||
|
|
54b169ecb1 | ||
|
|
4deeb7dcb7 | ||
|
|
2bfef47d65 | ||
|
|
21187ecb7c | ||
|
|
84324e9f9c | ||
|
|
a1deccd995 | ||
|
|
0fb3a8cc24 | ||
|
|
cf0ae957cb | ||
|
|
4f370def47 | ||
|
|
5967bd115c | ||
|
|
75ec2a8512 | ||
|
|
9c83ef4788 | ||
|
|
c2e2048505 | ||
|
|
b2c805099a | ||
|
|
4fce92814a | ||
|
|
871debbbb4 | ||
|
|
66537e588f | ||
|
|
8a228cdda6 | ||
|
|
a0dd12b860 | ||
|
|
366a62065f | ||
|
|
a4bd4a2733 | ||
|
|
b6b12087d5 | ||
|
|
e96fcd3447 | ||
|
|
66e1269a92 | ||
|
|
0f8c3abd27 | ||
|
|
f52511c7d2 | ||
|
|
c0ab518282 | ||
|
|
f5cf55eed6 | ||
|
|
dba40cf579 | ||
|
|
d8d23fcbd8 | ||
|
|
4a0f0f969b | ||
|
|
9a2250c71d | ||
|
|
37cc9f97f0 | ||
|
|
f539f435b3 | ||
|
|
6ccabf89cd | ||
|
|
8253cd25d2 | ||
|
|
e0ed633d50 | ||
|
|
a3bfc4416b | ||
|
|
dfeeb04b25 | ||
|
|
c3e89d99e0 | ||
|
|
8d758fa24a | ||
|
|
48e0eb2d07 | ||
|
|
63bd1a6a0c | ||
|
|
5bfcc6026b | ||
|
|
ff700ec8ed | ||
|
|
e3de9d9757 | ||
|
|
aeb965c8f7 | ||
|
|
8f5625eb3e | ||
|
|
52efd15474 | ||
|
|
9506d425cd | ||
|
|
db61457819 | ||
|
|
34de91fa4b | ||
|
|
b43a8750f1 | ||
|
|
c0fe48e947 | ||
|
|
2f9295eb59 | ||
|
|
e796d8ee0c | ||
|
|
35ae47f04f | ||
|
|
713f46b70b | ||
|
|
cde7566614 | ||
|
|
261a1f1066 | ||
|
|
344adcf98f | ||
|
|
e30a00a405 | ||
|
|
8c02b57175 | ||
|
|
b4b377c77c | ||
|
|
d74d6dba11 | ||
|
|
6827953da0 | ||
|
|
58dd99921b | ||
|
|
2486247fd6 | ||
|
|
2204e5e42a | ||
|
|
b1382029d2 | ||
|
|
0fbb661de9 | ||
|
|
10b8cecaed | ||
|
|
ff7876fe3a | ||
|
|
6641f919da | ||
|
|
5360adc697 | ||
|
|
654184bc2a | ||
|
|
91f3a23fe7 | ||
|
|
5cafe38f80 | ||
|
|
5503814aa6 | ||
|
|
f9fb38cf55 | ||
|
|
24573a19e3 | ||
|
|
e58e21db36 | ||
|
|
a0facda4d9 | ||
|
|
f84b9ec3bd | ||
|
|
d4902d9cf0 | ||
|
|
80e710c521 | ||
|
|
701129a811 | ||
|
|
97c4344237 | ||
|
|
ce450ea8cd | ||
|
|
1e72d49bfc | ||
|
|
70df1190ba | ||
|
|
6fad9f6b78 | ||
|
|
feef9081de | ||
|
|
2c854bdd44 | ||
|
|
0ae18e763b | ||
|
|
3f95d2fe87 | ||
|
|
87614cf494 | ||
|
|
a360bdeeee | ||
|
|
9668ccdb93 | ||
|
|
2611175288 | ||
|
|
df9a608d07 | ||
|
|
f50af5c4f7 | ||
|
|
597e364d65 | ||
|
|
7e7737416e | ||
|
|
58a52f76b5 | ||
|
|
347eecf8bb | ||
|
|
7f840e39bc | ||
|
|
7a27ea32a9 | ||
|
|
0b39a2733d | ||
|
|
e33ae9476a | ||
|
|
848a9006c2 | ||
|
|
82eade1531 | ||
|
|
43e9b915ae | ||
|
|
a16d119124 | ||
|
|
029d4f847f | ||
|
|
cb8b635480 | ||
|
|
b6e3c4be5d | ||
|
|
0167d42270 | ||
|
|
e3177a10b8 | ||
|
|
37847b5422 | ||
|
|
51c74e5768 | ||
|
|
6e1bcd2945 | ||
|
|
a925f5a75f | ||
|
|
6fc1aa9384 | ||
|
|
e2a6fae9ed | ||
|
|
9df235b204 | ||
|
|
07af641f4b | ||
|
|
aeb380df5c | ||
|
|
a21df08eb8 | ||
|
|
f923cf2ae3 | ||
|
|
e17cdd3a2f | ||
|
|
3939d2a6b5 | ||
|
|
a7eb7bed6f | ||
|
|
a66d98b3af | ||
|
|
991a869e27 | ||
|
|
715e4cd70b | ||
|
|
8198790488 | ||
|
|
7fee602207 | ||
|
|
03fe25ceee | ||
|
|
31a1283057 | ||
|
|
31cc0f7a8d | ||
|
|
98981dfa8c | ||
|
|
198b304dd7 | ||
|
|
a6e5b5f436 | ||
|
|
5f22e8208b | ||
|
|
7736734033 | ||
|
|
4d59247fc0 | ||
|
|
e211ed5834 | ||
|
|
82f1ea62b4 | ||
|
|
56d8804f40 | ||
|
|
5b46f35260 | ||
|
|
4ae7392e8c | ||
|
|
9a28b90f60 | ||
|
|
971f65c584 | ||
|
|
e6aa1c44b2 | ||
|
|
7fa8139380 | ||
|
|
7364d7cd42 | ||
|
|
dfa099e381 | ||
|
|
b424b2ae90 | ||
|
|
effcee7a15 | ||
|
|
ba83f555ea | ||
|
|
1d9e7c4664 | ||
|
|
18d8219ca6 | ||
|
|
a8ebc01d9d | ||
|
|
6b67fbab84 | ||
|
|
65bc02b4d9 | ||
|
|
281a2625e5 | ||
|
|
6689dd3344 | ||
|
|
5f7b18ccb0 | ||
|
|
580d4a5b27 | ||
|
|
8bf7a62e97 | ||
|
|
ed7b4a2ffc | ||
|
|
4d12f6aa65 | ||
|
|
2f60d3acb7 | ||
|
|
c6503e0233 | ||
|
|
014da0dc55 | ||
|
|
5766d8a67f | ||
|
|
8da8aeda2c | ||
|
|
97162a5cd5 | ||
|
|
f8a7a98d4a | ||
|
|
4f61601b85 | ||
|
|
9efe33beb1 | ||
|
|
e3e6beb176 | ||
|
|
d49bf1f7f4 |
@ -26,6 +26,9 @@ after_script:
|
||||
notifications:
|
||||
email: false
|
||||
|
||||
sudo:
|
||||
false
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
|
||||
|
||||
19
CHANGELOG.md
19
CHANGELOG.md
@ -83,6 +83,25 @@ Included buyer notify field (when creating an invoice)
|
||||
- HTTP 100 messages not parsed correctly when doing payouts
|
||||
|
||||
## [Unreleased][unreleased]
|
||||
## [3.0.0] - 2016-03-10
|
||||
###Fixed
|
||||
- should respect that numbers coming from the api might not have decimal points at all, but they are still valid
|
||||
- Bug fixes that include proper type checking for invoice object creation
|
||||
- Fixed invoice, expiration, and current time error
|
||||
- Repaired tests based on current changes to the code.
|
||||
|
||||
###Added
|
||||
- Using this library with Symfony >=2.3 or Symfony 3.0.x should work. So if you are already using Symfony 3.0, then this library should work with it too.
|
||||
- Leo Hochberg added PaymentUrl support to the library since the BitPay backend support it. Thanks Leo.
|
||||
|
||||
## [2.2.7] - 2015-10-28
|
||||
###Fixed
|
||||
- btcPaid on invoice responses now contains the amount paid instead of the price
|
||||
|
||||
## [2.2.6] - 2015-07-31
|
||||
###Fixed
|
||||
- The fixes several issues, including "Price only accepts .00 precision" and "Invoice exception state"
|
||||
|
||||
### Changed
|
||||
- Refactored function calls out of loops
|
||||
|
||||
|
||||
2
Makefile
2
Makefile
@ -1,5 +1,5 @@
|
||||
setup:
|
||||
composer.phar install
|
||||
./composer.phar install
|
||||
npm install
|
||||
|
||||
test:
|
||||
|
||||
23
README.md
23
README.md
@ -8,11 +8,10 @@ bitpay/php-bitpay-client
|
||||
[](https://scrutinizer-ci.com/g/bitpay/php-bitpay-client/)
|
||||
[](https://coveralls.io/r/bitpay/php-bitpay-client)
|
||||
|
||||
[](https://readthedocs.org/projects/php-bitpay-client/?badge=latest)
|
||||
[](https://packagist.org/packages/bitpay/php-client)
|
||||
[](https://packagist.org/packages/bitpay/php-client)
|
||||
|
||||
This is a self-contained PHP implementation of BitPay's new cryptographically secure API: https://bitpay.com/api
|
||||
This is a self-contained PHP implementation of BitPay's cryptographically secure API: https://bitpay.com/api
|
||||
|
||||
# Installation
|
||||
|
||||
@ -33,7 +32,7 @@ Add to your composer.json file by hand.
|
||||
...
|
||||
"require": {
|
||||
...
|
||||
"bitpay/php-client": "~2.2"
|
||||
"bitpay/php-client": "^3.0"
|
||||
}
|
||||
...
|
||||
}
|
||||
@ -57,24 +56,6 @@ See https://support.bitpay.com/hc/en-us/articles/115003001063-How-do-I-configure
|
||||
|
||||
# Usage
|
||||
|
||||
## Autoloader
|
||||
|
||||
To use the library's autoloader (which doesn't include composer dependencies)
|
||||
instead of composer's autoloader, use the following code:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$autoloader = __DIR__ . '/relative/path/to/Bitpay/Autoloader.php';
|
||||
if (true === file_exists($autoloader) &&
|
||||
true === is_readable($autoloader))
|
||||
{
|
||||
require_once $autoloader;
|
||||
\Bitpay\Autoloader::register();
|
||||
} else {
|
||||
throw new Exception('BitPay Library could not be loaded');
|
||||
}
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
Please see the ``docs`` directory for information on how to use this library
|
||||
|
||||
32
behat.yml
32
behat.yml
@ -1,32 +0,0 @@
|
||||
# behat.yml
|
||||
|
||||
default:
|
||||
context:
|
||||
parameters:
|
||||
user:
|
||||
password:
|
||||
base_url:
|
||||
driver: 'selenium2'
|
||||
paths:
|
||||
features: tests/integrations
|
||||
bootstrap: %behat.paths.features%/bootstrap
|
||||
extensions:
|
||||
Behat\MinkExtension\Extension:
|
||||
goutte: ~
|
||||
selenium2: ~
|
||||
|
||||
phantomjs:
|
||||
context:
|
||||
parameters:
|
||||
user:
|
||||
password:
|
||||
base_url:
|
||||
driver: 'phantomjs'
|
||||
paths:
|
||||
features: tests/integrations
|
||||
bootstrap: %behat.paths.features%/bootstrap
|
||||
extensions:
|
||||
Behat\MinkExtension\Extension:
|
||||
goutte: ~
|
||||
selenium2:
|
||||
wd_host: "http://localhost:8643/wd/hub"
|
||||
@ -3,12 +3,11 @@
|
||||
<project name="bitpay/package" default="build">
|
||||
<target name="build" depends="lint,phpunit,phpcs" />
|
||||
|
||||
<target name="lint"
|
||||
description="Check the syntax of PHP files">
|
||||
<target name="lint" description="Check the syntax of PHP files">
|
||||
<mkdir dir="${project.basedir}/build/cache" />
|
||||
<phplint cachefile="${project.basedir}/build/cache/phplint.cache">
|
||||
<fileset dir="${project.basedir}/src">
|
||||
<include name="**/*.php"/>
|
||||
<include name="**/*.php" />
|
||||
</fileset>
|
||||
</phplint>
|
||||
</target>
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
require_once 'phar://bitpay.phar/src/Bitpay/Autoloader.php';
|
||||
\Bitpay\Autoloader::register();
|
||||
require_once 'phar://bitpay.phar/bin/bitpay';
|
||||
__HALT_COMPILER();
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "bitpay/php-client",
|
||||
"description": "PHP Library to work with the new cryptographically secure BitPay API",
|
||||
"description": "PHP Library to work with the cryptographically secure BitPay API",
|
||||
"license": "MIT",
|
||||
"minimum-stability": "stable",
|
||||
"keywords": ["bitpay", "bitcoin"],
|
||||
@ -32,13 +32,8 @@
|
||||
"symfony/dependency-injection": "^2.3 || ^3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"behat/behat": "2.5.*@stable",
|
||||
"behat/mink": "1.6.1",
|
||||
"behat/mink-extension": "1.3.*",
|
||||
"behat/mink-selenium2-driver": "1.2.0",
|
||||
"fabpot/goutte": "~1.0.4",
|
||||
"behat/mink-goutte-driver": "1.*",
|
||||
"phpmd/phpmd": "~2.1.3",
|
||||
"phpmd/phpmd": "master-dev",
|
||||
"phpunit/phpunit": "~4.3.1",
|
||||
"fzaninotto/faker": "~1.4.0",
|
||||
"mikey179/vfsStream": "~1.4.0",
|
||||
@ -53,7 +48,7 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.2.x-dev"
|
||||
"dev-master": "3.0.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,25 +3,6 @@ Please make sure that you have Installed this library and have
|
||||
Configured it correctly. This section will help guide you on how to use
|
||||
this library.
|
||||
|
||||
Autoloader
|
||||
==========
|
||||
|
||||
To use the library's autoloader (which doesn't include composer dependencies)
|
||||
instead of composer's autoloader, use the following code:
|
||||
|
||||
``` {.sourceCode .php}
|
||||
<?php
|
||||
$autoloader = __DIR__ . '/relative/path/to/Bitpay/Autoloader.php';
|
||||
if (true === file_exists($autoloader) &&
|
||||
true === is_readable($autoloader))
|
||||
{
|
||||
require_once $autoloader;
|
||||
\Bitpay\Autoloader::register();
|
||||
} else {
|
||||
throw new Exception('BitPay Library could not be loaded');
|
||||
}
|
||||
```
|
||||
|
||||
Dependency Injection
|
||||
====================
|
||||
|
||||
|
||||
@ -27,24 +27,20 @@ class AccessToken implements AccessTokenInterface
|
||||
protected $label;
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
* Set various defaults for this object.
|
||||
*/
|
||||
protected $useNonce;
|
||||
|
||||
/**
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct($id = null, $email = null, $label = null)
|
||||
{
|
||||
/**
|
||||
* Set various defaults for this object.
|
||||
*/
|
||||
$this->useNonce = true;
|
||||
$this->id = $id;
|
||||
$this->email = $email;
|
||||
$this->label = $label;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
* Setter for the id.
|
||||
*
|
||||
* @return AccessTokenInterface
|
||||
* @param string $id
|
||||
* @return AccessToken
|
||||
*/
|
||||
public function setId($id)
|
||||
{
|
||||
@ -64,9 +60,10 @@ class AccessToken implements AccessTokenInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $email
|
||||
* Setter for the email address.
|
||||
*
|
||||
* @return AccessTokenInterface
|
||||
* @param string $email
|
||||
* @return AccessToken
|
||||
*/
|
||||
public function setEmail($email)
|
||||
{
|
||||
@ -86,9 +83,10 @@ class AccessToken implements AccessTokenInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $label
|
||||
* Setter for the label.
|
||||
*
|
||||
* @return AccessTokenInterface
|
||||
* @param string $label
|
||||
* @return AccessToken
|
||||
*/
|
||||
public function setLabel($label)
|
||||
{
|
||||
@ -106,36 +104,4 @@ class AccessToken implements AccessTokenInterface
|
||||
{
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function isNonceDisabled()
|
||||
{
|
||||
return !($this->useNonce);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable nonce usage
|
||||
*
|
||||
* @return AccessTokenInterface
|
||||
*/
|
||||
public function nonceEnable()
|
||||
{
|
||||
$this->useNonce = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable nonce usage
|
||||
*
|
||||
* @return AccessTokenInterface
|
||||
*/
|
||||
public function nonceDisable()
|
||||
{
|
||||
$this->useNonce = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
namespace Bitpay;
|
||||
|
||||
/**
|
||||
* Creates an access token for the given client
|
||||
* Interface for an access token for the given client
|
||||
*
|
||||
* @package Bitpay
|
||||
*/
|
||||
@ -27,9 +27,4 @@ interface AccessTokenInterface
|
||||
* @return string
|
||||
*/
|
||||
public function getLabel();
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isNonceDisabled();
|
||||
}
|
||||
|
||||
@ -7,7 +7,6 @@
|
||||
namespace Bitpay;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Bitpay
|
||||
*/
|
||||
class Application implements ApplicationInterface
|
||||
@ -22,8 +21,6 @@ class Application implements ApplicationInterface
|
||||
*/
|
||||
protected $orgs;
|
||||
|
||||
/**
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->users = array();
|
||||
@ -49,11 +46,10 @@ class Application implements ApplicationInterface
|
||||
/**
|
||||
* Add user to stack
|
||||
*
|
||||
* @param UserInterface $user
|
||||
*
|
||||
* @return ApplicationInterface
|
||||
* @param User $user
|
||||
* @return Application
|
||||
*/
|
||||
public function addUser(UserInterface $user)
|
||||
public function addUser(User $user)
|
||||
{
|
||||
if (!empty($user)) {
|
||||
$this->users[] = $user;
|
||||
@ -65,11 +61,10 @@ class Application implements ApplicationInterface
|
||||
/**
|
||||
* Add org to stack
|
||||
*
|
||||
* @param OrgInterface $org
|
||||
*
|
||||
* @return ApplicationInterface
|
||||
* @param Org $org
|
||||
* @return Application
|
||||
*/
|
||||
public function addOrg(OrgInterface $org)
|
||||
public function addOrg(Org $org)
|
||||
{
|
||||
if (!empty($org)) {
|
||||
$this->orgs[] = $org;
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace Bitpay;
|
||||
|
||||
/**
|
||||
* Creates an application for a new merchant account
|
||||
* Creates an application for a new merchant account.
|
||||
*
|
||||
* @package Bitpay
|
||||
*/
|
||||
|
||||
@ -1,58 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace Bitpay;
|
||||
|
||||
/**
|
||||
* @package Bitpay
|
||||
*/
|
||||
class Autoloader
|
||||
{
|
||||
/**
|
||||
* Register the autoloader, by default this will put the BitPay autoloader
|
||||
* first on the stack, to append the autoloader, pass `false` as an argument.
|
||||
*
|
||||
* Some applications will throw exceptions if the class isn't found and
|
||||
* some are not compatible with PSR standards.
|
||||
*
|
||||
* @param boolean $prepend
|
||||
*/
|
||||
public static function register($prepend = true)
|
||||
{
|
||||
spl_autoload_register(array(__CLASS__, 'autoload'), true, (bool) $prepend);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister this autoloader
|
||||
*/
|
||||
public static function unregister()
|
||||
{
|
||||
spl_autoload_unregister(array(__CLASS__, 'autoload'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Give a class name and it will require the file.
|
||||
*
|
||||
* @param string $class
|
||||
* @return bool
|
||||
*/
|
||||
public static function autoload($class)
|
||||
{
|
||||
if (0 === strpos($class, 'Bitpay\\')) {
|
||||
$classname = substr($class, 7);
|
||||
|
||||
$file = __DIR__.DIRECTORY_SEPARATOR.str_replace('\\', DIRECTORY_SEPARATOR, $classname).'.php';
|
||||
|
||||
if (is_file($file) && is_readable($file)) {
|
||||
require_once $file;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
throw new \Exception(sprintf('Class "%s" Not Found', $class));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -18,7 +18,7 @@ class Bill implements BillInterface
|
||||
protected $items;
|
||||
|
||||
/**
|
||||
* @var CurrencyInterface
|
||||
* @var Currency
|
||||
*/
|
||||
protected $currency;
|
||||
|
||||
@ -77,8 +77,6 @@ class Bill implements BillInterface
|
||||
*/
|
||||
protected $archived;
|
||||
|
||||
/**
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->address = array();
|
||||
@ -96,11 +94,10 @@ class Bill implements BillInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ItemInterface $item
|
||||
*
|
||||
* @return BillInterface
|
||||
* @param Item $item
|
||||
* @return Bill
|
||||
*/
|
||||
public function addItem(ItemInterface $item)
|
||||
public function addItem(Item $item)
|
||||
{
|
||||
if (!empty($item)) {
|
||||
$this->items[] = $item;
|
||||
@ -118,11 +115,10 @@ class Bill implements BillInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CurrencyInterface $currency
|
||||
*
|
||||
* @return BillInterface
|
||||
* @param Currency $currency
|
||||
* @return Bill
|
||||
*/
|
||||
public function setCurrency(CurrencyInterface $currency)
|
||||
public function setCurrency(Currency $currency)
|
||||
{
|
||||
if (!empty($currency)) {
|
||||
$this->currency = $currency;
|
||||
@ -141,8 +137,7 @@ class Bill implements BillInterface
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return BillInterface
|
||||
* @return Bill
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
@ -163,8 +158,7 @@ class Bill implements BillInterface
|
||||
|
||||
/**
|
||||
* @param array $address
|
||||
*
|
||||
* @return BillInterface
|
||||
* @return Bill
|
||||
*/
|
||||
public function setAddress($address)
|
||||
{
|
||||
@ -185,8 +179,7 @@ class Bill implements BillInterface
|
||||
|
||||
/**
|
||||
* @param string $city
|
||||
*
|
||||
* @return BillInterface
|
||||
* @return Bill
|
||||
*/
|
||||
public function setCity($city)
|
||||
{
|
||||
@ -207,8 +200,7 @@ class Bill implements BillInterface
|
||||
|
||||
/**
|
||||
* @param string $state
|
||||
*
|
||||
* @return BillInterface
|
||||
* @return Bill
|
||||
*/
|
||||
public function setState($state)
|
||||
{
|
||||
@ -229,8 +221,7 @@ class Bill implements BillInterface
|
||||
|
||||
/**
|
||||
* @param string $zip
|
||||
*
|
||||
* @return BillInterface
|
||||
* @return Bill
|
||||
*/
|
||||
public function setZip($zip)
|
||||
{
|
||||
@ -251,8 +242,7 @@ class Bill implements BillInterface
|
||||
|
||||
/**
|
||||
* @param string $country
|
||||
*
|
||||
* @return BillInterface
|
||||
* @return Bill
|
||||
*/
|
||||
public function setCountry($country)
|
||||
{
|
||||
@ -273,8 +263,7 @@ class Bill implements BillInterface
|
||||
|
||||
/**
|
||||
* @param string $email
|
||||
*
|
||||
* @return BillInterface
|
||||
* @return Bill
|
||||
*/
|
||||
public function setEmail($email)
|
||||
{
|
||||
@ -295,8 +284,7 @@ class Bill implements BillInterface
|
||||
|
||||
/**
|
||||
* @param string $phone
|
||||
*
|
||||
* @return BillInterface
|
||||
* @return Bill
|
||||
*/
|
||||
public function setPhone($phone)
|
||||
{
|
||||
@ -317,8 +305,7 @@ class Bill implements BillInterface
|
||||
|
||||
/**
|
||||
* @param string $status
|
||||
*
|
||||
* @return BillInterface
|
||||
* @return Bill
|
||||
*/
|
||||
public function setStatus($status)
|
||||
{
|
||||
@ -339,8 +326,7 @@ class Bill implements BillInterface
|
||||
|
||||
/**
|
||||
* @param string $showRate
|
||||
*
|
||||
* @return BillInterface
|
||||
* @return Bill
|
||||
*/
|
||||
public function setShowRate($showRate)
|
||||
{
|
||||
@ -361,8 +347,7 @@ class Bill implements BillInterface
|
||||
|
||||
/**
|
||||
* @param boolean $archived
|
||||
*
|
||||
* @return BillInterface
|
||||
* @return Bill
|
||||
*/
|
||||
public function setArchived($archived)
|
||||
{
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace Bitpay;
|
||||
|
||||
/**
|
||||
* Creates a bill for the calling merchant
|
||||
* Creates a bill for the calling merchant.
|
||||
*
|
||||
* @package Bitpay
|
||||
*/
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -18,14 +18,14 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||
|
||||
/**
|
||||
* Setups container and is ready for some dependency injection action
|
||||
* Sets up container and prepares for dependency injection.
|
||||
*
|
||||
* @package Bitpay
|
||||
*/
|
||||
class Bitpay
|
||||
{
|
||||
/**
|
||||
* @var ContainerInterface
|
||||
* @var ContainerBuilder
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
@ -37,9 +37,9 @@ class Bitpay
|
||||
* The second argument is the container if you want to build one by hand.
|
||||
*
|
||||
* @param array|string $config
|
||||
* @param ContainerInterface $container
|
||||
* @param null|ContainerBuilder $container
|
||||
*/
|
||||
public function __construct($config = array(), ContainerInterface $container = null)
|
||||
public function __construct($config = array(), ContainerBuilder $container = null)
|
||||
{
|
||||
$this->container = $container;
|
||||
|
||||
@ -50,6 +50,8 @@ class Bitpay
|
||||
|
||||
/**
|
||||
* Initialize the container
|
||||
*
|
||||
* @param array|string $config
|
||||
*/
|
||||
protected function initializeContainer($config)
|
||||
{
|
||||
@ -58,7 +60,10 @@ class Bitpay
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the container of services and parameters
|
||||
* Build the container of services and parameters.
|
||||
*
|
||||
* @param array|string $config
|
||||
* @return ContainerBuilder
|
||||
*/
|
||||
protected function buildContainer($config)
|
||||
{
|
||||
@ -70,16 +75,20 @@ class Bitpay
|
||||
return $container;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string,string>
|
||||
*/
|
||||
protected function getParameters()
|
||||
{
|
||||
return array(
|
||||
'bitpay.root_dir' => realpath(__DIR__.'/..'),
|
||||
'bitpay.root_dir' => realpath(__DIR__ . '/..'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ContainerBuilder $container
|
||||
*/
|
||||
private function prepareContainer(ContainerInterface $container)
|
||||
private function prepareContainer(ContainerBuilder $container)
|
||||
{
|
||||
foreach ($this->getDefaultExtensions() as $ext) {
|
||||
$container->registerExtension($ext);
|
||||
@ -88,10 +97,10 @@ class Bitpay
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ContainerInterface $container
|
||||
* @return LoaderInterface
|
||||
* @param ContainerBuilder $container
|
||||
* @return DelegatingLoader
|
||||
*/
|
||||
private function getContainerLoader(ContainerInterface $container)
|
||||
private function getContainerLoader(ContainerBuilder $container)
|
||||
{
|
||||
$locator = new FileLocator();
|
||||
$resolver = new LoaderResolver(
|
||||
@ -105,9 +114,9 @@ class Bitpay
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of the default extensions
|
||||
* Returns an array of the default extensions.
|
||||
*
|
||||
* @return array
|
||||
* @return BitpayExtension[]
|
||||
*/
|
||||
private function getDefaultExtensions()
|
||||
{
|
||||
@ -117,7 +126,7 @@ class Bitpay
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ContainerInterface
|
||||
* @return ContainerBuilder
|
||||
*/
|
||||
public function getContainer()
|
||||
{
|
||||
@ -125,7 +134,7 @@ class Bitpay
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @return object|null
|
||||
*/
|
||||
public function get($service)
|
||||
{
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
|
||||
@ -1,13 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace Bitpay;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Bitpay
|
||||
*/
|
||||
interface BuyerInterface extends UserInterface
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -18,11 +18,10 @@ use Bitpay\Client\ResponseInterface;
|
||||
interface AdapterInterface
|
||||
{
|
||||
/**
|
||||
* Send request to BitPay
|
||||
* Send a request to BitPay.
|
||||
*
|
||||
* @param RequestInterface $request
|
||||
*
|
||||
* @return ResponseInterface
|
||||
* @param \Bitpay\Client\Request $request
|
||||
* @return \Bitpay\Client\Response
|
||||
*/
|
||||
public function sendRequest(RequestInterface $request);
|
||||
public function sendRequest(\Bitpay\Client\Request $request);
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -11,9 +11,7 @@ use Bitpay\Client\ResponseInterface;
|
||||
use Bitpay\Client\Response;
|
||||
|
||||
/**
|
||||
* Adapter that sends Request objects using CURL
|
||||
*
|
||||
* @TODO add way to configure curl with options
|
||||
* Adapter class that sends Request objects using cURL.
|
||||
*
|
||||
* @package Bitpay
|
||||
*/
|
||||
@ -33,7 +31,7 @@ class CurlAdapter implements AdapterInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of curl settings to use
|
||||
* Returns an array of cURL settings to use
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@ -45,14 +43,18 @@ class CurlAdapter implements AdapterInterface
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function sendRequest(RequestInterface $request)
|
||||
public function sendRequest(\Bitpay\Client\Request $request)
|
||||
{
|
||||
$curl = curl_init();
|
||||
|
||||
if ($curl === false) {
|
||||
throw new \Exception('[ERROR] In CurlAdapter::sendRequest(): Could not initialize cURL.');
|
||||
}
|
||||
|
||||
$default_curl_options = $this->getCurlDefaultOptions($request);
|
||||
|
||||
foreach ($this->getCurlOptions() as $curl_option_key => $curl_option_value) {
|
||||
if (!is_null($curl_option_value)) {
|
||||
if (is_null($curl_option_value) === false) {
|
||||
$default_curl_options[$curl_option_key] = $curl_option_value;
|
||||
}
|
||||
}
|
||||
@ -71,13 +73,14 @@ class CurlAdapter implements AdapterInterface
|
||||
|
||||
$raw = curl_exec($curl);
|
||||
|
||||
if (false === $raw) {
|
||||
if ($raw === false) {
|
||||
$errorMessage = curl_error($curl);
|
||||
curl_close($curl);
|
||||
throw new \Bitpay\Client\ConnectionException($errorMessage);
|
||||
|
||||
throw new \Bitpay\Client\ConnectionException('[ERROR] In CurlAdapter::sendRequest(): curl_exec failed with the error "' . $errorMessage . '".');
|
||||
}
|
||||
|
||||
/** @var ResponseInterface */
|
||||
/** @var Response */
|
||||
$response = Response::createFromRawResponse($raw);
|
||||
|
||||
// For some unknown reason, on some machine, the status code is equal to 0
|
||||
@ -89,12 +92,12 @@ class CurlAdapter implements AdapterInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of default curl settings to use
|
||||
* Returns an array of default cURL settings to use.
|
||||
*
|
||||
* @param RequestInterface $request
|
||||
* @param \Bitpay\Client\Request $request
|
||||
* @return array
|
||||
*/
|
||||
private function getCurlDefaultOptions(RequestInterface $request)
|
||||
private function getCurlDefaultOptions(\Bitpay\Client\Request $request)
|
||||
{
|
||||
return array(
|
||||
CURLOPT_URL => $request->getFullUri(),
|
||||
@ -103,7 +106,7 @@ class CurlAdapter implements AdapterInterface
|
||||
CURLOPT_TIMEOUT => 10,
|
||||
CURLOPT_SSL_VERIFYPEER => 1,
|
||||
CURLOPT_SSL_VERIFYHOST => 2,
|
||||
CURLOPT_CAINFO => __DIR__.'/ca-bundle.crt',
|
||||
CURLOPT_CAINFO => __DIR__ . '/ca-bundle.crt',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_FORBID_REUSE => 1,
|
||||
CURLOPT_FRESH_CONNECT => 1,
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
##
|
||||
## Bundle of CA Root Certificates
|
||||
##
|
||||
## Certificate data from Mozilla downloaded on: Thu Sep 4 06:31:22 2014
|
||||
## Certificate data from Mozilla as of: Mon Apr 27 08:58:04 2015
|
||||
##
|
||||
## This is a bundle of X.509 certificates of public Certificate Authorities
|
||||
## (CA). These were automatically extracted from Mozilla's root certificates
|
||||
@ -13,66 +13,11 @@
|
||||
## an Apache+mod_ssl webserver for SSL client authentication.
|
||||
## Just configure this file as the SSLCACertificateFile.
|
||||
##
|
||||
## Conversion done with mk-ca-bundle.pl verison 1.22.
|
||||
## SHA1: c4540021427a6fa29e5f50db9f12d48c97d33889
|
||||
## Conversion done with mk-ca-bundle.pl version 1.25.
|
||||
## SHA1: ed3c0bbfb7912bcc00cd2033b0cb85c98d10559c
|
||||
##
|
||||
|
||||
|
||||
GTE CyberTrust Global Root
|
||||
==========================
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICWjCCAcMCAgGlMA0GCSqGSIb3DQEBBAUAMHUxCzAJBgNVBAYTAlVTMRgwFgYDVQQKEw9HVEUg
|
||||
Q29ycG9yYXRpb24xJzAlBgNVBAsTHkdURSBDeWJlclRydXN0IFNvbHV0aW9ucywgSW5jLjEjMCEG
|
||||
A1UEAxMaR1RFIEN5YmVyVHJ1c3QgR2xvYmFsIFJvb3QwHhcNOTgwODEzMDAyOTAwWhcNMTgwODEz
|
||||
MjM1OTAwWjB1MQswCQYDVQQGEwJVUzEYMBYGA1UEChMPR1RFIENvcnBvcmF0aW9uMScwJQYDVQQL
|
||||
Ex5HVEUgQ3liZXJUcnVzdCBTb2x1dGlvbnMsIEluYy4xIzAhBgNVBAMTGkdURSBDeWJlclRydXN0
|
||||
IEdsb2JhbCBSb290MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCVD6C28FCc6HrHiM3dFw4u
|
||||
sJTQGz0O9pTAipTHBsiQl8i4ZBp6fmw8U+E3KHNgf7KXUwefU/ltWJTSr41tiGeA5u2ylc9yMcql
|
||||
HHK6XALnZELn+aks1joNrI1CqiQBOeacPwGFVw1Yh0X404Wqk2kmhXBIgD8SFcd5tB8FLztimQID
|
||||
AQABMA0GCSqGSIb3DQEBBAUAA4GBAG3rGwnpXtlR22ciYaQqPEh346B8pt5zohQDhT37qw4wxYMW
|
||||
M4ETCJ57NE7fQMh017l93PR2VX2bY1QY6fDq81yx2YtCHrnAlU66+tXifPVoYb+O7AWXX1uw16OF
|
||||
NMQkpw0PlZPvy5TYnh+dXIVtx6quTx8itc2VrbqnzPmrC3p/
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
Thawte Server CA
|
||||
================
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDEzCCAnygAwIBAgIBATANBgkqhkiG9w0BAQQFADCBxDELMAkGA1UEBhMCWkExFTATBgNVBAgT
|
||||
DFdlc3Rlcm4gQ2FwZTESMBAGA1UEBxMJQ2FwZSBUb3duMR0wGwYDVQQKExRUaGF3dGUgQ29uc3Vs
|
||||
dGluZyBjYzEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjEZMBcGA1UE
|
||||
AxMQVGhhd3RlIFNlcnZlciBDQTEmMCQGCSqGSIb3DQEJARYXc2VydmVyLWNlcnRzQHRoYXd0ZS5j
|
||||
b20wHhcNOTYwODAxMDAwMDAwWhcNMjAxMjMxMjM1OTU5WjCBxDELMAkGA1UEBhMCWkExFTATBgNV
|
||||
BAgTDFdlc3Rlcm4gQ2FwZTESMBAGA1UEBxMJQ2FwZSBUb3duMR0wGwYDVQQKExRUaGF3dGUgQ29u
|
||||
c3VsdGluZyBjYzEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjEZMBcG
|
||||
A1UEAxMQVGhhd3RlIFNlcnZlciBDQTEmMCQGCSqGSIb3DQEJARYXc2VydmVyLWNlcnRzQHRoYXd0
|
||||
ZS5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANOkUG7I/1Zr5s9dtuoMaHVHoqrC2oQl
|
||||
/Kj0R1HahbUgdJSGHg91yekIYfUGbTBuFRkC6VLAYttNmZ7iagxEOM3+vuNkCXDF/rFrKbYvScg7
|
||||
1CcEJRCXL+eQbcAoQpnXTEPew/UhbVSfXcNY4cDk2VuwuNy0e982OsK1ZiIS1ocNAgMBAAGjEzAR
|
||||
MA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEEBQADgYEAB/pMaVz7lcxG7oWDTSEwjsrZqG9J
|
||||
GubaUeNgcGyEYRGhGshIPllDfU+VPaGLtwtimHp1it2ITk6eQNuozDJ0uW8NxuOzRAvZim+aKZuZ
|
||||
GCg70eNAKJpaPNW15yAbi8qkq43pUdniTCxZqdq5snUb9kLy78fyGPmJvKP/iiMucEc=
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
Thawte Premium Server CA
|
||||
========================
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDJzCCApCgAwIBAgIBATANBgkqhkiG9w0BAQQFADCBzjELMAkGA1UEBhMCWkExFTATBgNVBAgT
|
||||
DFdlc3Rlcm4gQ2FwZTESMBAGA1UEBxMJQ2FwZSBUb3duMR0wGwYDVQQKExRUaGF3dGUgQ29uc3Vs
|
||||
dGluZyBjYzEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjEhMB8GA1UE
|
||||
AxMYVGhhd3RlIFByZW1pdW0gU2VydmVyIENBMSgwJgYJKoZIhvcNAQkBFhlwcmVtaXVtLXNlcnZl
|
||||
ckB0aGF3dGUuY29tMB4XDTk2MDgwMTAwMDAwMFoXDTIwMTIzMTIzNTk1OVowgc4xCzAJBgNVBAYT
|
||||
AlpBMRUwEwYDVQQIEwxXZXN0ZXJuIENhcGUxEjAQBgNVBAcTCUNhcGUgVG93bjEdMBsGA1UEChMU
|
||||
VGhhd3RlIENvbnN1bHRpbmcgY2MxKDAmBgNVBAsTH0NlcnRpZmljYXRpb24gU2VydmljZXMgRGl2
|
||||
aXNpb24xITAfBgNVBAMTGFRoYXd0ZSBQcmVtaXVtIFNlcnZlciBDQTEoMCYGCSqGSIb3DQEJARYZ
|
||||
cHJlbWl1bS1zZXJ2ZXJAdGhhd3RlLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA0jY2
|
||||
aovXwlue2oFBYo847kkEVdbQ7xwblRZH7xhINTpS9CtqBo87L+pW46+GjZ4X9560ZXUCTe/LCaIh
|
||||
Udib0GfQug2SBhRz1JPLlyoAnFxODLz6FVL88kRu2hFKbgifLy3j+ao6hnO2RlNYyIkFvYMRuHM/
|
||||
qgeN9EJN50CdHDcCAwEAAaMTMBEwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQQFAAOBgQAm
|
||||
SCwWwlj66BZ0DKqqX1Q/8tfJeGBeXm43YyJ3Nn6yF8Q0ufUIhfzJATj/Tb7yFkJD57taRvvBxhEf
|
||||
8UqwKEbJw8RCfbz6q1lu1bdRiBHjpIUZa4JMpAwSremkrj/xw0llmozFyD4lt5SZu5IycQfwhl7t
|
||||
UCemDaYj+bvLpgcUQg==
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
Equifax Secure CA
|
||||
=================
|
||||
-----BEGIN CERTIFICATE-----
|
||||
@ -93,25 +38,6 @@ BIZCe/zuf6IWUrVnZ9NA2zsmWLIodz2uFHdh1voqZiegDfqnc1zqcPGUIWVEX/r87yloqaKHee95
|
||||
70+sB3c4
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
Verisign Class 3 Public Primary Certification Authority - G2
|
||||
============================================================
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDAjCCAmsCEH3Z/gfPqB63EHln+6eJNMYwDQYJKoZIhvcNAQEFBQAwgcExCzAJBgNVBAYTAlVT
|
||||
MRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xhc3MgMyBQdWJsaWMgUHJpbWFy
|
||||
eSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMTowOAYDVQQLEzEoYykgMTk5OCBWZXJpU2ln
|
||||
biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVz
|
||||
dCBOZXR3b3JrMB4XDTk4MDUxODAwMDAwMFoXDTI4MDgwMTIzNTk1OVowgcExCzAJBgNVBAYTAlVT
|
||||
MRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xhc3MgMyBQdWJsaWMgUHJpbWFy
|
||||
eSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMTowOAYDVQQLEzEoYykgMTk5OCBWZXJpU2ln
|
||||
biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVz
|
||||
dCBOZXR3b3JrMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDMXtERXVxp0KvTuWpMmR9ZmDCO
|
||||
FoUgRm1HP9SFIIThbbP4pO0M8RcPO/mn+SXXwc+EY/J8Y8+iR/LGWzOOZEAEaMGAuWQcRXfH2G71
|
||||
lSk8UOg013gfqLptQ5GVj0VXXn7F+8qkBOvqlzdUMG+7AUcyM83cV5tkaWH4mx0ciU9cZwIDAQAB
|
||||
MA0GCSqGSIb3DQEBBQUAA4GBAFFNzb5cy5gZnBWyATl4Lk0PZ3BwmcYQWpSkU01UbSuvDV1Ai2TT
|
||||
1+7eVmGSX6bEHRBhNtMsJzzoKQm5EWR0zLVznxxIqbxhAe7iF6YM40AIOw7n60RzKprxaZLvcRTD
|
||||
Oaxxp5EJb+RxBrO6WVcmeQD2+A2iMzAo1KpYoJ2daZH9
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
GlobalSign Root CA
|
||||
==================
|
||||
-----BEGIN CERTIFICATE-----
|
||||
@ -248,40 +174,6 @@ Y71k5h+3zvDyny67G7fyUIhzksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9H
|
||||
RCwBXbsdtTLSR9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
Equifax Secure Global eBusiness CA
|
||||
==================================
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICkDCCAfmgAwIBAgIBATANBgkqhkiG9w0BAQQFADBaMQswCQYDVQQGEwJVUzEcMBoGA1UEChMT
|
||||
RXF1aWZheCBTZWN1cmUgSW5jLjEtMCsGA1UEAxMkRXF1aWZheCBTZWN1cmUgR2xvYmFsIGVCdXNp
|
||||
bmVzcyBDQS0xMB4XDTk5MDYyMTA0MDAwMFoXDTIwMDYyMTA0MDAwMFowWjELMAkGA1UEBhMCVVMx
|
||||
HDAaBgNVBAoTE0VxdWlmYXggU2VjdXJlIEluYy4xLTArBgNVBAMTJEVxdWlmYXggU2VjdXJlIEds
|
||||
b2JhbCBlQnVzaW5lc3MgQ0EtMTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAuucXkAJlsTRV
|
||||
PEnCUdXfp9E3j9HngXNBUmCbnaEXJnitx7HoJpQytd4zjTov2/KaelpzmKNc6fuKcxtc58O/gGzN
|
||||
qfTWK8D3+ZmqY6KxRwIP1ORROhI8bIpaVIRw28HFkM9yRcuoWcDNM50/o5brhTMhHD4ePmBudpxn
|
||||
hcXIw2ECAwEAAaNmMGQwEQYJYIZIAYb4QgEBBAQDAgAHMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0j
|
||||
BBgwFoAUvqigdHJQa0S3ySPY+6j/s1draGwwHQYDVR0OBBYEFL6ooHRyUGtEt8kj2Puo/7NXa2hs
|
||||
MA0GCSqGSIb3DQEBBAUAA4GBADDiAVGqx+pf2rnQZQ8w1j7aDRRJbpGTJxQx78T3LUX47Me/okEN
|
||||
I7SS+RkAZ70Br83gcfxaz2TE4JaY0KNA4gGK7ycH8WUBikQtBmV1UsCGECAhX2xrD2yuCRyv8qIY
|
||||
NMR1pHMc8Y3c7635s3a0kr/clRAevsvIO1qEYBlWlKlV
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
Equifax Secure eBusiness CA 1
|
||||
=============================
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICgjCCAeugAwIBAgIBBDANBgkqhkiG9w0BAQQFADBTMQswCQYDVQQGEwJVUzEcMBoGA1UEChMT
|
||||
RXF1aWZheCBTZWN1cmUgSW5jLjEmMCQGA1UEAxMdRXF1aWZheCBTZWN1cmUgZUJ1c2luZXNzIENB
|
||||
LTEwHhcNOTkwNjIxMDQwMDAwWhcNMjAwNjIxMDQwMDAwWjBTMQswCQYDVQQGEwJVUzEcMBoGA1UE
|
||||
ChMTRXF1aWZheCBTZWN1cmUgSW5jLjEmMCQGA1UEAxMdRXF1aWZheCBTZWN1cmUgZUJ1c2luZXNz
|
||||
IENBLTEwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAM4vGbwXt3fek6lfWg0XTzQaDJj0ItlZ
|
||||
1MRoRvC0NcWFAyDGr0WlIVFFQesWWDYyb+JQYmT5/VGcqiTZ9J2DKocKIdMSODRsjQBuWqDZQu4a
|
||||
IZX5UkxVWsUPOE9G+m34LjXWHXzr4vCwdYDIqROsvojvOm6rXyo4YgKwEnv+j6YDAgMBAAGjZjBk
|
||||
MBEGCWCGSAGG+EIBAQQEAwIABzAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFEp4MlIR21kW
|
||||
Nl7fwRQ2QGpHfEyhMB0GA1UdDgQWBBRKeDJSEdtZFjZe38EUNkBqR3xMoTANBgkqhkiG9w0BAQQF
|
||||
AAOBgQB1W6ibAxHm6VZMzfmpTMANmvPMZWnmJXbMWbfWVMMdzZmsGd20hdXgPfxiIKeES1hl8eL5
|
||||
lSE/9dR+WB5Hh1Q+WKG1tfgq73HnvMP2sUlG4tega+VWeponmHxGYhTnyfxuAxJ5gDgdSIKN/Bf+
|
||||
KpYrtWKmpj29f5JZzVoqgrI3eQ==
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
AddTrust Low-Value Services Root
|
||||
================================
|
||||
-----BEGIN CERTIFICATE-----
|
||||
@ -527,59 +419,6 @@ gn2Z9DH2canPLAEnpQW5qrJITirvn5NSUZU8UnOOVkwXQMAJKOSLakhT2+zNVVXxxvjpoixMptEm
|
||||
X36vWkzaH6byHCx+rgIW0lbQL1dTR+iS
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
America Online Root Certification Authority 1
|
||||
=============================================
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDpDCCAoygAwIBAgIBATANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEcMBoGA1UEChMT
|
||||
QW1lcmljYSBPbmxpbmUgSW5jLjE2MDQGA1UEAxMtQW1lcmljYSBPbmxpbmUgUm9vdCBDZXJ0aWZp
|
||||
Y2F0aW9uIEF1dGhvcml0eSAxMB4XDTAyMDUyODA2MDAwMFoXDTM3MTExOTIwNDMwMFowYzELMAkG
|
||||
A1UEBhMCVVMxHDAaBgNVBAoTE0FtZXJpY2EgT25saW5lIEluYy4xNjA0BgNVBAMTLUFtZXJpY2Eg
|
||||
T25saW5lIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgMTCCASIwDQYJKoZIhvcNAQEBBQAD
|
||||
ggEPADCCAQoCggEBAKgv6KRpBgNHw+kqmP8ZonCaxlCyfqXfaE0bfA+2l2h9LaaLl+lkhsmj76CG
|
||||
v2BlnEtUiMJIxUo5vxTjWVXlGbR0yLQFOVwWpeKVBeASrlmLojNoWBym1BW32J/X3HGrfpq/m44z
|
||||
DyL9Hy7nBzbvYjnF3cu6JRQj3gzGPTzOggjmZj7aUTsWOqMFf6Dch9Wc/HKpoH145LcxVR5lu9Rh
|
||||
sCFg7RAycsWSJR74kEoYeEfffjA3PlAb2xzTa5qGUwew76wGePiEmf4hjUyAtgyC9mZweRrTT6PP
|
||||
8c9GsEsPPt2IYriMqQkoO3rHl+Ee5fSfwMCuJKDIodkP1nsmgmkyPacCAwEAAaNjMGEwDwYDVR0T
|
||||
AQH/BAUwAwEB/zAdBgNVHQ4EFgQUAK3Zo/Z59m50qX8zPYEX10zPM94wHwYDVR0jBBgwFoAUAK3Z
|
||||
o/Z59m50qX8zPYEX10zPM94wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBBQUAA4IBAQB8itEf
|
||||
GDeC4Liwo+1WlchiYZwFos3CYiZhzRAW18y0ZTTQEYqtqKkFZu90821fnZmv9ov761KyBZiibyrF
|
||||
VL0lvV+uyIbqRizBs73B6UlwGBaXCBOMIOAbLjpHyx7kADCVW/RFo8AasAFOq73AI25jP4BKxQft
|
||||
3OJvx8Fi8eNy1gTIdGcL+oiroQHIb/AUr9KZzVGTfu0uOMe9zkZQPXLjeSWdm4grECDdpbgyn43g
|
||||
Kd8hdIaC2y+CMMbHNYaz+ZZfRtsMRf3zUMNvxsNIrUam4SdHCh0Om7bCd39j8uB9Gr784N/Xx6ds
|
||||
sPmuujz9dLQR6FgNgLzTqIA6me11zEZ7
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
America Online Root Certification Authority 2
|
||||
=============================================
|
||||
-----BEGIN CERTIFICATE-----
|
||||
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
|
||||
cX/9XhmgD0uRuMRUvAawRY8mkaKO/qk=
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
Visa eCommerce Root
|
||||
===================
|
||||
-----BEGIN CERTIFICATE-----
|
||||
@ -1777,33 +1616,6 @@ JOzHdiEoZa5X6AeIdUpWoNIFOqTmjZKILPPy4cHGYdtBxceb9w4aUUXCYWvcZCcXjFq32nQozZfk
|
||||
vQ==
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
TC TrustCenter Class 3 CA II
|
||||
============================
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIEqjCCA5KgAwIBAgIOSkcAAQAC5aBd1j8AUb8wDQYJKoZIhvcNAQEFBQAwdjELMAkGA1UEBhMC
|
||||
REUxHDAaBgNVBAoTE1RDIFRydXN0Q2VudGVyIEdtYkgxIjAgBgNVBAsTGVRDIFRydXN0Q2VudGVy
|
||||
IENsYXNzIDMgQ0ExJTAjBgNVBAMTHFRDIFRydXN0Q2VudGVyIENsYXNzIDMgQ0EgSUkwHhcNMDYw
|
||||
MTEyMTQ0MTU3WhcNMjUxMjMxMjI1OTU5WjB2MQswCQYDVQQGEwJERTEcMBoGA1UEChMTVEMgVHJ1
|
||||
c3RDZW50ZXIgR21iSDEiMCAGA1UECxMZVEMgVHJ1c3RDZW50ZXIgQ2xhc3MgMyBDQTElMCMGA1UE
|
||||
AxMcVEMgVHJ1c3RDZW50ZXIgQ2xhc3MgMyBDQSBJSTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
|
||||
AQoCggEBALTgu1G7OVyLBMVMeRwjhjEQY0NVJz/GRcekPewJDRoeIMJWHt4bNwcwIi9v8Qbxq63W
|
||||
yKthoy9DxLCyLfzDlml7forkzMA5EpBCYMnMNWju2l+QVl/NHE1bWEnrDgFPZPosPIlY2C8u4rBo
|
||||
6SI7dYnWRBpl8huXJh0obazovVkdKyT21oQDZogkAHhg8fir/gKya/si+zXmFtGt9i4S5Po1auUZ
|
||||
uV3bOx4a+9P/FRQI2AlqukWdFHlgfa9Aigdzs5OW03Q0jTo3Kd5c7PXuLjHCINy+8U9/I1LZW+Jk
|
||||
2ZyqBwi1Rb3R0DHBq1SfqdLDYmAD8bs5SpJKPQq5ncWg/jcCAwEAAaOCATQwggEwMA8GA1UdEwEB
|
||||
/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBTUovyfs8PYA9NXXAek0CSnwPIA1DCB
|
||||
7QYDVR0fBIHlMIHiMIHfoIHcoIHZhjVodHRwOi8vd3d3LnRydXN0Y2VudGVyLmRlL2NybC92Mi90
|
||||
Y19jbGFzc18zX2NhX0lJLmNybIaBn2xkYXA6Ly93d3cudHJ1c3RjZW50ZXIuZGUvQ049VEMlMjBU
|
||||
cnVzdENlbnRlciUyMENsYXNzJTIwMyUyMENBJTIwSUksTz1UQyUyMFRydXN0Q2VudGVyJTIwR21i
|
||||
SCxPVT1yb290Y2VydHMsREM9dHJ1c3RjZW50ZXIsREM9ZGU/Y2VydGlmaWNhdGVSZXZvY2F0aW9u
|
||||
TGlzdD9iYXNlPzANBgkqhkiG9w0BAQUFAAOCAQEANmDkcPcGIEPZIxpC8vijsrlNirTzwppVMXzE
|
||||
O2eatN9NDoqTSheLG43KieHPOh6sHfGcMrSOWXaiQYUlN6AT0PV8TtXqluJucsG7Kv5sbviRmEb8
|
||||
yRtXW+rIGjs/sFGYPAfaLFkB2otE6OF0/ado3VS6g0bsyEa1+K+XwDsJHI/OcpY9M1ZwvJbL2NV9
|
||||
IJqDnxrcOfHFcqMRA/07QlIp2+gB95tejNaNhk4Z+rwcvsUhpYeeeC422wlxo3I0+GzjBgnyXlal
|
||||
092Y+tTmBvTwtiBjS+opvaqCZh77gaqnN60TGOaSw4HBM7uIHqHn4rS9MWwOUT1v+5ZWgOI2F9Hc
|
||||
5A==
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
TC TrustCenter Universal CA I
|
||||
=============================
|
||||
-----BEGIN CERTIFICATE-----
|
||||
@ -2421,28 +2233,6 @@ yULyMtd6YebS2z3PyKnJm9zbWETXbzivf3jTo60adbocwTZ8jx5tHMN1Rq41Bab2XD0h7lbwyYIi
|
||||
LXpUq3DDfSJlgnCW
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
E-Guven Kok Elektronik Sertifika Hizmet Saglayicisi
|
||||
===================================================
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDtjCCAp6gAwIBAgIQRJmNPMADJ72cdpW56tustTANBgkqhkiG9w0BAQUFADB1MQswCQYDVQQG
|
||||
EwJUUjEoMCYGA1UEChMfRWxla3Ryb25payBCaWxnaSBHdXZlbmxpZ2kgQS5TLjE8MDoGA1UEAxMz
|
||||
ZS1HdXZlbiBLb2sgRWxla3Ryb25payBTZXJ0aWZpa2EgSGl6bWV0IFNhZ2xheWljaXNpMB4XDTA3
|
||||
MDEwNDExMzI0OFoXDTE3MDEwNDExMzI0OFowdTELMAkGA1UEBhMCVFIxKDAmBgNVBAoTH0VsZWt0
|
||||
cm9uaWsgQmlsZ2kgR3V2ZW5saWdpIEEuUy4xPDA6BgNVBAMTM2UtR3V2ZW4gS29rIEVsZWt0cm9u
|
||||
aWsgU2VydGlmaWthIEhpem1ldCBTYWdsYXlpY2lzaTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
|
||||
AQoCggEBAMMSIJ6wXgBljU5Gu4Bc6SwGl9XzcslwuedLZYDBS75+PNdUMZTe1RK6UxYC6lhj71vY
|
||||
8+0qGqpxSKPcEC1fX+tcS5yWCEIlKBHMilpiAVDV6wlTL/jDj/6z/P2douNffb7tC+Bg62nsM+3Y
|
||||
jfsSSYMAyYuXjDtzKjKzEve5TfL0TW3H5tYmNwjy2f1rXKPlSFxYvEK+A1qBuhw1DADT9SN+cTAI
|
||||
JjjcJRFHLfO6IxClv7wC90Nex/6wN1CZew+TzuZDLMN+DfIcQ2Zgy2ExR4ejT669VmxMvLz4Bcpk
|
||||
9Ok0oSy1c+HCPujIyTQlCFzz7abHlJ+tiEMl1+E5YP6sOVkCAwEAAaNCMEAwDgYDVR0PAQH/BAQD
|
||||
AgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFJ/uRLOU1fqRTy7ZVZoEVtstxNulMA0GCSqG
|
||||
SIb3DQEBBQUAA4IBAQB/X7lTW2M9dTLn+sR0GstG30ZpHFLPqk/CaOv/gKlR6D1id4k9CnU58W5d
|
||||
F4dvaAXBlGzZXd/aslnLpRCKysw5zZ/rTt5S/wzw9JKp8mxTq5vSR6AfdPebmvEvFZ96ZDAYBzwq
|
||||
D2fK/A+JYZ1lpTzlvBNbCNvj/+27BrtqBrF6T2XGgv0enIu1De5Iu7i9qgi0+6N8y5/NkHZchpZ4
|
||||
Vwpm+Vganf2XKWDeEaaQHBkc7gGWIjQ0LpH5t8Qn0Xvmv/uARFoW5evg1Ao4vOSR49XrXMGs3xtq
|
||||
fJ7lddK2l4fbzIcrQzqECK+rPNv3PGYxhrCdU3nt+CPeQuMtgvEP5fqX
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
GlobalSign Root CA - R3
|
||||
=======================
|
||||
-----BEGIN CERTIFICATE-----
|
||||
@ -3892,3 +3682,307 @@ ONFLAzkopR6RctR9q5czxNM+4Gm2KHmgCY0c0f9BckgG/Jou5yD5m6Leie2uPAmvylezkolwQOQv
|
||||
T8Jwg0DXJCxr5wkf09XHwQj02w47HAcLQxGEIYbpgNR12KvxAmLBsX5VYc8T1yaw15zLKYs4SgsO
|
||||
kI26oQ==
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
COMODO RSA Certification Authority
|
||||
==================================
|
||||
-----BEGIN CERTIFICATE-----
|
||||
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
|
||||
LaZRfyHBNVOFBkpdn627G190
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
USERTrust RSA Certification Authority
|
||||
=====================================
|
||||
-----BEGIN CERTIFICATE-----
|
||||
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
|
||||
Q+6IHdfGjjxDah2nGN59PRbxYvnKkKj9
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
USERTrust ECC Certification Authority
|
||||
=====================================
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICjzCCAhWgAwIBAgIQXIuZxVqUxdJxVt7NiYDMJjAKBggqhkjOPQQDAzCBiDELMAkGA1UEBhMC
|
||||
VVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU
|
||||
aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlv
|
||||
biBBdXRob3JpdHkwHhcNMTAwMjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMC
|
||||
VVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU
|
||||
aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlv
|
||||
biBBdXRob3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQarFRaqfloI+d61SRvU8Za2EurxtW2
|
||||
0eZzca7dnNYMYf3boIkDuAUU7FfO7l0/4iGzzvfUinngo4N+LZfQYcTxmdwlkWOrfzCjtHDix6Ez
|
||||
nPO/LlxTsV+zfTJ/ijTjeXmjQjBAMB0GA1UdDgQWBBQ64QmG1M8ZwpZ2dEl23OA1xmNjmjAOBgNV
|
||||
HQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjA2Z6EWCNzklwBB
|
||||
HU6+4WMBzzuqQhFkoJ2UOQIReVx7Hfpkue4WQrO/isIJxOzksU0CMQDpKmFHjFJKS04YcPbWRNZu
|
||||
9YO6bVi9JNlWSOrvxKJGgYhqOkbRqZtNyWHa0V1Xahg=
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
GlobalSign ECC Root CA - R4
|
||||
===========================
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIB4TCCAYegAwIBAgIRKjikHJYKBN5CsiilC+g0mAIwCgYIKoZIzj0EAwIwUDEkMCIGA1UECxMb
|
||||
R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI0MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
|
||||
EwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoXDTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMb
|
||||
R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI0MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
|
||||
EwpHbG9iYWxTaWduMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEuMZ5049sJQ6fLjkZHAOkrprl
|
||||
OQcJFspjsbmG+IpXwVfOQvpzofdlQv8ewQCybnMO/8ch5RikqtlxP6jUuc6MHaNCMEAwDgYDVR0P
|
||||
AQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFFSwe61FuOJAf/sKbvu+M8k8o4TV
|
||||
MAoGCCqGSM49BAMCA0gAMEUCIQDckqGgE6bPA7DmxCGXkPoUVy0D7O48027KqGx2vKLeuwIgJ6iF
|
||||
JzWbVsaj8kfSt24bAgAXqmemFZHe+pTsewv4n4Q=
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
GlobalSign ECC Root CA - R5
|
||||
===========================
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICHjCCAaSgAwIBAgIRYFlJ4CYuu1X5CneKcflK2GwwCgYIKoZIzj0EAwMwUDEkMCIGA1UECxMb
|
||||
R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI1MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
|
||||
EwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoXDTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMb
|
||||
R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI1MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
|
||||
EwpHbG9iYWxTaWduMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAER0UOlvt9Xb/pOdEh+J8LttV7HpI6
|
||||
SFkc8GIxLcB6KP4ap1yztsyX50XUWPrRd21DosCHZTQKH3rd6zwzocWdTaRvQZU4f8kehOvRnkmS
|
||||
h5SHDDqFSmafnVmTTZdhBoZKo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAd
|
||||
BgNVHQ4EFgQUPeYpSJvqB8ohREom3m7e0oPQn1kwCgYIKoZIzj0EAwMDaAAwZQIxAOVpEslu28Yx
|
||||
uglB4Zf4+/2a4n0Sye18ZNPLBSWLVtmg515dTguDnFt2KaAJJiFqYgIwcdK1j1zqO+F4CYWodZI7
|
||||
yFz9SO8NdCKoCOJuxUnOxwy8p2Fp8fc74SrL+SvzZpA3
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
Staat der Nederlanden Root CA - G3
|
||||
==================================
|
||||
-----BEGIN CERTIFICATE-----
|
||||
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
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
Staat der Nederlanden EV Root CA
|
||||
================================
|
||||
-----BEGIN CERTIFICATE-----
|
||||
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
|
||||
eUN51q1veieQA6TqJIc/2b3Z6fJfUEkc7uzXLg==
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
IdenTrust Commercial Root CA 1
|
||||
==============================
|
||||
-----BEGIN CERTIFICATE-----
|
||||
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
|
||||
cGzM7vRX+Bi6hG6H
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
IdenTrust Public Sector Root CA 1
|
||||
=================================
|
||||
-----BEGIN CERTIFICATE-----
|
||||
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
|
||||
3Wl9af0AVqW3rLatt8o+Ae+c
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
Entrust Root Certification Authority - G2
|
||||
=========================================
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIEPjCCAyagAwIBAgIESlOMKDANBgkqhkiG9w0BAQsFADCBvjELMAkGA1UEBhMCVVMxFjAUBgNV
|
||||
BAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVy
|
||||
bXMxOTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ug
|
||||
b25seTEyMDAGA1UEAxMpRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzIw
|
||||
HhcNMDkwNzA3MTcyNTU0WhcNMzAxMjA3MTc1NTU0WjCBvjELMAkGA1UEBhMCVVMxFjAUBgNVBAoT
|
||||
DUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVybXMx
|
||||
OTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ugb25s
|
||||
eTEyMDAGA1UEAxMpRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzIwggEi
|
||||
MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC6hLZy254Ma+KZ6TABp3bqMriVQRrJ2mFOWHLP
|
||||
/vaCeb9zYQYKpSfYs1/TRU4cctZOMvJyig/3gxnQaoCAAEUesMfnmr8SVycco2gvCoe9amsOXmXz
|
||||
HHfV1IWNcCG0szLni6LVhjkCsbjSR87kyUnEO6fe+1R9V77w6G7CebI6C1XiUJgWMhNcL3hWwcKU
|
||||
s/Ja5CeanyTXxuzQmyWC48zCxEXFjJd6BmsqEZ+pCm5IO2/b1BEZQvePB7/1U1+cPvQXLOZprE4y
|
||||
TGJ36rfo5bs0vBmLrpxR57d+tVOxMyLlbc9wPBr64ptntoP0jaWvYkxN4FisZDQSA/i2jZRjJKRx
|
||||
AgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqciZ6
|
||||
0B7vfec7aVHUbI2fkBJmqzANBgkqhkiG9w0BAQsFAAOCAQEAeZ8dlsa2eT8ijYfThwMEYGprmi5Z
|
||||
iXMRrEPR9RP/jTkrwPK9T3CMqS/qF8QLVJ7UG5aYMzyorWKiAHarWWluBh1+xLlEjZivEtRh2woZ
|
||||
Rkfz6/djwUAFQKXSt/S1mja/qYh2iARVBCuch38aNzx+LaUa2NSJXsq9rD1s2G2v1fN2D807iDgi
|
||||
nWyTmsQ9v4IbZT+mD12q/OWyFcq1rca8PdCE6OoGcrBNOTJ4vz4RnAuknZoh8/CbCzB428Hch0P+
|
||||
vGOaysXCHMnHjf87ElgI5rY97HosTvuDls4MPGmHVHOkc8KT/1EQrBVUAdj8BbGJoX90g5pJ19xO
|
||||
e4pIb4tF9g==
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
Entrust Root Certification Authority - EC1
|
||||
==========================================
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIC+TCCAoCgAwIBAgINAKaLeSkAAAAAUNCR+TAKBggqhkjOPQQDAzCBvzELMAkGA1UEBhMCVVMx
|
||||
FjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVn
|
||||
YWwtdGVybXMxOTA3BgNVBAsTMChjKSAyMDEyIEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXpl
|
||||
ZCB1c2Ugb25seTEzMDEGA1UEAxMqRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5
|
||||
IC0gRUMxMB4XDTEyMTIxODE1MjUzNloXDTM3MTIxODE1NTUzNlowgb8xCzAJBgNVBAYTAlVTMRYw
|
||||
FAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3QubmV0L2xlZ2Fs
|
||||
LXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxMiBFbnRydXN0LCBJbmMuIC0gZm9yIGF1dGhvcml6ZWQg
|
||||
dXNlIG9ubHkxMzAxBgNVBAMTKkVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAt
|
||||
IEVDMTB2MBAGByqGSM49AgEGBSuBBAAiA2IABIQTydC6bUF74mzQ61VfZgIaJPRbiWlH47jCffHy
|
||||
AsWfoPZb1YsGGYZPUxBtByQnoaD41UcZYUx9ypMn6nQM72+WCf5j7HBdNq1nd67JnXxVRDqiY1Ef
|
||||
9eNi1KlHBz7MIKNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE
|
||||
FLdj5xrdjekIplWDpOBqUEFlEUJJMAoGCCqGSM49BAMDA2cAMGQCMGF52OVCR98crlOZF7ZvHH3h
|
||||
vxGU0QOIdeSNiaSKd0bebWHvAvX7td/M/k7//qnmpwIwW5nXhTcGtXsI/esni0qU+eH6p44mCOh8
|
||||
kmhtc9hvJqwhAriZtyZBWyVgrtBIGu4G
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
CFCA EV ROOT
|
||||
============
|
||||
-----BEGIN CERTIFICATE-----
|
||||
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
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
@ -1,7 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace Bitpay\Client;
|
||||
|
||||
/**
|
||||
* @package Bitpay
|
||||
*/
|
||||
class ArgumentException extends \Exception
|
||||
{
|
||||
|
||||
|
||||
@ -1,7 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace Bitpay\Client;
|
||||
|
||||
/**
|
||||
* @package Bitpay
|
||||
*/
|
||||
class BitpayException extends \Exception
|
||||
{
|
||||
|
||||
|
||||
@ -1,13 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace Bitpay\Client;
|
||||
|
||||
use Bitpay\Client\Adapter\AdapterInterface;
|
||||
use Bitpay\Network\NetworkInterface;
|
||||
use Bitpay\TokenInterface;
|
||||
use Bitpay\InvoiceInterface;
|
||||
use Bitpay\PayoutInterface;
|
||||
@ -15,8 +14,9 @@ use Bitpay\Util\Util;
|
||||
use Bitpay\PublicKey;
|
||||
use Bitpay\PrivateKey;
|
||||
|
||||
date_default_timezone_set('UTC');
|
||||
/**
|
||||
* Client used to send requests and receive responses for BitPay's Web API
|
||||
* Client used to send requests and receive responses for BitPay's Web API.
|
||||
*
|
||||
* @package Bitpay
|
||||
*/
|
||||
@ -53,7 +53,7 @@ class Client implements ClientInterface
|
||||
protected $privateKey;
|
||||
|
||||
/**
|
||||
* @var uri
|
||||
* @var string
|
||||
*/
|
||||
protected $uri;
|
||||
|
||||
@ -84,6 +84,8 @@ class Client implements ClientInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the network adapter object to use.
|
||||
*
|
||||
* @param AdapterInterface $adapter
|
||||
*/
|
||||
public function setAdapter(AdapterInterface $adapter)
|
||||
@ -92,6 +94,8 @@ class Client implements ClientInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns the token to use for a request.
|
||||
*
|
||||
* @param TokenInterface $token
|
||||
* @return ClientInterface
|
||||
*/
|
||||
@ -113,6 +117,8 @@ class Client implements ClientInterface
|
||||
$currentTime = is_numeric($data['currentTime']) ? intval($data['currentTime']/1000) : $data['currentTime'];
|
||||
|
||||
$invoiceToken = new \Bitpay\Token();
|
||||
$paymentUrls = new \Bitpay\PaymentUrlSet();
|
||||
|
||||
$invoice
|
||||
->setToken($invoiceToken->setToken($data['token']))
|
||||
->setUrl($data['url'])
|
||||
@ -136,6 +142,12 @@ class Client implements ClientInterface
|
||||
->setPaymentTotals(array_key_exists('paymentTotals', $data) ? $data['paymentTotals'] : '')
|
||||
->setPaymentSubtotals(array_key_exists('paymentSubtotals', $data) ? $data['paymentSubtotals'] : '')
|
||||
->setExchangeRates(array_key_exists('exchangeRates', $data) ? $data['exchangeRates'] : '');
|
||||
|
||||
if (isset($data['paymentUrls'])) {
|
||||
$invoice
|
||||
->setPaymentUrls($paymentUrls->setUrls($data['paymentUrls']));
|
||||
}
|
||||
|
||||
return $invoice;
|
||||
}
|
||||
|
||||
@ -156,49 +168,53 @@ class Client implements ClientInterface
|
||||
$this->checkPriceAndCurrency($item->getPrice(), $currency->getCode());
|
||||
|
||||
$body = array(
|
||||
'price' => $item->getPrice(),
|
||||
'taxIncluded' => $item->getTaxIncluded(),
|
||||
'currency' => $currency->getCode(),
|
||||
'posData' => $invoice->getPosData(),
|
||||
'notificationURL' => $invoice->getNotificationUrl(),
|
||||
'transactionSpeed' => $invoice->getTransactionSpeed(),
|
||||
'fullNotifications' => $invoice->isFullNotifications(),
|
||||
'price' => $item->getPrice(),
|
||||
'taxIncluded' => $item->getTaxIncluded(),
|
||||
'currency' => $currency->getCode(),
|
||||
'posData' => $invoice->getPosData(),
|
||||
'notificationURL' => $invoice->getNotificationUrl(),
|
||||
'transactionSpeed' => $invoice->getTransactionSpeed(),
|
||||
'fullNotifications' => $invoice->isFullNotifications(),
|
||||
'extendedNotifications' => $invoice->isExtendedNotifications(),
|
||||
'notificationEmail' => $invoice->getNotificationEmail(),
|
||||
'redirectURL' => $invoice->getRedirectUrl(),
|
||||
'orderID' => $invoice->getOrderId(),
|
||||
'itemDesc' => $item->getDescription(),
|
||||
'itemCode' => $item->getCode(),
|
||||
'physical' => $item->isPhysical(),
|
||||
'buyerName' => trim(sprintf('%s %s', $buyer->getFirstName(), $buyer->getLastName())),
|
||||
'buyerAddress1' => isset($buyerAddress[0]) ? $buyerAddress[0] : '',
|
||||
'buyerAddress2' => isset($buyerAddress[1]) ? $buyerAddress[1] : '',
|
||||
'buyerCity' => $buyer->getCity(),
|
||||
'buyerState' => $buyer->getState(),
|
||||
'buyerZip' => $buyer->getZip(),
|
||||
'buyerCountry' => $buyer->getCountry(),
|
||||
'buyerEmail' => $buyer->getEmail(),
|
||||
'buyerPhone' => $buyer->getPhone(),
|
||||
'buyerNotify' => $buyer->getNotify(),
|
||||
'guid' => Util::guid(),
|
||||
'nonce' => Util::nonce(),
|
||||
'token' => $this->token->getToken(),
|
||||
'notificationEmail' => $invoice->getNotificationEmail(),
|
||||
'redirectURL' => $invoice->getRedirectUrl(),
|
||||
'orderID' => $invoice->getOrderId(),
|
||||
'itemDesc' => $item->getDescription(),
|
||||
'itemCode' => $item->getCode(),
|
||||
'physical' => $item->isPhysical(),
|
||||
'buyerName' => trim(sprintf('%s %s', $buyer->getFirstName(), $buyer->getLastName())),
|
||||
'buyerAddress1' => isset($buyerAddress[0]) ? $buyerAddress[0] : '',
|
||||
'buyerAddress2' => isset($buyerAddress[1]) ? $buyerAddress[1] : '',
|
||||
'buyerCity' => $buyer->getCity(),
|
||||
'buyerState' => $buyer->getState(),
|
||||
'buyerZip' => $buyer->getZip(),
|
||||
'buyerCountry' => $buyer->getCountry(),
|
||||
'buyerEmail' => $buyer->getEmail(),
|
||||
'buyerPhone' => $buyer->getPhone(),
|
||||
'buyerNotify' => $buyer->getNotify(),
|
||||
'guid' => Util::guid(),
|
||||
'token' => $this->token->getToken(),
|
||||
);
|
||||
|
||||
$request->setBody(json_encode($body));
|
||||
|
||||
$this->addIdentityHeader($request);
|
||||
$this->addSignatureHeader($request);
|
||||
|
||||
$this->request = $request;
|
||||
$this->response = $this->sendRequest($request);
|
||||
|
||||
$body = json_decode($this->response->getBody(), true);
|
||||
|
||||
$error_message = false;
|
||||
$error_message = (!empty($body['error'])) ? $body['error'] : $error_message;
|
||||
$error_message = (!empty($body['errors'])) ? $body['errors'] : $error_message;
|
||||
$error_message = (is_array($error_message)) ? implode("\n", $error_message) : $error_message;
|
||||
|
||||
if (false !== $error_message) {
|
||||
throw new \Exception($error_message);
|
||||
}
|
||||
|
||||
$data = $body['data'];
|
||||
|
||||
$invoice = $this->fillInvoiceData($invoice, $data);
|
||||
@ -214,12 +230,17 @@ class Client implements ClientInterface
|
||||
$this->request = $this->createNewRequest();
|
||||
$this->request->setMethod(Request::METHOD_GET);
|
||||
$this->request->setPath('currencies');
|
||||
|
||||
$this->response = $this->sendRequest($this->request);
|
||||
$body = json_decode($this->response->getBody(), true);
|
||||
|
||||
$body = json_decode($this->response->getBody(), true);
|
||||
|
||||
if (empty($body['data'])) {
|
||||
throw new \Exception('Error with request: no data returned');
|
||||
}
|
||||
|
||||
$currencies = $body['data'];
|
||||
|
||||
array_walk($currencies, function (&$value, $key) {
|
||||
$currency = new \Bitpay\Currency();
|
||||
$currency
|
||||
@ -232,6 +253,7 @@ class Client implements ClientInterface
|
||||
->setPluralName($value['plural'])
|
||||
->setAlts($value['alts'])
|
||||
->setPayoutFields($value['payoutFields']);
|
||||
|
||||
$value = $currency;
|
||||
});
|
||||
|
||||
@ -260,12 +282,12 @@ class Client implements ClientInterface
|
||||
'effectiveDate' => $effectiveDate,
|
||||
'pricingMethod' => $payout->getPricingMethod(),
|
||||
'guid' => Util::guid(),
|
||||
'nonce' => Util::nonce()
|
||||
);
|
||||
|
||||
// Optional
|
||||
foreach (array('reference','notificationURL','notificationEmail') as $value) {
|
||||
$function = 'get' . ucfirst($value);
|
||||
|
||||
if ($payout->$function() != null) {
|
||||
$body[$value] = $payout->$function();
|
||||
}
|
||||
@ -281,21 +303,26 @@ class Client implements ClientInterface
|
||||
}
|
||||
|
||||
$request->setBody(json_encode($body));
|
||||
|
||||
$this->addIdentityHeader($request);
|
||||
$this->addSignatureHeader($request);
|
||||
|
||||
$this->request = $request;
|
||||
$this->response = $this->sendRequest($request);
|
||||
|
||||
$body = json_decode($this->response->getBody(), true);
|
||||
|
||||
$error_message = false;
|
||||
$error_message = (!empty($body['error'])) ? $body['error'] : $error_message;
|
||||
$error_message = (!empty($body['errors'])) ? $body['errors'] : $error_message;
|
||||
$error_message = (is_array($error_message)) ? implode("\n", $error_message) : $error_message;
|
||||
|
||||
if (false !== $error_message) {
|
||||
throw new \Exception($error_message);
|
||||
}
|
||||
|
||||
$data = $body['data'];
|
||||
|
||||
$payout
|
||||
->setId($data['id'])
|
||||
->setAccountId($data['account'])
|
||||
@ -316,9 +343,11 @@ class Client implements ClientInterface
|
||||
{
|
||||
$request = $this->createNewRequest();
|
||||
$request->setMethod(Request::METHOD_GET);
|
||||
|
||||
$path = 'payouts?token='
|
||||
. $this->token->getToken()
|
||||
. (($status == null) ? '' : '&status=' . $status);
|
||||
|
||||
$request->setPath($path);
|
||||
|
||||
$this->addIdentityHeader($request);
|
||||
@ -326,11 +355,14 @@ class Client implements ClientInterface
|
||||
|
||||
$this->request = $request;
|
||||
$this->response = $this->sendRequest($this->request);
|
||||
$body = json_decode($this->response->getBody(), true);
|
||||
|
||||
$body = json_decode($this->response->getBody(), true);
|
||||
|
||||
$error_message = false;
|
||||
$error_message = (!empty($body['error'])) ? $body['error'] : $error_message;
|
||||
$error_message = (!empty($body['errors'])) ? $body['errors'] : $error_message;
|
||||
$error_message = (is_array($error_message)) ? implode("\n", $error_message) : $error_message;
|
||||
|
||||
if (false !== $error_message) {
|
||||
throw new \Exception($error_message);
|
||||
}
|
||||
@ -398,12 +430,13 @@ class Client implements ClientInterface
|
||||
$this->request = $request;
|
||||
$this->response = $this->sendRequest($this->request);
|
||||
|
||||
$body = json_decode($this->response->getBody(), true);
|
||||
$body = json_decode($this->response->getBody(), true);
|
||||
|
||||
if (empty($body['data'])) {
|
||||
throw new \Exception('Error with request: no data returned');
|
||||
}
|
||||
|
||||
$data = $body['data'];
|
||||
$data = $body['data'];
|
||||
|
||||
$payout->setStatus($data['status']);
|
||||
|
||||
@ -418,19 +451,22 @@ class Client implements ClientInterface
|
||||
$request = $this->createNewRequest();
|
||||
$request->setMethod(Request::METHOD_GET);
|
||||
$request->setPath(sprintf('payouts/%s?token=%s', $payoutId, $this->token->getToken()));
|
||||
|
||||
$this->addIdentityHeader($request);
|
||||
$this->addSignatureHeader($request);
|
||||
|
||||
$this->request = $request;
|
||||
$this->response = $this->sendRequest($this->request);
|
||||
|
||||
$body = json_decode($this->response->getBody(), true);
|
||||
$body = json_decode($this->response->getBody(), true);
|
||||
|
||||
if (empty($body['data'])) {
|
||||
throw new \Exception('Error with request: no data returned');
|
||||
}
|
||||
$data = $body['data'];
|
||||
|
||||
$data = $body['data'];
|
||||
$payout = new \Bitpay\Payout();
|
||||
|
||||
$payout
|
||||
->setId($data['id'])
|
||||
->setAccountId($data['account'])
|
||||
@ -481,12 +517,15 @@ class Client implements ClientInterface
|
||||
$request = $this->createNewRequest();
|
||||
$request->setMethod(Request::METHOD_GET);
|
||||
$request->setPath('tokens');
|
||||
|
||||
$this->addIdentityHeader($request);
|
||||
$this->addSignatureHeader($request);
|
||||
|
||||
$this->request = $request;
|
||||
$this->response = $this->sendRequest($this->request);
|
||||
$body = json_decode($this->response->getBody(), true);
|
||||
|
||||
$body = json_decode($this->response->getBody(), true);
|
||||
|
||||
if (empty($body['data'])) {
|
||||
throw new \Exception('Error with request: no data returned');
|
||||
}
|
||||
@ -513,19 +552,22 @@ class Client implements ClientInterface
|
||||
public function createToken(array $payload = array())
|
||||
{
|
||||
if (isset($payload['pairingCode']) && 1 !== preg_match('/^[a-zA-Z0-9]{7}$/', $payload['pairingCode'])) {
|
||||
throw new \InvalidArgumentException("pairing code is not legal");
|
||||
throw new \Exception('[ERROR] In Client::createToken(): The pairing code provided is not legal.');
|
||||
}
|
||||
|
||||
$this->request = $this->createNewRequest();
|
||||
$this->request->setMethod(Request::METHOD_POST);
|
||||
$this->request->setPath('tokens');
|
||||
|
||||
$payload['guid'] = Util::guid();
|
||||
|
||||
$this->request->setBody(json_encode($payload));
|
||||
$this->response = $this->sendRequest($this->request);
|
||||
$body = json_decode($this->response->getBody(), true);
|
||||
|
||||
$body = json_decode($this->response->getBody(), true);
|
||||
|
||||
if (isset($body['error'])) {
|
||||
throw new \Bitpay\Client\BitpayException($this->response->getStatusCode().": ".$body['error']);
|
||||
throw new \Bitpay\Client\BitpayException($this->response->getStatusCode() . ': ' . $body['error']);
|
||||
}
|
||||
|
||||
if($this->response->getStatusCode() >= 400) {
|
||||
@ -535,13 +577,13 @@ class Client implements ClientInterface
|
||||
$tkn = $body['data'][0];
|
||||
$createdAt = new \DateTime();
|
||||
$pairingExpiration = new \DateTime();
|
||||
|
||||
$token = new \Bitpay\Token();
|
||||
|
||||
$token
|
||||
->setPolicies($tkn['policies'])
|
||||
->setToken($tkn['token'])
|
||||
->setFacade($tkn['facade'])
|
||||
->setCreatedAt($createdAt->setTimestamp(floor($tkn['dateCreated']/1000)));
|
||||
->setCreatedAt($createdAt->setTimestamp(floor($tkn['dateCreated'] / 1000)));
|
||||
|
||||
if (isset($tkn['resource'])) {
|
||||
$token->setResource($tkn['resource']);
|
||||
@ -549,15 +591,15 @@ class Client implements ClientInterface
|
||||
|
||||
if (isset($tkn['pairingCode'])) {
|
||||
$token->setPairingCode($tkn['pairingCode']);
|
||||
$token->setPairingExpiration($pairingExpiration->setTimestamp(floor($tkn['pairingExpiration']/1000)));
|
||||
$token->setPairingExpiration($pairingExpiration->setTimestamp(floor($tkn['pairingExpiration'] / 1000)));
|
||||
}
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Response object that BitPay returned from the request that
|
||||
* was sent
|
||||
* Returns the Response object that BitPay returned from
|
||||
* the request that was sent.
|
||||
*
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
@ -567,7 +609,7 @@ class Client implements ClientInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the request object that was sent to BitPay
|
||||
* Returns the request object that was sent to BitPay.
|
||||
*
|
||||
* @return RequestInterface
|
||||
*/
|
||||
@ -583,6 +625,7 @@ class Client implements ClientInterface
|
||||
{
|
||||
$this->request = $this->createNewRequest();
|
||||
$this->request->setMethod(Request::METHOD_GET);
|
||||
|
||||
if ($this->token && $this->token->getFacade() === 'merchant') {
|
||||
$this->request->setPath(sprintf('invoices/%s?token=%s', $invoiceId, $this->token->getToken()));
|
||||
$this->addIdentityHeader($this->request);
|
||||
@ -590,7 +633,9 @@ class Client implements ClientInterface
|
||||
} else {
|
||||
$this->request->setPath(sprintf('invoices/%s', $invoiceId));
|
||||
}
|
||||
|
||||
$this->response = $this->sendRequest($this->request);
|
||||
|
||||
$body = json_decode($this->response->getBody(), true);
|
||||
|
||||
if (isset($body['error'])) {
|
||||
@ -605,10 +650,6 @@ class Client implements ClientInterface
|
||||
return $invoice;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param RequestInterface $request
|
||||
* @return ResponseInterface
|
||||
@ -625,11 +666,12 @@ class Client implements ClientInterface
|
||||
|
||||
/**
|
||||
* @param RequestInterface $request
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function addIdentityHeader(RequestInterface $request)
|
||||
{
|
||||
if (null === $this->publicKey) {
|
||||
throw new \Exception('Please set your Public Key.');
|
||||
throw new \Exception('[ERROR] In Client::addIdentityHeader(): No public key value found. Please set your kublic key first before you can add the x-identity header.');
|
||||
}
|
||||
|
||||
$request->setHeader('x-identity', (string) $this->publicKey);
|
||||
@ -637,6 +679,7 @@ class Client implements ClientInterface
|
||||
|
||||
/**
|
||||
* @param RequestInterface $request
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function addSignatureHeader(RequestInterface $request)
|
||||
{
|
||||
@ -677,20 +720,25 @@ class Client implements ClientInterface
|
||||
/**
|
||||
* Prepares the request object by adding additional headers
|
||||
*
|
||||
* @see http://en.wikipedia.org/wiki/User_agent
|
||||
* @param RequestInterface $request
|
||||
*/
|
||||
protected function prepareRequestHeaders(RequestInterface $request)
|
||||
{
|
||||
// @see http://en.wikipedia.org/wiki/User_agent
|
||||
$request->setHeader(
|
||||
'User-Agent',
|
||||
sprintf('%s/%s (PHP %s)', self::NAME, self::VERSION, phpversion())
|
||||
);
|
||||
|
||||
$request->setHeader('X-BitPay-Plugin-Info', sprintf('%s/%s', self::NAME, self::VERSION));
|
||||
$request->setHeader('Content-Type', 'application/json');
|
||||
$request->setHeader('X-Accept-Version', '2.0.0');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $price
|
||||
* @param string $currency
|
||||
*/
|
||||
protected function checkPriceAndCurrency($price, $currency)
|
||||
{
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -10,15 +10,12 @@ use Bitpay\InvoiceInterface;
|
||||
use Bitpay\PayoutInterface;
|
||||
|
||||
/**
|
||||
* Sends request(s) to bitpay server
|
||||
* Interface for class that sends request(s) to BitPay.
|
||||
*
|
||||
* @package Bitpay
|
||||
*/
|
||||
interface ClientInterface
|
||||
{
|
||||
const TESTNET = '0x6F';
|
||||
const LIVENET = '0x00';
|
||||
|
||||
/**
|
||||
* These can be changed/updated so when the request is sent to BitPay it
|
||||
* gives insight into what is making the calls.
|
||||
@ -28,17 +25,6 @@ interface ClientInterface
|
||||
const NAME = 'BitPay PHP-Client';
|
||||
const VERSION = '2.2.20';
|
||||
|
||||
//public function createApplication(ApplicationInterface $application);
|
||||
|
||||
//public function createBill(BillInterface $bill);
|
||||
//public function getBills($status = null);
|
||||
//public function getBill($billId);
|
||||
//public function updateBill(BillInterface $bill);
|
||||
|
||||
//public function createAccessToken(AccessTokenInterface $accessToken);
|
||||
//public function getAccessTokens();
|
||||
//public function getAccessToken($keyId);
|
||||
|
||||
public function getCurrencies();
|
||||
|
||||
/**
|
||||
@ -47,7 +33,6 @@ interface ClientInterface
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createInvoice(InvoiceInterface $invoice);
|
||||
//public function getInvoices();
|
||||
|
||||
/**
|
||||
* @param $invoiceId
|
||||
@ -56,17 +41,9 @@ interface ClientInterface
|
||||
*/
|
||||
public function getInvoice($invoiceId);
|
||||
|
||||
|
||||
|
||||
//public function getLedgers();
|
||||
//public function getLedger(CurrencyInterface $currency);
|
||||
|
||||
//public function getOrgs();
|
||||
//public function getOrg($orgId);
|
||||
//public function updateOrg(OrgInterface $org);
|
||||
|
||||
/**
|
||||
* Create a Payout Request on Bitpay
|
||||
* Create a Payout Request on Bitpay.
|
||||
*
|
||||
* @param PayoutInterface $payout
|
||||
* @return PayoutInterface|mixed
|
||||
* @throws \Exception
|
||||
@ -94,18 +71,11 @@ interface ClientInterface
|
||||
*/
|
||||
public function deletePayout(PayoutInterface $payout);
|
||||
|
||||
//public function updatePayout(PayoutInterface $payout);
|
||||
|
||||
//public function getRates();
|
||||
//public function getRate(CurrencyInterface $currency);
|
||||
|
||||
/**
|
||||
* Get an array of tokens indexed by facade
|
||||
* Get an array of tokens indexed by facade.
|
||||
*
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getTokens();
|
||||
|
||||
//public function getUser();
|
||||
//public function updateUser(UserInterface $user);
|
||||
}
|
||||
|
||||
@ -1,7 +1,13 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
namespace Bitpay\Client;
|
||||
|
||||
/**
|
||||
* @package Bitpay
|
||||
*/
|
||||
class ConnectionException extends \Exception
|
||||
{
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -44,8 +44,6 @@ class Request implements RequestInterface
|
||||
*/
|
||||
protected $path;
|
||||
|
||||
/**
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Set some sane default headers
|
||||
@ -62,7 +60,7 @@ class Request implements RequestInterface
|
||||
|
||||
/**
|
||||
* Converts this request into a standard HTTP/1.1 message to be sent over
|
||||
* the wire
|
||||
* the wire.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@ -93,7 +91,7 @@ class Request implements RequestInterface
|
||||
|
||||
/**
|
||||
* Set the method of the request, for known methods see the
|
||||
* RequestInterface
|
||||
* RequestInterface.
|
||||
*
|
||||
* @param string $method
|
||||
*/
|
||||
@ -110,7 +108,7 @@ class Request implements RequestInterface
|
||||
return $this->uri;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getFullUri()
|
||||
@ -130,6 +128,7 @@ class Request implements RequestInterface
|
||||
public function setUri($uri)
|
||||
{
|
||||
$this->uri = $uri;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -140,6 +139,7 @@ class Request implements RequestInterface
|
||||
{
|
||||
// remove invalid headers
|
||||
$headers = $this->headers;
|
||||
|
||||
foreach ($headers as $header => $value) {
|
||||
if (empty($header) || empty($value)) {
|
||||
unset($headers[$header]);
|
||||
@ -149,9 +149,13 @@ class Request implements RequestInterface
|
||||
return $headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getHeaderFields()
|
||||
{
|
||||
$fields = array();
|
||||
|
||||
foreach ($this->getHeaders() as $header => $value) {
|
||||
$fields[] = sprintf('%s: %s', $header, $value);
|
||||
}
|
||||
@ -171,20 +175,22 @@ class Request implements RequestInterface
|
||||
$return .= sprintf("%s: %s\r\n", $h, $v);
|
||||
}
|
||||
|
||||
return $return."\r\n";
|
||||
return $return . "\r\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a http header for the request
|
||||
* Set a http header for the request.
|
||||
*
|
||||
* @param string $header
|
||||
* @param string $value
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function setHeader($header, $value)
|
||||
{
|
||||
if (is_array($value)) {
|
||||
throw new \Exception('Could not set the header: '.$header);
|
||||
throw new \Exception('Could not set the header: ' . $header);
|
||||
}
|
||||
|
||||
$this->headers[$header] = $value;
|
||||
}
|
||||
|
||||
@ -197,9 +203,10 @@ class Request implements RequestInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* The the body of the request
|
||||
* Sets the body of the request.
|
||||
*
|
||||
* @param string $body
|
||||
* @return Request
|
||||
*/
|
||||
public function setBody($body)
|
||||
{
|
||||
@ -219,6 +226,7 @@ class Request implements RequestInterface
|
||||
|
||||
/**
|
||||
* @param string $host
|
||||
* @return Request
|
||||
*/
|
||||
public function setPath($path)
|
||||
{
|
||||
|
||||
@ -1,13 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace Bitpay\Client;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Bitpay
|
||||
*/
|
||||
interface RequestInterface
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace Bitpay\Client;
|
||||
|
||||
/**
|
||||
* Generic Response object used to parse a response from a server
|
||||
* Generic Response class used to parse a response from a server.
|
||||
*
|
||||
* @package Bitpay
|
||||
*/
|
||||
@ -33,8 +33,6 @@ class Response implements ResponseInterface
|
||||
*/
|
||||
protected $statusCode;
|
||||
|
||||
/**
|
||||
*/
|
||||
public function __construct($raw = null)
|
||||
{
|
||||
$this->headers = array();
|
||||
@ -48,7 +46,7 @@ class Response implements ResponseInterface
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return (string) $this->raw;
|
||||
return (string)$this->raw;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -70,7 +68,7 @@ class Response implements ResponseInterface
|
||||
$linesLen = count($lines);
|
||||
|
||||
for ($i = 0; $i < $linesLen; $i++) {
|
||||
if (0 == $i) {
|
||||
if (0 === $i) {
|
||||
preg_match('/^HTTP\/(\d\.\d)\s(\d+)\s(.+)/', $lines[$i], $statusLine);
|
||||
|
||||
$response->setStatusCode($statusCode = $statusLine[2]);
|
||||
@ -104,12 +102,11 @@ class Response implements ResponseInterface
|
||||
|
||||
/**
|
||||
* @param integer
|
||||
*
|
||||
* @return ResponseInterface
|
||||
* @return Response
|
||||
*/
|
||||
public function setStatusCode($statusCode)
|
||||
{
|
||||
$this->statusCode = (integer) $statusCode;
|
||||
$this->statusCode = (integer)$statusCode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@ -126,6 +123,7 @@ class Response implements ResponseInterface
|
||||
* Set the body of the response
|
||||
*
|
||||
* @param string $body
|
||||
* @return Response
|
||||
*/
|
||||
public function setBody($body)
|
||||
{
|
||||
@ -145,6 +143,7 @@ class Response implements ResponseInterface
|
||||
/**
|
||||
* @param string $header
|
||||
* @param string $value
|
||||
* @return Response
|
||||
*/
|
||||
public function setHeader($header, $value)
|
||||
{
|
||||
|
||||
@ -1,13 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace Bitpay\Client;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Bitpay
|
||||
*/
|
||||
interface ResponseInterface
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -15,35 +15,42 @@ use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
* documentation as well.
|
||||
*
|
||||
* @see http://symfony.com/doc/current/components/config/definition.html
|
||||
*
|
||||
* @package Bitpay
|
||||
*/
|
||||
class Configuration implements ConfigurationInterface
|
||||
{
|
||||
private $pubfilename = '/.bitpay/api.pub';
|
||||
private $prifilename = '/.bitpay/api.key';
|
||||
private $sinfilename = '/.bitpay/api.sin';
|
||||
private $defstorage = 'Bitpay\Storage\EncryptedFilesystemStorage';
|
||||
private $adapters = array('curl', 'mock');
|
||||
|
||||
/**
|
||||
* @return TreeBuilder
|
||||
*/
|
||||
public function getConfigTreeBuilder()
|
||||
{
|
||||
$treeBuilder = new TreeBuilder();
|
||||
$rootNode = $treeBuilder->root('bitpay');
|
||||
|
||||
$rootNode
|
||||
->children()
|
||||
->scalarNode('public_key')
|
||||
->info('Public Key Filename')
|
||||
->defaultValue(getenv('HOME').'/.bitpay/api.pub')
|
||||
->defaultValue($this->getPubKeyFilename())
|
||||
->end()
|
||||
->scalarNode('private_key')
|
||||
->info('Private Key Filename')
|
||||
->defaultValue(getenv('HOME').'/.bitpay/api.key')
|
||||
->defaultValue($this->getPriKeyFilename())
|
||||
->end()
|
||||
->scalarNode('sin_key')
|
||||
->info('Private Key Filename')
|
||||
->defaultValue(getenv('HOME').'/.bitpay/api.sin')
|
||||
->info('SIN Filename')
|
||||
->defaultValue($this->getSinFilename())
|
||||
->end()
|
||||
->enumNode('adapter')
|
||||
->values(array('curl', 'mock'))
|
||||
->values($this->adapters)
|
||||
->info('Client Adapter')
|
||||
->defaultValue('curl')
|
||||
->defaultValue($this->adapters[0])
|
||||
->end()
|
||||
->append($this->addKeyStorageNode())
|
||||
->scalarNode('key_storage_password')
|
||||
@ -56,11 +63,13 @@ class Configuration implements ConfigurationInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the key_storage node with validation rules
|
||||
*
|
||||
* Adds the key_storage node with validation rules.
|
||||
* key_storage MUST:
|
||||
* * implement Bitpay\Storage\StorageInterface
|
||||
* * be a class that can be loaded
|
||||
*
|
||||
* @return \Symfony\Component\Config\Definition\Builder\NodeDefinition
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function addKeyStorageNode()
|
||||
{
|
||||
@ -69,7 +78,7 @@ class Configuration implements ConfigurationInterface
|
||||
|
||||
$node
|
||||
->info('Class that is used to store your keys')
|
||||
->defaultValue('Bitpay\Storage\EncryptedFilesystemStorage')
|
||||
->defaultValue($this->defstorage)
|
||||
->validate()
|
||||
->always()
|
||||
->then(function ($value) {
|
||||
@ -83,13 +92,8 @@ class Configuration implements ConfigurationInterface
|
||||
}
|
||||
|
||||
// requires PHP >= 5.3.7
|
||||
if (!is_subclass_of($value, 'Bitpay\Storage\StorageInterface')) {
|
||||
throw new \Exception(
|
||||
sprintf(
|
||||
'"%s" does not implement "Bitpay\Storage\StorageInterface"',
|
||||
$value
|
||||
)
|
||||
);
|
||||
if (is_subclass_of($value, 'Bitpay\Storage\StorageInterface') === false) {
|
||||
throw new \Exception('[ERROR] In Configuration::addKeyStorageNode(): "' . $value . '" does not implement "Bitpay\Storage\StorageInterface".');
|
||||
}
|
||||
|
||||
return $value;
|
||||
@ -98,4 +102,28 @@ class Configuration implements ConfigurationInterface
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getPubKeyFilename()
|
||||
{
|
||||
return getenv('HOME') . $this->pubfilename;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getPriKeyFilename()
|
||||
{
|
||||
return getenv('HOME') . $this->prifilename;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getSinFilename()
|
||||
{
|
||||
return getenv('HOME') . $this->sinfilename;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace Bitpay;
|
||||
|
||||
use Bitpay\Client;
|
||||
|
||||
/**
|
||||
* For the most part this should conform to ISO 4217
|
||||
*
|
||||
|
||||
@ -1,15 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace Bitpay;
|
||||
|
||||
/**
|
||||
* This is the currency code set for the price setting. The pricing currencies
|
||||
* currently supported are USD, EUR, BTC, and all of the codes listed on this page:
|
||||
* https://bitpay.com/bitcoinexchangerates
|
||||
* This is the currency code set for the price setting. The currencies supported are any
|
||||
* of the codes listed on this page: https://bitpay.com/bitcoin-exchange-rates
|
||||
*
|
||||
* @package Bitpay
|
||||
*/
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!--
|
||||
/**
|
||||
* @license Copyright 2011-2017 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2017 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
-->
|
||||
|
||||
@ -1,13 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace Bitpay;
|
||||
|
||||
use DateTime;
|
||||
use DateTimeZone;
|
||||
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Bitpay
|
||||
*/
|
||||
class Invoice implements InvoiceInterface
|
||||
@ -20,7 +24,7 @@ class Invoice implements InvoiceInterface
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $orderId;
|
||||
protected $orderId = '';
|
||||
|
||||
/**
|
||||
* @var ItemInterface
|
||||
@ -30,32 +34,32 @@ class Invoice implements InvoiceInterface
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $transactionSpeed = self::TRANSACTION_SPEED_MEDIUM;
|
||||
protected $transactionSpeed = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $notificationEmail;
|
||||
protected $notificationEmail = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $notificationUrl;
|
||||
protected $notificationUrl = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectUrl;
|
||||
protected $redirectUrl = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $posData;
|
||||
protected $posData = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $status;
|
||||
protected $status = '';
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
@ -70,26 +74,26 @@ class Invoice implements InvoiceInterface
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $id;
|
||||
protected $id = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $url;
|
||||
protected $url = '';
|
||||
|
||||
/**
|
||||
* @deprecated Deprecated with introduction of BCH
|
||||
* @var float
|
||||
*/
|
||||
protected $btcPrice;
|
||||
protected $btcPrice = 0.000000;
|
||||
|
||||
/**
|
||||
* @var \DateTime
|
||||
* @var DateTime
|
||||
*/
|
||||
protected $invoiceTime;
|
||||
|
||||
/**
|
||||
* @var \DateTime
|
||||
* @var DateTime
|
||||
*/
|
||||
protected $expirationTime;
|
||||
|
||||
@ -104,15 +108,15 @@ class Invoice implements InvoiceInterface
|
||||
protected $buyer;
|
||||
|
||||
/**
|
||||
* @var
|
||||
* @var string
|
||||
*/
|
||||
protected $exceptionStatus;
|
||||
protected $exceptionStatus = '';
|
||||
|
||||
/**
|
||||
* @deprecated Deprecated with introduction of BCH
|
||||
* @var
|
||||
* @var float
|
||||
*/
|
||||
protected $btcPaid;
|
||||
protected $btcPaid = 0.000000;
|
||||
|
||||
/**
|
||||
* @var
|
||||
@ -121,12 +125,12 @@ class Invoice implements InvoiceInterface
|
||||
|
||||
/**
|
||||
* @deprecated Deprecated with introduction of BCH
|
||||
* @var
|
||||
* @var float
|
||||
*/
|
||||
protected $rate;
|
||||
protected $rate = 0.000000;
|
||||
|
||||
/**
|
||||
* @var
|
||||
* @var Token
|
||||
*/
|
||||
protected $token;
|
||||
|
||||
@ -155,13 +159,37 @@ class Invoice implements InvoiceInterface
|
||||
*/
|
||||
protected $paymentTotals;
|
||||
|
||||
/**
|
||||
* @var PaymentUrlInterface
|
||||
*/
|
||||
protected $paymentUrls;
|
||||
|
||||
public function __construct(
|
||||
$transactionSpeed = self::TRANSACTION_SPEED_MEDIUM,
|
||||
$fullNotifications = true,
|
||||
$item = null,
|
||||
$currency = null,
|
||||
$orderId = '',
|
||||
$posData = ''
|
||||
) {
|
||||
$this->currency = $currency;
|
||||
$this->transactionSpeed = $transactionSpeed;
|
||||
$this->fullNotifications = $fullNotifications;
|
||||
$this->item = $item;
|
||||
$this->orderId = $orderId;
|
||||
$this->posData = $posData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getPrice()
|
||||
{
|
||||
return $this->getItem()->getPrice();
|
||||
if (is_a($this->item, '\Bitpay\Item')) {
|
||||
return $this->getItem()->getPrice();
|
||||
}
|
||||
|
||||
return 0.000000;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -174,13 +202,12 @@ class Invoice implements InvoiceInterface
|
||||
|
||||
/**
|
||||
* @param float $price
|
||||
*
|
||||
* @return InvoiceInterface
|
||||
* @return Invoice
|
||||
*/
|
||||
public function setPrice($price)
|
||||
{
|
||||
if (!empty($price)) {
|
||||
$this->getItem()->setPrice($price);
|
||||
if (is_numeric($price)) {
|
||||
$this->getItem()->setPrice(floatval($price));
|
||||
}
|
||||
|
||||
return $this;
|
||||
@ -205,17 +232,20 @@ class Invoice implements InvoiceInterface
|
||||
*/
|
||||
public function getCurrency()
|
||||
{
|
||||
if ($this->currency === null) {
|
||||
$this->currency = new Currency('BTC');
|
||||
}
|
||||
|
||||
return $this->currency;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CurrencyInterface $currency
|
||||
*
|
||||
* @return InvoiceInterface
|
||||
* @return Invoice
|
||||
*/
|
||||
public function setCurrency(CurrencyInterface $currency)
|
||||
{
|
||||
if (!empty($currency)) {
|
||||
if (is_a($currency, '\Bitpay\Currency')) {
|
||||
$this->currency = $currency;
|
||||
}
|
||||
|
||||
@ -227,10 +257,7 @@ class Invoice implements InvoiceInterface
|
||||
*/
|
||||
public function getItem()
|
||||
{
|
||||
// If there is not an item already set, we need to use a default item
|
||||
// so that some methods do not throw errors about methods and
|
||||
// non-objects.
|
||||
if (null == $this->item) {
|
||||
if (null === $this->item) {
|
||||
$this->item = new Item();
|
||||
}
|
||||
|
||||
@ -239,12 +266,11 @@ class Invoice implements InvoiceInterface
|
||||
|
||||
/**
|
||||
* @param ItemInterface $item
|
||||
*
|
||||
* @return InvoiceInterface
|
||||
* @return Invoice
|
||||
*/
|
||||
public function setItem(ItemInterface $item)
|
||||
{
|
||||
if (!empty($item)) {
|
||||
if (is_a($item, '\Bitpay\Item')) {
|
||||
$this->item = $item;
|
||||
}
|
||||
|
||||
@ -256,8 +282,7 @@ class Invoice implements InvoiceInterface
|
||||
*/
|
||||
public function getBuyer()
|
||||
{
|
||||
// Same logic as getItem method
|
||||
if (null == $this->buyer) {
|
||||
if ($this->buyer === null) {
|
||||
$this->buyer = new Buyer();
|
||||
}
|
||||
|
||||
@ -266,12 +291,11 @@ class Invoice implements InvoiceInterface
|
||||
|
||||
/**
|
||||
* @param BuyerInterface $buyer
|
||||
*
|
||||
* @return InvoiceInterface
|
||||
* @return Invoice
|
||||
*/
|
||||
public function setBuyer(BuyerInterface $buyer)
|
||||
{
|
||||
if (!empty($buyer)) {
|
||||
if (is_a($buyer, '\Bitpay\Buyer')) {
|
||||
$this->buyer = $buyer;
|
||||
}
|
||||
|
||||
@ -288,13 +312,20 @@ class Invoice implements InvoiceInterface
|
||||
|
||||
/**
|
||||
* @param string $transactionSpeed
|
||||
*
|
||||
* @return InvoiceInterface
|
||||
* @return Invoice
|
||||
*/
|
||||
public function setTransactionSpeed($transactionSpeed)
|
||||
{
|
||||
if (!empty($transactionSpeed) && ctype_print($transactionSpeed)) {
|
||||
$this->transactionSpeed = trim($transactionSpeed);
|
||||
switch (strtolower(trim($transactionSpeed))) {
|
||||
case 'high':
|
||||
$this->transactionSpeed = self::TRANSACTION_SPEED_HIGH;
|
||||
break;
|
||||
case 'medium':
|
||||
$this->transactionSpeed = self::TRANSACTION_SPEED_MEDIUM;
|
||||
break;
|
||||
case 'low':
|
||||
default:
|
||||
$this->transactionSpeed = self::TRANSACTION_SPEED_LOW;
|
||||
}
|
||||
|
||||
return $this;
|
||||
@ -310,12 +341,11 @@ class Invoice implements InvoiceInterface
|
||||
|
||||
/**
|
||||
* @param string $notificationEmail
|
||||
*
|
||||
* @return InvoiceInterface
|
||||
* @return Invoice
|
||||
*/
|
||||
public function setNotificationEmail($notificationEmail)
|
||||
{
|
||||
if (!empty($notificationEmail) && ctype_print($notificationEmail)) {
|
||||
if (filter_var($notificationEmail, FILTER_VALIDATE_EMAIL)) {
|
||||
$this->notificationEmail = trim($notificationEmail);
|
||||
}
|
||||
|
||||
@ -332,12 +362,11 @@ class Invoice implements InvoiceInterface
|
||||
|
||||
/**
|
||||
* @param string $notificationUrl
|
||||
*
|
||||
* @return InvoiceInterface
|
||||
* @return Invoice
|
||||
*/
|
||||
public function setNotificationUrl($notificationUrl)
|
||||
{
|
||||
if (!empty($notificationUrl) && ctype_print($notificationUrl)) {
|
||||
if (preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $notificationUrl)) {
|
||||
$this->notificationUrl = trim($notificationUrl);
|
||||
}
|
||||
|
||||
@ -354,12 +383,11 @@ class Invoice implements InvoiceInterface
|
||||
|
||||
/**
|
||||
* @param string $redirectUrl
|
||||
*
|
||||
* @return InvoiceInterface
|
||||
* @return Invoice
|
||||
*/
|
||||
public function setRedirectUrl($redirectUrl)
|
||||
{
|
||||
if (!empty($redirectUrl) && ctype_print($redirectUrl)) {
|
||||
if (preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $redirectUrl)) {
|
||||
$this->redirectUrl = trim($redirectUrl);
|
||||
}
|
||||
|
||||
@ -376,12 +404,11 @@ class Invoice implements InvoiceInterface
|
||||
|
||||
/**
|
||||
* @param string $posData
|
||||
*
|
||||
* @return InvoiceInterface
|
||||
* @return Invoice
|
||||
*/
|
||||
public function setPosData($posData)
|
||||
{
|
||||
if (!empty($posData)) {
|
||||
if (is_string($posData)) {
|
||||
$this->posData = $posData;
|
||||
}
|
||||
|
||||
@ -398,12 +425,11 @@ class Invoice implements InvoiceInterface
|
||||
|
||||
/**
|
||||
* @param string $status
|
||||
*
|
||||
* @return InvoiceInterface
|
||||
* @return Invoice
|
||||
*/
|
||||
public function setStatus($status)
|
||||
{
|
||||
if (!empty($status) && ctype_print($status)) {
|
||||
if (is_string($status)) {
|
||||
$this->status = trim($status);
|
||||
}
|
||||
|
||||
@ -450,12 +476,11 @@ class Invoice implements InvoiceInterface
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
*
|
||||
* @return InvoiceInterface
|
||||
* @return Invoice
|
||||
*/
|
||||
public function setId($id)
|
||||
{
|
||||
if (!empty($id) && ctype_print($id)) {
|
||||
if (is_string($id)) {
|
||||
$this->id = trim($id);
|
||||
}
|
||||
|
||||
@ -472,12 +497,11 @@ class Invoice implements InvoiceInterface
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
*
|
||||
* @return InvoiceInterface
|
||||
* @return Invoice
|
||||
*/
|
||||
public function setUrl($url)
|
||||
{
|
||||
if (!empty($url) && ctype_print($url)) {
|
||||
if (preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $url)) {
|
||||
$this->url = trim($url);
|
||||
}
|
||||
|
||||
@ -496,13 +520,12 @@ class Invoice implements InvoiceInterface
|
||||
/**
|
||||
* @deprecated Deprecated with introduction of BCH
|
||||
* @param float $btcPrice
|
||||
*
|
||||
* @return InvoiceInterface
|
||||
* @return Invoice
|
||||
*/
|
||||
public function setBtcPrice($btcPrice)
|
||||
{
|
||||
if (!empty($btcPrice)) {
|
||||
$this->btcPrice = $btcPrice;
|
||||
if (is_numeric($btcPrice)) {
|
||||
$this->btcPrice = floatval($btcPrice);
|
||||
}
|
||||
|
||||
return $this;
|
||||
@ -518,18 +541,18 @@ class Invoice implements InvoiceInterface
|
||||
|
||||
/**
|
||||
* @param DateTime $invoiceTime
|
||||
*
|
||||
* @return InvoiceInterface
|
||||
* @return Invoice
|
||||
*/
|
||||
public function setInvoiceTime($invoiceTime)
|
||||
{
|
||||
if (is_a($invoiceTime, 'DateTime')) {
|
||||
$this->invoiceTime = $invoiceTime;
|
||||
} else if (is_numeric($invoiceTime)) {
|
||||
$invoiceDateTime = new \DateTime('', new \DateTimeZone("UTC"));
|
||||
$invoiceDateTime = new DateTime('', new DateTimeZone('UTC'));
|
||||
$invoiceDateTime->setTimestamp($invoiceTime);
|
||||
$this->invoiceTime = $invoiceDateTime;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -543,18 +566,18 @@ class Invoice implements InvoiceInterface
|
||||
|
||||
/**
|
||||
* @param DateTime $expirationTime
|
||||
*
|
||||
* return InvoiceInterface
|
||||
* return Invoice
|
||||
*/
|
||||
public function setExpirationTime($expirationTime)
|
||||
{
|
||||
if (is_a($expirationTime, 'DateTime')) {
|
||||
$this->expirationTime = $expirationTime;
|
||||
} else if (is_numeric($expirationTime)) {
|
||||
$expirationDateTime = new \DateTime('', new \DateTimeZone("UTC"));
|
||||
$expirationDateTime = new DateTime('', new DateTimeZone('UTC'));
|
||||
$expirationDateTime->setTimestamp($expirationTime);
|
||||
$this->expirationTime = $expirationDateTime;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -568,18 +591,18 @@ class Invoice implements InvoiceInterface
|
||||
|
||||
/**
|
||||
* @param DateTime $currentTime
|
||||
*
|
||||
* @return InvoiceInterface
|
||||
* @return Invoice
|
||||
*/
|
||||
public function setCurrentTime($currentTime)
|
||||
{
|
||||
if (is_a($currentTime, 'DateTime')) {
|
||||
$this->currentTime = $currentTime;
|
||||
} else if (is_numeric($currentTime)) {
|
||||
$currentDateTime = new \DateTime('', new \DateTimeZone("UTC"));
|
||||
$currentDateTime = new DateTime('', new DateTimeZone('UTC'));
|
||||
$currentDateTime->setTimestamp($currentTime);
|
||||
$this->currentTime = $currentDateTime;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -593,12 +616,11 @@ class Invoice implements InvoiceInterface
|
||||
|
||||
/**
|
||||
* @param string $orderId
|
||||
*
|
||||
* @return InvoiceInterface
|
||||
* @return Invoice
|
||||
*/
|
||||
public function setOrderId($orderId)
|
||||
{
|
||||
if (!empty($orderId) && ctype_print($orderId)) {
|
||||
if (is_string($orderId)) {
|
||||
$this->orderId = trim($orderId);
|
||||
}
|
||||
|
||||
@ -637,7 +659,7 @@ class Invoice implements InvoiceInterface
|
||||
$firstName = $this->getBuyer()->getFirstName();
|
||||
$lastName = $this->getBuyer()->getLastName();
|
||||
|
||||
return trim($firstName.' '.$lastName);
|
||||
return trim($firstName . ' ' . $lastName);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -718,8 +740,7 @@ class Invoice implements InvoiceInterface
|
||||
|
||||
/**
|
||||
* @param
|
||||
*
|
||||
* @return InvoiceInterface
|
||||
* @return Invoice
|
||||
*/
|
||||
public function setExceptionStatus($exceptionStatus)
|
||||
{
|
||||
@ -744,7 +765,7 @@ class Invoice implements InvoiceInterface
|
||||
*/
|
||||
public function setBtcPaid($btcPaid)
|
||||
{
|
||||
if (isset($btcPaid)) {
|
||||
if (is_numeric($btcPaid)) {
|
||||
$this->btcPaid = $btcPaid;
|
||||
}
|
||||
|
||||
@ -790,8 +811,8 @@ class Invoice implements InvoiceInterface
|
||||
*/
|
||||
public function setRate($rate)
|
||||
{
|
||||
if (!empty($rate)) {
|
||||
$this->rate = $rate;
|
||||
if (is_numeric($rate)) {
|
||||
$this->rate = floatval($rate);
|
||||
}
|
||||
|
||||
return $this;
|
||||
@ -827,15 +848,20 @@ class Invoice implements InvoiceInterface
|
||||
{
|
||||
return $this->token;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TokenInterface $token
|
||||
* @return InvoiceInterface
|
||||
* @return Invoice
|
||||
*/
|
||||
public function setToken(TokenInterface $token)
|
||||
{
|
||||
$this->token = $token;
|
||||
if (is_a($token, '\Bitpay\Token')) {
|
||||
$this->token = $token;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
@ -922,4 +948,36 @@ class Invoice implements InvoiceInterface
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PaymentUrlInterface
|
||||
*/
|
||||
public function getPaymentUrls()
|
||||
{
|
||||
if ($this->paymentUrls === null) {
|
||||
$this->paymentUrls = new PaymentUrlSet();
|
||||
}
|
||||
|
||||
return $this->paymentUrls;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PaymentUrlInterface $paymentUrls
|
||||
* @return Invoice
|
||||
*/
|
||||
public function setPaymentUrls(PaymentUrlInterface $paymentUrls)
|
||||
{
|
||||
$this->paymentUrls = $paymentUrls;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $paymentUrlType
|
||||
* @return string
|
||||
*/
|
||||
public function getPaymentUrl($paymentUrlType)
|
||||
{
|
||||
return $this->getPaymentUrls()->getUrl($paymentUrlType);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace Bitpay;
|
||||
|
||||
/**
|
||||
* Invoice
|
||||
*
|
||||
* @package Bitpay
|
||||
*/
|
||||
interface InvoiceInterface
|
||||
@ -80,7 +78,7 @@ interface InvoiceInterface
|
||||
* specified in a currency other than BTC, the price will be converted into BTC at
|
||||
* market exchange rates to determine the amount collected from the buyer.
|
||||
*
|
||||
* @return string
|
||||
* @return float
|
||||
*/
|
||||
public function getPrice();
|
||||
|
||||
@ -96,6 +94,10 @@ interface InvoiceInterface
|
||||
public function getCurrency();
|
||||
|
||||
/**
|
||||
* If there is not an item already set, we need to use a default item
|
||||
* so that some methods do not throw errors about methods and
|
||||
* non-objects.
|
||||
*
|
||||
* @return ItemInterface
|
||||
*/
|
||||
public function getItem();
|
||||
@ -204,7 +206,7 @@ interface InvoiceInterface
|
||||
* The amount of bitcoins being requested for payment of this invoice (same as the
|
||||
* price if the merchant set the price in BTC).
|
||||
*
|
||||
* @return string
|
||||
* @return float
|
||||
*/
|
||||
public function getBtcPrice();
|
||||
|
||||
@ -353,18 +355,22 @@ interface InvoiceInterface
|
||||
public function getBuyerPhone();
|
||||
|
||||
/**
|
||||
* Returns exception status.
|
||||
*/
|
||||
public function getExceptionStatus();
|
||||
|
||||
/**
|
||||
* Returns the amount of BTC paid.
|
||||
*/
|
||||
public function getBtcPaid();
|
||||
|
||||
/**
|
||||
* Returns the exchange rate.
|
||||
*/
|
||||
public function getRate();
|
||||
|
||||
/**
|
||||
* Returns the token for this resource.
|
||||
*/
|
||||
public function getToken();
|
||||
|
||||
@ -379,4 +385,11 @@ interface InvoiceInterface
|
||||
* @return array|object
|
||||
*/
|
||||
public function getRefundAddresses();
|
||||
|
||||
/**
|
||||
* Returns a set of payment urls.
|
||||
*
|
||||
* @return PaymentUrlInterface
|
||||
*/
|
||||
public function getPaymentUrls();
|
||||
}
|
||||
|
||||
@ -6,10 +6,7 @@
|
||||
|
||||
namespace Bitpay;
|
||||
|
||||
use Bitpay\Client;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Bitpay
|
||||
*/
|
||||
class Item implements ItemInterface
|
||||
@ -44,8 +41,6 @@ class Item implements ItemInterface
|
||||
*/
|
||||
protected $physical;
|
||||
|
||||
/**
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->physical = false;
|
||||
@ -61,7 +56,6 @@ class Item implements ItemInterface
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
*
|
||||
* @return ItemInterface
|
||||
*/
|
||||
public function setCode($code)
|
||||
@ -81,7 +75,6 @@ class Item implements ItemInterface
|
||||
|
||||
/**
|
||||
* @param string $description
|
||||
*
|
||||
* @return ItemInterface
|
||||
*/
|
||||
public function setDescription($description)
|
||||
@ -93,8 +86,6 @@ class Item implements ItemInterface
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getPrice()
|
||||
{
|
||||
@ -113,8 +104,7 @@ class Item implements ItemInterface
|
||||
|
||||
/**
|
||||
* @param mixed $price A float, integer, or en_US formatted numeric string
|
||||
*
|
||||
* @return ItemInterface
|
||||
* @return Item
|
||||
*/
|
||||
public function setPrice($price)
|
||||
{
|
||||
@ -148,8 +138,7 @@ class Item implements ItemInterface
|
||||
|
||||
/**
|
||||
* @param integer $quantity
|
||||
*
|
||||
* @return ItemInterface
|
||||
* @return Item
|
||||
*/
|
||||
public function setQuantity($quantity)
|
||||
{
|
||||
@ -168,8 +157,7 @@ class Item implements ItemInterface
|
||||
|
||||
/**
|
||||
* @param boolean $physical
|
||||
*
|
||||
* @return ItemInterface
|
||||
* @return Item
|
||||
*/
|
||||
public function setPhysical($physical)
|
||||
{
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -30,12 +30,12 @@ interface ItemInterface
|
||||
public function getDescription();
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @return float
|
||||
*/
|
||||
public function getPrice();
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @return integer
|
||||
*/
|
||||
public function getTaxIncluded();
|
||||
|
||||
|
||||
31
src/Bitpay/PaymentUrlInterface.php
Normal file
31
src/Bitpay/PaymentUrlInterface.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace Bitpay;
|
||||
|
||||
/**
|
||||
* Interface PaymentUrlInterface
|
||||
* @package Bitpay
|
||||
*/
|
||||
interface PaymentUrlInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* This is a list of returned payment url types
|
||||
*
|
||||
*/
|
||||
const BIP_21 = 'BIP21';
|
||||
const BIP_72 = 'BIP72';
|
||||
const BIP_72B = 'BIP72b';
|
||||
const BIP_73 = 'BIP73';
|
||||
|
||||
/**
|
||||
* Return the account parameter given by Bitpay.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUrl($urlType);
|
||||
}
|
||||
51
src/Bitpay/PaymentUrlSet.php
Normal file
51
src/Bitpay/PaymentUrlSet.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace Bitpay;
|
||||
|
||||
/**
|
||||
* @package Bitpay
|
||||
*/
|
||||
class PaymentUrlSet implements PaymentUrlInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $paymentUrls;
|
||||
|
||||
|
||||
public function __construct(array $paymentUrls = array())
|
||||
{
|
||||
$this->paymentUrls = $paymentUrls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the account parameter given by Bitpay.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUrl($urlType)
|
||||
{
|
||||
if (array_key_exists($urlType, $this->paymentUrls)) {
|
||||
return $this->paymentUrls[$urlType];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the account parameter given by Bitpay.
|
||||
*
|
||||
* @return PaymentUrlInterface
|
||||
*/
|
||||
public function setUrls(array $paymentUrls)
|
||||
{
|
||||
$this->paymentUrls = $paymentUrls;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@ -6,6 +6,8 @@
|
||||
|
||||
namespace Bitpay;
|
||||
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
/**
|
||||
* Class Payout
|
||||
* @package Bitpay
|
||||
|
||||
@ -6,6 +6,8 @@
|
||||
|
||||
namespace Bitpay;
|
||||
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
/**
|
||||
* Class PayoutInstruction
|
||||
* @package Bitpay
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -12,7 +12,7 @@ use Bitpay\Util\SecureRandom;
|
||||
use Bitpay\Math\Math;
|
||||
|
||||
/**
|
||||
* @package Bitcore
|
||||
* @package Bitpay
|
||||
* @see https://en.bitcoin.it/wiki/List_of_address_prefixes
|
||||
*/
|
||||
class PrivateKey extends Key
|
||||
@ -81,7 +81,7 @@ class PrivateKey extends Key
|
||||
do {
|
||||
$privateKey = \Bitpay\Util\SecureRandom::generateRandom(32);
|
||||
$this->hex = strtolower(bin2hex($privateKey));
|
||||
} while (Math::cmp('0x'.$this->hex, '1') <= 0 || Math::cmp('0x'.$this->hex, '0x'.Secp256k1::N) >= 0);
|
||||
} while (Math::cmp('0x'.$this->hex, '1') <= 0 || Math::cmp('0x' . $this->hex, '0x' . Secp256k1::N) >= 0);
|
||||
|
||||
$this->dec = Util::decodeHex($this->hex);
|
||||
|
||||
@ -117,9 +117,11 @@ class PrivateKey extends Key
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an ECDSA signature of $message
|
||||
* Creates an ECDSA signature of $data.
|
||||
*
|
||||
* @param string
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function sign($data)
|
||||
{
|
||||
@ -135,19 +137,19 @@ class PrivateKey extends Key
|
||||
|
||||
do {
|
||||
if (substr(strtolower($this->hex), 0, 2) != '0x') {
|
||||
$d = '0x'.$this->hex;
|
||||
$d = '0x' . $this->hex;
|
||||
} else {
|
||||
$d = $this->hex;
|
||||
}
|
||||
|
||||
$k = SecureRandom::generateRandom(32);
|
||||
|
||||
$k_hex = '0x'.strtolower(bin2hex($k));
|
||||
$n_hex = '0x'.Secp256k1::N;
|
||||
$k_hex = '0x' . strtolower(bin2hex($k));
|
||||
$n_hex = '0x' . Secp256k1::N;
|
||||
|
||||
|
||||
$Gx = '0x'.substr(Secp256k1::G, 2, 64);
|
||||
$Gy = '0x'.substr(Secp256k1::G, 66, 64);
|
||||
$Gx = '0x' . substr(Secp256k1::G, 2, 64);
|
||||
$Gy = '0x' . substr(Secp256k1::G, 66, 64);
|
||||
|
||||
$P = new Point($Gx, $Gy);
|
||||
|
||||
@ -155,11 +157,10 @@ class PrivateKey extends Key
|
||||
$R = Util::doubleAndAdd($k_hex, $P);
|
||||
|
||||
$Rx_hex = Util::encodeHex($R->getX());
|
||||
|
||||
$Rx_hex = str_pad($Rx_hex, 64, '0', STR_PAD_LEFT);
|
||||
|
||||
// r = x1 mod n
|
||||
$r = Math::mod('0x'.$Rx_hex, $n_hex);
|
||||
$r = Math::mod('0x' . $Rx_hex, $n_hex);
|
||||
|
||||
// s = k^-1 * (e+d*r) mod n
|
||||
$edr = Math::add($e, Math::mul($d, $r));
|
||||
@ -211,42 +212,44 @@ class PrivateKey extends Key
|
||||
$dec = Util::decodeHex($r);
|
||||
|
||||
while (Math::cmp($dec, '0') > 0) {
|
||||
$dv = Math::div($dec, '256');
|
||||
$rem = Math::mod($dec, '256');
|
||||
$dec = $dv;
|
||||
$byte = $byte.$digits[$rem];
|
||||
$dv = Math::div($dec, '256');
|
||||
$rem = Math::mod($dec, '256');
|
||||
$dec = $dv;
|
||||
$byte = $byte . $digits[$rem];
|
||||
}
|
||||
|
||||
$byte = strrev($byte);
|
||||
|
||||
// msb check
|
||||
if (Math::cmp('0x'.bin2hex($byte[0]), '0'.'x80') >= 0) {
|
||||
$byte = chr(0x00).$byte;
|
||||
if (Math::cmp('0x' . bin2hex($byte[0]), '0x80') >= 0) {
|
||||
$byte = chr(0x00) . $byte;
|
||||
}
|
||||
|
||||
$retval['bin_r'] = bin2hex($byte);
|
||||
$seq = chr(0x02).chr(strlen($byte)).$byte;
|
||||
$seq = chr(0x02) . chr(strlen($byte)) . $byte;
|
||||
$dec = Util::decodeHex($s);
|
||||
|
||||
$byte = '';
|
||||
|
||||
while (Math::cmp($dec, '0') > 0) {
|
||||
$dv = Math::div($dec, '256');
|
||||
$rem = Math::mod($dec, '256');
|
||||
$dec = $dv;
|
||||
$byte = $byte.$digits[$rem];
|
||||
$dv = Math::div($dec, '256');
|
||||
$rem = Math::mod($dec, '256');
|
||||
$dec = $dv;
|
||||
$byte = $byte . $digits[$rem];
|
||||
}
|
||||
|
||||
$byte = strrev($byte);
|
||||
|
||||
// msb check
|
||||
if (Math::cmp('0x'.bin2hex($byte[0]), '0'.'x80') >= 0) {
|
||||
$byte = chr(0x00).$byte;
|
||||
if (Math::cmp('0x' . bin2hex($byte[0]), '0x80') >= 0) {
|
||||
$byte = chr(0x00) . $byte;
|
||||
}
|
||||
|
||||
$retval['bin_s'] = bin2hex($byte);
|
||||
$seq = $seq.chr(0x02).chr(strlen($byte)).$byte;
|
||||
$seq = chr(0x30).chr(strlen($seq)).$seq;
|
||||
|
||||
$seq = $seq . chr(0x02) . chr(strlen($byte)) . $byte;
|
||||
$seq = chr(0x30) . chr(strlen($seq)) . $seq;
|
||||
|
||||
$retval['seq'] = bin2hex($seq);
|
||||
|
||||
return $retval;
|
||||
@ -257,6 +260,7 @@ class PrivateKey extends Key
|
||||
*
|
||||
* @param string $pem_data The data to decode.
|
||||
* @return array The keypair info.
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function pemDecode($pem_data)
|
||||
{
|
||||
@ -306,6 +310,7 @@ class PrivateKey extends Key
|
||||
*
|
||||
* @param array $keypair The keypair info.
|
||||
* @return string The data to decode.
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function pemEncode($keypair)
|
||||
{
|
||||
@ -342,7 +347,7 @@ class PrivateKey extends Key
|
||||
'a1_ele_len' => '44',
|
||||
'bit_str_beg' => '03',
|
||||
'bit_str_len' => '42',
|
||||
'bit_str_val' => '00'.$keypair[1],
|
||||
'bit_str_val' => '00' . $keypair[1],
|
||||
);
|
||||
|
||||
$beg_ec_text = '-----BEGIN EC PRIVATE KEY-----';
|
||||
@ -354,16 +359,16 @@ class PrivateKey extends Key
|
||||
throw new \Exception('Invalid or corrupt secp256k1 keypair provided. Cannot encode the supplied data.');
|
||||
}
|
||||
|
||||
$dec = Util::decodeHex('0x'.$dec);
|
||||
$dec = Util::decodeHex('0x' . $dec);
|
||||
|
||||
while (Math::cmp($dec, '0') > 0) {
|
||||
$dv = Math::div($dec, '256');
|
||||
$rem = Math::mod($dec, '256');
|
||||
$dec = $dv;
|
||||
$byte = $byte.$digits[$rem];
|
||||
$dv = Math::div($dec, '256');
|
||||
$rem = Math::mod($dec, '256');
|
||||
$dec = $dv;
|
||||
$byte = $byte . $digits[$rem];
|
||||
}
|
||||
|
||||
$byte = $beg_ec_text."\r\n".chunk_split(base64_encode(strrev($byte)), 64).$end_ec_text;
|
||||
$byte = $beg_ec_text . "\r\n" . chunk_split(base64_encode(strrev($byte)), 64) . $end_ec_text;
|
||||
|
||||
$this->pemEncoded = $byte;
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -11,7 +11,7 @@ use Bitpay\Util\Secp256k1;
|
||||
use Bitpay\Util\Util;
|
||||
|
||||
/**
|
||||
* @package Bitcore
|
||||
* @package Bitpay
|
||||
*/
|
||||
class PublicKey extends Key
|
||||
{
|
||||
@ -36,7 +36,7 @@ class PublicKey extends Key
|
||||
return '';
|
||||
}
|
||||
|
||||
if (Math::mod('0x'.$this->y, '0'.'x02') == '1') {
|
||||
if (Math::mod('0x'.$this->y, '0x02') == '1') {
|
||||
return sprintf('03%s', $this->x);
|
||||
} else {
|
||||
return sprintf('02%s', $this->x);
|
||||
@ -45,6 +45,7 @@ class PublicKey extends Key
|
||||
|
||||
/**
|
||||
* @param PrivateKey
|
||||
* @return PublicKey
|
||||
*/
|
||||
public static function createFromPrivateKey(PrivateKey $private)
|
||||
{
|
||||
@ -55,7 +56,8 @@ class PublicKey extends Key
|
||||
}
|
||||
|
||||
/**
|
||||
* @return KeyInterface
|
||||
* @param PrivateKey
|
||||
* @return PublicKey
|
||||
*/
|
||||
public function setPrivateKey(PrivateKey $privateKey)
|
||||
{
|
||||
@ -68,8 +70,8 @@ class PublicKey extends Key
|
||||
* Generates an uncompressed and compressed EC public key.
|
||||
*
|
||||
* @param \Bitpay\PrivateKey $privateKey
|
||||
*
|
||||
* @return Bitpay\PublicKey
|
||||
* @return \Bitpay\PublicKey
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function generate(PrivateKey $privateKey = null)
|
||||
{
|
||||
@ -111,6 +113,7 @@ class PublicKey extends Key
|
||||
|
||||
$this->x = $RxHex;
|
||||
$this->y = $RyHex;
|
||||
|
||||
$this->hex = sprintf('%s%s', $RxHex, $RyHex);
|
||||
$this->dec = Util::decodeHex($this->hex);
|
||||
|
||||
@ -139,6 +142,7 @@ class PublicKey extends Key
|
||||
|
||||
if (null === $this->sin) {
|
||||
$this->sin = new SinKey();
|
||||
|
||||
$this->sin->setPublicKey($this);
|
||||
$this->sin->generate();
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -11,15 +11,19 @@ use Bitpay\Util\Gmp;
|
||||
use Bitpay\Util\Util;
|
||||
|
||||
/**
|
||||
* @package Bitcore
|
||||
* @package BitPay
|
||||
*/
|
||||
class SinKey extends Key
|
||||
{
|
||||
// Type 2 (ephemeral)
|
||||
const SIN_TYPE = '02';
|
||||
/**
|
||||
* Type 2 (ephemeral)
|
||||
*/
|
||||
const SIN_TYPE = '02';
|
||||
|
||||
// Always the prefix!
|
||||
// (well, right now)
|
||||
/**
|
||||
* Always the prefix!
|
||||
* (well, right now)
|
||||
*/
|
||||
const SIN_VERSION = '0F';
|
||||
|
||||
/**
|
||||
@ -56,6 +60,7 @@ class SinKey extends Key
|
||||
* https://en.bitcoin.it/wiki/Identity_protocol_v1
|
||||
*
|
||||
* @return SinKey
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function generate()
|
||||
{
|
||||
@ -70,7 +75,6 @@ class SinKey extends Key
|
||||
}
|
||||
|
||||
$step1 = Util::sha256(Util::binConv($compressedValue), true);
|
||||
|
||||
$step2 = Util::ripe160($step1);
|
||||
|
||||
$step3 = sprintf(
|
||||
@ -81,10 +85,8 @@ class SinKey extends Key
|
||||
);
|
||||
|
||||
$step4 = Util::twoSha256(Util::binConv($step3), true);
|
||||
|
||||
$step5 = substr(bin2hex($step4), 0, 8);
|
||||
|
||||
$step6 = $step3.$step5;
|
||||
$step6 = $step3 . $step5;
|
||||
|
||||
$this->value = Base58::encode($step6);
|
||||
|
||||
|
||||
@ -1,12 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace Bitpay\Storage;
|
||||
|
||||
/**
|
||||
* @package Bitpay
|
||||
*/
|
||||
class EncryptedFilesystemStorage implements StorageInterface
|
||||
{
|
||||
@ -15,11 +16,6 @@ class EncryptedFilesystemStorage implements StorageInterface
|
||||
*/
|
||||
private $password;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $unencoded_password;
|
||||
|
||||
/**
|
||||
* Initialization Vector
|
||||
*/
|
||||
@ -40,10 +36,7 @@ class EncryptedFilesystemStorage implements StorageInterface
|
||||
*/
|
||||
public function __construct($password)
|
||||
{
|
||||
//to make this an non-breaking api change,
|
||||
//I will have to keep both versions of the password
|
||||
$this->password = base64_encode($password);
|
||||
$this->unencoded_password = $password;
|
||||
$this->password = $password;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -51,17 +44,13 @@ class EncryptedFilesystemStorage implements StorageInterface
|
||||
*/
|
||||
public function persist(\Bitpay\KeyInterface $key)
|
||||
{
|
||||
$path = $key->getId();
|
||||
$data = serialize($key);
|
||||
$encoded = bin2hex(openssl_encrypt(
|
||||
$data,
|
||||
self::METHOD,
|
||||
$this->password,
|
||||
1,
|
||||
self::IV
|
||||
));
|
||||
$path = $key->getId();
|
||||
$data = serialize($key);
|
||||
|
||||
file_put_contents($path, $encoded);
|
||||
$encrypted = $this->dataEncrypt($data);
|
||||
$encoded = $this->dataEncode($encrypted);
|
||||
|
||||
$this->saveToFile($encoded, $path);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -69,25 +58,120 @@ class EncryptedFilesystemStorage implements StorageInterface
|
||||
*/
|
||||
public function load($id)
|
||||
{
|
||||
if (!is_file($id)) {
|
||||
throw new \Exception(sprintf('Could not find "%s"', $id));
|
||||
$encoded = $this->readFromFile($id);
|
||||
$decoded = $this->dataDecode($encoded);
|
||||
$decrypted = $this->dataDecrypt($decoded);
|
||||
|
||||
return unserialize($decrypted);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $data
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function dataEncrypt($data)
|
||||
{
|
||||
$encrypted = openssl_encrypt($data, self::METHOD, $this->password, self::OPENSSL_RAW_DATA, self::IV);
|
||||
|
||||
if ($encrypted === false) {
|
||||
throw new \Exception('[ERROR] In EncryptedFilesystemStorage::dataEncrypt(): Could not encrypt data "' . $data . '". OpenSSL error(s) are: "' . $this->getOpenSslErrors() . '".');
|
||||
}
|
||||
|
||||
if (!is_readable($id)) {
|
||||
throw new \Exception(sprintf('"%s" cannot be read, check permissions', $id));
|
||||
return $encrypted;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $data
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function dataDecrypt($data)
|
||||
{
|
||||
$decrypted = openssl_decrypt($data, self::METHOD, $this->password, self::OPENSSL_RAW_DATA, self::IV);
|
||||
|
||||
if ($decrypted === false) {
|
||||
throw new \Exception('[ERROR] In EncryptedFilesystemStorage::dataDecrypt(): Could not decrypt data "' . $data . '". OpenSSL error(s) are: "' . $this->getOpenSslErrors() . '".');
|
||||
}
|
||||
|
||||
$encoded = file_get_contents($id);
|
||||
$decoded = openssl_decrypt(\Bitpay\Util\Util::binConv($encoded), self::METHOD, $this->password, 1, self::IV);
|
||||
return $decrypted;
|
||||
}
|
||||
|
||||
if (false === $decoded) {
|
||||
$decoded = openssl_decrypt(\Bitpay\Util\Util::binConv($encoded), self::METHOD, $this->unencoded_password, 1, self::IV);
|
||||
/**
|
||||
* @param string $data
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function dataEncode($data)
|
||||
{
|
||||
$encoded = base64_encode($data);
|
||||
|
||||
if ($encoded === false) {
|
||||
throw new \Exception('[ERROR] In EncryptedFilesystemStorage::dataEncode(): Could not encode data "' . $data . '".');
|
||||
}
|
||||
|
||||
if (false === $decoded) {
|
||||
throw new \Exception('Could not decode key');
|
||||
return $encoded;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $data
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function dataDecode($data)
|
||||
{
|
||||
$decoded = base64_decode($data, true);
|
||||
|
||||
if ($decoded === false) {
|
||||
throw new \Exception('[ERROR] In EncryptedFilesystemStorage::dataDecode(): Could not decode data "' . $data . '".');
|
||||
}
|
||||
|
||||
return unserialize($decoded);
|
||||
return $decoded;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $data
|
||||
* @param string $path
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function saveToFile($data, $path)
|
||||
{
|
||||
if (file_put_contents($path, $data) === false) {
|
||||
throw new \Exception('[ERROR] In EncryptedFilesystemStorage::saveToFile(): Could not write to the file "' . $path . '".');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function readFromFile($path)
|
||||
{
|
||||
if (is_file($path) === false || is_readable($path) === false) {
|
||||
throw new \Exception('[ERROR] In EncryptedFilesystemStorage::readFromFile(): The file "' . $path . '" does not exist or cannot be read, check permissions.');
|
||||
}
|
||||
|
||||
$data = file_get_contents($path);
|
||||
|
||||
if ($data === false) {
|
||||
throw new \Exception('[ERROR] In EncryptedFilesystemStorage::readFromFile(): The file "' . $path . '" cannot be read, check permissions.');
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getOpenSslErrors()
|
||||
{
|
||||
$openssl_error_msg = '';
|
||||
|
||||
while ($msg = openssl_error_string()) {
|
||||
$openssl_error_msg .= $msg . "\r\n";
|
||||
}
|
||||
|
||||
return $openssl_error_msg;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace Bitpay\Storage;
|
||||
|
||||
/**
|
||||
* Used to persist keys to the filesystem
|
||||
* Used to persist keys to the filesystem.
|
||||
*
|
||||
* @package Bitpay
|
||||
*/
|
||||
class FilesystemStorage implements StorageInterface
|
||||
{
|
||||
@ -16,8 +18,12 @@ class FilesystemStorage implements StorageInterface
|
||||
*/
|
||||
public function persist(\Bitpay\KeyInterface $key)
|
||||
{
|
||||
$path = $key->getId();
|
||||
file_put_contents($path, serialize($key));
|
||||
try {
|
||||
$path = $key->getId();
|
||||
file_put_contents($path, serialize($key));
|
||||
} catch (\Exception $e) {
|
||||
throw new \Exception('[ERROR] In FilesystemStorage::persist(): ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -26,11 +32,11 @@ class FilesystemStorage implements StorageInterface
|
||||
public function load($id)
|
||||
{
|
||||
if (!is_file($id)) {
|
||||
throw new \Exception(sprintf('Could not find "%s"', $id));
|
||||
throw new \Exception(sprintf('[ERROR] In FilesystemStorage::load(): Could not find "%s".', $id));
|
||||
}
|
||||
|
||||
if (!is_readable($id)) {
|
||||
throw new \Exception(sprintf('"%s" cannot be read, check permissions', $id));
|
||||
throw new \Exception(sprintf('[ERROR] In FilesystemStorage::load(): "%s" cannot be read, check permissions.', $id));
|
||||
}
|
||||
|
||||
return unserialize(file_get_contents($id));
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -8,14 +8,21 @@ namespace Bitpay\Storage;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* @package Bitcore
|
||||
* @package Bitpay
|
||||
*/
|
||||
class MockStorage implements StorageInterface
|
||||
{
|
||||
/**
|
||||
* @param Key $key
|
||||
*/
|
||||
public function persist(\Bitpay\KeyInterface $key)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
* @return void
|
||||
*/
|
||||
public function load($id)
|
||||
{
|
||||
return;
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace Bitpay\Storage;
|
||||
|
||||
/**
|
||||
* @package Bitcore
|
||||
* @package Bitpay
|
||||
*/
|
||||
interface StorageInterface
|
||||
{
|
||||
@ -18,7 +18,6 @@ interface StorageInterface
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
*
|
||||
* @return KeyInterface
|
||||
*/
|
||||
public function load($id);
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace Bitpay;
|
||||
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
/**
|
||||
* @package Bitpay
|
||||
*/
|
||||
@ -46,8 +48,6 @@ class Token implements TokenInterface
|
||||
*/
|
||||
protected $pairingExpiration;
|
||||
|
||||
/**
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->policies = array();
|
||||
@ -58,7 +58,7 @@ class Token implements TokenInterface
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return (string) $this->getToken();
|
||||
return (string)$this->getToken();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -69,6 +69,10 @@ class Token implements TokenInterface
|
||||
return $this->token;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string
|
||||
* @return Token
|
||||
*/
|
||||
public function setToken($token)
|
||||
{
|
||||
$this->token = $token;
|
||||
@ -84,6 +88,10 @@ class Token implements TokenInterface
|
||||
return $this->resource;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string
|
||||
* @return Token
|
||||
*/
|
||||
public function setResource($resource)
|
||||
{
|
||||
$this->resource = $resource;
|
||||
@ -99,6 +107,10 @@ class Token implements TokenInterface
|
||||
return $this->facade;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string
|
||||
* @return Token
|
||||
*/
|
||||
public function setFacade($facade)
|
||||
{
|
||||
$this->facade = $facade;
|
||||
@ -114,6 +126,10 @@ class Token implements TokenInterface
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime
|
||||
* @return Token
|
||||
*/
|
||||
public function setCreatedAt(\DateTime $createdAt)
|
||||
{
|
||||
$this->createdAt = $createdAt;
|
||||
@ -129,6 +145,10 @@ class Token implements TokenInterface
|
||||
return $this->policies;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string
|
||||
* @return Token
|
||||
*/
|
||||
public function setPolicies($policies)
|
||||
{
|
||||
$this->policies = $policies;
|
||||
@ -143,11 +163,15 @@ class Token implements TokenInterface
|
||||
{
|
||||
return $this->pairingCode;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string
|
||||
* @return Token
|
||||
*/
|
||||
public function setPairingCode($pairingCode)
|
||||
{
|
||||
$this->pairingCode = $pairingCode;
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -159,6 +183,10 @@ class Token implements TokenInterface
|
||||
return $this->pairingExpiration;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime
|
||||
* @return Token
|
||||
*/
|
||||
public function setPairingExpiration(\DateTime $pairingExpiration)
|
||||
{
|
||||
$this->pairingExpiration = $pairingExpiration;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -76,8 +76,7 @@ class User implements UserInterface
|
||||
|
||||
/**
|
||||
* @param string $phone
|
||||
*
|
||||
* @return UserInterface
|
||||
* @return User
|
||||
*/
|
||||
public function setPhone($phone)
|
||||
{
|
||||
@ -98,8 +97,7 @@ class User implements UserInterface
|
||||
|
||||
/**
|
||||
* @param string $email
|
||||
*
|
||||
* @return UserInterface
|
||||
* @return User
|
||||
*/
|
||||
public function setEmail($email)
|
||||
{
|
||||
@ -120,8 +118,7 @@ class User implements UserInterface
|
||||
|
||||
/**
|
||||
* @param string $firstName
|
||||
*
|
||||
* @return UserInterface
|
||||
* @return User
|
||||
*/
|
||||
public function setFirstName($firstName)
|
||||
{
|
||||
@ -142,8 +139,7 @@ class User implements UserInterface
|
||||
|
||||
/**
|
||||
* @param string $lastName
|
||||
*
|
||||
* @return UserInterface
|
||||
* @return User
|
||||
*/
|
||||
public function setLastName($lastName)
|
||||
{
|
||||
@ -164,8 +160,7 @@ class User implements UserInterface
|
||||
|
||||
/**
|
||||
* @param array $address
|
||||
*
|
||||
* @return UserInterface
|
||||
* @return User
|
||||
*/
|
||||
public function setAddress(array $address)
|
||||
{
|
||||
@ -186,8 +181,7 @@ class User implements UserInterface
|
||||
|
||||
/**
|
||||
* @param string $city
|
||||
*
|
||||
* @return UserInterface
|
||||
* @return User
|
||||
*/
|
||||
public function setCity($city)
|
||||
{
|
||||
@ -208,8 +202,7 @@ class User implements UserInterface
|
||||
|
||||
/**
|
||||
* @param string $state
|
||||
*
|
||||
* @return UserInterface
|
||||
* @return User
|
||||
*/
|
||||
public function setState($state)
|
||||
{
|
||||
@ -230,8 +223,7 @@ class User implements UserInterface
|
||||
|
||||
/**
|
||||
* @param string $zip
|
||||
*
|
||||
* @return UserInterface
|
||||
* @return User
|
||||
*/
|
||||
public function setZip($zip)
|
||||
{
|
||||
@ -252,8 +244,7 @@ class User implements UserInterface
|
||||
|
||||
/**
|
||||
* @param string $country
|
||||
*
|
||||
* @return UserInterface
|
||||
* @return User
|
||||
*/
|
||||
public function setCountry($country)
|
||||
{
|
||||
@ -266,7 +257,6 @@ class User implements UserInterface
|
||||
|
||||
/**
|
||||
* @param bool $boolvalue
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
public function setAgreedToTOSandPP($boolvalue)
|
||||
@ -277,6 +267,7 @@ class User implements UserInterface
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
@ -1,13 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace Bitpay;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Bitpay
|
||||
*/
|
||||
interface UserInterface
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -11,7 +11,7 @@ use Bitpay\Math\Math;
|
||||
/**
|
||||
* Utility class for encoding/decoding BASE-58 data
|
||||
*
|
||||
* @package Bitcore
|
||||
* @package Bitpay
|
||||
*/
|
||||
final class Base58
|
||||
{
|
||||
@ -21,17 +21,18 @@ final class Base58
|
||||
const BASE58_CHARS = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
||||
|
||||
/**
|
||||
* Encodes $data into BASE-58 format
|
||||
* Encodes a numeric string into BASE-58 format.
|
||||
*
|
||||
* @param string $data
|
||||
*
|
||||
* @return string
|
||||
* @return string $output_string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function encode($data)
|
||||
{
|
||||
$dataLen = strlen($data);
|
||||
|
||||
if ($dataLen % 2 != 0 || $dataLen == 0) {
|
||||
throw new \Exception('Invalid Length');
|
||||
throw new \Exception('Invalid length data string provided to Base58::encode() method.');
|
||||
}
|
||||
|
||||
$code_string = self::BASE58_CHARS;
|
||||
@ -39,8 +40,8 @@ final class Base58
|
||||
$output_string = '';
|
||||
|
||||
while (Math::cmp($x, '0') > 0) {
|
||||
$q = Math::div($x, 58);
|
||||
$r = Math::mod($x, 58);
|
||||
$q = Math::div($x, '58');
|
||||
$r = Math::mod($x, '58');
|
||||
$output_string .= substr($code_string, intval($r), 1);
|
||||
$x = $q;
|
||||
}
|
||||
@ -55,11 +56,10 @@ final class Base58
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes $data from BASE-58 format
|
||||
* Decodes a numeric string from BASE-58 format.
|
||||
*
|
||||
* @param string $data
|
||||
*
|
||||
* @return string
|
||||
* @return string $return
|
||||
*/
|
||||
public static function decode($data)
|
||||
{
|
||||
@ -74,11 +74,11 @@ final class Base58
|
||||
$return = Util::encodeHex($return);
|
||||
|
||||
for ($i = 0; $i < $dataLen && substr($data, $i, 1) == '1'; $i++) {
|
||||
$return = '00'.$return;
|
||||
$return = '00' . $return;
|
||||
}
|
||||
|
||||
if (strlen($return) % 2 != 0) {
|
||||
$return = '0'.$return;
|
||||
$return = '0' . $return;
|
||||
}
|
||||
|
||||
return $return;
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace Bitpay\Util;
|
||||
|
||||
/**
|
||||
*/
|
||||
interface CurveParameterInterface
|
||||
{
|
||||
public function aHex();
|
||||
|
||||
@ -1,11 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace Bitpay\Util;
|
||||
|
||||
/**
|
||||
* General error class.
|
||||
*
|
||||
* @package Bitpay
|
||||
*/
|
||||
class Error
|
||||
{
|
||||
/**
|
||||
@ -97,6 +102,7 @@ class Error
|
||||
if (empty($error_types)) {
|
||||
$error_types = E_ALL | E_STRICT;
|
||||
}
|
||||
|
||||
switch (strtolower($type)) {
|
||||
case 'error':
|
||||
switch (strtolower($action)) {
|
||||
|
||||
@ -1,13 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace Bitpay\Util;
|
||||
|
||||
/**
|
||||
* Utility class for generating an operating system & enivironment fingerprint
|
||||
* Utility class for generating an operating system & enivironment fingerprint.
|
||||
*
|
||||
* @package Bitpay
|
||||
*/
|
||||
class Fingerprint
|
||||
{
|
||||
@ -19,7 +21,6 @@ class Fingerprint
|
||||
* takes the hash of that value to use as the env
|
||||
* fingerprint.
|
||||
*
|
||||
* @param void
|
||||
* @return string
|
||||
*/
|
||||
final public static function generate()
|
||||
@ -47,11 +48,11 @@ class Fingerprint
|
||||
|
||||
self::$sigData[] = phpversion();
|
||||
self::$sigData[] = get_current_user();
|
||||
self::$sigData[] = php_uname('s').php_uname('n').php_uname('m').PHP_OS.PHP_SAPI.ICONV_IMPL.ICONV_VERSION;
|
||||
self::$sigData[] = php_uname('s') . php_uname('n') . php_uname('m') . PHP_OS . PHP_SAPI . ICONV_IMPL . ICONV_VERSION;
|
||||
self::$sigData[] = sha1_file(__FILE__);
|
||||
|
||||
self::$finHash = implode(self::$sigData);
|
||||
self::$finHash = sha1(str_ireplace(' ', '', self::$finHash).strlen(self::$finHash).metaphone(self::$finHash));
|
||||
self::$finHash = sha1(str_ireplace(' ', '', self::$finHash) . strlen(self::$finHash) . metaphone(self::$finHash));
|
||||
self::$finHash = sha1(self::$finHash);
|
||||
|
||||
return self::$finHash;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -12,8 +12,7 @@ namespace Bitpay\Util;
|
||||
* also:
|
||||
*
|
||||
* @see https://en.bitcoin.it/wiki/Secp256k1
|
||||
*
|
||||
* @package Bitcore
|
||||
* @package Bitpay
|
||||
*/
|
||||
class Secp256k1 implements CurveParameterInterface
|
||||
{
|
||||
|
||||
@ -1,13 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace Bitpay\Util;
|
||||
|
||||
/**
|
||||
* Generates secure random numbers
|
||||
* Generates cryptographically-secure random numbers using the OpenSSL extension.
|
||||
*
|
||||
* @package Bitpay
|
||||
*/
|
||||
class SecureRandom
|
||||
{
|
||||
@ -17,7 +19,12 @@ class SecureRandom
|
||||
protected static $hasOpenSSL;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* Generates 32 bytes of random data using the OpenSSL extension.
|
||||
*
|
||||
* @see http://php.net/manual/en/function.openssl-random-pseudo-bytes.php
|
||||
* @param integer $bytes
|
||||
* @return string $random
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function generateRandom($bytes = 32)
|
||||
{
|
||||
@ -35,6 +42,8 @@ class SecureRandom
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true/false if the OpenSSL extension is installed & enabled.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function hasOpenSSL()
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -13,7 +13,7 @@ use Bitpay\Math\Math;
|
||||
/**
|
||||
* Utility class used by string and arbitrary integer methods.
|
||||
*
|
||||
* @package Bitcore
|
||||
* @package Bitpay
|
||||
*/
|
||||
class Util
|
||||
{
|
||||
@ -25,11 +25,11 @@ class Util
|
||||
/**
|
||||
* Computes a digest hash value for the given data using
|
||||
* the given method, and returns a raw or binhex encoded
|
||||
* string, see:
|
||||
* http://us1.php.net/manual/en/function.openssl-digest.php
|
||||
* string. Uses the OpenSSL extension.
|
||||
*
|
||||
* @see http://us1.php.net/manual/en/function.openssl-digest.php
|
||||
* @param string $data
|
||||
*
|
||||
* @param boolean $binary
|
||||
* @return string
|
||||
*/
|
||||
public static function sha256($data, $binary = false)
|
||||
@ -40,11 +40,10 @@ class Util
|
||||
/**
|
||||
* Computes a digest hash value for the given data using
|
||||
* the given method, and returns a raw or binhex encoded
|
||||
* string, see:
|
||||
* http://us1.php.net/manual/en/function.openssl-digest.php
|
||||
* string. Uses the OpenSSL extension.
|
||||
*
|
||||
* @see http://us1.php.net/manual/en/function.openssl-digest.php
|
||||
* @param string $data
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function sha512($data)
|
||||
@ -54,11 +53,10 @@ class Util
|
||||
|
||||
/**
|
||||
* Generate a keyed hash value using the HMAC method.
|
||||
* http://us1.php.net/manual/en/function.hash-hmac.php
|
||||
*
|
||||
* @see http://us1.php.net/manual/en/function.hash-hmac.php
|
||||
* @param string $data
|
||||
* @param string $key
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function sha512hmac($data, $key)
|
||||
@ -67,10 +65,12 @@ class Util
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a RIPDEMD160 hash of a value.
|
||||
* Uses the OpenSSL extention to calculate the RIPDEMD160
|
||||
* hash of a value.
|
||||
*
|
||||
* @see http://php.net/manual/en/function.openssl-digest.php
|
||||
* @param string $data
|
||||
*
|
||||
* @param boolean $binary
|
||||
* @return string
|
||||
*/
|
||||
public static function ripe160($data, $binary = false)
|
||||
@ -82,7 +82,6 @@ class Util
|
||||
* Returns a SHA256 hash of a RIPEMD160 hash of a value.
|
||||
*
|
||||
* @param string $data
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function sha256ripe160($data)
|
||||
@ -94,7 +93,7 @@ class Util
|
||||
* Returns a double SHA256 hash of a value.
|
||||
*
|
||||
* @param string $data
|
||||
*
|
||||
* @param boolean $binary
|
||||
* @return string
|
||||
*/
|
||||
public static function twoSha256($data, $binary = false)
|
||||
@ -102,23 +101,10 @@ class Util
|
||||
return self::sha256(self::sha256($data, $binary), $binary);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a nonce for use in REST calls.
|
||||
*
|
||||
* @see http://en.wikipedia.org/wiki/Cryptographic_nonce
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function nonce()
|
||||
{
|
||||
return microtime(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a GUID for use in REST calls.
|
||||
*
|
||||
* @see http://en.wikipedia.org/wiki/Globally_unique_identifier
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function guid()
|
||||
@ -138,6 +124,7 @@ class Util
|
||||
*
|
||||
* @param string $dec
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function encodeHex($dec)
|
||||
{
|
||||
@ -151,12 +138,12 @@ class Util
|
||||
|
||||
$hex = '';
|
||||
|
||||
while (Math::cmp($dec, 0) > 0) {
|
||||
$q = Math::div($dec, 16);
|
||||
$rem = Math::mod($dec, 16);
|
||||
while (Math::cmp($dec, '0') > 0) {
|
||||
$q = Math::div($dec, '16');
|
||||
$rem = Math::mod($dec, '16');
|
||||
$dec = $q;
|
||||
|
||||
$hex = substr(self::HEX_CHARS, intval($rem), 1).$hex;
|
||||
$hex = substr(self::HEX_CHARS, intval($rem), 1) . $hex;
|
||||
}
|
||||
|
||||
return $hex;
|
||||
@ -167,6 +154,7 @@ class Util
|
||||
*
|
||||
* @param string $hex
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function decodeHex($hex)
|
||||
{
|
||||
@ -174,7 +162,7 @@ class Util
|
||||
throw new \Exception('Argument must be a string of hex digits.');
|
||||
}
|
||||
|
||||
$hex = strtolower($hex);
|
||||
$hex = strtolower(trim($hex));
|
||||
|
||||
// if it has a prefix of 0x this needs to be trimed
|
||||
if (substr($hex, 0, 2) == '0x') {
|
||||
@ -182,31 +170,40 @@ class Util
|
||||
}
|
||||
|
||||
$hexLen = strlen($hex);
|
||||
|
||||
for ($dec = '0', $i = 0; $i < $hexLen; $i++) {
|
||||
$current = strpos(self::HEX_CHARS, $hex[$i]);
|
||||
$dec = Math::add(Math::mul($dec, 16), $current);
|
||||
$dec = Math::add(Math::mul($dec, '16'), $current);
|
||||
}
|
||||
|
||||
return $dec;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates a new EC curve point.
|
||||
*
|
||||
* @param string $hex
|
||||
* @param PointInterface $point
|
||||
* @param CurveParameterInterface $parameters
|
||||
* @return Point
|
||||
*/
|
||||
public static function doubleAndAdd($hex, PointInterface $point, CurveParameterInterface $parameters = null)
|
||||
{
|
||||
if (null === $parameters) {
|
||||
$parameters = new Secp256k1();
|
||||
}
|
||||
$tmp = self::decToBin($hex);
|
||||
|
||||
$tmp = self::decToBin($hex);
|
||||
$n = strlen($tmp) - 1;
|
||||
$S = new Point(PointInterface::INFINITY, PointInterface::INFINITY);
|
||||
|
||||
|
||||
while ($n >= 0) {
|
||||
$S = self::pointDouble($S);
|
||||
|
||||
if ($tmp[$n] == 1) {
|
||||
$S = self::pointAdd($S, $point);
|
||||
}
|
||||
|
||||
$n--;
|
||||
}
|
||||
|
||||
@ -217,10 +214,9 @@ class Util
|
||||
* This method returns a binary string representation of
|
||||
* the decimal number. Used for the doubleAndAdd() method.
|
||||
*
|
||||
* @see http://php.net/manual/en/function.decbin.php but for large numbers
|
||||
*
|
||||
* @param string
|
||||
* @return string
|
||||
* @see http://php.net/manual/en/function.decbin.php (but for large numbers)
|
||||
* @param string $dec
|
||||
* @return string $bin
|
||||
*/
|
||||
public static function decToBin($dec)
|
||||
{
|
||||
@ -229,12 +225,14 @@ class Util
|
||||
}
|
||||
|
||||
$bin = '';
|
||||
|
||||
while (Math::cmp($dec, '0') > 0) {
|
||||
if (Math::mod($dec, 2) == '1') {
|
||||
if (Math::mod($dec, '2') == '1') {
|
||||
$bin .= '1';
|
||||
} else {
|
||||
$bin .= '0';
|
||||
}
|
||||
|
||||
$prevDec = $dec;
|
||||
$dec = Math::div($dec, 2);
|
||||
//sanity check to avoid infinite loop
|
||||
@ -252,9 +250,10 @@ class Util
|
||||
* xR = s2 - 2xP mod p
|
||||
* yR = -yP + s(xP - xR) mod p
|
||||
*
|
||||
* @param PointInterface $point
|
||||
* @param CurveParameterInterface
|
||||
* @param PointInterface $point
|
||||
* @param CurveParameterInterface $parameters
|
||||
* @return PointInterface
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function pointDouble(PointInterface $point, CurveParameterInterface $parameters = null)
|
||||
{
|
||||
@ -278,41 +277,38 @@ class Util
|
||||
// Critical math section
|
||||
try {
|
||||
$m = Math::add(Math::mul(3, Math::mul($point->getX(), $point->getX())), $a);
|
||||
$o = Math::mul(2, $point->getY());
|
||||
$o = Math::mul('2', $point->getY());
|
||||
$n = Math::invertm($o, $p);
|
||||
$n2 = Math::mod($o, $p);
|
||||
$st = Math::mul($m, $n);
|
||||
$st2 = Math::mul($m, $n2);
|
||||
$s = Math::mod($st, $p);
|
||||
$s2 = Math::mod($st2, $p);
|
||||
$xmul = Math::mul(2, $point->getX());
|
||||
$xmul = Math::mul('2', $point->getX());
|
||||
$smul = Math::mul($s, $s);
|
||||
$xsub = Math::sub($smul, $xmul);
|
||||
$xmod = Math::mod($xsub, $p);
|
||||
$R['x'] = $xmod;
|
||||
$ysub = Math::sub($point->getX(), $R['x']);
|
||||
$ymul = Math::mul($s, $ysub);
|
||||
$ysub2 = Math::sub(0, $point->getY());
|
||||
$ysub2 = Math::sub('0', $point->getY());
|
||||
$yadd = Math::add($ysub2, $ymul);
|
||||
|
||||
$R['y'] = Math::mod($yadd, $p);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
throw new \Exception('Error in Util::pointDouble(): '.$e->getMessage());
|
||||
throw new \Exception('Error in Util::pointDouble(): ' . $e->getMessage());
|
||||
}
|
||||
|
||||
return new Point($R['x'], $R['y']);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Point addition method P + Q = R where:
|
||||
* s = (yP - yQ)/(xP - xQ) mod p
|
||||
* xR = s2 - xP - xQ mod p
|
||||
* yR = -yP + s(xP - xR) mod p
|
||||
*
|
||||
* @param PointInterface
|
||||
* @param PointInterface
|
||||
*
|
||||
* @param PointInterface $P
|
||||
* @param PointInterface $Q
|
||||
* @return PointInterface
|
||||
*/
|
||||
public static function pointAdd(PointInterface $P, PointInterface $Q)
|
||||
@ -329,8 +325,9 @@ class Util
|
||||
return self::pointDouble(new Point($P->getX(), $P->getY()));
|
||||
}
|
||||
|
||||
$p = '0x'.Secp256k1::P;
|
||||
$a = '0x'.Secp256k1::A;
|
||||
$p = '0x' . Secp256k1::P;
|
||||
$a = '0x' . Secp256k1::A;
|
||||
|
||||
$s = 0;
|
||||
$R = array(
|
||||
'x' => 0,
|
||||
@ -356,10 +353,11 @@ class Util
|
||||
),
|
||||
$p
|
||||
);
|
||||
|
||||
$R['y'] = Math::mod(
|
||||
Math::add(
|
||||
Math::sub(
|
||||
0,
|
||||
'0',
|
||||
$P->getY()
|
||||
),
|
||||
Math::mul(
|
||||
@ -375,18 +373,17 @@ class Util
|
||||
|
||||
$R['s'] = $s;
|
||||
} catch (Exception $e) {
|
||||
throw new \Exception('Error in Util::pointAdd(): '.$e->getMessage());
|
||||
throw new \Exception('Error in Util::pointAdd(): ' . $e->getMessage());
|
||||
}
|
||||
|
||||
return new Point($R['x'], $R['y']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts hex value into octet (byte) string
|
||||
* Converts hex value into octet (byte) string.
|
||||
*
|
||||
* @param string
|
||||
*
|
||||
* @return string
|
||||
* @param string $hex
|
||||
* @return string $byte
|
||||
*/
|
||||
public static function binConv($hex)
|
||||
{
|
||||
@ -400,21 +397,21 @@ class Util
|
||||
}
|
||||
|
||||
if (substr(strtolower($hex), 0, 2) != '0x') {
|
||||
$hex = '0x'.strtolower($hex);
|
||||
$hex = '0x' . strtolower(trim($hex));
|
||||
}
|
||||
|
||||
while (Math::cmp($hex, 0) > 0) {
|
||||
$dv = Math::div($hex, 256);
|
||||
$rem = Math::mod($hex, 256);
|
||||
while (Math::cmp($hex, '0') > 0) {
|
||||
$dv = Math::div($hex, '256');
|
||||
$rem = Math::mod($hex, '256');
|
||||
$hex = $dv;
|
||||
$byte = $byte.$digits[$rem];
|
||||
$byte = $byte . $digits[$rem];
|
||||
}
|
||||
|
||||
return strrev($byte);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks dependencies for the library
|
||||
* Checks dependencies for the library.
|
||||
*
|
||||
* @return array list of each requirement, boolean true if met, string error message if not as value
|
||||
*/
|
||||
@ -427,6 +424,7 @@ class Util
|
||||
$version = explode('.', PHP_VERSION);
|
||||
define('PHP_VERSION_ID', ($version[0] * 10000 + $version[1] * 100 + $version[2]));
|
||||
}
|
||||
|
||||
if (PHP_VERSION_ID < 50400) {
|
||||
$requirements['PHP'] = 'Your PHP version, ' . PHP_VERSION . ', is too low. PHP version >= 5.4 is required.';
|
||||
} else {
|
||||
@ -452,8 +450,9 @@ class Util
|
||||
$requirements['cURL'] = 'The cURL PHP extension could not be found.';
|
||||
} else {
|
||||
$requirements['cURL'] = true;
|
||||
$curl_version = curl_version();
|
||||
$curl_version = curl_version();
|
||||
$ssl_supported = ($curl_version['features'] & CURL_VERSION_SSL);
|
||||
|
||||
if (!$ssl_supported) {
|
||||
$requirements['cURL.SSL'] = 'The cURL PHP extension does not have SSL support.';
|
||||
} else {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -13,9 +13,7 @@ class AccessTokenTest extends \PHPUnit_Framework_TestCase
|
||||
$token = new AccessToken();
|
||||
|
||||
$this->assertNotNull($token);
|
||||
|
||||
$token->setId('test');
|
||||
|
||||
$this->assertSame('test', $token->getId());
|
||||
}
|
||||
|
||||
@ -24,9 +22,7 @@ class AccessTokenTest extends \PHPUnit_Framework_TestCase
|
||||
$token = new AccessToken();
|
||||
|
||||
$this->assertNotNull($token);
|
||||
|
||||
$token->setEmail('support@bitpay.com');
|
||||
|
||||
$this->assertSame('support@bitpay.com', $token->getEmail());
|
||||
}
|
||||
|
||||
@ -35,40 +31,7 @@ class AccessTokenTest extends \PHPUnit_Framework_TestCase
|
||||
$token = new AccessToken();
|
||||
|
||||
$this->assertNotNull($token);
|
||||
|
||||
$token->setLabel('label');
|
||||
|
||||
$this->assertSame('label', $token->getLabel());
|
||||
}
|
||||
|
||||
public function testNonce()
|
||||
{
|
||||
$token = new AccessToken();
|
||||
|
||||
$this->assertNotNull($token);
|
||||
|
||||
$this->assertFalse($token->isNonceDisabled());
|
||||
}
|
||||
|
||||
public function testNonceDisable()
|
||||
{
|
||||
$token = new AccessToken();
|
||||
|
||||
$this->assertNotNull($token);
|
||||
|
||||
$this->assertFalse($token->isNonceDisabled());
|
||||
$token->nonceDisable();
|
||||
$this->assertTrue($token->isNonceDisabled());
|
||||
}
|
||||
|
||||
public function testNonceEnable()
|
||||
{
|
||||
$token = new AccessToken();
|
||||
|
||||
$this->assertNotNull($token);
|
||||
|
||||
$this->assertFalse($token->isNonceDisabled());
|
||||
$token->nonceEnable();
|
||||
$this->assertFalse($token->isNonceDisabled());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -13,7 +13,6 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
|
||||
$application = new Application();
|
||||
|
||||
$this->assertNotNull($application);
|
||||
|
||||
$this->assertInternalType('array', $application->getUsers());
|
||||
$this->assertEmpty($application->getUsers());
|
||||
}
|
||||
@ -26,7 +25,6 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
|
||||
$application = new Application();
|
||||
|
||||
$this->assertNotNull($application);
|
||||
|
||||
$application->addUser($this->getMockUser());
|
||||
|
||||
$this->assertInternalType('array', $application->getUsers());
|
||||
@ -38,7 +36,6 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
|
||||
$application = new Application();
|
||||
|
||||
$this->assertNotNull($application);
|
||||
|
||||
$this->assertInternalType('array', $application->getOrgs());
|
||||
$this->assertEmpty($application->getOrgs());
|
||||
}
|
||||
@ -51,7 +48,6 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
|
||||
$application = new Application();
|
||||
|
||||
$this->assertNotNull($application);
|
||||
|
||||
$application->addOrg($this->getMockOrg());
|
||||
|
||||
$this->assertInternalType('array', $application->getOrgs());
|
||||
@ -60,11 +56,11 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
private function getMockUser()
|
||||
{
|
||||
return $this->getMock('Bitpay\UserInterface');
|
||||
return $this->getMock('Bitpay\User');
|
||||
}
|
||||
|
||||
private function getMockOrg()
|
||||
{
|
||||
return $this->getMock('Bitpay\OrgInterface');
|
||||
return $this->getMock('Bitpay\Org');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,66 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace Bitpay;
|
||||
|
||||
class AutoloaderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
protected function teardown()
|
||||
{
|
||||
Autoloader::unregister();
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure that our autoloader is first in the queue
|
||||
*/
|
||||
public function testRegister()
|
||||
{
|
||||
Autoloader::register();
|
||||
$functions = spl_autoload_functions();
|
||||
$this->assertSame(array('Bitpay\Autoloader','autoload'), $functions[0]);
|
||||
}
|
||||
|
||||
public function testUnregister()
|
||||
{
|
||||
Autoloader::register();
|
||||
$numOfAutoloaders = count(spl_autoload_functions());
|
||||
Autoloader::unregister();
|
||||
$this->assertCount($numOfAutoloaders - 1, spl_autoload_functions());
|
||||
}
|
||||
|
||||
public function testAutoload()
|
||||
{
|
||||
Autoloader::register();
|
||||
|
||||
Autoloader::autoload('Bitpay\Bitpay');
|
||||
// Is only required once
|
||||
Autoloader::autoload('Bitpay\Bitpay');
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function testNoClass()
|
||||
{
|
||||
Autoloader::autoload('Foo\Bar');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
*/
|
||||
public function testException()
|
||||
{
|
||||
Autoloader::autoload('Bitpay\ClassThatWillNeverBeCreated');
|
||||
}
|
||||
|
||||
public function testNoExceptionForBitpayClasslike()
|
||||
{
|
||||
Autoloader::register();
|
||||
|
||||
// Magento Classes
|
||||
Autoloader::autoload('Bitpay_Core_Model');
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -35,7 +35,7 @@ class BillTest extends \PHPUnit_Framework_TestCase
|
||||
public function testGetCurrency()
|
||||
{
|
||||
$this->assertNotNull($this->bill);
|
||||
$this->assertInstanceOf('Bitpay\CurrencyInterface', $this->bill->getCurrency());
|
||||
$this->assertInstanceOf('Bitpay\Currency', $this->bill->getCurrency());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -45,7 +45,7 @@ class BillTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->assertNotNull($this->bill);
|
||||
$this->bill->setCurrency($this->getMockCurrency());
|
||||
$this->assertInstanceOf('Bitpay\CurrencyInterface', $this->bill->getCurrency());
|
||||
$this->assertInstanceOf('Bitpay\Currency', $this->bill->getCurrency());
|
||||
}
|
||||
|
||||
public function testGetName()
|
||||
@ -162,8 +162,8 @@ class BillTest extends \PHPUnit_Framework_TestCase
|
||||
public function testSetEmail()
|
||||
{
|
||||
$this->assertNotNull($this->bill);
|
||||
$this->bill->setEmail('support@bitpay.com');
|
||||
$this->assertSame('support@bitpay.com', $this->bill->getEmail());
|
||||
$this->bill->setEmail('integrations@bitpay.com');
|
||||
$this->assertSame('integrations@bitpay.com', $this->bill->getEmail());
|
||||
}
|
||||
|
||||
public function testGetPhone()
|
||||
@ -232,11 +232,11 @@ class BillTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
private function getMockItem()
|
||||
{
|
||||
return $this->getMock('Bitpay\ItemInterface');
|
||||
return $this->getMock('Bitpay\Item');
|
||||
}
|
||||
|
||||
private function getMockCurrency()
|
||||
{
|
||||
return $this->getMock('Bitpay\CurrencyInterface');
|
||||
return $this->getMock('Bitpay\Currency');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -10,6 +10,16 @@ use org\bovigo\vfs\vfsStream;
|
||||
|
||||
class BitpayTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $temp_path_pri;
|
||||
private $temp_path_pub;
|
||||
private $temp_path_root;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->temp_path_root = 'tmp';
|
||||
$this->temp_path_pri = $this->temp_path_root . '/key.pri';
|
||||
$this->temp_path_pub = $this->temp_path_root . '/key.pub';
|
||||
}
|
||||
|
||||
public function testConstruct()
|
||||
{
|
||||
@ -23,7 +33,7 @@ class BitpayTest extends \PHPUnit_Framework_TestCase
|
||||
public function testGetContainer()
|
||||
{
|
||||
$bitpay = new \Bitpay\Bitpay();
|
||||
$this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerInterface', $bitpay->getContainer());
|
||||
$this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $bitpay->getContainer());
|
||||
}
|
||||
|
||||
public function testGet()
|
||||
@ -43,19 +53,20 @@ class BitpayTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testConfigAbleToPersistAndLoadKeys()
|
||||
{
|
||||
$root = vfsStream::setup('tmp');
|
||||
$root = vfsStream::setup($this->temp_path_root);
|
||||
$bitpay = new \Bitpay\Bitpay(
|
||||
array(
|
||||
'bitpay' => array(
|
||||
'private_key' => vfsStream::url('tmp/key.pri'),
|
||||
'public_key' => vfsStream::url('tmp/key.pub'),
|
||||
'private_key' => vfsStream::url($this->temp_path_pri),
|
||||
'public_key' => vfsStream::url($this->temp_path_pub),
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$pri = new \Bitpay\PrivateKey(vfsStream::url('tmp/key.pri'));
|
||||
$pri = new \Bitpay\PrivateKey(vfsStream::url($this->temp_path_pri));
|
||||
$pri->generate();
|
||||
$pub = new \Bitpay\PublicKey(vfsStream::url('tmp/key.pub'));
|
||||
|
||||
$pub = new \Bitpay\PublicKey(vfsStream::url($this->temp_path_pub));
|
||||
$pub->setPrivateKey($pri)->generate();
|
||||
|
||||
/**
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -43,8 +43,8 @@ class BuyerTest extends \PHPUnit_Framework_TestCase
|
||||
public function testSetEmail()
|
||||
{
|
||||
$this->assertNotNull($this->user);
|
||||
$this->user->setEmail('support@bitpay.com');
|
||||
$this->assertSame('support@bitpay.com', $this->user->getEmail());
|
||||
$this->user->setEmail('integrations@bitpay.com');
|
||||
$this->assertSame('integrations@bitpay.com', $this->user->getEmail());
|
||||
}
|
||||
|
||||
public function testGetFirstName()
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -56,5 +56,4 @@ class CurlAdapterTest extends \PHPUnit_Framework_TestCase
|
||||
$response = $adapter->sendRequest($this->request);
|
||||
$this->assertNotNull($response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -31,7 +31,8 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
||||
$this->client->setAdapter($adapter);
|
||||
}
|
||||
|
||||
public function testCheckPriceAndCurrency() {
|
||||
public function testCheckPriceAndCurrency()
|
||||
{
|
||||
$client = new ChildOfClient();
|
||||
$res = $client->checkPriceAndCurrency(.999999, 'BTC');
|
||||
$this->assertNull($res);
|
||||
@ -97,7 +98,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
||||
->setEffectiveDate("1415853007000")
|
||||
->setPricingMethod('bitcoinbestbuy')
|
||||
->setNotificationUrl('https://bitpay.com')
|
||||
->setNotificationEmail('support@bitpay.com')
|
||||
->setNotificationEmail('integrations@bitpay.com')
|
||||
->setPricingMethod('bitcoinbestbuy')
|
||||
->setReference('your reference, can be json')
|
||||
->setAmount(5625)
|
||||
@ -107,6 +108,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
||||
\Bitpay\PayoutInstruction::STATUS_UNPAID => null,
|
||||
\Bitpay\PayoutInstruction::STATUS_PAID => '0'
|
||||
);
|
||||
|
||||
$instruction0 = new \Bitpay\PayoutInstruction();
|
||||
$instruction0
|
||||
->setId('Sra19AFU57Rx53rKQbbRKZ')
|
||||
@ -158,7 +160,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('your reference, can be json', $payout->getReference());
|
||||
$this->assertEquals('1415853007000', $payout->getEffectiveDate());
|
||||
$this->assertEquals('https://bitpay.com', $payout->getNotificationUrl());
|
||||
$this->assertEquals('support@bitpay.com', $payout->getNotificationEmail());
|
||||
$this->assertEquals('integrations@bitpay.com', $payout->getNotificationEmail());
|
||||
$this->assertEquals('8mZ37Gt91Wr7GXGPnB9zj1zwTcLGweRDka4axVBPi9Uxiiv7zZWvEKSgmFddQZA1Jy', $payout->getResponseToken());
|
||||
$instructions = $payout->getInstructions();
|
||||
$this->assertSame($instruction0, $instructions[0]);
|
||||
@ -195,15 +197,24 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('abcdefghijkmnopqrstuvw', $invoice->getId());
|
||||
$this->assertEquals('https://test.bitpay.com/invoice?id=abcdefghijkmnopqrstuvw', $invoice->getUrl());
|
||||
$this->assertEquals('new', $invoice->getStatus());
|
||||
//$this->assertEquals('0.0632', $invoice->getBtcPrice());
|
||||
$this->assertEquals('0.0632', $invoice->getBtcPrice());
|
||||
$this->assertEquals(19.95, $invoice->getPrice());
|
||||
$this->assertEquals(1412594514, $invoice->getInvoiceTime()->getTimestamp());
|
||||
$this->assertEquals(1412595414, $invoice->getExpirationTime()->getTimestamp());
|
||||
$this->assertEquals(1412594514, $invoice->getCurrentTime()->getTimestamp());
|
||||
$this->assertInstanceOf('DateTime', $invoice->getInvoiceTime());
|
||||
$this->assertInstanceOf('DateTime', $invoice->getExpirationTime());
|
||||
$this->assertInstanceOf('DateTime', $invoice->getCurrentTime());
|
||||
//$this->assertEquals('0.0000', $invoice->getBtcPaid());
|
||||
$this->assertEquals('0.0000', $invoice->getBtcPaid());
|
||||
$this->assertEquals(315.7, $invoice->getRate());
|
||||
$this->assertEquals(false, $invoice->getExceptionStatus());
|
||||
$this->assertEquals('abcdefghijklmno', $invoice->getToken()->getToken());
|
||||
$this->assertEquals('bitcoin:mabcdefghijkmnopqrstuvw123456789AB?amount=0.0632', $invoice->getPaymentUrl(\BitPay\PaymentUrlSet::BIP_21));
|
||||
//assert that invoice, expiration and currenttime are in the past
|
||||
//meaning we didn't try to create date objects from unix timestamps including milliseconds
|
||||
$this->assertLessThan(time(), $invoice->getInvoiceTime()->getTimestamp());
|
||||
$this->assertLessThan(time(), $invoice->getExpirationTime()->getTimestamp());
|
||||
$this->assertLessThan(time(), $invoice->getCurrentTime()->getTimestamp());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -331,7 +342,6 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
||||
$payouts = $this->client->getPayouts();
|
||||
$this->assertInternalType('array', $payouts);
|
||||
$this->assertInstanceOf('Bitpay\PayoutInterface', $payouts[0]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -347,7 +357,6 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
||||
$this->client->setAdapter($adapter);
|
||||
|
||||
$payouts = $this->client->getPayouts();
|
||||
|
||||
}
|
||||
|
||||
public function testGetTokens()
|
||||
@ -503,7 +512,6 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$payout = $this->client->getPayout('7m7hSF3ws1LhnWUf17CXsJ');
|
||||
|
||||
|
||||
// Test deletePayout
|
||||
$response = $this->getMockResponse();
|
||||
$response->method('getBody')->willReturn(file_get_contents(__DIR__ . '/../../DataFixtures/payouts/cancelled.json'));
|
||||
@ -513,7 +521,6 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
||||
$this->client->setAdapter($adapter);
|
||||
|
||||
$payout = $this->client->deletePayout($payout);
|
||||
|
||||
$this->assertSame($payout->getStatus(), \Bitpay\Payout::STATUS_CANCELLED);
|
||||
}
|
||||
|
||||
@ -533,7 +540,6 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
||||
$payout = $this->client->getPayout('7m7hSF3ws1LhnWUf17CXsJ');
|
||||
|
||||
// Test with exception
|
||||
|
||||
$response = $this->getMockResponse();
|
||||
$response->method('getBody')->willReturn('{"error":"Object not found"}');
|
||||
|
||||
@ -545,7 +551,6 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame($payout->getStatus(), \Bitpay\Payout::STATUS_CANCELLED);
|
||||
}
|
||||
|
||||
|
||||
private function getMockInvoice()
|
||||
{
|
||||
$invoice = $this->getMockBuilder('Bitpay\InvoiceInterface')
|
||||
@ -557,10 +562,10 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
||||
'getExpirationTime', 'getCurrentTime', 'getOrderId', 'getItemDesc', 'getItemCode',
|
||||
'isPhysical', 'getBuyerName', 'getBuyerAddress1', 'getBuyerAddress2', 'getBuyerCity',
|
||||
'getBuyerState', 'getBuyerZip', 'getBuyerCountry', 'getBuyerEmail', 'getBuyerPhone',
|
||||
'getExceptionStatus', 'getBtcPaid', 'getRate', 'getToken', 'getRefundAddresses',
|
||||
'setId', 'setUrl', 'setStatus', 'setBtcPrice', 'setPrice', 'setInvoiceTime', 'setExpirationTime',
|
||||
'setCurrentTime', 'setBtcPaid', 'setRate', 'setToken', 'setExceptionStatus', 'isExtendedNotifications',
|
||||
'setPosData',
|
||||
'getExceptionStatus', 'getBtcPaid', 'getRate', 'getToken', 'setId', 'setUrl',
|
||||
'setStatus', 'setBtcPrice', 'setPrice', 'setInvoiceTime', 'setExpirationTime',
|
||||
'setCurrentTime', 'setBtcPaid', 'setRate', 'setToken', 'setExceptionStatus', 'getRefundAddresses',
|
||||
'getPaymentUrls', 'isExtendedNotifications', 'setPosData'
|
||||
)
|
||||
)
|
||||
->getMock();
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -36,7 +36,7 @@ class CurrencyTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testSetCodeWithExceptionThrown()
|
||||
{
|
||||
new Currency('Dodge Coin');
|
||||
new Currency('Foo Coin');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -157,8 +157,8 @@ class CurrencyTest extends \PHPUnit_Framework_TestCase
|
||||
public function testSetAlts()
|
||||
{
|
||||
$this->assertNotNull($this->currency);
|
||||
$this->currency->setAlts('usd bucks');
|
||||
$this->assertSame('usd bucks', $this->currency->getAlts());
|
||||
$this->currency->setAlts('USD Bucks');
|
||||
$this->assertSame('USD Bucks', $this->currency->getAlts());
|
||||
}
|
||||
|
||||
public function testGetPayoutFields()
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -18,7 +18,7 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase
|
||||
public function testGetPrice()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
$this->assertNull($this->invoice->getPrice());
|
||||
$this->assertSame($this->invoice->getPrice(), 0.0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -34,7 +34,7 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase
|
||||
public function testGetCurrency()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
$this->assertNull($this->invoice->getCurrency());
|
||||
$this->assertInstanceOf('Bitpay\Currency', $this->invoice->getCurrency());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -94,14 +94,14 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase
|
||||
public function testSetTransactionSpeed()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
$this->invoice->setTransactionSpeed(Invoice::TRANSACTION_SPEED_MEDIUM);
|
||||
$this->assertSame(Invoice::TRANSACTION_SPEED_MEDIUM, $this->invoice->getTransactionSpeed());
|
||||
$this->invoice->setTransactionSpeed(Invoice::TRANSACTION_SPEED_LOW);
|
||||
$this->assertSame(Invoice::TRANSACTION_SPEED_LOW, $this->invoice->getTransactionSpeed());
|
||||
}
|
||||
|
||||
public function testGetNotificationEmail()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
$this->assertNull($this->invoice->getNotificationEmail());
|
||||
$this->assertSame($this->invoice->getNotificationEmail(), '');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -110,14 +110,14 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase
|
||||
public function testSetNotificationEmail()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
$this->invoice->setNotificationEmail('support@bitpay.com');
|
||||
$this->assertSame('support@bitpay.com', $this->invoice->getNotificationEmail());
|
||||
$this->invoice->setNotificationEmail('integrations@bitpay.com');
|
||||
$this->assertSame('integrations@bitpay.com', $this->invoice->getNotificationEmail());
|
||||
}
|
||||
|
||||
public function testGetNotificationUrl()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
$this->assertNull($this->invoice->getNotificationUrl());
|
||||
$this->assertSame($this->invoice->getNotificationUrl(), '');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -133,7 +133,7 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase
|
||||
public function testGetRedirectUrl()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
$this->assertNull($this->invoice->getRedirectUrl());
|
||||
$this->assertSame($this->invoice->getRedirectUrl(), '');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -149,7 +149,7 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase
|
||||
public function testGetPosData()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
$this->assertNull($this->invoice->getPosData());
|
||||
$this->assertSame($this->invoice->getPosData(), '');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -165,7 +165,7 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase
|
||||
public function testGetStatus()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
$this->assertNull($this->invoice->getStatus());
|
||||
$this->assertSame($this->invoice->getStatus(), '');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -187,7 +187,7 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase
|
||||
public function testGetId()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
$this->assertNull($this->invoice->getId());
|
||||
$this->assertSame($this->invoice->getId(), '');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -203,7 +203,7 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase
|
||||
public function testGetUrl()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
$this->assertNull($this->invoice->getUrl());
|
||||
$this->assertSame($this->invoice->getUrl(), '');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -219,7 +219,7 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase
|
||||
public function testGetBtcPrice()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
$this->assertNull($this->invoice->getBtcPrice());
|
||||
$this->assertSame($this->invoice->getBtcPrice(), 0.0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -294,7 +294,7 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase
|
||||
public function testGetOrderId()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
$this->assertNull($this->invoice->getOrderId());
|
||||
$this->assertSame($this->invoice->getOrderId(), '');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -313,26 +313,12 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertNull($this->invoice->getItemDesc());
|
||||
}
|
||||
|
||||
public function testSetItemDesc()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
|
||||
// TODO: add a test for setting the item description...
|
||||
}
|
||||
|
||||
public function testGetItemCode()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
$this->assertNull($this->invoice->getItemCode());
|
||||
}
|
||||
|
||||
public function testSetItemCode()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
|
||||
// TODO: add a test for setting the item code...
|
||||
}
|
||||
|
||||
public function testIsPhysical()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
@ -345,121 +331,58 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEmpty($this->invoice->getBuyerName());
|
||||
}
|
||||
|
||||
public function testSetBuyerName()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
|
||||
// TODO: add a test for setting the buyer name...
|
||||
}
|
||||
|
||||
public function testGetBuyerAddress1()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
$this->assertNull($this->invoice->getBuyerAddress1());
|
||||
}
|
||||
|
||||
public function testSetBuyerAddress1()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
|
||||
// TODO: add a test for setting the buyer address1...
|
||||
}
|
||||
|
||||
public function testGetBuyerAddress2()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
$this->assertNull($this->invoice->getBuyerAddress2());
|
||||
}
|
||||
|
||||
public function testSetBuyerAddress2()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
|
||||
// TODO: add a test for setting the buyer address2...
|
||||
}
|
||||
|
||||
public function testGetBuyerCity()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
$this->assertNull($this->invoice->getBuyerCity());
|
||||
}
|
||||
|
||||
public function testSetBuyerCity()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
|
||||
// TODO: add a test for setting the buyer city...
|
||||
}
|
||||
|
||||
public function testGetBuyerState()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
$this->assertNull($this->invoice->getBuyerState());
|
||||
}
|
||||
|
||||
public function testSetBuyerState()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
|
||||
// TODO: add a test for setting the buyer state...
|
||||
}
|
||||
|
||||
public function testGetBuyerZip()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
$this->assertNull($this->invoice->getBuyerZip());
|
||||
}
|
||||
|
||||
public function testSetBuyerZip()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
|
||||
// TODO: add a test for setting the buyer zip...
|
||||
}
|
||||
|
||||
public function testGetBuyerCountry()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
$this->assertNull($this->invoice->getBuyerCountry());
|
||||
}
|
||||
|
||||
public function testSetBuyerCountry()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
|
||||
// TODO: add a test for setting the buyer country...
|
||||
}
|
||||
|
||||
public function testGetBuyerEmail()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
$this->assertNull($this->invoice->getBuyerEmail());
|
||||
}
|
||||
|
||||
public function testSetBuyerEmail()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
|
||||
// TODO: add a test for setting the buyer email...
|
||||
}
|
||||
|
||||
public function testGetBuyerPhone()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
$this->assertNull($this->invoice->getBuyerPhone());
|
||||
}
|
||||
|
||||
public function testSetBuyerPhone()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
|
||||
// TODO: add a test for setting the buyer phone...
|
||||
}
|
||||
|
||||
public function testGetExceptionStatus()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
$this->assertNull($this->invoice->getExceptionStatus());
|
||||
$this->assertSame($this->invoice->getExceptionStatus(), '');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -475,7 +398,7 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase
|
||||
public function testGetBtcPaid()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
$this->assertNull($this->invoice->getBtcPaid());
|
||||
$this->assertSame($this->invoice->getBtcPaid(), 0.0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -491,7 +414,7 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase
|
||||
public function testGetRate()
|
||||
{
|
||||
$this->assertNotNull($this->invoice);
|
||||
$this->assertNull($this->invoice->getRate());
|
||||
$this->assertSame($this->invoice->getRate(), 0.0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -59,6 +59,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase
|
||||
public function testSetPrice()
|
||||
{
|
||||
setlocale(LC_NUMERIC, 'en_US');
|
||||
|
||||
// Accepts floats
|
||||
$this->item->setPrice(9.99);
|
||||
$this->assertSame(9.99, $this->item->getPrice());
|
||||
@ -138,7 +139,6 @@ class ItemTest extends \PHPUnit_Framework_TestCase
|
||||
setlocale(LC_NUMERIC, 'en_US');
|
||||
}
|
||||
|
||||
|
||||
public function testGetQuantity()
|
||||
{
|
||||
$this->assertNotNull($this->item);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -8,6 +8,13 @@ namespace Bitpay;
|
||||
|
||||
class KeyManagerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $temp_path;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->temp_path = '/tmp/mock.key';
|
||||
}
|
||||
|
||||
public function testConstruct()
|
||||
{
|
||||
$storage = $this->getMockStorage();
|
||||
@ -41,13 +48,12 @@ class KeyManagerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$manager = new KeyManager($storage);
|
||||
$this->assertNotNull($manager);
|
||||
|
||||
$manager->load($this->getMockKey());
|
||||
}
|
||||
|
||||
private function getMockKey()
|
||||
{
|
||||
return new \Bitpay\PublicKey('/tmp/mock.key');
|
||||
return new \Bitpay\PublicKey($this->temp_path);
|
||||
}
|
||||
|
||||
private function getMockStorage()
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -9,15 +9,13 @@ namespace Bitpay\Math;
|
||||
class BcEngineTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @requires extension gmp
|
||||
* @requires extension bcmath
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
if (!extension_loaded('bcmath'))
|
||||
{
|
||||
$this->markTestSkipped('The Bcmath extension is NOT loaded! You must enable it to run this test');
|
||||
}
|
||||
if (!extension_loaded('bcmath')) {
|
||||
$this->markTestSkipped('The Bcmath extension is NOT loaded! You must enable it to run this test');
|
||||
}
|
||||
}
|
||||
|
||||
public function testConstruct()
|
||||
@ -78,7 +76,6 @@ class BcEngineTest extends \PHPUnit_Framework_TestCase
|
||||
$b = '1234123412341234123412341234123412412341234213412421341342342';
|
||||
$c = '0x1234123412341234123412341234123412412341234213412421341342342';
|
||||
|
||||
|
||||
$this->assertEquals(0, $math->invertm($a, $a));
|
||||
$this->assertEquals(0, $math->invertm($b, $b));
|
||||
$this->assertEquals(0, $math->invertm($c, $c));
|
||||
@ -179,7 +176,8 @@ class BcEngineTest extends \PHPUnit_Framework_TestCase
|
||||
);
|
||||
|
||||
$math = new BcEngine();
|
||||
for($i = 0, $size = count($inputs); $i < $size; $i++) {
|
||||
|
||||
for ($i = 0, $size = count($inputs); $i < $size; $i++) {
|
||||
$this->assertEquals($outputs[$i], $math->input($inputs[$i]));
|
||||
}
|
||||
}
|
||||
@ -219,5 +217,4 @@ class BcEngineTest extends \PHPUnit_Framework_TestCase
|
||||
$math = new BcEngine();
|
||||
$this->assertTrue($math->coprime($a, $b));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -8,119 +8,96 @@ namespace Bitpay\Math;
|
||||
|
||||
class GmpEngineTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $a;
|
||||
private $b;
|
||||
private $c;
|
||||
private $math;
|
||||
|
||||
/**
|
||||
* @requires extension gmp
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
if (!extension_loaded('gmp'))
|
||||
{
|
||||
$this->markTestSkipped('The GMP extension is NOT loaded! You must enable it to run this test');
|
||||
}
|
||||
$this->a = 1234;
|
||||
$this->b = '1234123412341234123412341234123412412341234213412421341342342';
|
||||
$this->c = '0x1234123412341234123412341234123412412341234213412421341342342';
|
||||
|
||||
if (!extension_loaded('gmp')) {
|
||||
$this->markTestSkipped('The GMP extension is NOT loaded! You must enable it to run this test');
|
||||
} else {
|
||||
$this->math = new GmpEngine();
|
||||
}
|
||||
}
|
||||
|
||||
public function testadd()
|
||||
public function testAdd()
|
||||
{
|
||||
$a = 1234;
|
||||
$b = '1234123412341234123412341234123412412341234213412421341342342';
|
||||
$c = '0x1234123412341234123412341234123412412341234213412421341342342';
|
||||
|
||||
$math = new GmpEngine();
|
||||
$this->assertEquals(gmp_strval(gmp_add($a, $a)), $math->add($a, $a));
|
||||
$this->assertEquals(gmp_strval(gmp_add($b, $b)), $math->add($b, $b));
|
||||
$this->assertEquals(gmp_strval(gmp_add($c, $c)), $math->add($c, $c));
|
||||
$this->assertEquals(2, $math->add(1, 1));
|
||||
$this->assertEquals(gmp_strval(gmp_add($this->a, $this->a)), $this->math->add($this->a, $this->a));
|
||||
$this->assertEquals(gmp_strval(gmp_add($this->b, $this->b)), $this->math->add($this->b, $this->b));
|
||||
$this->assertEquals(gmp_strval(gmp_add($this->c, $this->c)), $this->math->add($this->c, $this->c));
|
||||
$this->assertEquals(2, $this->math->add(1, 1));
|
||||
}
|
||||
|
||||
public function testcmp()
|
||||
public function testCmp()
|
||||
{
|
||||
$a = 1234;
|
||||
$b = '1234123412341234123412341234123412412341234213412421341342342';
|
||||
$c = '0x1234123412341234123412341234123412412341234213412421341342342';
|
||||
$math = new GmpEngine();
|
||||
$this->assertEquals(gmp_strval(gmp_cmp($a, $a)), $math->cmp($a, $a));
|
||||
$this->assertEquals(gmp_strval(gmp_cmp($b, $b)), $math->cmp($b, $b));
|
||||
$this->assertEquals(gmp_strval(gmp_cmp($c, $c)), $math->cmp($c, $c));
|
||||
$this->assertEquals(0, $math->cmp(1, 1));
|
||||
$this->assertEquals(gmp_strval(gmp_cmp($this->a, $this->a)), $this->math->cmp($this->a, $this->a));
|
||||
$this->assertEquals(gmp_strval(gmp_cmp($this->b, $this->b)), $this->math->cmp($this->b, $this->b));
|
||||
$this->assertEquals(gmp_strval(gmp_cmp($this->c, $this->c)), $this->math->cmp($this->c, $this->c));
|
||||
$this->assertEquals(0, $this->math->cmp(1, 1));
|
||||
}
|
||||
|
||||
public function testdiv()
|
||||
public function testDiv()
|
||||
{
|
||||
$a = 1234;
|
||||
$b = '1234123412341234123412341234123412412341234213412421341342342';
|
||||
$c = '0x1234123412341234123412341234123412412341234213412421341342342';
|
||||
$math = new GmpEngine();
|
||||
$this->assertEquals(gmp_strval(gmp_div($a, $a)), $math->div($a, $a));
|
||||
$this->assertEquals(gmp_strval(gmp_div($b, $b)), $math->div($b, $b));
|
||||
$this->assertEquals(gmp_strval(gmp_div($c, $c)), $math->div($c, $c));
|
||||
$this->assertEquals(1, $math->div(1, 1));
|
||||
$this->assertEquals(gmp_strval(gmp_div($this->a, $this->a)), $this->math->div($this->a, $this->a));
|
||||
$this->assertEquals(gmp_strval(gmp_div($this->b, $this->b)), $this->math->div($this->b, $this->b));
|
||||
$this->assertEquals(gmp_strval(gmp_div($this->c, $this->c)), $this->math->div($this->c, $this->c));
|
||||
$this->assertEquals(1, $this->math->div(1, 1));
|
||||
}
|
||||
|
||||
public function testinvertm()
|
||||
public function testInvertm()
|
||||
{
|
||||
$a = 1234;
|
||||
$b = '1234123412341234123412341234123412412341234213412421341342342';
|
||||
$c = '0x1234123412341234123412341234123412412341234213412421341342342';
|
||||
$math = new GmpEngine();
|
||||
$this->assertEquals(gmp_strval(gmp_invert($a, $a)), $math->invertm($a, $a));
|
||||
$this->assertEquals(gmp_strval(gmp_invert($b, $b)), $math->invertm($b, $b));
|
||||
$this->assertEquals(gmp_strval(gmp_invert($c, $c)), $math->invertm($c, $c));
|
||||
$this->assertEquals(0, $math->invertm(1, 1));
|
||||
$this->assertEquals(gmp_strval(gmp_invert($this->a, $this->a)), $this->math->invertm($this->a, $this->a));
|
||||
$this->assertEquals(gmp_strval(gmp_invert($this->b, $this->b)), $this->math->invertm($this->b, $this->b));
|
||||
$this->assertEquals(gmp_strval(gmp_invert($this->c, $this->c)), $this->math->invertm($this->c, $this->c));
|
||||
$this->assertEquals(0, $this->math->invertm(1, 1));
|
||||
|
||||
$o = '2';
|
||||
$p = '0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f';
|
||||
$this->assertEquals('57896044618658097711785492504343953926634992332820282019728792003954417335832', $math->invertm($o, $p));
|
||||
$this->assertEquals('57896044618658097711785492504343953926634992332820282019728792003954417335832', $this->math->invertm($o, $p));
|
||||
|
||||
$o = '-207267379875244730201206352791949018434229233557197871725317424106240926035466';
|
||||
$p = '0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f';
|
||||
$this->assertEquals('93736451599995461267424215486556527005103980679329099329644578865571485201981', $math->invertm($o, $p));
|
||||
$this->assertEquals('93736451599995461267424215486556527005103980679329099329644578865571485201981', $this->math->invertm($o, $p));
|
||||
}
|
||||
|
||||
public function testmod()
|
||||
public function testMod()
|
||||
{
|
||||
$a = 1234;
|
||||
$b = '1234123412341234123412341234123412412341234213412421341342342';
|
||||
$c = '0x1234123412341234123412341234123412412341234213412421341342342';
|
||||
$math = new GmpEngine();
|
||||
$this->assertEquals(gmp_strval(gmp_mod($a, $a)), $math->mod($a, $a));
|
||||
$this->assertEquals(gmp_strval(gmp_mod($b, $b)), $math->mod($b, $b));
|
||||
$this->assertEquals(gmp_strval(gmp_mod($c, $c)), $math->mod($c, $c));
|
||||
$this->assertEquals(0, $math->mod(1, 1));
|
||||
$this->assertEquals(gmp_strval(gmp_mod($this->a, $this->a)), $this->math->mod($this->a, $this->a));
|
||||
$this->assertEquals(gmp_strval(gmp_mod($this->b, $this->b)), $this->math->mod($this->b, $this->b));
|
||||
$this->assertEquals(gmp_strval(gmp_mod($this->c, $this->c)), $this->math->mod($this->c, $this->c));
|
||||
$this->assertEquals(0, $this->math->mod(1, 1));
|
||||
}
|
||||
|
||||
public function testmul()
|
||||
public function testMul()
|
||||
{
|
||||
$a = 1234;
|
||||
$b = '1234123412341234123412341234123412412341234213412421341342342';
|
||||
$c = '0x1234123412341234123412341234123412412341234213412421341342342';
|
||||
$math = new GmpEngine();
|
||||
$this->assertEquals(gmp_strval(gmp_mul($a, $a)), $math->mul($a, $a));
|
||||
$this->assertEquals(gmp_strval(gmp_mul($b, $b)), $math->mul($b, $b));
|
||||
$this->assertEquals(gmp_strval(gmp_mul($c, $c)), $math->mul($c, $c));
|
||||
$this->assertEquals(1, $math->mul(1, 1));
|
||||
$this->assertEquals(gmp_strval(gmp_mul($this->a, $this->a)), $this->math->mul($this->a, $this->a));
|
||||
$this->assertEquals(gmp_strval(gmp_mul($this->b, $this->b)), $this->math->mul($this->b, $this->b));
|
||||
$this->assertEquals(gmp_strval(gmp_mul($this->c, $this->c)), $this->math->mul($this->c, $this->c));
|
||||
$this->assertEquals(1, $this->math->mul(1, 1));
|
||||
}
|
||||
|
||||
public function testpow()
|
||||
public function testPow()
|
||||
{
|
||||
$a = 1234;
|
||||
$b = '1234123412341234123412341234123412412341234213412421341342342';
|
||||
$c = '0x1234123412341234123412341234123412412341234213412421341342342';
|
||||
$math = new GmpEngine();
|
||||
$this->assertEquals(gmp_strval(gmp_pow($a, $a)), $math->pow($a, $a));
|
||||
$this->assertEquals(gmp_strval(gmp_pow($b, $b)), $math->pow($b, $b));
|
||||
$this->assertEquals(gmp_strval(gmp_pow($c, $c)), $math->pow($c, $c));
|
||||
$this->assertEquals(1, $math->pow(1, 1));
|
||||
$this->assertEquals(gmp_strval(gmp_pow($this->a, $this->a)), $this->math->pow($this->a, $this->a));
|
||||
$this->assertEquals(gmp_strval(gmp_pow($this->b, $this->b)), $this->math->pow($this->b, $this->b));
|
||||
$this->assertEquals(gmp_strval(gmp_pow($this->c, $this->c)), $this->math->pow($this->c, $this->c));
|
||||
$this->assertEquals(1, $this->math->pow(1, 1));
|
||||
}
|
||||
|
||||
public function testsub()
|
||||
public function testSub()
|
||||
{
|
||||
$a = 1234;
|
||||
$b = '1234123412341234123412341234123412412341234213412421341342342';
|
||||
$c = '0x1234123412341234123412341234123412412341234213412421341342342';
|
||||
$math = new GmpEngine();
|
||||
$this->assertEquals(gmp_strval(gmp_sub($a, $a)), $math->sub($a, $a));
|
||||
$this->assertEquals(gmp_strval(gmp_sub($b, $b)), $math->sub($b, $b));
|
||||
$this->assertEquals(gmp_strval(gmp_sub($c, $c)), $math->sub($c, $c));
|
||||
$this->assertEquals(0, $math->sub(1, 1));
|
||||
$this->assertEquals(gmp_strval(gmp_sub($this->a, $this->a)), $this->math->sub($this->a, $this->a));
|
||||
$this->assertEquals(gmp_strval(gmp_sub($this->b, $this->b)), $this->math->sub($this->b, $this->b));
|
||||
$this->assertEquals(gmp_strval(gmp_sub($this->c, $this->c)), $this->math->sub($this->c, $this->c));
|
||||
$this->assertEquals(0, $this->math->sub(1, 1));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -8,47 +8,48 @@ namespace Bitpay\Math;
|
||||
|
||||
function function_exists($func)
|
||||
{
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
class MathTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testIsEngineSet()
|
||||
{
|
||||
Math::setEngine(null);
|
||||
$this->assertNull(Math::getEngine());
|
||||
$engine = $this->getMock('Bitpay\Math\EngineInterface');
|
||||
Math::setEngine($engine);
|
||||
$this->assertInstanceOf('Bitpay\Math\EngineInterface', Math::getEngine());
|
||||
}
|
||||
public function testIsEngineSet()
|
||||
{
|
||||
Math::setEngine(null);
|
||||
$this->assertNull(Math::getEngine());
|
||||
$engine = $this->getMock('Bitpay\Math\EngineInterface');
|
||||
|
||||
/**
|
||||
* @requires extension gmp
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
public function testGmpMath()
|
||||
{
|
||||
if (!extension_loaded('gmp'))
|
||||
{
|
||||
$this->markTestSkipped('The GMP extension is NOT loaded! You must enable it to run this test');
|
||||
}
|
||||
Math::add("3324234234234234234", "3324234234234234234");
|
||||
$this->assertEquals(new GmpEngine(), Math::getEngine());
|
||||
}
|
||||
Math::setEngine($engine);
|
||||
$this->assertInstanceOf('Bitpay\Math\EngineInterface', Math::getEngine());
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires extension bcmath
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
public function testBcMath()
|
||||
{
|
||||
if (!extension_loaded('bcmath'))
|
||||
{
|
||||
$this->markTestSkipped('The Bcmath extension is NOT loaded! You must enable it to run this test');
|
||||
} elseif (extension_loaded('gmp')) {
|
||||
$this->markTestSkipped('The GMP extension is loaded! You must remove it to run this test');
|
||||
}
|
||||
Math::add("3324234234234234234", "3324234234234234234");
|
||||
$this->assertEquals(new BcEngine(), Math::getEngine());
|
||||
}
|
||||
/**
|
||||
* @requires extension gmp
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
public function testGmpMath()
|
||||
{
|
||||
if (!extension_loaded('gmp')) {
|
||||
$this->markTestSkipped('The GMP extension is NOT loaded! You must enable it to run this test');
|
||||
}
|
||||
|
||||
Math::add("3324234234234234234", "3324234234234234234");
|
||||
$this->assertEquals(new GmpEngine(), Math::getEngine());
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires extension bcmath
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
public function testBcMath()
|
||||
{
|
||||
if (!extension_loaded('bcmath')) {
|
||||
$this->markTestSkipped('The Bcmath extension is NOT loaded! You must enable it to run this test');
|
||||
} else if (extension_loaded('gmp')) {
|
||||
$this->markTestSkipped('The GMP extension is loaded! You must remove it to run this test');
|
||||
}
|
||||
|
||||
Math::add("3324234234234234234", "3324234234234234234");
|
||||
$this->assertEquals(new BcEngine(), Math::getEngine());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -125,6 +125,7 @@ class PayoutInstructionTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertNotNull($this->instruction->getBtc());
|
||||
$this->assertSame($btc, $this->instruction->getBtc());
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testGetAmount
|
||||
*/
|
||||
@ -140,6 +141,7 @@ class PayoutInstructionTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertInternalType('float', $this->instruction->getAmount());
|
||||
$this->assertSame(10.99, $this->instruction->getAmount());
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testGetStatus
|
||||
*/
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -77,7 +77,6 @@ class PayoutTest extends \PHPUnit_Framework_TestCase
|
||||
->setLabel($label);
|
||||
|
||||
$this->payout->addInstruction($instruction);
|
||||
|
||||
$this->assertInternalType('array', $this->payout->getInstructions());
|
||||
$this->assertTrue(count($this->payout->getInstructions()) == 1);
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -8,8 +8,6 @@ namespace Bitpay;
|
||||
|
||||
class PointTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
*/
|
||||
public function testConstruct()
|
||||
{
|
||||
$point = new Point(1, 2);
|
||||
@ -66,6 +64,7 @@ class PointTest extends \PHPUnit_Framework_TestCase
|
||||
);
|
||||
|
||||
$pointA = unserialize($data);
|
||||
|
||||
$this->assertInstanceOf('Bitpay\PointInterface', $pointA);
|
||||
$this->assertSame('1', $pointA->getX());
|
||||
$this->assertSame('2', $pointA->getY());
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -28,10 +28,10 @@ class PrivateKeyTest extends \PHPUnit_Framework_TestCase
|
||||
} else {
|
||||
\Bitpay\Math\Math::setEngine(new \Bitpay\Math\RpEngine());
|
||||
}
|
||||
|
||||
$priKey = new PrivateKey();
|
||||
$this->assertNotNull($priKey);
|
||||
|
||||
$priKey = new PrivateKey();
|
||||
|
||||
$this->assertNotNull($priKey);
|
||||
$this->assertNull($priKey->getHex());
|
||||
$this->assertNull($priKey->getDec());
|
||||
|
||||
@ -44,8 +44,11 @@ class PrivateKeyTest extends \PHPUnit_Framework_TestCase
|
||||
public function testGenerateCannotHappenTwice()
|
||||
{
|
||||
$privateKey = new PrivateKey();
|
||||
|
||||
$privateKey->generate();
|
||||
|
||||
$hex = $privateKey->getHex();
|
||||
|
||||
$privateKey->generate();
|
||||
$this->assertSame($hex, $privateKey->getHex());
|
||||
}
|
||||
@ -53,10 +56,9 @@ class PrivateKeyTest extends \PHPUnit_Framework_TestCase
|
||||
public function testGetHex()
|
||||
{
|
||||
$priKey = new PrivateKey();
|
||||
|
||||
$this->assertNotNull($priKey);
|
||||
|
||||
$this->assertNull($priKey->getHex());
|
||||
|
||||
$this->assertEquals(0, strlen($priKey->getHex()));
|
||||
|
||||
$priKey->generate();
|
||||
@ -71,6 +73,7 @@ class PrivateKeyTest extends \PHPUnit_Framework_TestCase
|
||||
public function testToString()
|
||||
{
|
||||
$priKey = new PrivateKey();
|
||||
|
||||
$this->assertNotNull($priKey);
|
||||
|
||||
// Make sure this is a string
|
||||
@ -87,10 +90,9 @@ class PrivateKeyTest extends \PHPUnit_Framework_TestCase
|
||||
public function testGetDec()
|
||||
{
|
||||
$priKey = new PrivateKey();
|
||||
|
||||
$this->assertNotNull($priKey);
|
||||
|
||||
$this->assertNull($priKey->getDec());
|
||||
|
||||
$this->assertEquals(0, strlen($priKey->getDec()));
|
||||
|
||||
$priKey->generate();
|
||||
@ -101,8 +103,8 @@ class PrivateKeyTest extends \PHPUnit_Framework_TestCase
|
||||
public function testIsValid()
|
||||
{
|
||||
$priKey = new PrivateKey();
|
||||
$this->assertNotNull($priKey);
|
||||
|
||||
$this->assertNotNull($priKey);
|
||||
$this->assertFalse($priKey->isValid());
|
||||
|
||||
$priKey->generate();
|
||||
@ -113,6 +115,7 @@ class PrivateKeyTest extends \PHPUnit_Framework_TestCase
|
||||
public function testSign()
|
||||
{
|
||||
$priKey = new PrivateKey();
|
||||
|
||||
$priKey->generate();
|
||||
|
||||
// Make sure not exceptions are thrown
|
||||
@ -122,8 +125,8 @@ class PrivateKeyTest extends \PHPUnit_Framework_TestCase
|
||||
public function testHasValidHex()
|
||||
{
|
||||
$priKey = new PrivateKey();
|
||||
$this->assertNotNull($priKey);
|
||||
|
||||
$this->assertNotNull($priKey);
|
||||
$this->assertFalse($priKey->hasValidHex());
|
||||
|
||||
$priKey->generate();
|
||||
@ -134,8 +137,8 @@ class PrivateKeyTest extends \PHPUnit_Framework_TestCase
|
||||
public function testHasValidDec()
|
||||
{
|
||||
$priKey = new PrivateKey();
|
||||
$this->assertNotNull($priKey);
|
||||
|
||||
$this->assertNotNull($priKey);
|
||||
$this->assertFalse($priKey->hasValidDec());
|
||||
|
||||
$priKey->generate();
|
||||
@ -163,9 +166,11 @@ class PrivateKeyTest extends \PHPUnit_Framework_TestCase
|
||||
$public_key = '048d970d6ba29dcfa190c177140fd889fadd6d2590b1ee1a6a06e255dbf22b4017ee7bc8e1f07ed0ff8bd77c002b98d31a1a8b53a63767ca65a531fb33cd726197';
|
||||
|
||||
$pkey = new PrivateKey();
|
||||
|
||||
$this->assertNotNull($pkey);
|
||||
|
||||
$keys = $pkey->pemDecode($data);
|
||||
|
||||
$this->assertNotNull($pkey);
|
||||
|
||||
// Ensure it's an array
|
||||
@ -190,11 +195,12 @@ class PrivateKeyTest extends \PHPUnit_Framework_TestCase
|
||||
$public_key = '048d970d6ba29dcfa190c177140fd889fadd6d2590b1ee1a6a06e255dbf22b4017ee7bc8e1f07ed0ff8bd77c002b98d31a1a8b53a63767ca65a531fb33cd726197';
|
||||
|
||||
$keypair = array($private_key, $public_key);
|
||||
$pkey = new PrivateKey();
|
||||
|
||||
$pkey = new PrivateKey();
|
||||
$this->assertNotNull($pkey);
|
||||
|
||||
$pemdata = $pkey->pemEncode($keypair);
|
||||
|
||||
$this->assertNotNull($pemdata);
|
||||
|
||||
// Ensure it's a string
|
||||
|
||||
@ -1,17 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace Bitpay;
|
||||
|
||||
/**
|
||||
* @see https://github.com/bitpay/bitcore/blob/master/test/test.Key.js
|
||||
*/
|
||||
class PublicKeyTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
private $hexKeys = array(
|
||||
array(
|
||||
'private' => '10a2036fd1c8f7aeae1e21cd2a11bb9654f76844d1636809618b5e2cbb00c35d',
|
||||
@ -78,6 +74,7 @@ class PublicKeyTest extends \PHPUnit_Framework_TestCase
|
||||
public function testId()
|
||||
{
|
||||
$key = new PublicKey('/path/to/key.pub');
|
||||
|
||||
$this->assertSame('/path/to/key.pub', $key->getId());
|
||||
}
|
||||
|
||||
@ -90,6 +87,7 @@ class PublicKeyTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
foreach($this->hexKeys as $hexKey) {
|
||||
$pubKey = new PublicKey();
|
||||
|
||||
$pubKey->setPrivateKey($this->getMockPrivateKey($hexKey['private']));
|
||||
$pubKey->generate();
|
||||
$this->assertEquals($hexKey['public'], (string) $pubKey);
|
||||
@ -99,6 +97,7 @@ class PublicKeyTest extends \PHPUnit_Framework_TestCase
|
||||
public function testGenerateOnlyOnce()
|
||||
{
|
||||
$key = new PublicKey();
|
||||
|
||||
$key->setPrivateKey($this->getMockPrivateKey());
|
||||
$key->generate();
|
||||
|
||||
@ -107,10 +106,7 @@ class PublicKeyTest extends \PHPUnit_Framework_TestCase
|
||||
$key->generate();
|
||||
|
||||
// Make sure values do not change
|
||||
$this->assertSame(
|
||||
$hexValue,
|
||||
$key->getHex()
|
||||
);
|
||||
$this->assertSame($hexValue, $key->getHex());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -119,6 +115,7 @@ class PublicKeyTest extends \PHPUnit_Framework_TestCase
|
||||
public function testGetHex()
|
||||
{
|
||||
$pubKey = new PublicKey();
|
||||
|
||||
$pubKey->setPrivateKey($this->getMockPrivateKey());
|
||||
$this->assertNull($pubKey->getHex());
|
||||
$pubKey->generate();
|
||||
@ -131,46 +128,41 @@ class PublicKeyTest extends \PHPUnit_Framework_TestCase
|
||||
public function testGetDec()
|
||||
{
|
||||
$pubKey = new PublicKey();
|
||||
|
||||
$this->assertNotNull($pubKey);
|
||||
|
||||
$pubKey->setPrivateKey($this->getMockPrivateKey());
|
||||
|
||||
$this->assertNull($pubKey->getDec());
|
||||
|
||||
$pubKey->generate();
|
||||
$this->assertGreaterThanOrEqual(154, strlen($pubKey->getDec()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see https://github.com/bitpay/bitcore/blob/master/test/test.Key.js
|
||||
* @depends testGenerate
|
||||
*/
|
||||
public function testToString()
|
||||
{
|
||||
$pubKey = new PublicKey();
|
||||
|
||||
$this->assertNotNull($pubKey);
|
||||
|
||||
$pubKey->setPrivateKey(PrivateKey::create()->generate());
|
||||
|
||||
$this->assertSame('', (string) $pubKey);
|
||||
|
||||
$this->assertSame('', (string)$pubKey);
|
||||
$pubKey->generate(PrivateKey::create()->generate());
|
||||
|
||||
if ('02'.$pubKey->getX() == $pubKey) {
|
||||
$compressed = '02'.$pubKey->getX();
|
||||
if ('02' . $pubKey->getX() == $pubKey) {
|
||||
$compressed = '02' . $pubKey->getX();
|
||||
} else {
|
||||
$compressed = '03'.$pubKey->getX();
|
||||
$compressed = '03' . $pubKey->getX();
|
||||
}
|
||||
|
||||
$this->assertSame($compressed, (string) $pubKey);
|
||||
|
||||
$this->assertEquals(66, strlen((string) $pubKey));
|
||||
$this->assertSame($compressed, (string)$pubKey);
|
||||
$this->assertEquals(66, strlen((string)$pubKey));
|
||||
}
|
||||
|
||||
public function testGetX()
|
||||
{
|
||||
foreach($this->hexKeys as $hexKey) {
|
||||
$pubKey = new PublicKey();
|
||||
|
||||
$pubKey->setPrivateKey($this->getMockPrivateKey($hexKey['private']));
|
||||
$pubKey->generate();
|
||||
$this->assertEquals($hexKey['pub_x'], $pubKey->getX());
|
||||
@ -181,6 +173,7 @@ class PublicKeyTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
foreach($this->hexKeys as $hexKey) {
|
||||
$pubKey = new PublicKey();
|
||||
|
||||
$pubKey->setPrivateKey($this->getMockPrivateKey($hexKey['private']));
|
||||
$pubKey->generate();
|
||||
$this->assertEquals($hexKey['pub_y'], $pubKey->getY());
|
||||
@ -190,12 +183,14 @@ class PublicKeyTest extends \PHPUnit_Framework_TestCase
|
||||
public function testCreateFromPrivateKey()
|
||||
{
|
||||
$key = PublicKey::createFromPrivateKey($this->getMockPrivateKey());
|
||||
|
||||
$this->assertInstanceOf('Bitpay\PublicKey', $key);
|
||||
}
|
||||
|
||||
public function testIsValid()
|
||||
{
|
||||
$key = new PublicKey();
|
||||
|
||||
$this->assertFalse($key->isValid());
|
||||
$key->setPrivateKey($this->getMockPrivateKey());
|
||||
$key->generate();
|
||||
@ -205,7 +200,9 @@ class PublicKeyTest extends \PHPUnit_Framework_TestCase
|
||||
public function testGetSin()
|
||||
{
|
||||
$pub = new PublicKey();
|
||||
|
||||
$pub->setPrivateKey($this->getMockPrivateKey());
|
||||
|
||||
$sin = $pub->getSin();
|
||||
|
||||
$this->assertInstanceOf('Bitpay\SinKey', $sin);
|
||||
@ -214,19 +211,18 @@ class PublicKeyTest extends \PHPUnit_Framework_TestCase
|
||||
public function testGetSinOnlyOnce()
|
||||
{
|
||||
$pub = new PublicKey();
|
||||
|
||||
$pub->setPrivateKey($this->getMockPrivateKey());
|
||||
|
||||
$sin = $pub->getSin();
|
||||
|
||||
$this->assertSame(
|
||||
$sin,
|
||||
$pub->getSin()
|
||||
);
|
||||
$this->assertSame($sin,$pub->getSin());
|
||||
}
|
||||
|
||||
public function testIsGenerated()
|
||||
{
|
||||
$pub = new PublicKey();
|
||||
|
||||
$pub->setPrivateKey($this->getMockPrivateKey());
|
||||
$this->assertFalse($pub->isGenerated());
|
||||
$pub->generate();
|
||||
@ -237,13 +233,10 @@ class PublicKeyTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$hex = ($hex === null) ? $this->hexKeys[0]['private'] : $hex;
|
||||
$key = $this->getMock('Bitpay\PrivateKey');
|
||||
$key->method('isValid')->will($this->returnValue(true));
|
||||
|
||||
$key
|
||||
->method('getHex')
|
||||
->will($this->returnValue($hex));
|
||||
|
||||
$key->method('isValid')->will($this->returnValue(true));
|
||||
$key->method('getHex')->will($this->returnValue($hex));
|
||||
|
||||
return $key;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,34 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace Bitpay;
|
||||
|
||||
/**
|
||||
* @package Bitcore
|
||||
* @package Bitpay
|
||||
*/
|
||||
class SinKeyTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testToString()
|
||||
{
|
||||
$pubKey = PublicKey::create();
|
||||
|
||||
$this->assertNotNull($pubKey);
|
||||
|
||||
$pubKey->setPrivateKey(PrivateKey::create()->generate());
|
||||
|
||||
$pubKey->generate();
|
||||
|
||||
$sinKey = new SinKey();
|
||||
|
||||
$this->assertNotNull($sinKey);
|
||||
|
||||
$sinKey->setPublicKey($pubKey);
|
||||
|
||||
$this->assertSame('', (string) $sinKey);
|
||||
|
||||
$sinKey->generate();
|
||||
|
||||
$this->assertEquals(35, strlen((string) $sinKey));
|
||||
}
|
||||
|
||||
@ -38,6 +34,7 @@ class SinKeyTest extends \PHPUnit_Framework_TestCase
|
||||
public function testGenerateWithException()
|
||||
{
|
||||
$sinKey = new SinKey();
|
||||
|
||||
$this->assertNotNull($sinKey);
|
||||
$sinKey->generate();
|
||||
}
|
||||
@ -48,27 +45,24 @@ class SinKeyTest extends \PHPUnit_Framework_TestCase
|
||||
public function testGenerateWithoutPublicKey()
|
||||
{
|
||||
$sinKey = new SinKey();
|
||||
|
||||
$this->assertNotNull($sinKey);
|
||||
|
||||
$sinKey->generate();
|
||||
}
|
||||
|
||||
public function testGenerateWithoutException()
|
||||
{
|
||||
$pubKey = PublicKey::create();
|
||||
|
||||
$this->assertNotNull($pubKey);
|
||||
|
||||
$pubKey->setPrivateKey(PrivateKey::create()->generate());
|
||||
|
||||
$pubKey->generate();
|
||||
|
||||
$sinKey = new SinKey();
|
||||
|
||||
$this->assertNotNull($sinKey);
|
||||
|
||||
$sinKey->setPublicKey($pubKey);
|
||||
|
||||
$sinKey->generate();
|
||||
|
||||
$this->assertEquals(35, strlen((string) $sinKey));
|
||||
}
|
||||
|
||||
@ -78,21 +72,17 @@ class SinKeyTest extends \PHPUnit_Framework_TestCase
|
||||
public function testIsValid()
|
||||
{
|
||||
$sinKey = new SinKey();
|
||||
|
||||
$this->assertNotNull($sinKey);
|
||||
|
||||
$this->assertFalse($sinKey->isValid());
|
||||
|
||||
$pubKey = PublicKey::create();
|
||||
|
||||
$this->assertNotNull($pubKey);
|
||||
|
||||
$pubKey->setPrivateKey(PrivateKey::create()->generate());
|
||||
|
||||
$pubKey->generate();
|
||||
|
||||
$sinKey->setPublicKey($pubKey);
|
||||
|
||||
$sinKey->generate();
|
||||
|
||||
$this->assertTrue($sinKey->isValid());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -10,89 +10,83 @@ use org\bovigo\vfs\vfsStream;
|
||||
|
||||
class EncryptedFilesystemStorageTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $root;
|
||||
private $pubkeyStream;
|
||||
private $pubkeyName;
|
||||
private $storage;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->pubkeyName = 'tmp/public.key';
|
||||
$this->root = vfsStream::setup('tmp');
|
||||
$this->pubkeyStream = vfsStream::url($this->pubkeyName);
|
||||
$this->storage = new EncryptedFilesystemStorage('satoshi');
|
||||
}
|
||||
|
||||
public function testPersist()
|
||||
{
|
||||
$storage = new EncryptedFilesystemStorage('dN$8WNaT}j<gD3*q');
|
||||
$storage->persist(new \Bitpay\PublicKey(vfsStream::url('tmp/public.key')));
|
||||
$this->assertTrue($this->root->hasChild('tmp/public.key'));
|
||||
}
|
||||
|
||||
public function testUnencodedLoad()
|
||||
{
|
||||
$storage = new EncryptedFilesystemStorage('dN$8WNaT}j<gD3*q');
|
||||
|
||||
vfsStream::newFile('public.key')
|
||||
->at($this->root)
|
||||
->setContent('97f394f4153a75ad7da3d9b8844cf0593c5abbea78695ba41c8528bc7bcd158cdc73a93ba2826d4a9ef1b3552f0f754a2db43010488ebea5648c7d897749df8d27d761683de7c17d225d2464413c89cc5ddc6d0a1b522b0efbeb47cc247a9ecb8d4e5a8790a2eb82cf1a9b6a727b90e3de444f2245b3c6aae7a1f12f3727ad926935f6540a49fd7e7e633b613ee1a196ed56b8c19d2c9353a4d9ee1f94f6a39f0a5bcf6729ea9677e9d9d590e53cdf25e04e2b00ee31f2489b7ae42cb0666dd002b536a95224f11ca0a9dc771b3eaf230b2f2bad72e13837308a58e0acfc03d2ac53522dad3231e754c647c75282bc9882f4b9d4ab712cb901f6d4d03c346df444c4e2a2a2114fd22a3c396c2a0e8ddf6838fa3fc54ea72b5095807c3a6f402cfd7ad15da7b45630bb31ed4c7e95bdfdff477c6b9c0e48fe678266d6b15505eeb2a0e8ff60b400af3f376fd261619fa9c1233efbb75ace29f9dfbc6360f9e4ac7d53e1bf112fa2ab8740f53dd40318da0e7360cb40cbcc15fe3c589bf34fdf7b981800b50d666b2e795438ce22b2640b4d55b98fa08aa37e18d6581e198d5c960574b07ab7daaf89b9e361719d85040a0c1e53b51f96f3119b27f922ab1ae7989bc8d686860f8c2d7201fe427a401be9dba0fd19ced8124d99b1475f75f007bf8cf213065c52544b3dffc126b05c5c3b2965ffacd4a16a395f11341a0149023b9b6df3326a6161cdb28d2e71690560a2');
|
||||
|
||||
$key = $storage->load(vfsStream::url('tmp/public.key'));
|
||||
$this->assertInstanceOf('Bitpay\PublicKey', $key);
|
||||
$this->storage->persist(new \Bitpay\PublicKey($this->pubkeyStream));
|
||||
$this->assertTrue($this->root->hasChild($this->pubkeyName));
|
||||
}
|
||||
|
||||
public function testLoad()
|
||||
{
|
||||
$storage = new EncryptedFilesystemStorage('dN$8WNaT}j<gD3*q');
|
||||
|
||||
vfsStream::newFile('public.key')
|
||||
->at($this->root)
|
||||
->setContent('222464cf5e76807259205ed98a1114e3164ecada597352259f9e09ce06524cdf7eaf862bff208d44163b8b24719afbfe031344d97a44502955b63158e012c09f604f66f3c7ca99290e9991a4a1413c3a4095fb6522653ceda25d831d115be3de6756fd7511ed91d970dac0e4e01a5df91ce9b412a0c8a42eb266cf2a93e1d1b50090b3eb89c93fcd85ed2cee6ee08499a6d69c3ffe7836878e30a37df92226fc78a2936f6037d8bf4b0a33bb11dad77b544a1baaf1c097be38d04f6b642285811b9c9e27c51d460a57e298851bb047f6fa2a02f501e7902a660fa66630240cf8586f6cf774b6b0a6e62a06de6eee328b3dfaa3658fd692b0e7590ea58281c8a563e3fe09a1209de96c7919a3b92c5307b782b4729a68b08f220b03df02c15e7742977a48b48c4bff7d060020e3b4717d5ae05d630e9e5f1374d2bb9ac04652ee12ef9de37c67cd07461ae7a201ddd04975ec4f60e781e214b50ca1b756988b7a1868fdbf2b07db66e0e7c9a29526c7d11127bb58c606c515325d7375a21c9d1db63167fb34106c87c49d238fc1eb41309eb5f23d946743534bf8d454729dd94ac9c3d18cb7261fd773c913e674a4427c0b90b4f9a541b77363d43f957445fff395ad5c48b51131913917882413ce8084db0d20ab308b3504d43e8f67afb4f6611324d07d8980ffc8d9ae6817bfe1be5e4f5ad6e5155b9767d15c01c96fc101538071f9bef40978f805e52e31a8e169bf');
|
||||
->setContent('i8A7jkJy1H6oHWPGVxuBcrB360Krq8aZD8g3Ef4JYaLSZIJjhV+Kob1kNYL6091jRA3LpC1C7Tb19FDY80VXuHsd2zTn9QMgfQnl85awBzLdEBxh5Vx/Xv9FQSq9VDrKb2/jhZAnBjBC13rP2KuwS6fj8PNKz4BeVPENh09ADHo0uGhj5tzdXr80E09TkxcmRR2Ss2sGUCiCGWdjFM0AdwmEXDHqSPBHqBF7GuxzG5Ozuh7YLU4sHQoGWLRHKhaWsSyPMvuWLuEN13H7EcyKeHN/RrHP1aXbIJ6YgJWxQ7a4QEe0UH7xkhMJD0eIZM1uowNWpO0+lHUglxtqyU87ILPt2gtAGlXGuuxQqlPnKumNTdE7ji1PL/gClW6gEtACEdqVsAH5pv7EYVFqOhGakzAP2WtF2/SiNEgbu+j2dUYe4KuJ0sxir+v3LknVZ+fR1YdwNoKCbXMArLe8if2rjeNrjHOjs/FbNGIxMoPcPC0L24d3sQxzb2Lw7vJ0bu4zM4D6PoK1AiWYrR6NQuI0lvnH77Roav4qDw23Gs2SdysyCObQzoJboj1+hojEF888u+fBW9ZdqRRwhrwLwqiRC+q5XD1n79pRqh7Y6icJe6iSSLqrUbO/gGKmXguM7Ef55NYmVYESgZHgDtSVmTnk790EiEy2qA71j3UbxbgWH8DlZtMf6rEwqp/7401I1iym');
|
||||
|
||||
$key = $storage->load(vfsStream::url('tmp/public.key'));
|
||||
$key = $this->storage->load($this->pubkeyStream);
|
||||
$this->assertInstanceOf('Bitpay\PublicKey', $key);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
* @expectedException \Exception
|
||||
* @expectedExceptionMessage [ERROR] In EncryptedFilesystemStorage::readFromFile(): The file "vfs://tmp/public.key" does not exist or cannot be read, check permissions.
|
||||
*/
|
||||
public function testNotFileException()
|
||||
{
|
||||
$storage = new EncryptedFilesystemStorage('satoshi');
|
||||
$storage->load(vfsStream::url('tmp/public.key'));
|
||||
$this->storage->load($this->pubkeyStream);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
* @expectedException \Exception
|
||||
*/
|
||||
public function testLoadNotReadableException()
|
||||
{
|
||||
$storage = new EncryptedFilesystemStorage('satoshi');
|
||||
vfsStream::newFile('public.key', 0600)
|
||||
if (stripos(PHP_OS, 'WIN') === 0) {
|
||||
$this->markTestSkipped('Skip \Bitpay\Storage\EncryptedFilesystemStorageTest::testLoadNotReadableException() test on Windows system');
|
||||
}
|
||||
vfsStream::newFile('badpublic.key', 0600)
|
||||
->at($this->root)
|
||||
->setContent('')
|
||||
->chown(vfsStream::OWNER_ROOT)
|
||||
->chgrp(vfsStream::GROUP_ROOT);
|
||||
$storage->load(vfsStream::url('tmp/public.key'));
|
||||
|
||||
$this->storage->load(vfsStream::url('tmp/badpublic.key'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
* @expectedException \Exception
|
||||
* @expectedExceptionMessage [ERROR] In EncryptedFilesystemStorage::dataDecode(): Could not decode data "\".
|
||||
*/
|
||||
public function testLoadCouldNotDecode()
|
||||
{
|
||||
$storage = new EncryptedFilesystemStorage('satoshi');
|
||||
|
||||
vfsStream::newFile('public.key')
|
||||
vfsStream::newFile('badpublic.key')
|
||||
->at($this->root)
|
||||
->setContent('00');
|
||||
->setContent('\\');
|
||||
|
||||
$key = $storage->load(vfsStream::url('tmp/public.key'));
|
||||
$key = $this->storage->load(vfsStream::url('tmp/badpublic.key'));
|
||||
$this->assertInstanceOf('Bitpay\PublicKey', $key);
|
||||
}
|
||||
|
||||
public function testPersistAndLoadWithoutPassword()
|
||||
{
|
||||
$storage = new EncryptedFilesystemStorage(null);
|
||||
$storage->persist(new \Bitpay\PublicKey(vfsStream::url('tmp/public.key')));
|
||||
$this->assertTrue($this->root->hasChild('tmp/public.key'));
|
||||
|
||||
$key = $storage->load(vfsStream::url('tmp/public.key'));
|
||||
$storage->persist(new \Bitpay\PublicKey($this->pubkeyStream));
|
||||
$this->assertTrue($this->root->hasChild($this->pubkeyName));
|
||||
|
||||
$key = $storage->load($this->pubkeyStream);
|
||||
$this->assertInstanceOf('Bitpay\PublicKey', $key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,59 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace Bitpay\Storage;
|
||||
|
||||
use org\bovigo\vfs\vfsStream;
|
||||
use org\bovigo\vfs\vfsStreamDirectory;
|
||||
|
||||
class FilesystemStorageTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/** @var FilesystemStorage */
|
||||
private $storage;
|
||||
|
||||
/** @var string */
|
||||
private $key_file_content;
|
||||
|
||||
/** @var vfsStreamDirectory */
|
||||
private $root;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->storage = new FilesystemStorage();
|
||||
$this->key_file_content = 'C:16:"Bitpay\PublicKey":62:{a:5:{i:0;s:20:"vfs://tmp/public.key";i:1;N;i:2;N;i:3;N;i:4;N;}}';
|
||||
$this->root = vfsStream::setup('tmp');
|
||||
}
|
||||
|
||||
public function testPersist()
|
||||
{
|
||||
$storage = new FilesystemStorage();
|
||||
$storage->persist(new \Bitpay\PublicKey(vfsStream::url('tmp/public.key')));
|
||||
$this->storage->persist(new \Bitpay\PublicKey(vfsStream::url('tmp/public.key')));
|
||||
$this->assertTrue($this->root->hasChild('tmp/public.key'));
|
||||
}
|
||||
|
||||
public function testLoad()
|
||||
{
|
||||
$storage = new FilesystemStorage();
|
||||
|
||||
vfsStream::newFile('public.key')
|
||||
->at($this->root)
|
||||
->setContent('C:16:"Bitpay\PublicKey":62:{a:5:{i:0;s:20:"vfs://tmp/public.key";i:1;N;i:2;N;i:3;N;i:4;N;}}');
|
||||
->setContent($this->key_file_content);
|
||||
|
||||
$key = $storage->load(vfsStream::url('tmp/public.key'));
|
||||
$key = $this->storage->load(vfsStream::url('tmp/public.key'));
|
||||
$this->assertInstanceOf('Bitpay\PublicKey', $key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
* @expectedException \Exception
|
||||
*/
|
||||
public function testNotFileException()
|
||||
{
|
||||
$storage = new FilesystemStorage();
|
||||
$storage->load(vfsStream::url('tmp/public.key'));
|
||||
$this->storage->load(vfsStream::url('tmp/public.key'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
* @expectedException \Exception
|
||||
*/
|
||||
public function testLoadNotReadableException()
|
||||
{
|
||||
$storage = new FilesystemStorage();
|
||||
if (stripos(PHP_OS, 'WIN') === 0) {
|
||||
$this->markTestSkipped('Skip \Bitpay\Storage\EncryptedFilesystemStorageTest::testLoadNotReadableException() test on Windows system');
|
||||
}
|
||||
|
||||
vfsStream::newFile('public.key', 0600)
|
||||
->at($this->root)
|
||||
->setContent('C:16:"Bitpay\PublicKey":62:{a:5:{i:0;s:20:"vfs://tmp/public.key";i:1;N;i:2;N;i:3;N;i:4;N;}}')
|
||||
->setContent($this->key_file_content)
|
||||
->chown(vfsStream::OWNER_ROOT)
|
||||
->chgrp(vfsStream::GROUP_ROOT);
|
||||
$storage->load(vfsStream::url('tmp/public.key'));
|
||||
|
||||
$this->storage->load(vfsStream::url('tmp/public.key'));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -27,7 +27,6 @@ class UserTest extends \PHPUnit_Framework_TestCase
|
||||
public function testSetPhone()
|
||||
{
|
||||
$this->assertNotNull($this->user);
|
||||
|
||||
$this->user->setPhone('555-555-5555');
|
||||
$this->assertNotNull($this->user->getPhone());
|
||||
$this->assertSame('555-555-5555', $this->user->getPhone());
|
||||
@ -45,7 +44,6 @@ class UserTest extends \PHPUnit_Framework_TestCase
|
||||
public function testSetEmail()
|
||||
{
|
||||
$this->assertNotNull($this->user);
|
||||
|
||||
$this->user->setEmail('support@bitpay.com');
|
||||
$this->assertNotNull($this->user->getEmail());
|
||||
$this->assertSame('support@bitpay.com', $this->user->getEmail());
|
||||
@ -63,7 +61,6 @@ class UserTest extends \PHPUnit_Framework_TestCase
|
||||
public function testSetFirstName()
|
||||
{
|
||||
$this->assertNotNull($this->user);
|
||||
|
||||
$this->user->setFirstName('BitPay');
|
||||
$this->assertNotNull($this->user->getFirstName());
|
||||
$this->assertSame('BitPay', $this->user->getFirstName());
|
||||
@ -81,7 +78,6 @@ class UserTest extends \PHPUnit_Framework_TestCase
|
||||
public function testSetLastName()
|
||||
{
|
||||
$this->assertNotNull($this->user);
|
||||
|
||||
$this->user->setLastName('Inc');
|
||||
$this->assertNotNull($this->user->getLastName());
|
||||
$this->assertSame('Inc', $this->user->getLastName());
|
||||
@ -122,7 +118,6 @@ class UserTest extends \PHPUnit_Framework_TestCase
|
||||
public function testSetCity()
|
||||
{
|
||||
$this->assertNotNull($this->user);
|
||||
|
||||
$this->user->setCity('Atlanta');
|
||||
$this->assertNotNull($this->user->getCity());
|
||||
$this->assertSame('Atlanta', $this->user->getCity());
|
||||
@ -140,7 +135,6 @@ class UserTest extends \PHPUnit_Framework_TestCase
|
||||
public function testSetState()
|
||||
{
|
||||
$this->assertNotNull($this->user);
|
||||
|
||||
$this->user->setState('GA');
|
||||
$this->assertNotNull($this->user->getState());
|
||||
$this->assertSame('GA', $this->user->getState());
|
||||
@ -158,7 +152,6 @@ class UserTest extends \PHPUnit_Framework_TestCase
|
||||
public function testSetZip()
|
||||
{
|
||||
$this->assertNotNull($this->user);
|
||||
|
||||
$this->user->setZip('37379');
|
||||
$this->assertNotNull($this->user->getZip());
|
||||
$this->assertSame('37379', $this->user->getZip());
|
||||
@ -176,7 +169,6 @@ class UserTest extends \PHPUnit_Framework_TestCase
|
||||
public function testSetCountry()
|
||||
{
|
||||
$this->assertNotNull($this->user);
|
||||
|
||||
$this->user->setCountry('US');
|
||||
$this->assertNotNull($this->user->getCountry());
|
||||
$this->assertSame('US', $this->user->getCountry());
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -23,6 +23,7 @@ class Base58Test extends \PHPUnit_Framework_TestCase
|
||||
$data = array(
|
||||
array('', '', '3QJmnh'),
|
||||
);
|
||||
|
||||
foreach ($data as $datum) {
|
||||
$this->assertSame($datum[1], Base58::encode($datum[0]));
|
||||
}
|
||||
@ -44,6 +45,7 @@ class Base58Test extends \PHPUnit_Framework_TestCase
|
||||
array('3e', '25', ''),
|
||||
array('39', 'z', ''),
|
||||
);
|
||||
|
||||
foreach ($data as $datum) {
|
||||
$decoded = Base58::decode($datum[1]);
|
||||
$this->assertSame($datum[0], $decoded, sprintf('%s != %s', $datum[0], $decoded));
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -8,7 +8,6 @@ namespace Bitpay\Util;
|
||||
|
||||
class FingerprintTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
public function testGenerate()
|
||||
{
|
||||
$finger = Fingerprint::generate();
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace Bitpay\Util;
|
||||
|
||||
/**
|
||||
* @package Bitcore
|
||||
* @package Bitpay
|
||||
*
|
||||
* @requires function openssl_random_pseudo_bytes
|
||||
*/
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
||||
* @license Copyright 2011-2015 BitPay Inc., MIT License
|
||||
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@ -9,11 +9,10 @@ namespace Bitpay\Util;
|
||||
use Bitpay\Point;
|
||||
|
||||
/**
|
||||
* @package Bitcore
|
||||
* @package Bitpay
|
||||
*/
|
||||
class UtilTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
public function testSha256()
|
||||
{
|
||||
$data = array(
|
||||
@ -94,16 +93,6 @@ class UtilTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
}
|
||||
|
||||
public function testNonce()
|
||||
{
|
||||
$a = Util::nonce();
|
||||
usleep(1);
|
||||
$b = Util::nonce();
|
||||
|
||||
// ensure a < b
|
||||
$this->assertGreaterThan($a, $b);
|
||||
}
|
||||
|
||||
public function testGuid()
|
||||
{
|
||||
$guid = Util::guid();
|
||||
@ -173,6 +162,7 @@ class UtilTest extends \PHPUnit_Framework_TestCase
|
||||
$point = Util::doubleAndAdd('1', new Point(1, 1));
|
||||
$this->assertEquals('1', $point->getX());
|
||||
$this->assertEquals('1', $point->getY());
|
||||
|
||||
$point = new Point(
|
||||
'0x'.substr(Secp256k1::G, 2, 64),
|
||||
'0x'.substr(Secp256k1::G, 66, 64)
|
||||
@ -182,6 +172,7 @@ class UtilTest extends \PHPUnit_Framework_TestCase
|
||||
'0xb7dafe35d7d1aab78b53982c8ba554584518f86d50af565c98e053613c8f15e0',
|
||||
$point
|
||||
);
|
||||
|
||||
$this->assertEquals('14976827122927988984909748681266837395089399768482149532452617485742004777865', $R->getX());
|
||||
$this->assertEquals('5009713401941157350243425146365130573323232660945282226881202857781593637456', $R->getY());
|
||||
|
||||
@ -189,6 +180,7 @@ class UtilTest extends \PHPUnit_Framework_TestCase
|
||||
'0xfd7c6914790d3bbf3184d9830e3f1a327e951e3478dd0b28f0fd3b0e774bbd68',
|
||||
$point
|
||||
);
|
||||
|
||||
$this->assertEquals('65041784833307054098962518952641430476519680065454324565175938819000678523383', $R->getX());
|
||||
$this->assertEquals('53140314933116045874248958072587249546886301333167874306830834776596206062743', $R->getY());
|
||||
}
|
||||
@ -199,6 +191,7 @@ class UtilTest extends \PHPUnit_Framework_TestCase
|
||||
array('123456789', '101010001011001111011010111'),
|
||||
array('0x123456789', '100100011110011010100010110001001'),
|
||||
);
|
||||
|
||||
foreach ($data as $datum) {
|
||||
$this->assertSame($datum[1], Util::decToBin($datum[0]));
|
||||
}
|
||||
@ -229,6 +222,7 @@ class UtilTest extends \PHPUnit_Framework_TestCase
|
||||
new Point(1, 1),
|
||||
new Point(1, 1)
|
||||
);
|
||||
|
||||
$expectedpoint = new Point("28948022309329048855892746252171976963317496166410141009864396001977208667916", "14474011154664524427946373126085988481658748083205070504932198000988604333958");
|
||||
$this->assertEquals($expectedpoint, $point);
|
||||
|
||||
@ -236,6 +230,7 @@ class UtilTest extends \PHPUnit_Framework_TestCase
|
||||
new Point(0, 0),
|
||||
new Point(1, 1)
|
||||
);
|
||||
|
||||
$expectedpoint = new Point("0", "0");
|
||||
$this->assertEquals($expectedpoint, $point);
|
||||
|
||||
@ -243,6 +238,7 @@ class UtilTest extends \PHPUnit_Framework_TestCase
|
||||
new Point(1, 0),
|
||||
new Point(0, 1)
|
||||
);
|
||||
|
||||
$expectedpoint = new Point("0", "115792089237316195423570985008687907853269984665640564039457584007908834671662");
|
||||
$this->assertEquals($expectedpoint, $point);
|
||||
}
|
||||
@ -253,6 +249,7 @@ class UtilTest extends \PHPUnit_Framework_TestCase
|
||||
array('7361746f736869', 'satoshi'),
|
||||
array('0x7361746f736869', 'satoshi'),
|
||||
);
|
||||
|
||||
foreach ($data as $datum) {
|
||||
$this->assertSame($datum[1], Util::binConv($datum[0]));
|
||||
}
|
||||
@ -267,6 +264,7 @@ class UtilTest extends \PHPUnit_Framework_TestCase
|
||||
$version = explode('.', PHP_VERSION);
|
||||
define('PHP_VERSION_ID', ($version[0] * 10000 + $version[1] * 100 + $version[2]));
|
||||
}
|
||||
|
||||
if (PHP_VERSION_ID >= 50400) {
|
||||
$this->assertTrue($requirements['PHP']);
|
||||
} else {
|
||||
@ -292,6 +290,7 @@ class UtilTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertTrue($requirements['cURL']);
|
||||
$curl_version = curl_version();
|
||||
$ssl_supported = ($curl_version['features'] & CURL_VERSION_SSL);
|
||||
|
||||
if ($ssl_supported) {
|
||||
$this->assertTrue($requirements['cURL.SSL']);
|
||||
} else {
|
||||
@ -309,5 +308,4 @@ class UtilTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertTrue(is_string($requirements['Math']));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -23,7 +23,6 @@
|
||||
"plural": "Zimbabwean Dollar",
|
||||
"alts": "",
|
||||
"payoutFields": [
|
||||
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
@ -1 +1 @@
|
||||
{"facade":"public/invoice","data":{"url":"https://test.bitpay.com/invoice?id=5NxFkXcJbCSivtQRJa4kHP","posData":"{\"posData\":{\"orderId\":\"100000009\"},\"hash\":\"GA.VW7o8puqPA\"}","status":"expired","btcPrice":"0.0032","btcDue":"0.0032","price":1.99,"taxIncluded":0.0,"currency":"USD","exRates":{"USD":619.39},"orderId":"100000009","invoiceTime":1405974404088,"expirationTime":1405975304088,"currentTime":1412886370907,"id":"5NxFkXcJbCSivtQRJa4kHP","btcPaid":"0.0000","rate":619.39,"exceptionStatus":false,"token":"9CKEkTYE4VA4skhMPBxUsPQyUqXE36qpmitmYbtKssPnY3p8rYqhTTcEzUeowKwvzL"}}
|
||||
{"facade":"public/invoice","data":{"url":"https://test.bitpay.com/invoice?id=5NxFkXcJbCSivtQRJa4kHP","paymentUrls":{"BIP21":"bitcoin:mgjLEW6oUZ5TeAGMikYsFoBE54dzJybTpH?amount=0.0632","BIP72":"bitcoin:mgjLEW6oUZ5TeAGMikYsFoBE54dzJybTpH?amount=0.0632&r=https://test.bitpay.com/i/5NxFkXcJbCSivtQRJa4kHP","BIP72b":"bitcoin:?r=https://test.bitpay.com/i/5NxFkXcJbCSivtQRJa4kHP","BIP73":"https://test.bitpay.com/i/5NxFkXcJbCSivtQRJa4kHP"},"posData":"{\"posData\":{\"orderId\":\"100000009\"},\"hash\":\"GA.VW7o8puqPA\"}","status":"expired","btcPrice":"0.0032","btcDue":"0.0032","price":1.99,"currency":"USD","exRates":{"USD":619.39},"orderId":"100000009","invoiceTime":1405974404088,"expirationTime":1405975304088,"currentTime":1412886370907,"id":"5NxFkXcJbCSivtQRJa4kHP","btcPaid":"0.0000","rate":619.39,"exceptionStatus":false,"taxIncluded": 0,"token":"9CKEkTYE4VA4skhMPBxUsPQyUqXE36qpmitmYbtKssPnY3p8rYqhTTcEzUeowKwvzL"}}
|
||||
|
||||
@ -1,2 +1 @@
|
||||
{"data":[{"payroll":"39zPuHaBbO8VMZe8Bdr9RjmRY6pHT7Gs3ifcbKM6PYSg2"},{"payroll/payoutRequest":"FFehd3N8CmNFqdQnPC4HMMx1MQUbmN6RsbLZsrqPqS8x"},{"payroll/payoutRequest":"5QziWnr75x7c4B9DdJ5QUo"}]}
|
||||
|
||||
|
||||
@ -1,373 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Behat\Behat\Context\ClosuredContextInterface,
|
||||
Behat\Behat\Context\TranslatedContextInterface,
|
||||
Behat\Behat\Context\BehatContext,
|
||||
Behat\Behat\Exception\PendingException;
|
||||
use Behat\Gherkin\Node\PyStringNode,
|
||||
Behat\Gherkin\Node\TableNode;
|
||||
use Behat\Mink\Mink;
|
||||
use Behat\Mink\Session;
|
||||
use Behat\Mink\Driver\Selenium2Driver;
|
||||
|
||||
|
||||
require_once __DIR__ . '/../../../vendor/autoload.php';
|
||||
require_once __DIR__ . '/StepHelper.php';
|
||||
|
||||
/**
|
||||
* Features context.
|
||||
*/
|
||||
class FeatureContext extends BehatContext
|
||||
{
|
||||
private $params = array();
|
||||
|
||||
protected $mink;
|
||||
|
||||
public $validPairingCode;
|
||||
|
||||
protected $error;
|
||||
|
||||
public $reponse;
|
||||
|
||||
protected $invoiceId;
|
||||
|
||||
protected $user;
|
||||
|
||||
protected $password;
|
||||
|
||||
protected $base_url;
|
||||
|
||||
protected $port;
|
||||
|
||||
protected $port_required_in_url;
|
||||
|
||||
protected $network;
|
||||
|
||||
/**
|
||||
* Initializes context.
|
||||
* Every scenario gets it's own context object.
|
||||
*
|
||||
* @param array $parameters context parameters (set them up through behat.yml)
|
||||
*/
|
||||
public function __construct(array $parameters)
|
||||
{
|
||||
$this->params = $parameters;
|
||||
|
||||
if (null == getenv('BITPAY_EMAIL')) {
|
||||
$this->email = $this->params['user'];
|
||||
} else {
|
||||
$this->email = getenv('BITPAY_EMAIL');
|
||||
}
|
||||
if (null == getenv('BITPAY_PASSWORD')) {
|
||||
$this->password = $this->params['password'];
|
||||
} else {
|
||||
$this->password = getenv('BITPAY_PASSWORD');
|
||||
}
|
||||
|
||||
if (null == getenv('BITPAY_URL')) {
|
||||
$this->base_url = $this->params['base_url'];
|
||||
} else {
|
||||
$this->base_url = getenv('BITPAY_URL');
|
||||
}
|
||||
|
||||
$port = parse_url($this->base_url, PHP_URL_PORT);
|
||||
if (true == is_null(parse_url($this->base_url, PHP_URL_PORT))) {
|
||||
$this->port = 443;
|
||||
$this->port_required_in_url = false;
|
||||
} else {
|
||||
$this->port = parse_url($this->base_url, PHP_URL_PORT);
|
||||
$this->port_required_in_url = true;
|
||||
}
|
||||
|
||||
if (parse_url($this->base_url, PHP_URL_HOST) == 'test.bitpay.com') {
|
||||
$this->network = new \Bitpay\Network\Testnet();
|
||||
} else {
|
||||
$url = parse_url($this->base_url, PHP_URL_HOST);
|
||||
$this->network = new \Bitpay\Network\Customnet($url, $this->port, $this->port_required_in_url);
|
||||
}
|
||||
|
||||
if ((null == $this->email) || (null == $this->password)) {
|
||||
throw new Exception("Your email or password are not configured.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (null == $this->base_url) {
|
||||
throw new Exception("Your url is not configured.");
|
||||
return;
|
||||
}
|
||||
|
||||
$phantomjsDriver = new \Behat\Mink\Driver\Selenium2Driver('phantomJS', null, 'http://127.0.0.1:8643');
|
||||
$selenium2Driver = new \Behat\Mink\Driver\Selenium2Driver('firefox');
|
||||
|
||||
$this->mink = new \Behat\Mink\Mink(
|
||||
array(
|
||||
'phantomjs' => new \Behat\Mink\Session($phantomjsDriver),
|
||||
'selenium2' => new \Behat\Mink\Session($selenium2Driver),
|
||||
)
|
||||
);
|
||||
|
||||
$this->mink->setDefaultSessionName($this->params['driver']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^the user is authenticated with BitPay$/
|
||||
*/
|
||||
public function theUserIsAuthenticatedWithBitpay()
|
||||
{
|
||||
if(true == !file_exists('/tmp/token.json') || true == !file_exists('/tmp/bitpay.pri') || true == !file_exists('/tmp/bitpay.pub')){
|
||||
$this->theUserPairsWithBitpayWithAValidPairingCode();
|
||||
$this->theUserIsPairedWithBitpay();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^the user creates an invoice for "([^"]*)" "([^"]*)"$/
|
||||
*/
|
||||
public function theUserCreatesAnInvoiceFor($price, $currency)
|
||||
{
|
||||
try {
|
||||
// Load keys
|
||||
list($privateKey, $publicKey, $token_id) = loadKeys();
|
||||
|
||||
$network = $this->network;
|
||||
$client = createClient($network, $privateKey, $publicKey);
|
||||
|
||||
$token = new \Bitpay\Token();
|
||||
$token->setToken($token_id);
|
||||
$client->setToken($token);
|
||||
|
||||
$invoice = new \Bitpay\Invoice();
|
||||
|
||||
$item = new \Bitpay\Item();
|
||||
$item
|
||||
->setCode('skuNumber')
|
||||
->setDescription('General Description of Item')
|
||||
->setPrice($price);
|
||||
$invoice->setItem($item);
|
||||
|
||||
$invoice->setCurrency(new \Bitpay\Currency($currency));
|
||||
$client->createInvoice($invoice);
|
||||
$this->response = $client->getResponse();
|
||||
$body = $this->response->getBody();
|
||||
$json = json_decode($body, true);
|
||||
$this->invoiceId = $json['data']['id'];
|
||||
} catch (\Exception $e) {
|
||||
$this->error = $e;
|
||||
} finally {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^they should recieve an invoice in response for "([^"]*)" "([^"]*)"$/
|
||||
*/
|
||||
public function theyShouldRecieveAnInvoiceInResponseFor($price, $currency)
|
||||
{
|
||||
$body = $this->response->getBody();
|
||||
$json = json_decode($body, true);
|
||||
$responsePrice = (string) $json['data']['price'];
|
||||
$responseCurrency = $json['data']['currency'];
|
||||
if ($responsePrice !== $price){
|
||||
throw new Exception("Error: Price is different", 1);
|
||||
}
|
||||
if ($responseCurrency !== $currency){
|
||||
throw new Exception("Error: Currency is different", 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^the user pairs with BitPay with a valid pairing code$/
|
||||
*/
|
||||
public function theUserPairsWithBitpayWithAValidPairingCode()
|
||||
{
|
||||
// Login
|
||||
|
||||
$this->mink->getSession()->visit($this->base_url.'/merchant-login');
|
||||
|
||||
$this->mink->getSession()->wait(1500);
|
||||
$this->mink->getSession()->getPage()->fillField('email', $this->email);
|
||||
$this->mink->getSession()->getPage()->fillField('password', $this->password);
|
||||
|
||||
$value = $this->mink->getSession()->getPage()->pressButton('loginButton');
|
||||
|
||||
$this->mink->getSession()->wait(2500);
|
||||
|
||||
$assert = $this->mink->assertSession();
|
||||
$assert->pageTextContains('Dashboard');
|
||||
|
||||
// Navigate to tokens
|
||||
$this->mink->getSession()->wait(1500);
|
||||
$this->mink->getSession()->getPage()->clickLink('My Account');
|
||||
$this->mink->getSession()->wait(1500);
|
||||
$this->mink->getSession()->getPage()->clickLink('API Tokens');
|
||||
$this->mink->getSession()->wait(1500);
|
||||
|
||||
// Create and set pairing code
|
||||
$cssSelector = ".icon-plus";
|
||||
$element = $this->mink->getSession()->getPage()->find(
|
||||
'xpath',
|
||||
$this->mink->getSession()->getSelectorsHandler()->selectorToXpath('css', $cssSelector) // just changed xpath to css
|
||||
);
|
||||
if (null === $element) {
|
||||
throw new \InvalidArgumentException(sprintf('Could not evaluate CSS Selector: "%s"', $cssSelector));
|
||||
}
|
||||
$element->press();
|
||||
|
||||
$this->mink->getSession()->wait(1500);
|
||||
$this->mink->getSession()->getPage()->pressButton("Add Token");
|
||||
$this->mink->getSession()->wait(5000);
|
||||
|
||||
$this->validPairingCode = $this->mink->getSession()->getPage()->find('xpath', '//*[@id="my-token-access-wrapper"]/div[1]/div[2]/div/div')->getText();
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^the user is paired with BitPay$/
|
||||
*/
|
||||
public function theUserIsPairedWithBitpay()
|
||||
{
|
||||
// Create Keys
|
||||
list($privateKey, $publicKey, $sinKey) = generateAndPersistKeys();
|
||||
|
||||
//Set Client
|
||||
$network = $this->network;
|
||||
$client = createClient($network, $privateKey, $publicKey);
|
||||
|
||||
$pairingCode = $this->validPairingCode;
|
||||
|
||||
// Pair
|
||||
try {
|
||||
$token = $client->createToken(
|
||||
array(
|
||||
'pairingCode' => $pairingCode,
|
||||
'label' => 'Integrations Testing',
|
||||
'id' => (string) $sinKey,
|
||||
)
|
||||
);
|
||||
$token_file = fopen('/tmp/token.json', 'w');
|
||||
fwrite($token_file, $token);
|
||||
fclose($token_file);
|
||||
} catch (\Exception $e) {
|
||||
$request = $client->getRequest();
|
||||
$response = $client->getResponse();
|
||||
echo (string) $request.PHP_EOL.PHP_EOL.PHP_EOL;
|
||||
echo (string) $response.PHP_EOL.PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^the user fails to pair with a semantically (?:in|)valid code "([^"]*)"$/
|
||||
*/
|
||||
public function theUserFailsToPairWithASemanticallyValidCode($pairingCode)
|
||||
{
|
||||
try {
|
||||
// Stupid rate limiters
|
||||
$this->mink->getSession()->wait(1500);
|
||||
|
||||
// Create Keys
|
||||
list($privateKey, $publicKey, $sinKey) = generateAndPersistKeys();
|
||||
|
||||
//Set Client
|
||||
$network = $this->network;
|
||||
$client = createClient($network, $privateKey, $publicKey);
|
||||
|
||||
// Pair
|
||||
$token = $client->createToken(
|
||||
array(
|
||||
'pairingCode' => $pairingCode,
|
||||
'label' => 'Integrations Testing',
|
||||
'id' => (string) $sinKey,
|
||||
)
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
$this->error = $e;
|
||||
} finally {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^they will receive a "([^"]*)" matching \'([^\']*)\'$/
|
||||
*/
|
||||
public function theyWillReceiveAnErrorMatching($expectedErrorName, $expectedErrorMessage)
|
||||
{
|
||||
$curlError = $this->error;
|
||||
$curlErrorMessage = $this->error->getMessage();
|
||||
if (strpos($curlErrorMessage, $expectedErrorMessage) === false) {
|
||||
throw new Exception("Error message incorrect: ".$curlErrorMessage, 1);
|
||||
}
|
||||
if (strpos(get_class($curlError), $expectedErrorName) === false) {
|
||||
throw new Exception("Error name incorrect: ".get_class($curlError), 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^the client fails to pair with BitPay because (open|closed) port ([0-9]+) is an incorrect port$/
|
||||
*/
|
||||
public function theClientFailsToPairWithBitpayBecauseOfAnIncorrectPort($status, $port)
|
||||
{
|
||||
try {
|
||||
// Stupid rate limiters
|
||||
$this->mink->getSession()->wait(1500);
|
||||
|
||||
// Create Keys
|
||||
list($privateKey, $publicKey, $sinKey) = generateAndPersistKeys();
|
||||
|
||||
//Set Client
|
||||
$url = parse_url($this->base_url, PHP_URL_HOST);
|
||||
$network = new \Bitpay\Network\Customnet($url, $port, true);
|
||||
$curl_options = array(
|
||||
CURLOPT_SSL_VERIFYPEER => false,
|
||||
CURLOPT_SSL_VERIFYHOST => false,
|
||||
CURLOPT_TIMEOUT => 5,
|
||||
);
|
||||
$client = createClient($network, $privateKey, $publicKey, $curl_options);
|
||||
|
||||
// Pair
|
||||
$token = $client->createToken(
|
||||
array(
|
||||
'pairingCode' => 'aaaaaaa',
|
||||
'label' => 'Integrations Testing',
|
||||
'id' => (string) $sinKey,
|
||||
)
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
$this->error = $e;
|
||||
} finally {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^that a user knows an invoice id$/
|
||||
*/
|
||||
public function thatAUserKnowsAnInvoiceId()
|
||||
{
|
||||
if(true == !file_exists('/tmp/token.json') || true == !file_exists('/tmp/bitpay.pri') || true == !file_exists('/tmp/bitpay.pub')){
|
||||
$this->theUserPairsWithBitpayWithAValidPairingCode();
|
||||
$this->theUserIsPairedWithBitpay();
|
||||
}
|
||||
$this->theUserCreatesAnInvoiceFor(1.99, 'USD');
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^they can retrieve that invoice$/
|
||||
*/
|
||||
public function theyCanRetrieveThatInvoice()
|
||||
{
|
||||
try
|
||||
{
|
||||
$network = $this->network;
|
||||
$client = createClient($network);
|
||||
$response = $client->getInvoice($this->invoiceId);
|
||||
} catch (Exception $e){
|
||||
var_dump($e->getMessage());
|
||||
}
|
||||
$responseInvoiceId = $response->getId();
|
||||
if($responseInvoiceId !== $this->invoiceId){
|
||||
throw new Exception("Invoice ids don't match");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,54 +0,0 @@
|
||||
<?php
|
||||
|
||||
function generateAndPersistKeys()
|
||||
{
|
||||
$privateKey = new \Bitpay\PrivateKey('/tmp/bitpay.pri');
|
||||
$privateKey->generate();
|
||||
$publicKey = new \Bitpay\PublicKey('/tmp/bitpay.pub');
|
||||
$publicKey->setPrivateKey($privateKey);
|
||||
$publicKey->generate();
|
||||
$sinKey = new \Bitpay\SinKey('/tmp/sin.key');
|
||||
$sinKey->setPublicKey($publicKey);
|
||||
$sinKey->generate();
|
||||
|
||||
//Persist Keys
|
||||
$storageEngine = new \Bitpay\Storage\EncryptedFilesystemStorage('YourTopSecretPassword');
|
||||
$storageEngine->persist($privateKey);
|
||||
$storageEngine->persist($publicKey);
|
||||
|
||||
return array($privateKey, $publicKey, $sinKey);
|
||||
}
|
||||
|
||||
function loadKeys()
|
||||
{
|
||||
$storageEngine = new \Bitpay\Storage\EncryptedFilesystemStorage('YourTopSecretPassword');
|
||||
$privateKey = $storageEngine->load('/tmp/bitpay.pri');
|
||||
$publicKey = $storageEngine->load('/tmp/bitpay.pub');
|
||||
$token_id = file_get_contents('/tmp/token.json');
|
||||
|
||||
return array($privateKey, $publicKey, $token_id);
|
||||
}
|
||||
|
||||
function createClient($network, $privateKey = null, $publicKey = null, $curl_options = null)
|
||||
{
|
||||
if(true === is_null($curl_options)) {
|
||||
$curl_options = array(
|
||||
CURLOPT_SSL_VERIFYPEER => false,
|
||||
CURLOPT_SSL_VERIFYHOST => false,
|
||||
);
|
||||
}
|
||||
$adapter = new \Bitpay\Client\Adapter\CurlAdapter($curl_options);
|
||||
$client = new \Bitpay\Client\Client();
|
||||
|
||||
if(true === !is_null($privateKey)) {
|
||||
$client->setPrivateKey($privateKey);
|
||||
}
|
||||
if(true === !is_null($publicKey)) {
|
||||
$client->setPublicKey($publicKey);
|
||||
}
|
||||
|
||||
$client->setNetwork($network);
|
||||
$client->setAdapter($adapter);
|
||||
|
||||
return $client;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user