当前位置: 首页>>代码示例>>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;未经允许,请勿转载。