Paypal payment works on sandbox but not live paypal? - php

We are facing some issue with paypal business account, under sandbox everything is working fine, bellow is the form we are using for live:
<form method="post" action="https://www.paypal.com/cgi-bin/webscr" id="paypalForm">
<input type="hidden" value="_xclick" name="cmd">
<input type="hidden" value="email#email.com" name="business">
<input type="hidden" value="1" name="quantity">
<input type="hidden" value="website" name="item_name">
<input type="hidden" value="MDAW" name="item_number">
<input type="hidden" value="0.3" name="amount">
<input type="hidden" value="0" name="shipping">
<input type="hidden" value="http://www.website.com/ipn.php" name="notify_url">
<input type="hidden" value="USD" name="currency_code">
<input type="hidden" value="http://website.com/orderconfirm.php" name="return">
<input type="hidden" value="12" name="custom"> <a class="btn btn-primary" href="selectpixel.php"><i class="fa fa-angle-double-left"></i> Back</a>
<button id="btnOrderForm" class="btn btn-success" type="button">Make Payment via PayPal</button>
</form>
Bellow is the IPN URL where we are receiving custom values correctly while go through sandbox:
http://www.website.com/ipn.php
But we're not sure what is happening with live paypal, we are not able to go back to our site and not even receive custom variable on ipn.php file even after successful transaction.
IPN url is same as sandbox and other then that everything is same.
When the user clicks a 'pay now' button, that will redirect you on paypal and then from payal after payment it messed in case of live paypal transaction, the user can pay successfully but it is not returing back to website and IPN is not hit back to http://website.com/ipn.php url for updating information.

