Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

PHP 

[Release] Points System PaymentWall for EVERY website!

Hi there

I am releasing here a paymentwall source which works on EVERY website or forum if your hosting allows php mysql / pdo connections.

first go to paymentwall
make an account
make a new app
follow it's instructions!
then when you are on the pingback just wait

we have to make the php file first

be aware edit the database information AND edit the database row where your selecting from

edit Your Secret Key Here with the secret key of your application in paymentwall (findabled in Application settings)
php:
PHP Code

<?php
/*  
 *  Pingback Listener Script
 *  For Virtual Currency API
 *  Copyright (c) 2010-2013 Paymentwall Team
 */
/*  
 *  Define your application-specific options
 */
define('SECRET', 'Your Secret Key Here'); // secret key of your application
define('IP_WHITELIST_CHECK_ACTIVE', true);
define('CREDIT_TYPE_CHARGEBACK', 2);
/**  
 *  The IP addresses below are Paymentwall's
 *  servers. Make sure your pingback script
 *  accepts requests from these addresses ONLY.
 *
 */
$ipsWhitelist = array(
    
'174.36.92.186',
    
'174.36.96.66',
    
'174.36.92.187',
    
'174.36.92.192',
    
'174.37.14.28'
);

/**  
 *  Collect the GET parameters from the request URL
 */
$userId = isset($_GET['uid']) ? $_GET['uid'] : null;
$credits = isset($_GET['currency']) ? $_GET['currency'] : null;
$type = isset($_GET['type']) ? $_GET['type'] : null;
$refId = isset($_GET['ref']) ? $_GET['ref'] : null;
$signature = isset($_GET['sig']) ? $_GET['sig'] : null;
$sign_version = isset($_GET['sign_version']) ? $_GET['sign_version'] : null;

$result = false;

/**  
 *  If there are any errors encountered, the script will list them
 *  in an array.
 */
$errors = array ();

if (!empty(
$userId) && !empty($credits) && isset($type) && !empty($refId) && !empty($signature)) {
    
$signatureParams = array();

    
/** 
  *  version 1 signature
  */
    
if (empty($sign_version) || $sign_version <= 1) {
  
$signatureParams = array(
    
'uid' => $userId,
    
'currency' => $credits,
    
'type' => $type,
    
'ref' => $refId
  
);
    }
    
/** 
  *  version 2+ signature
  */
    
else {
  
$signatureParams = array();
  foreach (
$_GET as $param => $value) {    
    
$signatureParams[$param] = $value;
  }
  unset(
$signatureParams['sig']);
    }

    
/** 
  *  check if IP is in whitelist and if signature matches    
  */
    
$signatureCalculated = calculatePingbackSignature($signatureParams, SECRET, $sign_version);

    
/** 
  *  Run the security check -- if the request's origin is one
  *  of Paymentwall's servers, and if the signature matches
  *  the parameters.
  */
    
if (!IP_WHITELIST_CHECK_ACTIVE || in_array($_SERVER['REMOTE_ADDR'], $ipsWhitelist)) {
  if (
$signature == $signatureCalculated) {
    
$result = true;
    if (
$type == CREDIT_TYPE_CHARGEBACK) {
    
/** 
  *  Deduct credits from user. Note that currency amount
  *  sent for chargeback is negative, e.g. -5, so be
  *  careful about the sign Don't deduct negative
  *  number, otherwise user will gain credits instead
  *  of losing them
  *
  */
            //editing parts
                
$con = new Database("host","user","password","database") OR DIE('Cannot connect to the Database Connector');
                  
$query = $con->runQuery("SELECT `row` FROM `table` WHERE `userid row` = '".$userId."';");
        if(
$query->rowCount() != 0) {
                while(
$row = $query->fetch(PDO::FETCH_ASSOC)) {
        
$final = $row['row'] + $credits;
        
$con->runQuery("UPDATE `table` SET `row` = '{$final}' WHERE `userid` = '{$userId}'");
        }
        
$con = null;
    }
    } else {
            
//editing parts
                
$con = new Database("host","user","password","database") OR DIE('Cannot connect to the Database Connector');
                  
$query = $con->runQuery("SELECT `row` FROM `table` WHERE `userid row` = '".$userId."';");
        if(
$query->rowCount() != 0) {
                while(
$row = $query->fetch(PDO::FETCH_ASSOC)) {
        
$final = $row['row'] + $credits;
        
$con->runQuery("UPDATE `table` SET `row` = '{$final}' WHERE `userid` = '{$userId}'");
        }
        
$con = null;
    }
    
// Give credits to user
    
}
  } else {
    
$errors['signature'] = 'Signature is not valid!';    
  }
    } else {
  
$errors['whitelist'] = 'IP not in whitelist!';
    }
} else {
    
$errors['params'] = 'Missing parameters!';
}
/**  
 *  Always make sure to echo OK so Paymentwall
 *  will know that the transaction is successful.
 */
