pilot/ogone-payment-bundle

Ogone payment bundle, doctrine port

Installs: 151

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 2

Forks: 5

Type:symfony-bundle

1.0.0 2015-06-23 14:38 UTC

This package is not auto-updated.

Last update: 2025-08-02 19:25:17 UTC


README

Doctrine port of Cedriclombardot/OgonePaymentBundle

Build Status

Features

  • Full featured sample controller
  • Simple transactions
  • Feedback managment
  • Alias managment

Todo

  • make part of original bundle with doctrine ORM option

Setup

Add in your composer.json :

"require": {
   "pilot/ogone-payment-bundle": "dev-master"
}

Configure your kernel

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

Configure ogone in config.yml

pilot_ogone_payment:
    secret:
        shaInKey: Mysecretsig1875!?
        shaOutKey: Mysecretsig1875!?
        algorithm: sha512
    general:
        PSPID: MyCompagny
        currency: EUR
        language: en_EN
    design:
        title: Give Me Your money - Payment page
        bgColor: "#4e84c4"
        txtColor: "#FFFFFF"
        tblBgColor: "#FFFFFF"
        buttonBgColor: "#00467F"
        buttonTxtColor: "#FFFFFF"
        fontType: "Verdana"

Creation of a transaction

In the controller

public function indexAction()
{
  $client = $this->getRepository('PilotOgonePaymentBundle:OgoneClient')->findOneBy(array(
      'email' => 'test@test.com',
  ));

  if (!$client) {
      $client = new OgoneClient();
      $client->setEmail('test@test.com');

      $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(),
      )
  );
}

And the feedback:

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'
  );
}

Alias managment

You have Ogone premium account with alias option:

Update config.yml

pilot_ogone_payment:
    general:
        use_aliases: true

In your transaction controller

// 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

See a complete controller implementation here https://github.com/pilot/OgonePaymentBundle/blob/master/Controller/PaymentController.php