-
Aug 9th, 2010, 04:26 AM
#1
Thread Starter
Addicted Member
how to make a Payment system in VB!
the code is simple no passwords are needed no saving/loading just 1 small code and 3 web scripts
everything i use here what u must enter or replace i underline it
in this case i use paypal and have 1 addon in my application (or 1 pro edition)
start making a project (windows forms)
go to the settings section in your project page
add the setting (do not change this just enter as it is here)
addon String user false
thats it start by saving your project
ok now we are gonna make 3 php scripts and i give u 1 (config.php,paypal.php,validatekey.php) and u get (paypal.class.php) from me
ok lets start make a new text file call it config.php (dont forget to remove the .txt)
enter this code and replace values with your own
PHP Code:
<?php //setup SQL connection $db = "database"; // database $host = "localhost"; // most of the time localhost $username = "root"; // your username $pass = "root"; // your password ?>
if u use a free host as ur hosting provider if u have SQL and what the details are if you dont know yet
ok now the Biggest script the payment script call it paypal.php for ordening
its a BIG code so read it fully!
PHP Code:
<?php $game_name = "bakkery"; // product name change this $costs = "3.30"; // price in dollars change this $pay_pal = "bla@bla.com"; // paypal email change this
// UNDER THIS LINE DO NOT EDIT IF U DONT KNOW WHAT UR DOING! require_once('paypal.class.php'); $p = new paypal_class; $p->paypal_url = 'https://www.paypal.com/cgi-bin/webscr'; //$p->paypal_url = 'https://www.paypal.com/cgi-bin/webscr';
$this_script = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
if (empty($_GET['action'])) $_GET['action'] = 'process';
switch ($_GET['action']) { case 'process':
$p->add_field('business', $pay_pal); $p->add_field('return', $this_script.'?action=success'); $p->add_field('cancel_return', $this_script.'?action=cancel'); $p->add_field('notify_url', $this_script.'?action=ipn'); $p->add_field('item_name', $game_name); $p->add_field('amount', $costs);
$p->submit_paypal_post(); //$p->dump_fields(); break; case 'success': echo "<html><head><title>Success</title></head><body><h3>Thank you for your order.</h3>"; foreach ($_POST as $key => $value) { echo "$key: $value<br>"; } echo "</body></html>"; break; case 'cancel':
echo "<html><head><title>Canceled</title></head><body><h3>The order was canceled.</h3>"; echo "</body></html>"; break; case 'ipn': if ($p->validate_ipn()) { include "config.php"; mysql_connect("$host", "$username", "$pass")or die("cannot connect"); mysql_select_db("$db")or die("cannot select DB"); $subject = 'Instant Payment Notification - Recieved Payment'; // we are emailing this to use with all the data $to = '$pay_pal'; $body = "An instant payment notification was successfully recieved MCG will now transact it to your paypal accound\n"; $body .= "from ".$p->ipn_data['payer_email']." on ".date('m/d/Y'); $body .= " at ".date('g:i A')."\n\nDetails:\n"; foreach ($p->ipn_data as $key => $value) { $body .= "\n$key: $value"; } mail($to, $subject, $body); $test = rand(1990345, 14235622346); //we now randomly generate a key so there are never easy keys and all are different $test2 = rand(1990345, 14235622346); $test3 = rand(1990345, 14235622346); $test4 = rand(1990345, 14235622346); $test5 = rand(1990345, 14235622346); $mega = "$test-$test2-$test3-$test4-$test5"; // we combine then to XXXXXXX-XXXXXXXXXXX-XXXXXXX-XXXXXXXXXXX $ip = $p->ipn_data['payer_email']; $sql2="INSERT INTO `database`.`tablename` (`key`, `email`, `uses`, `addon`) VALUES ('$mega', '$ip', '5', '^^the addon or product name^^');"; // we are inserting the data to sql database for checking replace database and table name with your own $result2=mysql_query($sql2); echo "your registration info <br/>"; // this is the text user gets to see after payment echo "your Registration key : $mega <br/>"; echo "your email : $ip <br/>"; echo "you bought : $game_name <br/>"; echo "you get an email with your information within 1 hour if not please contact us with your paypal details to $pay_pal"; $subject2 = 'Instant Payment Notification - payment complete!'; // this is sended to the customer with its details $to2 = $p->ipn_data['payer_email']; $body2 = " we have your payment succesfully <br/>"; $body2 .= "Registration key : $mega -- your email : $ip -- you bought : ^^the addon or product name^^ <br/>"; $body2 .= "thank you for your support buying this software addon good luck <br/>"; $body2 .= "for support contact us at $pay_pal"; mail($to2, $subject2, $body2); } break; } // thats it ?>
replace the values where i put a ^^ on every end or where i put change this after
wow half way there! easy or not? i did al the word for u XD
now lets make the last script validatekey.php
PHP Code:
<?php include "config.php"; ob_start();
// PLEASE DO NOT EDIT THE CODE JUST THE TABLE NAMES WHEN ASKED // Connect to server and select databse. mysql_connect("$host", "$username", "$pass")or die("cannot connect"); mysql_select_db("$db")or die("cannot select DB");
// Define the values given by VB $myusername=$_REQUEST['mykey']; $mypassword=$_REQUEST['email']; $addon=$_REQUEST['addon'];
// To protect MySQL injection $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword);
// check if the key exists $sql="SELECT mykey,email,uses,addon FROM `!!TABLE NAME!!` WHERE mykey='$myusername' AND email='$mypassword' AND uses='5'OR uses='4' OR uses='3' OR uses='2' OR uses='1' AND addon='$addon'"; // change the table name if (!$result=mysql_query($sql)) { trigger_error(mysql_error().'<br />In query: '.$sql); } elseif(mysql_num_rows($result) == 0) { echo 'keyerror'; // if not give a key error } else { $sql2="UPDATE !!tablename!! set uses=uses-1 WHERE mykey='$myusername' AND email='$mypassword'"; // if true lower the uses count and !!change the table name!! if (!$result=mysql_query($sql2)) { trigger_error(mysql_error().'<br />In query: '.$sql2); } else { echo"keyok"; // and if that succeeded give the ok signal } } //check that u removed the !! marks around the table name otherwise u get errors ob_end_flush(); ?>
so thats ready! now i give u the last peace of code
download
put all the files together put them on 1 folder in ur site/server and go back to VB
make a button and give it the text buy now then enter this code
replace the adress to paypal.php with your site aka www.yourdomain.com/vb/paypal.php
ok now when the user clicks the button they are pointed to the payment page
ok now the heavy duty
make another form place 2 textboxes and a combobox and a button
call the button register
give the combobox the same value as u gave the addon name in the paypal script ( when there are more addons make multiple paypal scripts each with different addon names)
textbox1 = key
textbox2 = email used when the used payd
combobox1 = addon selection
ok now the code open the click button 1
and enter this code
VB.Net Code:
Dim wc As New Net.WebClient Dim bt() As Byte 'the returned bytes Dim html As String 'the returned HTML text Dim email As String = TextBox1.Text Dim mykey As String = TextBox2.Text Dim addon As String = ComboBox1.Text Dim fields As New Specialized.NameValueCollection fields.Add("mykey", mykey) 'email fields.Add("email", email) 'email fields.Add("addon", addon) 'email bt = wc.UploadValues("http://yourdomain.com/vb/validatekey.php", fields) 'replace the adress html = System.Text.Encoding.ASCII.GetString(bt) Dim returnValue As String = html If returnValue = "keyok" And ComboBox1.Text = "extras" Then My.Settings.addon = "true" My.Settings.Save() MsgBox("registration success!") Application.Restart() End If If returnValue = "keyerror" Then MsgBox("you have used your code more then 5 times or your key is invalid") End If
ok now to see the difference go back to form1 make a label give it the text i'm not registered
open the forms code then upper dropdownbox form1.events on the right load
teh u get form1 load box now make this code
VB.Net Code:
if my.settings.addon = "true" then label1.text = "i'm registered" end if
thats it now try the payment system and see that your application has been upgraded!
rate me if u think this tutorial was or is helpfull
Last edited by mmuziek; Aug 10th, 2010 at 03:00 PM.
Reason: corrected Code tags
-
Aug 9th, 2010, 06:04 AM
#2
Thread Starter
Addicted Member
Re: how to make a Payment system in VB!
please reply give feedback
-
Aug 9th, 2010, 05:53 PM
#3
Re: how to make a Payment system in VB!
This should be in the codebank, but you have a PHP class as the code you're showing us with a link to a paypal.class.rar file. I haven't dl'd it to see if it's in VB.net, or if it's compiled/source code. Either way, this should be in the codebank regardless. I shall inform a moderator if one hasn't been informed already.
EDIT: Even the downloaded file is a PHP class. This code has hardly any relation to VB.net since you did not actually code a physical application that puts this to use. This actually belongs in our PHP Codebank.
-
Aug 10th, 2010, 03:24 AM
#4
Thread Starter
Addicted Member
Re: how to make a Payment system in VB!
listen up this topic is not ment for discussion about what code it is
this is intergrating Paypal and registration system in VB 8 or 10 no matter how its made
its the First time i share something and i only get Complains about nothing
-
Aug 10th, 2010, 05:25 AM
#5
Re: how to make a Payment system in VB!
I have moved this thread from the 'VB.Net' forum to the 'CodeBank VB.Net' forum - and removed several posts which discussed the move, and the language involved.
It is debatable which CodeBank it should be in (VB.Net or PHP), but I think the VB.Net one will do for now.
Originally Posted by mmuziek
listen up this topic is not ment for discussion about
what code it is
this is intergrating Paypal and registration system in VB 8 or 10 no matter how its made
its the First time i share something and i only get Complains about nothing
In future I suggest you try to understand why people are telling you something like that, rather than simply denying it as you have done in this thread.
People thought this was nothing to do with VB because your post did not show any VB code whatsoever (you accidentally hid it by making a mistake in the code tags). Based on the comments you were getting, you should have at least looked at your post again.
I have fixed the tags, but I have not corrected the lack of line breaks in the code (which was also caused by your mistake), so I suggest that you go up and edit the post to fix that.
-
Aug 10th, 2010, 04:13 AM
#6
Re: how to make a Payment system in VB!
It is good that you share your code. The example you give does not have VB.Net code, but suggests how to create the code.
I suggest you show an example of the VB.Net code you would use to complete your example, then it would go into the codebank on something like 'Calling php Payment system from VB.Net'
-
Aug 10th, 2010, 11:57 AM
#7
Thread Starter
Addicted Member
Re: how to make a Payment system in VB!
ok but how do u guys think is my tutorial?
-
Aug 15th, 2010, 03:57 AM
#8
Thread Starter
Addicted Member
Re: how to make a Payment system in VB!
thanks for the support i will never post a tutorial here anymore as its definitely not appreciated
-
Aug 15th, 2010, 11:12 AM
#9
Re: how to make a Payment system in VB!
Originally Posted by mmuziek
thanks for the support i will never post a tutorial here anymore as its definitely not appreciated
I've posted a few things here myself and gotten little feedback. It's not that it's not wanted/supported, it's as Grimfort said: There might not be a demand for such a tutorial.
No need to get all huffy when something you wrote/created doesn't get used by the masses here, I certainly know that all my stuff isn't used by the masses so no reason for you to get all up in arms about it.
-
Aug 15th, 2010, 07:58 AM
#10
Re: how to make a Payment system in VB!
Unless someone has a need for this code, and it is quite specific, I doubt anyone would have used it in a project. Adding things to the forums are not about self-gratification, if you managed to help someone, then great, maybe you learn a few things yourself in return.
-
Aug 15th, 2010, 11:31 AM
#11
Thread Starter
Addicted Member
Re: how to make a Payment system in VB!
sorry. i'm a autist and doesnt know when to calculate it like that.
sorry.
when my domains nameservers works u can watch all my written tutorials on www.mtut.co.cc
-
Sep 9th, 2010, 11:45 AM
#12
Junior Member
Re: how to make a Payment system in VB!
Very Good! Worked flawlessy for me.
-
Sep 9th, 2010, 02:08 PM
#13
Thread Starter
Addicted Member
Re: how to make a Payment system in VB!
-
Oct 9th, 2010, 03:28 PM
#14
Lively Member
Re: how to make a Payment system in VB!
Love it mmuziek, I have been looking for something similar.
many thamks
-
Oct 9th, 2010, 04:15 PM
#15
Re: how to make a Payment system in VB!
There you go ! 2 members have used your code, gj.
-
Oct 10th, 2010, 04:08 AM
#16
Thread Starter
Addicted Member
Re: how to make a Payment system in VB!
wel good luck for both of them.
its very usefull so i hope its working for them.
-
Nov 11th, 2010, 06:56 PM
#17
Lively Member
Re: how to make a Payment system in VB!
I keep on getting the error, "cannot connect" in a browser, and nothing happens in the application at all.
I think everything in my php file is correct, do I need to do anything to the database ?
Thanks for this script, I would love to get it working though
-
Nov 12th, 2010, 04:28 AM
#18
Thread Starter
Addicted Member
Re: how to make a Payment system in VB!
youmust have a SQL DB
with a table with : mykey email uses addon
point the script to that DB and table by replacing the right information
do not do this if you dont know how SQL DB's work
-
Dec 1st, 2010, 08:43 AM
#19
New Member
Re: how to make a Payment system in VB!
Originally Posted by mmuziek
youmust have a SQL DB
with a table with : mykey email uses addon
point the script to that DB and table by replacing the right information
do not do this if you dont know how SQL DB's work
Great code.
I'm currently making a "App Store" (kinda wannabe apple appstore), but got stuck where i wanted people to buy points, so they could buy apps.
Maybe i can modify this code ?
-
Feb 12th, 2012, 05:56 AM
#20
Thread Starter
Addicted Member
Re: how to make a Payment system in VB!
sir i shal quote what i alraidy said
Originally Posted by mmuziek
youmust have a SQL DB
with a table with : mykey email uses addon
point the script to that DB and table by replacing the right information
do not do this if you dont know how SQL DB's work
-
Feb 12th, 2012, 11:26 AM
#21
New Member
Re: how to make a Payment system in VB!
is there away to do this with using excel spreadsheet/tables.
-
Feb 13th, 2012, 05:13 AM
#22
Thread Starter
Addicted Member
Re: how to make a Payment system in VB!
Originally Posted by PiratePaul
is there away to do this with using excel spreadsheet/tables.
well if u dont even know how to make the tables.
then how are u supose to do that.
its not easy to make that such system. atleast not for me.
i have some engines that create excell data sheet from a SQL db. but thats way to big for such small script as this,
-
Feb 13th, 2012, 11:23 AM
#23
New Member
Re: how to make a Payment system in VB!
Originally Posted by mmuziek
well if u dont even know how to make the tables.
then how are u supose to do that.
its not easy to make that such system. atleast not for me.
i have some engines that create excell data sheet from a SQL db. but thats way to big for such small script as this,
I understand Excel I don't understand SQL DB
-
Feb 11th, 2012, 10:51 PM
#24
New Member
Re: how to make a Payment system in VB!
how would you set up the SQL database for this?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|