Menu

## InvoiceClient
in package

InvoiceClient.php : 32

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
buyerEmailOrSms() : bool
  Check if buyerEmail or buyerSms is present, and not both.
isSmsCodeRequired() : bool
  Check if smsCode is required.

### Properties

#### $instance

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

#### $restCli

InvoiceClient.php : 36
`private RESTcli $restCli`

#### $tokenCache

InvoiceClient.php : 35
`private Tokens $tokenCache`

### Methods

#### cancel()

InvoiceClient.php : 369

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
  InvoiceCancellationException
throws
  BitPayException

##### Return values

Invoice —

$invoice Cancelled invoice object.

#### cancelByGuid()

InvoiceClient.php : 415

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
  InvoiceCancellationException
throws
  BitPayException

##### Return values

Invoice —

$invoice Cancelled invoice object.

#### create()

InvoiceClient.php : 69

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
  BitPayException

##### Return values

Invoice

#### get()

InvoiceClient.php : 180

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
  InvoiceQueryException

##### Return values

Invoice

#### getByGuid()

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

##### Parameters

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

##### Tags

throws
  InvoiceQueryException

##### Return values

Invoice

#### getInstance()

InvoiceClient.php : 51

Factory method for Invoice Client.

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

##### Parameters

$tokenCache : Tokens
$restCli : RESTcli

##### Return values

static

#### getInvoices()

InvoiceClient.php : 272

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
  BitPayException

##### Return values

array<string|int, Invoice>

#### pay()

InvoiceClient.php : 462

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
  InvoicePaymentException
throws
  BitPayException

##### Return values

Invoice —

$invoice Invoice object.

#### requestNotification()

InvoiceClient.php : 334

Request a BitPay Invoice Webhook.

`public requestNotification(string $invoiceId) : bool`

##### Parameters

$invoiceId : string

  A BitPay invoice ID.

##### Tags

throws
  InvoiceQueryException
throws
  BitPayException

##### Return values

bool —

True if the webhook was successfully requested, false otherwise.

#### update()

InvoiceClient.php : 116

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 updated.

$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
  InvoiceUpdateException

##### Return values

Invoice

#### __construct()

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

##### Parameters

$tokenCache : Tokens
$restCli : RESTcli

#### buyerEmailOrSms()

InvoiceClient.php : 505

Check if buyerEmail or buyerSms is present, and not both.

`private buyerEmailOrSms(string|null $buyerEmail, string|null $buyerSms) : bool`

##### Parameters

$buyerEmail : string|null

  The buyer's email address.

$buyerSms : string|null

  The buyer's cell number.

##### Return values

bool

#### isSmsCodeRequired()

InvoiceClient.php : 518

Check if smsCode is required.

`private isSmsCodeRequired(bool $autoVerify, string $buyerSms, string $smsCode) : bool`

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

##### Return values

bool

## Search results