if ($result) {
    echo 
'OK';
} else {
    echo 
implode(' ', $errors);
}

/**  
 *  Signature calculation function
 */
function calculatePingbackSignature($params, $secret, $version) {
    
$str = '';
    if (
$version == 2) {
  
ksort($params);
    }
    foreach (
$params as $k=>$v) {
  
$str .= "$k=$v";
    }
    
$str .= $secret;
    return 
md5($str);
}
class 
Database
    
{
        private 
$db;
        public function 
Database($host, $user, $pass, $db) {
            try {
                
$this->db = new PDO("mysql:dbname=".$db.";host=".$host.";", $user, $pass);        
            } catch(
PDOEXCEPTION $e) {
                die(
'An error oncorupied! [Code: '.$e->getCode().']!');
            }
        }
        public function 
runQuery($query) {
            return 
$this->db->query($query);    
        }
    }
    
?>

now upload this to a spot where you want it too on your website
set the pingback to the php url

you cannot typ the url because it's not going over paymentwall. THIS IS WITH A PURPOSE SO PEOPLE CANNOT JUST HIT THE URL!

now test the pingback url
it will probably fail

check the response if it says something like:
HTTP/1.0 200 OK
Server: hosting
Date: Fri, 31 May 2013 17:31:57 GMT
Content-type: text/html
Content-length: 5
X-powered-by: PHP/5.4.14
Connection: close

OK

if it does then your good
because it contains the OK

now send an inquiry to paymentwall

they will probably response:
Quote:It look's like there's a BOM symbol in your script.

We've modified the success pattern from our end. Now it should go through


this is not the php file this is a side on paymentwall itselves

now for the url where people will START buying it (the so called: Application URL [in the application setting])
is the url where the iframe is

i would suggest you to make it like this for mybb:

Install the plugin pagemanager
active pagemanager
make a new page with your own name on how you want to name it :)

then say use mybb theme NO
then use the code:

BE AWARE TO EDIT ?key=appkey TO ?key= YOUR APPLICATION KEY HERE!
if you don't edit it to your own appkey then it won't work!

edit the mybb->user['row name']
to the row named into the database
example:

if your row name of the coins/points is Coins
then rename mybb->user['row name'] TO: mybb->user['Coins']

this is stated as $b!!!!

the getcoins php file must be the same then with FROM `mybb_users`

but thats understand able I guess

PHP Code

<?php

global $headerinclude, $header, $theme, $footer;

if(
$mybb->user['usergroup'] == 1)
{
    
error_no_permission();
}
if(
$mybb->user['usergroup'] == 5)
{
    
$a = 'You do not have permissions to view this page!';
}

if(
in_array($mybb->user['usergroup'] , array(2,3,4,6)))
{
    
$b = "{$mybb->user['row name']}";
    
$d = "{$mybb->user['uid']}";
    
$e = "{$mybb->user['username']}";
    
$c = '<iframe src="https://wallapi.com/api/ps/?key=appkey&uid='.$d.'&widget=p1_1" width="750" height="800" frameborder="0"></iframe>';
    
$a = '<font size="6">You currently have '.$b.' Coins<br/><hr></font><font size="4">Your coins will be assigned to:<br/> userid: '.$d.'<br/>username: '.$e.'</font><br/><hr><br/>'.$c.'<br/><br/><font size="4"><b>Please be aware it can take sometime to verify your payment succeeded!</b></font>';
}

