Ogone payment bundle for ogone.com
Doctrine port of Cedriclombardot/OgonePaymentBundle, (*1)
, (*2)
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 :, (*3)
"require": {
"pilot/ogone-payment-bundle": "dev-master"
}
Configure your kernel, (*4)
$bundles = array(
new Pilot\OgonePaymentBundle\PilotOgonePaymentBundle(),
);
Configure ogone in config.yml, (*5)
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, (*6)
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:, (*7)
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:, (*8)
Update config.yml
, (*9)
pilot_ogone_payment:
general:
use_aliases: true
In your transaction controller, (*10)
``` php
// Client recuperation HERE, (*11)
// Transaction creation HERE, (*12)
$transaction->save();, (*13)
if ($this->container->getParameter('ogone.use_aliases')) {
$alias = $this->getRepository('PilotOgonePaymentBundle:OgoneAlias')->findOneBy(array(
'client' => $client,
'operation' => OgoneAlias::OPERATION_BYMERCHANT,
'name' => 'ABONNEMENT',
));, (*14)
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);
}, (*15)
$form = $transaction->getForm();, (*16)
// render the view
```, (*17)
See a complete controller implementation here https://github.com/pilot/OgonePaymentBundle/blob/master/Controller/PaymentController.php, (*18)