-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBitpay.php
90 lines (79 loc) · 2.27 KB
/
Bitpay.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
/*
* For basic Bitpay functionality
*/
class Bitpay
{
// To hold configuration value from application.ini file
private $_configuration;
// To hold value for bitpay configuration
private $_options;
public function __construct()
{
$registry = Zend_Registry::getInstance();
$this->_configuration = $registry->configuration;
// Load bipay library files
Zend_Loader::loadFile('bp_options.php', $this->_configuration->includePaths->library . '/bitpay', true);
Zend_Loader::loadFile('bp_lib.php', $this->_configuration->includePaths->library . '/bitpay', true);
// Global variable in bitpay to hold configuration values
global $bpOptions;
$this->_options = array_merge($bpOptions, $this->_configuration->bitpay->toArray());
$bpOptions = $this->_options;
}
/**
* Merged the parameter with global bitpay option
*
* @param $options array
* @return array
*/
public function setDynamicOptions($options)
{
global $bpOptions;
$bpOptions = array_merge($bpOptions, $options);
$this->_options = $bpOptions;
return $bpOptions;
}
/**
* Get the information about already created invoice
*
* @param string $invoiceId
* @return JSON mixed
*/
public function getBitpayInvoiceInfo($invoiceId)
{
$invoiceInfo = bpGetInvoice($invoiceId);
if (empty($invoiceInfo['error'])) {
return $invoiceInfo;
} else {
return false;
}
}
/**
* Create new invoice on Bipay
*
* @param string $invoiceId
* @param string $price
* @param string $posData
* @param array $options
* @return array|bool
*/
public function createBitpayInvoice($invoiceId, $price, $posData, $options = array())
{
$invoiceInfo = bpCreateInvoice($invoiceId, $price, $posData, $options);
if (empty($invoiceInfo['error'])) {
return $invoiceInfo;
} else {
return false;
}
}
/**
* Retrieve notification from Bitpay
*
* @return JSON mixed
*/
public function getNotification()
{
$notificationData = bpVerifyNotification();
return $notificationData;
}
}