Jump to content
MakeWebGames

Need help with a New Donation Page


peterisgb

Recommended Posts

I havent seen anything like this before so i tried to make my own donation page where the users choose what they want in the donations packs,

The table and the sums work fine, but i cant figure out how to transport the info into the paypal donations link,

If some-one could help me with this so i can then post it in the free modifcations aswell, thanks.

 

<?php
include "globals.php";
print "
<br />
<h2>Custom Donator Packs</h2>
<br />
This Page is Still under work, PLEASE DO NOT USE THIS UNTIL I GIVE THE GO-AHEAD. Thanks<br />
If you Enter 1 on the Points Section, You will not Get the Point, you have to put min of 10 in, thanks<br />
<br /><br />
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script>
   </head>
   <body>
<table width='450px' border='1' style='border-collapse:collapse;background-color:#E8DCFF'>
   <tr>
       <td width='40px'>1</td>
       <td>Dollars</td>
       <td><input class='txt' type='text' name='txt'/></td>
       <td>1 = $100,000,000</td>
   </tr>
   <tr>
       <td>2</td>
       <td>Gold</td>
       <td><input class='txt' type='text' name='txt'/></td>
       <td>1 = 100,000 Gold</td>
   </tr>
   <tr>
       <td>3</td>
       <td>Turns</td>
       <td><input class='txt' type='text' name='txt'/></td>
       <td>1 = 500 Turns</td>
   </tr>
   <tr>
       <td>4</td>
       <td>Points</td>
       <td><input class='txt' type='text' name='txt'/></td>
       <td>10 = 1 Points</td>
   </tr>
   <tr>
       <td>5</td>
       <td>Donator Days</td>
       <td><input class='txt' type='text' name='txt'/></td>
       <td>1 = 10 Donator Days</td>
   </tr>
   <tr>
       <td>6</td>
       <td>Smoking Levels</td>
       <td><input class='txt' type='text' name='txt'/></td>
       <td>1 = 1,000 Smoking Levels</td>
   </tr>
   <tr id='summation'>
       <td> </td>
       <td align='right'>Total to Pay :</td>
       <td align='center'>$<span id='sum'>0</span></td>
   </tr>
</table>
<script>
   $(document).ready(function(){

       //iterate through each textboxes and add keyup
       //handler to trigger sum event
       $('.txt').each(function() {

           $(this).keyup(function(){
               calculateSum();
           });
       });

   });

   function calculateSum() {

       var sum = 0;
       //iterate through each textboxes and add the values
       $('.txt').each(function() {

           //add only if the value is number
           if(!isNaN(this.value) && this.value.length!=0) {
               sum += parseFloat(this.value);
           }

       });
       //.toFixed() method will roundoff the final sum to 2 decimal places
       $('#sum').html(sum.toFixed(2));
   }
</script>
<br /><br /><br /><br />
<form action='https://www.paypal.com/cgi-bin/webscr' method='post' target='_blank'>
<input type=hidden name=cmd value=_xclick>
<input type='hidden' name='business' value='{$set['paypal']}'>
<input type='hidden' name='item_name' value='{$domain}|Custom|M=|G=|T=|P=|DD=|SL=|{$userid}'>
<input type='hidden' name='amount' value='0'>
<input type='hidden' name='no_shipping' value='1'>
<input type='hidden' name='return' value='http://{$domain}/donatordone.php?action=done&type=special'>
<input type='hidden' name='cancel_return' value='http://{$domain}/donatordone.php?action=cancel'>
<input type='hidden' name='notify_url' value='http://{$domain}/ipn_donator.php'>
<input type='hidden' name='cn' value='Your Player ID'>
<input type='hidden' name='currency_code' value='USD'>
<input type='hidden' name='tax' value='0'>
<input type='image' src='https://www.paypal.com/en_US/i/btn/x-click-but21.gif' border='0' name='submit' alt='Make payments with PayPal - it's fast, free and secure!'>
</form>
";
$h->endpage();
?>
Link to comment
Share on other sites

  • 2 weeks later...

Handed on a spoon

 

<?php
include_once('globals');
?>

<h2>Custom Donator Packs</h2>

This Page is Still under work, PLEASE DO NOT USE THIS UNTIL I GIVE THE GO-AHEAD. Thanks
If you Enter 1 on the Points Section, You will not Get the Point, you have to put min of 10 in, thanks

