Merge pull request #17 from ryanxcharles/bug/fix-config

fix config
This commit is contained in:
Ryan X. Charles 2013-12-12 16:54:39 -08:00
commit 69c8ab2a46
3 changed files with 23 additions and 20 deletions

View File

@ -1,12 +1,15 @@
<?php
$bpconfig_host="bitpay.com";
$bpconfig_port=443;
$bpconfig_hostAndPort=$bpconfig_host;
if ($bpconfig_port!=443)
$bpconfig_hostAndPort.=":".$bpconfig_port;
$bpconfig_ssl_verifypeer=1;
$bpconfig_ssl_verifyhost=2;
global $bpconfig;
$bpconfig['host']="bitpay.com";
$bpconfig['port']=443;
$bpconfig['hostAndPort']=$bpconfig['host'];
if ($bpconfig['port']!=443)
$bpconfig['hostAndPort'].=":".$bpconfig['host'];
$bpconfig['ssl_verifypeer']=1;
$bpconfig['ssl_verifyhost']=2;
//include custom config overrides if it exists
if (file_exists('bp_config.php'))
require_once 'bp_config.php';
try {
include 'bp_config.php';
} catch (Exception $e) {
}
?>

View File

@ -4,7 +4,7 @@ require_once 'bp_config_default.php';
require_once 'bp_options.php';
function bpCurl($url, $apiKey, $post = false) {
global $bpOptions;
global $bpOptions, $bpconfig;
$curl = curl_init($url);
$length = 0;
@ -22,12 +22,12 @@ function bpCurl($url, $apiKey, $post = false) {
"Authorization: Basic $uname",
);
curl_setopt($curl, CURLOPT_PORT, $bpconfig_port);
curl_setopt($curl, CURLOPT_PORT, $bpconfig['port']);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC ) ;
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $bpconfig_ssl_verifypeer); // verify certificate
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, $bpconfig_ssl_verifyhost); // check existence of CN and verify that it matches hostname
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $bpconfig['ssl_verifypeer']); // verify certificate
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, $bpconfig['ssl_verifyhost']); // check existence of CN and verify that it matches hostname
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FORBID_REUSE, 1);
curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1);
@ -61,7 +61,7 @@ function bpCurl($url, $apiKey, $post = false) {
// If a given option is not provided here, the value of that option will default to what is found in bp_options.php
// (see api documentation for information on these options).
function bpCreateInvoice($orderId, $price, $posData, $options = array()) {
global $bpOptions;
global $bpOptions, $bpconfig;
$options = array_merge($bpOptions, $options); // $options override any options found in bp_options.php
@ -81,14 +81,14 @@ function bpCreateInvoice($orderId, $price, $posData, $options = array()) {
$post[$o] = $options[$o];
$post = json_encode($post);
$response = bpCurl('https://'.$bpconfig_hostAndPort.'/api/invoice/', $options['apiKey'], $post);
$response = bpCurl('https://'.$bpconfig['hostAndPort'].'/api/invoice/', $options['apiKey'], $post);
return $response;
}
// Call from your notification handler to convert $_POST data to an object containing invoice data
function bpVerifyNotification($apiKey = false) {
global $bpOptions;
global $bpOptions, $bpconfig;
if (!$apiKey)
$apiKey = $bpOptions['apiKey'];
@ -114,11 +114,11 @@ function bpVerifyNotification($apiKey = false) {
// $options can include ('apiKey')
function bpGetInvoice($invoiceId, $apiKey=false) {
global $bpOptions;
global $bpOptions, $bpconfig;
if (!$apiKey)
$apiKey = $bpOptions['apiKey'];
$response = bpCurl('https://'.$bpconfig_hostAndPort.'/api/invoice/'.$invoiceId, $apiKey);
$response = bpCurl('https://'.$bpconfig['hostAndPort'].'/api/invoice/'.$invoiceId, $apiKey);
if (is_string($response))
return $response; // error
$response['posData'] = json_decode($response['posData'], true);
@ -128,4 +128,4 @@ function bpGetInvoice($invoiceId, $apiKey=false) {
}
?>
?>

View File

@ -27,4 +27,4 @@ $bpOptions['fullNotifications'] = 'true';
$bpOptions['transactionSpeed'] = 'low';
?>
?>