Firstly, your link (http://www.website.com/ipn.php) showing "HTTP 404 - File not found" when access. So, you are quested to modify this page to the available one. You can go to the link (https://github.com/paypal/ipn-code-samples) for PayPal's latest IPN sample code, and then update accordingly to your IPN script page.
Secondly, you can refer to the link (https://developer.paypal.com/docs/classic/button-manager/integration-guide/ButtonManagerHTMLVariables/?mark=html) for the HTML variable for PayPal button. The variable "return" is for the function to redirect your customers to a page after they finish the payment. The variable "notify_url" is designed for PayPal IPN which is for the function to notify the back end of your web server about the transaction information. You can go to the link below for the detais about PayPal IPN (https://developer.paypal.com/webapps/developer/docs/classic/ipn/integration-guide/IPNIntro/)

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="email#email.com">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="item_name" value="Test_Item">
<input type="hidden" name="item_number" value="MDAW">
<input type="hidden" name="amount" value="0.3">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="quantity" value="1">
<input type="hidden" name="return" value="http://website.com/orderconfirm.php">
<input type="hidden" name="notify_url" value="http://website.com/orderconfirm.php">
<input type="hidden" name="button_subtype" value="products">
<input type="hidden" name="cn" value="Add special instructions to the seller">
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" name="weight_unit" value="lbs">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted">
<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

Related

Working with Paypal cancel_return

I'm doing my project with laravel 5 and here I have to do payment with paypal. I got this code and doing well with my payments. But when someone goto paypal and if he return without doing payment cancel_return works.It's fine. But I don't know how to handle the $_GET when return Here is my route also
Route::get('/paypal/cancel','Paypal\PaypalController#paypalCancel');
I'm using this code to move to paypal page with my sandbox account.
form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" id="paypal">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="cbt" value="Return to example" />
<input type="hidden" name="business" value="xxx#gmail.com" />
<input type="hidden" name="item_name" value="{{$data['p_name']}}" />
<input type="hidden" name="amount" value="{{$data['tot']}}">
<input type="hidden" name="button_subtype" value="services" />
<input type="hidden" name="no_shipping" value="0">
<input type="hidden" name="return" value="{{url('/paypal/return')}}" />
<input type="hidden" name="notify_url" value="{{url('/paypal/notify')}}"/>
<input type="hidden" name="cancel_return" value="{{url('/paypal/cancel')}}" />
<input type="hidden" name="currency_code" value="USD"/>
<input type="hidden" name="image_url" value="" />
<input type="hidden" id="custom" name="custom" value="{{$data['id']}}"/>
<input type="hidden" class="btn btn-primary" style="width:100%" alt="PayPal - The safer, easier way to pay online!"/>
</form>
Just tell me what should I have do when user cancel his payment in paypal login and return..Thanks..
If a user cancels payment in PayPal, the next action is up to you. You can either display a "Payment was canceled" page to inform the user that they canceled the payment, or you can prompt them to try payment again.
The cancel_return URL is purely there so developers can show a friendly message when payment has been canceled.

Paypal sandbox - test payment

I am developing online store application with Laravel 4.2 + Knockoutjs and I want to make test payments with paypal. So I have created new Paypal Sandbox account. Then I login and go to Dashboard->Accounts where I created buyer and seller accounts: test-facilitator#gmail.com and test-buyer#gmail.com. Following this documentation https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/formbasics/ this is my form:
<form method="post" action="https://www.paypal.com/cgi-bin/webscr">
<fieldset>
<input id="buy" name="submit" type="submit" class="btn btn-primary" value="Buy" id="">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="test-facilitator#gmail.com">
<input type="hidden" name="item_name" value="My online store">
<input type="hidden" name="currency_code" value="EUR">
<input type="hidden" name="amount" data-bind="value: amount">
<input type="hidden" name="notify_url" value="my_notify_url">
<input type="hidden" name="return" value="my_return_url">
<input type="hidden" name="cancel_return" value="my_cancel_url">
</fieldset>
</form>
So I am clicking the button, redirected to paypal and I am trying to login with my test-buyer#gmail.com with the password I have set in the sandbox account. And here is the problem - Paypal says that my credentials are wrong. How should I proceed my test payment, what am I doing wrong ?
The problem is that your form action is posting to https://www.paypal.com/....
Your action url should be https://www.sandbox.paypal.com/cgi-bin/webscr

paypal notify_url not working and tx ID variable not pass to thank you page

Here is my paypal buy now html code:
<form name="_xclick" action="https://www.paypal.com/ca/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="alex#xumanii.com">
<input type="hidden" name="item_name" value="Bewolf Shooping Cart">
<input type="hidden" name="amount" value="<? echo $grandtotal2;?>">
<input type="hidden" name="add" value="1">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="currency_code" value="CAD">
<input type="hidden" name="member_id" value="<? echo $info['member_id'];?>">
<input type="hidden" name="return" value="http://www.bewolfclothing.com/thankyou.php">
<input type="hidden" name="notify_url" value="http://www.bewolfclothing.com/notify_paypal2.php">
<input type="hidden" name="cancel_return" value="http://www.bewolfclothing.com/mycart.php">
<input type="hidden" name="undefined_quantity" value="0">
<div class="submit-container"><input class="submit-button" type="submit" name="submit" value="CHECK OUT" /></div>
</form>
In my paypal account, under profile, my selling tools, I have set the AUTO RETURN to ON and I put the thankyou page in there.
After the purchase, it goes to the thankyou page, but the $_REQUEST['tx'] for the paypal transaction ID is not working and the notify_url NEVER gets called.
I searched online and saw that lots of people seem to have trouble with that, but I couldn't find a solution.
notify_url is used to Instant Payment Notification and the url should always be a live URL.
To get the tx ID, you need to
-Auto Return is set to ON
-Valid Return URL
-Payment Data Transfer is set to ON
and in your "http://www.bewolfclothing.com/thankyou.php"
$tx_id = $_GET['tx']; //gives you tx id

Paypal ipn - Empty IPN and wrong date. Used to work

I have a website with a simple ticket shop built into it using IPN. It has been working for the past month and I left it alone. I was working on another payment site on the same webhost and for the first time i specified the "notification_url". I noticed that I couldn't get any response from PayPal on my new build and left it there. I then checked to see that my orginal system was still working at least; It was not.
For some reason when i check my IPN history the "latest delivery atempt" is "1984/12/14 04:53:12 CET (UTC+1)". The worst thing is that it also sais "Notification url: ". Empty.
This aparently returned 200 and success allthough my access logs show no traffic to my ipn-page. I have logs running and i havn't modified either code. I can access the IPN url manualt and it will get logged. No html login and no restrictions.
Heres my payment form:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="8TPEJKFGZEJBS">
<input type="hidden" name="lc" value="sv_SE">
<input type="hidden" name="item_name" value="'.$text.'">
<input type="hidden" name="item_number" value="'.$order_id.'">
<input type="hidden" name="amount" value="'.$cost.'">
<input type="hidden" name="currency_code" value="SEK">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="rm" value="2">
<input type="hidden" name="return" value="http://mywebsite.com/?page=13&done">
<input type="hidden" name="cancel_return" value="http://mywebsite.com/? page=13&cancel">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_paynowCC_LG.gif:NonHosted">
<input type="image" style="border: none;" src="images/buy.png" border="0" name="submit" alt="PayPal - Det tryggare, enklare sättet att betala online!">
<img alt="" border="0" src="https://www.paypalobjects.com/sv_SE/i/scr/pixel.gif" width="1" height="1">
</form>
What is wrong and what should i try to fix it?
You just need to add a field "notify_url" in your form. This URL is your IPN file url.
<input type="hidden" name="notify_url" value="http://mywebsite.com/?page=13&done">
For more details:
https://cms.paypal.com/cms_content/GB/en_GB/files/developer/PP_WebsitePaymentsStandard_IntegrationGuide.pdf

redirect to a page after paypal payment success

Is it possible to redirect the user to certain page after the payment is successful.
I have this form, and when the user fills the details, I want to redirect the user to my page when the payment is successful. Is it possiblt?
This is a sample of paypal payment code.
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="accounts#freelanceswitch.com">
<input type="hidden" name="item_name" value="Donation">
<input type="hidden" name="item_number" value="1">
<input type="hidden" name="amount" value="9.00">
<input type="hidden" name="no_shipping" value="0">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="lc" value="AU">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="hidden" name="return" value="http://net.tutsplus.com/payment-complete/">
<input type="image" src="https://www.paypal.com/en_AU/i/btn/btn_buynow_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.paypal.com/en_AU/i/scr/pixel.gif" width="1" height="1">
</form>
Here <input type="hidden" name="return" value="http://net.tutsplus.com/payment-complete/"> specifies the return url. For more info - Go Here
Consider also the Auto return option: it allows you to set up an url for all buttons.
Log in and click the Profile subtab under My Account.
Click the Website Payment Preferences link under Selling Preferences.
Click the On radio button to enable Auto Return.
Enter the Return URL
The Return URL will be applied universally to all Auto Return payments. This can be overridden by mentioning separate return URLs in the payment buttons that you’ve created in your PayPal profile
More info in this answer.

Categories