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.
Related
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.
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 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 trying to set up PayPal's IPN for custom cart use. But somehow it does not work. Can you guys have a look at the PayPal button code I am using? Do you notice any problems? Once I click on the Pay button, I am taking to PayPal's page that has the follow message:
We have detected a problem with this shopping cart. If the problem persists, please contact the merchant.
Questions:
What is the right way to name these variables: item_numberX or item_number_X? And the same with variables responsible for: price, name, and quantity. Do I need to add the underscore?
<input type="hidden" name="item_number_1" value="1">
<input type="hidden" name="item_name_1" value="Service 1">
<input type="hidden" name="amount_1" value="148.00">
<input type="hidden" name="quantity_1" value="1">
<input type="hidden" name="mc_gross_1" value="148">
<input type="hidden" name="item_number_2" value="2">
<input type="hidden" name="item_name_2" value="Service 2">
<input type="hidden" name="amount_2" value="30.00">
<input type="hidden" name="quantity_2" value="1">
<input type="hidden" name="mc_gross_2" value="30">
<input type="hidden" name="return" value="http://www.sitename.com/thank-you/">
<input type="hidden" name="notify_url" value="http://www.sitename.com/ipn.php">
<input type="hidden" name="first_name" value="Peter" />
<input type="hidden" name="last_name" value="James" />
<input type="hidden" name="payer_email" value="alex111#gmail.com" />
<input type="hidden" name="item_number" value="144" / >
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif"
border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
Thank you.
You have most of the button right, the only variables I see issues with are "mc_gross_x", "payer_email" and "item_number". I am not sure where you got mc_gross_x at, but this would not be used in a button, you may have it confused with an IPN variable. As for payer_email, again you may have this confused with an IPN variable. If you are trying to populate the buyers email address on the PayPal payment page, it would just be "email". Also, you do not need to pass "item_number", since you are using the cart upload method, you would just use the format that you are already using up above in your code"item_number_x".
If the button still does not work for you, I would need to see the rest of the bottom code to see why it is not working.
Implementing a standard Paypal "Buy Now" button. The docs here are unclear as to what data is passed to the 'return' url. The docs also do not mention how to send your own custom data through the form.
Can anyone supply the appropriate documentation for this?
Relevant Code:
<form accept-charset="UTF-8" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓"><input name="authenticity_token" type="hidden" value="mYAT+aR+YhVyBrulWoYoMjzY00DQggAXUVGI12TA6zk="></div>
<input id="cmd" name="cmd" type="hidden" value="_xclick">
<input id="currency_code" name="currency_code" type="hidden" value="USD">
<input id="notify_url" name="notify_url" type="hidden" value="http://localhost:3000/en/paypal_ipns/cart_purchase_ipn">
<input id="item_name" name="item_name" type="hidden" value="Cart id 5398">
<input id="quantity" name="quantity" type="hidden" value="1">
<input id="business" name="business" type="hidden" value="seller_1318259_biz#me.net">
<input id="return" name="return" type="hidden" value="http://localhost:3000/en/checkout/process_paypal_return">
<input id="amount" name="amount" type="hidden" value="1.99">
<input id="rm" name="rm" type="hidden" value="2">
<p>
<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_xpressCheckout.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">
</p>
</form>
You can have the transaction information returned to your page using PDT (Payment Data Transfer). You can find more on it here. You can also find a list of PDT variables that can get returned here. If you are wanting to pass over custom information, you can populate this into the variable "custom", and then parse that variable out once you are back on your return page. I usually separate my different variables and values that I populate into the "custom" variable with a "|" but you can use whatever works for you.