paypal / PayPal-PHP-Server-SDK

Other
5 stars 0 forks source link

Could not find required constructor arguments for PaypalServerSdkLib\\Models\\NetworkTransactionReference: id #10

Open james-ingold opened 2 weeks ago

james-ingold commented 2 weeks ago

Just started getting this error in the sandbox when calling ordersCapture. I've been testing error handling so not sure if I've made too many calls or something. Order is created and then the error happens on capture. This was working previously.

$captureBody = [ "id" => _the_order_id, ];

$apiResponse = $this->client->getOrdersController()->ordersCapture($captureBody);

[2024-10-30 15:18:49] local.ERROR: Could not find required constructor arguments for PaypalServerSdkLib\Models\NetworkTransactionReference: id {"userId":"43d41861-7d07-4676-82cb-6833e5aef5f1","exception":"[object] (apimatic\\js10:18:49 [42/1581]
erException(code: 0): Could not find required constructor arguments for PaypalServerSdkLib\\Models\\NetworkTransactionReference: id at localhost/vendor/apimatic/jsonmapper/src/JsonMapperException.php:169)
[stacktrace]
#0 localhost/vendor/apimatic/jsonmapper/src/JsonMapper.php(1825): apimatic\\jsonmapper\\JsonMapperException::fewerArgumentsException('PaypalServerSdk...', Array)
#1 localhost/vendor/apimatic/jsonmapper/src/JsonMapper.php(1189): apimatic\\jsonmapper\\JsonMapper->createInstance('PaypalServerSdk...', Object(stdClass), false)
#2 localhost/vendor/apimatic/jsonmapper/src/JsonMapper.php(529): apimatic\\jsonmapper\\JsonMapper->mapClass(Object(stdClass), '\\\\PaypalServerSd...', false)
#3 localhost/vendor/apimatic/jsonmapper/src/JsonMapper.php(304): apimatic\\jsonmapper\\JsonMapper->getMappedValue(Object(stdClass), '\\\\PaypalServerSd...', NULL, NULL, 'PaypalServerSdk...', 'PaypalServerSdk...',
 false)
#4 localhost/vendor/apimatic/jsonmapper/src/JsonMapper.php(1428): apimatic\\jsonmapper\\JsonMapper->map(Object(stdClass), Object(PaypalServerSdkLib\\Models\\Capture), false)
#5 localhost/vendor/apimatic/jsonmapper/src/JsonMapper.php(510): apimatic\\jsonmapper\\JsonMapper->mapArray(Array, Array, '\\\\PaypalServerSd...', 1, false)                                                        #6 localhost/vendor/apimatic/jsonmapper/src/JsonMapper.php(304): apimatic\\jsonmapper\\JsonMapper->getMappedValue(Array, 'Capture[]', NULL, NULL, 'PaypalServerSdk...', 'PaypalServerSdk...', false)
#7 localhost/vendor/apimatic/jsonmapper/src/JsonMapper.php(1199): apimatic\\jsonmapper\\JsonMapper->map(Object(stdClass), Object(PaypalServerSdkLib\\Models\\PaymentCollection), false)
#8 localhost/vendor/apimatic/jsonmapper/src/JsonMapper.php(529): apimatic\\jsonmapper\\JsonMapper->mapClass(Object(stdClass), '\\\\PaypalServerSd...', false)
#9 localhost/vendor/apimatic/jsonmapper/src/JsonMapper.php(304): apimatic\\jsonmapper\\JsonMapper->getMappedValue(Object(stdClass), '\\\\PaypalServerSd...', NULL, NULL, 'PaypalServerSdk...', 'PaypalServerSdk...', false)
#10 localhost/vendor/apimatic/jsonmapper/src/JsonMapper.php(1428): apimatic\\jsonmapper\\JsonMapper->map(Object(stdClass), Object(PaypalServerSdkLib\\Models\\PurchaseUnit), false)
#11 localhost/vendor/apimatic/jsonmapper/src/JsonMapper.php(510): apimatic\\jsonmapper\\JsonMapper->mapArray(Array, Array, '\\\\PaypalServerSd...', 1, false)
#12 localhost/vendor/apimatic/jsonmapper/src/JsonMapper.php(304): apimatic\\jsonmapper\\JsonMapper->getMappedValue(Array, 'PurchaseUnit[]', NULL, NULL, 'PaypalServerSdk...', 'PaypalServerSdk...', false)
#13 localhost/vendor/apimatic/jsonmapper/src/JsonMapper.php(1199): apimatic\\jsonmapper\\JsonMapper->map(Object(stdClass), Object(PaypalServerSdkLib\\Models\\Order), false)                                        #14 localhost/vendor/apimatic/core/src/Utils/JsonHelper.php(71): apimatic\\jsonmapper\\JsonMapper->mapClass(Object(stdClass), 'PaypalServerSdk...')
#15 localhost/vendor/apimatic/core/src/Response/Types/ResponseType.php(65): Core\\Utils\\JsonHelper->mapClass(Object(stdClass), 'PaypalServerSdk...', 0)                                                            #16 localhost/vendor/apimatic/core/src/Response/ResponseHandler.php(178): Core\\Response\\Types\\ResponseType->getFrom(Object(Core\\Response\\Context))
#17 localhost/vendor/apimatic/core/src/ApiCall.php(51): Core\\Response\\ResponseHandler->getResult(Object(Core\\Response\\Context))
#18 localhost/vendor/paypal/paypal-server-sdk/src/Controllers/BaseController.php(40): Core\\ApiCall->execute()
#19 localhost/vendor/paypal/paypal-server-sdk/src/Controllers/OrdersController.php(345): PaypalServerSdkLib\\Controllers\\BaseController->execute(Object(Core\\Request\\RequestBuilder), Object(Core\\Response\\Resp
onseHandler))
james-ingold commented 2 weeks ago

