- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
C# SDK v1.7 CIM.UpdatePaymentProfile() throws Null Reference Exception
Version 1.7 of the SDK throws a Null Reference Exception when attempting to use CustomerGateway.UpdatePaymentProfile(). This problem was also present in pervious SDK versions. The root of the problem is inside PaymentProfile.ToApi() where result.payment is never initialized before setting result.payment.Item = card.
I'd also like to call out the fact that your SDK has no Unit Tests. I'd like to think that if the SDK had unit tests, it wouldn't be plagued by these kinds of simple errors.
"Every single line of code that you write should be tested. Period'. ('Uncle Bob' Martin - The Clean Coder)
03-06-2012 02:54 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Location3,
Thanks for the report, we'll document it for our Development team to take a review and fix in a future update.
Thanks,
Joy
03-12-2012 02:35 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
9 months down the line they still dont fix a SIMPLE problem.
For all who are having the problem with the c# SDK for CIM when using UpdatePaymentProfile, just download the SDK and add one line to fix the null exception.
Open the file PaymentProfile.cs and locate the customerPaymentProfileExType method. under the line
var result = new customerPaymentProfileExType();
add
result.payment = new APICore.paymentType();
save, compile and add the generated dll to your project and problem fixed.
Hope this helps the community.
12-09-2012 05:16 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Or just skip the dll. Just use the web service call.
12-09-2012 05:46 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have just encounted the problem with UpdatePaymentProfile. Here's my code
Dim gate As CustomerGateway = New CustomerGateway("xxxxxxxxxx", "xxxxxxxxx", ServiceMode.Test)
Dim c1 As New Customer
Dim pid As String = ""
c1 = gate.GetCustomer("11062943")
Dim p1 As PaymentProfile
p1 = c1.PaymentProfiles(0)
pid = p1.ProfileID
p1.CardExpiration = "2017-12"
gate.UpdatePaymentProfile(pid, p1)
Expiration is masked as XXXX and CardNumber is masked as XXXX1111
I am intending to change expiration and I get a record cannot be found error. c1 contains the customer profile and pid contains the correct payment profile ID. p1 contains the correct and only payment profile on this customer profile.
So why does it tell me a record cannot be found? I applied the update below:
add this line to customerPaymentProfileExType after the 'var result = new customerPaymentProfileExType();' line:
result.payment = new APICore.paymentType();
Error processing request: E00040 - The record cannot be found.
12-10-2012 03:27 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
UpdatePaymentProfile the first param is the customer profile ID and not the customer payment profile ID.
so in your case would be "11062943"
12-10-2012 03:44 PM

