Exemple #1
0
 /**
  * Make the paypal request and return a Response object
  *
  * @param AbstractRequest $model
  * @return Response
  * @throws Exception
  */
 public function send(AbstractRequest $model)
 {
     try {
         $client = $this->client;
         $config = $this->config;
         if (false === $config->isValid()) {
             throw new \Exception("Configuration is not valid.");
         }
         if (is_null($client)) {
             throw new \Exception('Zend\\Http\\Client must be set and must be valid.');
         }
         if (false === $model->isValid()) {
             throw new \Exception(get_class($model) . " is invalid.");
         }
         $client->setMethod('POST');
         $client->setUri(new \Zend\Uri\Http($config->getEndpoint()));
         $client->setRawBody($config . $model);
         $httpResponse = $client->send();
         $response = new Response($httpResponse->getBody());
     } catch (\Exception $e) {
         $response = new Response();
         $response->addError($e->getMessage());
     }
     return $response;
 }
 public function toArray()
 {
     $data = parent::toArray();
     $idx = 0;
     if (!is_null($this->_paymentDetails)) {
         foreach ($this->_paymentDetails as $paymentDetail) {
             $paymentDetail->setPrefix("PAYMENTREQUEST_{$idx}_");
             $data = array_merge($data, $paymentDetail->toArray());
             $idx++;
         }
     }
     //parse shipping options
     if (!is_null($this->_shippingOptions)) {
         $option = $this->_shippingOptions;
         for ($i = 0; $i < count($option); $i++) {
             if (!$option[$i] instanceof ExpressShippingOption) {
                 continue;
             }
             $data["L_SHIPPINGOPTIONNAME{$i}"] = $option[$i]->getName();
             $data["L_SHIPPINGOPTIONAMOUNT{$i}"] = $option[$i]->getAmount();
             $data["L_SHIPPINGOPTIONISDEFAULT{$i}"] = $option[$i]->getDefault();
         }
     }
     return $data;
 }
 public function __construct($options = array())
 {
     parent::__construct($options);
     $this->setMethod('getExpressCheckoutDetails');
 }
 public function __construct($options = array())
 {
     parent::__construct($options);
     $this->setMethod('RefundTransaction');
 }
 public function __construct($options = array())
 {
     parent::__construct($options);
     $this->setMethod('getTransactionDetails');
 }
Exemple #6
0
 public function __construct($options = array())
 {
     parent::__construct($options);
     $this->setMethod('DoVoid');
 }
Exemple #7
0
 /**
  * TransactionId received from doDirectPayment
  * Amount is the amount of funds to capture
  *
  * @param $transactionId
  * @param $amount
  */
 public function __construct($options = array())
 {
     parent::__construct($options);
     $this->setMethod('doCapture');
 }
 public function __construct($options = array())
 {
     parent::__construct($options);
     $this->setMethod('doAuthorization');
 }
 public function __construct($options = array())
 {
     parent::__construct($options);
     $this->setMethod('GetBalance');
 }
 public function toArray()
 {
     $data = parent::toArray();
     $data = array_merge($data, $this->_paymentDetails->toArray());
     if (!is_null($this->_address)) {
         //get address
         $address = $this->_address->toArray();
         if (isset($address['PHONENUM'])) {
             $address['SHIPTOPHONENUM'] = $address['PHONENUM'];
             unset($address['PHONENUM']);
         }
         $data = array_merge($data, $address);
     }
     if (!is_null($this->_shipAddress)) {
         $shipAddress = $this->_shipAddress->toArray();
         $tmp = array();
         foreach ($shipAddress as $key => $value) {
             $tmp["SHIPTO{$key}"] = $value;
         }
         $data = array_merge($data, $tmp);
     }
     return $data;
 }
Exemple #11
0
 public function toArray()
 {
     $data = parent::toArray();
     if (!is_null($this->_shippingOptions)) {
         $option = $this->_shippingOptions;
         for ($i = 0; $i < count($option); $i++) {
             if (!$option[$i] instanceof ExpressShippingOption) {
                 continue;
             }
             $data["L_SHIPPINGOPTIONNAME{$i}"] = $option[$i]->getName();
             $data["L_SHIPPINGOPTIONLABEL{$i}"] = $option[$i]->getLabel();
             $data["L_SHIPPINGOPTIONAMOUNT{$i}"] = $option[$i]->getAmount();
             $data["L_TAXAMT{$i}"] = $option[$i]->getTaxAmount();
             $data["L_INSURANCEAMOUNT{$i}"] = $option[$i]->getInsuranceAmount();
             $data["L_SHIPPINGOPTIONISDEFAULT{$i}"] = $option[$i]->getDefault();
         }
     }
     return $data;
 }
 public function toArray()
 {
     $data = parent::toArray();
     //parse payment details
     if (is_null($this->_paymentDetails)) {
         throw new \Exception("Missing payment details.");
     }
     $idx = 0;
     foreach ($this->_paymentDetails as $paymentDetail) {
         $paymentDetail->setPrefix("PAYMENTREQUEST_{$idx}_");
         $data = array_merge($data, $paymentDetail->toArray());
         $idx++;
     }
     return $data;
 }