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.
Related
We integrated Paypal button to support our starting business. We received several user feedbacks about not being able to complete payment. They reported that they can see the payment page after clicking the Buy Now button. However they tried pay through Paypal account, pay with credit card and pay with Paypal credit. None of them work. However, no one in our team has faced such problem when checking out. So we really don't have an idea about what's going on. Here is an example Paypal button code we use:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="business#myticket.com">
<input type="hidden" name="env" value="www">
<input type="hidden" name="address_override" value="0">
<input type="hidden" name="item_name_1" value="演唱会">
<input type="hidden" name="amount_1" value="122">
<input type="hidden" name="discount_rate_1" value="10">
<input type="hidden" name="item_name_2" value="演唱会">
<input type="hidden" name="amount_2" value="122">
<input type="hidden" name="discount_rate_2" value="10">
<input type="hidden" name="shipping_1" value="$27.95">
<!-- Fill full name in the first_name field -->
<input type="hidden" name="first_name" value="Bruce Lee">
<input type="hidden" name="notify_url" value="https://www.myticket.com/payment/ipn">
<input type="hidden" name="address1" value="">
<input type="hidden" name="address2" value="">
<input type="hidden" name="city" value="">
<input type="hidden" name="state" value="">
<input type="hidden" name="zip" value="">
<input type="hidden" name="country" value="US">
<input type="hidden" name="email" value="">
<input type="hidden" name="custom" value="lmIvjDuZVRsCWFPDdfFsrKiNVrnAbWeTZSINiDuszZEGKjeXfhqxyqRrn">
<input type="hidden" name="paymentaction" value="authorization">
<input type="hidden" name="charset" value="utf-8">
<input type="hidden" name="return" value="https://www.myticket.com">
<input type="hidden" name="cancel_return" value="https://www.myticket.com">
<input type="image" name="submit" border="0" src="https://www.paypalobjects.com/webstatic/en_US/i/buttons/checkout-logo-large.png" alt="Check out with PayPal">
</form>
Is there any problem with this Paypal button? If not, what else could be causing the payment to fail?
Besides, is there a way we can get a message about these failures? Right now we are using IPN. However IPN doesn't seem to notify us about these payment failures.
BTW, myticket.com is a fake url in this post.
Well first, when using Website Payments Standard buttons, you don't get much back as far as the declines. Typically you are only going to get details of declines back when you are using API calls to process the payment. As for the button itself, it looks fine to me. Perhaps some of the issue is with the special characters for the item name which is leading to the failure. You could try creating 2 of the same buttons/items but without the special characters and see if those same buyers run into the issue with the second button that they did with the first one. You could also try using the "lc" variable in your button code to see if this helps. You can see the description of what the "lc" variable does here.
I need to collect information about our high school reunion attendees and allow them to pay via a PayPal button. I've created the PayPal Pay Now button, but not sure what if any information will be collected and sent back to me. Do I need a separate form to collect information or is there a way to make the PayPal button work as the submit button for the data I collect using a form?
You should use a IPN (Instant Payment Notification) for this. There are lots of good templates for this available on GitHub. Your form might look like this:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" >
<input type="hidden" name="business" value="YOUR PAYPAL ID">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="upload" value="1" />
<input type="hidden" name="item_name" value="ITEM_NAME">
<input type="hidden" name="item_number" value="ITEM_NUMBER>
<input type="hidden" name="amount" value="TOTAL_AMOUNT">
<input type="hidden" name="custom" value="<?php echo $attendee_id ?>">
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="rm" value="2">
<input type="hidden" name="cbt" value="Return to website">
<input type="hidden" name="currency_code" value="EUR">
<input type="hidden" name="return" value="http://domain.com/success.php"/>
<input type="hidden" name="notify_url" value="http://domain.com/ipn.php"/>
<input type="hidden" name="cancel_return" value="http://domain.com/canceled.php"/>
<button type="submit">Pay using PayPal</button>
</form>
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 ?
I am trying to send POST vars to paypal ipn like that:
<form class="form-horizontal paypal-button" method="post" action="https://www.sandbox.paypal.com/cgi-bin/webscr" target="_top" style="opacity: 1;">
<input type="hidden" name="button" value="buynow">
<input type="hidden" name="business" value="vendedor#estadosbinarios.com">
<input type="hidden" name="quantity" value="1">
<input type="hidden" name="currency_code" value="EUR">
<input type="hidden" name="shipping" value="0">
<input type="hidden" name="tax" value="0">
<input type="hidden" name="notify_url" value="http://www.estadosbinarios.com/pagos/paypal_ipn.php">
<input type="hidden" name="return" value="http://www.estadosbinarios.com/pagos/success.php">
<input type="hidden" name="env" value="www.sandbox">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="bn" value="JavaScriptButton_buynow">
<!-- Enable override of buyers’s address stored with PayPal . -->
<input type="hidden" name="address_override" value="1">
<input id="nombre" name="first_name" type="text" placeholder="" class="form-control input-md">
<input id="nombre" name="last_name" type="text" placeholder="" class="form-control input-md">
</form>
But Paypal doesn´t care my vars first_name or last_name, paypal is always getting the vars from user account of paypal and overwriting that var.
Is there any way to choose my vars?
When people pay with PayPal through it is indeed going to use the info provided from the shipping address of their account. You can't get around this with Payments Standard like you're using.
You could switch to the Express Checkout API which would give you the option of collecting the buyers name, address, etc. and then passing that over to PayPal in a way that cannot be overridden. This way you'd get whatever they typed into your site instead of relying on PayPal to provide those details.
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.