BitPay PHP SDK

InvoiceClient
in package

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

Methods

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
throws
BitPayApiException
throws
BitPayGenericException
Return values
Invoice

get()

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

getInstance()

Factory method for Invoice Client.

public static getInstance(Tokens $tokenCache, RESTcli $restCli) : static
Parameters
$tokenCache : Tokens
$restCli : RESTcli
Return values
static

getInvoices()

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()

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()

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()

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

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
throws
BitPayValidationException

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.

Tags
throws
BitPayValidationException

        
On this page

Search results