Client
in package
Client class to interact with the BitPay API.
Tags
Table of Contents
Properties
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
$restCli
protected
RESTcli
$restCli
$tokenCache
protected
Tokens
$tokenCache
Methods
__construct()
Client constructor.
public
__construct(RESTcli $restCli, Tokens $tokenCache) : mixed
Parameters
cancelInvoice()
Cancel a BitPay invoice.
public
cancelInvoice(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.
cancelInvoiceByGuid()
Cancel a BitPay invoice.
public
cancelInvoiceByGuid(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.
cancelPayout()
Cancel a BitPay Payout.
public
cancelPayout(string $payoutId) : bool
Parameters
- $payoutId : string
-
The id of the payout to cancel.
Tags
Return values
boolcancelPayoutGroup()
public
cancelPayoutGroup(string $groupId) : PayoutGroup
Parameters
- $groupId : string
Tags
Return values
PayoutGroupcancelRefund()
Cancel a previously submitted refund request on a BitPay invoice.
public
cancelRefund(string $refundId) : Refund
Parameters
- $refundId : string
-
The refund Id for the refund to be canceled.
Tags
Return values
Refund —$refund Cancelled refund Object.
cancelRefundByGuid()
Cancel a previously submitted refund request on a BitPay invoice.
public
cancelRefundByGuid(string $guid) : Refund
Parameters
- $guid : string
-
The refund Guid for the refund to be canceled.
Tags
Return values
Refund —$refund Cancelled refund Object.
createBill()
Create a BitPay Bill.
public
createBill(Bill $bill[, string $facade = Facade::MERCHANT ][, bool $signRequest = true ]) : Bill
Parameters
- $bill : Bill
-
A Bill object with request parameters defined.
- $facade : string = Facade::MERCHANT
-
The facade used to create it.
- $signRequest : bool = true
-
Signed request.
Tags
Return values
BillcreateInvoice()
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
Return values
InvoicecreatePayoutGroup()
public
createPayoutGroup(array<string|int, Payout> $payouts) : PayoutGroup
Parameters
- $payouts : array<string|int, Payout>
Tags
Return values
PayoutGroupcreateRefund()
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
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
Return values
ClientcreateWithFile()
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
Return values
ClientdeletePayoutRecipient()
Delete a Payout Recipient.
public
deletePayoutRecipient(string $recipientId) : bool
Parameters
- $recipientId : string
-
The recipient id for the recipient to be deleted.
Tags
Return values
bool —True if the recipient was successfully deleted, false otherwise.
deliverBill()
Deliver a BitPay Bill.
public
deliverBill(string $billId, string $billToken[, bool $signRequest = true ]) : bool
Parameters
- $billId : string
-
The id of the requested bill.
- $billToken : string
-
The token of the requested bill.
- $signRequest : bool = true
-
Allow unsigned request
Tags
Return values
boolgetBill()
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
Return values
BillgetBills()
Retrieve a collection of BitPay bills.
public
getBills([string $status = null ]) : array<string|int, Bill>
Parameters
- $status : string = null
Tags
Return values
array<string|int, 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
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
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
Return values
InvoicegetInvoiceByGuid()
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
Return values
InvoicegetInvoices()
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>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
Return values
array<string|int, LedgerEntry> —A Ledger object populated with the BitPay ledger entries list.
getLedgers()
Retrieve a list of ledgers using the merchant facade.
public
getLedgers() : array<string|int, Ledger>
Tags
Return values
array<string|int, Ledger> —A list of Ledger objects populated with the currency and current balance of each one.
getPayout()
Retrieve a BitPay payout by payout id using. The client must have been previously authorized for the payout facade.
public
getPayout(string $payoutId) : Payout
Parameters
- $payoutId : string
-
The id of the payout to retrieve.
Tags
Return values
PayoutgetPayoutRecipient()
Retrieve a BitPay payout recipient by batch id using. The client must have been previously authorized for the payout facade.
public
getPayoutRecipient(string $recipientId) : PayoutRecipient
Parameters
- $recipientId : string
-
The id of the recipient to retrieve.
Tags
Return values
PayoutRecipientgetPayoutRecipients()
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
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
Return values
array<string|int, Payout>getRates()
Retrieve the exchange rate table maintained by BitPay.
public
getRates() : Rates
Tags
Return values
RatesgetRefund()
Retrieve a previously made refund request on a BitPay invoice.
public
getRefund(string $refundId) : Refund
Parameters
- $refundId : string
-
The BitPay refund ID.
Tags
Return values
Refund —$refund BitPay Refund object with the associated Refund object.
getRefundByGuid()
Retrieve a previously made refund request on a BitPay invoice.
public
getRefundByGuid(string $guid) : Refund
Parameters
- $guid : string
-
The BitPay refund Guid
Tags
Return values
Refund —BitPay Refund object with the associated Refund object.
getRefunds()
Retrieve all refund requests on a BitPay invoice.
public
getRefunds(string $invoiceId) : array<string|int, Refund>
Parameters
- $invoiceId : string
-
The BitPay invoice object having the associated refunds.
Tags
Return values
array<string|int, Refund>getSettlement()
Retrieves a summary of the specified settlement.
public
getSettlement(string $settlementId) : Settlement
Parameters
- $settlementId : string
-
Settlement Id.
Tags
Return values
SettlementgetSettlementReconciliationReport()
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
Return values
SettlementgetSettlements()
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, orfailed. - $limit : int|null = null
-
int Maximum number of settlements to retrieve.
- $offset : int|null = null
-
int Offset for paging.
Tags
Return values
array<string|int, Settlement>getSupportedWallets()
Retrieve all supported wallets.
public
getSupportedWallets() : array<string|int, Wallet>
Tags
Return values
array<string|int, Wallet>getTokens()
Get Tokens.
public
getTokens() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>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
Return values
Invoice —$invoice Invoice object.
requestInvoiceNotification()
Request a BitPay Invoice Webhook.
public
requestInvoiceNotification(string $invoiceId) : bool
Parameters
- $invoiceId : string
-
A BitPay invoice ID.
Tags
Return values
bool —True if the webhook was successfully requested, false otherwise.
requestPayoutNotification()
Notify BitPay Payout.
public
requestPayoutNotification(string $payoutId) : bool
Parameters
- $payoutId : string
-
The id of the Payout to notify.
Tags
Return values
boolrequestPayoutRecipientNotification()
Notify BitPay Payout Recipient.
public
requestPayoutRecipientNotification(string $recipientId) : bool
Parameters
- $recipientId : string
-
The id of the recipient to notify.
Tags
Return values
bool —True if the notification was successfully sent, false otherwise.
sendRefundNotification()
Send a refund notification.
public
sendRefundNotification(string $refundId) : bool
Parameters
- $refundId : string
-
A BitPay refund ID.
Tags
Return values
bool —$result An updated Refund Object
submitPayout()
Submit a BitPay Payout.
public
submitPayout(Payout $payout) : Payout
Parameters
- $payout : Payout
-
A Payout object with request parameters defined.
Tags
Return values
PayoutsubmitPayoutRecipients()
Submit BitPay Payout Recipients.
public
submitPayoutRecipients(PayoutRecipients $recipients) : array<string|int, PayoutRecipient>
Parameters
- $recipients : PayoutRecipients
-
A PayoutRecipients object with request parameters defined.
Tags
Return values
array<string|int, PayoutRecipient> —A list of BitPay PayoutRecipients objects.
updateBill()
Update a BitPay Bill.
public
updateBill(Bill $bill, string $billId) : Bill
Parameters
- $bill : Bill
-
A Bill object with the parameters to update defined.
- $billId : string
-
The Id of the Bill to update.
Tags
Return values
BillupdateInvoice()
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
Return values
InvoiceupdatePayoutRecipient()
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
Return values
PayoutRecipientupdateRefund()
Update the status of a BitPay invoice.
public
updateRefund(string $refundId, string $status) : Refund
Parameters
- $refundId : string
-
BitPay refund ID.
- $status : string
-
The new status for the refund to be updated.
Tags
Return values
Refund —$refund Refund A BitPay generated Refund object.
updateRefundByGuid()
Update the status of a BitPay invoice.
public
updateRefundByGuid(string $guid, string $status) : Refund
Parameters
- $guid : string
-
BitPay refund Guid.
- $status : string
-
The new status for the refund to be updated.
Tags
Return values
Refund —$refund Refund A BitPay generated Refund object.
getBillClient()
Gets bill client
protected
getBillClient() : BillClient
Return values
BillClient —the bill client
getInvoiceClient()
Gets invoice client
protected
getInvoiceClient() : InvoiceClient
Return values
InvoiceClient —the invoice client
getLedgerClient()
Gets ledger client
protected
getLedgerClient() : LedgerClient
Return values
LedgerClient —the ledger client
getPayoutClient()
Gets payout client
protected
getPayoutClient() : PayoutClient
Return values
PayoutClient —the payout client
getPayoutRecipientsClient()
Gets payout recipients client
protected
getPayoutRecipientsClient() : PayoutRecipientsClient
Return values
PayoutRecipientsClient —the payout recipients client
getRateClient()
Gets rate client
protected
getRateClient() : RateClient
Return values
RateClient —the rate client
getRefundClient()
Gets refund client
protected
getRefundClient() : RefundClient
Return values
RefundClient —the refund client
getSettlementClient()
Gets settlement client
protected
getSettlementClient() : SettlementClient
Return values
SettlementClient —the settlements client
getWalletClient()
Gets wallet client
protected
getWalletClient() : WalletClient
Return values
WalletClient —the wallet client
getConfigData()
private
static getConfigData(string $configFilePath) : array<string|int, mixed>
Parameters
- $configFilePath : string
Tags
Return values
array<string|int, mixed>getTokenClient()
Gets token client
private
getTokenClient() : TokenClient
Return values
TokenClientinitKeys()
private
static initKeys(string|null $privateKey, string|null $privateKeySecret) : PrivateKey|null
Parameters
- $privateKey : string|null
- $privateKeySecret : string|null