Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Professionals
|
ASP.NET 3.5 Professionals If you are an experienced ASP.NET programmer, this is the forum for your 3.5 questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Professionals 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 30th, 2009, 09:06 PM
Friend of Wrox
 
Join Date: Sep 2007
Posts: 169
Thanks: 7
Thanked 2 Times in 2 Posts
Default

Quote:
Originally Posted by dparsons View Post
You will want to look in to how to deny users access to directories. This should help you:

http://www.google.com/search?hl=en&r...ion+deny+users

-Doug
I can deny them through the asp.net membership site. I just don't know how to allow only users who paid to the create user name section. Like I can just deny all users to the create user page but how do I allow those ppl who made a payment get to that section?
 
Old January 30th, 2009, 09:16 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Your business logic should work like this:

Create.aspx:
1. User provides a username, password, and any other demographic infor
2. User provides payment information.
3. Submit Form to Payment Gateway

Payment Gateway
1. Payment is processed
If Ok
Goto Members.aspx
else
Return to Create.aspx with error message

---------Pages from here on out should be restricted via Membership---------------
Members.aspx
1. Do whatever


You shouldn't make a user first pay you THEN ask them to create login credentials. You should wrap this up in one step, IMHO.

hth.
-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
 
Old February 4th, 2009, 06:25 PM
Friend of Wrox
 
Join Date: Sep 2007
Posts: 169
Thanks: 7
Thanked 2 Times in 2 Posts
Default

Hi

After playing around with the open source stuff I found them over the top and very hard to customize.

I am now trying to make my own. I want to make the payapl express system. On the paypal site I see they got some wizard that generates the paypal express for you but I really don't want to use it.

I looked that the 3 sample files for the express.

ECDoExpressCheckout
ECGetExpressCheckout
ECSetExpressCheckout

and they make sense to me for the most part. So I want to use the paypal api and these files and make basically the payapl express this way.

I however don't know how to hook everything up though. Like how do I get the ball rolling.

So how do I make it so the user clicks on the express button it starts the process of going to paypal(I believe this is the set) then grabbing the info(get) and then sumbiting the final order(do).

Do you have any tutorials that show how I would connect all this stuff or could you quickly right something up. Like as far I see the sample code basically does all the stuff for you its just a matter of calling it. After I guess I can just build upon this sample code if needed but right now I want to just get it run.

I am using NVP not Soap.

I think I probably need some form to do a post? but I am not quite sure.
 
Old February 4th, 2009, 07:54 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Have you been here yet:

https://developer.paypal.com/

If not, register for account and login. I think you will find that there documentation is spot on and will help you a great deal.

Let me know if you need anything!

-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
 
Old February 4th, 2009, 08:10 PM
Friend of Wrox
 
Join Date: Sep 2007
Posts: 169
Thanks: 7
Thanked 2 Times in 2 Posts
Default

Quote:
Originally Posted by dparsons View Post
Have you been here yet:

https://developer.paypal.com/

If not, register for account and login. I think you will find that there documentation is spot on and will help you a great deal.

Let me know if you need anything!

-Doug
Yep, I been there and looked over that's how I found the 3 sample files. It just does not have anything on how to link them up using asp.net and thats my problem and once I get it all linked up and see how it all interacts then it probably very similar for anything else I need to add.
 
Old February 4th, 2009, 08:22 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

They should have a document on there about what fields they require.

Essentially you will have a form that looks like this on your page:

<form action="<paypal server>" method="post">
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="upload" value="1" />
<input type="hidden" name="business" value="YourPayPalAccount" />
//more fields
</form>

This will post the data to PayPal for processing. Again there should be a document that you can download that will outline all of the fields necessary as this is only some of them.

hth.
-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
 
Old February 4th, 2009, 08:28 PM
Friend of Wrox
 
Join Date: Sep 2007
Posts: 169
Thanks: 7
Thanked 2 Times in 2 Posts
Default

Quote:
Originally Posted by dparsons View Post
They should have a document on there about what fields they require.

Essentially you will have a form that looks like this on your page:

<form action="<paypal server>" method="post">
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="upload" value="1" />
<input type="hidden" name="business" value="YourPayPalAccount" />
//more fields
</form>

This will post the data to PayPal for processing. Again there should be a document that you can download that will outline all of the fields necessary as this is only some of them.

hth.
-Doug
ok I will look around.

Thanks


What would this stuff be called?

I found in this pdf: https://cms.paypal.com/cms_content/U...loperGuide.pdf

in chapter 4(express api pg 39) alot of parameters but not if they belong to the field or not.

Last edited by chobo2; February 4th, 2009 at 08:33 PM..
 
Old February 5th, 2009, 11:08 PM
Friend of Wrox
 
Join Date: Sep 2007
Posts: 169
Thanks: 7
Thanked 2 Times in 2 Posts
Default

Ok

I been playing around with the sample code files that where given and have gotten somewhere but not sure about a couple things.

I have this

expresscheckout.aspx
Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="expresscheckout.aspx.cs"
    Inherits="PayPalEC" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>

  <form action='expresscheckout.aspx' method='post' runat="server">

    <asp:ImageButton ID="ImageButton1" runat="server" 
        src='https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif' 
        onclick="ImageButton1_Click" />

  
    </form>
</body>
</html>
codebehind

Code:
using System;
using System.Web;
using GenerateCodeNVP;
using System.Net;
using System.IO;

