cancel
Showing results for 
Search instead for 
Did you mean: 

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)

http://www.amazon.com/Clean-Coder-Conduct-Professional-Programmers/dp/0137081073/ref=sr_1_1?ie=UTF8&...

 

Location3
Member
5 REPLIES 5

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

Joy
Administrator Administrator
Administrator

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.

Or just skip the dll. Just use the web service call.

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.

 

 

UpdatePaymentProfile the first param is the customer profile ID and not the customer payment profile ID.

so in your case would be "11062943"