PHP code example of tmconsulting / payum-uniteller-gateway
1. Go to this page and download the library: Download tmconsulting/payum-uniteller-gateway 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/ */
tmconsulting / payum-uniteller-gateway example snippets
use Payum\Core\GatewayFactoryInterface;
$builder->addGatewayFactory('uniteller', function(array $config, GatewayFactoryInterface $coreGatewayFactory) {
return new \Payum\Uniteller\UnitellerGatewayFactory($config, $coreGatewayFactory);
})
->addGateway('uniteller', [
'factory' => 'uniteller',
'token_extra' => false, // enable this options, if you want to set token to comment field.
'shop_id' => 'shop_od for production',
'test_shop_id' => 'shop_id for sandbox',
'login' => 'login_digits',
'password' => 'password',
'sandbox' => true,
]);
use Payum\Core\Request\Notify;
use Payum\Core\Request\GetHumanStatus;
class PaymentController extends PayumController
{
public function notifyAction(Request $request)
{
$gateway = $this->getPayum()->getPayment('uniteller');
$payment = $this->getPayum()
->getStorage(Payment::class)
->findBy([
// find payum token by Order_ID, when uniteller call you callback url
'number' => $request->get('Order_ID'),
]);
if ($reply = $gateway->execute(new Notify($payment), true)) {
if ($reply instanceof HttpResponse) {
$gateway->execute($status = new GetHumanStatus($payment));
if ($status->isCaptured() || $status->isAuthorized()) {
// Payment is done
// Notify your app here
// Payum library does not update status in the database
}
throw $reply;
}
throw new \LogicException('Unsupported reply', null, $reply);
}
return new Response('', 204);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.