diff --git a/.travis.yml b/.travis.yml
index cce0875c..e77378b2 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,6 +4,7 @@ php:
- 5.4
- 5.5
- 5.6
+ - hhvm
install:
- composer install
@@ -23,8 +24,13 @@ after_script:
notifications:
email: false
+sudo:
+ false
+
matrix:
fast_finish: true
+ allow_failures:
+ - php: hhvm
# Only build the master branch and pull requests for the master branch
branches:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1a5b4843..ba154065 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,25 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## [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
diff --git a/Makefile b/Makefile
index c3d61c37..696d737e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
setup:
- composer.phar install
+ ./composer.phar install
npm install
test:
diff --git a/README.md b/README.md
index 5ab56917..b55b6780 100644
--- a/README.md
+++ b/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"
}
...
}
@@ -48,12 +47,12 @@ php composer.phar update bitpay/php-client
### Install using composer
```bash
-php composer.phar require bitpay/php-client:^2.2
+php composer.phar require bitpay/php-client:^3.0
```
# Configuration
-See https://labs.bitpay.com/t/php-bitpay-client-library-configuration/555
+https://help.bitpay.com/8451-Implementation-/how-to-configure-the-php-bitpay-client-library
# Usage
@@ -65,9 +64,8 @@ instead of composer's autoloader, use the following code:
```php
-
+
-
+
diff --git a/composer.json b/composer.json
index b2951204..c1d88d82 100644
--- a/composer.json
+++ b/composer.json
@@ -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"],
@@ -29,17 +29,17 @@
"ext-json": "*",
"ext-openssl": "*",
"ext-mcrypt": "*",
- "symfony/config": "2.5.*",
- "symfony/dependency-injection": "2.5.*"
+ "symfony/config": "^2.3 || ^3.0",
+ "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/behat": "master-dev",
+ "behat/mink": "master-dev",
+ "behat/mink-extension": "master-dev",
"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",
@@ -54,7 +54,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "2.2.x-dev"
+ "dev-master": "3.0.x-dev"
}
}
}
diff --git a/src/Bitpay/AccessToken.php b/src/Bitpay/AccessToken.php
index 69a02f87..a02819fc 100644
--- a/src/Bitpay/AccessToken.php
+++ b/src/Bitpay/AccessToken.php
@@ -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 @@ public function getId()
}
/**
- * @param string $email
+ * Setter for the email address.
*
- * @return AccessTokenInterface
+ * @param string $email
+ * @return AccessToken
*/
public function setEmail($email)
{
@@ -86,9 +83,10 @@ public function getEmail()
}
/**
- * @param string $label
+ * Setter for the label.
*
- * @return AccessTokenInterface
+ * @param string $label
+ * @return AccessToken
*/
public function setLabel($label)
{
@@ -106,36 +104,4 @@ public function getLabel()
{
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;
- }
}
diff --git a/src/Bitpay/AccessTokenInterface.php b/src/Bitpay/AccessTokenInterface.php
index b701db3a..b32722b9 100644
--- a/src/Bitpay/AccessTokenInterface.php
+++ b/src/Bitpay/AccessTokenInterface.php
@@ -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 @@ public function getEmail();
* @return string
*/
public function getLabel();
-
- /**
- * @return boolean
- */
- public function isNonceDisabled();
}
diff --git a/src/Bitpay/Application.php b/src/Bitpay/Application.php
index 2e6931ca..10c2d923 100644
--- a/src/Bitpay/Application.php
+++ b/src/Bitpay/Application.php
@@ -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 @@ public function getOrgs()
/**
* 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 @@ public function addUser(UserInterface $user)
/**
* 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;
diff --git a/src/Bitpay/ApplicationInterface.php b/src/Bitpay/ApplicationInterface.php
index 63dbbee5..89480994 100644
--- a/src/Bitpay/ApplicationInterface.php
+++ b/src/Bitpay/ApplicationInterface.php
@@ -1,13 +1,13 @@
address = array();
@@ -96,11 +94,10 @@ public function getItems()
}
/**
- * @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 @@ public function getCurrency()
}
/**
- * @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 @@ public function getName()
/**
* @param string $name
- *
- * @return BillInterface
+ * @return Bill
*/
public function setName($name)
{
@@ -163,8 +158,7 @@ public function getAddress()
/**
* @param array $address
- *
- * @return BillInterface
+ * @return Bill
*/
public function setAddress($address)
{
@@ -185,8 +179,7 @@ public function getCity()
/**
* @param string $city
- *
- * @return BillInterface
+ * @return Bill
*/
public function setCity($city)
{
@@ -207,8 +200,7 @@ public function getState()
/**
* @param string $state
- *
- * @return BillInterface
+ * @return Bill
*/
public function setState($state)
{
@@ -229,8 +221,7 @@ public function getZip()
/**
* @param string $zip
- *
- * @return BillInterface
+ * @return Bill
*/
public function setZip($zip)
{
@@ -251,8 +242,7 @@ public function getCountry()
/**
* @param string $country
- *
- * @return BillInterface
+ * @return Bill
*/
public function setCountry($country)
{
@@ -273,8 +263,7 @@ public function getEmail()
/**
* @param string $email
- *
- * @return BillInterface
+ * @return Bill
*/
public function setEmail($email)
{
@@ -295,8 +284,7 @@ public function getPhone()
/**
* @param string $phone
- *
- * @return BillInterface
+ * @return Bill
*/
public function setPhone($phone)
{
@@ -317,8 +305,7 @@ public function getStatus()
/**
* @param string $status
- *
- * @return BillInterface
+ * @return Bill
*/
public function setStatus($status)
{
@@ -339,8 +326,7 @@ public function getShowRate()
/**
* @param string $showRate
- *
- * @return BillInterface
+ * @return Bill
*/
public function setShowRate($showRate)
{
@@ -361,8 +347,7 @@ public function getArchived()
/**
* @param boolean $archived
- *
- * @return BillInterface
+ * @return Bill
*/
public function setArchived($archived)
{
diff --git a/src/Bitpay/BillInterface.php b/src/Bitpay/BillInterface.php
index a957fe82..17cffa11 100644
--- a/src/Bitpay/BillInterface.php
+++ b/src/Bitpay/BillInterface.php
@@ -1,13 +1,13 @@
container = $container;
@@ -50,6 +50,8 @@ public function __construct($config = array(), ContainerInterface $container = n
/**
* Initialize the container
+ *
+ * @param array|string $config
*/
protected function initializeContainer($config)
{
@@ -58,7 +60,10 @@ protected function initializeContainer($config)
}
/**
- * 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 @@ protected function buildContainer($config)
return $container;
}
+ /**
+ * @return array
+ */
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 @@ private function prepareContainer(ContainerInterface $container)
}
/**
- * @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 @@ private function getContainerLoader(ContainerInterface $container)
}
/**
- * 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 @@ private function getDefaultExtensions()
}
/**
- * @return ContainerInterface
+ * @return ContainerBuilder
*/
public function getContainer()
{
@@ -125,7 +134,7 @@ public function getContainer()
}
/**
- * @return mixed
+ * @return object|null
*/
public function get($service)
{
diff --git a/src/Bitpay/Buyer.php b/src/Bitpay/Buyer.php
index a065c961..82681b62 100644
--- a/src/Bitpay/Buyer.php
+++ b/src/Bitpay/Buyer.php
@@ -1,6 +1,6 @@
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 @@ public function sendRequest(RequestInterface $request)
$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 \Exception('[ERROR] In CurlAdapter::sendRequest(): curl_exec failed with the error "' . $errorMessage . '".');
}
- /** @var ResponseInterface */
+ /** @var Response */
$response = Response::createFromRawResponse($raw);
curl_close($curl);
@@ -86,12 +89,12 @@ public function sendRequest(RequestInterface $request)
}
/**
- * 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->getUri(),
@@ -101,7 +104,7 @@ private function getCurlDefaultOptions(RequestInterface $request)
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,
diff --git a/src/Bitpay/Client/Adapter/ca-bundle.crt b/src/Bitpay/Client/Adapter/ca-bundle.crt
index 0838d5de..759a4d6f 100644
--- a/src/Bitpay/Client/Adapter/ca-bundle.crt
+++ b/src/Bitpay/Client/Adapter/ca-bundle.crt
@@ -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
-DFdlc3Rlcm4gQ2FwZTESMBAGA1UEBxMJQ2FwZSBUb3duMR0wGwYDVQQKExRUaGF3dGUgQ29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ure 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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ZMzfmpTMANmvPMZWnmJXbMWbfWVMMdzZmsGd20hdXgPfxiIKeES1hl8eL5
-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-----
-MIIFpDCCA4ygAwIBAgIBATANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEcMBoGA1UEChMT
-QW1lcmljYSBPbmxpbmUgSW5jLjE2MDQGA1UEAxMtQW1lcmljYSBPbmxpbmUgUm9vdCBDZXJ0aWZp
-Y2F0aW9uIEF1dGhvcml0eSAyMB4XDTAyMDUyODA2MDAwMFoXDTM3MDkyOTE0MDgwMFowYzELMAkG
-A1UEBhMCVVMxHDAaBgNVBAoTE0FtZXJpY2EgT25saW5lIEluYy4xNjA0BgNVBAMTLUFtZXJpY2Eg
-T25saW5lIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgMjCCAiIwDQYJKoZIhvcNAQEBBQAD
-ggIPADCCAgoC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Xg
-JXUjhx5c3LqdsKyzadsXg8n33gy8CNyRnqjQ1xU3c6U1uPx+xURABsPr+CKAXEfOAuMRn0T//Zoy
-zH1kUQ7rVyZ2OuMeIjzCpjbdGe+n/BLzJsBZMYVMnNjP36TMzCmT/5RtdlwTCJfy7aULTd3oyWgO
-ZtMADjMSW7yV5TKQqLPGbIOtd+6Lfn6xqavT4fG2wLHqiMDn05DpKJKUe2h7lyoKZy2FAjgQ5ANh
-1NolNscIWC2hp1GvMApJ9aZphwctREZ2jirlmjvXGKL8nDgQzMY70rUXOm/9riW99XJZZLF0Kjhf
-GEzfz3EEWjbUvy+ZnOjZurGV5gJLIaFb1cFPj65pbVPbAZO1XB4Y3WRayhgoPmMEEf0cjQAPuDff
-Z4qdZqkCapH/E8ovXYO8h5Ns3CRRFgQlZvqz2cK6Kb6aSDiCmfS/O0oxGfm/jiEzFMpPVF/7zvuP
-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
-c3RDZW50ZXIgR21iSDEiMCAGA1UEC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s/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-----
+MIIF2DCCA8CgAwIBAgIQTKr5yttjb+Af907YWwOGnTANBgkqhkiG9w0BAQwF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obg2P9A3fvQQoh/ozM6LlweQRGBY84YcWsr7KaKtzFcOmpH4MN5
+WdYgGq/yapiqcrxXStJLnbsQ/LBMQeXtHT1eKJ2czL+zUdqnR+WEUwIDAQABo0IwQDAdBgNVHQ4E
+FgQUu69+Aj36pvE8hI6t7jiY7NkyMtQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8w
+DQYJKoZIhvcNAQEMBQADggIBAArx1UaEt65Ru2yyTUEUAJNMnMvlwFTPoCWOAvn9sKIN9SCYPBMt
+rFaisNZ+EZLpLrqeLppysb0ZRGxhNaKatBYSaVqM4dc+pBroLwP0rmEdEBsqpIt6xf4FpuHA1sj+
+nq6PK7o9mfjYcwlYRm6mnPTXJ9OV2jeDchzTc+CiR5kDOF3VSXkAKRzH7JsgHAckaVd4sjn8OoSg
+tZx8jb8uk2IntznaFxiuvTwJaP+EmzzV1gsD41eeFPfR60/IvYcjt7ZJQ3mFXLrrkguhxuhoqEwW
+sRqZCuhTLJK7oQkYdQxlqHvLI7cawiiFwxv/0Cti76R7CZGYZ4wUAc1oBmpjIXUDgIiKboHGhfKp
+pC3n9KUkEEeDys30jXlYsQab5xoq2Z0B15R97QNKyvDb6KkBPvVWmckejkk9u+UJueBPSZI9FoJA
+zMxZxuY67RIuaTxslbH9qh17f4a+Hg4yRvv7E491f0yLS0Zj/gA0QHDBw7mh3aZw4gSzQbzpgJHq
+ZJx64SIDqZxubw5lT2yHh17zbqD5daWbQOhTsiedSrnAdyGN/4fy3ryM7xfft0kL0fJuMAsaDk52
+7RH89elWsn2/x20Kk4yl0MC2Hb46TpSi125sC8KKfPog88Tk5c0NqMuRkrF8hey1FGlmDoLnzc7I
+LaZRfyHBNVOFBkpdn627G190
+-----END CERTIFICATE-----
+
+USERTrust RSA Certification Authority
+=====================================
+-----BEGIN CERTIFICATE-----
+MIIF3jCCA8agAwIBAgIQAf1tMPyjylGoG7xkDjUDLTANBgkqhkiG9w0BAQwFADCBiDELMAkGA1UE
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MtPAlR1n6BB6T1CZGSlCBst6+
+eLf8ZxXhyVeEHg9j1uliutZfVS7qXMYoCAQlObgOK6nyTJccBz8NUvXt7y+CDwIDAQABo0IwQDAd
+BgNVHQ4EFgQUU3m/WqorSs9UgOHYm8Cd8rIDZsswDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQF
+MAMBAf8wDQYJKoZIhvcNAQEMBQADggIBAFzUfA3P9wF9QZllDHPFUp/L+M+ZBn8b2kMVn54CVVeW
+FPFSPCeHlCjtHzoBN6J2/FNQwISbxmtOuowhT6KOVWKR82kV2LyI48SqC/3vqOlLVSoGIG1VeCkZ
+7l8wXEskEVX/JJpuXior7gtNn3/3ATiUFJVDBwn7YKnuHKsSjKCaXqeYalltiz8I+8jRRa8YFWSQ
+Eg9zKC7F4iRO/Fjs8PRF/iKz6y+O0tlFYQXBl2+odnKPi4w2r78NBc5xjeambx9spnFixdjQg3IM
+8WcRiQycE0xyNN+81XHfqnHd4blsjDwSXWXavVcStkNr/+XeTWYRUc+ZruwXtuhxkYzeSf7dNXGi
+FSeUHM9h4ya7b6NnJSFd5t0dCy5oGzuCr+yDZ4XUmFF0sbmZgIn/f3gZXHlKYC6SQK5MNyosycdi
+yA5d9zZbyuAlJQG03RoHnHcAP9Dc1ew91Pq7P8yF1m9/qS3fuQL39ZeatTXaw2ewh0qpKJ4jjv9c
+J2vhsE/zB+4ALtRZh8tSQZXq9EfX7mRBVXyNWQKV3WKdwrnuWih0hKWbt5DHDAff9Yk2dDLWKMGw
+sAvgnEzDHNb842m1R0aBL6KCq9NjRHDEjf8tM7qtj3u1cIiuPhnPQCjY/MiQu12ZIvVS5ljFH4gx
+Q+6IHdfGjjxDah2nGN59PRbxYvnKkKj9
+-----END CERTIFICATE-----
+
+USERTrust ECC Certification Authority
+=====================================
+-----BEGIN CERTIFICATE-----
+MIICjzCCAhWgAwIBAgIQXIuZxVqUxdJxVt7NiYDMJjAKBggqhkjOPQQDAzCBiDELMAkGA1UEBhMC
+V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NVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAd
+BgNVHQ4EFgQUPeYpSJvqB8ohREom3m7e0oPQn1kwCgYIKoZIzj0EAwMDaAAwZQIxAOVpEslu28Yx
+uglB4Zf4+/2a4n0Sye18ZNPLBSWLVtmg515dTguDnFt2KaAJJiFqYgIwcdK1j1zqO+F4CYWodZI7
+yFz9SO8NdCKoCOJuxUnOxwy8p2Fp8fc74SrL+SvzZpA3
+-----END CERTIFICATE-----
+
+Staat der Nederlanden Root CA - G3
+==================================
+-----BEGIN CERTIFICATE-----
+MIIFdDCCA1ygAwIBAgIEAJiiOTANBgkqhkiG9w0BAQsFADBaMQswCQYDVQQGEwJOTDEeMBwGA1UE
+CgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSswKQYDVQQDDCJTdGFhdCBkZXIgTmVkZXJsYW5kZW4g
+Um9vdCBDQSAtIEczMB4XDTEzMTExNDExMjg0MloXDTI4MTExMzIzMDAwMFowWjELMAkGA1UEBhMC
+TkwxHjAcBgNVBAoMFVN0YWF0IGRlciBOZWRlcmxhbmRlbjErMCkGA1UEAwwiU3RhYXQgZGVyIE5l
+ZGVybGFuZGVuIFJvb3QgQ0EgLSBHMzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAL4y
+olQPcPssXFnrbMSkUeiFKrPMSjTysF/zDsccPVMeiAho2G89rcKezIJnByeHaHE6n3WWIkYFsO2t
+x1ueKt6c/DrGlaf1F2cY5y9JCAxcz+bMNO14+1Cx3Gsy8KL+tjzk7FqXxz8ecAgwoNzFs21v0IJy
+EavSgWhZghe3eJJg+szeP4TrjTgzkApyI/o1zCZxMdFyKJLZWyNtZrVtB0LrpjPOktvA9mxjeM3K
+Tj215VKb8b475lRgsGYeCasH/lSJEULR9yS6YHgamPfJEf0WwTUaVHXvQ9Plrk7O53vDxk5hUUur
+mkVLoR9BvUhTFXFkC4az5S6+zqQbwSmEorXLCCN2QyIkHxcE1G6cxvx/K2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dj3BP1lB0/QFH1T/U67cjF68IeHRaVesd+QnGTbksV
+tzDfqu1XhUisHWrdOWnk4Xl4vs4Fv6EM94B7IWcnMFk=
+-----END CERTIFICATE-----
+
+Staat der Nederlanden EV Root CA
+================================
+-----BEGIN CERTIFICATE-----
+MIIFcDCCA1igAwIBAgIEAJiWjTANBgkqhkiG9w0BAQsFADBYMQswCQYDVQQGEwJOTDEeMBwGA1UE
+CgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSkwJwYDVQQDDCBTdGFhdCBkZXIgTmVkZXJsYW5kZW4g
+RVYgUm9vdCBDQTAeFw0xMDEyMDgxMTE5MjlaFw0yMjEyMDgxMTEwMjhaMFgxCzAJBgNVBAYTAk5M
+MR4wHAYDVQQKDBVTdGFhdCBkZXIgTmVkZXJsYW5kZW4xKTAnBgNVBAMMIFN0YWF0IGRlciBOZWRl
+cmxhbmRlbiBFViBSb290IENBMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA48d+ifkk
+SzrSM4M1LGns3Amk41GoJSt5uAg94JG6hIXGhaTK5skuU6TJJB79VWZxXSzFYGgEt9nCUiY4iKTW
+O0Cmws0/zZiTs1QUWJZV1VD+hq2kY39ch/aO5ieSZxeSAgMs3NZmdO3dZ//BYY1jTw+bbRcwJu+r
+0h8QoPnFfxZpgQNH7R5ojXKhTbImxrpsX23Wr9GxE46prfNeaXUmGD5BKyF/7otdBwadQ8QpCiv8
+Kj6GyzyDOvnJDdrFmeK8eEEzduG/L13lpJhQDBXd4Pqcfzho0LKmeqfRMb1+ilgnQ7O6M5HTp5gV
+XJrm0w912fxBmJc+qiXbj5IusHsMX/FjqTf5m3VpTCgmJdrV8hJwRVXj33NeN/UhbJCONVrJ0yPr
+08C+eKxCKFhmpUZtcALXEPlLVPxdhkqHz3/KRawRWrUgUY0viEeXOcDPusBCAUCZSCELa6fS/ZbV
+0b5GnUngC6agIk440ME8MLxwjyx1zNDFjFE7PZQIZCZhfbnDZY8UnCHQqv0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f8EBAMC
+AQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU7UQZwNPwBovupHu+QucmVMiONnYwDQYJKoZI
+hvcNAQELBQADggIBAA2ukDL2pkt8RHYZYR4nKM1eVO8lvOMIkPkp165oCOGUAFjvLi5+U1KMtlwH
+6oi6mYtQlNeCgN9hCQCTrQ0U5s7B8jeUeLBfnLOic7iPBZM4zY0+sLj7wM+x8uwtLRvM7Kqas6pg
+ghstO8OEPVeKlh6cdbjTMM1gCIOQ045U8U1mwF10A0Cj7oV+wh93nAbowacYXVKV7cndJZ5t+qnt
+ozo00Fl72u1Q8zW/7esUTTHHYPTa8Yec4kjixsU3+wYQ+nVZZjFHKdp2mhzpgq7vmrlR94gjmmmV
+YjzlVYA211QC//G5Xc7UI2/YRYRKW2XviQzdFKcgyxilJbQN+QHwotL0AMh0jqEqSI5l2xPE4iUX
+feu+h1sXIFRRk0pTAwvsXcoz7WL9RccvW9xYoIA55vrX/hMUpu09lEpCdNTDd1lzzY9GvlU47/ro
+kTLql1gEIt44w8y8bckzOmoKaT+gyOpyj4xjhiO9bTyWnpXgSUyqorkqG5w2gXjtw+hG4iZZRHUe
+2XWJUc0QhJ1hYMtd+ZciTY6Y5uN/9lu7rs3KSoFrXgvzUeF0K+l+J6fZmUlO+KWA2yUPHGNiiskz
+Z2s8EIPGrd6ozRaOjfAHN3Gf8qv8QfXBi+wAN10J5U6A7/qxXDgGpRtK4dw4LTzcqx+QGtVKnO7R
+cGzM7vRX+Bi6hG6H
+-----END CERTIFICATE-----
+
+IdenTrust Public Sector Root CA 1
+=================================
+-----BEGIN CERTIFICATE-----
+MIIFZjCCA06gAwIBAgIQCgFCgAAAAUUjz0Z8AAAAAjANBgkqhkiG9w0BAQsFADBNMQswCQYDVQQG
+EwJVUzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3Rv
+ciBSb290IENBIDEwHhcNMTQwMTE2MTc1MzMyWh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4an4EKwt3X9wnQW3IV5B4Jaj0z8yGa5hV+rVHVDRDtfULAj+7A
+mgjVQdZcDiFpboBhDhXAuM/FSRJSzL46zNQuOAXeNf0fb7iAaJg9TaDKQGXSc3z1i9kKlT/YPyNt
+GtEqJBnZhbMX73huqVjRI9PHE+1yJX9dsXNw0H8GlwmEKYBhHfpe/3OsoOOJuBxxFcbeMX8S3OFt
+m6/n6J91eEyrRjuazr8FGF1NFTwWmhlQBJqymm9li1JfPFgEKCXAZmExfrngdbkaqIHWchezxQMx
+NRF4eKLg6TCMf4DfWN88uieW4oA0beOY02QnrEh+KHdcxiVhJfiFDGX6xDIvpZgF5PgLZxYWxoK4
+Mhn5+bl53B/N66+rDt0b20XkeucC4pVd/GnwU2lhlXV5C15V5jgclKlZM57IcXR5f1GJtshquDDI
+ajjDbp7hNxbqBWJMWxJH7ae0s1hWx0nzfxJoCTFx8G34Tkf71oXuxVhAGaQdp/lLQzfcaFpPz+vC
+ZHTetBXZ9FRUGi8c15dxVJCO2SCdUyt/q4/i6jC8UDfv8Ue1fXwsBOxonbRJRBD0ckscZOf85muQ
+3Wl9af0AVqW3rLatt8o+Ae+c
+-----END CERTIFICATE-----
+
+Entrust Root Certification Authority - G2
+=========================================
+-----BEGIN CERTIFICATE-----
+MIIEPjCCAyagAwIBAgIESlOMKDANBgkqhkiG9w0BAQsFADCBvjELMAkGA1UEBhMCVVMxFjAUBgNV
+BAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVy
+bXMxOTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ug
+b25seTEyMDAGA1UEAxMpRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzIw
+HhcNMDkwNzA3MTcyNTU0WhcNMzAxMjA3MTc1NTU0WjCBvjELMAkGA1UEBhMCVVMxFjAUBgNVBAo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8BbGJoX90g5pJ19xO
+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/k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gumentException.php
index 3f1aa746..e1c50369 100644
--- a/src/Bitpay/Client/ArgumentException.php
+++ b/src/Bitpay/Client/ArgumentException.php
@@ -1,7 +1,14 @@
$buyer->getEmail(),
'buyerPhone' => $buyer->getPhone(),
'guid' => Util::guid(),
- 'nonce' => Util::nonce(),
'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'];
$invoiceToken = new \Bitpay\Token();
+ $paymentUrls = new \Bitpay\PaymentUrlSet();
+
$invoice
->setToken($invoiceToken->setToken($data['token']))
->setId($data['id'])
@@ -174,12 +185,13 @@ public function createInvoice(InvoiceInterface $invoice)
->setStatus($data['status'])
->setBtcPrice($data['btcPrice'])
->setPrice($data['price'])
- ->setInvoiceTime($data['invoiceTime'])
- ->setExpirationTime($data['expirationTime'])
- ->setCurrentTime($data['currentTime'])
+ ->setInvoiceTime($data['invoiceTime'] / 1000)
+ ->setExpirationTime($data['expirationTime'] / 1000)
+ ->setCurrentTime($data['currentTime'] / 1000)
->setBtcPaid($data['btcPaid'])
->setRate($data['rate'])
- ->setExceptionStatus($data['exceptionStatus']);
+ ->setExceptionStatus($data['exceptionStatus'])
+ ->setPaymentUrls($paymentUrls->setUrls($data['paymentUrls']));
return $invoice;
}
@@ -192,12 +204,17 @@ public function getCurrencies()
$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
@@ -210,6 +227,7 @@ public function getCurrencies()
->setPluralName($value['plural'])
->setAlts($value['alts'])
->setPayoutFields($value['payoutFields']);
+
$value = $currency;
});
@@ -238,12 +256,12 @@ public function createPayout(PayoutInterface $payout)
'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();
}
@@ -259,21 +277,26 @@ public function createPayout(PayoutInterface $payout)
}
$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'])
@@ -294,9 +317,11 @@ public function getPayouts($status = null)
{
$request = $this->createNewRequest();
$request->setMethod(Request::METHOD_GET);
+
$path = 'payouts?token='
. $this->token->getToken()
. (($status == null) ? '' : '&status=' . $status);
+
$request->setPath($path);
$this->addIdentityHeader($request);
@@ -304,11 +329,14 @@ public function getPayouts($status = null)
$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);
}
@@ -376,12 +404,13 @@ public function deletePayout(PayoutInterface $payout)
$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']);
@@ -396,19 +425,22 @@ public function getPayout($payoutId)
$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'])
@@ -459,12 +491,15 @@ public function getTokens()
$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');
}
@@ -491,31 +526,34 @@ public function getTokens()
public function createToken(array $payload = array())
{
if (isset($payload['pairingCode']) && 1 !== preg_match('/^[a-zA-Z0-9]{7}$/', $payload['pairingCode'])) {
- throw new ArgumentException("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']);
}
$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']);
@@ -523,15 +561,15 @@ public function createToken(array $payload = array())
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
*/
@@ -541,7 +579,7 @@ public function getResponse()
}
/**
- * Returns the request object that was sent to BitPay
+ * Returns the request object that was sent to BitPay.
*
* @return RequestInterface
*/
@@ -557,6 +595,7 @@ public function getInvoice($invoiceId)
{
$this->request = $this->createNewRequest();
$this->request->setMethod(Request::METHOD_GET);
+
if ($this->token->getFacade() === 'merchant') {
$this->request->setPath(sprintf('invoices/%s?token=%s', $invoiceId, $this->token->getToken()));
$this->addIdentityHeader($this->request);
@@ -564,7 +603,9 @@ public function getInvoice($invoiceId)
} 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'])) {
@@ -572,9 +613,10 @@ public function getInvoice($invoiceId)
}
$data = $body['data'];
-
$invoice = new \Bitpay\Invoice();
$invoiceToken = new \Bitpay\Token();
+ $paymentUrls = new \Bitpay\PaymentUrlSet();
+
$invoice
->setToken($invoiceToken->setToken($data['token']))
->setUrl($data['url'])
@@ -584,14 +626,19 @@ public function getInvoice($invoiceId)
->setPrice($data['price'])
->setCurrency(new \Bitpay\Currency($data['currency']))
->setOrderId($data['orderId'])
- ->setInvoiceTime($data['invoiceTime'])
- ->setExpirationTime($data['expirationTime'])
- ->setCurrentTime($data['currentTime'])
+ ->setInvoiceTime($data['invoiceTime'] / 1000)
+ ->setExpirationTime($data['expirationTime'] / 1000)
+ ->setCurrentTime($data['currentTime'] / 1000)
->setId($data['id'])
- ->setBtcPaid($data['btcPrice'])
+ ->setBtcPaid($data['btcPaid'])
->setRate($data['rate'])
->setExceptionStatus($data['exceptionStatus']);
+ if (isset($data['paymentUrls'])) {
+ $invoice
+ ->setPaymentUrls($paymentUrls->setUrls($data['paymentUrls']));
+ }
+
return $invoice;
}
@@ -611,11 +658,12 @@ public function sendRequest(RequestInterface $request)
/**
* @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);
@@ -623,6 +671,7 @@ protected function addIdentityHeader(RequestInterface $request)
/**
* @param RequestInterface $request
+ * @throws \Exception
*/
protected function addSignatureHeader(RequestInterface $request)
{
@@ -667,26 +716,38 @@ protected function createNewRequest()
/**
* 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
+ * @throws \Exception
+ */
protected function checkPriceAndCurrency($price, $currency)
{
- //get the decimal precision of the price
- $decimalPrecision = strlen(substr($price, strpos($price, '.')+1));
- if (($decimalPrecision > 2 && $currency != "BTC") || $decimalPrecision > 6) {
- throw new ArgumentException("Incorrect price format");
+ // Get the decimal precision of the price
+ $decimalPosition = strpos($price, '.');
+ if ($decimalPosition == 0) {
+ $decimalPrecision = 0;
+ } else {
+ $decimalPrecision = strlen(substr($price, $decimalPosition + 1));
+ }
+
+ if (($decimalPrecision > 2 && $currency != 'BTC') || $decimalPrecision > 6) {
+ throw new \Exception('Incorrect price format or currency type.');
}
}
}
diff --git a/src/Bitpay/Client/ClientInterface.php b/src/Bitpay/Client/ClientInterface.php
index 5c165a26..b63b450a 100644
--- a/src/Bitpay/Client/ClientInterface.php
+++ b/src/Bitpay/Client/ClientInterface.php
@@ -1,6 +1,6 @@
headers;
+
foreach ($headers as $header => $value) {
if (empty($header) || empty($value)) {
unset($headers[$header]);
@@ -205,9 +203,13 @@ public function getHeaders()
return $headers;
}
+ /**
+ * @return array
+ */
public function getHeaderFields()
{
$fields = array();
+
foreach ($this->getHeaders() as $header => $value) {
$fields[] = sprintf('%s: %s', $header, $value);
}
@@ -227,20 +229,22 @@ public function getHeadersAsString()
$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;
}
@@ -253,9 +257,10 @@ public function getBody()
}
/**
- * The the body of the request
+ * Sets the body of the request.
*
* @param string $body
+ * @return Request
*/
public function setBody($body)
{
@@ -275,6 +280,7 @@ public function getPath()
/**
* @param string $host
+ * @return Request
*/
public function setPath($path)
{
diff --git a/src/Bitpay/Client/RequestInterface.php b/src/Bitpay/Client/RequestInterface.php
index 7042f031..626b8719 100644
--- a/src/Bitpay/Client/RequestInterface.php
+++ b/src/Bitpay/Client/RequestInterface.php
@@ -1,13 +1,12 @@
headers = array();
@@ -48,26 +46,31 @@ public function __construct($raw = null)
*/
public function __toString()
{
- return (string) $this->raw;
+ return (string)$this->raw;
}
/**
+ * @param Response
*/
public static function createFromRawResponse($rawResponse)
{
$response = new self($rawResponse);
$lines = preg_split('/(\\r?\\n)/', $rawResponse);
$linesLen = count($lines);
+
for ($i = 0; $i < $linesLen; $i++) {
if (0 == $i) {
preg_match('/^HTTP\/(\d\.\d)\s(\d+)\s(.+)/', $lines[$i], $statusLine);
+
$response->setStatusCode($statusCode = $statusLine[2]);
+
continue;
}
if (empty($lines[$i])) {
$body = array_slice($lines, $i + 1);
$response->setBody(implode("\n", $body));
+
break;
}
@@ -90,12 +93,11 @@ public function getStatusCode()
/**
* @param integer
- *
- * @return ResponseInterface
+ * @return Response
*/
public function setStatusCode($statusCode)
{
- $this->statusCode = (integer) $statusCode;
+ $this->statusCode = (integer)$statusCode;
return $this;
}
@@ -112,6 +114,7 @@ public function getBody()
* Set the body of the response
*
* @param string $body
+ * @return Response
*/
public function setBody($body)
{
@@ -131,6 +134,7 @@ public function getHeaders()
/**
* @param string $header
* @param string $value
+ * @return Response
*/
public function setHeader($header, $value)
{
diff --git a/src/Bitpay/Client/ResponseInterface.php b/src/Bitpay/Client/ResponseInterface.php
index 11664d23..9a617e70 100644
--- a/src/Bitpay/Client/ResponseInterface.php
+++ b/src/Bitpay/Client/ResponseInterface.php
@@ -1,13 +1,12 @@
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('network')
- ->values(array('livenet', 'testnet'))
+ ->values($this->networks)
->info('Network')
- ->defaultValue('livenet')
+ ->defaultValue($this->networks[0])
->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')
@@ -61,11 +69,13 @@ public function getConfigTreeBuilder()
}
/**
- * 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()
{
@@ -74,7 +84,7 @@ protected function addKeyStorageNode()
$node
->info('Class that is used to store your keys')
- ->defaultValue('Bitpay\Storage\EncryptedFilesystemStorage')
+ ->defaultValue($this->defstorage)
->validate()
->always()
->then(function ($value) {
@@ -88,13 +98,8 @@ protected function addKeyStorageNode()
}
// 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;
@@ -103,4 +108,28 @@ protected function addKeyStorageNode()
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;
+ }
}
diff --git a/src/Bitpay/Currency.php b/src/Bitpay/Currency.php
index faab33ba..f2bb33a1 100644
--- a/src/Bitpay/Currency.php
+++ b/src/Bitpay/Currency.php
@@ -1,6 +1,6 @@
@@ -31,7 +31,7 @@
-
+
%bitpay.key_storage_password%
@@ -39,11 +39,11 @@
-
+
%bitpay.public_key%
-
+
%bitpay.private_key%
diff --git a/src/Bitpay/Invoice.php b/src/Bitpay/Invoice.php
index f1ec688d..9c774401 100644
--- a/src/Bitpay/Invoice.php
+++ b/src/Bitpay/Invoice.php
@@ -1,13 +1,14 @@
transactionSpeed = self::TRANSACTION_SPEED_MEDIUM;
- $this->fullNotifications = false;
+ $this->currency = $currency;
+ $this->transactionSpeed = $transactionSpeed;
+ $this->fullNotifications = $fullNotifications;
+ $this->item = $item;
+ $this->orderId = $orderId;
+ $this->posData = $posData;
}
/**
@@ -130,18 +138,21 @@ public function __construct()
*/
public function getPrice()
{
- return $this->getItem()->getPrice();
+ if (is_a($this->item, '\Bitpay\Item')) {
+ return $this->getItem()->getPrice();
+ } else {
+ return 0.000000;
+ }
}
/**
* @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;
@@ -152,17 +163,20 @@ public function setPrice($price)
*/
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;
}
@@ -174,10 +188,7 @@ public function setCurrency(CurrencyInterface $currency)
*/
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();
}
@@ -186,12 +197,11 @@ public function getItem()
/**
* @param ItemInterface $item
- *
- * @return InvoiceInterface
+ * @return Invoice
*/
public function setItem(ItemInterface $item)
{
- if (!empty($item)) {
+ if (is_a($item, '\Bitpay\Item')) {
$this->item = $item;
}
@@ -203,8 +213,7 @@ public function setItem(ItemInterface $item)
*/
public function getBuyer()
{
- // Same logic as getItem method
- if (null == $this->buyer) {
+ if ($this->buyer === null) {
$this->buyer = new Buyer();
}
@@ -213,12 +222,11 @@ public function getBuyer()
/**
* @param BuyerInterface $buyer
- *
- * @return InvoiceInterface
+ * @return Invoice
*/
public function setBuyer(BuyerInterface $buyer)
{
- if (!empty($buyer)) {
+ if (is_a($buyer, '\Bitpay\Buyer')) {
$this->buyer = $buyer;
}
@@ -235,13 +243,20 @@ public function getTransactionSpeed()
/**
* @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;
@@ -257,12 +272,11 @@ public function getNotificationEmail()
/**
* @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);
}
@@ -279,12 +293,11 @@ public function getNotificationUrl()
/**
* @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);
}
@@ -301,12 +314,11 @@ public function getRedirectUrl()
/**
* @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);
}
@@ -323,12 +335,11 @@ public function getPosData()
/**
* @param string $posData
- *
- * @return InvoiceInterface
+ * @return Invoice
*/
public function setPosData($posData)
{
- if (!empty($posData)) {
+ if (is_string($posData)) {
$this->posData = $posData;
}
@@ -345,12 +356,11 @@ public function getStatus()
/**
* @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);
}
@@ -382,12 +392,11 @@ public function getId()
/**
* @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);
}
@@ -404,12 +413,11 @@ public function getUrl()
/**
* @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);
}
@@ -426,13 +434,12 @@ public function getBtcPrice()
/**
* @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;
@@ -447,16 +454,18 @@ public function getInvoiceTime()
}
/**
- * @param DateTime $invoiceTime
- *
- * @return InvoiceInterface
+ * @param \DateTime $invoiceTime
+ * @return Invoice
*/
public function setInvoiceTime($invoiceTime)
{
- if (!empty($invoiceTime)) {
+ if (is_a($invoiceTime, 'DateTime')) {
$this->invoiceTime = $invoiceTime;
+ } else if (is_numeric($invoiceTime)) {
+ $invoiceDateTime = new \DateTime();
+ $invoiceDateTime->setTimestamp($invoiceTime);
+ $this->invoiceTime = $invoiceDateTime;
}
-
return $this;
}
@@ -469,16 +478,18 @@ public function getExpirationTime()
}
/**
- * @param DateTime $expirationTime
- *
- * return InvoiceInterface
+ * @param \DateTime $expirationTime
+ * return Invoice
*/
public function setExpirationTime($expirationTime)
{
- if (!empty($expirationTime)) {
+ if (is_a($expirationTime, 'DateTime')) {
$this->expirationTime = $expirationTime;
+ } else if (is_numeric($expirationTime)) {
+ $expirationDateTime = new \DateTime();
+ $expirationDateTime->setTimestamp($expirationTime);
+ $this->expirationTime = $expirationDateTime;
}
-
return $this;
}
@@ -491,14 +502,17 @@ public function getCurrentTime()
}
/**
- * @param DateTime $currentTime
- *
- * @return InvoiceInterface
+ * @param \DateTime $currentTime
+ * @return Invoice
*/
public function setCurrentTime($currentTime)
{
- if (!empty($currentTime)) {
+ if (is_a($currentTime, 'DateTime')) {
$this->currentTime = $currentTime;
+ } else if (is_numeric($currentTime)) {
+ $currentDateTime = new \DateTime();
+ $currentDateTime->setTimestamp($currentTime);
+ $this->currentTime = $currentDateTime;
}
return $this;
@@ -514,12 +528,11 @@ public function getOrderId()
/**
* @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);
}
@@ -558,7 +571,7 @@ public function getBuyerName()
$firstName = $this->getBuyer()->getFirstName();
$lastName = $this->getBuyer()->getLastName();
- return trim($firstName.' '.$lastName);
+ return trim($firstName . ' ' . $lastName);
}
/**
@@ -639,8 +652,7 @@ public function getExceptionStatus()
/**
* @param
- *
- * @return InvoiceInterface
+ * @return Invoice
*/
public function setExceptionStatus($exceptionStatus)
{
@@ -663,7 +675,7 @@ public function getBtcPaid()
*/
public function setBtcPaid($btcPaid)
{
- if (isset($btcPaid)) {
+ if (is_numeric($btcPaid)) {
$this->btcPaid = $btcPaid;
}
@@ -685,8 +697,8 @@ public function getRate()
*/
public function setRate($rate)
{
- if (!empty($rate)) {
- $this->rate = $rate;
+ if (is_numeric($rate)) {
+ $this->rate = floatval($rate);
}
return $this;
@@ -699,13 +711,49 @@ public function getToken()
{
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;
+ }
+
+ /**
+ * @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);
+ }
}
diff --git a/src/Bitpay/InvoiceInterface.php b/src/Bitpay/InvoiceInterface.php
index 3ea4f518..7323aab7 100644
--- a/src/Bitpay/InvoiceInterface.php
+++ b/src/Bitpay/InvoiceInterface.php
@@ -1,14 +1,12 @@
physical = false;
@@ -56,7 +53,6 @@ public function getCode()
/**
* @param string $code
- *
* @return ItemInterface
*/
public function setCode($code)
@@ -76,7 +72,6 @@ public function getDescription()
/**
* @param string $description
- *
* @return ItemInterface
*/
public function setDescription($description)
@@ -88,8 +83,6 @@ public function setDescription($description)
/**
* @inheritdoc
- *
- * @return float
*/
public function getPrice()
{
@@ -98,8 +91,7 @@ public function getPrice()
/**
* @param mixed $price A float, integer, or en_US formatted numeric string
- *
- * @return ItemInterface
+ * @return Item
*/
public function setPrice($price)
{
@@ -122,8 +114,7 @@ public function getQuantity()
/**
* @param integer $quantity
- *
- * @return ItemInterface
+ * @return Item
*/
public function setQuantity($quantity)
{
@@ -142,8 +133,7 @@ public function isPhysical()
/**
* @param boolean $physical
- *
- * @return ItemInterface
+ * @return Item
*/
public function setPhysical($physical)
{
@@ -162,7 +152,7 @@ public function setPhysical($physical)
protected function checkPriceFormat($price)
{
if (preg_match('/^[0-9]+?[\.,][0-9]{1,6}?$/', $price) !== 1) {
- throw new \Bitpay\Client\ArgumentException("Price must be formatted as a float");
+ throw new \Bitpay\Client\ArgumentException('[ERROR] In Item::checkPriceFormat(): Price value must be formatted as a float.');
}
}
}
diff --git a/src/Bitpay/ItemInterface.php b/src/Bitpay/ItemInterface.php
index 36e2dc58..ea96ea5d 100644
--- a/src/Bitpay/ItemInterface.php
+++ b/src/Bitpay/ItemInterface.php
@@ -1,6 +1,6 @@
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;
+ }
+}
diff --git a/src/Bitpay/Payout.php b/src/Bitpay/Payout.php
index 7195d886..e839b2fd 100644
--- a/src/Bitpay/Payout.php
+++ b/src/Bitpay/Payout.php
@@ -6,6 +6,8 @@
namespace Bitpay;
+date_default_timezone_set('UTC');
+
/**
* Class Payout
* @package Bitpay
diff --git a/src/Bitpay/PayoutInstruction.php b/src/Bitpay/PayoutInstruction.php
index 973c1583..4a6a9e74 100644
--- a/src/Bitpay/PayoutInstruction.php
+++ b/src/Bitpay/PayoutInstruction.php
@@ -6,6 +6,8 @@
namespace Bitpay;
+date_default_timezone_set('UTC');
+
/**
* Class PayoutInstruction
* @package Bitpay
diff --git a/src/Bitpay/PrivateKey.php b/src/Bitpay/PrivateKey.php
index b7120b2b..bc0c833a 100644
--- a/src/Bitpay/PrivateKey.php
+++ b/src/Bitpay/PrivateKey.php
@@ -1,6 +1,6 @@
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);
@@ -104,9 +104,11 @@ public function hasValidDec()
}
/**
- * Creates an ECDSA signature of $message
+ * Creates an ECDSA signature of $data.
*
+ * @param string
* @return string
+ * @throws \Exception
*/
public function sign($data)
{
@@ -122,19 +124,19 @@ public function sign($data)
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);
@@ -142,11 +144,10 @@ public function sign($data)
$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));
@@ -198,42 +199,44 @@ public static function serializeSig($r, $s)
$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]), '0x80') >= 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]), '0x80') >= 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;
@@ -244,6 +247,7 @@ public static function serializeSig($r, $s)
*
* @param string $pem_data The data to decode.
* @return array The keypair info.
+ * @throws \Exception
*/
public function pemDecode($pem_data)
{
@@ -293,6 +297,7 @@ public function pemDecode($pem_data)
*
* @param array $keypair The keypair info.
* @return string The data to decode.
+ * @throws \Exception
*/
public function pemEncode($keypair)
{
@@ -329,7 +334,7 @@ public function pemEncode($keypair)
'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-----';
@@ -341,16 +346,16 @@ public function pemEncode($keypair)
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;
diff --git a/src/Bitpay/PublicKey.php b/src/Bitpay/PublicKey.php
index 50bb9dd5..cb9173aa 100644
--- a/src/Bitpay/PublicKey.php
+++ b/src/Bitpay/PublicKey.php
@@ -1,6 +1,6 @@
x = $RxHex;
$this->y = $RyHex;
+
$this->hex = sprintf('%s%s', $RxHex, $RyHex);
$this->dec = Util::decodeHex($this->hex);
@@ -139,6 +142,7 @@ public function getSin()
if (null === $this->sin) {
$this->sin = new SinKey();
+
$this->sin->setPublicKey($this);
$this->sin->generate();
}
diff --git a/src/Bitpay/SinKey.php b/src/Bitpay/SinKey.php
index 09fce7b4..e4b7eca9 100644
--- a/src/Bitpay/SinKey.php
+++ b/src/Bitpay/SinKey.php
@@ -1,6 +1,6 @@
value = Base58::encode($step6);
diff --git a/src/Bitpay/Storage/EncryptedFilesystemStorage.php b/src/Bitpay/Storage/EncryptedFilesystemStorage.php
index 2424026a..00407cbe 100644
--- a/src/Bitpay/Storage/EncryptedFilesystemStorage.php
+++ b/src/Bitpay/Storage/EncryptedFilesystemStorage.php
@@ -1,12 +1,13 @@
getId();
- $data = serialize($key);
- $encoded = bin2hex(openssl_encrypt(
- $data,
- self::METHOD,
- $this->password,
- 1,
- self::IV
- ));
-
- file_put_contents($path, $encoded);
+ $path = $key->getId();
+ $data = serialize($key);
+
+ $encrypted = $this->dataEncrypt($data);
+ $encoded = $this->dataEncode($encrypted);
+
+ $this->saveToFile($encoded, $path);
}
/**
@@ -61,21 +58,120 @@ public function persist(\Bitpay\KeyInterface $key)
*/
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() . '".');
+ }
+
+ 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() . '".');
}
- if (!is_readable($id)) {
- throw new \Exception(sprintf('"%s" cannot be read, check permissions', $id));
+ return $decrypted;
+ }
+
+ /**
+ * @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 . '".');
}
- $encoded = file_get_contents($id);
- $decoded = openssl_decrypt(\Bitpay\Util\Util::binConv($encoded), self::METHOD, $this->password, 1, self::IV);
+ return $encoded;
+ }
+
+ /**
+ * @param string $data
+ * @return string
+ * @throws \Exception
+ */
+ private function dataDecode($data)
+ {
+ $decoded = base64_decode($data);
+
+ if ($decoded === false) {
+ throw new \Exception('[ERROR] In EncryptedFilesystemStorage::dataDecode(): Could not decode data "' . $data . '".');
+ }
+
+ 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 = '';
- if (false === $decoded) {
- throw new \Exception('Could not decode key');
+ while ($msg = openssl_error_string()) {
+ $openssl_error_msg .= $msg . "\r\n";
}
- return unserialize($decoded);
+ return $openssl_error_msg;
}
}
diff --git a/src/Bitpay/Storage/FilesystemStorage.php b/src/Bitpay/Storage/FilesystemStorage.php
index b84a996a..7bf8cfc6 100644
--- a/src/Bitpay/Storage/FilesystemStorage.php
+++ b/src/Bitpay/Storage/FilesystemStorage.php
@@ -1,13 +1,15 @@
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 @@ public function persist(\Bitpay\KeyInterface $key)
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));
diff --git a/src/Bitpay/Storage/MockStorage.php b/src/Bitpay/Storage/MockStorage.php
index 5cc1d1b0..fc5635b8 100644
--- a/src/Bitpay/Storage/MockStorage.php
+++ b/src/Bitpay/Storage/MockStorage.php
@@ -1,6 +1,6 @@
policies = array();
@@ -58,7 +58,7 @@ public function __construct()
*/
public function __toString()
{
- return (string) $this->getToken();
+ return (string)$this->getToken();
}
/**
@@ -69,6 +69,10 @@ public function getToken()
return $this->token;
}
+ /**
+ * @param string
+ * @return Token
+ */
public function setToken($token)
{
$this->token = $token;
@@ -84,6 +88,10 @@ public function getResource()
return $this->resource;
}
+ /**
+ * @param string
+ * @return Token
+ */
public function setResource($resource)
{
$this->resource = $resource;
@@ -99,6 +107,10 @@ public function getFacade()
return $this->facade;
}
+ /**
+ * @param string
+ * @return Token
+ */
public function setFacade($facade)
{
$this->facade = $facade;
@@ -114,6 +126,10 @@ public function getCreatedAt()
return $this->createdAt;
}
+ /**
+ * @param \DateTime
+ * @return Token
+ */
public function setCreatedAt(\DateTime $createdAt)
{
$this->createdAt = $createdAt;
@@ -129,6 +145,10 @@ public function getPolicies()
return $this->policies;
}
+ /**
+ * @param string
+ * @return Token
+ */
public function setPolicies($policies)
{
$this->policies = $policies;
@@ -143,11 +163,15 @@ public function getPairingCode()
{
return $this->pairingCode;
}
-
+
+ /**
+ * @param string
+ * @return Token
+ */
public function setPairingCode($pairingCode)
{
$this->pairingCode = $pairingCode;
-
+
return $this;
}
@@ -159,6 +183,10 @@ public function getPairingExpiration()
return $this->pairingExpiration;
}
+ /**
+ * @param \DateTime
+ * @return Token
+ */
public function setPairingExpiration(\DateTime $pairingExpiration)
{
$this->pairingExpiration = $pairingExpiration;
diff --git a/src/Bitpay/TokenInterface.php b/src/Bitpay/TokenInterface.php
index eeb774d4..96790dd5 100644
--- a/src/Bitpay/TokenInterface.php
+++ b/src/Bitpay/TokenInterface.php
@@ -1,6 +1,6 @@
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 @@ public static function encode($data)
}
/**
- * 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 @@ public static function decode($data)
$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;
diff --git a/src/Bitpay/Util/CurveParameterInterface.php b/src/Bitpay/Util/CurveParameterInterface.php
index 683f8ded..0d690ae3 100644
--- a/src/Bitpay/Util/CurveParameterInterface.php
+++ b/src/Bitpay/Util/CurveParameterInterface.php
@@ -1,13 +1,11 @@
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 @@ public static function encodeHex($dec)
*
* @param string $hex
* @return string
+ * @throws \Exception
*/
public static function decodeHex($hex)
{
@@ -174,7 +162,7 @@ public static function decodeHex($hex)
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 @@ public static function decodeHex($hex)
}
$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 @@ public static function doubleAndAdd($hex, PointInterface $point, CurveParameterI
* 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,13 +225,15 @@ public static function decToBin($dec)
}
$bin = '';
+
while (Math::cmp($dec, '0') > 0) {
- if (Math::mod($dec, 2) == '1') {
+ if (Math::mod($dec, '2') == '1') {
$bin .= '1';
} else {
$bin .= '0';
}
- $dec = Math::div($dec, 2);
+
+ $dec = Math::div($dec, '2');
}
return $bin;
@@ -247,9 +245,10 @@ public static function decToBin($dec)
* 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)
{
@@ -273,41 +272,38 @@ public static function pointDouble(PointInterface $point, CurveParameterInterfac
// 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)
@@ -324,8 +320,9 @@ public static function pointAdd(PointInterface $P, PointInterface $Q)
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,
@@ -351,10 +348,11 @@ public static function pointAdd(PointInterface $P, PointInterface $Q)
),
$p
);
+
$R['y'] = Math::mod(
Math::add(
Math::sub(
- 0,
+ '0',
$P->getY()
),
Math::mul(
@@ -370,18 +368,17 @@ public static function pointAdd(PointInterface $P, PointInterface $Q)
$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
- *
- * @param string
+ * Converts hex value into octet (byte) string.
*
- * @return string
+ * @param string $hex
+ * @return string $byte
*/
public static function binConv($hex)
{
@@ -395,21 +392,21 @@ public static function binConv($hex)
}
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
*/
@@ -422,6 +419,7 @@ public static function checkRequirements()
$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 {
@@ -454,8 +452,9 @@ public static function checkRequirements()
$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 {
diff --git a/tests/Bitpay/AccessTokenTest.php b/tests/Bitpay/AccessTokenTest.php
index 2159603e..a469fd6e 100644
--- a/tests/Bitpay/AccessTokenTest.php
+++ b/tests/Bitpay/AccessTokenTest.php
@@ -1,6 +1,6 @@
assertNotNull($token);
-
$token->setId('test');
-
$this->assertSame('test', $token->getId());
}
@@ -24,9 +22,7 @@ public function testEmail()
$token = new AccessToken();
$this->assertNotNull($token);
-
$token->setEmail('support@bitpay.com');
-
$this->assertSame('support@bitpay.com', $token->getEmail());
}
@@ -35,40 +31,7 @@ public function testLabel()
$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());
- }
}
diff --git a/tests/Bitpay/ApplicationTest.php b/tests/Bitpay/ApplicationTest.php
index 7cd700da..23627b72 100644
--- a/tests/Bitpay/ApplicationTest.php
+++ b/tests/Bitpay/ApplicationTest.php
@@ -1,6 +1,6 @@
assertNotNull($application);
-
$this->assertInternalType('array', $application->getUsers());
$this->assertEmpty($application->getUsers());
}
@@ -26,7 +25,6 @@ public function testAddUser()
$application = new Application();
$this->assertNotNull($application);
-
$application->addUser($this->getMockUser());
$this->assertInternalType('array', $application->getUsers());
@@ -38,7 +36,6 @@ public function testGetOrgs()
$application = new Application();
$this->assertNotNull($application);
-
$this->assertInternalType('array', $application->getOrgs());
$this->assertEmpty($application->getOrgs());
}
@@ -51,7 +48,6 @@ public function testAddOrg()
$application = new Application();
$this->assertNotNull($application);
-
$application->addOrg($this->getMockOrg());
$this->assertInternalType('array', $application->getOrgs());
@@ -60,11 +56,11 @@ public function testAddOrg()
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');
}
}
diff --git a/tests/Bitpay/AutoloaderTest.php b/tests/Bitpay/AutoloaderTest.php
index 1dbebf56..6db3cf6a 100644
--- a/tests/Bitpay/AutoloaderTest.php
+++ b/tests/Bitpay/AutoloaderTest.php
@@ -1,6 +1,6 @@
assertNotNull($this->bill);
- $this->assertInstanceOf('Bitpay\CurrencyInterface', $this->bill->getCurrency());
+ $this->assertInstanceOf('Bitpay\Currency', $this->bill->getCurrency());
}
/**
@@ -45,7 +45,7 @@ public function testSetCurrency()
{
$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 @@ public function testGetEmail()
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 @@ public function testSetArchived()
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');
}
}
diff --git a/tests/Bitpay/BitpayTest.php b/tests/Bitpay/BitpayTest.php
index 2b353409..7aa3e65d 100644
--- a/tests/Bitpay/BitpayTest.php
+++ b/tests/Bitpay/BitpayTest.php
@@ -1,6 +1,6 @@
temp_path_root = 'tmp';
+ $this->temp_path_pri = $this->temp_path_root . '/key.pri';
+ $this->temp_path_pub = $this->temp_path_root . '/key.pub';
+ $this->network_type = 'testnet';
+ }
public function testConstruct()
{
$bitpay = new \Bitpay\Bitpay(
array(
'bitpay' => array(
- 'network' => 'testnet',
+ 'network' => $this->network_type,
)
)
);
@@ -25,7 +37,7 @@ public function testConstruct()
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()
@@ -45,20 +57,21 @@ public function testGetInvalidService()
public function testConfigAbleToPersistAndLoadKeys()
{
- $root = vfsStream::setup('tmp');
+ $root = vfsStream::setup($this->temp_path_root);
$bitpay = new \Bitpay\Bitpay(
array(
'bitpay' => array(
'network' => 'testnet',
- '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();
/**
diff --git a/tests/Bitpay/BuyerTest.php b/tests/Bitpay/BuyerTest.php
index 9570d0fd..1d6b0f53 100644
--- a/tests/Bitpay/BuyerTest.php
+++ b/tests/Bitpay/BuyerTest.php
@@ -1,6 +1,6 @@
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()
diff --git a/tests/Bitpay/Client/Adapter/CurlAdapterTest.php b/tests/Bitpay/Client/Adapter/CurlAdapterTest.php
index b511ab31..7eef08dc 100644
--- a/tests/Bitpay/Client/Adapter/CurlAdapterTest.php
+++ b/tests/Bitpay/Client/Adapter/CurlAdapterTest.php
@@ -1,6 +1,6 @@
setExpectedException('Bitpay\Client\ConnectionException');
+ $this->setExpectedException('\Exception');
$curl_options = array(
CURLOPT_URL => "www.example.com",
@@ -55,5 +55,4 @@ public function testSendRequestWithoutException()
$response = $adapter->sendRequest($this->request);
$this->assertNotNull($response);
}
-
-}
\ No newline at end of file
+}
diff --git a/tests/Bitpay/Client/ClientTest.php b/tests/Bitpay/Client/ClientTest.php
index f0b40e8b..846e0663 100644
--- a/tests/Bitpay/Client/ClientTest.php
+++ b/tests/Bitpay/Client/ClientTest.php
@@ -1,11 +1,18 @@
client->setAdapter($adapter);
}
+ public function testCheckPriceAndCurrency() {
+ $client = new ChildOfClient();
+ $res = $client->checkPriceAndCurrency(.999999, 'BTC');
+ $this->assertNull($res);
+
+ $res = $client->checkPriceAndCurrency(1000, 'USD');
+ $this->assertNull($res);
+
+ $res = $client->checkPriceAndCurrency(0, 'USD');
+ $this->assertNull($res);
+
+ $res = $client->checkPriceAndCurrency(.01, 'USD');
+ $this->assertNull($res);
+
+ $res = $client->checkPriceAndCurrency(99, 'USD');
+ $this->assertNull($res);
+
+ $res = $client->checkPriceAndCurrency(100.9, 'USD');
+ $this->assertNull($res);
+ }
+
+ /**
+ * @expectedException \Exception
+ */
+ public function testCheckPriceAndCurrencyWithException() {
+ $client = new ChildOfClient();
+ $res = $client->checkPriceAndCurrency(.991, 'ABC');
+ }
/**
* @expectedException \Exception
@@ -63,7 +98,7 @@ public function testCreatePayout()
->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)
@@ -73,6 +108,7 @@ public function testCreatePayout()
\Bitpay\PayoutInstruction::STATUS_UNPAID => null,
\Bitpay\PayoutInstruction::STATUS_PAID => '0'
);
+
$instruction0 = new \Bitpay\PayoutInstruction();
$instruction0
->setId('Sra19AFU57Rx53rKQbbRKZ')
@@ -124,7 +160,7 @@ public function testCreatePayout()
$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]);
@@ -134,7 +170,6 @@ public function testCreatePayout()
public function testCreateInvoice()
{
-
$buyer = $this->getMockBuyer();
$buyer->method('getAddress')->will($this->returnValue(array()));
@@ -150,7 +185,6 @@ public function testCreateInvoice()
$item->setPrice('19.95');
$invoice->setItem($item);
-
$response = $this->getMockResponse();
$response->method('getBody')->willReturn(file_get_contents(__DIR__ . '/../../DataFixtures/invoice.json'));
@@ -165,13 +199,19 @@ public function testCreateInvoice()
$this->assertEquals('new', $invoice->getStatus());
$this->assertEquals('0.0632', $invoice->getBtcPrice());
$this->assertEquals(19.95, $invoice->getPrice());
- $this->assertEquals(1412594514486, $invoice->getInvoiceTime());
- $this->assertEquals(1412595414486, $invoice->getExpirationTime());
- $this->assertEquals(1412594514518, $invoice->getCurrentTime());
+ $this->assertEquals(1412594514, $invoice->getInvoiceTime()->getTimestamp());
+ $this->assertEquals(1412595414, $invoice->getExpirationTime()->getTimestamp());
+ $this->assertEquals(1412594514, $invoice->getCurrentTime()->getTimestamp());
$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());
}
/**
@@ -243,7 +283,6 @@ public function testCreateInvoiceWithTooMuchPrecisionForAnythingButBitcoin()
$this->client->createInvoice($invoice);
}
-
/**
* @expectedException Exception
*/
@@ -275,7 +314,7 @@ public function testCreateInvoiceWithTooMuchPrecisionEvenForBitcoin()
$this->client->createInvoice($invoice);
}
-
+
/**
* @depends testCreateInvoice
*/
@@ -364,7 +403,6 @@ public function testGetPayouts()
$payouts = $this->client->getPayouts();
$this->assertInternalType('array', $payouts);
$this->assertInstanceOf('Bitpay\PayoutInterface', $payouts[0]);
-
}
/**
@@ -380,7 +418,6 @@ public function testGetPayoutsWithException()
$this->client->setAdapter($adapter);
$payouts = $this->client->getPayouts();
-
}
public function testGetTokens()
@@ -536,7 +573,6 @@ public function testDeletePayout()
$payout = $this->client->getPayout('7m7hSF3ws1LhnWUf17CXsJ');
-
// Test deletePayout
$response = $this->getMockResponse();
$response->method('getBody')->willReturn(file_get_contents(__DIR__ . '/../../DataFixtures/payouts/cancelled.json'));
@@ -546,7 +582,6 @@ public function testDeletePayout()
$this->client->setAdapter($adapter);
$payout = $this->client->deletePayout($payout);
-
$this->assertSame($payout->getStatus(), \Bitpay\Payout::STATUS_CANCELLED);
}
@@ -566,7 +601,6 @@ public function testDeletePayoutWithException()
$payout = $this->client->getPayout('7m7hSF3ws1LhnWUf17CXsJ');
// Test with exception
-
$response = $this->getMockResponse();
$response->method('getBody')->willReturn('{"error":"Object not found"}');
@@ -578,7 +612,6 @@ public function testDeletePayoutWithException()
$this->assertSame($payout->getStatus(), \Bitpay\Payout::STATUS_CANCELLED);
}
-
private function getMockInvoice()
{
$invoice = $this->getMockBuilder('Bitpay\InvoiceInterface')
@@ -593,6 +626,7 @@ private function getMockInvoice()
'getExceptionStatus', 'getBtcPaid', 'getRate', 'getToken', 'setId', 'setUrl',
'setStatus', 'setBtcPrice', 'setPrice', 'setInvoiceTime', 'setExpirationTime',
'setCurrentTime', 'setBtcPaid', 'setRate', 'setToken', 'setExceptionStatus',
+ 'getPaymentUrls',
)
)
->getMock();
diff --git a/tests/Bitpay/Client/RequestTest.php b/tests/Bitpay/Client/RequestTest.php
index 77999c70..10c33fc0 100644
--- a/tests/Bitpay/Client/RequestTest.php
+++ b/tests/Bitpay/Client/RequestTest.php
@@ -1,6 +1,6 @@
assertSame(444, $this->request->getPort());
}
-
public function testGetSchema()
{
$this->assertSame('https', $this->request->getSchema());
diff --git a/tests/Bitpay/Client/ResponseTest.php b/tests/Bitpay/Client/ResponseTest.php
index 40242cce..8be09a2d 100644
--- a/tests/Bitpay/Client/ResponseTest.php
+++ b/tests/Bitpay/Client/ResponseTest.php
@@ -1,6 +1,6 @@
'I8OFg5parn9b0Qk8mJnQH0+SgQWwYER5'
);
- foreach($data as $unencrypted => $encrypted )
- {
+ foreach ($data as $unencrypted => $encrypted) {
$encryptedtext = $mcrypt->encrypt($unencrypted, $key, '00000000');
$this->assertEquals($encrypted, $encryptedtext);
}
@@ -39,7 +36,6 @@ public function testEncrypt()
public function testDecrypt()
{
-
$mcrypt = new McryptExtension();
$key = 'testEncrypt';
$data = array(
@@ -49,8 +45,7 @@ public function testDecrypt()
'___asdfa234($*(#__' => 'I8OFg5parn9b0Qk8mJnQH0+SgQWwYER5'
);
- foreach($data as $unencrypted => $encrypted )
- {
+ foreach ($data as $unencrypted => $encrypted) {
$plaintext = $mcrypt->decrypt($encrypted, $key, '00000000');
$this->assertEquals($unencrypted, $plaintext);
}
@@ -60,11 +55,11 @@ private function generateRandomString($length = 10)
{
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$randomString = '';
+
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, strlen($characters) - 1)];
}
return $randomString;
}
-
}
diff --git a/tests/Bitpay/CurrencyTest.php b/tests/Bitpay/CurrencyTest.php
index 295cf014..31645534 100644
--- a/tests/Bitpay/CurrencyTest.php
+++ b/tests/Bitpay/CurrencyTest.php
@@ -1,6 +1,6 @@
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()
diff --git a/tests/Bitpay/InvoiceTest.php b/tests/Bitpay/InvoiceTest.php
index 9eab65ea..5a22e471 100644
--- a/tests/Bitpay/InvoiceTest.php
+++ b/tests/Bitpay/InvoiceTest.php
@@ -1,6 +1,6 @@
assertNotNull($this->invoice);
- $this->assertNull($this->invoice->getPrice());
+ $this->assertSame($this->invoice->getPrice(), 0.0);
}
/**
@@ -34,7 +34,7 @@ public function testSetPrice()
public function testGetCurrency()
{
$this->assertNotNull($this->invoice);
- $this->assertNull($this->invoice->getCurrency());
+ $this->assertInstanceOf('Bitpay\Currency', $this->invoice->getCurrency());
}
/**
@@ -85,7 +85,7 @@ public function testSetBuyer()
public function testGetTransactionSpeed()
{
$this->assertNotNull($this->invoice);
- $this->assertSame(Invoice::TRANSACTION_SPEED_MEDIUM, $this->invoice->getTransactionSpeed());
+ $this->assertSame(Invoice::TRANSACTION_SPEED_LOW, $this->invoice->getTransactionSpeed());
}
/**
@@ -101,7 +101,7 @@ public function testSetTransactionSpeed()
public function testGetNotificationEmail()
{
$this->assertNotNull($this->invoice);
- $this->assertNull($this->invoice->getNotificationEmail());
+ $this->assertSame($this->invoice->getNotificationEmail(), '');
}
/**
@@ -110,14 +110,14 @@ public function testGetNotificationEmail()
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 @@ public function testSetNotificationUrl()
public function testGetRedirectUrl()
{
$this->assertNotNull($this->invoice);
- $this->assertNull($this->invoice->getRedirectUrl());
+ $this->assertSame($this->invoice->getRedirectUrl(), '');
}
/**
@@ -149,7 +149,7 @@ public function testSetRedirectUrl()
public function testGetPosData()
{
$this->assertNotNull($this->invoice);
- $this->assertNull($this->invoice->getPosData());
+ $this->assertSame($this->invoice->getPosData(), '');
}
/**
@@ -165,7 +165,7 @@ public function testSetPosData()
public function testGetStatus()
{
$this->assertNotNull($this->invoice);
- $this->assertNull($this->invoice->getStatus());
+ $this->assertSame($this->invoice->getStatus(), '');
}
/**
@@ -187,7 +187,7 @@ public function testIsFullNotifications()
public function testGetId()
{
$this->assertNotNull($this->invoice);
- $this->assertNull($this->invoice->getId());
+ $this->assertSame($this->invoice->getId(), '');
}
/**
@@ -203,7 +203,7 @@ public function testSetId()
public function testGetUrl()
{
$this->assertNotNull($this->invoice);
- $this->assertNull($this->invoice->getUrl());
+ $this->assertSame($this->invoice->getUrl(), '');
}
/**
@@ -219,7 +219,7 @@ public function testSetUrl()
public function testGetBtcPrice()
{
$this->assertNotNull($this->invoice);
- $this->assertNull($this->invoice->getBtcPrice());
+ $this->assertSame($this->invoice->getBtcPrice(), 0.0);
}
/**
@@ -294,7 +294,7 @@ public function testSetCurrentTime()
public function testGetOrderId()
{
$this->assertNotNull($this->invoice);
- $this->assertNull($this->invoice->getOrderId());
+ $this->assertSame($this->invoice->getOrderId(), '');
}
/**
@@ -313,26 +313,12 @@ public function testGetItemDesc()
$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 @@ public function testGetBuyerName()
$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 @@ public function testSetExcpetionStatus()
public function testGetBtcPaid()
{
$this->assertNotNull($this->invoice);
- $this->assertNull($this->invoice->getBtcPaid());
+ $this->assertSame($this->invoice->getBtcPaid(), 0.0);
}
/**
@@ -491,7 +414,7 @@ public function testSetBtcPaid()
public function testGetRate()
{
$this->assertNotNull($this->invoice);
- $this->assertNull($this->invoice->getRate());
+ $this->assertSame($this->invoice->getRate(), 0.0);
}
/**
diff --git a/tests/Bitpay/ItemTest.php b/tests/Bitpay/ItemTest.php
index 8f49a6dc..a50ce469 100644
--- a/tests/Bitpay/ItemTest.php
+++ b/tests/Bitpay/ItemTest.php
@@ -1,6 +1,6 @@
item->setPrice(9.99);
$this->assertSame(9.99, $this->item->getPrice());
@@ -142,7 +143,7 @@ public function testBadStringPrice()
}
/**
- * @expectedException \Bitpay\Client\ArgumentException
+ * @expectedException \Bitpay\Client\ArgumentException
*/
public function testSetPriceExceptionNoNumber()
{
@@ -150,7 +151,7 @@ public function testSetPriceExceptionNoNumber()
}
/**
- * @expectedException \Bitpay\Client\ArgumentException
+ * @expectedException \Bitpay\Client\ArgumentException
*/
public function testSetPriceExceptionDoubleDecimal()
{
diff --git a/tests/Bitpay/KeyManagerTest.php b/tests/Bitpay/KeyManagerTest.php
index 290d04d3..f3fe434e 100644
--- a/tests/Bitpay/KeyManagerTest.php
+++ b/tests/Bitpay/KeyManagerTest.php
@@ -1,6 +1,6 @@
temp_path = '/tmp/mock.key';
+ }
+
public function testConstruct()
{
$storage = $this->getMockStorage();
@@ -41,13 +48,12 @@ public function testLoad()
$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()
diff --git a/tests/Bitpay/Math/BcEngineTest.php b/tests/Bitpay/Math/BcEngineTest.php
index 08c27020..178b7917 100644
--- a/tests/Bitpay/Math/BcEngineTest.php
+++ b/tests/Bitpay/Math/BcEngineTest.php
@@ -1,6 +1,6 @@
markTestSkipped('The Bcmath extension is NOT loaded! You must enable it to run this test');
- } elseif (!extension_loaded('gmp'))
- {
- $this->markTestSkipped('The GMPmath 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');
+ } else if (!extension_loaded('gmp')) {
+ $this->markTestSkipped('The GMPmath extension is NOT loaded! You must enable it to run this test');
+ }
}
public function testConstruct()
@@ -81,7 +78,7 @@ public function testiInvertm()
$this->assertEquals(gmp_strval(gmp_invert($c, $c)), $math->invertm($c, $c));
$this->assertEquals(gmp_strval(gmp_invert(15, 14)), $math->invertm(15, 14));
- $this->assertEquals(gmp_strval(gmp_invert(-1, 1)), $math->invertm(-1, 1));
+ $this->assertEquals(gmp_strval(gmp_invert(-1, 1)), $math->invertm(-1, 1));
$this->assertEquals(0, $math->invertm(1, 1));
$o = '2';
@@ -171,7 +168,8 @@ public function testInput()
);
$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]));
}
}
@@ -211,5 +209,4 @@ public function testCoprime()
$math = new BcEngine();
$this->assertTrue($math->coprime($a, $b));
}
-
}
diff --git a/tests/Bitpay/Math/GmpEngineTest.php b/tests/Bitpay/Math/GmpEngineTest.php
index 4a5cb5f9..b10ea4c0 100644
--- a/tests/Bitpay/Math/GmpEngineTest.php
+++ b/tests/Bitpay/Math/GmpEngineTest.php
@@ -1,6 +1,6 @@
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));
}
}
diff --git a/tests/Bitpay/Math/MathTest.php b/tests/Bitpay/Math/MathTest.php
index 0bdb5f4a..7668772c 100644
--- a/tests/Bitpay/Math/MathTest.php
+++ b/tests/Bitpay/Math/MathTest.php
@@ -1,6 +1,6 @@
assertNull(Math::getEngine());
- $engine = $this->getMock('Bitpay\Math\EngineInterface');
- Math::setEngine($engine);
- $this->assertInstanceOf('Bitpay\Math\EngineInterface', 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');
- } 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());
- }
+ 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());
+ }
+
+ /**
+ * @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());
+ }
}
diff --git a/tests/Bitpay/Network/LivenetTest.php b/tests/Bitpay/Network/LivenetTest.php
index c2acb487..87fe9639 100644
--- a/tests/Bitpay/Network/LivenetTest.php
+++ b/tests/Bitpay/Network/LivenetTest.php
@@ -1,6 +1,6 @@
network = new Livenet();
diff --git a/tests/Bitpay/Network/NetworkAwareTest.php b/tests/Bitpay/Network/NetworkAwareTest.php
index 207dd4ef..204dd008 100644
--- a/tests/Bitpay/Network/NetworkAwareTest.php
+++ b/tests/Bitpay/Network/NetworkAwareTest.php
@@ -1,6 +1,6 @@
setNetwork(new \Bitpay\Network\Testnet());
$r = new \ReflectionObject($networkAware);
+
$network = $r->getProperty('network');
$network->setAccessible(true);
$network = $network->getValue($networkAware);
diff --git a/tests/Bitpay/Network/TestnetTest.php b/tests/Bitpay/Network/TestnetTest.php
index 62405309..b419b7c0 100644
--- a/tests/Bitpay/Network/TestnetTest.php
+++ b/tests/Bitpay/Network/TestnetTest.php
@@ -1,6 +1,6 @@
network = new Testnet();
diff --git a/tests/Bitpay/PayoutInstructionTest.php b/tests/Bitpay/PayoutInstructionTest.php
index 67663f36..4c22416e 100644
--- a/tests/Bitpay/PayoutInstructionTest.php
+++ b/tests/Bitpay/PayoutInstructionTest.php
@@ -1,6 +1,6 @@
assertNotNull($this->instruction->getBtc());
$this->assertSame($btc, $this->instruction->getBtc());
}
+
/**
* @depends testGetAmount
*/
@@ -140,6 +141,7 @@ public function testSetAmount()
$this->assertInternalType('float', $this->instruction->getAmount());
$this->assertSame(10.99, $this->instruction->getAmount());
}
+
/**
* @depends testGetStatus
*/
diff --git a/tests/Bitpay/PayoutTest.php b/tests/Bitpay/PayoutTest.php
index 10b34e0f..6059ae4e 100644
--- a/tests/Bitpay/PayoutTest.php
+++ b/tests/Bitpay/PayoutTest.php
@@ -1,6 +1,6 @@
setLabel($label);
$this->payout->addInstruction($instruction);
-
$this->assertInternalType('array', $this->payout->getInstructions());
$this->assertTrue(count($this->payout->getInstructions()) == 1);
diff --git a/tests/Bitpay/PayoutTransactionTest.php b/tests/Bitpay/PayoutTransactionTest.php
index 826e637a..135a8a29 100644
--- a/tests/Bitpay/PayoutTransactionTest.php
+++ b/tests/Bitpay/PayoutTransactionTest.php
@@ -1,6 +1,6 @@
assertInstanceOf('Bitpay\PointInterface', $pointA);
$this->assertSame('1', $pointA->getX());
$this->assertSame('2', $pointA->getY());
diff --git a/tests/Bitpay/PrivateKeyTest.php b/tests/Bitpay/PrivateKeyTest.php
index 06579dec..d3216e10 100644
--- a/tests/Bitpay/PrivateKeyTest.php
+++ b/tests/Bitpay/PrivateKeyTest.php
@@ -1,6 +1,6 @@
assertNotNull($priKey);
+ $this->assertNotNull($priKey);
$this->assertNull($priKey->getHex());
$this->assertNull($priKey->getDec());
@@ -44,8 +44,11 @@ public function testGenerate()
public function testGenerateCannotHappenTwice()
{
$privateKey = new PrivateKey();
+
$privateKey->generate();
+
$hex = $privateKey->getHex();
+
$privateKey->generate();
$this->assertSame($hex, $privateKey->getHex());
}
@@ -53,10 +56,9 @@ public function testGenerateCannotHappenTwice()
public function testGetHex()
{
$priKey = new PrivateKey();
- $this->assertNotNull($priKey);
+ $this->assertNotNull($priKey);
$this->assertNull($priKey->getHex());
-
$this->assertEquals(0, strlen($priKey->getHex()));
$priKey->generate();
@@ -71,6 +73,7 @@ public function testGetHex()
public function testToString()
{
$priKey = new PrivateKey();
+
$this->assertNotNull($priKey);
// Make sure this is a string
@@ -87,10 +90,9 @@ public function testToString()
public function testGetDec()
{
$priKey = new PrivateKey();
- $this->assertNotNull($priKey);
+ $this->assertNotNull($priKey);
$this->assertNull($priKey->getDec());
-
$this->assertEquals(0, strlen($priKey->getDec()));
$priKey->generate();
@@ -101,8 +103,8 @@ public function testGetDec()
public function testIsValid()
{
$priKey = new PrivateKey();
- $this->assertNotNull($priKey);
+ $this->assertNotNull($priKey);
$this->assertFalse($priKey->isValid());
$priKey->generate();
@@ -113,6 +115,7 @@ public function testIsValid()
public function testSign()
{
$priKey = new PrivateKey();
+
$priKey->generate();
// Make sure not exceptions are thrown
@@ -122,8 +125,8 @@ public function testSign()
public function testHasValidHex()
{
$priKey = new PrivateKey();
- $this->assertNotNull($priKey);
+ $this->assertNotNull($priKey);
$this->assertFalse($priKey->hasValidHex());
$priKey->generate();
@@ -134,8 +137,8 @@ public function testHasValidHex()
public function testHasValidDec()
{
$priKey = new PrivateKey();
- $this->assertNotNull($priKey);
+ $this->assertNotNull($priKey);
$this->assertFalse($priKey->hasValidDec());
$priKey->generate();
@@ -163,9 +166,11 @@ public function testPemDecode()
$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 @@ public function testPemEncode()
$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
diff --git a/tests/Bitpay/PublicKeyTest.php b/tests/Bitpay/PublicKeyTest.php
index 1a89b7e7..6ae2db43 100644
--- a/tests/Bitpay/PublicKeyTest.php
+++ b/tests/Bitpay/PublicKeyTest.php
@@ -1,17 +1,13 @@
'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 @@ public function testGenerate()
{
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 @@ public function testGenerate()
public function testGenerateOnlyOnce()
{
$key = new PublicKey();
+
$key->setPrivateKey($this->getMockPrivateKey());
$key->generate();
@@ -107,10 +106,7 @@ public function testGenerateOnlyOnce()
$key->generate();
// Make sure values do not change
- $this->assertSame(
- $hexValue,
- $key->getHex()
- );
+ $this->assertSame($hexValue, $key->getHex());
}
/**
@@ -119,6 +115,7 @@ public function testGenerateOnlyOnce()
public function testGetHex()
{
$pubKey = new PublicKey();
+
$pubKey->setPrivateKey($this->getMockPrivateKey());
$this->assertNull($pubKey->getHex());
$pubKey->generate();
@@ -131,46 +128,41 @@ public function testGetHex()
public function testGetDec()
{
$pubKey = new PublicKey();
- $this->assertNotNull($pubKey);
+ $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 @@ public function testGetY()
{
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 @@ public function testGetY()
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 @@ public function testIsValid()
public function testGetSin()
{
$pub = new PublicKey();
+
$pub->setPrivateKey($this->getMockPrivateKey());
+
$sin = $pub->getSin();
$this->assertInstanceOf('Bitpay\SinKey', $sin);
@@ -214,19 +211,18 @@ public function testGetSin()
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 @@ private function getMockPrivateKey($hex = null)
{
$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('getHex')
- ->will($this->returnValue($hex));
-
return $key;
}
-
}
diff --git a/tests/Bitpay/SinKeyTest.php b/tests/Bitpay/SinKeyTest.php
index 4fb3758d..a319a57b 100644
--- a/tests/Bitpay/SinKeyTest.php
+++ b/tests/Bitpay/SinKeyTest.php
@@ -1,34 +1,30 @@
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 @@ public function testToString()
public function testGenerateWithException()
{
$sinKey = new SinKey();
+
$this->assertNotNull($sinKey);
$sinKey->generate();
}
@@ -48,27 +45,24 @@ public function testGenerateWithException()
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 @@ public function testGenerateWithoutException()
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());
}
}
diff --git a/tests/Bitpay/Storage/EncryptedFilesystemStorageTest.php b/tests/Bitpay/Storage/EncryptedFilesystemStorageTest.php
index 58908128..0d2d671a 100644
--- a/tests/Bitpay/Storage/EncryptedFilesystemStorageTest.php
+++ b/tests/Bitpay/Storage/EncryptedFilesystemStorageTest.php
@@ -1,6 +1,6 @@
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('satoshi');
- $storage->persist(new \Bitpay\PublicKey(vfsStream::url('tmp/public.key')));
- $this->assertTrue($this->root->hasChild('tmp/public.key'));
+ $this->storage->persist(new \Bitpay\PublicKey($this->pubkeyStream));
+ $this->assertTrue($this->root->hasChild($this->pubkeyName));
}
public function testLoad()
{
- $storage = new EncryptedFilesystemStorage('satoshi');
+ //vfsStream::newFile('public.key')
+ // ->at($this->root)
+ // ->setContent('8bc03b8e4272d47ea81d63c6571b8172072ed03203ff7cd3fd434c03f7994b5721363d0dda3cec833f6f263bde0ececa06b79f68d5616be18b8e9311c486223e18c7424daaa59991f4b10db9f2fb8b4c42896c50d216010b403d562738ef5a96');
- vfsStream::newFile('public.key')
- ->at($this->root)
- ->setContent('8bc03b8e4272d47ea81d63c6571b8172072ed03203ff7cd3fd434c03f7994b5721363d0dda3cec833f6f263bde0ececa06b79f68d5616be18b8e9311c486223e18c7424daaa59991f4b10db9f2fb8b4c42896c50d216010b403d562738ef5a96');
+ $this->storage->persist(new \Bitpay\PublicKey($this->pubkeyStream));
- $key = $storage->load(vfsStream::url('tmp/public.key'));
+ $key = $this->storage->load($this->pubkeyStream);
$this->assertInstanceOf('Bitpay\PublicKey', $key);
}
@@ -39,8 +46,7 @@ public function testLoad()
*/
public function testNotFileException()
{
- $storage = new EncryptedFilesystemStorage('satoshi');
- $storage->load(vfsStream::url('tmp/public.key'));
+ $this->storage->load($this->pubkeyStream);
}
/**
@@ -48,13 +54,13 @@ public function testNotFileException()
*/
public function testLoadNotReadableException()
{
- $storage = new EncryptedFilesystemStorage('satoshi');
- vfsStream::newFile('public.key', 0600)
+ 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'));
}
/**
@@ -62,23 +68,22 @@ public function testLoadNotReadableException()
*/
public function testLoadCouldNotDecode()
{
- $storage = new EncryptedFilesystemStorage('satoshi');
-
- vfsStream::newFile('public.key')
+ vfsStream::newFile('badpublic.key')
->at($this->root)
->setContent('00');
- $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);
}
}
diff --git a/tests/Bitpay/Storage/FilesystemStorageTest.php b/tests/Bitpay/Storage/FilesystemStorageTest.php
index 5cfa954b..c511f02a 100644
--- a/tests/Bitpay/Storage/FilesystemStorageTest.php
+++ b/tests/Bitpay/Storage/FilesystemStorageTest.php
@@ -1,6 +1,6 @@
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');
}
@@ -28,7 +31,7 @@ public function testLoad()
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'));
$this->assertInstanceOf('Bitpay\PublicKey', $key);
@@ -49,11 +52,13 @@ public function testNotFileException()
public function testLoadNotReadableException()
{
$storage = new FilesystemStorage();
+
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'));
}
}
diff --git a/tests/Bitpay/TokenTest.php b/tests/Bitpay/TokenTest.php
index 24067b7d..f6541c32 100644
--- a/tests/Bitpay/TokenTest.php
+++ b/tests/Bitpay/TokenTest.php
@@ -1,6 +1,6 @@
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 @@ public function testGetEmail()
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 @@ public function testGetFirstName()
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 @@ public function testGetLastName()
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 @@ public function testGetCity()
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 @@ public function testGetState()
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 @@ public function testGetZip()
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 @@ public function testGetCountry()
public function testSetCountry()
{
$this->assertNotNull($this->user);
-
$this->user->setCountry('US');
$this->assertNotNull($this->user->getCountry());
$this->assertSame('US', $this->user->getCountry());
diff --git a/tests/Bitpay/Util/Base58Test.php b/tests/Bitpay/Util/Base58Test.php
index 3165a2a2..ffe4dfcf 100644
--- a/tests/Bitpay/Util/Base58Test.php
+++ b/tests/Bitpay/Util/Base58Test.php
@@ -1,6 +1,6 @@
assertSame($datum[1], Base58::encode($datum[0]));
}
@@ -44,6 +45,7 @@ public function testDecodeSpecial()
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));
diff --git a/tests/Bitpay/Util/FingerprintTest.php b/tests/Bitpay/Util/FingerprintTest.php
index 83d1a21c..1db1fa43 100644
--- a/tests/Bitpay/Util/FingerprintTest.php
+++ b/tests/Bitpay/Util/FingerprintTest.php
@@ -1,6 +1,6 @@
assertGreaterThan($a, $b);
- }
-
public function testGuid()
{
$guid = Util::guid();
@@ -173,6 +162,7 @@ public function testDoubleAndAdd()
$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 @@ public function testDoubleAndAdd()
'0xb7dafe35d7d1aab78b53982c8ba554584518f86d50af565c98e053613c8f15e0',
$point
);
+
$this->assertEquals('14976827122927988984909748681266837395089399768482149532452617485742004777865', $R->getX());
$this->assertEquals('5009713401941157350243425146365130573323232660945282226881202857781593637456', $R->getY());
@@ -189,6 +180,7 @@ public function testDoubleAndAdd()
'0xfd7c6914790d3bbf3184d9830e3f1a327e951e3478dd0b28f0fd3b0e774bbd68',
$point
);
+
$this->assertEquals('65041784833307054098962518952641430476519680065454324565175938819000678523383', $R->getX());
$this->assertEquals('53140314933116045874248958072587249546886301333167874306830834776596206062743', $R->getY());
}
@@ -199,6 +191,7 @@ public function testDecToBin()
array('123456789', '101010001011001111011010111'),
array('0x123456789', '100100011110011010100010110001001'),
);
+
foreach ($data as $datum) {
$this->assertSame($datum[1], Util::decToBin($datum[0]));
}
@@ -229,6 +222,7 @@ public function testPointAdd()
new Point(1, 1),
new Point(1, 1)
);
+
$expectedpoint = new Point("28948022309329048855892746252171976963317496166410141009864396001977208667916", "14474011154664524427946373126085988481658748083205070504932198000988604333958");
$this->assertEquals($expectedpoint, $point);
@@ -236,6 +230,7 @@ public function testPointAdd()
new Point(0, 0),
new Point(1, 1)
);
+
$expectedpoint = new Point("0", "0");
$this->assertEquals($expectedpoint, $point);
@@ -243,6 +238,7 @@ public function testPointAdd()
new Point(1, 0),
new Point(0, 1)
);
+
$expectedpoint = new Point("0", "115792089237316195423570985008687907853269984665640564039457584007908834671662");
$this->assertEquals($expectedpoint, $point);
}
@@ -253,6 +249,7 @@ public function testBinConv()
array('7361746f736869', 'satoshi'),
array('0x7361746f736869', 'satoshi'),
);
+
foreach ($data as $datum) {
$this->assertSame($datum[1], Util::binConv($datum[0]));
}
@@ -267,6 +264,7 @@ public function testCheckRequirements()
$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 {
@@ -299,6 +297,7 @@ public function testCheckRequirements()
$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 {
@@ -316,5 +315,4 @@ public function testCheckRequirements()
$this->assertTrue(is_string($requirements['Math']));
}
}
-
}
diff --git a/tests/DataFixtures/currencies.json b/tests/DataFixtures/currencies.json
index 063cebde..62f244ce 100644
--- a/tests/DataFixtures/currencies.json
+++ b/tests/DataFixtures/currencies.json
@@ -23,7 +23,6 @@
"plural": "Zimbabwean Dollar",
"alts": "",
"payoutFields": [
-
]
}
]
diff --git a/tests/DataFixtures/invoices/5NxFkXcJbCSivtQRJa4kHP.json b/tests/DataFixtures/invoices/5NxFkXcJbCSivtQRJa4kHP.json
index 3b5b17cf..f90a74db 100644
--- a/tests/DataFixtures/invoices/5NxFkXcJbCSivtQRJa4kHP.json
+++ b/tests/DataFixtures/invoices/5NxFkXcJbCSivtQRJa4kHP.json
@@ -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,"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,"token":"9CKEkTYE4VA4skhMPBxUsPQyUqXE36qpmitmYbtKssPnY3p8rYqhTTcEzUeowKwvzL"}}
diff --git a/tests/DataFixtures/with_tokens.json b/tests/DataFixtures/with_tokens.json
index 86066635..554c2cfd 100644
--- a/tests/DataFixtures/with_tokens.json
+++ b/tests/DataFixtures/with_tokens.json
@@ -1,2 +1 @@
{"data":[{"payroll":"39zPuHaBbO8VMZe8Bdr9RjmRY6pHT7Gs3ifcbKM6PYSg2"},{"payroll/payoutRequest":"FFehd3N8CmNFqdQnPC4HMMx1MQUbmN6RsbLZsrqPqS8x"},{"payroll/payoutRequest":"5QziWnr75x7c4B9DdJ5QUo"}]}
-
diff --git a/tests/integrations/bootstrap/FeatureContext.php b/tests/integrations/bootstrap/FeatureContext.php
index 2719c925..8b6cd4db 100644
--- a/tests/integrations/bootstrap/FeatureContext.php
+++ b/tests/integrations/bootstrap/FeatureContext.php
@@ -10,7 +10,6 @@
use Behat\Mink\Session;
use Behat\Mink\Driver\Selenium2Driver;
-
require_once __DIR__ . '/../../../vendor/autoload.php';
require_once __DIR__ . '/StepHelper.php';
@@ -58,6 +57,7 @@ public function __construct(array $parameters)
} else {
$this->email = getenv('BITPAY_EMAIL');
}
+
if (null == getenv('BITPAY_PASSWORD')) {
$this->password = $this->params['password'];
} else {
@@ -71,7 +71,8 @@ public function __construct(array $parameters)
}
$port = parse_url($this->base_url, PHP_URL_PORT);
- if (true == is_null(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 {
@@ -114,7 +115,7 @@ public function __construct(array $parameters)
*/
public function theUserIsAuthenticatedWithBitpay()
{
- if(true == !file_exists('/tmp/token.json') || true == !file_exists('/tmp/bitpay.pri') || true == !file_exists('/tmp/bitpay.pub')){
+ if (false === file_exists('/tmp/token.json') || false === file_exists('/tmp/bitpay.pri') || false === file_exists('/tmp/bitpay.pub')) {
$this->theUserPairsWithBitpayWithAValidPairingCode();
$this->theUserIsPairedWithBitpay();
}
@@ -143,13 +144,16 @@ public function theUserCreatesAnInvoiceFor($price, $currency)
->setCode('skuNumber')
->setDescription('General Description of Item')
->setPrice($price);
- $invoice->setItem($item);
+ $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;
@@ -167,11 +171,13 @@ public function theyShouldRecieveAnInvoiceInResponseFor($price, $currency)
$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 ($responsePrice !== $price) {
+ throw new \Exception("Error: Price is different", 1);
}
- if ($responseCurrency !== $currency){
- throw new Exception("Error: Currency is different", 1);
+
+ if ($responseCurrency !== $currency) {
+ throw new \Exception("Error: Currency is different", 1);
}
}
@@ -181,9 +187,7 @@ public function theyShouldRecieveAnInvoiceInResponseFor($price, $currency)
public function theUserPairsWithBitpayWithAValidPairingCode()
{
// Login
-
- $this->mink->getSession()->visit($this->base_url.'/merchant-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);
@@ -204,13 +208,16 @@ public function theUserPairsWithBitpayWithAValidPairingCode()
// 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);
@@ -231,7 +238,6 @@ public function theUserIsPairedWithBitpay()
//Set Client
$network = $this->network;
$client = createClient($network, $privateKey, $publicKey);
-
$pairingCode = $this->validPairingCode;
// Pair
@@ -243,17 +249,20 @@ public function theUserIsPairedWithBitpay()
'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);
}
-
}
/**
@@ -285,7 +294,6 @@ public function theUserFailsToPairWithASemanticallyValidCode($pairingCode)
} finally {
return true;
}
-
}
/**
@@ -295,9 +303,11 @@ public function theyWillReceiveAnErrorMatching($expectedErrorName, $expectedErro
{
$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);
}
@@ -318,11 +328,13 @@ public function theClientFailsToPairWithBitpayBecauseOfAnIncorrectPort($status,
//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
@@ -330,7 +342,7 @@ public function theClientFailsToPairWithBitpayBecauseOfAnIncorrectPort($status,
array(
'pairingCode' => 'aaaaaaa',
'label' => 'Integrations Testing',
- 'id' => (string) $sinKey,
+ 'id' => (string)$sinKey,
)
);
} catch (\Exception $e) {
@@ -345,10 +357,11 @@ public function theClientFailsToPairWithBitpayBecauseOfAnIncorrectPort($status,
*/
public function thatAUserKnowsAnInvoiceId()
{
- if(true == !file_exists('/tmp/token.json') || true == !file_exists('/tmp/bitpay.pri') || true == !file_exists('/tmp/bitpay.pub')){
+ if (false === file_exists('/tmp/token.json') || false === file_exists('/tmp/bitpay.pri') || false === file_exists('/tmp/bitpay.pub')) {
$this->theUserPairsWithBitpayWithAValidPairingCode();
$this->theUserIsPairedWithBitpay();
}
+
$this->theUserCreatesAnInvoiceFor(1.99, 'USD');
}
@@ -357,17 +370,18 @@ public function thatAUserKnowsAnInvoiceId()
*/
public function theyCanRetrieveThatInvoice()
{
- try
- {
- $network = $this->network;
- $client = createClient($network);
- $response = $client->getInvoice($this->invoiceId);
- } catch (Exception $e){
+ 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");
+
+ if ($responseInvoiceId !== $this->invoiceId) {
+ throw new \Exception("Invoice ids don't match");
}
}
-}
\ No newline at end of file
+}
diff --git a/tests/integrations/bootstrap/StepHelper.php b/tests/integrations/bootstrap/StepHelper.php
index 9f9bd000..8d116094 100644
--- a/tests/integrations/bootstrap/StepHelper.php
+++ b/tests/integrations/bootstrap/StepHelper.php
@@ -31,19 +31,21 @@ function loadKeys()
function createClient($network, $privateKey = null, $publicKey = null, $curl_options = null)
{
- if(true === is_null($curl_options)) {
+ 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();
+ $client = new \Bitpay\Client\Client();
- if(true === !is_null($privateKey)) {
+ if (false === is_null($privateKey)) {
$client->setPrivateKey($privateKey);
}
- if(true === !is_null($publicKey)) {
+
+ if (false === is_null($publicKey)) {
$client->setPublicKey($publicKey);
}
@@ -51,4 +53,4 @@ function createClient($network, $privateKey = null, $publicKey = null, $curl_opt
$client->setAdapter($adapter);
return $client;
-}
\ No newline at end of file
+}