[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Paypal expert

Posted on 2008-11-06
20
Medium Priority
?
608 Views
Last Modified: 2013-11-29
I need my order form at www.JointVentureDeals.com/order.htm simply integrated with my Authorize Net gateway account. I have all the fields in the form that I believe are correct.

Need ur assistance...
0
Comment
Question by:akiles99
  • 10
  • 10
20 Comments
 
LVL 14

Expert Comment

by:EMB01
ID: 22898674
I have integrated PayPal from the ground up... What's the specific question?
0
 

Author Comment

by:akiles99
ID: 22898686
I'm going to appear for paypal developer certification.Need to learn more about in parallel.

Can u guide me..?
0
 
LVL 14

Expert Comment

by:EMB01
ID: 22898837
Depends on what you're trying to do - what's your specific question(s) regarding PayPal integration with PHP applications?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:akiles99
ID: 22898941
Tell me how u integrate paypal with the php code?
0
 
LVL 14

Expert Comment

by:EMB01
ID: 22898985
The easiest way to integrate PayPal with PHP is to use the PayPal IPN:
https://www.paypal.com/us/cgi-bin/webscr?cmd=p/pdn/ipn-codesamples-pop-outside
0
 

Author Comment

by:akiles99
ID: 22898995
Also when i learning abt the paypal i heard of soap API...

Any idea about it?
0
 

Author Comment

by:akiles99
ID: 22899020
Can u explain this code...I'm new to coding..But can understand if u teach me...
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
 
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
 
// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
 
// assign posted variables to local variables
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
 
if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
// check the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// check that payment_amount/payment_currency are correct
// process payment
}
else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation
}
}
fclose ($fp);
}
?>

Open in new window

0
 
LVL 14

Accepted Solution

by:
EMB01 earned 2000 total points
ID: 22899243
Sure, I'll explain how this code works in the comments attached (it's mostly done for me already):

How PayPal's IPN works:
https://www.paypal.com/IntegrationCenter/ic_ipn.html

For-Loop definition and example:
http://www.tizag.com/phpT/forloop.php

I highly recommend reading the following book... I didn't know how to integrate PayPal before I read it either:
http://www.amazon.com/Professional-Web-APIs-PHP-Google/dp/0764589547

There's a section in there specifically on integration the IPN. You'll still have some questions, but you can always post them here for help.

About the SOAP API, I try not to use it because mostly everything I need can be done using the IPN. The IPN doesn't require any API credentials, either. So, you can use it with any PayPal account. Check this out for more information on the SOAP API:
https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_soap_PayPalSOAPAPIArchitecture
// read the post from PayPal system and add 'cmd'
// This part adds a field to the PayPal post which will be sent back (below) for security purposes (see above)
$req = 'cmd=_notify-validate';
 
// This part creates a for-loop (see above) from the POST data and adds the field from before ('cmd') for PayPal to validate.
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
 
// post back to PayPal system to validate
// This is the actual POST-back function as it appends the HEADER information to be sent. NOTE: You'll need to use a different socket when using PayPal's sandbox.
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
 
// assign posted variables to local variables
// This next part simply assigns the variables from the POST data.
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
 
if (!$fp) {
// HTTP ERROR
// This part throws an error if the socket could not be opened. Otherwise, if the socket was opened, the HEADER data is sent. 
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
// This part returns the result (whether PayPal verified the order or not).
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
// check the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// check that payment_amount/payment_currency are correct
// process payment
}
else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation
}
}
fclose ($fp);
}
?>

Open in new window

0
 
LVL 14

Expert Comment

by:EMB01
ID: 22899262
P.S. The function above isn't exactly a for-loop, but it is good to know how to use one anyway. Here is documentation on the actual function used in the script:
http://us.php.net/foreach
0
 

Author Comment

by:akiles99
ID: 22899288
>>>I highly recommend reading the following book... I didn't know how to integrate PayPal before I read it either:

But u know some coding languages right?But i dont know any language.Jus starting my carreer.
0
 
LVL 14

Expert Comment

by:EMB01
ID: 22899429
I knew very little, but PHP is quite easy for me now. Let me tell you, PHP (in my experience) is simply getting an understanding of how programming works (i.e. declaring variables, using functions, etc.), learning functions, and learning best programming practices. If you're beginning programming, I would also recommend this series of books (Visual Blueprint):
http://www.amazon.com/PHP-Blueprint-Creating-Server-Side-Content/dp/0764535617

That book will help you understand programming in general, and show you how PHP works at the same time.

Also, if you're just beginning; you probably don't want to just start out learning PHP. I think it would be wise to gain a solid understanding of HTML (if you havn't already). That way, you'll get to learn how programming works.

It took me a pretty long time before I was able to program my own applications. You may be better off taking a computer-programming class. All I did was read books...
0
 

Author Comment

by:akiles99
ID: 22899454
So u first want me to read HTML?Any good links for that...
0
 
LVL 14

Expert Comment

by:EMB01
ID: 22899496
Of course, check this place out:
http://www.w3schools.com/html/DEFAULT.asp

Another good way to accomplish programming goals for beginners is to use pre-built tools, such as these from WebAssist:
http://www.webassist.com/
0
 

Author Comment

by:akiles99
ID: 22899541
U really helped a lot...

I will sure read the books u preferred.

I have a account to my company library where i have all the books u said.Jus now going thru the web API also i found a book same like this but that is development with API.

Anyway i first follow ur instructions.

1.Html
2.PHP
3.WebAPI

Right?
0
 

Author Closing Comment

by:akiles99
ID: 31514049
Who is Expert?

Who shares and care for helping others and EMB01 is the one and best i have seen.

Thanks a lot:)
0
 
LVL 14

Expert Comment

by:EMB01
ID: 22899686
Yes, I believe that's the best way to go about your education in this field. Remember, these are the goals to go after:
- Gain a solid understanding of general programming (via simple languages such as HTML, CSS, even BBCODE.
- Learn basic PHP syntax and use of variables, functions and operators (http://us2.php.net/manual/en/language.basic-syntax.php).
- Implement these programming practices to create custom applications using a web-based API (such as PayPal).
0
 

Author Comment

by:akiles99
ID: 22899708
Thanks i will sure follow this may be it takes some years But i will be reach u oneday with my improvement...

Also http://www.webassist.com/  which one i need to use?
0
 
LVL 14

Expert Comment

by:EMB01
ID: 22899753
Well, I'm not sure you'll ever reach me! (just kidding!)

I recommend using WebAssist if you use Dreamweaver. They make extensions for Dreamweaver that will assist in development. For example, if you want a pre-built (but customizable) shopping cart that will integrate PayPal with Authorize.NET, check out this product:
http://www.webassist.com/professional/products/productdetails.asp?PID=123
0
 

Author Comment

by:akiles99
ID: 22899767
Ok Thanks....Its already late see u tomorrow on different thread:)

Good Night::)-
0
 
LVL 14

Expert Comment

by:EMB01
ID: 22899851
Take it easy! I'm glad I could help. Goodluck and stick with it - it'll be hard at first (I'm self-educated) and you'll probably get lost a bit; but remember: You can do it!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The online market is growing at an unprecedented rate and retail eCommerce sales are expected to reach $4 trillion by 2020. Yet, the profit is not just there for the taking because you have to set yourself apart from the competition.
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question