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.
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'm following the steps from this answer Paypal checkout return data to redirect buyers automatically to the return URL like this (as you can see the rm option is set to 2)
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="U74VBC2YUQS7E">
<input type="hidden" name="item_name" value="subscribe">
<input type="hidden" name="amount" value="100.00">
<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="2">
<input type="hidden" name="return" value="RETURN URL FOR CONFIRMED PAYMENTS">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted">
<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!">
now I'm trying to set Auto Return in paypal account to redirect the buyer automatically to the return URL but there's no "Website Payment Preferences" option.
Second question: how to send custom variables and fetch them again using the return url like username, password..... any data entered by the user before paying so I can grab all the data like this
$payer_email = $_POST['payer_email'];
$amount = $_POST['mc_gross'];
$payment_status= $_POST['payment_status'];
so if the status is Completed and the returned amount is equal to the form amount I can use the returned email, username and password to create a paid account on my site
$username = $_POST['username'];
$password = $_POST['password'];
My idea is to use custom field like this
<input type="hidden" name="custom" value="user=username&password=encrypted-user-pass-with-sha1">
but I guess it's wrong as mentioned here amount of non-hosted paypal buy now buttin is not changing
Sorry for this long post and Thanks in advance.
Manage Buttons. It's set on the button, not the account, or you can set it yourself in the form.
i'm creating a small marketplace where several sellers can sell their products and each has their own express checkout link, depending on their email.
my form is like this:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" id="form_paypal">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="bn" value="wa_dw_2.0.4">
<input type="hidden" name="business" value="receiver#gmail.com">
<input type="hidden" name="receiver_email" value="receiver#gmail.com">
<input type="hidden" name="amount" value="123.00">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="return" value="http://www.me.com/return.php">
<input type="hidden" name="item_name" value="Product Title Goes Here">
<input type="hidden" name="undefined_quantity" value="0">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="custom" value="12345">
<input type="hidden" name="cbt" value="Return to MY WEBSITE NAME">
<input type="hidden" name="cancel_return" value="http://www.me.com/failure.php">
<input type="hidden" name="notify_url" value="http://www.me.com/notify.php">
</form>
note that i set the "cbt" value as per https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/ but it's not working :( the return link still shows
"cancel and return to receiver#gmail.com"
which is confusing and just plain ugly for the buyer.
any ideas what i'm doing wrong here?
it's the same on the sandbox or the live version, i might add.
The document says "cbt : Sets the text for the Return to Merchant button on the PayPal Payment Complete page.For Business accounts, the return button displays your business name in place of the word "Merchant" by default. " This means you will see this text on the PayPal thank you page after the buyer completes the payments . Something like below :
First, what you're using here is Payments Standard, not Express Checkout. Eshan is correct with the information he provided regarding the parameter you're working with...it doesn't come up until after the payment is completed.
If you were actually using Express Checkout you would indeed have control over what you're asking about via the BRANDNAME parameter. It would still say "Cancel and return to" but then whatever you set for BRANDNAME would get output after that.
To my knowledge Payments Standard does not give you access to adjust the cancel link like EC does.
I am using the Paypal form , the easiest way it seems for me to return data back to the response page is by building a giant custom variable and splitting it up again on return. However the data seems to get half lost on return. I cant seem to find a consistency with it.
The custom variable is built using jQuery but Ill omit that code as I have tested it and its correctly filling up the entire variable.
<form id="paypal-submit" action="https://sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="adrianbusiness#mysite.com ">
<input type="hidden" name="item_name"
value="Memorex 256MB Memory Stick">
<input type="hidden" name="item_number" value="MEM32507725">
<input type="hidden" name="amount" value="3">
<input type="hidden" name="tax" value="1">
<input type="hidden" name="rm" value="2">
<input type="hidden" name="quantity" value="1">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="EUR">
<input id="custom-info" type="hidden" name="custom" value="adrian$%&quals$%&31 carab$%&8239 j $%&do no include address$%&adrian#gmal$%&061what$%&www.hjell=d$%&does not agree to texts$%&does not agree to contact listed in directory$%&does not agree to emails$%&does not agree to contact sharing for other organisations$%&does not wish to be publicly listed$%&ffndlk$%&do not include me in the directory of education$%&fd$%&do not include me in the speakers directory$%&fed">
<input name="notify_url" value="http://example.com/paypal-info" type="hidden">
<?php /* <input type="hidden" name="zip" value="">
<input type="hidden" name="country" value="US"> */ ?>
<input type="hidden" name="return" value="http://example.com/payment-success"/>
<input type="image" name="submit" border="0"
src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif"
alt="PayPal - The safer, easier way to pay online">
</form>
In my response page...
print_r($_POST['custom']);
might only output
adrian$%&quals$%&31 carab$%&8239 j $%&do no include address$%&adrian#gmal$%&061what$%&www.hjell=d$%&does not agree to texts$%&does not agree to contact listed in directory$%&does not agree to emails$%&does not agree to contact sharing for other organ
and just stop at that even there is more text in the string.
Might Paypal have a character limit or something?
The CUSTOM parameter has a limitation of 256 characters. You've got more than that in your value so it would get chopped off accordingly.
What I like to do is save all of that sort of data in a local database record prior to sending the person over to PayPal. That way you can include this record ID in the CUSTOM parameter, and then pull that data back out of your database using that ID.
If what you're saving is considered an order/invoice record, then you could actually use the INVOICE parameter with PayPal instead of CUSTOM, and that way it would show your local Invoice ID in the PayPal transaction details in the actual Invoice Number field instead of the Custom field. Either way would work fine, though.
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.