How to integrate paypal on website - paypal

I have a paypal account but are completely new of how to set up a paypal solution on my website. I develop on my computer so the website is not up on the internet yet.
I will sell digital goods which are textfiles and ebooks.
I try to use the wizard: https://devtools-paypal.com/integrationwizard
So in step 2, this creates a button which I placed on my website including putting "paypalfunctions.php", "orderconfirm.php", "checkout.php", "cancel.php" in the rootdirectory of the website.
In the .php file, I have changed those to the ones in the sandbox:
$API_UserName="xxxxxx_api1.hotmail.com";
$API_Password="xxxxxxpassword";
$API_Signature="xxxxxxxxxxxxxxxxxxxxxxp.yxxxxxxxxx";
I have created a sandbox account here: https://developer.paypal.com/developer/applications
When I click the paypal button on my website. It opens up a small window which has the same content as my actual page on the website where I clicked the paypal button. I don't understand what is happening here.
Shouldn't paypal payment processing be opened in that window?
I don't know what I am missing to start to set this up correctly?
I don't really know where to begin?
Thank you

Stop trying to make it so difficult. Use my example below, it is extremely simple. This will give you an idea on how things work. Go from there.
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="item_name" value="ITERMNAME HERE">
<input type="hidden" name="business" value="PAYPAL-EMAIL-ACCOUNT-HERE">
<input type="hidden" name="cn" value="CUSTOM FIELD HERE IF YOU WISH">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynow_LG.gif:NonHosted">
<input type="submit" name="submit">SUBMIT</input>

If your file that contains the button does not reside in the same directory as the php files you setup your form will fail and probably render whatever your server used as a default.
<form action='expresscheckout.php' METHOD='POST'>
In this case it expects expresscheckout.php to reside in the same folder. You may need to adjust this, such as /expresscheckout.php or similar.

Related

PayPal: skip trial period

