BitPay PHP SDK

Client
in package

Client class to interact with the BitPay API.

Tags
author

BitPay Integrations integrations@bitpay.com

license

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

Table of Contents

Properties

$restCli  : RESTcli
$tokenCache  : Tokens

Methods

__construct()  : mixed
Client constructor.
cancelInvoice()  : Invoice
Cancel a BitPay invoice.
cancelInvoiceByGuid()  : Invoice
Cancel a BitPay invoice.
cancelPayout()  : bool
Cancel a BitPay Payout.
cancelPayoutGroup()  : PayoutGroup
cancelRefund()  : Refund
Cancel a previously submitted refund request on a BitPay invoice.
cancelRefundByGuid()  : Refund
Cancel a previously submitted refund request on a BitPay invoice.
createBill()  : Bill
Create a BitPay Bill.
createInvoice()  : Invoice
Create a BitPay invoice.
createPayoutGroup()  : PayoutGroup
createRefund()  : Refund
Create a refund for a BitPay invoice.
createWithData()  : Client
Constructor for use if the keys and SIN are managed by this library.
createWithFile()  : Client
Constructor for use if the keys and SIN are managed by this library.
deletePayoutRecipient()  : bool
Delete a Payout Recipient.
deliverBill()  : bool
Deliver a BitPay Bill.
getBill()  : Bill
Retrieve a BitPay bill by bill id using the specified facade.
getBills()  : array<string|int, Bill>
Retrieve a collection of BitPay bills.
getCurrencyPairRate()  : Rate
Retrieve the rate for a cryptocurrency / fiat pair
getCurrencyRates()  : Rates
Retrieve all the rates for a given cryptocurrency
getInvoice()  : 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).
getInvoiceByGuid()  : Invoice
Retrieve a BitPay invoice by guid using the specified facade.
getInvoices()  : array<string|int, Invoice>
Retrieve a collection of BitPay invoices.
getLedgerEntries()  : array<string|int, LedgerEntry>
Retrieve a list of ledgers by date range using the merchant facade.
getLedgers()  : array<string|int, Ledger>
Retrieve a list of ledgers using the merchant facade.
getPayout()  : Payout
Retrieve a BitPay payout by payout id using. The client must have been previously authorized for the payout facade.
getPayoutRecipient()  : PayoutRecipient
Retrieve a BitPay payout recipient by batch id using. The client must have been previously authorized for the payout facade.
getPayoutRecipients()  : array<string|int, PayoutRecipient>
Retrieve a collection of BitPay Payout Recipients.
getPayouts()  : array<string|int, Payout>
Retrieve a collection of BitPay payouts.
getRates()  : Rates
Retrieve the exchange rate table maintained by BitPay.
getRefund()  : Refund
Retrieve a previously made refund request on a BitPay invoice.
getRefundByGuid()  : Refund
Retrieve a previously made refund request on a BitPay invoice.
getRefunds()  : array<string|int, Refund>
Retrieve all refund requests on a BitPay invoice.
getSettlement()  : Settlement
Retrieves a summary of the specified settlement.
getSettlementReconciliationReport()  : Settlement
Gets a detailed reconciliation report of the activity within the settlement period.
getSettlements()  : array<string|int, Settlement>
Retrieves settlement reports for the calling merchant filtered by query.
getSupportedWallets()  : array<string|int, Wallet>
Retrieve all supported wallets.
getTokens()  : array<string|int, mixed>
Get Tokens.
payInvoice()  : Invoice
Pay an invoice with a mock transaction
requestInvoiceNotification()  : bool
Request a BitPay Invoice Webhook.
requestPayoutNotification()  : bool
Notify BitPay Payout.
requestPayoutRecipientNotification()  : bool
Notify BitPay Payout Recipient.
sendRefundNotification()  : bool
Send a refund notification.
submitPayout()  : Payout
Submit a BitPay Payout.
submitPayoutRecipients()  : array<string|int, PayoutRecipient>
Submit BitPay Payout Recipients.
updateBill()  : Bill
Update a BitPay Bill.
updateInvoice()  : Invoice
Update a BitPay invoice.
updatePayoutRecipient()  : PayoutRecipient
Update a Payout Recipient.
updateRefund()  : Refund
Update the status of a BitPay invoice.
updateRefundByGuid()  : Refund
Update the status of a BitPay invoice.
getBillClient()  : BillClient
Gets bill client
getInvoiceClient()  : InvoiceClient
Gets invoice client
getLedgerClient()  : LedgerClient
Gets ledger client
getPayoutClient()  : PayoutClient
Gets payout client
getPayoutRecipientsClient()  : PayoutRecipientsClient
Gets payout recipients client
getRateClient()  : RateClient
Gets rate client
getRefundClient()  : RefundClient
Gets refund client
getSettlementClient()  : SettlementClient
Gets settlement client
getWalletClient()  : WalletClient
Gets wallet client
getConfigData()  : array<string|int, mixed>
getTokenClient()  : TokenClient
Gets token client
initKeys()  : PrivateKey|null

