Working with Paypal cancel_return - php

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.

Related

PayPal buy now button with IPN

I am new to PHP , and PayPal.
I need to do crowdfunding site.
Here I have a form where user can choose pay method :
Pay with terminal
Bank transfer
Paypal
Input with amount that user want to donate for project, and some fields like name, surname , phone etc.
Now action of my form is example.com/pay.php, here I register pay in my database with status "in progress" and i want after it to redirect user to PayPal page.
How to redirect user to PayPal with necessary data (see in PayPal button code) , after I add the transaction to my database?
Code of of my PayPal button:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="BJKELCPG5WDSN">
<input type="hidden" name="lc" value="MD">
<input type="hidden" name="item_name" value="Help African child">
<input type="hidden" name="item_number" value="2299">
<input type="hidden" name="amount" value="67.00">
<input type="hidden" name="currency_code" value="EUR">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="rm" value="1">
<input type="hidden" name="return" value="http://example.com/test/thanks.php">
<input type="hidden" name="cancel_return" value="http://example.com/test/">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted">
<input type="hidden" name="notify_url" value="http://example.com/test/listener.php">
<input type="image" src="https://www.paypalobjects.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.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
Help me please with this problem.

Paypal payment works on sandbox but not live paypal?

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>

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 Return URL not working while transferring payment to personal account

It is possible to enable return url for business account editing user website preference, but if I want to transfer money to personal account on paypal, then return url is not working
Please suggest
The HTML code for redirecting to paypal
<html>
<head><title>Processing Payment...</title></head>
<div id="loading_image" style="position:absolute; left:600px; top:300px;">
<img src="themes/theme1/images/waiting.gif" /> Redirecting to Paypal.
</div><form method="post" name="paypal_form" action="https://www.sandbox.paypal.com/cgi-bin/webscr">
<input type="hidden" name="rm" value="2"/>
<input type="hidden" name="cmd" value="_xclick"/>
<input type="hidden" name="business" value="email"/>
<input type="hidden" name="success_url" value="http://url/admin/transactions/index/successfull"/>
<input type="hidden" name="cancel_return" value="http://url/admin/transactions/index/failed"/>
<input type="hidden" name="notify_url" value="http://url/quotes/paypal_ipn"/>
<input type="hidden" name="custom" value="3|4|1|3"/>
<input type="hidden" name="item_name" value="Payment for Job Completion"/>
<input type="hidden" name="amount" value="11.4"/>
</form>
</body></html>
There is no any return url in paypal for success response you have to send success_url variable to paypal to respond back

How do i get the status of Paypal when it is completed

.I am developing a site where users can login with paypal and pay for a specific service. Money is transferring correctly. But i always get the status as Pending and reason as paymentreview or reason as unilateral. Is there any way to get the status when it is completed. I am testing this in sandbox. my code is
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="POST" name="_cart" id="paypal_form">
<input type="hidden" name="upload" value="1" />
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="business" value="mybusiness#gmail.com" />
<input type="hidden" id="custom" name="custom" value=""/>
<input type="hidden" id="on0" name="on0" value="0"/>
<input type="hidden" id="amount_1" name="amount_1" value="10" />
<input type="hidden" name="currency_code" value="<?php echo $cntry; ?>" />
<input type="hidden" name="item_name" value="Account Deposit" />
<input type="hidden" id="amount" name="amount" value="10" />
<input type="hidden" name="return" value="RETURN URL AFTER TRANSACTION" />
<input type="hidden" name="notify_url" value="URL FOR UPDATING STATUS AFTER PAYMENT" />
<input type="hidden" name="cancel_return" value="MYSITE.COM" />
</form>
Thank you..
That's what IPN is for. You get a notice sent to you by Paypal that will notify you when you get paid or when your payment status changes. So Paypal will notify you when your payment status goes to Completed

Categories