PHP code example of asciisd / tap-php

1. Go to this page and download the library: Download asciisd/tap-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

asciisd / tap-php example snippets






\Tap\Tap::setApiKey('sk_test_XKokBfNWv6FIYuTMg5sLPjhJ');
$charge = \Tap\Charge::create([
    'amount' => 2000, 
    'currency' => 'usd', 
    'source' => ['id' => 'tok_189fqt2eZvKYlo2CTGBeg6Uq'], 
    'customer' => ['id' => 'cus_w4MN2720192134x9XB1510264']
]);
echo $charge;

// set up your tweaked Curl client
$curl = new \Tap\HttpClient\CurlClient();
$curl->setTimeout(10); // default is \Tap\HttpClient\CurlClient::DEFAULT_TIMEOUT
$curl->setConnectTimeout(5); // default is \Tap\HttpClient\CurlClient::DEFAULT_CONNECT_TIMEOUT

echo $curl->getTimeout(); // 10
echo $curl->getConnectTimeout(); // 5

// tell Tap to use the tweaked client
\Tap\ApiRequestor::setHttpClient($curl);

// use the Tap API client as you normally would

\Tap\Tap::setLogger($logger);

$charge = \Tap\Charge::create([
    'amount' => 2000, 
    'currency' => 'usd', 
    'source' => ['id' => 'tok_189fqt2eZvKYlo2CTGBeg6Uq'], 
    'customer' => ['id' => 'cus_w4MN2720192134x9XB1510264']
]);
echo $charge->getLastResponse()->headers['Request-Id'];

$curl = new \Tap\HttpClient\CurlClient([CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1]);
\Tap\ApiRequestor::setHttpClient($curl);

\Tap\Charge::all([], [
    'api_key' => 'sk_test_...',
    'amount' => 2000, 
    'currency' => 'usd', 
    'source' => ['id' => 'tok_189fqt2eZvKYlo2CTGBeg6Uq'], 
    'customer' => ['id' => 'cus_w4MN2720192134x9XB1510264']
]);

\Tap\Charge::retrieve("ch_18atAXCdGbJFKhCuBAa4532Z", [
    'api_key' => 'sk_test_...',
    'amount' => 2000, 
    'currency' => 'usd', 
    'source' => ['id' => 'tok_189fqt2eZvKYlo2CTGBeg6Uq'], 
    'customer' => ['id' => 'cus_w4MN2720192134x9XB1510264']
]);

\Tap\Tap::setCABundlePath("path/to/ca/bundle");

\Tap\Tap::setMaxNetworkRetries(2);

\Tap\Tap::setEnableTelemetry(false);
 bash
$ composer