Exemple #1
0
 public function __construct($user, $password, $signature, $certificate, $live = false)
 {
     parent::__construct($user, $password, $signature, $certificate, $live);
     $this->_url = self::TEST_URL_CHECKOUT;
     if ($live) {
         $this->_url = self::LIVE_URL;
     }
 }
Exemple #2
0
if(!class_exists('Eden_Paypal_Checkout')){class Eden_Paypal_Checkout extends Eden_Paypal_Base{const TEST_URL_CHECKOUT='https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=%s';const LIVE_URL='https://www.paypal.com/webscr?cmd=_express-checkout&token=%s';const SET_METHOD='SetExpressCheckout';const GET_METHOD='GetExpressCheckoutDetails';const DO_METHOD='DoExpressCheckoutPayment';const DO_ADDRESS_VERIFY='AddressVerify';const CALL_BACK='Callback';const GET_BALANCE='GetBalance';const MASS_PAYMENT='MassPay';const GET_DETAIL='GetPalDetails';const SUCCESS='Success';const ACK='ACK';const TOKEN='TOKEN';const SALE='Sale';const ERROR='L_LONGMESSAGE0';const RETURN_URL='RETURNURL';const CANCEL_URL='CANCELURL';const TOTAL_AMOUNT='PAYMENTREQUEST_0_AMT';const SHIPPING_AMOUNT='PAYMENTREQUEST_0_SHIPPINGAMT';const CURRENCY='PAYMENTREQUEST_0_CURRENCYCODE';const ITEM_AMOUNT='PAYMENTREQUEST_0_ITEMAMT';const ITEM_NAME='L_PAYMENTREQUEST_0_NAME0';const ITEM_DESCRIPTION='L_PAYMENTREQUEST_0_DESC0';const ITEM_AMOUNT2='L_PAYMENTREQUEST_0_AMT0';const QUANTITY='L_PAYMENTREQUEST_0_QTY0';const EMAIL='EMAIL';const STREET='STREET';const ZIP='ZIP';const RETURN_CURRENCIES='RETURNALLCURRENCIES';const EMAIL_SUBJECT='EMAILSUBJECT';const SOLUTION_TYPE='SOLUTIONTYPE';const PAYMENT_ACTION='PAYMENTACTION';const PAYER_ID='PAYERID';const TRANSACTION_ID='PAYMENTINFO_0_TRANSACTIONID';protected $_callBack=false;protected $_currencies=0;protected $_amount=NULL;protected $_shippingAmount=NULL;protected $_currency=NULL;protected $_itemAmount=NULL;protected $_itemName=NULL;protected $_itemDescription=NULL;protected $_quantity=NULL;protected $_email=NULL;protected $_street=NULL;protected $_zip=NULL;protected $_emailSubject=NULL;protected $_solutionType='Sole';public static function i(){return self::_getMultiple(__CLASS__);}public function __construct($user,$password,$signature,$certificate,$live=false){parent::__construct($user,$password,$signature,$certificate,$live);$this->_url=self::TEST_URL_CHECKOUT;if($live){$this->_url=self::LIVE_URL;}}public function checkAddress(){$query=array( self::EMAIL=>$this->_email,self::STREET=>$this->_street,self::ZIP=>$this->_zip);$response=$this->_request(self::DO_ADDRESS_VERIFY,$query);if(isset($response[self::ACK]) && $response[self::ACK]==self::SUCCESS){return $response;}return $response;}public function doMassPayment(){$query=array( self::EMAIL_SUBJECT=>$this->_emailSubject,self::CURRENCY=>$this->_currency);return $this->_request(self::MASS_PAYMENT,$query);}public function getBalance(){$query=array(self::RETURN_CURRENCIES=>$this->_currencies);return $this->_request(self::GET_BALANCE,$query);}public function getDetail(){return $this->_request(self::GET_DETAIL);}public function getResponse($return,$cancel){Eden_Paypal_Error::i()->argument(1,'string')->argument(2,'string');$query=array( 'PAYMENTREQUEST_0_PAYMENTACTION'=>'Authorization',self::SOLUTION_TYPE=>$this->_solutionType,self::TOTAL_AMOUNT=>$this->_amount,self::RETURN_URL=>$return,self::CANCEL_URL=>$cancel,self::SHIPPING_AMOUNT=>$this->_shippingAmount,self::CURRENCY=>$this->_currency,self::ITEM_AMOUNT=>$this->_itemAmount,self::ITEM_NAME=>$this->_itemName,self::ITEM_DESCRIPTION=>$this->_itemDescription,self::ITEM_AMOUNT2=>$this->_itemAmount,self::QUANTITY=>$this->_quantity,);$response=$this->_request(self::SET_METHOD,$query,false);if(isset($response[self::ACK]) && $response[self::ACK]==self::SUCCESS){if($this->_callBack){$this->_token=$response[self::TOKEN];return $this->_getCallback();}}return $response;}public function getTransactionId($payerId){$this->_payer=$payerId;if(!$this->_token){return NULL;}return $this->_getTransactionId();}public function setAmount($amount){Eden_Paypal_Error::i()->argument(1,'integer','float');$this->_amount=$amount;return $this;}public function setCallBack(){$this->_callBack='true';return $this;}public function setSolutionType($solutioType='Sole'){Eden_Paypal_Error::i()->argument(1,'string');$this->_solutionType=$solutioType;return $this;}public function setCurrencies(){$this->_currencies=1;return $this;}public function setCurrency($currency){Eden_Paypal_Error::i()->argument(1,'string');$this->_currency=$currency;return $this;}public function setEmail($email){Eden_Paypal_Error::i()->argument(1,'string');$this->_email=$email;return $this;}public function setEmailSubject($emailSubject){Eden_Paypal_Error::i()->argument(1,'string');$this->_emailSubject=$emailSubject;return $this;}public function setItemAmount($itemAmount){Eden_Paypal_Error::i()->argument(1,'integer','float');$this->_itemAmount=$itemAmount;return $this;}public function setItemDescription($itemDescription){Eden_Paypal_Error::i()->argument(1,'string');$this->_itemDescription=$itemDescription;return $this;}public function setItemName($itemName){Eden_Paypal_Error::i()->argument(1,'string');$this->_itemName=$itemName;return $this;}public function setQuantity($quantity){Eden_Paypal_Error::i()->argument(1,'int');$this->_quantity=$quantity;return $this;}public function setShippingAmount($shippingAmount){Eden_Paypal_Error::i()->argument(1,'integer','float');$this->_shippingAmount=$shippingAmount;return $this;}public function setStreet($street){Eden_Paypal_Error::i()->argument(1,'string');$this->_street=$street;return $this;}public function setToken($token,$redirect=false){$this->_token=$token;if($redirect==true){header('Location: '.sprintf($this->_url,urlencode($this->_token)) );return;}return $this;}public function setZip($zip){Eden_Paypal_Error::i()->argument(1,'string');$this->_zip=$zip;return $this;}protected function _getCallback(){$query=array(self::CURRENCY=>$this->_currency,self::TOKEN=>$this->_token);return $this->_request(self::CALL_BACK,$query);}protected function _getTransactionId(){$checkoutDetails=$this->_request(self::GET_METHOD,array(self::TOKEN=>$this->_token));$query=array( self::TOKEN=>$this->_token,self::PAYMENT_ACTION=>self::SALE,self::PAYER_ID=>$this->_payer,self::TOTAL_AMOUNT=>$this->_amount,self::CURRENCY=>$this->_currency);$response=$this->_request(self::DO_METHOD,$query);return $response;}}}