I have created a hosted PayPal button for monthly subscription and included its code on my website.
The subscription offers a free trial period of 1 week.
I would like to check if the user has already used their trial and is trying to subscribe again. And if so, how do I let PayPal know that it should not allow a trial period for that user?
The button's code looks something like this:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="ABCDEFGHIJKLM">
<input type="hidden" name="on0" value="Your email">
<label for="plan-email">Your email</label>
<input id="plan-email" type="email" name="os0" placeholder="joanne.doe#gmail.com" required maxlength="200">
<button type="submit">Subscribe</button>
</form>
It would be even better, if you know a way to use Subscription Plan (created in https://www.paypal.com/billing/plans) as an HTML form similar to the one above (pure HTML form, without using PayPal JavaScript SDK) instead of a Button (created in https://www.paypal.com/buttons/). I need to pass an extra option (user's email) to PayPal as well as whether to allow a trial period or not.

Why would paypal notification URL different

Okay, so we have a member site using Joomla, and a component that allows users to perform certain tasks (creating teams). They are allowed to login, and create a team, but they can't add members to this team until they pay a $25.00 fee.
This happens through Paypal IPN. There is essentially this form below... (some personal data removed).
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="item_name" value="<?php echo $item_name;?>">
<input type="hidden" name="business" value="blah#blah.com">
<input type="hidden" name="amount" value="25">
<input type="hidden" name="quantity" value="1">
<input type="hidden" name="no_note" value="1">
<!--<input name="userId" value="<?php //echo $user->id;?>" type="hidden">-->
<!--<input name="task" value="paypal_register" type="hidden">-->
<input type="hidden" name="currency_code" value="USD">
<!-- Enable override of buyers's address stored with PayPal . -->
<!-- Set variables that override the address stored with PayPal. -->
<input type="hidden" name="return" value="<?php echo JURI::ROOT().'index.php?option=com_fastball&view=payment&task=paypal_register';?>">
<input type="hidden" name="notify_url" value="<?php echo JURI::ROOT().'index.php?option=com_fastball&view=payment&task=paypal_register&userId='.$user->id.'&ipn=1';?>">
<!--<input type="image" name="submit" border="0" src="https://www.paypal.com/en_US/i/btn/btn_buynow_LG.gif" alt="PayPal - The safer, easier way to pay online">-->
</form>
Now sometimes the IPN redirects and works just fine. But other times it cuts the url short from "index.php?option=com_fastball&view=payment&task=paypal_register&userId=" to "index.php?option=com_fastball", therefore not activating the view in Joomla that contains the code to update the database on notification.
It seems fairly random. There are several scenarios, 1 - New User Creating New Team. 2 - Old User Creating New Team. 3- Old User Renewing Old Team.
But regardless of that, they ALL hit this payment form button with THESE notify URL as hidden input.
So I'm not sure where paypal is either A.) Getting the shortened URL, or B.) They are cutting it short for some reason. It returns to the shortened URL with all of the Paypal Post info showing in the URL Parameters (&st=Completed&amt=25.00 etc from paypals servers)
This has been extremely frustrating and I may not have explained it well so if you have any questions or thoughts, just let me know. Thanks!
For URL paths you should use JURI::base() not JURI::ROOT. You can check the documentation here https://docs.joomla.org/Constants.
This appears to be a recent PayPal problem. All the urls (return, cancel_return, and notify_url) PayPal is stripping the url of all content after the first '&'.
Note also that the issue appears to be intermittent; it may be dependent on the PayPal server you connect to (QueryString values removed from the IPN endpoint by PayPal).
I have made some modifications to my own PayPal form replacing just the '&' with '&' (the encoded version) and that seems to work.

PayPal Donate button that accepts subscriptions

I'm hoping there's an accepted method for this, as I seem to be able to get it to kind of work.
I have a donate form that has an optional 'One-off/Every month' select box.
Ideally the user should be able to either donate a one-off amount, or create a donation subscription.
The issue I'm facing is that there's a subscription button, and there is a donate button, but no donate subscription button.
So the code I've cobbled together so far almost works:
<form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_donations" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="a3" value="5.00" />
<input type="hidden" name="p3" value="24" />
<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="bn" value="PP-DonationsBF:btn_donateCC_LG.gif:NonHostedGuest" />
<input type="hidden" name="business" value="X" />
<input type="hidden" name="currency_code" value="GBP" />
<input type="hidden" name="no_note" value="0" />
<input type="hidden" name="return" value="X" />
<input type="hidden" name="item_name" value="X" />
<input type="submit" name="submit" value="Donate now" />
</form>
(X replacing sensitive values)
So this will pass the user to a page that at least looks kind of right:
It's a donation form, with a subscription checkbox - almost there!
However you'll notice that the amount isn't present, and the recurring box isn't ticked.
If I include the amount attribute with the form then none of the subscription bits show up, and it reverts to a standard donation page.
Is what I'm trying to do actually possible? I mean it really should be, but the only content on the PayPal site that refers to it (via a Google search) takes me to a 404 page, so who knows: https://www.paypal.com/webapps/mpp/get-started/create-recurring-donation-button
(It's also not on the WayBack machine, unfortunately)
The description text on Google looks promising… so I'll keep my fingers crossed that somebody knows what used to be on that page…
Edit: The above link appears to be functioning correctly now. Must be due to some weird territory/permissions bug, as yesterday while logged in it was just a 'Sorry this page does not exist' page; logging out seems to have granted me access to PayPal's knowledge.
However the content is a tad ambiguous (maybe):
The instructions below will show you how to create a recurring donation button by creating a Subscription button, then changing some of the HTML … to make it appear as a Donate button.
I'm not sure I really see any advantage to this - are they saying this process will create a subscription button that just looks like a donation button? Not sure what the purpose of that would be…
After speaking with PayPal this morning on the phone I can confirm that #geewiz and the common advice is definitely the way to go. i.e. just use a standard subscription.
The piece of the puzzle I was missing (partially due to this being work for a client) is that the fee's applied are based on the account, not the payment type. i.e. a 'donation' through paypal is no different than any other payment, it's just a different button (and a slightly modified form at the other end).
If you're registered as a charity etc. then a standard subscription is sufficient, and the walkthrough provided by PayPal in my OP is the best resource for that. Just be warned that you might see a 'Sorry, that page doesn't exist' message when visiting the link. Logging out of PayPal worked for me.

Paypal - Dynamic Buy button to charge our clients customer

I need to implement a method where we can allow a clients customer to make a payment to the client via our website - all of which will be setup via our custom CMS.
Our initial plan was to use the following form script to generate a transaction and ask the client to add a return address to our website.
<form name="_xclick" action="https://www.paypal.com/uk/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="someone#someon.com">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="item_name" value="2 x sessions">
<input type="hidden" name="amount" value="50">
<input type="image" class="btn btn-default nom paypalBtn" src="" border="0" name="submit" alt="£50">
</form>
This would potentially work fine - as we could dynamically add the value, business email and item name. Though we are worried that any web savvy person could simply inspect the form in a browser and change the payment value to a more pleasing figure! So we feel we need a better solution.
Does anyone have any suggestions for a cleaner solution?
Log into your PayPal account, click on Merchant Services at the top of the page and then click one Create Payment Buttons for your website. When you create buttons on PayPal they are hosted and secure.

Paypal Buy Now button transaction response issue

I am using the following code to generate a "Buy Now" button for selling a single item.
It takes me to PayPal using the sandbox and does the payment but after I return nothing is received in the response (there is no extra parameter in the URL I get).
<form name="_xclick" action="https://www.sandbox.paypal.com/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="steve.johntestemail#gmail.com">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="item_name" value="Book_1">
<input type="hidden" name="amount" value="0.09">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="return" value="http://www.thequeenoflean.com.au">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHostedGuest">
<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!">
</form>
Will I get the data in get or post?
Actually I want to retrieve the email of the buyer and some other information as well.
Can anyone guide me what my mistake is here?
Thanks in advance.
i tried sandbox, live Paypal payment scenario but it was not working,
i tried so many tutorials but the steps mentioned in those tutorials were not working,
finally i got the reason:
i was trying to use Paypal from asian country where it is not supported and works abnormally,and that's why i was not getting response in return. if you use any other VPN with for example(american, Australian etc.. ips where it is supported) it will work fine and return you response accurately.
Thanks,
I know a reason why you're not getting any information.
take a look here: https://stackoverflow.com/a/11404356/279147
you see I have a notify_url parameter in my form, this is a url which will be called by paypal when the payment has been completed, whether it succeeds or fails.
the url is not opened by the browser, popups, etc, it's a "back channel" call to your server to just send data, there is no interaction with the client, so don't put any html, or return anything, it's just a "dead drop" url to dump data, if you put something like
<?php trigger_error(print_r($_POST,true)); ?>
in your code, your error log might show up some information, so then you know you are receiving information,
you're missing that, so you never get any information, unless the user clicks on the return to website button and in my experience that never happens. they just close the browser.
so take a look at my url, add the parameter and then try to do it again.