<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script>
   </head>
   <body>
<table width='450px' border='1' style='border-collapse:collapse;background-color:#E8DCFF'>
   <tr>
       <td width='40px'>1</td>
       <td>Dollars</td>
       <td><input class='txt' type='text' name='txt'/></td>
       <td>1 = $100,000,000</td>
   </tr>
   <tr>
       <td>2</td>
       <td>Gold</td>
       <td><input class='txt' type='text' name='txt'/></td>
       <td>1 = 100,000 Gold</td>
   </tr>
   <tr>
       <td>3</td>
       <td>Turns</td>
       <td><input class='txt' type='text' name='txt'/></td>
       <td>1 = 500 Turns</td>
   </tr>
   <tr>
       <td>4</td>
       <td>Points</td>
       <td><input class='txt' type='text' name='txt'/></td>
       <td>10 = 1 Points</td>
   </tr>
   <tr>
       <td>5</td>
       <td>Donator Days</td>
       <td><input class='txt' type='text' name='txt'/></td>
       <td>1 = 10 Donator Days</td>
   </tr>
   <tr>
       <td>6</td>
       <td>Smoking Levels</td>
       <td><input class='txt' type='text' name='txt'/></td>
       <td>1 = 1,000 Smoking Levels</td>
   </tr>
   <tr id='summation'>
       <td> </td>
       <td align='right'>Total to Pay :</td>
       <td align='center'>$<span id='sum'>0</span></td>
   </tr>
</table>
<script>
var arg = new Array();
   $(document).ready(function(){

       //iterate through each textboxes and add keyup
       //handler to trigger sum event
       $('.txt').each(function() {
			arg.push(this);
           $(this).keyup(function(){
               calculateSum();
           });
       });

   });

   function calculateSum() {

       var sum = 0;
       //iterate through each textboxes and add the values
       $('.txt').each(function() {

           //add only if the value is number
           if(!isNaN(this.value) && this.value.length!=0) {
               sum += parseFloat(this.value);
           }

       });
       //.toFixed() method will roundoff the final sum to 2 decimal places
       $('#sum').html(sum.toFixed(2));
       $('input[name=item_name]').val('<?php echo $domain; ?>|Custom|M='+arg[0].value+'|G='+arg[1].value+'|T='+arg[2].value+'|P='+arg[3].value+'|DD='+arg[4].value+'|SL='+arg[5].value+'|<?php echo $userid ?>');
   }
</script>

<form action='https://www.paypal.com/cgi-bin/webscr' method='post' target='_blank'>
<input type=hidden name=cmd value=_xclick>
<input type='hidden' name='business' value='<?php echo $set['paypal']; ?>'>
<input type='hidden' name='item_name' value='<?php echo $domain; ?>|Custom|M=|G=|T=|P=|DD=|SL=|<?php echo $userid ?>'>
<input type='hidden' name='amount' value='0'>
<input type='hidden' name='no_shipping' value='1'>
<input type='hidden' name='return' value='http://<?php echo $domain; ?>/donatordone.php?action=done&type=special'>
<input type='hidden' name='cancel_return' value='http://<?php echo $domain; ?>/donatordone.php?action=cancel'>
<input type='hidden' name='notify_url' value='http://<?php echo $domain; ?>/ipn_donator.php'>
<input type='hidden' name='cn' value='1'>
<input type='hidden' name='currency_code' value='USD'>
<input type='hidden' name='tax' value='0'>
<input type='image' src='https://www.paypal.com/en_US/i/btn/x-click-but21.gif' border='0' name='submit' alt='Make payments with PayPal - it's fast, free and secure!'>
</form>

<?php $h->endpage(); ?>
Edited by HauntedDawg
error
Link to comment
Share on other sites

Handed on a spoon

 

<?php
include_once('globals');
?>

<h2>Custom Donator Packs</h2>

This Page is Still under work, PLEASE DO NOT USE THIS UNTIL I GIVE THE GO-AHEAD. Thanks
If you Enter 1 on the Points Section, You will not Get the Point, you have to put min of 10 in, thanks

<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script>
   </head>
   <body>
