FAIL Error: 4011 - paypal

This is my form:
<form method=post action="https://www.paypal.com/cgi-bin/webscr">
<input type="hidden" name="cmd" value="_notify-synch">
<input type="hidden" name="tx" value="<?php echo $_GET['tx']; ?>">
<input type="hidden" name="at" value="52522320223225333633365254541">
<input type="submit" value="PDT">
</form>
When i submit the above form the fail will occur.

This error was cause by using SandBox credentials, while redirecting
to non-sandbox URL.
PayPal Express returns 4011 error message in Sandbox mode

Related

PayPal instant payment notification (IPN) sandbox

I am trying to enable PayPal IPN on my website. I am now facing some issues with the tests environment - PayPal sandbox.
I am trying to integrate with PHP, so I am using the code of the file paypal_ipn.php from https://github.com/paypal/ipn-code-samples.
I have a test HTML page with which I send the POST actions to paypal_ipn.php:
<form target="_new" method="post" action="http://example.com/paypal_integration/paypal_ipn.php">
<input type="hidden" name="business" value="your#paypal_email.com">
<input type="hidden" name="item_name" value="product name">
<input type="hidden" name="amount" value="1" >
<input type="hidden" name="item_number" value="1">
<input type="hidden" name="custom" value="CUSTOM_CODE_#...">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="quantity" value="1">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="return" value="http://example.com/paypal_integration/return.php">
<input type="hidden" name="cancel_return" value="http://example.com/paypal_integration/cancel_return.php">
<input type="hidden" name="cbt" value="description">
<input type="hidden" name="rm" value="2">
<input type="hidden" name="notify_url" value="http://example.com/paypal_integration/paypal_ipn.php">
<input type="submit" value="submit!" />
</form>
The result is "INVALID". How do I go through this problem, in the sandbox environment and after that in live environment? I.e. how to get "VERIFIED" actions in sandbox?
I have solved this:
in paypal account go to https://developer.paypal.com/developer/ipnsimulator/ ;
after that, fill the form: in "transaction type" choose for instance "cart checkout";
in "IPN handler URL" put the link of the IPN receiver page: http://example.com/paypal_integration/paypal_ipn.php
or:
in paypal account, create test accounts: https://developer.paypal.com/developer/accounts ;
log-in with the facilitator account, and then create a test button as indicated here: https://developer.paypal.com/docs/classic/paypal-payments-standard/ht_test-pps-buttons/ (go to: https://www.sandbox.paypal.com/pt/cgi-bin/webscr?cmd=_button-designer );
use the button code, eg.: <input type="hidden" name="hosted_button_id" value="6RNT8A4HBBJRE">, in the button of the website and then simulate a purchase.

paypal integration and testing

I use sandbox for simple pay, my form is:
<form method="post" action="https://www.sandbox.paypal.com/cgi-bin/webscr" name="paypal">
<input type="hidden" value="_cart" name="cmd">
<input type="hidden" value="1" name="upload">
<input type="hidden" value="1" name="no_note">
<input type="hidden" value="1" name="no_shipping">
<input type="hidden" value="USD" name="currency_code">
<input type="hidden" value="{{my external script here[http://example.com]}}" name="notify_url">
<input type="hidden" value="{{my email}}" name="business">
<input type="hidden" value="Eko " name="item_name_1">
<input type="hidden" value="107-372" name="item_number_1">
<input type="hidden" value="0.50" name="amount_1">
<input type="hidden" value="1" name="quantity_1">
<input type="hidden" value="E-mail" name="item_name_2">
<input type="hidden" value="Free Shipping" name="item_number_2">
<input type="hidden" value="0.00" name="amount_2">
<input type="hidden" value="1" name="quantity_2">
<input type="hidden" value="0.23" name="tax_cart">
<input type="hidden" value="0" name="discount_amount_cart">
<input type="hidden" value="http://test.t/put-log.php" name="return">
<input type="hidden" value="http://test.t/raw.html" name="cancel_return">
<input type="submit">
</form>
After submit this form I pay using another sandbox account. My payment is correct but Im not redirecting to notify_url, looks like my IPN is lost or not sending, maybe because sandbox mode or any other idea?
SOLVED
My sandbox account misconfiguration - added verfication (bank account) to sandbox account and now history logs looks ok
Thanks for help!!
notify_url is for IPN which is completely separate from the checkout flow. No redirection will take place with your notify_url. The redirect would be the "return" parameter and could be used with PDT, which is similar to IPN, however, the user is never guaranteed to make it back to your return URL so it's not recommended to handle any post-transaction processing with PDT.
IPN is what you want, but you have to remember it's separate from the checkout flow. Check the IPN History from the sandbox account you're using as the seller. Also check your web server logs. It could be that the IPN is getting triggered but you have an error in your script keeping it from running correctly. IPN History and your web server logs will help you track this down.

Paypal IPN test works, but I don´t get any ipn after a sandbox purchase

