PHP code example of tpweb / targetpay

1. Go to this page and download the library: Download tpweb/targetpay 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/ */

    

tpweb / targetpay example snippets


"tpweb/targetpay": "1.*"

TPWeb\TargetPay\TargetPayServiceProvider::class,

'TargetPay' => TPWeb\TargetPay\TargetPayFacade::class,

php artisan vendor:publish --provider="TPWeb\TargetPay\TargetPayServiceProvider"

TARGETPAY_LAYOUTCODE=xxxxx
TARGETPAY_KLANTCODE=xxxxx
TARGETPAY_TEST=false
TARGETPAY_DEBUG=true

$targetPay = new TargetPay(new \TPWeb\TargetPay\Transaction\IVR);
//$targetPay->transaction->setCountry(32);
$targetPay->transaction->setCountry(\TPWeb\TargetPay\Transaction\IVR::BELGIUM);
$targetPay->setAmount(3.00);
$targetPay->getPaymentInfo(); //Fetch payment info

echo $targetPay->transaction->getCurrency(); //Currency: EURO, GBP, ...
echo $targetPay->getAmount(); //Real payed amount.: 3.00
echo $targetPay->transaction->getServiceNumber(); //Number to call
echo $targetPay->transaction->getPayCode(); //Code to enter during call
echo $targetPay->transaction->getMode(); //Call type: PC or PM
echo ($targetPay->transaction->getMode() == "PM" ? $targetPay->transaction->getDuration() . "s" : ""); //duration in seconds

$targetPay = new TargetPay(new \TPWeb\TargetPay\Transaction\IVR);
$targetPay->transaction->setCountry($request->get('country'));
$targetPay->setAmount($request->get('amount'));
$targetPay->transaction->setServiceNumber($request->get('servicenumber'));
$targetPay->transaction->setPayCode($request->get('paycode'));
$targetPay->checkPaymentInfo();
if($targetPay->transaction->getPaymentDone()) {
    //Payment done
    echo $targetPay->getAmount(); //Real payed amount
    echo targetPay->transaction->getPayout(); //amount you 'll receive.
} else {
    //payment not completed
}

$targetPay = new TargetPay(new \TPWeb\TargetPay\Transaction\IDeal);
$targetPay->transaction->setBank(IDeal::ING);
$targetPay->setAmount(10.00);
$targetPay->transaction->setDescription("Description");
$targetPay->transaction->setReturnUrl("https://www.example.com");
$targetPay->getPaymentInfo();
$redirectUrl = $targetPay->transaction->getIdealUrl();
$transactionId = $targetPay->transaction->getTransactionId();

$targetPay = new TargetPay(new \TPWeb\TargetPay\Transaction\IDeal);
$targetPay->transaction->setTransactionId($transactionId);
$targetPay->checkPaymentInfo();
$once = false;
$targetPay->transaction->getPaymentDone($once);

$targetPay = new TargetPay(new \TPWeb\TargetPay\Transaction\MisterCash);
$targetPay->transaction->setLang("NL");
$targetPay->setAmount(10.00);
$targetPay->transaction->setDescription("Description");
$targetPay->transaction->setReturnUrl("https://www.example.com");
$targetPay->getPaymentInfo();
$redirectUrl = $targetPay->transaction->getMisterCashUrl();
$transactionId = $targetPay->transaction->getTransactionId();

$targetPay = new TargetPay(new \TPWeb\TargetPay\Transaction\MisterCash);
$targetPay->transaction->setTransactionId($transactionId);
$targetPay->checkPaymentInfo();
$once = false;
$targetPay->transaction->getPaymentDone($once);

$targetPay = new TargetPay(new \TPWeb\TargetPay\Transaction\Paysafecard);
$targetPay->setAmount(10.00);
$targetPay->transaction->setDescription("Description");
$targetPay->transaction->setReturnUrl("https://www.example.com");
$targetPay->getPaymentInfo();
$redirectUrl = $targetPay->transaction->getPaysafecardUrl();
$transactionId = $targetPay->transaction->getTransactionId();
//redirect to $redirectUrl

$targetPay = new TargetPay(new \TPWeb\TargetPay\Transaction\Paysafecard);
$targetPay->transaction->setTransactionId($transactionId);
$targetPay->checkPaymentInfo();
$once = false;
$targetPay->transaction->getPaymentDone($once);

$targetPay = new TargetPay(new \TPWeb\TargetPay\Transaction\SMS);
$targetPay->transaction->setCountry(SMS::BELGIUM);
$targetPay->setAmount(1.00);
$shortcode = $targetPay->transaction->getShortcode();
$keyword = $targetPay->transaction->getKeyword();
//User send keyword to shortcode, user get answer with code

$targetPay = new TargetPay(new \TPWeb\TargetPay\Transaction\SMS);
$targetPay->transaction->setCountry(SMS::BELGIUM);
$targetPay->setAmount(1.00);
$targetPay->transaction->setPayCode($code);
$targetPay->checkPaymentInfo();
$targetPay->transaction->getPaymentDone();