Changeset 2621879
- Timestamp:
- 10/29/2021 09:46:52 AM (4 years ago)
- File:
-
- 1 edited
-
chaiport-payment/trunk/chaiportGateway.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
chaiport-payment/trunk/chaiportGateway.php
r2607037 r2621879 178 178 function ChaiportVerifySignature($responseObj, $secretKey, $type) 179 179 { 180 $signature_hash = ""; 180 181 if ($type == "redirect") { 182 $queryParams = $responseObj->get_query_params(); 183 $statusTypes = array( 184 "Success", "Failed" 185 ); 186 if (in_array($queryParams['status'], $statusTypes)) { 187 $statusData = $queryParams['status']; 188 } else { 189 $statusData = "Success"; 190 $pairs = explode('&', $_SERVER[REQUEST_URI]); 191 foreach ($pairs as $value) { 192 if (substr($value, 0, 6) == "status=") { 193 $val = explode($value, '=')[1]; 194 if (in_array($val, $statusTypes)){ 195 $statusData = $val; 196 } 197 } 198 } 199 } 200 $signature_hash = $queryParams['signature_hash']; 181 201 $data = array( 182 'order_ref' => $ responseObj['order_ref'],183 'channel_order_ref' => $ responseObj['channel_order_ref'],184 'merchant_order_ref' => $ responseObj['merchant_order_ref'],185 'status' => $ responseObj['status']202 'order_ref' => $queryParams['order_ref'], 203 'channel_order_ref' => $queryParams['channel_order_ref'], 204 'merchant_order_ref' => $queryParams['merchant_order_ref'], 205 'status' => $statusData 186 206 ); 187 207 } else if ($type == "webhook") { 208 $signature_hash = $responseObj['signature_hash']; 188 209 $data = array( 189 210 'currency' => $responseObj['currency'], … … 198 219 ); 199 220 } 200 201 221 ksort($data); 202 222 $message = http_build_query($data); 203 223 $hash_value = base64_encode(hash_hmac('sha256', $message, $secretKey, true)); 204 224 205 if ($hash_value !== $ responseObj['signature_hash']) {225 if ($hash_value !== $signature_hash) { 206 226 echo "Hash verification failed, not from valid source"; 207 227 return false; … … 280 300 // updating order 281 301 if (($order != false) && ($isSignatureValid == true)) { 282 $status = $data["status"]; 302 $statusTypes = array( 303 "Success", "Failed" 304 ); 305 if (in_array($data['status'], $statusTypes)) { 306 $status = $data['status']; 307 } else { 308 $status = "Success"; 309 $pairs = explode('&', $_SERVER[REQUEST_URI]); 310 foreach ($pairs as $value) { 311 if (substr($value, 0, 6) == "status=") { 312 $val = explode($value, '=')[1]; 313 if (in_array($val, $statusTypes)){ 314 $status = $val; 315 } 316 } 317 } 318 } 283 319 $orderRef = $data["order_ref"]; 284 320 $note = "--- Redirect Update ---\n"; … … 671 707 "back_url" => get_bloginfo('url') . "/checkout/", 672 708 "shipping_charges" => 0.0, 709 "promo_discount" => 0 673 710 ); 674 711
Note: See TracChangeset
for help on using the changeset viewer.