· 7 years ago · Jul 03, 2018, 09:46 PM
1<?php
2/*
3English:
4This script will help you to integrate the PayGol payments platform on your Open Tibia server. Your users will be able to pay and get in-game points immediately and automatically, no need to wait hours or even days for manual delivery.
5Before starting, you must create an account at https://secure.paygol.com/signup
6For full technical documentation, visit https://devs.paygol.com/en
7
8Steps:
91) Upload this file to your server, try to make it a hard to guess path.
102) Enter the full path to this file into the "IPN URL" field, at the "Notifications" section of your Paygol dashboard.
11 Example: http://www.yoursite.com/dtz7895/paygol.php
12
13
14Español:
15Este código te ayudará a integrar la plataforma de pagos PayGol en tu servidor Open Tibia. Tus usuarios podrán pagar y obtener sus puntos de inmediato y de forma automática, sin necesidad de esperar horas o hasta dÃas por una entrega manual.
16Antes de comenzar, debes crear una cuenta en https://secure.paygol.com/signup
17Para ver documentacion técnica adicional visita https://devs.paygol.com/es
18
19Pasos:
201) Sube este archivo a tu servidor, intenta que sea una ruta difÃcil de adivinar.
212) Ingresa la ruta completa de este archivo en el campo "URL de IPN", en la sección "Notificaciones" de tu panel de Paygol.
22 Ejemplo: http://www.yoursite.com/dtz7895/paygol.php
23*/
24
25date_default_timezone_set("America/Sao_Paulo");
26$str = print_r($_GET, true);
27$f = fopen('pay_ERROR_logs.log', 'ab');
28fwrite($f, '[' . date(DateTime::RFC1123) . '] ' . $str . PHP_EOL);
29fclose($f);
30
31// Secret Key of your Paygol account
32$secret_key = "mysecret";
33
34// Secret key validation
35if ($secret_key != $_GET['key']) {
36 echo "Validation error";
37 exit;
38}
39
40// Custom parameter
41$custom = $_GET['custom'];
42
43// Get price and currency. Price always has a decimal point and 2 decimals (e.g. 10.00 EUR, 9000.00 CLP).
44$frmprice = $_GET['frmprice'];
45$frmcurrency = $_GET['frmcurrency'];
46
47// Get points based on the price and currency.
48switch ($frmprice." ".$frmcurrency){
49
50 // Possible prices and their points. You can add as many as you want.
51 case "10.00 EUR": $points = 20; break;
52 case "15.00 EUR": $points = 32; break;
53 case "30.00 EUR": $points = 70; break;
54
55 // If the price doesn't match any of the options above, stop script.
56 default: echo "Price validation failed";
57 exit;
58
59}
60
61// Replace this information with your database details
62$dbhost = "localhost"; //Your database domain
63$dbuser = "root"; //Database username
64$dbpassword = "MYDB"; //Database password
65$db = "myname"; //Database name
66
67// Connect to database
68$conn = mysqli_connect($dbhost, $dbuser, $dbpassword);
69
70// Select database
71mysqli_select_db($conn, $db);
72
73// Update points
74$sql = "UPDATE `accounts`
75 SET `premium_points` = `premium_points`+$points
76 WHERE `name` = '".mysqli_real_escape_string($conn, $custom)."'";
77mysqli_query($conn, $sql);
78
79// Close database connection
80mysqli_close($conn);
81
82?>