<table width='450px' border='1' style='border-collapse:collapse;background-color:#E8DCFF'>
   <tr>
       <td width='40px'>1</td>
       <td>Dollars</td>
       <td><input class='txt' type='text' name='txt'/></td>
       <td>1 = $100,000,000</td>
   </tr>
   <tr>
       <td>2</td>
       <td>Gold</td>
       <td><input class='txt' type='text' name='txt'/></td>
       <td>1 = 100,000 Gold</td>
   </tr>
   <tr>
       <td>3</td>
       <td>Turns</td>
       <td><input class='txt' type='text' name='txt'/></td>
       <td>1 = 500 Turns</td>
   </tr>
   <tr>
       <td>4</td>
       <td>Points</td>
       <td><input class='txt' type='text' name='txt'/></td>
       <td>10 = 1 Points</td>
   </tr>
   <tr>
       <td>5</td>
       <td>Donator Days</td>
       <td><input class='txt' type='text' name='txt'/></td>
       <td>1 = 10 Donator Days</td>
   </tr>
   <tr>
       <td>6</td>
       <td>Smoking Levels</td>
       <td><input class='txt' type='text' name='txt'/></td>
       <td>1 = 1,000 Smoking Levels</td>
   </tr>
   <tr id='summation'>
       <td>*</td>
       <td align='right'>Total to Pay :</td>
       <td align='center'>$<span id='sum'>0</span></td>
   </tr>
</table>
<script>
var arg = new Array();
   $(document).ready(function(){

       //iterate through each textboxes and add keyup
       //handler to trigger sum event
       $('.txt').each(function() {
			arg.push(this);
           $(this).keyup(function(){
               calculateSum();
           });
       });

   });

   function calculateSum() {

       var sum = 0;
       //iterate through each textboxes and add the values
       $('.txt').each(function() {

           //add only if the value is number
           if(!isNaN(this.value) && this.value.length!=0) {
               sum += parseFloat(this.value);
           }

       });
       //.toFixed() method will roundoff the final sum to 2 decimal places
       $('#sum').html(sum.toFixed(2));
       $('input[name=item_name]').val('<?php echo $domain; ?>|Custom|M='+arg[0].value+'|G='+arg[1].value+'|T='+arg[2].value+'|P='+arg[3].value+'|DD='+arg[4].value+'|SL='+arg[5].value+'|<?php echo $userid ?>');
   }
</script>

<form action='https://www.paypal.com/cgi-bin/webscr' method='post' target='_blank'>
<input type=hidden name=cmd value=_xclick>
<input type='hidden' name='business' value='<?php echo $set['paypal']; ?>'>
<input type='hidden' name='item_name' value='<?php echo $domain; ?>|Custom|M=|G=|T=|P=|DD=|SL=|<?php echo $userid ?>'>
<input type='hidden' name='amount' value='0'>
<input type='hidden' name='no_shipping' value='1'>
<input type='hidden' name='return' value='http://<?php echo $domain; ?>/donatordone.php?action=done&type=special'>
<input type='hidden' name='cancel_return' value='http://<?php echo $domain; ?>/donatordone.php?action=cancel'>
<input type='hidden' name='notify_url' value='http://<?php echo $domain; ?>/ipn_donator.php'>
<input type='hidden' name='cn' value='1'>
<input type='hidden' name='currency_code' value='USD'>
<input type='hidden' name='tax' value='0'>
<input type='image' src='https://www.paypal.com/en_US/i/btn/x-click-but21.gif' border='0' name='submit' alt='Make payments with PayPal - it's fast, free and secure!'>
</form>

<?php $h->endpage(); ?>

 

Not bad, still one of the problems i have is the price from the total on the table dont show up when you click the donate button

Link to comment
Share on other sites

$('input[name=amount]').val(sum.toFixed(2));

Now you can figure where tou place it. Not everything will be handed on a spoon :D but advice shall be given.

JQuery is a powerful JavaScript library. It does what is say's on the box. Write less, Do more. You should really just take one day and go through it. It's not hard at all!

Link to comment
Share on other sites

thanks, i dont mind doing some work, which i did quite alot of it, but thanks for the point in the right direction, i think i should be able to do the rest. (i Hope)

i used the code above, i know where to put it, but paypal chucks back this query

The link you have used to enter the PayPal system contains an incorrectly formatted item amount.

