Ejemplo n.º 1
0
function bpGetInvoice($invoiceId, $apiKey = false)
{
    global $bpOptions;
    if (!$apiKey) {
        $apiKey = $bpOptions['apiKey'];
    }
    $response = bpCurl('https://bitpay.com/api/invoice/' . $invoiceId, $apiKey);
    if (is_string($response)) {
        return $response;
    }
    // error
    $response['posData'] = json_decode($response['posData'], true);
    $response['posData'] = $response['posData']['posData'];
    return $response;
}
Ejemplo n.º 2
0
/**
 * $options can include ('apiKey')
 *
 * @param  string $invoiceId
 * @param  string $apiKey
 * @param  string $network
 * @return array
 */
function bpGetInvoice($invoiceId, $apiKey = false, $network = null)
{
    global $bpOptions;
    if (!$apiKey) {
        $apiKey = $bpOptions['apiKey'];
    }
    if (true == empty($network) || $network == 'live') {
        $network = 'https://bitpay.com/api/invoice/';
    } else {
        $network = 'https://test.bitpay.com/api/invoice/';
    }
    $response = bpCurl($network . $invoiceId, $apiKey);
    if (is_string($response)) {
        return $response;
        // error
    }
    $response['posData'] = json_decode($response['posData'], true);
    if ($bpOptions['verifyPos']) {
        $response['posData'] = $response['posData']['posData'];
    }
    return $response;
}
Ejemplo n.º 3
0
/**
 *
 * Retrieves an invoice from BitPay.  $options can include 'apiKey'
 *
 * @param string $invoiceId, boolean $apiKey
 * @return mixed $json
 * @throws Exception $e
 *
 */
function bpGetInvoice($invoiceId, $apiKey = false, $network = false)
{
    //function currently not being used
    global $bpOptions;
    try {
        if (!$apiKey) {
            $apiKey = $bpOptions['apiKey'];
        }
        if ($network == 'test') {
            $network_uri = 'test.bitpay.com';
        } else {
            $network_uri = 'bitpay.com';
        }
        $response = bpCurl('https://' . $network_uri . '/api/invoice/' . $invoiceId, $apiKey);
        if (is_string($response)) {
            return $response;
        }
        // error
        if (function_exists('json_decode')) {
            $response['posData'] = json_decode($response['posData'], true);
        } else {
            $response['posData'] = bpJSONdecode($response['posData']);
        }
        if ($bpOptions['verifyPos']) {
            $response['posData'] = $response['posData']['posData'];
        }
        return $response;
    } catch (Exception $e) {
        if ($bpOptions['useLogging']) {
            bpLog('Error: ' . $e->getMessage());
        }
        return 'Error: ' . $e->getMessage();
    }
}
Ejemplo n.º 4
0
function bpGetInvoice($invoiceId, $apiKey = false)
{
    global $bpOptions;
    if (!$apiKey) {
        $apiKey = $bpOptions['apiKey'];
    }
    $response = bpCurl('https://' . ($options['testMode'] ? 'test.' : '') . 'bitpay.com/api/invoice/' . $invoiceId, $apiKey);
    if (is_string($response)) {
        return array('error' => $response);
    }
    //decode posData
    $response['posData'] = json_decode($response['posData'], true);
    $response['posData'] = $response['posData']['posData'];
    return $response;
}
function bpGetInvoice($invoiceId, $apiKey = false)
{
    global $bpOptions;
    if (!$apiKey) {
        $apiKey = $bpOptions['apiKey'];
    }
    $network = MODULE_PAYMENT_BITPAY_NETWORK == 'Test' ? 'test.' : '';
    $response = bpCurl('https://' . $network . 'bitpay.com/api/invoice/' . $invoiceId, $apiKey);
    if (is_string($response)) {
        return $response;
    }
    // error
    $response['posData'] = json_decode($response['posData'], true);
    if ($bpOptions['verifyPos']) {
        $response['posData'] = $response['posData']['posData'];
    }
    return $response;
}