#Installation
Require this package in your composer.json
and update composer.
"tpweb/targetpay": "1.*"
After updating composer, add the ServiceProvider to the providers array in config/app.php
TPWeb\TargetPay\TargetPayServiceProvider::class,
You can use the facade for shorter code. Add this to your aliases:
'TargetPay' => TPWeb\TargetPay\TargetPayFacade::class,
To publish the config settings in Laravel 5 use:
php artisan vendor:publish --provider="TPWeb\TargetPay\TargetPayServiceProvider"
This will add a targetpay.php
config file to your config folder. In your .env file you can use:
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
(This will only give you a one-time successful callback!)
$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
}
Save $transactionId, redirect user to $redirectUrl.
$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);
Save $transactionId, redirect user to $redirectUrl.
$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);
Save $transactionId, redirect user to $redirectUrl.
$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);
Save $transactionId, redirect user to $redirectUrl.
$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();
The complete documentation can be found at: http://www.tpweb.org/my-projects/php-targetpay-library/
Support github or mail: [email protected]
Please try to follow the psr-2 coding style guide. http://www.php-fig.org/psr/psr-2/
This package is licensed under LGPL. You are free to use it in personal and commercial projects. The code can be forked and modified, but the original copyright author should always be included!