Jun 2, 2013 08:12 AM
(This post was last modified: Jun 2, 2013 11:02 AM by hellomen.)
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:
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:
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
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
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



