|
1
|
|
|
<?php namespace Arcanedev\Stripe\Resources; |
|
2
|
|
|
|
|
3
|
|
|
use Arcanedev\Stripe\Bases\ExternalAccount; |
|
4
|
|
|
use Arcanedev\Stripe\Contracts\Resources\BitcoinReceiverInterface; |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* Class BitcoinReceiver |
|
8
|
|
|
* |
|
9
|
|
|
* @package Arcanedev\Stripe\Resources |
|
10
|
|
|
* @author ARCANEDEV <[email protected]> |
|
11
|
|
|
* @link https://stripe.com/docs/api/php#bitcoin_receivers |
|
12
|
|
|
* |
|
13
|
|
|
* @property string id |
|
14
|
|
|
* @property string object |
|
15
|
|
|
* @property bool active |
|
16
|
|
|
* @property int amount |
|
17
|
|
|
* @property int amount_received |
|
18
|
|
|
* @property int bitcoin_amount |
|
19
|
|
|
* @property int bitcoin_amount_received |
|
20
|
|
|
* @property string bitcoin_uri |
|
21
|
|
|
* @property int created |
|
22
|
|
|
* @property string currency |
|
23
|
|
|
* @property Customer customer |
|
24
|
|
|
* @property string description |
|
25
|
|
|
* @property string email |
|
26
|
|
|
* @property bool filled |
|
27
|
|
|
* @property string inbound_address |
|
28
|
|
|
* @property bool livemode |
|
29
|
|
|
* @property \Arcanedev\Stripe\AttachedObject metadata |
|
30
|
|
|
* @property string payment |
|
31
|
|
|
* @property string refund_address |
|
32
|
|
|
* @property \Arcanedev\Stripe\Collection transactions |
|
33
|
|
|
* @property bool uncaptured_funds |
|
34
|
|
|
* @property bool used_for_payment |
|
35
|
|
|
*/ |
|
36
|
|
|
class BitcoinReceiver extends ExternalAccount implements BitcoinReceiverInterface |
|
37
|
|
|
{ |
|
38
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
39
|
|
|
| Main Functions |
|
40
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
41
|
|
|
*/ |
|
42
|
|
|
/** |
|
43
|
|
|
* @return string The instance URL for this resource. It needs to be special |
|
44
|
|
|
* cased because it doesn't fit into the standard resource pattern. |
|
45
|
|
|
*/ |
|
46
|
15 |
|
public function instanceUrl() |
|
47
|
|
|
{ |
|
48
|
15 |
|
if ( ! is_null($result = parent::instanceUrl())) { |
|
49
|
|
|
return $result; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
15 |
|
$base = self::classUrl(); |
|
53
|
15 |
|
$extn = urlencode(str_utf8($this['id'])); |
|
54
|
|
|
|
|
55
|
15 |
|
return "$base/$extn"; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* The class URL for this resource. |
|
60
|
|
|
* It needs to be special cased because it does not fit into the standard resource pattern. |
|
61
|
|
|
* |
|
62
|
|
|
* @param string $class |
|
63
|
|
|
* |
|
64
|
|
|
* @return string |
|
65
|
|
|
*/ |
|
66
|
45 |
|
public static function classUrl($class = '') |
|
67
|
|
|
{ |
|
68
|
45 |
|
return '/v1/bitcoin/receivers'; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
72
|
|
|
| CRUD Functions |
|
73
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
74
|
|
|
*/ |
|
75
|
|
|
/** |
|
76
|
|
|
* Retrieve Bitcoin Receiver. |
|
77
|
|
|
* @link https://stripe.com/docs/api/php#retrieve_bitcoin_receiver |
|
78
|
|
|
* |
|
79
|
|
|
* @param string $id |
|
80
|
|
|
* @param string|null $options |
|
81
|
|
|
* |
|
82
|
|
|
* @return self |
|
83
|
|
|
*/ |
|
84
|
10 |
|
public static function retrieve($id, $options = null) |
|
85
|
|
|
{ |
|
86
|
10 |
|
return self::scopedRetrieve($id, $options); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* List all Bitcoin Receivers. |
|
91
|
|
|
* @link https://stripe.com/docs/api/php#list_bitcoin_receivers |
|
92
|
|
|
* |
|
93
|
|
|
* @param array|null $params |
|
94
|
|
|
* @param string|null $options |
|
95
|
|
|
* |
|
96
|
|
|
* @return \Arcanedev\Stripe\Collection|array |
|
97
|
|
|
*/ |
|
98
|
5 |
|
public static function all($params = [], $options = null) |
|
99
|
|
|
{ |
|
100
|
5 |
|
return self::scopedAll($params, $options); |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* Create Bitcoin Receiver Object. |
|
105
|
|
|
* @link https://stripe.com/docs/api/php#create_bitcoin_receiver |
|
106
|
|
|
* |
|
107
|
|
|
* @param array|null $params |
|
108
|
|
|
* @param string|null $options |
|
109
|
|
|
* |
|
110
|
|
|
* @return self|array |
|
111
|
|
|
*/ |
|
112
|
40 |
|
public static function create($params = [], $options = null) |
|
113
|
|
|
{ |
|
114
|
40 |
|
return self::scopedCreate($params, $options); |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* Refund the Bitcoin Receiver item. |
|
119
|
|
|
* |
|
120
|
|
|
* @param array|null $params |
|
121
|
|
|
* @param array|string|null $options |
|
122
|
|
|
* |
|
123
|
|
|
* @return self |
|
124
|
|
|
*/ |
|
125
|
5 |
|
public function refund($params = null, $options = null) |
|
126
|
|
|
{ |
|
127
|
5 |
|
list($response, $opts) = $this->request( |
|
128
|
5 |
|
'post', $this->instanceUrl() . '/refund', $params, $options |
|
129
|
4 |
|
); |
|
130
|
|
|
|
|
131
|
5 |
|
$this->refreshFrom($response, $opts); |
|
132
|
|
|
|
|
133
|
5 |
|
return $this; |
|
134
|
|
|
} |
|
135
|
|
|
} |
|
136
|
|
|
|