Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6
This is the forum to discuss the Wrox book ASP.NET 2.0 Instant Results by Imar Spaanjaars, Paul Wilton, Shawn Livermore; ISBN: 9780471749516
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 23rd, 2009, 10:10 AM
Registered User
 
Join Date: Jan 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Web Shop

Thanks for your brilliant book it's saved me hours of development work!

My question is to do with integrating with paypal. I was furnished with the following code
to use in my integration. This only sends up one amount. Does this mean I can only send the total amount up to paypal not the individual items in the shopping Cart?
Code:
ProtectedSub btnFinalize_Click(ByVal sender AsObject, ByVal e As System.EventArgs) Handles btnFinalize.Click
If Profile.ProfileCompleted = TrueThen
Try
Dim orderAmount AsDecimal = ShopManager.ShoppingCart.Total
Dim theCustomer As Customer = _
New Customer(CType(Membership.GetUser().ProviderUserKey, Guid), _
Profile.FirstName, Profile.LastName, Profile.Address.Street, _
Profile.Address.ZipCode, Profile.Address.City, Profile.Address.Country)
Dim orderId AsInteger = ShopManager.FinalizeOrder(theCustomer)
Dim redirect AsString = ""
redirect += "https://www.sandbox.paypal.com/xclick/[email protected]"
'redirect += "https://www.paypal.com/xclick/[email protected]"
redirect += "&item_name=t-shirt"
redirect += "&item_number=123"
redirect += "&amount=0.01"
redirect += "&currency=USD"
redirect += "&return=http://www.titchytwobar.co.uk/thankyou.aspx"
redirect += "&cancel_return=http://www.titchytwobar.co.uk/cancel.aspx"
' Redirect to the payment page
Response.Redirect(redirect)
'Response.Redirect("ThankYou.aspx?OrderNumber=" & _
'orderId.ToString() & "&Total=" & orderAmount.ToString("c"))
Catch ex As Exception
lblFailure.Visible = True
btnFinalize.Visible = False
EndTry
Else
Response.Redirect("~/UserDetails.aspx")

 
EndIf
EndSub
 
Old January 24th, 2009, 04:41 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
This only sends up one amount. Does this mean I can only send the total amount up to paypal not the individual items in the shopping Cart?
Yes, that's the case. If you think about it a bit, it does make sense.

PayPal is a *payment* system, not an *ordering* system. When people pay your bills by bank or cheque, you only receive the total amount and an order reference number. It's up to you to link the order / transfer number back to your own system so you can what order it belongs to.

The same is true with PayPal: the only thing PayPal is interested in is the total amount for the entire order. PayPal asks the visitor to transfer the entire amount and when it succeeds they add it your balance and update you on the status. They are not interested in (nor do they need to have) the individual parts of the order.

It's up to you to link a PayPal confirmation back to an order with its individual parts in your own system.

Hope this clarifies things a bit...

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old January 24th, 2009, 06:10 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

One thing I'd like to point out: You don't *HAVE* to use Response.Redirect to go to PayPal. You could, instead, use a POPUP window and use TARGET= to bring up PayPal in the popup. In the meantime, in the background, you can leave the full shopping cart order visible, with the total, so the user can correlate the PayPal amount with the cart. Then, when PayPal reloads the popup with either your cancel or return page, you can have those pages use JavaScript to update the main window and then close the popup.

I haven't tried it, but you might even be able to get PayPal to show in an <IFRAME> on your main page, to avoid the popup.

Anyway, the point is that you *can* make the whole thing a lot "friendlier" than the default mechanism that you have been given. What you have works fine, but it can be improved.
 
Old January 26th, 2009, 05:24 AM
Registered User
 
Join Date: Jan 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Web Shop

Thanks for both your prompt replies, that makes sense. I will try out your suggestion for a pop up window.

Cheers!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 8, shop Beowulf BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9 3 September 30th, 2010 03:59 PM
Chapter 9 WebShop / Shop Default Page ASPLee BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 10 March 11th, 2007 03:40 AM
atlas and web shop gtjr92 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 1 October 21st, 2006 03:38 AM
Building an E-Shop Varg_88 Beginning PHP 0 March 15th, 2006 05:25 AM
WroxUnited Shop datae33 BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 March 4th, 2006 06:37 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.