1. Go to this page and download the library: Download kptive/payment-sips-bundle 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/ */
kptive / payment-sips-bundle example snippets
bash
$ php composer.phar
php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new JMS\Payment\CoreBundle\JMSPaymentCoreBundle(),
new Kptive\PaymentSipsBundle\KptivePaymentSipsBundle(),
);
// ...
}
// ...
php
namespace Acme\PaymentBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use JMS\Payment\CoreBundle\Entity\PaymentInstruction;
/**
* @ORM\Table(name="acme_order")
*/
class Order
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\OneToOne(targetEntity="JMS\Payment\CoreBundle\Entity\PaymentInstruction")
*/
private $paymentInstruction;
/**
* @ORM\Column(type="decimal", precision=10, scale=2)
*/
private $amount;
/**
* @ORM\Column(type="datetime", name="payed_at", nullable=true)
*/
private $payedAt;
// ...
public function getId()
{
return $this->id;
}
public function getAmount()
{
return $this->amount;
}
public function getPaymentInstruction()
{
return $this->paymentInstruction;
}
public function setPaymentInstruction(PaymentInstruction $instruction)
{
$this->paymentInstruction = $instruction;
return $this;
}
public function getPayedAt()
{
return $this->payedAt;
}
public function setPayedAt($payedAt)
{
$this->payedAt = $payedAt;
return $this;
}
php
namespace Acme\PaymentBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use JMS\Payment\CoreBundle\Entity\PaymentInstruction;
use Acme\PaymentBundle\Entity\Order;
/**
* @Route("/checkout")
*/
class CheckoutController extends Controller
{
// ...
/**
* @Route("/details/{id}", name = "payment_details")
* @Template()
*/
public function detailsAction(Order $order)
{
$request = $this->get('request');
$em = $this->get('doctrine')->getEntityManager();
$router = $this->get('router');
$ppc = $this->get('payment.plugin_controller');
$confirm = new \StdClass();
$form = $this->createFormBuilder($confirm)
->add('save', 'submit', array('label' => 'confirmer'))
->getForm();
if ('POST' === $request->getMethod()) {
$form->handleRequest($request);
if ($form->isValid()) {
$instruction = new PaymentInstruction($order->getAmount(), 978, 'sips');
$ppc->createPaymentInstruction($instruction);
$order->setPaymentInstruction($instruction);
$em->persist($order);
$em->flush($order);
return new RedirectResponse($router->generate('payment_gateway', array(
'id' => $order->getId(),
)));
}
}
return array(
'order' => $order,
'form' => $form->createView()
);
}
}
php
namespace Acme\PaymentBundle\EventListener;
use Doctrine\ORM\EntityManager;
use JMS\Payment\CoreBundle\PluginController\Event\PaymentStateChangeEvent;
use JMS\Payment\CoreBundle\Model\PaymentInterface;
class PaymentListener
{
protected $entityManager;
public function __construct(EntityManager $entityManager)
{
$this->entityManager = $entityManager;
}
public function onPaymentStateChange(PaymentStateChangeEvent $event)
{
if (PaymentInterface::STATE_DEPOSITED === $event->getNewState()) {
$order = $this
->entityManager
->getRepository('AcmePaymentBundle:Order')
->findOneBy(array('paymentInstruction' => $event->getPaymentInstruction()));
$order->setPayedAt(new \DateTime());
// Do various things with the Order here
// ...
$this->entityManager->persist($order);
$this->entityManager->flush();
}
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.