PayPal Convertings Spaces in _cart Form to Plus Sign - paypal

Recently (starting March 2017), the _cart form integration with PayPal payments standard has started encoding spaces in all item info (names and options) to the plus sign (+). I verified this was happening in Chrome and added the enctype attribute to the form, which seemed to solve the issue for me. In Chrome and Firefox, I can send data to PayPal and spaces are preserved properly. Perhaps this is a fluke?
However, almost every customer that purchases is getting their info encoded improperly, which results in the IPN request not being able to verify the products they purchased.
The form:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="name#example.com">
<input type="hidden" name="charset" value="utf-8">
<input type="hidden" name="item_name_1" value="Product With Spaces">
<input type="hidden" name="quantity_1" value="1">
<input type="hidden" name="amount_1" value="30.00">
<input type="hidden" name="on0_1" value="Name">
<input type="hidden" name="os0_1" value="First Last">
<input type="hidden" name="on1_1" value="Email">
<input type="hidden" name="os1_1" value="customer#example.com">
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" align="left" style="margin-right:7px; margin-top: 2px;">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
When submitted to PayPal, the product is shown as Product+With+Spaces and the name as First+Last. Thus the transaction record on PayPal and the IPN request have the incorrectly encoded data also.
I tried encoding the spaces as %20 or + (which would normally result in double-encoding, so I didn't expect it to help), but those literal characters were shown on PayPal.
I've read over the PayPal developer docs, and I seem to be using the most up-to-date fields and URLs. Also, this code has been running successfully for years without trouble.

Solved! added the enctype="multipart/form-data" attribute to the paypal button form, return variables to ipn come back in same state as submitted

Related

Paypal Express Checkout shows only one item

I am trying to use Paypal shopping cart in my web page:
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post" >
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="xxx">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="item_name" value="My Event Registration - Adult">
<input type="hidden" name="amount" value="30.00">
<input type="hidden" name="item_name_1" value="My Event Registration - Child">
<input type="hidden" name="amount_1" value="10.00">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="button_subtype" value="products">
<input type="hidden" name="add" value="1">
<input type="hidden" name="bn" value="PP-ShopCartBF:btn_cart_LG.gif:NonHosted">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_cart_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>
This code is mostly generated using PayPal Payment Button helper on PayPal's website.
It seems PayPal's website generates code only for a single item. As I needed two items, I added another item using input fields item_name_1 and amount_1.
When I click on the submit button, I am properly taken to PayPal's shopping cart. However, I see only one item in the cart. I was expecting to see both, Registration-Adult and Registration-Child, in the shopping cart.
I am wondering what is it that I am missing. Regards.
It seems the hidden field "add" can only add one item. You could use "upload" instead. However, in that case PayPal's shopping cart page does not get displayed. For our case, the shopping cart has to be shown so that users can change the number of items. My solution was to actually have two forms instead of one in the same webpage. This works. The only drawback is the user has to click on two buttons instead of one.

Paypal post data getting lost on return (sandbox)

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.

Automatically tick 'Make this recurring (monthly)'

I've got a donate page on a website I'm building for a charity. On the page they want to have two options: 'Donate' and 'Donate monthly'. These buttons should take you straight to the donations page on PayPal, however the client wants the 'Donate monthly' button to make the 'make this recurring (monthly)' box on the paypal site itself, pre-ticked.
Is there a way to do this by passing a parameter? Either via Query string or hidden input. Here is the code as it stands at the moment:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_donations">
<input type="hidden" name="business" value="paypal#clientemail.org">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="item_name" value="Client Name">
<input type="hidden" name="item_number" value="Donate">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="currency_code" value="EUR">
<input type="hidden" name="bn" value="PP-DonationsBF:donateBtnPaypal.png:NonHostedGuest">
<input class="btn shorter diavlo book" type="submit" value="Donate monthly (€)" 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>
What you could do is switch to the Express Checkout API. This would give you the ability to design those options into your own UI and pass it all over to PayPal however you want to.
If you're working with PHP my class library for PayPal will make it very easy on you. Specifically, you would be using:
SetExpressCheckout
GetExpressCheckoutDetails
DoExpressCheckoutPayment
CreateRecurringPaymentsProfile
No, its not possible to make it as default option "Make This Recurring (Monthly)"

paypal IPN works with Destop web-browsers but not mobile web-browsers

Hi I have an issue where I have a PayPal form on my website when I click to pay using a Desktop web-browser, the transaction completes with all IPN Posted data from PayPal being correct! However when I use an android or IOS device the transaction completes, but there is no Posted data from PayPal when user clicks the return to business-name site? Now if I do another transaction with the Desktop web-browser using an android user-agent, I get the same results that is happening with the mobile devices (No IPN posted data from PayPal)? My form:
<form action="https://www.sandbox.paypal.com/us/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="hug33472-facilitator#hugtech.com">
<input type="hidden" name="item_name" value="Power-Ball Roller Android App">
<input type="hidden" name="item_number" value="PBRAND0114">
<input type="hidden" name="amount" value="1.37">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="return" value="http://hugtech.com/cgi-bin/pbandroid/secret">
<input type="hidden" name="rm" value="2">
<input type="hidden" name="cancel_return" value="http://hugtech.com/power_ball/mob">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit"><img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
Thanks, Larry
It sounds like you're confusing PDT and IPN. They're very similar except that PDT is meant to send data back to your return URL while IPN is meant to send data to an entirely separate script that isn't part of your checkout flow. IPN is the recommended method of updating your database, sending out emails, etc. Based on what you're saying about clicking the return link, though, you must be using PDT.
I haven't specifically tested PDT with mobile checkouts, but I know IPN does trigger regardless of the payment method or device. So make sure you're using IPN, not PDT, and you'll be fine.

PayPal Checkout Buttons and Custom Variables

I have created a rather simple photo gallery that I wish to apply PayPal Checkout buttons. The basics are simple enough, but what I want to do is to at least pre-populate the named fields as part of the button or pass variables contained in each individual page through to the cart.
Each page contains a picture ID, date, and title. I would like to be able to pass this data along so that when someone clicks "Add to Cart", the data is already there. Right now the only way I can see the buttons working is creating custom fields and having the customer copy and paste the data themselves, kind of a pain.
If I could figure this one thing out PayPal checkout might be worth while. Has anyone here ever done this?
You need something like this? I got it out of the PayPal docs awhile back. I'm using it in a production app now. Please test before using though :)
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post" style="margin:4px 0px 0px 4px;">
<input type="image" src="<ADD_TO_CART_BUTTON>.jpg" border="0" name="submit" alt="Add this item to your shopping cart">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
<input type="hidden" name="add" value="1">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="<YOUR_PAYPAL_EMAIL>">
<input type="hidden" name="item_name" value="<THE_ITEM_NAME>">
<input type="hidden" name="item_number" value="<THE_ITEM_NUMBER_SKU_OR_WHATEVER>">
<input type="hidden" name="amount" value="<HOW_MUCH_IT_COSTS>">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="cn" value="<CUSTOM_TEXT_FOR_THE_BUYER_TO_LEAVE_YOU_SPECIAL_INSTRUCTIONS>">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="bn" value="PP-ShopCartBF">
<input type="hidden" name="address_override" value="1">
<input type="hidden" name="business_cs_email" value="<YOUR_PAYPAL_EMAIL>">
<input type="hidden" name="return" value="<WHERE_TO_TAKE_THE_USER_AFTER_PURCHASE_LIKE_thankyou.html>">
<input type="hidden" name="notify_url" value="<IF_YOU_PROCESS_ORDERS_THROUGH_YOUR_SITE_THE_CALLBACK_URL_GOES_HERE>">
</form>
You'll need one of these for each item you're selling.
Signup at http://sandbox.paypal.com and start working in their sandbox to try this out.
Also check out http://www.x.com and http://www.paypal-labs.com. They've been doing some cool stuff with checkouts.
Also check out using the "custom" PayPal variable, which you can use to pass any information you want to PayPal and get it back when the transaction completes.