How do I pass a comment to paypal's payment page? - paypal

I have a form that adds items to a cart. But I want to give them an option to ship the item to a store.
My form looks like this...
<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="XXXXXXXXXXXXXX" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="amount_1" value="19.99" />
<input type="hidden" name="item_name_1" value="MyCoolTshirt" />
<input type="hidden" name="quantity_1" value="2" />
<input type="image" src="Checkout-Button.jpg" name="submit" alt="cart add" />
</form>
Can I add a code in there that will deliver the comment to me, indicating "Ship to store" so customer can pickup instead of shipping it to them?

You can take a look at the standard variables list to see what all is available for you to use. There are a few different things you could do.
You could save everything into your local database first, complete with all notes or anything you'd want to reference. Then you can pass that "invoice ID" into the invoice parameter of your form, and you would always be able to relate back and pull that data from your own system.
You could also just use the "custom" parameter to pass anything you want up to 255 characters.
I'd browse through that list, though, as there could be lots of different things you decide you'd like to use.

Related

Paypal: How does xclick-auto-billing work?

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
<input type="hidden" name="business" value="dummy#example.com">
<input type="hidden" name="cmd" value="_xclick-auto-billing" /> <!-- _xclick-subscriptions works here -->
<input type="hidden" name="a3" value="1" />
<input type="hidden" name="p3" value="12" />
<input type="hidden" name="t3" value="M" />
<input type="hidden" name="src" value="1" />
<input type="hidden" name="no_note" value="1" />
<input type="submit" name="submit" />
<input type="hidden" value="PP-SubscriptionsBF" name="bn">
</form>
I was trying to find out what the differences are between _xclick-subscriptions and _xclick-auto-billing. Above form works when the cmd value is _xclick-subscriptions. However, when I replace it with _xclick-auto-billing, Paypal returns an error page saying "item amount" is incorrect. I check Paypal's documentation but there isn't much explanation or example about _xclick-auto-billing. So how should I use this cmd and what are the differences?
In general, auto-billing should not be used unless you are able to generate a sample auto billing button via https://www.paypal.com/buttons
When doing so, uncheck the option in section 2 to save the button at PayPal. When viewing the generated code, click the option to remove the code protection. Then you will have sample working HTML that you can adapt to your needs.
If you cannot create such a button, it is because your account does not support it. Subscriptions are much more widely supported and should be used instead, generally speaking.
Instead of the old-style Subscribe button, consider the new Smart Payment Buttons which use plans and products as a base and offer a much more modern checkout experience. See https://www.paypal.com/billing/plans

Business integration does not work

being a PP developer newbie, I used the PayPal documentation to set up this Business Starter integration:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="upload" value="1" />
<input type="hidden" name="business" value="info#mybusiness.com" />
<input type="hidden" name="item_name_1" value="My product 1" />
<input type="hidden" name="amount_1" value="10" />
<input type="hidden" name="quantity_1" value="2" />
<input type="hidden" name="display" value="1" />
<input type="hidden" name="return" value="http://www.mybusiness.com/cgi-bin/gk.cgi?ppstatus=ppy" />
<input type="hidden" name="cancel_return" value="http://www.mybusiness.com//cgi-bin/gk.cgi?ppstatus=ppn" />
<input type="hidden" name="cbt" value="Back to MyBusiness" />
<input type="hidden" name="currency_code" value="EUR" />
<input type="hidden" name="custom" value="MyID" />
<input name="submit" type="image" id="submit" src="../pics/b-pp_01.gif" width="200" height="30" border="0">
</form>
All I get after sending this form away is a blank page with the URL https://www.paypal.com/cgi-bin/webscr
Where did I go wrong?
Thanks for any help,
Emil
There are a few issues with your button (e.g. you don't specify a total amount; I don't think you are doing what you think you are doing with the custom field; etc.) but to start with: you are giving PayPal two different commands (cmd=_cart, cmd=_s_xclick), and likely neither of them is what you want. _cart is for using the PayPal cart, which is a little-used PayPal product where the cart is maintained by PayPal, not on your site. And _s-xclick is for secure, ie encrypted buttons, which you are not doing (your cart fields being plaintext in the form html).
Here's one overview of the button docs:
https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/
... that I hope can help, but ultimately get the reference guide for the particular product you are trying to use, specify only that cmd, and use only the field supported by that product. I also recommend using one of PayPal's (non-javascript) button generators to generate your first few buttons, thus guaranteeing that you are getting valid button html, and then modifying from there rather than trying to write from scratch. Helps get you on the right path.

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.

Paypal - a payment process to elucidate

