Menu

## InvoiceClient
in package

InvoiceClient.php : 30

Handles interactions with the invoice endpoints.

##### Tags

author

  BitPay Integrations integrations@bitpay.com

license

  http://www.opensource.org/licenses/mit-license.php MIT

### 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

InvoiceClient.php : 32
`private static self|null $instance = null`

#### $restCli

InvoiceClient.php : 34
`private RESTcli $restCli`

#### $tokenCache

InvoiceClient.php : 33
`private Tokens $tokenCache`

### Methods

#### cancel()

InvoiceClient.php : 274

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

throws
  BitPayApiException
throws
  BitPayGenericException

##### Return values

Invoice —

$invoice Cancelled invoice object.

#### cancelByGuid()

InvoiceClient.php : 306

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

throws
  BitPayApiException
throws
  BitPayGenericException

##### Return values

Invoice —

$invoice Cancelled invoice object.

#### create()

InvoiceClient.php : 68

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

throws
  BitPayApiException
throws
  BitPayGenericException

##### Return values

Invoice

#### get()

InvoiceClient.php : 144

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

throws
  BitPayApiException
throws
  BitPayGenericException

##### Return values

Invoice

#### getByGuid()

InvoiceClient.php : 174
`public getByGuid(string $guid[, string $facade = Facade::MERCHANT ][, bool $signRequest = true ]) : Invoice`

##### Parameters

$guid : string
$facade : string = Facade::MERCHANT
$signRequest : bool = true

##### Tags

throws
  BitPayGenericException
throws
  BitPayApiException

##### Return values

Invoice

#### getInstance()

InvoiceClient.php : 49

Factory method for Invoice Client.

`public static getInstance(Tokens $tokenCache, RESTcli $restCli) : static`

##### Parameters

$tokenCache : Tokens
$restCli : RESTcli

##### Return values

static

#### getInvoices()

InvoiceClient.php : 210

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

throws
  BitPayApiException
throws
  BitPayGenericException

##### Return values

array<string|int, Invoice>

#### pay()

InvoiceClient.php : 339

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

throws
  BitPayApiException
throws
  BitPayGenericException

##### Return values

Invoice —

$invoice Invoice object.

#### requestNotification()

InvoiceClient.php : 258

Request a BitPay Invoice Webhook.

`public requestNotification(string $invoiceId) : bool`

##### Parameters

$invoiceId : string

  A BitPay invoice ID.

##### Tags

throws
  BitPayApiException
throws
  BitPayGenericException

##### Return values

bool —

True if the webhook was successfully requested, false otherwise.

#### update()

InvoiceClient.php : 102

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

throws
  BitPayGenericException
throws
  BitPayApiException

##### Return values

Invoice

#### __construct()

InvoiceClient.php : 36
`private __construct(Tokens $tokenCache, RESTcli $restCli) : mixed`

##### Parameters

$tokenCache : Tokens
$restCli : RESTcli

#### validateBuyerEmailAndSms()

InvoiceClient.php : 369

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

throws
  BitPayValidationException

#### validateSmsCode()

InvoiceClient.php : 387

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.

##### Tags

throws
  BitPayValidationException

## Search results