Properties

Methods

createInvoice()

Create a BitPay invoice.

public createInvoice(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
see
https://developer.bitpay.com/reference/create-an-invoice

Create an Invoice

throws
BitPayApiException
throws
BitPayGenericException
Return values
Invoice

createRefund()

Create a refund for a BitPay invoice.

public createRefund(string $invoiceId, float $amount, string $currency[, bool $preview = false ][, bool $immediate = false ][, bool $buyerPaysRefundFee = false ][, string|null $guid = null ]) : Refund
Parameters
$invoiceId : string

The BitPay invoice Id having the associated refund to be created.

$amount : float

Amount to be refunded in the currency indicated.

$currency : string

Reference currency used for the refund, usually the same as the currency used to create the invoice.

$preview : bool = false

Whether to create the refund request as a preview (which will not be acted on until status is updated)

$immediate : bool = false

Whether funds should be removed from merchant ledger immediately on submission or at time of processing

$buyerPaysRefundFee : bool = false

Whether the buyer should pay the refund fee (default is merchant)

$guid : string|null = null
Tags
see
https://developer.bitpay.com/reference/create-a-refund-request

Create a Refund Request

throws
BitPayApiException

BitPayException class

throws
BitPayGenericException

BitPayGenericException

Return values
Refund

$refund An updated Refund Object

createWithData()

Constructor for use if the keys and SIN are managed by this library.

public static createWithData(string $environment, string $privateKey, Tokens $tokens[, string|null $privateKeySecret = null ][, string|null $proxy = null ][, string|null $platformInfo = null ]) : Client
Parameters
$environment : string

Target environment. Options: Env.Test / Env.Prod

$privateKey : string

Private Key file path or the HEX value.

$tokens : Tokens

Tokens containing the available tokens.

$privateKeySecret : string|null = null

Private Key encryption password.

$proxy : string|null = null

The url of your proxy to forward requests through. Example: http://********.com:3128

$platformInfo : string|null = null

Value for the X-BitPay-Platform header.

Tags
throws
BitPayApiException
throws
BitPayGenericException
Return values
Client

createWithFile()

Constructor for use if the keys and SIN are managed by this library.

public static createWithFile(string $configFilePath[, string|null $platformInfo = null ]) : Client
Parameters
$configFilePath : string

The path to the configuration file.

$platformInfo : string|null = null

Value for the X-BitPay-Platform header.

Tags
throws
BitPayGenericException
Return values
Client

getBill()

Retrieve a BitPay bill by bill id using the specified facade.

public getBill(mixed $billId[, mixed $facade = Facade::MERCHANT ][, mixed $signRequest = true ]) : Bill
Parameters
$billId : mixed

string The id of the bill to retrieve.

$facade : mixed = Facade::MERCHANT

string The facade used to retrieve it.

$signRequest : mixed = true

bool Signed request.

Tags
see
https://developer.bitpay.com/reference/retrieve-a-bill

Retrieve a Bill

throws
BitPayApiException
throws
BitPayGenericException
Return values
Bill

getCurrencyPairRate()

Retrieve the rate for a cryptocurrency / fiat pair

public getCurrencyPairRate(string $baseCurrency, string $currency) : Rate
Parameters
$baseCurrency : string

The cryptocurrency for which you want to fetch the fiat-equivalent rate. Current supported values are BTC, BCH, ETH, XRP, DOGE and LTC

$currency : string

The fiat currency for which you want to fetch the baseCurrency rate

Tags
see
https://developer.bitpay.com/reference/retrieve-the-rates-for-a-cryptocurrency-fiat-pair

Retrieve the rates for a cryptocurrency / fiat pair

throws
BitPayApiException
throws
BitPayGenericException
Return values
Rate

A Rate object populated with the currency rate for the requested baseCurrency.

getCurrencyRates()

Retrieve all the rates for a given cryptocurrency

public getCurrencyRates(string $baseCurrency) : Rates
Parameters
$baseCurrency : string

The cryptocurrency for which you want to fetch the rates. Current supported values are BTC, BCH, ETH, XRP, DOGE and LTC

Tags
see
https://developer.bitpay.com/reference/retrieve-all-the-rates-for-a-given-cryptocurrency

Retrieve all the rates for a given cryptocurrency

throws
BitPayApiException
throws
BitPayGenericException
Return values
Rates

A Rates object populated with the currency rates for the requested baseCurrency.

getInvoice()

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 getInvoice(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
see
https://developer.bitpay.com/reference/retrieve-an-invoice-by-guid

Retrieve an Invoice by GUID

throws
BitPayApiException
throws
BitPayGenericException
Return values
Invoice

getInvoiceByGuid()

Retrieve a BitPay invoice by guid using the specified facade.

public getInvoiceByGuid(string $guid[, string $facade = Facade::MERCHANT ][, bool $signRequest = true ]) : Invoice

The client must have been previously authorized for the specified facade.

Parameters
$guid : string

The guid of the invoice to retrieve.

$facade : string = Facade::MERCHANT

The facade used to create it.

$signRequest : bool = true

Signed request.

Tags
see
https://developer.bitpay.com/reference/retrieve-an-invoice-by-guid

Retrieve an Invoice by GUID

throws
BitPayApiException
throws
BitPayGenericException
Return values
Invoice

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
see
https://developer.bitpay.com/reference/retrieve-invoices-filtered-by-query

Retrieve Invoices Filtered by Query

throws
BitPayApiException
throws
BitPayGenericException
Return values
array<string|int, Invoice>

getLedgerEntries()

Retrieve a list of ledgers by date range using the merchant facade.

public getLedgerEntries(string $currency, string $startDate, string $endDate) : array<string|int, LedgerEntry>
Parameters
$currency : string

The three digit currency string for the ledger to retrieve.

$startDate : string

The first date for the query filter.

$endDate : string

The last date for the query filter.

Tags
see
https://developer.bitpay.com/reference/retrieve-ledger-entries

Retrieve Ledger Entries

throws
BitPayApiException
throws
BitPayGenericException
Return values
array<string|int, LedgerEntry>

A Ledger object populated with the BitPay ledger entries list.

getPayoutRecipients()

Retrieve a collection of BitPay Payout Recipients.

public getPayoutRecipients([string|null $status = null ][, int|null $limit = null ][, int|null $offset = null ]) : array<string|int, PayoutRecipient>
Parameters
$status : string|null = null

The recipient status you want to query on.

$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
see
https://developer.bitpay.com/reference/retrieve-recipients-by-status

Retrieve Recipients by Status

throws
BitPayApiException
throws
BitPayGenericException
Return values
array<string|int, PayoutRecipient>

getPayouts()

Retrieve a collection of BitPay payouts.

public getPayouts([string|null $startDate = null ][, string|null $endDate = null ][, string|null $status = null ][, string|null $reference = null ][, int|null $limit = null ][, int|null $offset = null ]) : array<string|int, Payout>
Parameters
$startDate : string|null = null

The start date to filter the Payout Batches.

$endDate : string|null = null

The end date to filter the Payout Batches.

$status : string|null = null

The status to filter the Payout Batches.

$reference : string|null = null

The optional reference specified at payout request 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
see
https://developer.bitpay.com/reference/retrieve-payouts-filtered-by-query

Retrieve Payouts Filtered by Query

throws
BitPayGenericException
throws
BitPayApiException
Return values
array<string|int, Payout>

getSettlementReconciliationReport()

Gets a detailed reconciliation report of the activity within the settlement period.

public getSettlementReconciliationReport(string $settlementId, string $settlementToken) : Settlement
Parameters
$settlementId : string

Settlement ID

$settlementToken : string

Settlement Token

Tags
see
https://developer.bitpay.com/reference/fetch-a-reconciliation-report

Fetch a Reconciliation Report

throws
BitPayApiException
throws
BitPayGenericException
Return values
Settlement

getSettlements()

Retrieves settlement reports for the calling merchant filtered by query.

public getSettlements(mixed $currency, mixed $dateStart, mixed $dateEnd[, string|null $status = null ][, int|null $limit = null ][, int|null $offset = null ]) : array<string|int, Settlement>

The limit and offset parameters specify pages for large query sets.

Parameters
$currency : mixed

string The three digit currency string for the ledger to retrieve.

$dateStart : mixed

string The start date for the query.

$dateEnd : mixed

string The end date for the query.

$status : string|null = null

string Can be processing, completed, or failed.

$limit : int|null = null

int Maximum number of settlements to retrieve.

$offset : int|null = null

int Offset for paging.

Tags
see
https://developer.bitpay.com/reference/retrieve-settlements

Retrieve Settlements

throws
BitPayApiException
throws
BitPayGenericException
Return values
array<string|int, Settlement>

payInvoice()

Pay an invoice with a mock transaction

public payInvoice(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.

submitPayoutRecipients()

Submit BitPay Payout Recipients.

public submitPayoutRecipients(PayoutRecipients $recipients) : array<string|int, PayoutRecipient>
Parameters
$recipients : PayoutRecipients

A PayoutRecipients object with request parameters defined.

Tags
see
https://developer.bitpay.com/reference/invite-recipients

Invite Recipients

throws
BitPayGenericException
throws
BitPayApiException
Return values
array<string|int, PayoutRecipient>

A list of BitPay PayoutRecipients objects.

updateInvoice()

Update a BitPay invoice.

public updateInvoice(string $invoiceId, string|null $buyerSms, string|null $smsCode, string|null $buyerEmail[, bool $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 : bool = false

Skip the user verification on sandbox ONLY.

Tags
see
https://developer.bitpay.com/reference/update-an-invoice

Update an Invoice

throws
BitPayApiException
throws
BitPayGenericException
Return values
Invoice

updatePayoutRecipient()

Update a Payout Recipient.

public updatePayoutRecipient(string $recipientId, PayoutRecipient $recipient) : PayoutRecipient
Parameters
$recipientId : string

The recipient id for the recipient to be updated.

$recipient : PayoutRecipient

A PayoutRecipient object with updated parameters defined.

Tags
see
https://developer.bitpay.com/reference/update-a-recipient

Update a Recipient

throws
BitPayGenericException
throws
BitPayApiException
Return values
PayoutRecipient

getConfigData()

private static getConfigData(string $configFilePath) : array<string|int, mixed>
Parameters
$configFilePath : string
Tags
throws
BitPayGenericException
Return values
array<string|int, mixed>

initKeys()

private static initKeys(string|null $privateKey, string|null $privateKeySecret) : PrivateKey|null
Parameters
$privateKey : string|null
$privateKeySecret : string|null
Tags
throws
BitPayApiException
throws
Exception
Return values
PrivateKey|null

        
On this page

Search results