1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
<?php require_once dirname(__FILE__).'/Callback.php'; require_once dirname(__FILE__).'/../core/ErrorCodes.php'; /** * * @author kblee * */ class NetCancelCallback implements Callback{ /** The web message dto. */ private $webMessageDTO; /** The service exception. */ private $serviceException; /** The hash set. */ private static $NETCANCEL_TARGET_ERROR_CODES; /** * */ public function NetCancelCallback(){ if(!isset(NetCancelCallback::$NETCANCEL_TARGET_ERROR_CODES)){ NetCancelCallback::$NETCANCEL_TARGET_ERROR_CODES = array(); NetCancelCallback::$NETCANCEL_TARGET_ERROR_CODES[0] = ErrorCodes::S002; NetCancelCallback::$NETCANCEL_TARGET_ERROR_CODES[1] = ErrorCodes::X003; NetCancelCallback::$NETCANCEL_TARGET_ERROR_CODES[2] = ErrorCodes::T001; NetCancelCallback::$NETCANCEL_TARGET_ERROR_CODES[3] = ErrorCodes::T002; NetCancelCallback::$NETCANCEL_TARGET_ERROR_CODES[4] = ErrorCodes::T003; } } /** * Sets the web message dto. * * @param webMessageDTO the new web message dto */ public function setWebMessageDTO($webMessageDTO) { $this->webMessageDTO = $webMessageDTO; } /** * Sets the service exception. * * @param serviceException the new service exception */ public function setServiceException($serviceException){ $this->serviceException = $serviceException; }
/** * Do callback. */ public function doCallback(){ try { if($this->isServiceExceptionTargetNetCancel()){ // ƯÁ¤ ¿¡·¯ÄÚµå ¹ß»ý½Ã ¸ÁÃë¼Ò $requestMsgDTO = new WebMessageDTO(); // Header (ÀÌ¿Ü µ¥ÀÌÅÍ ÀÚµ¿ ¼³Á¤) $requestMsgDTO->setParameter(VERSION, "NPG01"); // ¹öÀü $requestMsgDTO->setParameter(ID, "IPGC1"); // Àü¹®ID $requestMsgDTO->setParameter(TID, $this->webMessageDTO->getParameter(TID)); // °Å·¡¾ÆÀ̵ð $requestMsgDTO->setParameter(ENC_FLAG, $this->webMessageDTO->getParameter(ENC_FLAG)); // ¾Ïº¹È£È¿©ºÎ
// Body $requestMsgDTO->setParameter(PAY_METHOD, $this->webMessageDTO->getParameter(PAY_METHOD)); // ÁöºÒ¼ö´Ü $requestMsgDTO->setParameter(CANCEL_AMT, $this->webMessageDTO->getParameter(GOODS_AMT)); // Ãë¼Ò±Ý¾× $requestMsgDTO->setParameter(CANCEL_MSG, "¸ÁÃë¼Ò"); // Ãë¼Ò»çÀ¯ $requestMsgDTO->setParameter(MID, $this->webMessageDTO->getParameter(MID)); // »óÁ¡ID $requestMsgDTO->setParameter(CANCEL_PWD, ""); // Ãë¼ÒÆÐ½º¿öµå $requestMsgDTO->setParameter(MERCHANT_KEY, $this->webMessageDTO->getParameter(MERCHANT_KEY)); // »óÁ¡KEY $requestMsgDTO->setParameter(CANCEL_IP, $this->webMessageDTO->getParameter(MALL_IP)); // Ãë¼ÒIP $requestMsgDTO->setParameter(NET_CANCEL_CODE, "1"); // ¸ÁÃë¼Ò±¸ºÐ
$msgTemplateCreator = new MessageTemplateCreator(); $cancelRequestDocument = $msgTemplateCreator->createRequestDocumentTemplate(CANCEL_SERVICE_CODE,""); $cancelResponseDocument = $msgTemplateCreator->createResponseDocumentTemplate(CANCEL_SERVICE_CODE,""); $serviceFactory = new ServiceFactory(); $adaptorService = $serviceFactory->createService(CANCEL_SERVICE_CODE); $adaptorService->setRequestTemplateDocument($cancelRequestDocument); $adaptorService->setResponseTemplateDocument($cancelResponseDocument); $ioAdaptorTransport = new IoAdaptorTransport(); $adaptorService->setTransport($ioAdaptorTransport); // ¸ÁÃë¼Ò ½ÇÇà $adaptorService->service($requestMsgDTO);
if(LogMode::isAppLogable()){ $logJournal = NicePayLogJournal::getInstance(); $logJournal->errorAppLog("¸ÁÃë¼Ò ¿äû"); }
} } catch (ServiceException $e) { if(LogMode::isAppLogable()){ $logJournal = NicePayLogJournal::getInstance(); $logJournal->errorAppLog("¸Á»ó Ãë¼Ò½Ã ¿¹¿Ü°¡ ¹ß»ýÇÏ¿´½À´Ï´Ù. :"+$e->getMessage()); } } } /** * Checks if is service exception target net cancel. * * @return true, if is service exception target net cancel */ private function isServiceExceptionTargetNetCancel(){ $isServiceExceptionTarget = false; if(PAY_SERVICE_CODE == $this->webMessageDTO->getParameter(SERVICE_MODE)){ $errorCode = $this->serviceException->getErrorCode(); foreach (NetCancelCallback::$NETCANCEL_TARGET_ERROR_CODES as $key=>$value){ if($value == $errorCode){ $isServiceExceptionTarget = true; break; } } } return $isServiceExceptionTarget; } } ?>
|