![]() |
|
sfPaymentPlugin - 0.1.0A set of plugins to ease online payment implementation. |
|
![]() |
21
users
Sign-in
to change your status |
The sfPaymentPlugin intends to bring a standard, flexible and maintainable solution for managing online payments using the symfony framework throughout a set of plugins. |
WARNING : This plugin is in alpha state, therefore NOT READY for production. It still needs contribution to be fully functional.
The sfPaymentPlugin intends to bring a standard, flexible and maintainable solution
for managing online payments using the symfony framework throughout a set of plugins.
Please visit the official plugin page of the sfPayment project for more information.
Note : The only provider available as of this first release day is PayPal in standard mode. Please check sfPaymentPayPalPlugin for more information on PayPal support.
| Name | Status | |
|---|---|---|
|
|
lead | moc.docstel <<ta>> qcrelcel.eniotna |
|
|
developer | moc.docstel <<ta>> fuottal.ynnhoj |
|
|
developer | moc.48dnuor <<ta>> njiram |
|
|
developer | moc.liamg <<ta>> ruofphp |
Copyright (c) 2009 Contributors of this plugin, please visit http://wiki.github.com/letscod/sfPaymentPlugin
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.1.0alpha | MIT license | 0.1.0alpha | 24/07/2009 |
This is the first version of the plugin. It is NOT READY for production yet (i.e alpha state).
This is the first version of the plugin. It is NOT READY for production yet (i.e alpha state).
WARNING : This plugin is in alpha state, therefore NOT READY for production. It still needs contribution to be fully functional.
The sfPaymentPlugin intends to bring a standard, flexible and maintainable solution
for managing online payments using the symfony framework throughout a set of plugins.
Please visit the official plugin page of the sfPayment project for more information.
Note : The only provider available as of this first release day is PayPal in standard mode. Please check sfPaymentPayPalPlugin for more information on PayPal support.
Install the plugin
$ symfony plugin:install sfPaymentPlugin --stability=alpha
Clear you cache
$ symfony cc
Yes, it's always easier when we understand each others.
Gateway : It consists of the payment gateway (PayPal, Paybox, Google Checkout, Amazon Payments, 2CheckOut, ...). Each gateway object extends the sfPaymentGatewayInterface interface (see sfPaymentPlugin/lib/sfPaymentGatewayInterface.class.php). As of today, only PayPal is supported.
Transaction : The transaction deals with the money exchange and sends the required information to the gateway.
sfPayment plugins : As discussed on the mailing-lists (see the official plugin page), each gateway support files will be stored in a specific plugin. The sfPayment plugins (or sfPayment plugin suite) consist of all plugins related to sfPayment (sfPaymentPlugin, sfPaymentPayPalPlugin, sfPaymentPayboxPlugin, sfPaymentGoogleCheckoutPlugin...). The goal is to ease the development of gateway support. It still needs to be proven productive for developers, we may switch to integrating all gateway support in a single plugin. Any advice on this is welcome.
This plugin is required to use any sfPayment plugins (sfPaymentPayPal, sfPaymentPaybox, sfPayment[gateway]...). As explained in the introduction, the only supported gateway is PayPal as of today. It brings class and modules structure to ease implementation of online payment.
It contains mainly 2 classes :
It contains as well an helper, basic unit test and a mock class.
The following code creates a simple transaction using the PayPal gateway interface. It is located of the actions.class.php of your payment module.
#app/modules/payment/actions.class.php
// create paypal library instance
$gateway = new sfPaymentPayPal();
// instanciate transaction
$this->transaction = new sfPaymentTransaction($gateway);
// enable test mode if needed
$this->transaction->enableTestMode();
// define transaction information :
// - currency
$this->transaction->setCurrency("USD");
// - product information
$this->transaction->setAmount('20');
$this->transaction->setProductName('a $20 symfony book, deal !');
The following code creates the now famous "Pay with PayPal" button. It uses the Payment helper which brings the payment_form_tag_for function that will create the form tag with the hidden parameters.
<?php use_helper('Payment'); ?>
<h1>Sample : Pay with PayPal</h1>
<?php echo payment_form_tag_for($transaction->getGateway()); ?>
<input type="submit" value="Pay with PayPal">
</form>
The generated HTML looks like the following.
<h1>Sample : Pay with PayPal</h1>
<form method="POST" name="gateway_form" action="https://www.sandbox.paypal.com/cgi-bin/webscr">
<input type="hidden" name="rm" value="2"/>
<input type="hidden" name="cmd" value="_xclick"/>
<input type="hidden" name="return" value="http://localhost/sfPaymentPayPal/success"/>
<input type="hidden" name="cancel_return" value="http://localhost/sfPaymentPayPal/failure"/>
<input type="hidden" name="notify_url" value="http://localhost/sfPaymentPayPal/ipn"/>
<input type="hidden" name="business" value="seller_1248418954_biz@letscod.com"/>
<input type="hidden" name="currency_code" value="USD"/>
<input type="hidden" name="amount" value="20"/>
<input type="hidden" name="item_name" value="a $20 symfony book, deal !"/>
<input type="submit" value="Pay with PayPal">
</form>
Clicking on the "Pay with PayPal" link will bring you to the PayPal payment page.

The IPN validation is implemented in BasesfPaymentPayPalActions.class.php located in the sfPaymentPayPal module's lib.
The IPN consists of a verification with the gateway that a payment was processed. In the sfPaymentPayPalPlugin, it is processed at 2 specific times :
Finally, all you have to do is define the methods related to each payment status in the action.
#sfPaymentPayPalPlugin/modules/sfPaymentPayPal/actions/actions.class.php
/**
* Transaction verified and completed
*
* @param array $post_parameters
*/
public function transactionCompleted(sfWebRequest $request)
{
}
/**
* Transaction verified and failed
*
* @param array $post_parameters
*/
public function transactionFailed(sfWebRequest $request)
{
}
/**
* Transaction invalid (not verified)
*
* @param array $post_parameters
*/
public function transactionInvalid(sfWebRequest $request)
{
}
IMPORTANT : The sfPaymentPlugin does not (yet?) validate that the transaction information matches the IPN returns. It is the responsability of the developer to implement the check.
That's it !
The payment is made and we were able to validate with the gateway that the IPN information are correct.
The gateway was injected in the transaction object. We only used the transaction standard methods as well as pseudo-behaviors action classes.
Please provide feedbacks, comments, support on the symfony-payment-developers Google Group
