Jump to content

Recommended Posts

I was wondering, here
https://developer.paypal.com/devscr?cmd=_signup-run

I have a paypal account with my email address.
I also use paypal alot during development, and I have always had issues getting it to work, and to test it, I sit there and send the person 1 penny at a time, over and over again during the testing phase.  As well as send all the money back to me, and when I did 2 projects back, I noticed I had sent here nearly 2 dollars in pennies, through paypal.  I was figuring there had to be an easier way, so I went to paypal dev center, to see if I wanted to use. 
I don't get a few things go, I set up an email there, if I use the same email tosign up for that as my original paypal account what happens?

Can someone also tell me a little about how this works.  I know quite a bit about it, I have read what I could find about it?
I finally got in, I set up 2 paypal email accounts, in the sandbox.  I was wondering how to figure out one thing though, I choose 2 test email accounts, but how do I use those accounts when I am trying to mess with the form, that I am putting through the payments.
I don't know anything about them, I don't think I have any need for paypal's api, I have so far only needed the ipn,  I think they are for different purposes, I can always go back to testing it with 1 penny at a time, but I was hoping the sandbox would fix that, is there another way, or another idea.  Like for instance how to use the paypal email's in the sandbox to test the stuff.
Yes, the sandbox does fix that. You just have to change the action="" attribute of your PayPal form. It normally points to https://www.paypal.com/something, but you need to change it to point to https://sandbox.paypal.com/something. I believe that's the URL, anyway - look around and you'll find it.
[quote author=neylitalo link=topic=110379.msg446159#msg446159 date=1159898055]
Yes, the sandbox does fix that. You just have to change the action="" attribute of your PayPal form. It normally points to https://www.paypal.com/something, but you need to change it to point to https://sandbox.paypal.com/something. I believe that's the URL, anyway - look around and you'll find it.
[/quote]

You just need www. in front of it, so it is: https://www.sandbox.paypal.com/
Thank you, finally I was able to get someone to help, I was trying on 2 different paypal forums.

Now in reality you see why I come to phpfreaks, for every single question I have, except some php questions, adn a few css questions at w3schools.  90% of the time phpfreaks is the best place to ask for questions.
[code]<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="business" value="testrecieve@paypaldev.com" />
<input type="hidden" name="item_name" value="Payment Option 1" />
<input type="hidden" name="item_number" value="1" />
<input type="hidden" name="amount" value="0.01" />
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="bn" value="PP-BuyNowBF" />
<input type="hidden" name="return" value="http://www.hasbadservice.com/thankyou.php" />
<input type="hidden" name="cancel_return" value="http://www.hasbadservioce.com/cancelpayment.php" />
<input type="hidden" name="notify_url" value="http://www.hasbadservice.com/ipn.com" />
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but02.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!" />
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>[/code]
That fixed that problem, it's starting to work now, but it's not doing what I need in the ipn, I am just testing it out to see if it'll email me, but for now, I changed paypal address to sandbox, and it's not working here it is.

[code]<?php
// 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 ('www.sandbox.paypal.com', 80, $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'];
mysql_connect("localhost", "#####", "####");
mysql_select_db("hasbadse_hbservice");
mail("businessman332211@hotmail.com", "successful", "Message goes here");



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);
}

?>[/code]

I don't get it.  There is probably something simple, it is however successfully doing the full payment process, I have just to get it to test the ipn for me.
I am having problems, can someone help me with this again.

I have had a few problems, but reduced them to one, impassable one.

At first I was having overall troubles, but after a lot of work, and a mini tutorial, I set up a developer account(a paypal sandbox test account setup), and created 2 email addressses on there for testing the ipn.  I tested it, and after some work I was able to create a developer account(overall account setup), and then 2 test emails for it.  One was testrecieve, and one was testpay.  The test recieve is recieving the payment, and the testpay, is sending the payment.  I tested it, and the payments were going greate, but it's simply ignoring my call to the ipn, and it's not sending me the email like it's suppose to, so it's totally ignoring it.
The problem now is that I can't get it to just read the ipn. I just want it(for now), to email me, so I know it's working.  Here is my coding for the form, and the ipn set. 

[code]<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="business" value="testrecieve@paypaldev.com" />
<input type="hidden" name="item_name" value="Payment Option 1" />
<input type="hidden" name="item_number" value="1" />
<input type="hidden" name="amount" value="0.01" />
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="bn" value="PP-BuyNowBF" />
<input type="hidden" name="return" value="http://www.hasbadservice.com/thankyou.php" />
<input type="hidden" name="cancel_return" value="http://www.hasbadservioce.com/cancelpayment.php" />
<input type="hidden" name="notify_url" value="http://www.hasbadservice.com/ipn.com" />
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but02.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!" />
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>[/code]

ipn page.
[code]<?php
// 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 ('www.sandbox.paypal.com', 80, $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'];
mysql_connect("localhost", "#####", "#####");
mysql_select_db("hasbadse_hbservice");
mail("businessman332211@hotmail.com", "successful", "Message goes here");



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);
}

?>[/code]
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.