I am working on a ASP.NET + Paypal Express project,
Website only have 1 $10 product but customer can buy it in quantities (i.e 1 or 4 or 20 etc )
Its like a paypal cart but only with 1 product with quantities.
I have searched a lot but unable to find some suitable one.
Also I want to redirect my customer to a form after paying money on paypal website.
Can you just tell me the simplest method ?
Also I have few more question :-
using minicart Paypal is suitable for this?
Do I need to configure Paypal Express account & what to configure ?
Thanks a lot :)
=================================================================
Update : Use Paypal mini cart if you need simple integration
Add cart script.js before the body tag ( https://minicart.paypal-labs.com/ )
After that All you need to add this code in your html
<div class="demo container" align="center" >
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<fieldset>
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="add" value="1">
<input type="hidden" name="business" value="#gmail.com">
<input type="hidden" name="item_name" value="Buy Our Services">
<input type="hidden" name="amount" value="6.00">
<%--<input type="hidden" name="discount_amount" value="1.00">--%>
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="return" value="https://minicart.paypal-labs.com/?success">
<input type="hidden" name="cancel_return" value="https://minicart.paypal-labs.com/?cancel">
<strong>Service</strong>
<ul>
<li>Price: $6.00</li>
</ul>
<input type="submit" name="submit" value="Add to cart" class="button">
</fieldset>
</form>
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" class="last">
<fieldset>
<input type="hidden" name="business" value="#gmail.com">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="display" value="1">
<input type="submit" name="submit" value="View your cart" class="button">
</fieldset>
</form>
</div>
Change parameter accordingly & remove link to paypal instead of sandbox
You Paypal cart is ready to go.
If you want a more flexible solution then you should check this URL http://www.codeproject.com/KB/aspnet/paypal_c_aspnet.aspx
Thanks
Panky are you sure is it the right way ?
Customer come on site
Choose product/s and quantity/ies
Before do that you should store in session/database/cookies info that you need and pass to paypal only the stuff that you need with an id or other stuff which could be used to recognized customer too.
then move to pay to paypal.
Customer pay on paypal and paypal send back info about transaction
With these details you may re-create all the info that you need ans can use to complete first step back office tasks or even you may only show some message to cusotmer.
then you will wait ipn's(Instant Payment Notification) callback in order to make all tasks needed in backoffice automation.
This is the right way to do it.
Also you may able to make a good exception handling in order to prevent issue within it.
Related
Have an ASP .Net form built with C#.
Not sure what's going on here. I am sending a test transaction and setting the return URL within my Paypal account but it always redirects to the wrong URL after making a payment (So i get to paypal sandbox and make a payment using a test PP account but when it redirects it goes to the wrong URL).
Heres whats being sent to Paypal
action="https://www.sandbox.paypal.com/cgi-bin/webscr" >
<input type="hidden" name="cmd" value="_cart"/>
<input type="hidden" name="business" value="name.domain.com"/>
<input type="hidden" name="item_name_1" value="item"/>
<input type="hidden" name="amount_1" value="17.00"/>
<input type="hidden" name="quantity_1" value="1"/>
<input type="hidden" name="upload" value="1"/>
<input type="hidden" name="currency_code" value="GBP"/>
<input type="hidden" name="rm" value="2"/>
<input type="hidden" name="cancel_return" value="http://example.com/Cancel"/>
<input type="hidden" name="shopping_url" value="http://example.com/shopwithus"/>
<input type="hidden" name="notify_url" value="http://example.com/response/"/>
<input type="hidden" name="no_shipping" value="1"/>
<input type="hidden" name="lc" value="GB"/>
<input type="hidden" name="image_url" value="http://example.com/pic.gif"/>
<input type="hidden" name="no_note" value="1"/>
<input type="hidden" name="invoice" value="ab12963257"/>
I have checked the below areas once logging using my sandbox account on paypal's site
businessprofile/settings
businessprofile/mymoney
businessprofile/mysettings
businessprofile/mytools
I see the following options
Instant Payment Notification (IPN) - On
Under Current settings
Notification URL
Which ive set with the URL i would like it to go to.
Website preferences - Also set to the URL it needs to go to.
With the above actions taken it still takes me to the wrong URL. By saying wrong URL i mean an URL that i mustve set in the past somewhere.
Does anyone know where i need to look to change the return URL after a successful payment?
Our website has following one time payment buttons.
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="custom" value="#Model.UserId.ToString()">
<input type="hidden" name="notify_url" value="http://www.testweb.com/paypal/IpnHandler">
<input type="hidden" name="return" value="http://www.testweb.com/paypal/Onetimeyearlysuccess">
<input type="hidden" name="cancel_return" value="http://www.testweb.com/paypal/cancel">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="8xxxxxxC">
<input type="image" src="#Url.Content("~/images/OneTime55year.png")" border="0" name="submit" style="width: 130px !important; height: 47px !important;" alt="PayPal - The safer, easier way to pay online!" >
</form>
After done the paypal payment, we could see we are getting 404 error.
The issue is that we are getting wrong URL.
https://www.testweb.com/PaypalOnetimeyearlysuccess?amt=55.00&cc=USD&cm=22028&item_name=oneTimeAnnual55&st=Completed&tx=59M0424544743135Y
We don’t know why the slash missing after paypal.
The correct URL should be
https://www.testweb.com/Paypal/Onetimeyearlysuccess?amt=55.00&cc=USD&cm=22028&item_name=oneTimeAnnual55&st=Completed&tx=59M0424544743135Y
There needs to be slash symbol after paypal in the address URL.
You can see the correct URL from the return URL of the paypal button also.
Why it is redirecting to wrong address?
Also for testing purpose,we changed the return URL of the paypal button. We simply modified to “http://www.testweb.com/paypal/Onetimeyearlysuccesstest.”
But we could see after changed the return URL , paypal is not redirecting to modified URL.
Actually we are confused ,we need to know where the return URL is creating.
PayPal only recognize the value of 'return' variable. The key point is located at this URL (http://www.testweb.com/paypal/Onetimeyearlysuccess). You are advised to create a fixed single page without redirect function like .html, .php, .aspx, etc., to see the result.
I have a search box on my site.
The controller looks like this:
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult SearchResults(SearchModel model)
{
View:
<div class="siteSearch clearfix" role="search">
<form id="HeaderSearchForm">
#Html.AntiForgeryToken()
<label for="tbSiteSearch">Search:</label>
<input type="text" id="tbSiteSearch" name="tbSiteSearch" class="text" />
<button type="submit" class="btn submit">
<i class="icon-search"></i>
</button>
</form>
</div>
So when I do a search, I can see the hidden label with the Anti Forgery Token present. This all works as expected because if I take a blank html page, copy the form code and leave the '__RequestVerificationToken' blank, I get told that the token hasn't been set and the search doesn't run. Which is what I would expect.
The issue I have is if I submit a search, copy the token from my site and place it in to my blank html page e.g.
<html>
<body>
<script>history.pushState('', '', '/')</script>
<form action="https://www.adomainname.co.uk/Search/SearchResults/" method="POST">
<input type="hidden" name="SearchTerm" value="testing" />
<input type="hidden" name="__RequestVerificationToken" value="theverificationtokengoeshere" />
<input type="submit" value="Submit request" />
</form>
</body>
</html>
The request is submitted - even if I am running the above code on localhost. I would have expected the form to not submit as it was coming from a different domain. Am I misunderstanding how this should work?
If I refresh the page and resubmit Im obviously allocated a new AFT and so the submit fails again but this doesn't feel right.
Ideally I would prefer the form action to only run on the domain it's on and not be able to execute the action from another site. I thought using AntiForgeryToken prevent Cross-Site Request Forgery.
If any of this is unclear, please let me know and I'll explain more.
I'm trying to get my Buy Now button in PayPal Sandbox to work. However when I make a purchase using it, it does not show up on my business transaction overview. And in the personal account, it shows as "Unclaimed" and "The recipient of this payment is Unregistered". Here is the ASP.NET code I'm using for the button:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="notify_url" value="censored" />
<input type="hidden" name="item_name" value="Aktivt kontigent" />
<input type="hidden" name="item_number" value="1" />
<input type="hidden" name="amount" value="240" />
<input type="hidden" name="tax_rate" value="25" />
<input type="hidden" name="undefined_quantity" value="0" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="handling" value="5" />
<input type="hidden" name="business" value="censored" />
<asp:ImageButton ID="btnPayNow" runat="server" ImageUrl="~/images/btn_buynowCC_LG.gif" PostBackUrl="https://www.sandbox.paypal.com/cgi-bin/webscr"/>
</form>
I know I'm using the right business ID, because my Business name appears on the checkout page on PayPal. And the IPN is also working, I can see that on my server. However the transaction does not appear on seller account, and the personal account is having this weird status. Does anyone know how to fix this please?
Thank you in advance.
The problem with this was my e-mail was not veryfied. It worked after that.
it is required to integrate the paypal donation button in asp.net c# web form, on clicking the donate button an email should be sent to the receiver with capturing the details of the donor like donor name, occupation, address and donation amount etc.
Please any help from anyone will be appreciated.
thanks
First u go through with Paypal Documentaion... It is best source for to learn all the things which u require.
Paypal SDK Documentation
DOnation of paypal using Asp.Net : Custom Control
How to Use Paypal SDK.. Sample applicaiton.
Use this code for asp.net page for a simple donation button
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="myemail">
<input type="hidden" name="item_name" value="Item name">
<input type="hidden" name="item_number" value="Item ID">
<input type="hidden" name="amount" value="12.00">
<input type="hidden" name="buyer_credit_promo_code" value="">
<input type="hidden" name="buyer_credit_product_category" value="">
<input type="hidden" name="buyer_credit_shipping_method" value="">
<input type="hidden" name="buyer_credit_user_address_change" value="">
<input type="hidden" name="no_shipping" value="0">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input name="cbt" value="Click here to confirm the payment" type="hidden"/>
<input type="hidden" name="lc" value="US">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input name="CANCELURL" value='<%=errorurl %>' type="hidden"/>
<input name="return" value='<%=url %>' type="hidden"/>
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
'errorurl' and return url 'url' can be defined from codeback.
Also you can avoid unwanted parameters from the code.
You can set a custom image in the 'img' tag of the code.
Create a button of your own by using this link
https://www.paypal.com/cgi-bin/webscr?cmd=_donate-intro-outside
Resources mentioned are pretty good. To go through a live-setup example, you can visit this LINK and learn how you can achieve the same on your website.
NOTE: PayPal is integrated within a website, and doesn't offer a one-click solution like Web-API.