This repository was archived by the owner on Jan 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 147
/
Copy pathInvoiceInterface.php
372 lines (326 loc) · 12.1 KB
/
InvoiceInterface.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
<?php
/**
* @license Copyright 2011-2018 BitPay Inc., MIT License
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
*/
namespace Bitpay;
/**
* Invoice
*
* @package Bitpay
*/
interface InvoiceInterface
{
/**
* An invoice starts in this state. When in this state and only in this state, payments
* to the associated bitcoin address are credited to the invoice. If an invoice has
* received a partial payment, it will still reflect a status of new to the merchant
* (from a merchant system perspective, an invoice is either paid or not paid, partial
* payments and over payments are handled by bitpay.com by either refunding the
* customer or applying the funds to a new invoice.
*/
const STATUS_NEW = 'new';
/**
* As soon as full payment (or over payment) is received, an medium or low speed invoice goes into the
* paid status. A high speed invoice immediately goes into 'confirmed', see below.
*/
const STATUS_PAID = 'paid';
/**
* The transaction speed preference of an invoice determines when an invoice is
* confirmed. For the high speed setting, it will be confirmed as soon as full
* payment is received on the bitcoin network (note, the invoice will go from a status
* of new to confirmed, bypassing the paid status). For the medium speed setting,
* the invoice is confirmed after the payment transaction(s) have been confirmed by
* 1 block on the bitcoin network. For the low speed setting, 6 blocks on the bitcoin
* network are required. Invoices are considered complete after 6 blocks on the
* bitcoin network, therefore an invoice will go from a paid status directly to a
* complete status if the transaction speed is set to low.
*/
const STATUS_CONFIRMED = 'confirmed';
/**
* When an invoice is complete, it means that BitPay.com has credited the
* merchant’s account for the invoice. Currently, 6 confirmation blocks on the
* bitcoin network are required for an invoice to be complete. Note, in the future (for
* qualified payers), invoices may move to a complete status immediately upon
* payment, in which case the invoice will move directly from a new status to a
* complete status.
*/
const STATUS_COMPLETE = 'complete';
/**
* An expired invoice is one where payment was not received and the 15 minute
* payment window has elapsed.
*/
const STATUS_EXPIRED = 'expired';
/**
* An invoice is considered invalid when it was paid, but payment was not confirmed
* within 1 hour after receipt. It is possible that some transactions on the bitcoin
* network can take longer than 1 hour to be included in a block. In such
* circumstances, once payment is confirmed, BitPay.com will make arrangements
* with the merchant regarding the funds (which can either be credited to the
* merchant account on another invoice, or returned to the buyer).
*/
const STATUS_INVALID = 'invalid';
/**
* Code comment for each transaction speed
*/
const TRANSACTION_SPEED_HIGH = 'high';
const TRANSACTION_SPEED_MEDIUM = 'medium';
const TRANSACTION_SPEED_LOW = 'low';
/**
* This is the currency code set for the price setting. The pricing currencies
* currently supported are USD, EUR, BTC, BCH and all of the codes listed on this page:
* https://bitpay.com/bitcoinexchangerates
*
* @return CurrencyInterface
*/
public function getCurrency();
/**
* @return ItemInterface
*/
public function getItem();
/**
* @return BuyerInterface
*/
public function getBuyer();
/**
* default value: set in your https://bitpay.com/ordersettings, the default value set in
* your merchant dashboard is “medium”.
*
* ● “high”: An invoice is considered to be "confirmed" immediately upon
* receipt of payment.
* ● “medium”: An invoice is considered to be "confirmed" after 1 block
* confirmation (~10 minutes).
* ● “low”: An invoice is considered to be "confirmed" after 6 block
* confirmations (~1 hour).
*
* NOTE: Orders are posted to your Account Summary after 6 block confirmations
* regardless of this setting.
*
* @return string
*/
public function getTransactionSpeed();
/**
* Bitpay.com will send an email to this email address when the invoice status
* changes.
*
* @return string
*/
public function getNotificationEmail();
/**
* A URL to send status update messages to your server (this must be an https
* URL, unencrypted http URLs or any other type of URL is not supported).
* Bitpay.com will send a POST request with a JSON encoding of the invoice to
* this URL when the invoice status changes.
*
* @return string
*/
public function getNotificationUrl();
/**
* This is the URL for a return link that is displayed on the receipt, to return the
* shopper back to your website after a successful purchase. This could be a page
* specific to the order, or to their account.
*
* @return string
*/
public function getRedirectUrl();
/**
* A passthru variable provided by the merchant and designed to be used by the
* merchant to correlate the invoice with an order or other object in their system.
* Maximum string length is 100 characters.
*
* @return array|object
*/
public function getPosData();
/**
* The current invoice status. The possible states are described earlier in this
* document.
*
* @return string
*/
public function getStatus();
/**
* default value: true
* ● true: Notifications will be sent on every status change.
* ● false: Notifications are only sent when an invoice is confirmed (according
* to the “transactionSpeed” setting).
*
* @return boolean
*/
public function isFullNotifications();
/**
* default value: false
* ● true: Notifications will also be sent for expired invoices and refunds.
* ● false: Notifications will not be sent for expired invoices and refunds
*
* @return boolean
*/
public function isExtendedNotifications();
/**
* The unique id of the invoice assigned by bitpay.com
*
* @return string
*/
public function getId();
/**
* An https URL where the invoice can be viewed.
*
* @return string
*/
public function getUrl();
/**
* The time the invoice was created in milliseconds since midnight January 1,
* 1970. Time format is “20140101T19:01:01.123Z”.
*
* @return DateTime
*/
public function getInvoiceTime();
/**
* The time at which the invoice expires and no further payment will be accepted (in
* milliseconds since midnight January 1, 1970). Currently, all invoices are valid for
* 15 minutes. Time format is “20140101T19:01:01.123Z”.
*
* @return DateTime
*/
public function getExpirationTime();
/**
* The current time on the BitPay.com system (by subtracting the current time from
* the expiration time, the amount of time remaining for payment can be
* determined). Time format is “20140101T19:01:01.123Z”.
*
* @return DateTime
*/
public function getCurrentTime();
/**
* Used to display your public order number to the buyer on the BitPay invoice. In
* the merchant Account Summary page, this value is used to identify the ledger
* entry. Maximum string length is 100 characters.
*
* @return string
*/
public function getOrderId();
/**
* Used to display an item description to the buyer. Maximum string length is 100
* characters.
*
* @deprecated
* @return string
*/
public function getItemDesc();
/**
* Used to display an item SKU code or part number to the buyer. Maximum string
* length is 100 characters.
*
* @deprecated
* @return string
*/
public function getItemCode();
/**
* default value: false
* ● true: Indicates a physical item will be shipped (or picked up)
* ● false: Indicates that nothing is to be shipped for this order
*
* @deprecated
* @return boolean
*/
public function isPhysical();
/**
* These fields are used for display purposes only and will be shown on the invoice
* if provided. Maximum string length of each field is 100 characters.
*
* @deprecated
* @return string
*/
public function getBuyerName();
/**
* These fields are used for display purposes only and will be shown on the invoice
* if provided. Maximum string length of each field is 100 characters.
*
* @deprecated
* @return string
*/
public function getBuyerAddress1();
/**
* These fields are used for display purposes only and will be shown on the invoice
* if provided. Maximum string length of each field is 100 characters.
*
* @deprecated
* @return string
*/
public function getBuyerAddress2();
/**
* These fields are used for display purposes only and will be shown on the invoice
* if provided. Maximum string length of each field is 100 characters.
*
* @deprecated
* @return string
*/
public function getBuyerCity();
/**
* These fields are used for display purposes only and will be shown on the invoice
* if provided. Maximum string length of each field is 100 characters.
*
* @deprecated
* @return string
*/
public function getBuyerState();
/**
* These fields are used for display purposes only and will be shown on the invoice
* if provided. Maximum string length of each field is 100 characters.
*
* @deprecated
* @return string
*/
public function getBuyerZip();
/**
* These fields are used for display purposes only and will be shown on the invoice
* if provided. Maximum string length of each field is 100 characters.
*
* @deprecated
* @return string
*/
public function getBuyerCountry();
/**
* These fields are used for display purposes only and will be shown on the invoice
* if provided. Maximum string length of each field is 100 characters.
*
* @deprecated
* @return string
*/
public function getBuyerEmail();
/**
* These fields are used for display purposes only and will be shown on the invoice
* if provided. Maximum string length of each field is 100 characters.
*
* @deprecated
* @return string
*/
public function getBuyerPhone();
/**
*/
public function getExceptionStatus();
/**
*/
public function getToken();
/**
* An array containing all bitcoin addresses linked to the invoice.
* Only filled when doing a getInvoice using the Merchant facade.
* The array contains
* [refundAddress] => Array
* [type] => string (e.g. "PaymentProtocol")
* [date] => datetime string
*
* @return array|object
*/
public function getRefundAddresses();
public function getTransactionCurrency();
public function getPaymentSubtotals();
/**
* Equivalent to price for each supported transactionCurrency, excluding minerFees.
* The key is the currency and the value is an amount indicated in the smallest possible unit
* for each supported transactionCurrency (e.g satoshis for BTC and BCH)
* ex: '{"BCH": 1023200, "BTC": 113100 }'
*/
public function getPaymentTotals();
public function getAmountPaid();
public function getExchangeRates();
}