question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unhandled exception in BTCPayMiddleware during invoice creation

See original GitHub issue

Running BTCPayServer v1.0.3.54 via btcpayserver-docker

  1. user created
  2. store created
  3. token created
  4. try to create invoice with https://github.com/btcpayserver/php-bitpay-client package
$storageEngine = new \Bitpay\Storage\FilesystemStorage();
$privateKey    = $storageEngine->load('/tmp/bitpay.pri');
$publicKey     = $storageEngine->load('/tmp/bitpay.pub');
$client        = new \Bitpay\Client\Client();
$adapter       = new \Bitpay\Client\Adapter\CurlAdapter();
$client->setPrivateKey($privateKey);
$client->setPublicKey($publicKey);
$client->setUri('https://btcpay.my.domain/');
$client->setAdapter($adapter);

$token = new \Bitpay\Token();
$token->setToken('my_token');
$client->setToken($token);

$invoice = new \Bitpay\Invoice();

$item = new \Bitpay\Item();
$item
   ->setPrice(1.99);
$invoice->setItem($item);

$invoice->setCurrency(new \Bitpay\Currency('USD'));

$client->createInvoice($invoice);

http request: headers

Content-Type: application/json
X-BitPay-Plugin-Info: BitPay PHP-Client/2.2.20
User-Agent: BitPay PHP-Client/2.2.20 (PHP 7.1.17-0ubuntu0.17.10.1)
X-Accept-Version: 2.0.0
Content-Length: 585
x-identity: my_pub_key
x-signature: my_signature

body

{"price":1.99,"taxIncluded":null,"currency":"USD","posData":null,"notificationURL":null,"transactionSpeed":"medium","fullNotifications":true,"extendedNotifications":false,"notificationEmail":null,"redirectURL":null,"orderID":null,"itemDesc":null,"itemCode":null,"physical":false,"buyerName":"","buyerAddress1":"","buyerAddress2":"","buyerCity":null,"buyerState":null,"buyerZip":null,"buyerCountry":null,"buyerEmail":null,"buyerPhone":null,"buyerNotify":null,"guid":"08b31884-4d96-f539-a8ad-158e9988b4bd","nonce":1550321074.865315,"token":"my_token"}

http response: HTTP/1.1 500 Internal Server Error

error log

crit: PayServer:      Unhandled exception in BTCPayMiddleware
System.NullReferenceException: Object reference not set to an instance of an object.
   at BTCPayServer.Controllers.InvoiceController.CreateInvoiceCore(Invoice invoice, StoreData store, String serverUrl) in /source/Controllers/InvoiceController.cs:line 75
   at BTCPayServer.Controllers.InvoiceControllerAPI.CreateInvoice(Invoice invoice) in /source/Controllers/InvoiceController.API.cs:line 38
   at lambda_method(Closure , Object )
   at Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable.Awaiter.GetResult()
   at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
   at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
   at BTCPayServer.Hosting.BTCPayMiddleware.Invoke(HttpContext httpContext) in /source/Hosting/BTCpayMiddleware.cs:line 46
fail: Microsoft.AspNetCore.Server.Kestrel: Connection id "0HLKGCVH6SPTH", Request id "0HLKGCVH6SPTH:00000001": An unhandled exception was thrown by the application.
System.NullReferenceException: Object reference not set to an instance of an object.
   at BTCPayServer.Controllers.InvoiceController.CreateInvoiceCore(Invoice invoice, StoreData store, String serverUrl) in /source/Controllers/InvoiceController.cs:line 75
   at BTCPayServer.Controllers.InvoiceControllerAPI.CreateInvoice(Invoice invoice) in /source/Controllers/InvoiceController.API.cs:line 38
   at lambda_method(Closure , Object )
   at Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable.Awaiter.GetResult()
   at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
   at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
   at BTCPayServer.Hosting.BTCPayMiddleware.Invoke(HttpContext httpContext) in /source/Hosting/BTCpayMiddleware.cs:line 46
   at Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:18 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
NicolasDoriercommented, Feb 20, 2019

It is a bug on btcpay side, fixing it.

1reaction
NicolasDoriercommented, Feb 21, 2019

The problem was taxIncluded field. For some reason, json.net accept it not being specified but do not accept null value. I made the field “nullable”. Fixed in 1.0.3.57.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error When Opening Invoice Workbench Form (APXINWKB ...
R12: AP: Error When Opening Invoice Workbench Form (APXINWKB) FRM-40735: PRE-FORM Trigger Raised Unhandled Exception ORA-04063 (Doc ID 2747753.1).
Read more >
Custom invoice no longer works - error message ...
Hi. I have Simply Accounting Pro 2010. About a week ago my customized invoice that I had created awhile ago disappeared (not sure...
Read more >
Unhandled Exception Has Occurred in Your Application
The error message "Unhandled Exception Has Occurred in Your Application" can be generated when completing various tasks within Juris ®.
Read more >
R12: AP: When Trying To Open Invoice The following Error ...
When querying a speciflic invoice the following error occurs: FRM-40735 POST-QUERY trigger raised unhandled exception ORA-01403.
Read more >
Error - Unhandled Exception While making AR invoice and ...
Hello Expert, while making AP Invoice from user's computer after entering 2/3 invoice , SAP raises an error " and close SAP Business...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found