hello,

i'm currently working on a website for my team fortress 2 server, and am now getting to the premium part.
i would like to make a page where people select either a subscription or a one-time payment and then pay it. when the payment is done, they would be added to some sort of database or something which in turn will be used by the server to recognize the premium members.
i've tried this but i'm just not good enough at this stuff for things like that.

i already have a web host, tf2 server, paypal account (business account that is) and a database

could anyone help me out with this?
i am willing to give a small compensation for this because i really need it.

also, i can give you developer access to the paypal account to test code and stuff.

thanks!

Recommended Answers

All 6 Replies

Ages since i looked at paypal, heres the landing page after the payment was completed:

<?php
// read the post from PayPal system and add 'cmd'
if(ctype_alnum($_GET['tx'])){
    $tx = $_GET['tx'];
}else{
    $tx = '';
}
$req = 'cmd=_notify-synch';

$tx_token = $tx;
$auth_token = "YOURAUTHTOKEN";
$req .= "&tx=$tx_token&at=$auth_token";

// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
//$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);
// If possible, securely post back to paypal using HTTPS
// Your PHP server will need to be SSL enabled
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);

if (!$fp) {
    // HTTP ERROR
}else{
    fputs ($fp, $header . $req);
    // read the body data 
    $res = '';
    $headerdone = false;
    while (!feof($fp)) {
        $line = fgets ($fp, 1024);
        if (strcmp($line, "\r\n") == 0) {
            // read the header
            $headerdone = true;
        }else if ($headerdone){
            // header has been read. now read the contents
            $res .= $line;
        }
    }

    // parse the data
    $lines = explode("\n", $res);
    $keyarray = array();
    if (strcmp ($lines[0], "SUCCESS") == 0) {
        for ($i=1; $i<count($lines);$i++){
            list($key,$val) = explode("=", $lines[$i]);
            $keyarray[urldecode($key)] = urldecode($val);
        }
        // check the payment_status is Completed
        // check that txn_id has not been previously processed
        // check that receiver_email is your Primary PayPal email
        // check that payment_amount/payment_currency are correct
        // process payment
        $firstname = $keyarray['first_name'];
        $lastname = $keyarray['last_name'];
        $itemname = $keyarray['item_name'];
        $amount = $keyarray['payment_gross'];

        echo ("<p><h3>Thank you for your purchase!</h3></p>");

        echo ("<b>Payment Details</b><br>\n");
        echo ("<li>Name: $firstname $lastname</li>\n");
        echo ("<li>Item: $itemname</li>\n");
        echo ("<li>Amount: $amount</li>\n");
        echo ("");
        echo 'Your transaction has been completed, and a receipt for your purchase has been emailed to you.<br>
        You may log into your account at <a href="https://www.paypal.com">www.paypal.com</a> to view details of this transaction.<br>';
    }else if (strcmp ($lines[0], "FAIL") == 0) {
    // log for manual investigation
    echo 'FAILED';
    }
}
fclose ($fp);
?>

Hope it helps, i remember testing with paypal being a right pain i did very small purchases with a var_dump($_POST); to see what was there.

Sorry its not in code tags, this new interface keeps taking it out for me on chrome

hey, could you maybe help me out with posting the iser info in a database? i now have a payment button in which the user enters their steam id so i can identify them in the aerver, and i am working on a little login form so they have to login for the payment and then their session gets transferred through the payment so all the info is added to their account so they can change their settings

hey, could you maybe help me out with posting the iser info in a database? i now have a payment button in which the user enters their steam id so i can identify them in the aerver, and i am working on a little login form so they have to login for the payment and then their session gets transferred through the payment so all the info is added to their account so they can change their settings

that coding talk on the paypal website is skipping the parts that i need, i am now using this setup:

the buyer enters their steam ID (in the 0s0 field, which will mark it as special option in paypal), and then just buy the thing, i am currently using this test page: http://www.sergeantsclan.com/premium/test1.php

you can try, the login info is:
email: cas.el_1332769471_per@gmail.com
pass: 12345678

i set the return page for the button to http://www.sergeantsclan.com/premium/test.php (this is where the listener script that was sent in the first reply is located)

but if you finish the payment and click the return to webshop button (so go to /premium/test.php ) i get the FAILED message.

if anyone could help me out here i would be really happy.

have you set

$auth_token = "YOURAUTHTOKEN";

to your token?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.