$template='<html>
<head>
<title>'
.$pages['name'].'</title>
{$headerinclude}
</head>
<body>
{$header}
<table border="0" cellspacing="'
.$theme['borderwidth'].'" cellpadding="'.$theme['tablespace'].'" class="tborder">
<thead>
<tr>
<td class="thead">
<strong>'
.$pages['name'].'</strong>
</td>
</tr>
</thead>
<tbody>
<tr>
<td class="trow1">
<center>
$a
</center>
</td>
</tr>
</tbody>
</table>
<br />
{$footer}
</body>
</html>'
;

$template=str_replace("\'", "'", addslashes($template));

add_breadcrumb($pages['name']);

eval(
"\$page=\"".$template."\";");

output_page($page);

?>

Credits:
Paymentwall for their api
me for the database and mybb page manager page code!

if you use it it will be appreciated to give me credits!

it's maybe hard to understand with my bad english language skills but i have tried to make it understandable for all of you!

if you need help importing this system

feel free to request my help!

do I use it? YES
site: http://www.xetoia.com/forum
Point System: http://www.xetoia.com/forum/misc.php?page=xicoins
No one thinks a single thing of this?
You have done good job. Thanks for sharing this with us. Just in case; is that secure ?
Thanks a lot for your help! You really helped me with my website!
(Jun 6, 2013 03:34 AM)VPN Wrote:  You have done good job. Thanks for sharing this with us. Just in case; is that secure ?

it is secure because the only possibility to connect to the getpoints.php to receive points is through the paymentwall system

if they verify that the payment was a succes then it connects once with the user userid to the getpoints.php

also the user cannot simply bypass to getpoints.php

because
1: it checks for the registered paymentwall IP's if the ip isn't from the api then it will throw an IP error
2: you must have the correct url which is in case very long
3: you must have the register key which the paymentwall frame automaticly registers when the paymentwall is correct

I hope this answered your question(s).

(Jun 7, 2013 09:45 AM)Arkantos Wrote:  Thanks a lot for your help! You really helped me with my website!

You're welcome my friend
I really enjoy if I help people out correctly ;)
Thanks a lot, i might actually use this..

Do you need to submit any personal info to payment wall to verify it?
(Jun 8, 2013 03:58 AM)Alex™ Wrote:  Thanks a lot, i might actually use this..

Do you need to submit any personal info to payment wall to verify it?

you just register like paypal but on paymentwall and then you create your application
you do need some personal info for the register of your account
but they don't do anything with it...

https://i.imgur.com/4pfSIWU.jpg - register
https://i.imgur.com/QaCseJQ.jpg - application register

and then everything goes automaticly with filling out :)
I know its an old thread but i dont geht the OK.
Paymentwall told me too its not working but idk why :-(
well its not working the paymentwall script becuase of an error ( missing parameters! )
Nice grave digging you've done there.
Just to inform you, paymentwall changed their API over time, the missing parameters is there because there are 2 or 3 versions already for the paymentwall api, I believe this was version 1, I have to recheck that.
However I would highly recommend to ignore this topic and let it die in piece again as the new API is way easier to be used and which is much nicer.
You don't have to do all this by yourself anymore, there is are classes for it now, so all you have to do in the new API system is calling a few methods which can be downloaded by the paymentwall developer knowledge base (link to github is in there)


Possibly Related Threads...
Thread / Author Replies Views Last Post
[PHP] by DigitalxSep 7, 2015 12:04 AM 5 200 Sep 7, 2015 12:04 AM
Last Post: Digitalx
[PHP] by hellomenFeb 27, 2015 03:42 PM 0 226 Feb 27, 2015 03:42 PM
Last Post: hellomen
[PHP] by AshesOct 14, 2012 06:40 AM 3 469 Oct 14, 2012 06:40 AM
Last Post: SYN-