Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. \<?php
  2. require("../mainconfig.php");
  3.  
  4. $check_order = mysqli_query($db, "SELECT * FROM orders_pulsa WHERE status IN ('','Pending','Processing') AND provider = 'ATL'");
  5.  
  6. if (mysqli_num_rows($check_order) == 0) {
  7. die("Order Pending not found.");
  8. } else {
  9. while($data_order = mysqli_fetch_assoc($check_order)) {
  10. $o_oid = $data_order['oid'];
  11. $o_provider = $data_order['provider'];
  12. if ($o_provider == "MANUAL") {
  13. echo "Order Manual<br />";
  14. } else {
  15.  
  16. $check_provider = mysqli_query($db, "SELECT * FROM provider WHERE code = 'ATL'");
  17. $data_provider = mysqli_fetch_assoc($check_provider);
  18.  
  19. $p_apikey = $data_provider['api_key'];
  20.  
  21. if ($o_provider != "MANUAL") {
  22. $api_postdata = "api_key=R4ND0MK3Y&code=$o_oid";
  23. } else {
  24. die("System error!");
  25. }
  26.  
  27. $ch = curl_init();
  28. curl_setopt($ch, CURLOPT_URL, 'https://serverh2h.web.id/status/pulsa');
  29. curl_setopt($ch, CURLOPT_POST, 1);
  30. curl_setopt($ch, CURLOPT_POSTFIELDS, $api_postdata);
  31. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  32. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  33. $chresult = curl_exec($ch);
  34. echo $chresult;
  35. curl_close($ch);
  36. $json_result = json_decode($chresult);
  37.  
  38. if ($o_provider == "ATL") {
  39. $u_status = $json_result->status;
  40. $u_catatan = $json_result->catatan;
  41.  
  42. if ($u_status == "Pending") {
  43. $un_status = "Pending";
  44. } else if ($u_status == "Processing") {
  45. $un_status = "Processing";
  46. } else if ($u_status == "Error") {
  47. $un_status = "Error";
  48. } else if ($u_status == "Success") {
  49. $un_status = "Success";
  50. } else {
  51. $un_status = "Pending";
  52. }
  53. }
  54. $update_order = mysqli_query($db, "UPDATE orders_pulsa SET status = '$un_status' WHERE oid = '$o_oid'");
  55. if ($update_order == TRUE) {
  56. echo "<br />ID Pesanan Web: $o_oid<br /> Status: $un_status<br /><br />";
  57. } else {
  58. echo "Error database.";
  59. }
  60. }
  61. }
  62. }
  63. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement