-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsmsConfirm.php
More file actions
executable file
·72 lines (69 loc) · 2.36 KB
/
smsConfirm.php
File metadata and controls
executable file
·72 lines (69 loc) · 2.36 KB
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
<?php
require_once 'Mobilpay/Payment/Request/Abstract.php';
require_once 'Mobilpay/Payment/Request/Sms.php';
require_once 'Mobilpay/Payment/Request/Notify.php';
$errorCode = 0;
$errorType = Mobilpay_Payment_Request_Abstract::CONFIRM_ERROR_TYPE_NONE;
$errorMessage = '';
$cipher = 'rc4';
$iv = null;
if(array_key_exists('cipher', $_POST))
{
$cipher = $_POST['cipher'];
if(array_key_exists('iv', $_POST))
{
$iv = $_POST['iv'];
}
}
if (strcasecmp($_SERVER['REQUEST_METHOD'], 'post') == 0)
{
if(isset($_POST['env_key']) && isset($_POST['data']))
{
#calea catre cheia privata
#cheia privata este generata de mobilpay, accesibil in Admin -> Conturi de comerciant -> Detalii -> Setari securitate
$privateKeyFilePath = '<path_to_private_key>';
try
{
$objPmReq = Mobilpay_Payment_Request_Abstract::factoryFromEncrypted($_POST['env_key'], $_POST['data'], $privateKeyFilePath, null, $cipher, $iv);
switch($objPmReq->objPmNotify->action)
{
case 'confirmed':
$errorMessage = $objPmReq->objPmNotify->getCrc();
break;
default:
$errorType = Mobilpay_Payment_Request_Abstract::CONFIRM_ERROR_TYPE_PERMANENT;
$errorCode = Mobilpay_Payment_Request_Abstract::ERROR_CONFIRM_INVALID_ACTION;
$errorMessage = 'mobilpay_refference_action paramaters is invalid';
break;
}
}
catch(Exception $e)
{
$errorType = Mobilpay_Payment_Request_Abstract::CONFIRM_ERROR_TYPE_TEMPORARY;
$errorCode = $e->getCode();
$errorMessage = $e->getMessage();
}
}
else
{
$errorType = Mobilpay_Payment_Request_Abstract::CONFIRM_ERROR_TYPE_PERMANENT;
$errorCode = Mobilpay_Payment_Request_Abstract::ERROR_CONFIRM_INVALID_POST_PARAMETERS;
$errorMessage = 'mobilpay.ro posted invalid parameters';
}
}
else
{
$errorType = Mobilpay_Payment_Request_Abstract::CONFIRM_ERROR_TYPE_PERMANENT;
$errorCode = Mobilpay_Payment_Request_Abstract::ERROR_CONFIRM_INVALID_POST_METHOD;
$errorMessage = 'invalid request metod for payment confirmation';
}
header('Content-type: application/xml');
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
if($errorCode == 0)
{
echo "<crc>{$errorMessage}</crc>";
}
else
{
echo "<crc error_type=\"{$errorType}\" error_code=\"{$errorCode}\">{$errorMessage}</crc>";
}