|
-
Mar 5th, 2010, 06:54 PM
#1
[RESOLVED] Paypal payment system
Hi,
I am currently working on a website for church and I've decided to integrate the use of paypal into it so people can pay for their online. However, is setting up and configuring a normal paypal account any different from setting up and configuring a developer account?
This is the code I used when testing using my developer account will I need to make significant changes to it to access and work with a normal account?
PHP Code:
<?php
/* PHP Paypal IPN Integration Class Demonstration File
* 4.16.2005 - Micah Carrick, [email protected]
*/
// Setup class
session_start();
require_once('paypal.class.php'); // include the class file
$p = new paypal_class; // initiate an instance of the class
$p->paypal_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; // testing paypal url
//$p->paypal_url = 'https://www.paypal.com/cgi-bin/webscr'; // paypal url
// setup a variable for this script (ie: 'http://www.micahcarrick.com/paypal.php')
$this_script = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
// if there is not action variable, set the default action of 'process'
if (empty($_GET['action'])) $_GET['action'] = 'process';
switch ($_GET['action']) {
case 'process': // Process and order...
// For example, after ensureing all the POST variables from your custom
// order form are valid, you might have:
//
// $p->add_field('first_name', $_POST['first_name']);
// $p->add_field('last_name', $_POST['last_name']);
$p->add_field('business', '[email protected]');
$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', 'Paypal Test Transaction');
$total_amount= $_SESSION['total_amount'];
$p->add_field('amount', '$total_amount');
$p->submit_paypal_post(); // submit the fields to paypal
//$p->dump_fields(); // for debugging, output a table of all the fields
break;
case 'success': // Order was successful...
// This is where you would have the code to
// email an admin, update the database with payment status, activate a
// membership, etc.
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>";
// You could also simply re-direct them to another page, or your own
// order status page which presents the user with the status of their
// order based on a database
break;
case 'cancel': // Order was canceled...
// The order was canceled before being completed.
echo "<html><head><title>Canceled</title></head><body><h3>The order was canceled.</h3>";
echo "</body></html>";
break;
case 'ipn': // Paypal is calling page for IPN validation...
// It's important to remember that paypal calling this script. There
// is no output here. This is where you validate the IPN data and if it's
// valid, update your database to signify that the user has payed. If
// you try and use an echo or printf function here it's not going to do you
// a bit of good. This is on the "backend". That is why, by default, the
// class logs all IPN data to a text file.
if ($p->validate_ipn()) {
// Payment has been recieved and IPN is verified. This is where you
// update your database to activate or process the order, or setup
// the database with the user's order details, email an administrator,
// etc. You can access a slew of information via the ipn_data() array.
// For this example, we'll just email ourselves ALL the data.
$subject = 'Instant Payment Notification - Recieved Payment';
$to = '[email protected]'; // your email
$body = "An instant payment notification was successfully recieved\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);
}
break;
}
?>
Thanks,
Nightwalker
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Mar 5th, 2010, 07:47 PM
#2
Re: Paypal payment system
I've never worked with with this personally, but from a very brief look it doesn't look like you'd really need to change anything except for the account to use. I could be wrong, but you could always ask the creator (author's name at the beginning of the script you posted) or try contacting Paypal's support about what you're trying to do.
-
Mar 5th, 2010, 09:16 PM
#3
Re: Paypal payment system
I have emailed Paypal asking about my question above! Hopefully, I get a useful response.
Edit:
I received this response to my question:
In that code, you would need to change the "business" value to be the e-mail address to your Live PayPal account, or the secure Merchant ID found on the "Profile" page.
And you will want to either remove the comments to the Live "paypal_url" or replace the uncommented URL to be the Live URL.
So it would look something like this:
PHP Code:
//$p->paypal_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; // testing paypal url $p->paypal_url = 'https://www.paypal.com/cgi-bin/webscr'; // paypal url
Doing it that way will comment out the Sandbox URL and post the transaction details to the Live URL.
And, obviously, you will need to change the transaction details to reflect a live purchase.
That's all you need to change.
I guess all I need to do now is make the changes to the above code after checking to see if my church uses Paypal and if not seeing if they want an account set up.
Last edited by Nightwalker83; Mar 6th, 2010 at 12:20 AM.
Reason: Adding more!
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
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
|