mirror of
				https://github.com/notepad-plus-plus/notepad-plus-plus.git
				synced 2025-10-31 19:44:06 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			125 lines
		
	
	
		
			4.2 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			125 lines
		
	
	
		
			4.2 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| <?php
 | |
| /*
 | |
|  ************************************************************************
 | |
|  Copyright [2014] [PagSeguro Internet Ltda.]
 | |
|  Licensed under the Apache License, Version 2.0 (the "License");
 | |
|  you may not use this file except in compliance with the License.
 | |
|  You may obtain a copy of the License at
 | |
|  http://www.apache.org/licenses/LICENSE-2.0
 | |
|  Unless required by applicable law or agreed to in writing, software
 | |
|  distributed under the License is distributed on an "AS IS" BASIS,
 | |
|  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | |
|  See the License for the specific language governing permissions and
 | |
|  limitations under the License.
 | |
|  ************************************************************************
 | |
|  */
 | |
| require_once "../PagSeguroLibrary/PagSeguroLibrary.php";
 | |
| 
 | |
| function for123(){
 | |
|     alert 'nothing';
 | |
| }
 | |
| 
 | |
| abstract class PageGrille extends PageMotsBleus{
 | |
| 	abstract function GetTypeGrille() ; // blabla blabla
 | |
| 	abstract function GetGrilleJSON($p_grilleId); // Retourn JSON
 | |
| 
 | |
| 	function CleanStr($pStr){
 | |
| 		return str_replace ( "\\" , "" , $pStr);
 | |
| 	}
 | |
| 
 | |
| 	function GetJavascriptMajax() { /* a block comment */
 | |
| 		return "ABC";
 | |
| 	}
 | |
| 	/*
 | |
| 	function commentedFunc1() {
 | |
| 		return "commented 1";
 | |
| 	}
 | |
| 	*/
 | |
| }
 | |
| 
 | |
| function stringContainAsterisk_test1(){
 | |
| 	$target = '/path/to/files/*';
 | |
| }
 | |
| 
 | |
| /*function commentedFunc2(){
 | |
| 	return "commented 2";
 | |
| }*/
 | |
| 
 | |
| function stringContainAsterisk_test2(){
 | |
| 	$target = '/path/to/files/*.jpg';
 | |
| }
 | |
| 
 | |
| class NotificationListener
 | |
| {
 | |
|     public static function main()
 | |
|     {
 | |
|         $code = (isset($_POST['notificationCode']) && trim($_POST['notificationCode']) !== "" ?
 | |
|             trim($_POST['notificationCode']) : null);
 | |
|         $type = (isset($_POST['notificationType']) && trim($_POST['notificationType']) !== "" ?
 | |
|             trim($_POST['notificationType']) : null);
 | |
|         if ($code && $type) {
 | |
|             $notificationType = new PagSeguroNotificationType($type);
 | |
|             $strType = $notificationType->getTypeFromValue();
 | |
|             switch ($strType) {
 | |
|                 case 'TRANSACTION':
 | |
|                     self::transactionNotification($code);
 | |
|                     break;
 | |
|                 case 'APPLICATION_AUTHORIZATION':
 | |
|                     self::authorizationNotification($code);
 | |
|                     break;
 | |
|                 case 'PRE_APPROVAL':
 | |
|                     self::preApprovalNotification($code);
 | |
|                     break;
 | |
|                 default:
 | |
|                     LogPagSeguro::error("Unknown notification type [" . $notificationType->getValue() . "]");
 | |
|             }
 | |
|             self::printLog($strType);
 | |
|         } else {
 | |
|             LogPagSeguro::error("Invalid notification parameters.");
 | |
|             self::printLog();
 | |
|         }
 | |
|     }
 | |
|     private static function transactionNotification($notificationCode)
 | |
|     {
 | |
|         $credentials = PagSeguroConfig::getAccountCredentials();
 | |
|         try {
 | |
|             $transaction = PagSeguroNotificationService::checkTransaction($credentials, $notificationCode);
 | |
|             // Do something with $transaction
 | |
|         } catch (PagSeguroServiceException $e) {
 | |
|             die($e->getMessage());
 | |
|         }
 | |
|     }
 | |
|     private static function authorizationNotification($notificationCode)
 | |
|     {
 | |
|         $credentials = PagSeguroConfig::getApplicationCredentials();
 | |
|         try {
 | |
|             $authorization = PagSeguroNotificationService::checkAuthorization($credentials, $notificationCode);
 | |
|             // Do something with $authorization
 | |
|         } catch (PagSeguroServiceException $e) {
 | |
|             die($e->getMessage());
 | |
|         }
 | |
|     }
 | |
|     private static function preApprovalNotification($preApprovalCode)
 | |
|     {
 | |
|         $credentials = PagSeguroConfig::getAccountCredentials();
 | |
|         try {
 | |
|             $preApproval = PagSeguroNotificationService::checkPreApproval($credentials, $preApprovalCode);
 | |
|             // Do something with $preApproval
 | |
|             
 | |
|         } catch (PagSeguroServiceException $e) {
 | |
|             die($e->getMessage());
 | |
|         }
 | |
|     }
 | |
|     private static function printLog($strType = null)
 | |
|     {
 | |
|         $count = 4;
 | |
|         echo "<h2>Receive notifications</h2>";
 | |
|         if ($strType) {
 | |
|             echo "<h4>notifcationType: $strType</h4>";
 | |
|         }
 | |
|         echo "<p>Last <strong>$count</strong> items in <strong>log file:</strong></p><hr>";
 | |
|         echo LogPagSeguro::getHtml($count);
 | |
|     }
 | |
| }
 | |
| 
 | |
| NotificationListener::main(); |