VOOZH about

URL: https://payum.gitbook.io/payum/symfony/authorize

⇱ Authorize Payment | Payum


For the complete documentation index, see llms.txt. This page is also available as Markdown.

In get it started we showed you an example of how to capture the payment. It is not always the case, sometimes you want to just authorize it and capture a bit later.

Prepare payment

We have to caThe only difference from capture one example

<?php
// src/Acme/PaymentBundle/Controller/PaymentController.php
namespaceAcme\PaymentBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Payum\Core\Storage\StorageInterface;
use Payum\Core\Security\TokenInterface;
classPaymentControllerextendsController
{
publicfunctionprepareAction()
{
$gatewayName ='offline';
/**@varStorageInterface $storage */
$storage =$this->get('payum')->getStorage('Acme\PaymentBundle\Entity\Payment');
$payment =$storage->create();
$payment->setNumber(uniqid());
$payment->setCurrencyCode('EUR');
$payment->setTotalAmount(123);// 1.23 EUR
$payment->setDescription('A description');
$payment->setClientId('anId');
$payment->setClientEmail('foo@example.com');
$storage->update($payment);
/**@varTokenInterface $captureToken */
$captureToken =$this->get('payum')->getTokenFactory()->createAuthorizeToken(
$gatewayName,
$payment,
'done'// the route to redirect after autorize;
);
return$this->redirect($captureToken->getTargetUrl());
}
}

Supporting Payum

Payum is an MIT-licensed open source project with its ongoing development made possible entirely by the support of community and our customers. If you'd like to join them, please consider:

Last updated