/**
  * Retourne le montant total de la somme devant être
  * distribuée aux affiliés
  */
 protected function _getTotalAmountForAffiliates($installement_nr)
 {
     $affiliates = $this->order[0]->getAffiliate();
     if (!HIPAY_MAPI_UTILS::is_an_array_of($affiliates, 'HIPAY_MAPI_Affiliate')) {
         return false;
     }
     $total_aff = 0;
     foreach ($affiliates as $aff) {
         $total_aff += $aff->getAmount();
     }
     return $total_aff;
 }
Пример #2
0
 /**
  * Vérifie si l'objet est correctement initialisé
  *
  * @return float
  */
 public function check()
 {
     if ($this->price < 0) {
         throw new Exception('Montant invalide ou pas initilisé');
     }
     if (!HIPAY_MAPI_UTILS::is_an_array_of($this->tax, 'HIPAY_MAPI_Tax')) {
         throw new Exception('Taxes invalides ou pas initialisées');
     }
     foreach ($this->tax as $obj) {
         if (!$obj->check()) {
             return false;
         }
     }
     if (!is_bool($this->first)) {
         throw new Exception('Premier paiement ou suivant n\'est pas initialisé');
     }
     return true;
 }
Пример #3
0
 /**
  * Vérifie que l'objet est correctement initialisé
  *
  * @return boolean
  */
 public function check()
 {
     //if ($this->name=='' || $this->quantity<0 || $this->category<0 || $this->price<0 || !HIPAY_MAPI_UTILS::is_an_array_of($this->tax,'HIPAY_MAPI_Tax'))
     if ($this->name == '' || $this->quantity < 0 || $this->category < 0 || !HIPAY_MAPI_UTILS::is_an_array_of($this->tax, 'HIPAY_MAPI_Tax')) {
         throw new Exception('L\'objet n\'à pas été initialisé. Vous devez préciser un nom de produit, une quantité, un prix, une catégorie et des taxes');
     }
     foreach ($this->tax as $obj) {
         if (!$obj->check()) {
             return false;
         }
     }
     return true;
 }
Пример #4
0
 protected function init($paymentParams, $order, $items)
 {
     if (!$paymentParams instanceof HIPAY_MAPI_PaymentParams || !HIPAY_MAPI_UTILS::is_an_array_of($order, 'HIPAY_MAPI_Order') || !HIPAY_MAPI_UTILS::is_an_array_of($items, 'HIPAY_MAPI_Item') || count($items) < 1) {
         throw new Exception('Wrong parameters');
     }
     try {
         $paymentParams->check();
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
     }
     foreach ($order as $orderObj) {
         try {
             $orderObj->check();
         } catch (Exception $e) {
             throw new Exception($e->getMessage());
         }
     }
     foreach ($items as $obj) {
         try {
             $obj->check();
         } catch (Exception $e) {
             throw new Exception($e->getMessage());
         }
     }
     $this->paymentParams = clone $paymentParams;
     $this->paymentParams->lock();
     foreach ($order as $obj) {
         $this->order[] = clone $obj;
         end($this->order)->lock();
         $this->_taxItemsAmount[] = 0;
         $this->_taxShippingAmount[] = 0;
         $this->_taxInsuranceAmount[] = 0;
         $this->_taxFixedCostAmount[] = 0;
         $this->_itemsTotalAmount[] = 0;
         $this->_taxTotalAmount[] = 0;
         $this->_orderTotalAmount[] = 0;
         $this->_affiliateTotalAmount[] = 0;
     }
     foreach ($items as $obj) {
         $this->items[] = clone $obj;
         end($this->items)->lock();
     }
     try {
         $this->compute();
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
     }
 }
Пример #5
0
 /**
  * Défini les affiliés qui recevront une rétribution pour cette commande
  *
  * @param array $affiliate
  * @return boolean
  */
 public function setAffiliate($affiliate)
 {
     if ($this->_locked) {
         return false;
     }
     if (empty($affiliate)) {
         return false;
     }
     if (!HIPAY_MAPI_UTILS::is_an_array_of($affiliate, 'HIPAY_MAPI_Affiliate')) {
         return false;
     }
     foreach ($affiliate as $obj) {
         $this->affiliate[] = clone $obj;
     }
     return true;
 }
Пример #6
0
 /**
  * Vérifie que l'objet est correctement initialisé
  *
  * @return boolean
  */
 public function check()
 {
     if ($this->name == '' || $this->quantity < 0 || $this->category < 0 || $this->price < 0 || !HIPAY_MAPI_UTILS::is_an_array_of($this->tax, 'HIPAY_MAPI_Tax')) {
         throw new Exception('Object not initialized. Please precise a product name, quantity, price, category and taxes');
     }
     foreach ($this->tax as $obj) {
         if (!$obj->check()) {
             return false;
         }
     }
     return true;
 }