本文整理汇总了PHP中HttpStatus::getType方法的典型用法代码示例。如果您正苦于以下问题:PHP HttpStatus::getType方法的具体用法?PHP HttpStatus::getType怎么用?PHP HttpStatus::getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpStatus
的用法示例。
在下文中一共展示了HttpStatus::getType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createCheckoutRequest
public static function createCheckoutRequest(Credentials $credentials, PaymentRequest $paymentRequest)
{
LogPagSeguro::info("PaymentService.Register(" . $paymentRequest->toString() . ") - begin");
$connectionData = new PagSeguroConnectionData($credentials, self::serviceName);
try {
$connection = new HttpConnection();
$connection->post(self::buildCheckoutRequestUrl($connectionData), PaymentParser::getData($paymentRequest), $connectionData->getServiceTimeout(), $connectionData->getCharset());
$httpStatus = new HttpStatus($connection->getStatus());
switch ($httpStatus->getType()) {
case 'OK':
$PaymentParserData = PaymentParser::readSuccessXml($connection->getResponse());
$paymentUrl = self::buildCheckoutUrl($connectionData, $PaymentParserData->getCode());
LogPagSeguro::info("PaymentService.Register(" . $paymentRequest->toString() . ") - end {1}" . $PaymentParserData->getCode());
break;
case 'BAD_REQUEST':
$errors = PaymentParser::readErrors($connection->getResponse());
$e = new PagSeguroServiceException($httpStatus, $errors);
LogPagSeguro::error("PaymentService.Register(" . $paymentRequest->toString() . ") - error " . $e->getOneLineMessage());
throw $e;
break;
default:
$e = new PagSeguroServiceException($httpStatus);
LogPagSeguro::error("PaymentService.Register(" . $paymentRequest->toString() . ") - error " . $e->getOneLineMessage());
throw $e;
break;
}
return isset($paymentUrl) ? $paymentUrl : false;
} catch (PagSeguroServiceException $e) {
throw $e;
} catch (Exception $e) {
LogPagSeguro::error("Exception: " . $e->getMessage());
throw $e;
}
}
示例2: checkTransaction
/**
* Returns a transaction from a notification code
*
* @param Credentials $credentials
* @param String $notificationCode
* @throws PagSeguroServiceException
* @throws Exception
* @return a transaction
* @see Transaction
*/
public static function checkTransaction(Credentials $credentials, $notificationCode)
{
LogPagSeguro::info("NotificationService.CheckTransaction(notificationCode={$notificationCode}) - begin");
$connectionData = new PagSeguroConnectionData($credentials, self::serviceName);
try {
$connection = new HttpConnection();
$connection->get(self::buildTransactionNotificationUrl($connectionData, $notificationCode), $connectionData->getServiceTimeout(), $connectionData->getCharset());
$httpStatus = new HttpStatus($connection->getStatus());
switch ($httpStatus->getType()) {
case 'OK':
// parses the transaction
$transaction = TransactionParser::readTransaction($connection->getResponse());
LogPagSeguro::info("NotificationService.CheckTransaction(notificationCode={$notificationCode}) - end " . $transaction->toString() . ")");
break;
case 'BAD_REQUEST':
$errors = TransactionParser::readErrors($connection->getResponse());
$e = new PagSeguroServiceException($httpStatus, $errors);
LogPagSeguro::info("NotificationService.CheckTransaction(notificationCode={$notificationCode}) - error " . $e->getOneLineMessage());
throw $e;
break;
default:
$e = new PagSeguroServiceException($httpStatus);
LogPagSeguro::info("NotificationService.CheckTransaction(notificationCode={$notificationCode}) - error " . $e->getOneLineMessage());
throw $e;
break;
}
return isset($transaction) ? $transaction : null;
} catch (PagSeguroServiceException $e) {
throw $e;
} catch (Exception $e) {
LogPagSeguro::error("Exception: " . $e->getMessage());
throw $e;
}
}
示例3: searchAbandoned
/**
* Search transactions abandoned associated with this set of credentials within a date range
*
* @param Credentials $credentials
* @param String $initialDate
* @param String $finalDate
* @param integer $pageNumber
* @param integer $maxPageResults
* @return a object of TransactionSerachResult class
* @see TransactionSearchResult
* @throws PagSeguroServiceException
* @throws Exception
*/
public static function searchAbandoned(Credentials $credentials, $initialDate, $finalDate, $pageNumber, $maxPageResults)
{
LogPagSeguro::info("TransactionSearchService.searchAbandoned(initialDate=" . PagSeguroHelper::formatDate($initialDate) . ", finalDate=" . PagSeguroHelper::formatDate($finalDate) . ") - begin");
$connectionData = new PagSeguroConnectionData($credentials, self::serviceName);
$searchParams = array('initialDate' => PagSeguroHelper::formatDate($initialDate), 'finalDate' => PagSeguroHelper::formatDate($finalDate), 'pageNumber' => $pageNumber, 'maxPageResults' => $maxPageResults);
try {
$connection = new HttpConnection();
$connection->get(self::buildSearchUrlAbandoned($connectionData, $searchParams), $connectionData->getServiceTimeout(), $connectionData->getCharset());
$httpStatus = new HttpStatus($connection->getStatus());
switch ($httpStatus->getType()) {
case 'OK':
$searchResult = TransactionParser::readSearchResult($connection->getResponse());
LogPagSeguro::info("TransactionSearchService.searchAbandoned(initialDate=" . PagSeguroHelper::formatDate($initialDate) . ", finalDate=" . PagSeguroHelper::formatDate($finalDate) . ") - end " . $searchResult->toString());
break;
case 'BAD_REQUEST':
$errors = TransactionParser::readErrors($connection->getResponse());
$e = new PagSeguroServiceException($httpStatus, $errors);
LogPagSeguro::error("TransactionSearchService.searchAbandoned(initialDate=" . PagSeguroHelper::formatDate($initialDate) . ", finalDate=" . PagSeguroHelper::formatDate($finalDate) . ") - end " . $e->getOneLineMessage());
throw $e;
break;
default:
$e = new PagSeguroServiceException($httpStatus);
LogPagSeguro::error("TransactionSearchService.searchAbandoned(initialDate=" . PagSeguroHelper::formatDate($initialDate) . ", finalDate=" . PagSeguroHelper::formatDate($finalDate) . ") - end " . $e->getOneLineMessage());
throw $e;
break;
}
return isset($searchResult) ? $searchResult : false;
} catch (PagSeguroServiceException $e) {
throw $e;
} catch (Exception $e) {
LogPagSeguro::error("Exception: " . $e->getMessage());
throw $e;
}
}