public partial class PayPalEC : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
       
    }
    protected void ImageButton1_Click(object sender, System.Web.UI.ImageClickEventArgs e)
    {
        ECSetExpressCheckout setCheckout = new ECSetExpressCheckout();
        string result = setCheckout.ECSetExpressCheckoutCode("http://localhost:3300/return.aspx", "http://localhost:3300/cancel.aspx", "20", "Sale", "USD");
        Response.Redirect("https://www.sandbox.paypal.com/cgi-bin/webscr&cmd=_express-checkout&token=" + result + "&AMT=20&CURRENCYCODE=USD&RETURNURL=http://localhost:3300/return.aspx&CANCELURL=http://localhost:3300/cancel.aspx");

    }
}
So right now I am just had coded alot of the stuff. but my first question is with the one of their sample files

ECSetExpressCheckout.cs
Code:
/*
 * Copyright 2005, 2008 PayPal, Inc. All Rights Reserved.
 *
 * SetExpressCheckout NVP example; last modified 08MAY23. 
 *
 * Initiate an Express Checkout transaction.  
 */
using System;
using com.paypal.sdk.services;
using com.paypal.sdk.profiles;
using com.paypal.sdk.util;
/**
 * PayPal .NET SDK sample code
 */
namespace GenerateCodeNVP
{
    public class ECSetExpressCheckout
    {
        public ECSetExpressCheckout()
        {
        }
        public string ECSetExpressCheckoutCode(string returnURL,string cancelURL,string amount,string paymentType,string currencyCode)
        {
            NVPCallerServices caller = new NVPCallerServices();
            IAPIProfile profile = ProfileFactory.createSignatureAPIProfile();
            /*
             WARNING: Do not embed plaintext credentials in your application code.
             Doing so is insecure and against best practices.
             Your API credentials must be handled securely. Please consider
             encrypting them for use in any production environment, and ensure
             that only authorized individuals may view or modify them.
             */

            // Set up your API credentials, PayPal end point, API operation and version.
            profile.APIUsername = "name";
            profile.APIPassword = "pass";
            profile.APISignature = "sig";
            profile.Environment="sandbox";
            caller.APIProfile = profile;

            NVPCodec encoder = new NVPCodec();
            encoder["VERSION"] =  "51.0";    
            encoder["METHOD"] =  "SetExpressCheckout";

            // Add request-specific fields to the request.
            encoder["RETURNURL"] =  returnURL;
            encoder["CANCELURL"] =  cancelURL;    
            encoder["AMT"] =  amount;
            encoder["PAYMENTACTION"] =  paymentType;
            encoder["CURRENCYCODE"] =  currencyCode;    

            // Execute the API operation and obtain the response.
            string pStrrequestforNvp= encoder.Encode();
            string pStresponsenvp=caller.Call(pStrrequestforNvp);

            NVPCodec decoder = new NVPCodec();
            decoder.Decode(pStresponsenvp);

            return decoder["token"];
        //    return decoder["ACK"];
        }
    }
}
So they return decorder["ACK"] and this returns sucessful or failed. I don't' understand why it does not build the string for me? Like it has all the parts it could have easily built the required string yet I get a sucessful or failed.

I am not sure what it succeded into doing(testing to see the stuff can be transmited??).

Also how I see it I need to send with the set the token value. How do I get the token value? Like the only way I was able to get the token was returing that from the decoder if I did not do that I would have no clue how to get the token value.

When I do the response redirect I get to the paypal site. I am able to login and confirm my address(even though for mysite address does not really need an address since I won't send them anything).

I noticed though when there logged in I can see no where the price is listed on how much I sent to the site.

Like if I said the item would cost $20. I thought it would display this number to them while they where at paypal.

So then it gets returned to my return.aspx

return.aspx
Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="return.aspx.cs" Inherits="paypalTest1._return" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <h1>returned</h1>
    </div>
    </form>
</body>
</html>
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using GenerateCodeNVP;

namespace paypalTest1
{
    public partial class _return : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.HttpMethod == "GET")
            {
               char[] ampersand = { '&','='};
  
              string url = Request.RawUrl;
              string[] splitArray =  url.Split(ampersand);
              ECDoExpressCheckout doNow = new ECDoExpressCheckout();
           string test=   doNow.ECDoExpressCheckoutCode(splitArray[1], splitArray[3], "20.0", "Sale", "USD");

            }
        }
    }
}
Again I just used some hardcoded values and jsut looked at what postions the token and payerID was.

One thing I am not sure of is how do I keep track of how much there items cost? Like in my case I got 1 item and I know it is $20. I also know they only can purchase one quaity of it.

But what happens if I was sending a list of stuff from a cart. say $60 worth of stuff.

How do I keep track of the $60 when I return to another page and to finalize the transaction I must specify how much it will all cost.

How will I even know at this point what items they have bought?

So looking at the buyers account in my sandbox it takes the $20 off but I am not sure where that $20 goes. I have a sellers account setup too in my sandbox but it gets nothing. So I am guessing I am missing something still not sure what.

Does this look right what I have so far?





Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting Up A Development System For This Course ebstr BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 October 13th, 2008 09:27 AM
setting system time angelboy C# 2005 1 May 4th, 2007 08:05 PM
How to implement Online payment System virendar23 ASP.NET 1.x and 2.0 Application Design 3 October 2nd, 2006 01:12 PM
Online Payment eapsokha Classic ASP Professional 3 August 31st, 2004 12:42 AM





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