Click here to Skip to main content
15,914,010 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to create a "Send To" menu class using C# ? Pin
Christian Graus4-Aug-05 17:13
protectorChristian Graus4-Aug-05 17:13 
AnswerRe: How to create a "Send To" menu class using C# ? Pin
lin11614-Aug-05 20:49
lin11614-Aug-05 20:49 
GeneralRe: How to create a "Send To" menu class using C# ? Pin
mav.northwind4-Aug-05 23:42
mav.northwind4-Aug-05 23:42 
GeneralRe: How to create a "Send To" menu class using C# ? Pin
lin11615-Aug-05 15:39
lin11615-Aug-05 15:39 
GeneralHTTP POST & HTTP GET Pin
Mridang Agarwalla3-Aug-05 19:09
Mridang Agarwalla3-Aug-05 19:09 
GeneralRe: HTTP POST & HTTP GET Pin
Mohamad Al Husseiny3-Aug-05 19:13
Mohamad Al Husseiny3-Aug-05 19:13 
GeneralForm can't handle KeyDown event! Pin
levgiang3-Aug-05 18:11
levgiang3-Aug-05 18:11 
GeneralRe: Form can't handle KeyDown event! Pin
Christian Graus3-Aug-05 18:20
protectorChristian Graus3-Aug-05 18:20 
GeneralRe: Form can't handle KeyDown event! Pin
Mohamad Al Husseiny3-Aug-05 18:36
Mohamad Al Husseiny3-Aug-05 18:36 
GeneralRe: Form can't handle KeyDown event! Pin
levgiang3-Aug-05 19:07
levgiang3-Aug-05 19:07 
GeneralRe: Form can't handle KeyDown event! Pin
Christian Graus3-Aug-05 19:27
protectorChristian Graus3-Aug-05 19:27 
GeneralRe: Form can't handle KeyDown event! Pin
Anonymous5-Aug-05 18:53
Anonymous5-Aug-05 18:53 
GeneralRe: Form can't handle KeyDown event! Pin
Christian Graus7-Aug-05 13:30
protectorChristian Graus7-Aug-05 13:30 
GeneralWindows forms... Pin
lovelylooney3-Aug-05 17:33
lovelylooney3-Aug-05 17:33 
GeneralRe: Windows forms... Pin
Christian Graus3-Aug-05 17:56
protectorChristian Graus3-Aug-05 17:56 
GeneralRe: Windows forms... Pin
lovelylooney3-Aug-05 18:24
lovelylooney3-Aug-05 18:24 
GeneralRe: Windows forms... Pin
Mohamad Al Husseiny3-Aug-05 18:52
Mohamad Al Husseiny3-Aug-05 18:52 
GeneralRe: Windows forms... Pin
lovelylooney3-Aug-05 19:24
lovelylooney3-Aug-05 19:24 
GeneralError in .Net after adding PayPal webservice - please help!! Pin
nzmike3-Aug-05 17:11
nzmike3-Aug-05 17:11 
GeneralRe: Error in .Net after adding PayPal webservice - please help!! Pin
Christian Graus3-Aug-05 17:24
protectorChristian Graus3-Aug-05 17:24 
GeneralRe: Error in .Net after adding PayPal webservice - please help!! Pin
nzmike3-Aug-05 17:45
nzmike3-Aug-05 17:45 
GeneralRe: Error in .Net after adding PayPal webservice - please help!! Pin
Christian Graus3-Aug-05 17:54
protectorChristian Graus3-Aug-05 17:54 
GeneralRe: Error in .Net after adding PayPal webservice - please help!! Pin
nzmike3-Aug-05 18:09
nzmike3-Aug-05 18:09 
GeneralRe: Error in .Net after adding PayPal webservice - please help!! Pin
Christian Graus3-Aug-05 18:19
protectorChristian Graus3-Aug-05 18:19 
GeneralRe: Error in .Net after adding PayPal webservice - please help!! Pin
nzmike3-Aug-05 19:06
nzmike3-Aug-05 19:06 
'"PayPalAPIInterfaceService" description' is what the WSDL screen shows when you type the reference to the PayPal web services (http://www.paypal.com/wsdl/PayPalSvc.wsdl) and hit "go". It says "1 service found - PayPalSvc" and the name is com.paypal.www. I rename that to PayPalSvc and click "Add Reference". The code below in my wrapper class then tries to access PayPalAPIInterfaceService. (I've marked the error lines with "//GETS ERROR HERE".... that's where the compiler says it can't find PayPalAPIInterfaceService.)

If you want I could zip up the project and email it to you or make it downlaodable from my server... it might be easier to see waht's going on - let me know if that would help.

Thanks again,

Mike

------------ APIWrapper.cs --------------------

using System;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using PayPalAPI.PayPalSvc;
using PayPalAPI;
using System.Data;
using System.Collections;
using System.Security;

namespace PayPalAPI
{

///
/// Summary description for APIWrapper.
///

public class APIWrapper
{

string _APIUserName="";
string _APIPassword="";
string _CertLocation="";
string _APIUrl="";

public string APIUserName
{
get{return _APIUserName;}
}

public string APIPassword
{
get{return _APIPassword;}
}

public string CertLocation
{
get{return _CertLocation;}
}

public string APIUrl
{
get{return _APIUrl;}
}

PayPalAPIInterfaceService service; //GETS ERROR HERE

public APIWrapper(String APIUserName, string APIPassword, string CertLocation, string APIUrl)
{

_APIUserName=APIUserName;
_APIPassword=APIPassword;
_CertLocation=CertLocation;
_APIUrl=APIUrl;

// Add the CertificatePolicy so we can post to an untrusted site
ServicePointManager.CertificatePolicy = new MyCertificateValidation( );

service = new PayPalAPIInterfaceService( ); //GETS ERROR HERE
service.Url = _APIUrl;

// Add the X509 Cert to the service for authentication
X509Certificate certificate = X509Certificate.CreateFromCertFile(_CertLocation);
service.ClientCertificates.Add(certificate);
SetHeaderCredentials(service);

}

void SetHeaderCredentials(PayPalAPIInterfaceService service)
{

CustomSecurityHeaderType securityHeader = new CustomSecurityHeaderType( );
UserIdPasswordType userIdPassword = new UserIdPasswordType( );
userIdPassword.Username = _APIUserName;
userIdPassword.Password = _APIPassword;
//userIdPassword.Subject = subject;
securityHeader.Credentials = userIdPassword;
securityHeader.MustUnderstand = true;
service.RequesterCredentials = securityHeader;

}

string GetAmountValue(BasicAmountType amount)
{

string sOut="";

try
{
sOut="$"+amount.Value.ToString( );
amount.currencyID = CurrencyCodeType.USD;
}
catch
{
sOut="--";
}
return sOut;

}
}

class MyCertificateValidation : ICertificatePolicy
{
// Default policy for certificate validation.
public static bool DefaultValidate = false;

public bool CheckValidationResult(ServicePoint sp, X509Certificate cert, WebRequest request, int problem)
{
//implement your custom code here
return true;
}
}

}

------------ APIWrapper.cs --------------------

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.