1 | <?php |
||
22 | class NotificationResponse extends AbstractResponse implements NotificationInterface |
||
23 | { |
||
24 | /** |
||
25 | * |
||
26 | */ |
||
27 | private $errorMessage; |
||
28 | |||
29 | /** |
||
30 | * {@inheritdoc} |
||
31 | */ |
||
32 | public function __construct( RequestInterface $request, $data ) |
||
33 | { |
||
34 | parent::__construct( $request, $data ); |
||
35 | |||
36 | $signKey = $this->request->getTestMode( ) ? $this->request->getTestKey( ) : $this->request->getSignKey( ); |
||
37 | $signExpected = $this->request->calculateSign( $this->data, $signKey ); |
||
38 | |||
39 | if( $this->getCheckoutId( ) !== $this->request->getCheckoutId( ) ) |
||
40 | { |
||
41 | $this->errorMessage = 'Wrong checkout ID'; |
||
42 | } |
||
43 | else if( $this->getSign( ) !== $signExpected ) |
||
44 | { |
||
45 | $this->errorMessage = 'Failed to validate signature'; |
||
46 | } |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * Whether the payment is successful. |
||
51 | * |
||
52 | * @return boolean |
||
53 | */ |
||
54 | public function isSuccessful( ) |
||
65 | |||
66 | /** |
||
67 | * @return string |
||
68 | */ |
||
69 | public function getSign( ) |
||
73 | |||
74 | /** |
||
75 | * |
||
76 | */ |
||
77 | public function getMessage( ) |
||
81 | } |
||
82 |