本文整理汇总了PHP中PagSeguroHelper类的典型用法代码示例。如果您正苦于以下问题:PHP PagSeguroHelper类的具体用法?PHP PagSeguroHelper怎么用?PHP PagSeguroHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PagSeguroHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getData
public static function getData($authorization)
{
$data = null;
// Reference
if ($authorization->getReference() != null) {
$data['reference'] = $authorization->getReference();
}
// RedirectURL
if ($authorization->getRedirectURL() != null) {
$data['redirectURL'] = $authorization->getRedirectURL();
}
// NotificationURL
if ($authorization->getNotificationURL() != null) {
$data['notificationURL'] = $authorization->getNotificationURL();
}
// Permissions
if ($authorization->getPermissions()->getPermissions() != null) {
$data['permissions'] = implode(',', $authorization->getPermissions()->getPermissions());
}
// parameter
if (count($authorization->getParameter()->getItems()) > 0) {
foreach ($authorization->getParameter()->getItems() as $item) {
if ($item instanceof PagSeguroParameterItem) {
if (!PagSeguroHelper::isEmpty($item->getKey()) && !PagSeguroHelper::isEmpty($item->getValue())) {
if (!PagSeguroHelper::isEmpty($item->getGroup())) {
$data[$item->getKey() . '' . $item->getGroup()] = $item->getValue();
} else {
$data[$item->getKey()] = $item->getValue();
}
}
}
}
}
return $data;
}
示例2: 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;
}
}
示例3: __construct
/**
* @param null $group
* @param null $name
*/
public function __construct($group = null, $name = null)
{
if (isset($name) && !PagSeguroHelper::isEmpty($name)) {
$this->setName($name);
}
if (isset($group) && !PagSeguroHelper::isEmpty($group)) {
$this->setGroup($group);
}
}
示例4: __construct
public function __construct(array $data = null)
{
if ($data) {
if (isset($data['type']) && isset($data['value'])) {
$this->setType($data['type']);
$this->setValue(PagSeguroHelper::getOnlyNumbers($data['value']));
}
}
}
示例5: addItem
public function addItem(PagSeguroParameterItem $parameterItem)
{
if (!PagSeguroHelper::isEmpty($parameterItem->getKey())) {
if (!PagSeguroHelper::isEmpty($parameterItem->getValue())) {
$this->items[] = $parameterItem;
} else {
die('requered parameterValue.');
}
} else {
die('requered parameterKey.');
}
}
示例6: __construct
public function __construct($key, $value, $group = null)
{
if (isset($key) && !PagSeguroHelper::isEmpty($key)) {
$this->setKey($key);
}
if (isset($value) && !PagSeguroHelper::isEmpty($value)) {
$this->setValue($value);
}
if (isset($group) && !PagSeguroHelper::isEmpty($group)) {
$this->setGroup($group);
}
}
示例7: _normalizeParameter
/**
* Normalize metadata item value
* @param string $parameterValue
* @return string
*/
private function _normalizeParameter($parameterValue)
{
$parameterValue = PagSeguroHelper::formatString($parameterValue, 100, '');
switch ($this->getKey()) {
case PagSeguroMetaDataItemKeys::getItemKeyByDescription('CPF do passageiro'):
$parameterValue = PagSeguroHelper::getOnlyNumbers($parameterValue);
break;
case PagSeguroMetaDataItemKeys::getItemKeyByDescription('Tempo no jogo em dias'):
$parameterValue = PagSeguroHelper::getOnlyNumbers($parameterValue);
break;
case PagSeguroMetaDataItemKeys::getItemKeyByDescription('Celular de recarga'):
break;
default:
break;
}
return $parameterValue;
}
示例8: setName
/**
* Sets the sender name
* @param String $name
*/
public function setName($name)
{
$this->name = PagSeguroHelper::formatString($name, 50, '');
}
示例9: searchByReference
/**
* @param PagSeguroCredentials $credentials
* @param $pageNumber
* @param $maxPageResults
* @param $initialDate
* @param null $finalDate
* @return null|PagSeguroParserData
* @throws Exception
* @throws PagSeguroServiceException
*/
public static function searchByReference(PagSeguroCredentials $credentials, $pageNumber, $maxPageResults, $initialDate, $finalDate = null, $reference)
{
//Logging
$log['text'] = "PagSeguroPreApprovalService.FindByReference(initialDate=" . PagSeguroHelper::formatDate($initialDate) . ", finalDate=" . PagSeguroHelper::formatDate($finalDate) . ", reference=" . $reference . "begin";
LogPagSeguro::info($log['text']);
self::$connectionData = new PagSeguroConnectionData($credentials, self::SERVICE_NAME);
$params = self::buildParams($pageNumber, $maxPageResults, $initialDate, $finalDate, $reference);
try {
$connection = new PagSeguroHttpConnection();
$connection->get(self::buildFindByReferenceUrl(self::$connectionData, $params), self::$connectionData->getServiceTimeout(), self::$connectionData->getCharset());
self::$service = "FindByReference";
return self::getResult($connection);
} catch (PagSeguroServiceException $err) {
//Logging
LogPagSeguro::error("PagSeguroServiceException: " . $err->getMessage());
//Exception
throw $err;
} catch (Exception $err) {
//Logging
LogPagSeguro::error("Exception: " . $err->getMessage());
//Exception
throw $err;
}
}
示例10: isNotificationEmpty
/**
* Check if notification post is empty
* @param array $notification_data
* @return boolean
*/
public static function isNotificationEmpty(array $notification_data)
{
$isEmpty = true;
if (isset($notification_data['notificationCode']) && isset($notification_data['notificationType'])) {
$isEmpty = PagSeguroHelper::isEmpty($notification_data['notificationCode']) || PagSeguroHelper::isEmpty($notification_data['notificationType']);
}
return $isEmpty;
}
示例11: 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;
}
示例12: 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;
}
示例13: _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);
}
示例14: getNotificationUrl
/**
* Gets notification url
* @return string
*/
public function getNotificationUrl()
{
return !PagSeguroHelper::isEmpty(Configuration::get('PAGSEGURO_NOTIFICATION_URL')) ? Configuration::get('PAGSEGURO_NOTIFICATION_URL') : $this->_notificationURL();
}
示例15: 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);
}