Skip to main content
June 10, 2010
Question

PayPal to MySQL Database...

  • June 10, 2010
  • 1 reply
  • 2990 views

I have created a website that a user selects a PayPal subscription for lets say $9.95 per month.  I got the PayPal working on my site to go up to the purchase.  However, I heard that there is a way that PayPal is able to connect or send something to my MySQL database inserting the user information so that the user can have access to the website rather than inserting the information manually when I get the papal confirmation.  If someone can explain to me how the procedure if it is possible to have PayPal info of what the user subscribed to back to my MySQL database and not need to enter the information manually.  Here is what I have.

MySQL database for the user

CREATE TABLE IF NOT EXISTS `payaccthist` (
  `payhistid` varchar(35) NOT NULL,
  `date` date NOT NULL,
  `userid` varchar(35) NOT NULL,
  `acctexpir` date DEFAULT NULL,
  `regcostid` varchar(35) NOT NULL DEFAULT '',
  `approved` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Only to show',
  PRIMARY KEY (`payhistid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

Snippet of PayPal page

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
<input type="hidden" name="cmd" value="_xclick-subscriptions" />
<input type="hidden" name="business" value="me@me.com" />
<input type="hidden" name="lc" value="CA" />
<input type="hidden" name="item_name" value="<?php echo $monthsSelected; ?> Month(ly) Subscription" />
<input type="hidden" name="item_number" value="<?php echo $monthsSelected; ?> months" />
<input type="hidden" name="no_note" value="1" />
<select name="a3">
<?php do { ?>
<option value="<?php echo $row_getMonthly['cost']; ?>"><?php echo $row_getMonthly['cost']; ?></option>
<?php } while ($row_getMonthly = mysql_fetch_assoc($getMonthly)); ?>
</select>
<br />
<input type="hidden" name="currency_code" value="CAD" />
<input type="hidden" name="src" value="1" />
<!--Continous billing for 12 months-->
<select name="srt">
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
Months <br />
<input type="hidden" name="t3" value="M" />
<input type="hidden" name="sra" value="1" />
<input type="hidden" name="p3" value="1" />
<input type="hidden" name="bn" value="PP-SubscriptionsBF:btn_subscribeCC_LG.gif:NonHostedGuest" />

<input type="hidden" name="receiver_email" value="me@me.com" />
<input type="hidden" name="custom" value="User: <?php echo $row_getUseSubscription['username']; ?> is <?php echo $row_getUseSubscription['f_name']; ?> <?php echo $row_getUseSubscription['l_name']; ?>" />
<br />
<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal Gateway - The safer, easier way to pay online!" />
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" />
</form>

Thank you for your responses.

This topic has been closed for replies.

1 reply

Inspiring
June 10, 2010

Do you want to get the IPN confirmation?

Its not clear what you mean by: "PayPal is able to connect or send something to my MySQL database  inserting the user information so that the user can have access to the  website"

Or do you want the users details to come across onto the paypal payment page?

June 10, 2010

What I want to know is it possible that when a user pays a subscription on my site using PayPal Subscription button submitting PHP code.  Is there a way that if a user pays for a subscription on my site and when he/she pays that there is a way of PayPal submitting me back to me in php code that will insert that users information that now this user can have access to the website.  Is there such a thing?

Inspiring
June 11, 2010

Hi,

Yes there is: Google this: PHP Toolkit for PayPal v0.51

It is a php Paypal processing script, with IPN, it can send a notification back to your database.

You will need a field in your database to hold the response.

The file paypal will write back to should have a database connection and a insert statement.

I have used this with great success.