and this was using $('input[name=amount]').val(sum.toFixed(2));

Edited by peterisgb
Link to comment
Share on other sites

   <h2>Custom Donator Packs</h2>

   This Page is Still under work, PLEASE DO NOT USE THIS UNTIL I GIVE THE GO-AHEAD. Thanks
   If you Enter 1 on the Points Section, You will not Get the Point, you have to put min of 10 in, thanks

    <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script>
       </head>
       <body>
   <table width='450px' border='1' style='border-collapse:collapse;background-color:#E8DCFF'>
       <tr>
           <td width='40px'>1</td>
           <td>Dollars</td>
           <td><input class='txt' type='text' name='txt'/></td>
           <td>1 = $100,000,000</td>
       </tr>
       <tr>
           <td>2</td>
           <td>Gold</td>
           <td><input class='txt' type='text' name='txt'/></td>
           <td>1 = 100,000 Gold</td>
       </tr>
       <tr>
           <td>3</td>
           <td>Turns</td>
           <td><input class='txt' type='text' name='txt'/></td>
           <td>1 = 500 Turns</td>
       </tr>
       <tr>
           <td>4</td>
           <td>Points</td>
           <td><input class='txt' type='text' name='txt'/></td>
           <td>10 = 1 Points</td>
       </tr>
       <tr>
           <td>5</td>
           <td>Donator Days</td>
           <td><input class='txt' type='text' name='txt'/></td>
           <td>1 = 10 Donator Days</td>
       </tr>
       <tr>
           <td>6</td>
           <td>Smoking Levels</td>
           <td><input class='txt' type='text' name='txt'/></td>
           <td>1 = 1,000 Smoking Levels</td>
       </tr>
       <tr id='summation'>
           <td>*</td>
           <td align='right'>Total to Pay :</td>
           <td align='center'>$<span id='sum'>0</span></td>
       </tr>
   </table>
   <script>
       var arg = new Array();
       $(document).ready(function(){

           //iterate through each textboxes and add keyup
           //handler to trigger sum event
           $('.txt').each(function() {
               arg.push(this);
               $(this).keyup(function(){
                   calculateSum();
               });
           });

       });

       function calculateSum() {

           var sum = 0;
           //iterate through each textboxes and add the values
           $('.txt').each(function() {

               //add only if the value is number
               if(!isNaN(this.value) && this.value.length!=0) {
                   sum += parseFloat(this.value);
               }

           });
           //.toFixed() method will roundoff the final sum to 2 decimal places
           $('#sum').html(sum.toFixed(2));
           $('input[name=item_name]').val('<?php echo $domain; ?>|Custom|M='+arg[0].value+'|G='+arg[1].value+'|T='+arg[2].value+'|P='+arg[3].value+'|DD='+arg[4].value+'|SL='+arg[5].value+'|<?php echo $userid ?>');
           $('input[name=amount]').val(sum.toFixed(2));
       }
   </script>

   <form action='https://www.paypal.com/cgi-bin/webscr' method='post' target='_blank'>
   <input type='hidden' name='cmd' value='_xclick'>
   <input type='hidden' name='business' value='<?php echo $set['paypal']; ?>'>
   <input type='hidden' name='item_name' value='<?php echo $domain; ?>|Custom|M=|G=|T=|P=|DD=|SL=|<?php echo $userid ?>'>
   <input type='hidden' name='amount' value='0'>
   <input type='hidden' name='no_shipping' value='1'>
   <input type='hidden' name='return' value='http://<?php echo $domain; ?>/donatordone.php?action=done&type=special'>
   <input type='hidden' name='cancel_return' value='http://<?php echo $domain; ?>/donatordone.php?action=cancel'>
   <input type='hidden' name='notify_url' value='http://<?php echo $domain; ?>/ipn_donator.php'>
   <input type='hidden' name='cn' value='1'>
   <input type='hidden' name='currency_code' value='USD'>
   <input type='hidden' name='tax' value='0'>
   <input type='image' src='https://www.paypal.com/en_US/i/btn/x-click-but21.gif' border='0' name='submit' alt='Make payments with PayPal'>
   </form>

 

Work's perfect for me.

With the code supplied above, remember to add back the $h->endpage and the include at the top.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...