PHP code example of vmdevelopment / laravel-tap-payments
1. Go to this page and download the library: Download vmdevelopment/laravel-tap-payments 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/ */
vmdevelopment / laravel-tap-payments example snippets
use VMdevelopment\TapPayment\Facade\TapPayment;
public function pay()
{
try{
$payment = TapPayment::createCharge();
$payment->setCustomerName( "John Doe" );
$payment->setCustomerPhone( "123456789" );
$payment->setDescription( "Some description" );
$payment->setAmount( 123 );
$payment->setCurrency( "KWD" );
$payment->setSource( "src_kw.knet" );
$payment->setRedirectUrl( "https://example.com" );
$payment->setPostUrl( "https://example.com" ); // if you are using post request to handle payment updates
$payment->setMetaData( [ 'package' => json_encode( $package ) ] ); // if you want to send metadata
$invoice = $payment->pay();
} catch( \Exception $exception ){
// your handling of request failure
}
$payment->isSuccess() // check if TapPayment has successfully handled request.
}
public function check( $id )
{
try{
$invoice = TapPayment::findCharge( $id );;
} catch( \Exception $exception ){
// your handling of request failure
}
$invoice->checkHash($request->header('Hashstring')); // check hashstring to make sure that request comes from Tap
$invoice->isSuccess(); // check if invoice is paid
$invoice->isInitiated(); // check if invoice is unpaid yet
}