I am having problems with the CreateCustomerPaymetProfile() function in the SOAP AIM, working in VB.Net. I am getting an “Object reference not set” Error on the CustomerPaymentProfileType method. However no errors are showing up in Visual Web Developer code editor.
Before I run this I run the CreateCustomerProfile() function and that runs OK, no errors.
Below is the code I am trying. If I comment out all of the “new_payment_profile” lines I don’t get the error (“new_payment” and “new_card” are OK). Any help would be appreciated.
Public Function CreateCustomerPaymentProfile(ByVal CPID As Long, ByVal Name As String, ByVal Address As String, ByVal City As String, ByVal Zip As String, ByVal CardNumber As String, ByVal ExpDate As String) As Long Dim new_payment_profile As New CIMService.CustomerPaymentProfileType() Dim new_payment As New CIMService.PaymentType() Dim new_card As New CIMService.CreditCardType() new_payment_profile.billTo.firstName = Name new_payment_profile.billTo.address = Address new_payment_profile.billTo.city = City new_payment_profile.billTo.zip = Zip new_card.cardNumber = CardNumber new_card.expirationDate = ExpDate new_payment.Item = new_card new_payment_profile.payment = new_payment Dim response As CIMService.CreateCustomerPaymentProfileResponseType = Service.CreateCustomerPaymentProfile(MerchantAuthentication, CPID, new_payment_profile, CIMService.ValidationModeEnum.liveMode) Dim out_id As Long = 0 If Len(response.customerPaymentProfileId) > 0 Then out_id = response.customerPaymentProfileId Else For i As Integer = 0 To response.messages.Length - 1 SessionClass.ErrorMsg += response.messages(i).text Next End If Return out_id End Function
Thanks
Solved! Go to Solution.
09-24-2012 03:37 PM
Don't need the reference.vb. I was just wondering if it something wrong with the C# to VB translation.
I copy your code to my test project the error I got was on the
new_payment_profile.billTo.firstName = Name
so, I added just before that line
new_payment_profile.billTo = new CIMService.CustomerAddressType()
other than that it was ok.
09-25-2012 08:33 AM - edited 09-25-2012 08:34 AM
Did you copy and modify the web reference from the sample code or did your own? Can't see why it will false on that. Can you trace thru the code.
09-25-2012 04:18 AM
I mostly copied this from the C# sample code for CIM SOAP and ran it through an online translator to get vb. and then pulled out the CreateCustomerProfile() and CreateCustomerPaymentProfile() functions along with the
Service(), MerchantAuthentication(), properties and the 3 Constants and 2 variables used by the properties
I added the WSDL file from here (https://api.authorize.net/soap/v1/Service.asmx?WSDL) named the folder CIMService and changed all the references in the CustomerProfile functions to match, I made no changes to the WSDL file. I also changed the CustomerProfile functions from Public Shared to just Public as I was getting reference errors in the editor with the shared functions.
The CreateCustomerProfile function runs great and I can add live profiles to our CIM with it, so I really don't understand why the CreatCustomerPaymentProfile would throw this error, and I don't even know where to look, since the methods used within these functions are all created from the WSDL file. I went through the code commenting out lines and I believe the error is from the CustomerPaymentProfileType object named new_payment_profile. the other objects in the function do not seem to cause a problem
I enabled page trace and pasted the results below. Not sure what to look for in all of that either.
Thanks for the Help
aspx.page | Begin PreInit | ||
aspx.page | End PreInit | 1.36190493484507E-05 | 0.000014 |
aspx.page | Begin Init | 3.51301631911318E-05 | 0.000022 |
aspx.page | End Init | 5.15428636879827E-05 | 0.000016 |
aspx.page | Begin InitComplete | 6.32063572325533E-05 | 0.000012 |
aspx.page | End InitComplete | 7.48000094984139E-05 | 0.000012 |
aspx.page | Begin LoadState | 8.61841379281445E-05 | 0.000011 |
aspx.page | End LoadState | 0.000214412725639711 | 0.000128 |
aspx.page | Begin ProcessPostData | 0.000229428600562362 | 0.000015 |
aspx.page | End ProcessPostData | 0.000413739735078062 | 0.000184 |
aspx.page | Begin PreLoad | 0.000428825451279422 | 0.000015 |
aspx.page | End PreLoad | 0.000440628627381413 | 0.000012 |
aspx.page | Begin Load | 0.000451733390696304 | 0.000011 |
aspx.page | End Load | 0.000464234979585394 | 0.000013 |
aspx.page | Begin ProcessPostData Second Try | 0.000475549266736415 | 0.000011 |
aspx.page | End ProcessPostData Second Try | 0.000486654030051305 | 0.000011 |
aspx.page | Begin Raise ChangedEvents | 0.000497549269530066 | 0.000011 |
aspx.page | End Raise ChangedEvents | 0.000517942922913387 | 0.000020 |
aspx.page | Begin Raise PostBackEvent | 0.000531282607146998 | 0.000013 |
Unhandled Execution Error | Object reference not set to an instance of an object. at Payments.CreateCustomerPaymentProfile(Int64 CPID, String Name, String Address, String City, String Zip, String CardNumber, String ExpDate) at PmtSystemTest.RunTestButton2_Click(Object sender, EventArgs e) at System.Web.UI.WebControls.Button.OnClick(EventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) | 0.00386096556964642 | 0.003330 |
Control TreeControl UniqueID Type Render Size Bytes (including children) ViewState Size Bytes (excluding children) ControlState Size Bytes (excluding children)
__Page | ASP.pmtsystemtest_aspx | 0 | 0 | 0 |
ctl02 | System.Web.UI.LiteralControl | 0 | 0 | 0 |
ctl00 | System.Web.UI.HtmlControls.HtmlHead | 0 | 0 | 0 |
ctl01 | System.Web.UI.HtmlControls.HtmlTitle | 0 | 0 | 0 |
ctl03 | System.Web.UI.LiteralControl | 0 | 0 | 0 |
form1 | System.Web.UI.HtmlControls.HtmlForm | 0 | 0 | 0 |
ctl04 | System.Web.UI.LiteralControl | 0 | 0 | 0 |
RunTestBtton | System.Web.UI.WebControls.Button | 0 | 0 | 0 |
ctl05 | System.Web.UI.LiteralControl | 0 | 0 | 0 |
TestResults | System.Web.UI.WebControls.Label | 0 | 0 | 0 |
ctl06 | System.Web.UI.LiteralControl | 0 | 0 | 0 |
CPID | System.Web.UI.WebControls.TextBox | 0 | 0 | 0 |
ctl07 | System.Web.UI.LiteralControl | 0 | 0 | 0 |
CardNumber | System.Web.UI.WebControls.TextBox | 0 | 0 | 0 |
ctl08 | System.Web.UI.LiteralControl | 0 | 0 | 0 |
ExpDate | System.Web.UI.WebControls.TextBox | 0 | 0 | 0 |
ctl09 | System.Web.UI.LiteralControl | 0 | 0 | 0 |
RunTestButton2 | System.Web.UI.WebControls.Button | 0 | 0 | 0 |
ctl10 | System.Web.UI.LiteralControl | 0 | 0 | 0 |
TestResults2 | System.Web.UI.WebControls.Label | 0 | 0 | 0 |
ctl11 | System.Web.UI.LiteralControl | 0 | 0 | 0 |
ErrorMsg | System.Web.UI.WebControls.Label | 0 | 0 | 0 |
ctl12 | System.Web.UI.LiteralControl | 0 | 0 | 0 |
ctl13 | System.Web.UI.LiteralControl | 0 | 0 | 0 |
Session StateSession Key Type ValueApplication StateApplication Key Type ValueRequest Cookies CollectionName Value SizeResponse Cookies CollectionName Value SizeHeaders CollectionName Value
Connection | keep-alive |
Content-Length | 274 |
Content-Type | application/x-www-form-urlencoded |
Accept | text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 |
Accept-Encoding | gzip, deflate |
Accept-Language | en-us,en;q=0.5 |
Host | multihullnetsnew.multihullnets.com |
Referer | http://multihullnetsnew.multihullnets.com/PmtSystemTest.aspx |
User-Agent | Mozilla/5.0 (Windows NT 5.1; rv:15.0) Gecko/20100101 Firefox/15.0.1 |
Response Headers CollectionName Value
X-AspNet-Version | 2.0.50727 |
Cache-Control | private |
Content-Type | text/html |
Form CollectionName Value
__VIEWSTATE | /wEPDwUKLTU0ODc4NTc0MWRksGP49BDIixHKI0vB0aLtNoQW040= |
__EVENTVALIDATION | /wEWBgLN3py2BALWzrD7AgLK7ZrjAQKi0rDKCALhkra6AQKXs5LxDi9cgnXewVzGxY9+T2iTk3NjsTVC |
CPID | 45198835 |
CardNumber | 4111111111111 |
ExpDate | 2015-03 |
RunTestButton2 | Run CreateCustomerPaymentProfile |
Querystring CollectionName ValueServer VariablesName Value
ALL_HTTP | HTTP_CONNECTION:keep-alive HTTP_CONTENT_LENGTH:274 HTTP_CONTENT_TYPE:application/x-www-form-urlencoded HTTP_ACCEPT:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 HTTP_ACCEPT_ENCODING:gzip, deflate HTTP_ACCEPT_LANGUAGE:en-us,en;q=0.5 HTTP_HOST:multihullnetsnew.multihullnets.com HTTP_REFERER:http://multihullnetsnew.multihullnets.com/PmtSystemTest.aspx HTTP_USER_AGENT:Mozilla/5.0 (Windows NT 5.1; rv:15.0) Gecko/20100101 Firefox/15.0.1 |
ALL_RAW | Connection: keep-alive Content-Length: 274 Content-Type: application/x-www-form-urlencoded Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Encoding: gzip, deflate Accept-Language: en-us,en;q=0.5 Host: multihullnetsnew.multihullnets.com Referer: http://multihullnetsnew.multihullnets.com/PmtSystemTest.aspx User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:15.0) Gecko/20100101 Firefox/15.0.1 |
APPL_MD_PATH | /LM/W3SVC/184/ROOT |
APPL_PHYSICAL_PATH | E:\HostingSpaces\LocalUser\RLeng\MultihullnetsNew.multihullnets.com\wwwroot\ |
AUTH_TYPE | |
AUTH_USER | |
AUTH_PASSWORD | |
LOGON_USER | |
REMOTE_USER | |
CERT_COOKIE | |
CERT_FLAGS | |
CERT_ISSUER | |
CERT_KEYSIZE | |
CERT_SECRETKEYSIZE | |
CERT_SERIALNUMBER | |
CERT_SERVER_ISSUER | |
CERT_SERVER_SUBJECT | |
CERT_SUBJECT | |
CONTENT_LENGTH | 274 |
CONTENT_TYPE | application/x-www-form-urlencoded |
GATEWAY_INTERFACE | CGI/1.1 |
HTTPS | off |
HTTPS_KEYSIZE | |
HTTPS_SECRETKEYSIZE | |
HTTPS_SERVER_ISSUER | |
HTTPS_SERVER_SUBJECT | |
INSTANCE_ID | 184 |
INSTANCE_META_PATH | /LM/W3SVC/184 |
LOCAL_ADDR | 66.199.128.250 |
PATH_INFO | /PmtSystemTest.aspx |
PATH_TRANSLATED | E:\HostingSpaces\LocalUser\RLeng\MultihullnetsNew.multihullnets.com\wwwroot\PmtSystemTest.aspx |
QUERY_STRING | |
REMOTE_ADDR | 67.78.212.182 |
REMOTE_HOST | 67.78.212.182 |
REMOTE_PORT | 3613 |
REQUEST_METHOD | POST |
SCRIPT_NAME | /PmtSystemTest.aspx |
SERVER_NAME | multihullnetsnew.multihullnets.com |
SERVER_PORT | 80 |
SERVER_PORT_SECURE | 0 |
SERVER_PROTOCOL | HTTP/1.1 |
SERVER_SOFTWARE | Microsoft-IIS/7.0 |
URL | /PmtSystemTest.aspx |
HTTP_CONNECTION | keep-alive |
HTTP_CONTENT_LENGTH | 274 |
HTTP_CONTENT_TYPE | application/x-www-form-urlencoded |
HTTP_ACCEPT | text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 |
HTTP_ACCEPT_ENCODING | gzip, deflate |
HTTP_ACCEPT_LANGUAGE | en-us,en;q=0.5 |
HTTP_HOST | multihullnetsnew.multihullnets.com |
HTTP_REFERER | http://multihullnetsnew.multihullnets.com/PmtSystemTest.aspx |
HTTP_USER_AGENT | Mozilla/5.0 (Windows NT 5.1; rv:15.0) Gecko/20100101 Firefox/15.0.1 |
09-25-2012 07:28 AM
I created a new web site and did a "add web reference" to the apitest.authorize.net/soap/v1/service.asmx
And it works fine.
under your CIMService folder, does it have a reference.vb? if it exist, it probably something in the CustomerPaymentProfileType or CustomerPaymentProfileBaseType class.
09-25-2012 07:48 AM
No. my Web Reference folder only contains a Service.discomap and Service.wsdl files.
I noticed the C# sample contains a Reference.cs file but how would i get a Reference.vb file. I am using VisualWebDeveloper 2010 Express. I right click on the Solution Explorer, select Add Web Reference, enter the URL and click add. I have tried this several times and no reference file shows up.
09-25-2012 08:15 AM - edited 09-25-2012 08:16 AM
Don't need the reference.vb. I was just wondering if it something wrong with the C# to VB translation.
I copy your code to my test project the error I got was on the
new_payment_profile.billTo.firstName = Name
so, I added just before that line
new_payment_profile.billTo = new CIMService.CustomerAddressType()
other than that it was ok.
09-25-2012 08:33 AM - edited 09-25-2012 08:34 AM
That was it. Thanks.
09-25-2012 10:05 AM
Make sure Authorize.NET dll was not properly refresh in bin folder when creating a new Customer Profile on Authorize.NET.
I am using asp.net c# code.
So please refresh or remove and add new Authorize.NET dll and u will create new customer easily.
01-01-2016 09:03 PM