$cc = new prestaPaypal( sfConfig::get('sf_plugins_dir').DIRECTORY_SEPARATOR.'prestaPaypalPlugin'.DIRECTORY_SEPARATOR.'sdk'.DIRECTORY_SEPARATOR.'lib' );
$cc->setUserName( 'mysandboxapiusername' );
$cc->setPassword( 'mysandboxapipassword' );
$cc->setSignature('mysandboxapisignature');
$cc->setTestMode(true);
sfLoader::loadHelpers(array('Url'));
$cc->setCancelURL(url_for('order/cancelpaypal', true));
$cc->setReturnURL(url_for('order/chargepaypal', true));
$cc->setTransactionTotal('39.95');
$cc->setTransactionDescription('Registration');
$goto = $cc->GetExpressUrl();
if ( $goto ){
$this->redirect($goto);
}else{
$this->error = $cc->getErrorString() ;
} $this->redirect($goto.'&useraction=commit'); public function executePaypalConfirm(sfWebRequest $request)
{
$this->forward404Unless($token = $request->getParameter('token'));
$basket = BasketPeer::getUserBasket();
$cc = new prestaPaypal();
$cc->setUserName(sfConfig::get('mod_order_paypal_user'));
$cc->setPassword(sfConfig::get('mod_order_paypal_password'));
$cc->setSignature(sfConfig::get('mod_order_paypal_signature'));
$cc->setTestMode(sfConfig::get('mod_order_paypal_test'));
$cc->setTransactionTotal(round($basket->getTotalValue()/100,2));
if(!$cc->chargeExpressCheckout($token)) $this->errormessage = $cc->getErrorString();
$basket->setCheckedOut(1);
$basket->save();
} public function __construct($path=null)
{
$path = sfConfig::get('mod_order_paypal_path');
if( !is_null($path) )
{
// Get rid of the many warnings from the Paypal API
error_reporting(E_ERROR | E_WARNING | E_PARSE);
ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . $path);
require_once 'PayPal.php';
require_once 'PayPal/Profile/Handler/Array.php';
require_once 'PayPal/Profile/API.php';
}
}Users browsing this forum: No registered users and 1 guest