Esempio n. 1
0
 public function loadPaymentInfo()
 {
     $this->payment->freetrial = 0;
     $this->payment->amount = null;
     $this->payment->method_name = null;
     if (!empty($this->passthrough['task'])) {
         $task = $this->passthrough['task'];
     } else {
         $task = "";
     }
     if (empty($this->cart) && !empty($this->plan)) {
         if (!isset($this->recurring)) {
             $this->recurring = 0;
         }
         $terms = $this->plan->getTermsForUser($this->recurring, $this->metaUser);
         if (!empty($terms)) {
             if (is_object($terms->nextterm)) {
                 $this->payment->amount = $terms->nextterm->renderTotal();
                 if ($terms->nextterm->free && $terms->nextterm->get('type') == 'trial') {
                     $this->payment->freetrial = 1;
                 }
             }
         } else {
             $this->payment->amount = null;
         }
         $this->items->itemlist[] = array('item' => array('obj' => $this->plan), 'terms' => $terms);
     } elseif (!empty($this->cartobject->id) || $task == 'confirmCart') {
         $this->getCart();
         $this->payment->amount = $this->cartobject->getAmount($this->metaUser, 0, $this);
     } else {
         $this->payment->amount = $this->invoice->amount;
     }
     $this->payment->amount = AECToolbox::correctAmount($this->payment->amount);
     if (empty($this->payment->currency) && !empty($this->invoice->currency)) {
         $this->payment->currency = $this->invoice->currency;
     }
     // Amend ->payment
     if (!empty($this->payment->currency)) {
         $this->payment->currency_symbol = AECToolbox::getCurrencySymbol($this->payment->currency);
     } else {
         $this->payment->currency_symbol = '';
     }
     if (!empty($this->plan)) {
         $this->payment->amount_format = AECToolbox::formatAmountCustom($this, $this->plan);
     } else {
         if (!empty($this->payment->currency)) {
             $this->payment->amount_format = AECToolbox::formatAmount($this->payment->amount, $this->payment->currency);
         } else {
             $this->payment->amount_format = AECToolbox::formatAmount($this->payment->amount);
         }
     }
 }
Esempio n. 2
0
 /**
  * @param InvoiceFactory $request
  */
 static function formatAmountCustom($request, $plan, $forcedefault = false, $proposed = null)
 {
     if (empty($plan->params['customamountformat']) || $forcedefault) {
         $format = '{aecjson}{"cmd":"condition","vars":[{"cmd":"data","vars":"payment.freetrial"},' . '{"cmd":"concat","vars":[{"cmd":"constant","vars":"CONFIRM_FREETRIAL"}," ",{"cmd":"data","vars":"payment.method_name"}]},' . '{"cmd":"concat","vars":[{"cmd":"data","vars":"payment.amount"},{"cmd":"data","vars":"payment.currency_symbol"}," - ",{"cmd":"data","vars":"payment.method_name"}]}' . ']}{/aecjson}';
     } else {
         $format = $plan->params['customamountformat'];
     }
     $request->payment->amount = AECToolbox::formatAmount($request->payment->amount);
     $rwEngine = new reWriteEngine();
     $rwEngine->resolveRequest($request);
     $amount = $rwEngine->resolve($format);
     if (strpos($amount, 'JSON PARSE ERROR') !== false) {
         if (!$forcedefault) {
             return AECToolbox::formatAmountCustom($request, $plan, true, $amount);
         } else {
             return $proposed;
         }
     }
     return $amount;
 }