views:

79

answers:

1

So I'm running out of time on this project and I posted here in hopes that someone can help me.

Backstory There's a church retreat coming up and I'm in charge of making the website.

The Meaty Info On the site there's a simple registration form on the page that has some basic information (I have to add fields for Location, Phone Number, and Address. Ignoring that...) Screenshot of the page here. Ignore the error at the top and the PayPal button, I was trying to get it to work but I'm doing something wrong.

Now the retreat site does checks in PHP when you submit the form to see that you put real information for all the fields. Hitting the submit button will call the register.php page and do the checks, returning whether or not there were any errors.

The Problem I've never used an API but I have a good knowledge of PHP. As of now, what I wanted to happen was:

  1. The user inputs their information on the church retreat site. The retreat site would then check if the information was correct, and if it was it would redirect them to a PayPal page very similair to this.
  2. There, they'd enter billing information, then, after completing and processing the order all on PayPal's site, PayPal would redirect to my church registration page.
  3. My site would (somehow) receive from PayPal that the transaction was successful, and then add the user to a database of paid attendees.

The problems are setting up PayPal on my site how I outlined. Then, how would my site know whether or not a transfer was successful? Where would I find the files necessary to do the API commands?

I have no idea how to do that. It's boggling my mind and after reading documentation, I've just become more confused. I need someone's help on this so if anyone cares to help me: Thank You. I could really use a human answer as to the steps I need to take to get this done.

+2  A: 

To do what you're talking about, first you need to post a form to paypal. This pseudocode should help.

<form action='https://www.paypal.com/cgi-bin/webscr' method='post'>
<input type='hidden' name='cmd' value='_cart' />
<input type='hidden' name='upload' value='1' />
<input type='hidden' name='business' value='{$paypal_email}' />
<input type='hidden' name='shopping_url' value='{$return_path}' />
<input type='hidden' name='currency_code' value='USD' />

(for each item in the cart, repeat...)

  <input type='hidden' name='item_number_{$one_based_counter}' value='{$item_number}'>
  <input type='hidden' name='item_name_{$one_based_counter}' value='{$item_name}'>
  <input type='hidden' name='amount_{$one_based_counter}' value='{$amount}'>
  <input type='hidden' name='quantity_{$one_based_counter}' value='{$quantity}'>

  (for each custom field for this item (e.g. size, style))

    <input type='hidden' name='on{$zero_based_counter}_{$one_based_counter}' 
                        value='{$custom_field_name[$zero_based_counter]}'>
    <input type='hidden' name='os{$zero_based_counter}_{$one_based_counter}' 
                        value='{$custom_field_value[$zero_based_counter]}'>

  (end for each)

(end for each)

<input type='submit' value='Pay Me' /></form>

After that, you need to write another script to handle payment notifications from PayPal. Look into PayPal's Instant Payment Notification (IPN). Log in to PayPal and have IPN post to your notification handler script. There are some pretty good IPN tutorials on PayPal's site and elsewhere.

no
Researching and trying. But I'm not selling anything (other than registration.)
NessDan
It will work fine for a single item with no custom fields, I just provided the multiple items / custom fields stuff for completeness.
no
Now is there a way where I can do this all on my site? So instead of redirecting to PayPal, the user would put down all their info right on the site and it would be processed by PayPal? Then using (from what I've read) the ACK or IPN, to confirm the purchase?
NessDan
I think that would be outside the scope of the project you're describing. Once you begin collecting billing info and sending it around the net, you have to deal with some serious security issues... google "PCI compliance" and you'll see what I mean.
no
Thanks anyways, I'm going with your original idea and using IPN.
NessDan