PHP code example of pilot / ogone-payment-bundle

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

    

pilot / ogone-payment-bundle example snippets


$bundles = array(
    new Pilot\OgonePaymentBundle\PilotOgonePaymentBundle(),
);

public function indexAction()
{
  $client = $this->getRepository('PilotOgonePaymentBundle:OgoneClient')->findOneBy(array(
      'email' => '[email protected]',
  ));

  if (!$client) {
      $client = new OgoneClient();
      $client->setEmail('[email protected]');

      $this->getManager()->persist($client);
      $this->getManager()->flush();
  }

  $transaction = $this->get('ogone.transaction_builder')
      ->order()
          ->setClient($client)
          ->setAmount(99)
      ->end()
      ->configure()
          ->setBgColor('#ffffff')
          ->setAcceptUrl($this->generateUrl('ogone_payment_feedback', array(), true))
          ->setDeclineUrl($this->generateUrl('ogone_payment_feedback', array(), true))
          ->setExceptionUrl($this->generateUrl('ogone_payment_feedback', array(), true))
          ->setCancelUrl($this->generateUrl('ogone_payment_feedback', array(), true))
          ->setBackUrl($this->generateUrl('ogone_payment_feedback', array(), true))
      ->end()
  ;

  $transaction->save();

  $form = $transaction->getForm();

  return $this->render(
      'PilotOgonePaymentBundle:Payment:index.html.twig',
      array(
          'form' => $form->createView(),
      )
  );
}

public function feedbackAction()
{
  if (!$this->get('ogone.feedbacker')->isValidCall()) {
      throw $this->createNotFoundException();
  }

  $this->get('ogone.feedbacker')->updateOrder();

  return $this->render(
      'PilotOgonePaymentBundle:Payment:feedback.html.twig'
  );
}
 php
// Client recuperation HERE

// Transaction creation HERE

$transaction->save();

if ($this->container->getParameter('ogone.use_aliases')) {
    $alias = $this->getRepository('PilotOgonePaymentBundle:OgoneAlias')->findOneBy(array(
        'client' => $client,
        'operation' => OgoneAlias::OPERATION_BYMERCHANT,
        'name' => 'ABONNEMENT',
    ));

    if (!$alias) {
        $alias = new OgoneAlias();
        $alias
            ->setClient($client)
            ->setOperation(OgoneAlias::OPERATION_BYMERCHANT)
            ->setStatus(OgoneAlias::STATUS_ACTIVE)
            ->setName('ABONNEMENT')
        ;

        $this->getManager()->persist($alias);
        $this->getManager()->flush();
    }

    $transaction->useAlias($alias);
}

$form = $transaction->getForm();

// render the view