I have just began working on a project processing paypal payment on a web site, which does not work fine in the sense that the email notification is sent if and only if the user goes back to the site. The fact is that I didn't code it and I even don't know what kind of api it uses. I read the doc which is quite obscure to me (It understood there is a token needs to be sent from the site by get request method but I am really not sure). I understand from the code that, in the following, the op=dodons uri is used to mange the response of paypal and to send an email notification to the user. Here is the only thing I can tell you about the page from which I want to fetch up how the payment is processed :
<form action="{$payPalURL}" method="post" class="payPalForm" id="frmpp">
<input type="hidden" name="cmd" value="_donations" id="typedon"/>
<input type="hidden" name="item_name" value="Donation" />
<input type="hidden" name="business" value="{$myPayPalEmail}" />
<input type="hidden" name="notify_url" value="{$url}/index.php?op=dodons&donation=1&tid={$randomID}&payment=1" />
<input type="hidden" name="return" value="{$url}index.php?page=campaign&op=dodons&campaign_id={$campaign->getId()}&don=ok" />
<input type="hidden" name="rm" value="2" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="cbt" value="Continue" />
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="lc" value="US" />
<input type="hidden" name="currency_code" value="EUR" />
<input type="hidden" name="txn_id" value="{$randomID}" />
<input type="hidden" name="tid" value="{$randomID}" />
{if $logged_user != null}
<input type="hidden" name="a_id" value="{$logged_user->getId()}" />
</form>
It looks like you're using Payments Standard in combination with Payment Data Transfer (PDT).
PDT only works if the user makes it back to the site which is never guaranteed, even with Auto-Return enabled.
Instead, use Instant Payment Notification (IPN). This is a simple POST of all transaction data to a listener script on your server, and this happens regardless of whether or not the user makes it back to your site or not. It's completely separate from the checkout flow.

Simplest way to confirm payment via PayPal?

what's the best way to simply get feedback from PayPal to confirm that your customer paid? It looks as if the answer is IPN - if so, my followup question is, can I enable IPN for only specific buttons? I don't want PayPal pinging my IPN listener for purchases that don't require any kind of IPN integration.
I'm all about Agile and YAGNI, and therefore I don't want to do anything that is unnecessary.
You should read the IPN Documentation that have provided by PayPal. To use IPN, the simple way is to have invoice id for a transaction that you want to track. In the IPN listener page, you will get ipn_data and one of the field is the invoice. Using this id, you should get the data from your own transaction database, then change the status to reflect the payment status in PayPal.
In my code, usually I set status to unpaid, direct the user to paypal to do payment, and in IPN listener I will set the status to paid.
PayPal provide sample code so you can start right away. You can also see other PayPal documentation in this page.
You can easily include which IPN listener to use for in a button's parameters.
If you don't have a default location set on PayPal's website, then your IPN listener will only get pinged for those buttons that do have one set.
The PayPal form variable in question is "notify_url".
Here's an example subscription button, same variable for anything else though.
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="image" src="https://www.paypal.com/en_GB/i/btn/x-click-butcc-subscribe.gif"
border="0" name="submit" alt="PayPal - The safer, easier way to pay online."
onclick="_gaq.push(['_trackEvent', 'Click', 'PayPalMonthSub', 'SubscribePage']);" />
<img alt="" border="0" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" width="1"
height="1" />
<input type="hidden" name="cmd" value="_xclick-subscriptions" />
<input type="hidden" name="business" value="paypal#yourdomain.com" />
<input type="hidden" name="item_name" value=" Monthly Subscription" />
<input type="hidden" name="item_number" value="1" />
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="currency_code" value="GBP" />
<input type="hidden" name="lc" value="GB" />
<input type="hidden" name="bn" value="PP-SubscriptionsBF" />
<input type="hidden" name="a3" value="4.99" />
<input type="hidden" name="p3" value="1" />
<input type="hidden" name="t3" value="M" />
<input type="hidden" name="src" value="1" />
<input type="hidden" name="sra" value="1" />
<input type="hidden" name="return" value="http://yourdomain.com/subscribe/thanks.aspx" />
<input type="hidden" name="rm" value="2" />
<input type="hidden" name="cancel_return" value="http://yourdomain.com/subscribe" />
<input type="hidden" name="notify_url" value="/http://yourdomain.com/IPN.aspx" />
</form>
If you need the default notification url set on your account then you will only be able to stop your handler being pinged by including a different handler in buttons that don't need it. If PayPal doesn't get an HTTP200 from a handler though it will keep trying it so I wouldn't advise setting anything to a non existent URI.