PHP Class BxPmtBitPay, dolphin.pro

Inheritance: extends BxPmtProvider
Show file Open project: boonex/dolphin.pro

Public Methods

Method Description
__construct ( $oDb, $oConfig, $aConfig ) Constructor
checkoutFinished ( )
createInvoice ( $orderId, $price, $posData, $options = [] ) : array Creates BitPay invoice via Bitpay::curl.
finalizeCheckout ( &$aData )
getCurrencyList ( ) : array Retrieves a list of all supported currencies and returns associative array.
getInvoice ( $invoiceId, $apiKey = false ) : mixed Retrieves an invoice from BitPay. $options can include 'apiKey'
getRate ( string $code = 'USD' ) : string Retrieves the current rate based on $code.
initializeCheckout ( $iPendingId, $aCartInfo, $bRecurring = false, $iRecurringDays )

Protected Methods

Method Description
_curl ( $url, $apiKey, $post = false ) : mixed Handles post/get to BitPay via curl.
_decodeResponse ( string $response ) : array Decodes JSON response and returns associative array.
_hash ( $data, $key ) : string Generates a base64 encoded keyed hash.
_initializeOptions ( )
_log ( mixed $contents ) Writes $contents to a log file specified in the bp_options file or, if missing, defaults to a standard filename of 'bplog.txt'.
_verifyAmount ( $aPosData, $fAmount )
_verifyNotification ( ) : mixed Call from your notification handler to convert $_POST data to an object containing invoice data
_verifyPosData ( array $aPosData ) : boolean Call from your notification handler to verify posData

Method Details

__construct() public method

Constructor
public __construct ( $oDb, $oConfig, $aConfig )

_curl() protected method

Handles post/get to BitPay via curl.
protected _curl ( $url, $apiKey, $post = false ) : mixed
return mixed $response

_decodeResponse() protected method

Decodes JSON response and returns associative array.
protected _decodeResponse ( string $response ) : array
$response string
return array $arrResponse

_hash() protected method

Generates a base64 encoded keyed hash.
protected _hash ( $data, $key ) : string
return string $hmac

_initializeOptions() protected method

protected _initializeOptions ( )

_log() protected method

Writes $contents to a log file specified in the bp_options file or, if missing, defaults to a standard filename of 'bplog.txt'.
protected _log ( mixed $contents )
$contents mixed

_verifyAmount() protected method

protected _verifyAmount ( $aPosData, $fAmount )

_verifyNotification() protected method

Call from your notification handler to convert $_POST data to an object containing invoice data
protected _verifyNotification ( ) : mixed
return mixed $json

_verifyPosData() protected method

Call from your notification handler to verify posData
protected _verifyPosData ( array $aPosData ) : boolean
$aPosData array
return boolean

checkoutFinished() public method

public checkoutFinished ( )

createInvoice() public method

Creates BitPay invoice via Bitpay::curl.
public createInvoice ( $orderId, $price, $posData, $options = [] ) : array
return array $response

finalizeCheckout() public method

public finalizeCheckout ( &$aData )

getCurrencyList() public method

Retrieves a list of all supported currencies and returns associative array.
public getCurrencyList ( ) : array
return array $currencies

getInvoice() public method

Retrieves an invoice from BitPay. $options can include 'apiKey'
public getInvoice ( $invoiceId, $apiKey = false ) : mixed
return mixed $json

getRate() public method

The default code us USD, so calling the function without a parameter will return the current BTC/USD price.
public getRate ( string $code = 'USD' ) : string
$code string
return string $rate

initializeCheckout() public method

public initializeCheckout ( $iPendingId, $aCartInfo, $bRecurring = false, $iRecurringDays )