when I run an ipn test everything works great. The data gets logged into the database as I planned it.. However when I purchase a product via. the sandbox:
money transfered
money accepted
I don´t get any ipn
The form code I use:
<div class="panel-footer">
<form class="btn-block" name="_xclick" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="paypal#**.com">
<input type="hidden" name="item_name" value="product name">
<input type="hidden" name="item_number" value="3500">
<input type="hidden" name="amount" value="50">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="custom" value="<?php echo $sponsored_data[$key]['user_id']; ?>::bteam::50::3500">
<input type="hidden" name="notify_url" value="http://**.com/paypal/ipn.html">
<input type="hidden" name="return" value="http://**.com/sponsor.html">
<input type="hidden" name="shopping_url" value="http://**.com/sponsor.html">
<button type="submit" class="btn btn-lg btn-block btn-default">BUY NOW!</button>
</form>
</div>
As I said, if I run the test on this adress it works fine: http://**.com/sponsor.html
Is the sandbox test not sending any ipn or did I do something wrong ?

Paypal throws empty response while send multiple items

I am working from last couple of days on same issue. Getting empty response while sending multiple items. But, for single payment, I am getting Array values. Can you please check the below code and let me know any changes required.
Test.php
..............
<?php
$cur_dir='http://'.$_SERVER['SERVER_NAME'] . dirname($_SERVER['REQUEST_URI']);?>
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<INPUT TYPE="hidden" name="charset" value="utf-8">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="xxxxxxx#gmail.com">
<input type="hidden" name="currency_code" value="US">
<input type="hidden" name="item_name_1" value="beach ball">
<input type="hidden" name="amount_1" value="15">
<input type="hidden" name="item_name_2" value="towel">
<input type="hidden" name="amount_2" value="20">
<input type="hidden" name="return" value="<?php echo $cur_dir.'/test1.php'; ?>">
<input type="hidden" name="notify_url" value="<?php echo $cur_dir.'/test.php'; ?>">
<input type="image" value="submit" src="images/byunow.jpg" alt="submit Button" >
</fieldset>
</form>
Test1.php returns Empty value
.................
<?php print_r($_POST); ?>
You may want to enable the Payment Data Transfer feature for the seller account - see: https://developer.paypal.com/webapps/developer/docs/classic/products/payment-data-transfer/
you can then take the returned data to establish a secure connection to paypal in order to retrieve payment details.
However, please bear in mind that the buyer won't hit the return URL 100% of the time - so you will want to rely on IPN (See: https://developer.paypal.com/webapps/developer/docs/classic/ipn/gs_IPN/) for processes like updating an order status.
IPNs are sent to the "notify_URL" as soon as a new transaction arrives on the account.

PayPal get params after success returned

I am currently implement PayPal into a form for articles subscription, below codes are run fine to direct to paypal web screen and process the transaction.
HOW if I want to get back certain params after transaction has successfully made? I tried echo $_REQUEST['custom'], $_REQUEST['email'], $_REQUEST['a3'] and $_REQUEST['p3'] after redirect from paypal back to returned url, BUT only $_REQUEST['custom'] is display, how can I get these params back for further proccess?
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick-subscriptions">
<input type="hidden" name="business" value="someone_1360103868_biz#sitename.com">
<input type="hidden" name="email" value="<?php echo $BuyerEmail ?>">
<input type="hidden" name="item_name" value="<?php echo $ProdDesc ?>">
<input type="hidden" name="item_number" value="1">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="rm" value="2">
<input type="hidden" name="return" value="http://sitename.com/return.php?msg=Transaction+Complete">
<input type="hidden" name="cancel_return" value="http://sitename.com/return.php?msg=Transaction+Canceled">
<input type="hidden" name="notify_url" value="http://sitename.com/notify.php">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="<?php echo $Currency ?>">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="custom" value="<?php echo $RefNo ?>">
<input type="hidden" name="a3" value="<?php echo $Amount ?>">
<input type="hidden" name="p3" value="<?php echo $Duration ?>">
<input type="hidden" name="t3" value="M">
<input type="hidden" name="src" value="1">
<input type="hidden" name="sra" value="1">
<input type="submit" name="Submit" value="Pay now">
</form>
one way i have found:
try to insert this field into your generated form code:
<input type='hidden' name='rm' value='2'>
rm means return method;
2 means (post)
Than after user purchases and returns to your site url, then that url gets the POST parameters as well
p.s. if using php, try to insert var_dumy($_POST); in your return url(script),then make a test purchase and when you return back to your site you will see what variables are got on your url.
Trying to get back the information is not necessary if you record them on the way out, ie: before submitting to Paypal. For example it's a good idea to record all attempts so that you can follow up on failed transactions, ie: users having card problems, bugs in your code, etc.
If you are using a "good" shopping cart this will already be included. So when someone completes and submits an order form, your shopping cart adds the record and generates a new order number (ID number). The form submitting to Paypal can then include that ID number, so all that you need to retrieve after a successful transaction is that ID number and then you can programmatically update the order as paid and provide a printable receipt online that is populated from your database table.
To do this all you need to do is retrieve Request("item_number")
How are you wanting to return the information to your site. Are you wanting it returned to the return page on your site so that you can display it to your buyer, or are you just wanting it returned to your system to update a database. If you are wanting the mbuyer to see this on the return page, you would want to use either the return method where you use the variable "rm" and pass over the return URL in your button code. You can use a POST for this method, or you can use PDT and this will be a GET method. PDT will also allow you to validate the data against the PayPal. Then there is IPN, which will not be desplayed to the buyer. This would be used for udpating your database. See my post I made here as well, as this may have some more useful information.