Seems to no longer be occurring.

james-ingold commented 1 week ago

Seem to be randomly getting this issue in production fyi. The order id is populated.

$captureBody = [ "id" => _the_order_id, ];

$this->client->getOrdersController()->ordersCapture($captureBody);

apimatic\jsonmapper\JsonMapperException: Could not find required constructor arguments for PaypalServerSdkLib\Models\NetworkTransactionReference: id

(apimatic\jsonmapper\JsonMapperException(code: 0): Could not find required constructor arguments for PaypalServerSdkLib\Models\NetworkTransactionReference: id at /app/vendor/apimatic/jsonmapper/src/JsonMapperException.php:169)

It also seems like the charge to the user is occurring even though this errors so potentially occurring when parsing the paypal api response? The response on these is a 201 with status COMPLETED

james-ingold commented 5 days ago

Switching back to old payment flow until this is resolved

alisacorporation commented 2 days ago

$captureBody = {"id":"0SV24052CE043231L"} is this legit for php?

$captureBody = ['id' => '0SV24052CE043231L'];

james-ingold commented 2 days ago

Thanks, @alisacorporation just an issue copy and pasting code to github, since I redacted the order id. I've updated the post in github but that is not the issue. Most of our transactions are going through successfully in both the sandbox and production. This issue occurs occasionally and from the call stack is from parsing the capture response in the Paypal PHP SDK. If it was an issue with the capture body we wouldn't be getting to this point.

james-ingold commented 2 days ago

@DPoplin Hey do you have any insight into this issue? I also received a support response from Paypal Technical Support that this library is deprecated which is hopefully not the case.

PrestonPHX commented 2 days ago

This library is not deprecated; it is new and in beta, some kinks left to work out apparently...

That confusion must arise because a much older repository, called "PayPal-PHP-SDK" (no "server-") was long ago deprecated

LeonarthusMectus commented 1 day ago

Hello all. Apologies for being late to the discussion.

@james-ingold I can confirm that @PrestonPHX is correct, this SDK is part of six (6) new SDKs we are building to replace older deprecated SDKs. There may be some folks on our support teams who aren't aware of this. In any case, I and my team are very much working on them to correct issues and add additional features.

To the point, would it be possible for you to grab a debug ID from a failed request as well as a non-failed request for me? These should be available in the response headers or possibly logged by the SDK depending on your logging config. With those I can take a look and try to compare what's going on here.

james-ingold commented 1 day ago

Thanks @LeonarthusMectus for checking this out. Just to clarify these are all successful, non-failed responses in paypal, (200, 201 response codes) but seem to be erroring in the SDK when parsing the response:

Example request that threw this error: DEBUG ID: 6f4811777118b (capture request) Request that did not throw this error: DEBUG ID: 1c9d2861bc074 (capture request)

james-ingold commented 7 hours ago

3 more examples from today: @LeonarthusMectus Same user tried to make a payment, and was charged 3 times, hitting the error each time even though they were successful payments and 201 capture responses from Paypal.

DEBUG ID: 030f6676c8f78 DEBUG ID: 6375849bf2e17 DEBUG ID: 9e6fc0792097c

james-ingold commented 7 hours ago

Not sure if it helps but these seem to be debit cards when this occurs, but that might just be a coincidence

LeonarthusMectus commented 6 hours ago

Perfect! Thanks for those. It definitely looks like all these instances are all Debit cards, and are missing the id property of the network transaction reference object in the capture response, which from what I understand should always be present.

I'm following up with some colleagues on our API teams to try and understand the relationship between Debit networks & the network transaction reference to work out if there's a case where the ID would not be present, or if it's mistakenly being omitted in the response. That should give us an idea of where the fix is needed, and we can go about getting that put into place to remediate the exception.

I'll follow up here just as soon I have any details or updates to share.