1. Go to this page and download the library: Download adnane-ka/omnipay-tap 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/ */
adnane-ka / omnipay-tap example snippets
use Omnipay\Omnipay;
$gateway = Omnipay::create('Tap');
/**
* You can use the testing API key provided by Tap.
* No worries on switching test & live mode since Tap provides
* Keys for both, and can distinguish between them
*
* @see https://developers.tap.company/reference/api-endpoint
* @see https://developers.tap.company/reference/testing-keys
*/
$gateway->setApiToken('sk_test_XKokBfNWv6FIYuTMg5sLPjhJ');
$response = $gateway->purchase([
'amount' => 1, // Required
'currency' => 'KWD', // Optional, Default is USD
'customerName' => 'Test', // Optional, Default is Test
'customerEmail' => '[email protected]', // Optional, Default is Test
'sourceId' => 'src_all', // Optional, Default is src_all @see https://developers.tap.company/reference/charges#the-payment-source-object
'threeDSecure' => false, // Optional, Default is true
'returnUrl' => 'http://your_website.com/redirect_url' // Required
])
->send();
if ($response->isRedirect()) {
// Data is valid and you're ready to be redirected offsite
$response->redirect();
} else {
// An error occured
// @see https://developers.tap.company/reference/charge-response-codes
echo $response->getMessage();
}
$response = $gateway->completePurchase([
// tap_id is usually injected as a URL param when returned from gateway
'tap_id' => 'TYPE_IN_THE_TARGET_CHARGE_ID'
])->send();
if($response->isSuccessful()){
// Payment was successful and charge was captured
// $response->getData()
// $response->getTransactionReference() // payment reference
}else{
// Charge was not captured and payment failed
// $response->getData()
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.