Jump to content

submit button running php script and paypal


dolcezza

Recommended Posts

I have a form. When the form is submitted I want it to

1. run my php script which puts all info in database (this is done and works fine on it's own)

2.Take the user to paypal using paypla subscription/ipn (this would be gotten from paypal) form action has to be: <form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post">

 

Can anybody guide me in the right direction to make 1 submit button do both?

Thanks in advance.

 

Susan

Link to comment
Share on other sites

sorry, but I am new at this.

If I'm understanding correctly, you change the action from paypal stuff to the php script, and put paypal in the header(), right?

The header() command goes in the php document? And this still has all the variables from the form for paypal?

Link to comment
Share on other sites

IPN is a two stage process, first off you have a page with your stuff on it (an item or a list of stuff), you send this info to paypal using a form. e.g. this use's the

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">

bit...

 

This leads your client to a set of paypal pages, once almost finished the paypal server requests your authorisation page. Here you check the stuff and communicate with paypal through a socket, then they'll send back either "VERIFIED" or "INVALID", at this point you have confirmation of sale.

 

Be aware of the differences between the following address's:

$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);

$fp = fsockopen ('www.sandbox.paypal.com', 80, $errno, $errstr, 30);

Link to comment
Share on other sites

Well, let's say you have a confirmation of order page, as you produce this page you may put the info to db, also on this page you have the paypal button. At this point, no payment has been made, not until they've confirmed with paypal, then paypal have confirmed with you. After that paypal return them to you.

 

Alternatively you have a confirm button, that links to one of your php pages which records some info, then redirects (using 'header' as described above) to the paypal site, all is same after that...

 

1)

Confirm -> Paypal -> Verify -> Paypal -> Confirm2

 

2)

Confirm -> Confirm.php -> Verify -> Paypal -> Confirm2

 

 

 

Link to comment
Share on other sites

so if i put header(paypalpage) in my php page, it will redirect to paypal,  something like this...

$query = mysql_query("INSERT INTO caregivers (firstname, lastname, email, phone, county, experience, date) VALUES ('$firstname', '$lastname', '$email', '$phone', '$county', '$experience', '$date')") or die(mysql_error());

if($query)
{
header(redirect to paypal page)

but will it still have all the info in the form that paypal needs or do I have to redeclare all that info? (I was trying to avoid having a confirm page)

Link to comment
Share on other sites

You could connect to the paypal page with a socket (see http://uk3.php.net/function.fsockopen for https fsockopen details) and use it like you'd use telnet:

POST /cgi-bin/webscr HTTP/1.0
From: a@b.com
User-Agent: CrashNBurn
Content-Type: application/x-www-form-urlencoded
Content-Length: 555

cmd=_xclick&business=aselle_007_biz@hotmail.co.uk&item_name=Image&item_number=555amount=3.21

Adjust 'Content-Length' according to the data your passing, also change the data...

 

If I were you i'd practice this on the sandbox or even your own setup first, i've never had to use on https... have fun!

Link to comment
Share on other sites

Having a play with telnet helps you understand how a protocol works, a basic one to look at is when constructing an email with php. But even simpler is getting web pages and the such. You might enjoi the following if you've not had a go before:

http://www.groovyweb.uklinux.net/?page_name=Using%20http%20commands%20through%20telnet

http://www.pasteur.fr/formation/infobio/web/cours/ch01.html

http://www.jmarshall.com/easy/http/

 

But, yes the original way is simpler. Not that i've tried 'curl', but that might have some builtin stuff for this type of thing, i'm sure someone else could tell you more... Have fun!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.