adebisi-fa / paystack-dotnet

PayStack API for .Net Developers!
http://developers.paystack.co/docs
MIT License
37 stars 37 forks source link

NullReferenceException: Object reference not set to an instance of an object. #16

Closed ddynamight closed 5 years ago

ddynamight commented 5 years ago

@adebisi-fa, thanks for the fix, v0.7.5 did fixed the error, sorry to bother you again.

But I keep getting this error. When I tried using the transfer interface too.

An unhandled exception occurred while processing the request. NullReferenceException: Object reference not set to an instance of an object. PayStack.Net.PayStackApi.ParseAndResolveMetadata(ref string rawJson)

First when I tried creating a recipient like this

var recipentRequest = new CreateTransferRecipientRequest { Name = disbursement.Name, AccountNumber = disbursement.Account, BankCode = "057", Currency = "NGN", Description = $"Fund Transter For {request.Reference}", Type = "nuban" }; var recipientResult = payApi.Transfers.Recipients.Create(recipentRequest);

is there something I am missing here.

A quick response will be so much appreciated.

Originally posted by @ddynamight in https://github.com/adebisi-fa/paystack-dotnet/issues/15#issuecomment-529129884

adebisi-fa commented 5 years ago

Dear @ddynamight,

Sorry for the delay. I'll review the code for the possible cause of this error.

Thanks once again for reporting this.

The library unit test will get better with time!

ASAP, please.

Regards.

adebisi-fa commented 5 years ago

Hello @ddynamight,

Unfortunately, I couldn't reproduce the error.

I tried the exactly code you sent, with real values in place of disbursement.Name, disbursement.Account, and request.Reference variables and everything worked as expected.

Can you please send the values for your variables, so I could try to reproduce the exception?

Regards.

adebisi-fa commented 5 years ago

Hello @ddynamight ,

Never mind. I was able to reproduce it with an incorrect request.AccountNumber and request.BankCode mapping.

I'll review the code and provide a fix, ASAP.

Thanks once again, please.

Regards.

adebisi-fa commented 5 years ago

Hello @ddynamight,

This has been fixed in v0.7.6.

Please kindly check if it works with your use-case.

Hope this helps.

ddynamight commented 5 years ago

Hello @ adebisi-fa,

Thanks for the reply. Sorry, I wasn't online earlier. I noticed that too. I was apparently using the test bank account provided on the Paystack documentation and I got the error that incorrect account number. so I used that with a correct details and all seem to work even with v0.7.5. I will try out v0.7.6 and reply this thread.

Thanks for being Awesome.

Cheers.

adebisi-fa commented 5 years ago

Dear @ddynamight,

Thank you most for trusting Paystack.Net Library much enough to do your Paystack plumbings, and for not giving up when it was getting your fingers burnt!

The code might not be perfect yet, but it will surely get better with time, and with issue report from folks like you. Please don't hesitate to drop by again if your keyboard suddenly gets hotter than you expected (even with the gloves on)!

Happy coding.

Regards.

[PS: Please don't forget to drop a note on if upgrading to 0.7.6 fixes this issue.]

ddynamight commented 5 years ago

Hi @adebisi-fa,

Thanks for the response and for making our work easier with the library, I hope your weekend was great. The v0.7.6 did fixed the previous problems. But I have another issue with the BvnResolve endpoint.

When called like this:

var bvnDetailsResult = payApi.Miscellaneous.ResolveBVN(request.Bvn);

with request.Bvn being a string

Please see error below.

An unhandled exception has occurred while executing the request. Newtonsoft.Json.JsonReaderException: Error reading JObject from JsonReader. Path '', line 0, position 0. at Newtonsoft.Json.Linq.JObject.Load(JsonReader reader, JsonLoadSettings settings) at Newtonsoft.Json.Linq.JObject.Parse(String json, JsonLoadSettings settings) at PayStack.Net.PayStackApi.ParseAndResolveMetadata[TR](String& rawJson) at PayStack.Net.PayStackApi.Get[TR](String relativeUrl)