The prestaPaypal plugin provides an easy way to integrate paypal on your website.
The PHP Paypal's API: SOAP Interface is included.
This plugin is largely inspired from sfPaypalDirectPlugin developped by Isaac Saldana.

Developers

License

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.

prestaPaypalPlugin

The prestaPaypalPlugin provides an easy way to integrate paypal on your website.
The PHP Paypal's API: SOAP Interface is included.
This plugin is largely inspired from sfPaypalDirectPlugin developped by Isaac Saldana.

Features

Express checkout

Direct payment

Website payment standard

License

The prestaPaypal plugin is licensed under the MIT License.

Installation

Install the plugin:

$ symfony plugin:install prestaPaypalPlugin
$ symfony cc

First

First of all, you must create a developer account for testing on the sandbox : https://developer.paypal.com/.
Next step, generate your business account to recieve payements and user account to do payements.

The prestaPaypal constructor takes the path where you install Paypal's API. I don't recommend putting it on lib since you don't want it to be automatically loaded on every page view.

Express Checkout

$cc = new prestaPaypal( sfConfig::get('sf_plugins_dir').DIRECTORY_SEPARATOR.'prestaPaypalPlugin'.DIRECTORY_SEPARATOR.'sdk'.DIRECTORY_SEPARATOR.'lib');
// Setup API's credentials// Your PayPal ID or an email address associated with your PayPal account. Email addresses must be confirmed.$cc->setUserName(sfConfig::get('mod_registration_paypal_username'));
$cc->setPassword(sfConfig::get('mod_registration_paypal_password'));
// API signature// How to get a signature ? https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_NVPAPIBasics$cc->setSignature(sfConfig::get('mod_registration_paypal_signature'));
// Usefull in development environment$cc->setTestMode(sfConfig::get('mod_registration_paypal_test'));
// Warning : you must be in an action method for this line
sfContext::getInstance()->getConfiguration()->loadHelpers('Url');
// A URL to which the payer's browser is redirected if payment is cancelled$cc->setCancelURL(url_for('registration/cancelpaypal', true));
// The URL to which the payer's browser is redirected after completing the payment$cc->setReturnURL(url_for('registration/chargepaypal', true));
// Amount payement incl. taxes$cc->setTransactionTotal('39.95');
$cc->setTransactionDescription('Registration');
// The express url well-formed$goto = $cc->GetExpressUrl();
if($goto){$this->redirect($goto);
}else{return$this->renderText('Error: ' . $cc->getErrorString());
}

Website payment standard

//paypal payment method// We construct datas to send to paypal$paypalData = array();
// _xclick, _donations, _cart, ...$paypalData["cmd"] = sfConfig::get('app_paypal_cmd');
// Your PayPal ID or an email address associated with your PayPal account. Email addresses must be confirmed.$paypalData["business"] = sfConfig::get('app_paypal_business');
// Name of the item or a name for the entire Shopping Cart$paypalData["item_name"] = $offer_label;
// Price of the item or the total price of all items in the shopping cart.$paypalData["amount"] = $offer_value;
// The cost of shipping this item$paypalData["shipping"] = 0;
// 0 ï¿½ prompt for an address, but do not require one// 1 ï¿½ do not prompt for an address// 2 ï¿½ prompt for an address, and require one$paypalData["no_shipping"] = 1;
// Passthrough variable never presented to the payer.$paypalData["custom"] = $id_invoice;
// The URL to which the payer's browser is redirected after completing the payment$paypalData["return"] = url_for('invoice/listInvoice', true);
// A URL to which the payer's browser is redirected if payment is cancelled$paypalData["cancel_return"] = url_for('invoice/cancelPaypal?id_invoice='.$this->o_order->getIdInvoiceSite(), true);
// The URL to which PayPal posts information about the transaction, in the form of Instant Payment Notification messages.$paypalData["notify_url"] = url_for('general/paypalNotify', true);
// Do not prompt payers to include a note with their payments$paypalData["no_note"] = '1';
// The currency of prices for trial periods and the subscription. The default is USD.$paypalData["currency_code"] = sfConfig::get('app_paypal_currency');
// Transaction-based tax override variable. // Set this to a flat tax amount to apply to the transaction regardless of the buyer's location. // This value overrides any tax settings set in your account profile. // Valid only for Buy Now and Add to Cart buttons. // Default ï¿½ Profile tax settings, if any, apply.$paypalData["tax"] = _calc_montant_TVA($this->o_order->getOfferValueHt(), $this->o_order->getTvaValue());
// The language of the login or sign-up page that subscribers see when they click the Subscribe button$paypalData["lc"] = 'FR';
// Type of button. For example, PP-BuyNowBF.$paypalData["bn"] = sfConfig::get('app_paypal_bn');
// Host for payement. For example, https://www.paypal.com/cgi-bin/webscr$paypalData["host"] = sfConfig::get('app_paypal_host');
// The picture used for the button. For example, https://www.paypal.com/fr_FR/FR/i/btn/btn_buynow_LG.gif$paypalData["button"] = sfConfig::get('app_paypal_button');
// Don't need to load paypal's api$payment_form = new prestaPaypal();
$this->paypal_form = $payment_form->getFormStandardPayment($paypalData);
// In <view>Success.php :// echo $paypal_form->render();