![]() |
|
sfPayzenPlugin - 0.0.3Symfony plugin for Payzen |
|
![]() |
0
user
Sign-in
to change your status |
This plugins provides basic features to interact with Payzen |
This plugins provides basic features to use PayZen platform. See the readme for more informations.
| Name | Status | |
|---|---|---|
|
|
lead | moc.evitcaretni-noitulos <<ta>> sotnas-sod.kcirtap |
Copyright (c) 2012 Patrick Dos Santos
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
| Version | License | API | Released |
|---|---|---|---|
| 0.0.3alpha | MIT license | 0.0.3alpha | 02/07/2012 |
| 0.0.2alpha | MIT license | 0.0.2alpha | 20/06/2012 |
| 0.0.1alpha | MIT license | 0.0.1alpha | 20/06/2012 |
| Version | License | API | Released |
|---|---|---|---|
| 0.0.3alpha | MIT license | 0.0.3alpha | 02/07/2012 |
| 0.0.2alpha | MIT license | 0.0.2alpha | 20/06/2012 |
| 0.0.1alpha | MIT license | 0.0.1alpha | 20/06/2012 |
The sfPayzenPlugin is a symfony plugin that provides basic features to use
the Payzen payment plateform
It gives you the classes and the component to create a "Pay" button on your website's pages.
This plugin has been tested for the 2.8 version of Payzen API.
Note that this plugin does not provide persistance in your database. See sfDoctrinePayzenPlugin for a Doctrine implementation for Payzen. Since there is no database persistance, the generation of the vads_trans_id is not provided by this plugin.
Install the plugin (via a package) :
symfony plugin:install sfPayzenPlugin
Install the plugin (via a Subversion checkout) :
svn co http//svn.symfony-project.com/plugins/sfPayzenPlugin/trunk plugins/sfPayzenPlugin
Activate the plugin in the config/ProjectConfiguration.class.php :
class ProjectConfiguration extends sfProjectConfiguration { public function setup() { $this->enablePlugins(array( 'sfPayzenPlugin', )); } }
Enable the module in your settings.yml :
all:
.settings:
enabled_modules: [default, sfPayzenPlugin]Clear you cache
symfony cc
The easiest way to use the plugin is to configure it in the app.yml
Set your parameters in app.yml (see the Payzen documentation for more information) :
all:
sf_payzen_plugin:
options:
vads_site_id: your_payzen_id
certificate: your_certificate
vads_ctx_mode: TEST
vads_currency: 978 #(euro)
vads_action_mode: INTERACTIVE
Configure the payment in your actions.class.php :
public function executeMyAction(sfWebRequest $request) { [...] $this->options = array( 'vads_amount' => 100000, 'vads_trans_id' => $vadsTransId, ); }
Add the component in your template :
<?php include_component('SfPayzen', 'payzenForm', array('options'=>$options, 'payzen_version'=>'2_8')) ?>
That's it. You should see a "Pay" button on your page
Although in most cases app.yml configuration might be sufficient, you can override all the options in your controller.
Note that you can use both way at the same time.
By default, the plugin uses the option specified in the option array. If the option is not set, it will check in the app.yml. Then if the option is still not set, and if it's a required option, the plugin will use the default Payzen value. Finally it will throw an Exception if there is no default value.
Overriding the options :
<?php public function executeMyAction(sfWebRequest $request) { [...] $this->options = array( 'certificate'=> your_certificate 'vads_ctx_mode'=> 'PROD' 'vads_action_mode'=> 'INTERACTIVE' 'vads_amount' => '100000', 'vads_trans_id' => $vadsTransId, ..., ); }
If you don't want to use the sfPayzenPlugin's component, you can set all you need to work with Payzen directly in the sfPayzenPayment class.
In your controller or custom class :
<?php public function myFunction() { [...] $options = array( 'certificate'=> your_certificate 'vads_ctx_mode'=> sfPayzenPayment_2_8::VADS_CTX_MODE_TEST 'vads_action_mode'=> VADS_ACTION_MODE_INTERACTIVE 'vads_amount' => '100000', 'vads_trans_id' => $vadsTransId, ..., ); $payment = new sfPayzenPayment_2_8($options); $signature = $payment->getSignature(); //You can still use the plugin's form $form = new sfPayzenPaymentForm($payment); }
If you want to do something with each sfPayzenPayment created, you can use the built-in symfony event manager. Each time a sfPayzenPayment is created, it notifies the event manager.
In your ProjectConfiguration.class.php add :
$this->dispatcher->connect('sf_payzen_plugin.new_payment', array('myListenerClass', 'listenToPayzenNewPayment'));
In your myListener.class.php :
<?php class myListener { static public function listenToPayzenNewPayment(sfEvent $event) { $sfPayzenPayment = $event->getSubject(); //Do something with the payment } }
