Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
james-ingold opened this issue Oct 30, 2024 · 16 comments

Comments

@james-ingold
Copy link

james-ingold commented Oct 30, 2024

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
Copy link
Author

Seems to no longer be occurring.

@james-ingold
Copy link
Author

james-ingold commented Nov 6, 2024

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 james-ingold reopened this Nov 6, 2024
@james-ingold
Copy link
Author

Switching back to old payment flow until this is resolved

@alisacorporation
Copy link

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

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

@james-ingold
Copy link
Author

james-ingold commented Nov 12, 2024

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
Copy link
Author

@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
Copy link

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
Copy link

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
Copy link
Author

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
Copy link
Author

james-ingold commented Nov 14, 2024

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
Copy link
Author

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

@LeonarthusMectus
Copy link

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.

@james-ingold
Copy link
Author

Anything we can do to move forward on this ASAP? We hit another instance today with a user charged 3 times due to this error. Not the best experience for our customers.

james-ingold added a commit to james-ingold/PayPal-PHP-Server-SDK that referenced this issue Nov 21, 2024
…quired

 Allows the NetworkTransactionReference class to be instantiated without a transaction ID, and the JsonMapper will no longer throw an exception when the ID is not provided in the response.
@james-ingold
Copy link
Author

@PrestonPHX @DPoplin this production issue is almost a month old now. Any updates on when a fix is expected to be deployed?

james-ingold added a commit to james-ingold/PayPal-PHP-Server-SDK that referenced this issue Nov 25, 2024
…to-be-null

Fix for paypal#10 - Allow NetworkTransactionReference id to not be required
@LeonarthusMectus
Copy link

@james-ingold We're working with the teams that maintain the APIs to confirm the fixes for both of your issues.

While it appears you have a patch in place for the problem you're seeing in specifically in your implementations, we're trying to ensure we address all issues related to this specific bug with these teams. We're working to avoid adding values piece by piece as folks encounter issues.

@james-ingold
Copy link
Author

Yep, I can confirm my patch is working in production. Had to get a bandaid in before Black Friday. Looking forward to a proper fix in the lib. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants