/callback/dotpay.php

https://bitbucket.org/redkorn/whmcs-dotpay · PHP · 42 lines · 25 code · 11 blank · 6 comment · 7 complexity · 024fb323f50c00b9bea531b7f042f932 MD5 · raw file

  1. <?php
  2. # Required File Includes
  3. include("../../../dbconnect.php");
  4. include("../../../includes/functions.php");
  5. include("../../../includes/gatewayfunctions.php");
  6. include("../../../includes/invoicefunctions.php");
  7. $gatewaymodule = "dotpay";
  8. $GATEWAY = getGatewayVariables($gatewaymodule);
  9. // sprawdzamy ip, czy nalezy do dotpay.pl
  10. if($_SERVER['REMOTE_ADDR']!='217.17.41.5' && $_SERVER['REMOTE_ADDR']!='195.150.9.37') die("Incorrect sender IP ".$_SERVER['REMOTE_ADDR']);
  11. if (!$GATEWAY["type"]) die("Module Not Activated");
  12. # Get Returned Variables
  13. $status = $_POST["status"];
  14. $t_status = $_POST["t_status"];
  15. $invoiceid = $_POST["control"];
  16. $transid = $_POST["t_id"];
  17. $amount = $_POST["amount"];
  18. $fee = $amount*0.039;
  19. $invoiceid = checkCbInvoiceID($invoiceid,$GATEWAY["name"]); # sprawdzamy ID platnosci
  20. checkCbTransID($transid); # sprawdzamy, czy numer transakcji jest juz w bazie
  21. if ($status=="OK" && $t_status == 2) {
  22. # Successful
  23. addInvoicePayment($invoiceid,$transid,$amount,$fee,$gatewaymodule);
  24. logTransaction($GATEWAY["name"],$_POST,"Successful");
  25. } else {
  26. # Unsuccessful
  27. logTransaction($GATEWAY["name"],$_POST,"Unsuccessful");
  28. }
  29. // dotpay.pl oczekuje w odpowiedzi 'OK'
  30. echo "OK";
  31. ?>