當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PagSeguroHelper::decimalFormat方法代碼示例

本文整理匯總了PHP中PagSeguroHelper::decimalFormat方法的典型用法代碼示例。如果您正苦於以下問題:PHP PagSeguroHelper::decimalFormat方法的具體用法?PHP PagSeguroHelper::decimalFormat怎麽用?PHP PagSeguroHelper::decimalFormat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PagSeguroHelper的用法示例。


在下文中一共展示了PagSeguroHelper::decimalFormat方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getInstallments

 /**
  * Get from webservice installments for direct payment.
  * @param PagSeguroCredentials $credentials
  * @param $amount
  * @param $cardBrand
  * @param $maxInstallmentNoInterest
  * @return bool|PagSeguroInstallment
  * @throws Exception
  * @throws PagSeguroServiceException
  */
 public static function getInstallments(PagSeguroCredentials $credentials, $amount, $cardBrand = null, $maxInstallmentNoInterest = null)
 {
     $amount = PagSeguroHelper::decimalFormat($amount);
     LogPagSeguro::info("PagSeguroInstallmentService.getInstallments(" . $amount . ") - begin");
     self::$connectionData = new PagSeguroConnectionData($credentials, self::SERVICE_NAME);
     try {
         $connection = new PagSeguroHttpConnection();
         $connection->get(self::buildInstallmentURL(self::$connectionData, $amount, $cardBrand, $maxInstallmentNoInterest), self::$connectionData->getServiceTimeout(), self::$connectionData->getCharset());
         $httpStatus = new PagSeguroHttpStatus($connection->getStatus());
         switch ($httpStatus->getType()) {
             case 'OK':
                 $installments = PagSeguroInstallmentParser::readInstallments($connection->getResponse());
                 LogPagSeguro::info("PagSeguroInstallmentService.getInstallments() - end ");
                 break;
             case 'BAD_REQUEST':
                 $errors = PagSeguroInstallmentParser::readErrors($connection->getResponse());
                 $e = new PagSeguroServiceException($httpStatus, $errors);
                 LogPagSeguro::error("PagSeguroInstallmentService.getInstallments() - error " . $e->getOneLineMessage());
                 throw $e;
                 break;
             default:
                 $e = new PagSeguroServiceException($httpStatus);
                 LogPagSeguro::error("PagSeguroInstallmentService.getInstallments() - error " . $e->getOneLineMessage());
                 throw $e;
                 break;
         }
         return isset($installments) ? $installments : false;
     } catch (PagSeguroServiceException $e) {
         throw $e;
     } catch (Exception $e) {
         LogPagSeguro::error("Exception: " . $e->getMessage());
         throw $e;
     }
 }
開發者ID:KikoPoaRS,項目名稱:mudamuda,代碼行數:44,代碼來源:PagSeguroInstallmentService.class.php

示例2: getData

 /**
  * @param $payment PagSeguroPaymentRequest
  * @return mixed
  */
 public static function getData($payment)
 {
     $data = null;
     // reference
     if ($payment->getReference() != null) {
         $data["reference"] = $payment->getReference();
     }
     // sender
     if ($payment->getSender() != null) {
         if ($payment->getSender()->getName() != null) {
             $data['senderName'] = $payment->getSender()->getName();
         }
         if ($payment->getSender()->getEmail() != null) {
             $data['senderEmail'] = $payment->getSender()->getEmail();
         }
         // phone
         if ($payment->getSender()->getPhone() != null) {
             if ($payment->getSender()->getPhone()->getAreaCode() != null) {
                 $data['senderAreaCode'] = $payment->getSender()->getPhone()->getAreaCode();
             }
             if ($payment->getSender()->getPhone()->getNumber() != null) {
                 $data['senderPhone'] = $payment->getSender()->getPhone()->getNumber();
             }
         }
         // documents
         /** @var $document PagSeguroDocument */
         if ($payment->getSender()->getDocuments() != null) {
             $documents = $payment->getSender()->getDocuments();
             if (is_array($documents) && count($documents) == 1) {
                 foreach ($documents as $document) {
                     if (!is_null($document)) {
                         $data['senderCPF'] = $document->getValue();
                     }
                 }
             }
         }
     }
     // currency
     if ($payment->getCurrency() != null) {
         $data['currency'] = $payment->getCurrency();
     }
     // items
     $items = $payment->getItems();
     if (count($items) > 0) {
         $i = 0;
         foreach ($items as $key => $value) {
             $i++;
             if ($items[$key]->getId() != null) {
                 $data["itemId{$i}"] = $items[$key]->getId();
             }
             if ($items[$key]->getDescription() != null) {
                 $data["itemDescription{$i}"] = $items[$key]->getDescription();
             }
             if ($items[$key]->getQuantity() != null) {
                 $data["itemQuantity{$i}"] = $items[$key]->getQuantity();
             }
             if ($items[$key]->getAmount() != null) {
                 $amount = PagSeguroHelper::decimalFormat($items[$key]->getAmount());
                 $data["itemAmount{$i}"] = $amount;
             }
             if ($items[$key]->getWeight() != null) {
                 $data["itemWeight{$i}"] = $items[$key]->getWeight();
             }
             if ($items[$key]->getShippingCost() != null) {
                 $data["itemShippingCost{$i}"] = PagSeguroHelper::decimalFormat($items[$key]->getShippingCost());
             }
         }
     }
     // extraAmount
     if ($payment->getExtraAmount() != null) {
         $data['extraAmount'] = PagSeguroHelper::decimalFormat($payment->getExtraAmount());
     }
     // shipping
     if ($payment->getShipping() != null) {
         if ($payment->getShipping()->getType() != null && $payment->getShipping()->getType()->getValue() != null) {
             $data['shippingType'] = $payment->getShipping()->getType()->getValue();
         }
         if ($payment->getShipping()->getCost() != null && $payment->getShipping()->getCost() != null) {
             $data['shippingCost'] = $payment->getShipping()->getCost();
         }
         // address
         if ($payment->getShipping()->getAddress() != null) {
             if ($payment->getShipping()->getAddress()->getStreet() != null) {
                 $data['shippingAddressStreet'] = $payment->getShipping()->getAddress()->getStreet();
             }
             if ($payment->getShipping()->getAddress()->getNumber() != null) {
                 $data['shippingAddressNumber'] = $payment->getShipping()->getAddress()->getNumber();
             }
             if ($payment->getShipping()->getAddress()->getComplement() != null) {
                 $data['shippingAddressComplement'] = $payment->getShipping()->getAddress()->getComplement();
             }
             if ($payment->getShipping()->getAddress()->getCity() != null) {
                 $data['shippingAddressCity'] = $payment->getShipping()->getAddress()->getCity();
             }
             if ($payment->getShipping()->getAddress()->getState() != null) {
                 $data['shippingAddressState'] = $payment->getShipping()->getAddress()->getState();
//.........這裏部分代碼省略.........
開發者ID:cbsistem,項目名稱:PWD-Lib,代碼行數:101,代碼來源:PagSeguroPaymentParser.class.php

示例3: getData

 public static function getData($payment)
 {
     // reference
     if ($payment->getReference() != null) {
         $data["reference"] = $payment->getReference();
     }
     // sender
     if ($payment->getSender() != null) {
         if ($payment->getSender()->getName() != null) {
             $data['senderName'] = $payment->getSender()->getName();
         }
         if ($payment->getSender()->getEmail() != null) {
             $data['senderEmail'] = $payment->getSender()->getEmail();
         }
         // phone
         if ($payment->getSender()->getPhone() != null) {
             if ($payment->getSender()->getPhone()->getAreaCode() != null) {
                 $data['senderAreaCode'] = $payment->getSender()->getPhone()->getAreaCode();
             }
             if ($payment->getSender()->getPhone()->getNumber() != null) {
                 $data['senderPhone'] = $payment->getSender()->getPhone()->getNumber();
             }
         }
     }
     // currency
     if ($payment->getCurrency() != null) {
         $data['currency'] = $payment->getCurrency();
     }
     // items
     $items = $payment->getItems();
     if (count($items) > 0) {
         $i = 0;
         foreach ($items as $key => $value) {
             $i++;
             if ($items[$key]->getId() != null) {
                 $data["itemId{$i}"] = $items[$key]->getId();
             }
             if ($items[$key]->getDescription() != null) {
                 $data["itemDescription{$i}"] = $items[$key]->getDescription();
             }
             if ($items[$key]->getQuantity() != null) {
                 $data["itemQuantity{$i}"] = $items[$key]->getQuantity();
             }
             if ($items[$key]->getAmount() != null) {
                 $amount = PagSeguroHelper::decimalFormat($items[$key]->getAmount());
                 $data["itemAmount{$i}"] = $amount;
             }
             if ($items[$key]->getWeight() != null) {
                 $data["itemWeight{$i}"] = $items[$key]->getWeight();
             }
             if ($items[$key]->getShippingCost() != null) {
                 $data["itemShippingCost{$i}"] = PagSeguroHelper::decimalFormat($items[$key]->getShippingCost());
             }
         }
     }
     // extraAmount
     if ($payment->getExtraAmount() != null) {
         $data['extraAmount'] = PagSeguroHelper::decimalFormat($payment->getExtraAmount());
     }
     // shipping
     if ($payment->getShipping() != null) {
         if ($payment->getShipping()->getType() != null && $payment->getShipping()->getType()->getValue() != null) {
             $data['shippingType'] = $payment->getShipping()->getType()->getValue();
         }
         if ($payment->getShipping()->getCost() != null && $payment->getShipping()->getCost() != null) {
             $data['shippingCost'] = $payment->getShipping()->getCost();
         }
         // address
         if ($payment->getShipping()->getAddress() != null) {
             if ($payment->getShipping()->getAddress()->getStreet() != null) {
                 $data['shippingAddressStreet'] = $payment->getShipping()->getAddress()->getStreet();
             }
             if ($payment->getShipping()->getAddress()->getNumber() != null) {
                 $data['shippingAddressNumber'] = $payment->getShipping()->getAddress()->getNumber();
             }
             if ($payment->getShipping()->getAddress()->getComplement() != null) {
                 $data['shippingAddressComplement'] = $payment->getShipping()->getAddress()->getComplement();
             }
             if ($payment->getShipping()->getAddress()->getCity() != null) {
                 $data['shippingAddressCity'] = $payment->getShipping()->getAddress()->getCity();
             }
             if ($payment->getShipping()->getAddress()->getState() != null) {
                 $data['shippingAddressState'] = $payment->getShipping()->getAddress()->getState();
             }
             if ($payment->getShipping()->getAddress()->getDistrict() != null) {
                 $data['shippingAddressDistrict'] = $payment->getShipping()->getAddress()->getDistrict();
             }
             if ($payment->getShipping()->getAddress()->getPostalCode() != null) {
                 $data['shippingAddressPostalCode'] = $payment->getShipping()->getAddress()->getPostalCode();
             }
             if ($payment->getShipping()->getAddress()->getCountry() != null) {
                 $data['shippingAddressCountry'] = $payment->getShipping()->getAddress()->getCountry();
             }
         }
     }
     // maxAge
     if ($payment->getMaxAge() != null) {
         $data['maxAge'] = $payment->getMaxAge();
     }
     // maxUses
//.........這裏部分代碼省略.........
開發者ID:HikaShop,項目名稱:hikashoppayment-pagseguro,代碼行數:101,代碼來源:PagSeguroPaymentParser.class.php

示例4: extraAmount

 /**
  * Extra Amount
  * @return extra amount
  */
 private function extraAmount()
 {
     $discountAmount = self::toFloat($this->order->getBaseDiscountAmount());
     $taxAmount = self::toFloat($this->order->getTaxAmount());
     return PagSeguroHelper::decimalFormat($discountAmount + $taxAmount);
 }
開發者ID:cabrerabywaters,項目名稱:magentoSunshine,代碼行數:10,代碼來源:PaymentMethod.php

示例5: _generateShippingData

 /**
  * Generates shipping data to PagSeguro transaction
  * @param stdClass $deliveryAddress
  * @param float $shippingCost
  * @return \PagSeguroShipping
  */
 private function _generateShippingData($order)
 {
     $shipping = new PagSeguroShipping();
     $shipping->setAddress($this->_generateShippingAddressData($order));
     $shipping->setType($this->_generateShippingType());
     $shipping->setCost(PagSeguroHelper::decimalFormat((double) $order->order_shipping_price));
     return $shipping;
 }
開發者ID:HikaShop,項目名稱:hikashoppayment-pagseguro,代碼行數:14,代碼來源:pagseguro.php

示例6: _generateShippingData

 /**
  * Generates shipping data to PagSeguro transaction
  * @param stdClass $deliveryAddress
  * @param float $shippingCost
  * @return \PagSeguroShipping
  */
 private function _generateShippingData($deliveryAddress, $shippingCost)
 {
     $shipping = new PagSeguroShipping();
     $shipping->setAddress($this->_generateShippingAddressData($deliveryAddress));
     $shipping->setType($this->_generateShippingType());
     $shipping->setCost(PagSeguroHelper::decimalFormat((double) $shippingCost));
     return $shipping;
 }
開發者ID:saper,項目名稱:organic-extensions,代碼行數:14,代碼來源:pagseguro.patch.php

示例7: getCharge

 /**
  * @param $preApproval
  * @return array
  */
 public static function getCharge($preApproval)
 {
     $data = array();
     if ($preApproval->getReference() != null) {
         $data["reference"] = $preApproval->getReference();
     }
     if ($preApproval->getPreApprovalCode() != null) {
         $data["preApprovalCode"] = $preApproval->getPreApprovalCode();
     }
     // items
     $items = $preApproval->getItems();
     if (count($items) > 0) {
         $i = 0;
         foreach ($items as $key => $value) {
             $i++;
             if ($items[$key]->getId() != null) {
                 $data["itemId{$i}"] = $items[$key]->getId();
             }
             if ($items[$key]->getDescription() != null) {
                 $data["itemDescription{$i}"] = $items[$key]->getDescription();
             }
             if ($items[$key]->getQuantity() != null) {
                 $data["itemQuantity{$i}"] = $items[$key]->getQuantity();
             }
             if ($items[$key]->getAmount() != null) {
                 $amount = PagSeguroHelper::decimalFormat($items[$key]->getAmount());
                 $data["itemAmount{$i}"] = $amount;
             }
         }
     }
     return $data;
 }
開發者ID:songinfo,項目名稱:php,代碼行數:36,代碼來源:PagSeguroPreApprovalParser.class.php

示例8: getItemsTotalAmount

 public function getItemsTotalAmount($items, $shipping = false)
 {
     foreach ($items as $item) {
         if (isset($amount)) {
             $amount = $amount + $item->getAmount() * $item->getQuantity();
             if ($shipping) {
                 $amount = $amount + $item->getShippingCost();
             }
         } else {
             $amount = $item->getAmount() * $item->getQuantity();
             if ($shipping) {
                 $amount = $amount + $item->getShippingCost();
             }
         }
     }
     return PagSeguroHelper::decimalFormat($amount);
 }
開發者ID:novasdream,項目名稱:php,代碼行數:17,代碼來源:PagSeguroDirectPaymentRequest.class.php

示例9: setValue

 public function setValue($value)
 {
     $this->value = PagSeguroHelper::decimalFormat($value);
 }
開發者ID:caina,項目名稱:pando,代碼行數:4,代碼來源:PagSeguroPaymentMethodConfigItem.class.php

示例10: getData

 public static function getData($payment)
 {
     $data = null;
     $data = parent::getData($payment);
     // paymentMode
     if ($payment->getPaymentMode() != null) {
         $data["paymentMode"] = $payment->getPaymentMode()->getValue();
     }
     // paymentMethod
     if ($payment->getPaymentMethod()->getPaymentMethod() != null) {
         $data["paymentMethod"] = $payment->getPaymentMethod()->getPaymentMethod();
     }
     // senderHash
     if ($payment->getSenderHash() != null) {
         $data["senderHash"] = $payment->getSenderHash();
     }
     // receiverEmail
     if ($payment->getReceiverEmail() != null) {
         $data["receiverEmail"] = $payment->getReceiverEmail();
     }
     // Bank name
     if ($payment->getOnlineDebit() != null) {
         $data["bankName"] = $payment->getOnlineDebit()->getBankName();
     }
     //Credit Card
     if ($payment->getCreditCard() != null) {
         //Token
         if ($payment->getCreditCard()->getToken() != null) {
             $data['creditCardToken'] = $payment->getCreditCard()->getToken();
         }
         //Installments
         if ($payment->getCreditCard()->getInstallment() != null) {
             $installment = $payment->getCreditCard()->getInstallment();
             if ($installment->getQuantity() != null && $installment->getValue()) {
                 $data['installmentQuantity'] = $installment->getQuantity();
                 $data['installmentValue'] = PagSeguroHelper::decimalFormat($installment->getValue());
             }
         }
         //Holder
         if ($payment->getCreditCard()->getHolder() != null) {
             $holder = $payment->getCreditCard()->getHolder();
             if ($holder->getName() != null) {
                 $data['creditCardHolderName'] = $holder->getName();
             }
             // documents
             /*** @var $document PagSeguroDocument */
             if ($payment->getCreditCard()->getHolder()->getDocuments() != null) {
                 $documents = $payment->getCreditCard()->getHolder()->getDocuments();
                 $data['creditCardHolderCPF'] = $documents->getValue();
             }
             if ($holder->getBirthDate() != null) {
                 $data['creditCardHolderBirthDate'] = $holder->getBirthDate();
             }
             // phone
             if ($holder->getPhone() != null) {
                 if ($holder->getPhone()->getAreaCode() != null) {
                     $data['creditCardHolderAreaCode'] = $holder->getPhone()->getAreaCode();
                 }
                 if ($holder->getPhone()->getNumber() != null) {
                     $data['creditCardHolderPhone'] = $holder->getPhone()->getNumber();
                 }
             }
         }
         //Billing Address
         if ($payment->getCreditCard()->getBilling() != null) {
             $billingAddress = $payment->getCreditCard()->getBilling()->getAddress();
             if ($billingAddress->getStreet() != null) {
                 $data['billingAddressStreet'] = $billingAddress->getStreet();
             }
             if ($billingAddress->getNumber() != null) {
                 $data['billingAddressNumber'] = $billingAddress->getNumber();
             }
             if ($billingAddress->getComplement() != null) {
                 $data['billingAddressComplement'] = $billingAddress->getComplement();
             }
             if ($billingAddress->getCity() != null) {
                 $data['billingAddressCity'] = $billingAddress->getCity();
             }
             if ($billingAddress->getState() != null) {
                 $data['billingAddressState'] = $billingAddress->getState();
             }
             if ($billingAddress->getDistrict() != null) {
                 $data['billingAddressDistrict'] = $billingAddress->getDistrict();
             }
             if ($billingAddress->getPostalCode() != null) {
                 $data['billingAddressPostalCode'] = $billingAddress->getPostalCode();
             }
             if ($billingAddress->getCountry() != null) {
                 $data['billingAddressCountry'] = $billingAddress->getCountry();
             }
         }
     }
     return $data;
 }
開發者ID:songinfo,項目名稱:php,代碼行數:94,代碼來源:PagSeguroDirectPaymentParser.class.php

示例11: _extraAmount

 /**
  * Extra Amount
  * @return extra amount
  */
 private function _extraAmount()
 {
     $_tax_amount = self::toFloat($this->Order->getTaxAmount());
     $_discount_amount = self::toFloat($this->Order->getBaseDiscountAmount());
     return PagSeguroHelper::decimalFormat($_discount_amount + $_tax_amount);
 }
開發者ID:RobertaFortes,項目名稱:assisteste,代碼行數:10,代碼來源:PaymentMethod.php


注:本文中的PagSeguroHelper::decimalFormat方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。