InvoiceClient
in package
Handles interactions with the invoice endpoints.
Tags
Table of Contents
Properties
- $instance : self|null
- $restCli : RESTcli
- $tokenCache : Tokens
Methods
- cancel() : Invoice
- Cancel a BitPay invoice.
- cancelByGuid() : Invoice
- Cancel a BitPay invoice.
- create() : Invoice
- Create a BitPay invoice.
- get() : Invoice
- Retrieve a BitPay invoice by invoice id using the specified facade. The client must have been previously authorized for the specified facade (the public facade requires no authorization).
- getByGuid() : Invoice
- getInstance() : static
- Factory method for Invoice Client.
- getInvoices() : array<string|int, Invoice>
- Retrieve a collection of BitPay invoices.
- pay() : Invoice
- Pay an invoice with a mock transaction
- requestNotification() : bool
- Request a BitPay Invoice Webhook.
- update() : Invoice
- Update a BitPay invoice.
- __construct() : mixed
- validateBuyerEmailAndSms() : void
- Check if buyerEmail or buyerSms is present, and not both.
- validateSmsCode() : void
- Check if smsCode is required.
Properties
$instance
private
static self|null
$instance
= null
$restCli
private
RESTcli
$restCli
$tokenCache
private
Tokens
$tokenCache
Methods
cancel()
Cancel a BitPay invoice.
public
cancel(string $invoiceId[, bool $forceCancel = false ]) : Invoice
Parameters
- $invoiceId : string
-
The id of the invoice to updated.
- $forceCancel : bool = false
Tags
Return values
Invoice —$invoice Cancelled invoice object.
cancelByGuid()
Cancel a BitPay invoice.
public
cancelByGuid(string $guid[, bool $forceCancel = false ]) : Invoice
Parameters
- $guid : string
-
The guid of the invoice to cancel.
- $forceCancel : bool = false
Tags
Return values
Invoice —$invoice Cancelled invoice object.
create()
Create a BitPay invoice.
public
create(Invoice $invoice[, string $facade = Facade::MERCHANT ][, bool $signRequest = true ]) : Invoice
Parameters
- $invoice : Invoice
-
An Invoice object with request parameters defined.
- $facade : string = Facade::MERCHANT
-
The facade used to create it.
- $signRequest : bool = true
-
Signed request.
Tags
Return values
Invoiceget()
Retrieve a BitPay invoice by invoice id using the specified facade. The client must have been previously authorized for the specified facade (the public facade requires no authorization).
public
get(string $invoiceId[, string $facade = Facade::MERCHANT ][, bool $signRequest = true ]) : Invoice
Parameters
- $invoiceId : string
-
The id of the invoice to retrieve.
- $facade : string = Facade::MERCHANT
-
The facade used to create it.
- $signRequest : bool = true
-
Signed request.
Tags
Return values
InvoicegetByGuid()
public
getByGuid(string $guid[, string $facade = Facade::MERCHANT ][, bool $signRequest = true ]) : Invoice
Parameters
- $guid : string
- $facade : string = Facade::MERCHANT
- $signRequest : bool = true
Tags
Return values
InvoicegetInstance()
Factory method for Invoice Client.
public
static getInstance(Tokens $tokenCache, RESTcli $restCli) : static
Parameters
Return values
staticgetInvoices()
Retrieve a collection of BitPay invoices.
public
getInvoices(string $dateStart, string $dateEnd[, string|null $status = null ][, string|null $orderId = null ][, int|null $limit = null ][, int|null $offset = null ]) : array<string|int, Invoice>
Parameters
- $dateStart : string
-
The start of the date window to query for invoices. Format YYYY-MM-DD.
- $dateEnd : string
-
The end of the date window to query for invoices. Format YYYY-MM-DD.
- $status : string|null = null
-
The invoice status you want to query on.
- $orderId : string|null = null
-
The optional order id specified at time of invoice creation.
- $limit : int|null = null
-
Maximum results that the query will return (useful for paging results).
- $offset : int|null = null
-
Number of results to offset (ex. skip 10 will give you results starting with the 11th result).
Tags
Return values
array<string|int, Invoice>pay()
Pay an invoice with a mock transaction
public
pay(string $invoiceId[, string $status = 'confirmed' ]) : Invoice
Parameters
- $invoiceId : string
-
The id of the invoice.
- $status : string = 'confirmed'
-
Status the invoice will become. Acceptable values are confirmed (default) and complete.
Tags
Return values
Invoice —$invoice Invoice object.
requestNotification()
Request a BitPay Invoice Webhook.
public
requestNotification(string $invoiceId) : bool
Parameters
- $invoiceId : string
-
A BitPay invoice ID.
Tags
Return values
bool —True if the webhook was successfully requested, false otherwise.
update()
Update a BitPay invoice.
public
update(string $invoiceId, string|null $buyerSms, string|null $smsCode, string|null $buyerEmail[, false $autoVerify = false ]) : Invoice
Parameters
- $invoiceId : string
-
The id of the invoice to update.
- $buyerSms : string|null
-
The buyer's cell number.
- $smsCode : string|null
-
The buyer's received verification code.
- $buyerEmail : string|null
-
The buyer's email address.
- $autoVerify : false = false
-
Skip the user verification on sandbox ONLY.
Tags
Return values
Invoice__construct()
private
__construct(Tokens $tokenCache, RESTcli $restCli) : mixed
Parameters
validateBuyerEmailAndSms()
Check if buyerEmail or buyerSms is present, and not both.
private
validateBuyerEmailAndSms(string|null $buyerEmail, string|null $buyerSms) : void
Updating the invoice will require EITHER SMS or E-mail, but not both.
Parameters
- $buyerEmail : string|null
-
The buyer's email address.
- $buyerSms : string|null
-
The buyer's cell number.
Tags
validateSmsCode()
Check if smsCode is required.
private
validateSmsCode(bool $autoVerify, string $buyerSms, string $smsCode) : void
smsCode required only when verifying SMS, except when autoVerify is true.
Parameters
- $autoVerify : bool
-
Skip the user verification on sandbox ONLY.
- $buyerSms : string
-
The buyer's cell number.
- $smsCode : string
-
The buyer's received verification code.