-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpaytabs-ipn.php
More file actions
204 lines (144 loc) · 5.09 KB
/
Copy pathpaytabs-ipn.php
File metadata and controls
204 lines (144 loc) · 5.09 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
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<?php
include('header.php');
require('magento.php');
require('quick_books_update.php');//QUICKBOOK DATA PROCESSING FILE
$Response=json_encode($_REQUEST);
$ocd_order_no = $_REQUEST['reference_id'];
//COFIG FOR QUICKBOOK FUNCTION
$GatewayName = 'paytabs';
$OrderNumber = $ocd_order_no;
$TotalAmount = $_REQUEST['amount'];
$Currency = $_REQUEST['currency'];
$insert = mysqli_query($kdbcon,"INSERT INTO o_paytabs_transactions (Response,Reference) values('$Response','$ocd_order_no') ");
$Response=$_REQUEST;
$resp_code = $Response['response_code'];
//LOADING ORDER NUMBER
$order = Mage::getModel('sales/order')->load($ocd_order_no, 'increment_id');
$entity_id = $order->getId();
$payment = $order->getPayment();
$payment_type = $payment['method'];
$username = "Paytabs";
$con_time = date('d-m-Y H:i:s');
$mag_time = date('m/d/y H:i:s');
$ip_adr = $_SERVER['REMOTE_ADDR'];
if(($Response['response_code']=='5001') OR ($Response['response_code']=='5002'))
{
//update_quickbooks($GatewayName,$OrderNumber,$TotalAmount,$Currency,true);
$order_query = "
UPDATE
o_order_con_del
SET
ocd_con_status = 'Confirmed',
ocd_del_status = 'Undelivered',
ocd_ovl_status = 'Processing',
ocd_can_status = '',
ocd_con_user='$username',
ocd_con_ip_add='$ip_adr',
ocd_entity_id='$entity_id',
is_paid='1'
WHERE ocd_order_no='$ocd_order_no' and is_paid='0'";
$order_query = mysqli_query($kdbcon,$order_query);
$ovl_status = "Processing";
//BEIZU QUERY START
if(($ocd_payment_mode=='phoenix_cashondelivery') OR ($ocd_payment_mode=='cashondelivery'))
{
$cod_queren = 'YES';
$shoukuan = 'NO';
}
else
{
$cod_queren = 'NO';
$shoukuan = 'YES';
}
$orderquxiao = 'NO';
$szbeihuo = 'NO';
$select = "SELECT * FROM cs_order_beizhu WHERE order_id='$entity_id'";
$squery = mysqli_query($kdbcon, $select);
$scount = mysqli_num_rows($squery);
if($scount==1)
{
$beizhu_query = "UPDATE cs_order_beizhu
SET cod_queren='$cod_queren',
cod_time='$mag_time',
cod_user='$username',
shoukuan='$shoukuan',
orderquxiao='$orderquxiao',
shoukuan_time='$mag_time',
shoukuan_user='$username'
WHERE order_id='$entity_id'";
}
else
{
$beizhu_query = "INSERT INTO cs_order_beizhu (order_id, increment_id, cod_queren, shoukuan, orderquxiao, szbeihuo, cod_time, cod_user, shoukuan_time, shoukuan_user)
VALUES ('$entity_id',
'$ocd_order_no',
'$cod_queren',
'$shoukuan',
'$orderquxiao',
'$szbeihuo',
'$mag_time',
'$username',
'$mag_time',
'$username')";
}
mysqli_query($kdbcon, $beizhu_query) or die(mysql_error());
}
//IF PAYEMENT REJECTED
if($Response['response_code']=='5000')
{
$ovl_status = "canceled";
$con_status = "Updated";
$ocd_can_note = "Payment Not Verified";
$ocd_can_reason = "Paytabs Payment Rejected";
$ocd_del_status = "Undelivered";
$con_status = "Updated";
$order_query = mysqli_query($kdbcon,"
UPDATE
o_order_con_del
SET
ocd_con_status = 'Confirmed',
ocd_del_status = 'Undelivered',
ocd_ovl_status = 'Cancelled',
ocd_can_status = 'Cancelled',
ocd_con_user = '$username',
ocd_con_ip_add = '$ip_adr',
ocd_entity_id = '$entity_id'
WHERE ocd_order_no='$ocd_order_no'
");
mysqli_query($kdbcon, $order_query);
$insert_history_query = "INSERT INTO o_order_history (hs_order_no, hs_entity_id, hs_remarks, hs_updated_user, hs_status, hs_updated_ip_add)
VALUES ('$ocd_order_no',
'$entity_id',
'$ocd_can_note',
'$username',
'$con_status',
'$ip_adr')";
mysqli_query($kdbcon, $insert_history_query) or die(mysql_error());
$ord_quxiao = 'YES';
if($scount==0)
{
$beizhu_query = "INSERT INTO cs_order_beizhu (order_id, increment_id, orderquxiao, after_sale, quexiao_time, quexiao_user)
VALUES ('$entity_id',
'$ocd_order_no',
'$ord_quxiao',
'$ocd_can_note',
'$mac_time',
'$username')";
}
else
{
//echo $scount;
$beizhu_query = "UPDATE cs_order_beizhu
SET orderquxiao='$ord_quxiao',
after_sale='$ocd_can_note',
quexiao_time='$mac_time',
quexiao_user='$username'
WHERE (order_id='$entity_id')";
}
mysqli_query($kdbcon, $beizhu_query) or die(mysqli_error($kdbcon));
}
$update = "UPDATE sales_flat_order SET status='$ovl_status',payment_method='paytabs' WHERE entity_id='$entity_id'";
$uquery = mysqli_query($kdbcon, $update) or die(mysqli_error($kdbcon));
$updatea = "UPDATE sales_flat_order_grid SET status='$ovl_status' WHERE entity_id='$entity_id'";
$uaquery = mysqli_query($kdbcon, $updatea) or die(mysqli_error($kdbcon));
?>