YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

Error invoking PayPalAPI.PayPalAPIInitialize() Options
Dominic.Burford
#1 Posted : Monday, January 30, 2012 10:13:46 AM
Rank: Starting Member

Groups: Registered

Joined: 1/30/2012
Posts: 4
Location: Kettering, United Kingdom
I have downloaded the example project AspNetSamples_Nvp and am trying to rewrite the example C# code in VB.net. However I am getting an error on the following line of code:

com.paypal.sdk.services.NVPCallerServices caller =PayPalAPI.PayPalAPIInitialize()

I am getting the following error:

System.NullReferenceException was unhandled by user code
Message="Object reference not set to an instance of an object."
Source="paypal_base"
StackTrace:
at com.paypal.sdk.core.nvp.NVPAPICaller.SetupConnection(IAPIProfile cprofile)
at com.paypal.sdk.core.APICallerBase.set_Profile(IAPIProfile value)
at com.paypal.sdk.services.NVPCallerServices.set_APIProfile(IAPIProfile value)
at ASPDotNetSamples.AspNet.PayPalAPI.PayPalAPIInitialize()


The error is being thrown by the method com.paypal.sdk.core.nvp.NVPAPICaller.SetupConnection(IAPIProfile cprofile), but I have copied the example code exactly as written so can't see what I'm doing wrong.

Any ideas would be greatly appreciated.

I conclude that there are two ways of constructing a software design: One way is to make it so simple there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies." - Tony Hoare
Sponsor  
 
Dominic.Burford
#2 Posted : Wednesday, February 01, 2012 12:34:23 PM
Rank: Starting Member

Groups: Registered

Joined: 1/30/2012
Posts: 4
Location: Kettering, United Kingdom
I've managed to resolve the problem using the .NET Reflector to see what the code was expecting internally. I have now added the following code to the start of my Paypal processing code:

Session("stage") = PAYPAL_ENVIRONMENT
SetProfile.SessionProfile = CreateDefaultProfile() ' defined below

ASPDotNetSamples.Global.is3token = True
ASPDotNetSamples.Global.isunipay = False
ASPDotNetSamples.Global.ispermission = False


' Add this function to your class
Private Function CreateDefaultProfile() As IAPIProfile
Dim profile As IAPIProfile = ProfileFactory.createSignatureAPIProfile()
profile.APIUsername = API_USERNAME
profile.APIPassword = API_PASSWORD
profile.Environment = PAYPAL_ENVIRONMENT
profile.Subject = PAYPAL_SUBJECT
profile.APISignature = API_SIGNATURE
Return profile
End Function

' These are the default values supplied by the example code, add your own values here if necessary
Private Const API_USERNAME As String = "sdk-three_api1.sdk.com"
Private Const API_PASSWORD As String = "QFZCWN5HZM8VBG7Q"
Private Const API_SIGNATURE As String = "A.d9eRKfd1yVkRrtmMfCFLTqa6M9AyodL0SJkhYztxUi8W9pCXF6.4NI"
Private Const PAYPAL_ENVIRONMENT As String = "SANDBOX"
Private Const PAYPAL_SUBJECT As String = ""


Hope this helps someone else who may experience this problem.
I conclude that there are two ways of constructing a software design: One way is to make it so simple there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies." - Tony Hoare
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAFVision Theme by Jaben Cargman (Tiny Gecko)
Powered by YAF | YAF © 2003-2009, Yet Another Forum.NET
This page was generated in 0.143 seconds.