Closed (fixed)
Project:
Commerce PayPal
Version:
8.x-1.x-dev
Component:
Payflow Gateway
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
20 Dec 2017 at 22:21 UTC
Updated:
14 Dec 2021 at 15:29 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
replicaobscuraAdding related issue for the issue these changes originally came from (the patch in comment #10 there)
Comment #3
replicaobscuraHere are the changes split out into a separate patch.
Comment #4
bojanz commentedThis is odd.
Commerce Shipping doesn't add such a field. Why would we add integration for a non-Shipping-provided field?
Sounds like we need an alter mechanism (== event) instead.
Comment #5
replicaobscuraHm, I don't know why it works for me if commerce_shipping doesn't add that field, I guess another patch I was using may have introduced it or something. That should be changed to some standard way to access the shipping profile in that case.
I think even if it's the wrong field name or mechanism for accessing the shipping profile, it seems like it still makes sense to support commerce_shipping within commerce_paypal if it's enabled (using a better mechanism to access the profile). Otherwise, commerce_shipping would need to support commerce_paypal and that doesn't seem right to me as shipping is a much broader module than a particular payment processor. A higher percentage of commerce_paypal users will be using commerce_shipping than the percentage of commerce_shipping users using commerce_paypal.
Unless you're suggesting the event model in order to separate the logic into a submodule of commerce_paypal (though I don't think there's enough code for that to be necessary), or simply to split the logic out of that file into a class dedicated to shipping, which I could understand. Or, the other reason I could see for that to be handled in an event would be to require users to add support for commerce_shipping on their own rather than supporting shipping within commerce_paypal, but that seems unnecessarily burdensome when a significant portion of users will likely be using shipping.
I'm not opposed to using an event for it in general, to allow other modifications to it besides for just supporting shipping, but I still feel that the shipping use case should be supported by default if the order has shipping information (obviously using a more standard way to access the profile since you indicated this isn't normal).
Unless there's some reason not to support shipping by default?
Comment #6
mglamanThe order number isn't populated until the order is placed, so this will be empty.
I think we should just remove this, for now. Or check if shipping module is enabled.
Why should this be split out of the main function?
Comment #7
replicaobscuraI do think it could be useful to submit shipping information to PayFlow, but I agree that it should at least check if commerce_shipping is enabled first. Or this could be abstracted into an event with a submodule used for commerce_shipping, but that seems kind of heavy for such a simple bit of code.
The main reason to split out the function is that mapping profile parameters seems like it should be a separate concern to me. All the main function should care about is that the profile parameters get populated, but which fields map where, and how they're retrieved, seems like a prime candidate for abstraction.
I would be fine with combining the functions if preferred, I just tend to prefer keeping functions small and focused to a single concern if possible.
Comment #9
shaunole commentedI'm attempting to tackle this from another direction - similar to how the
CheckoutSdk.phphandles modifying the PayPal request params. Perhaps, we should allow the parameters to be specified via an Event Subscriber when the payment is created via Payflow. I've incorporated a few changes that create a new Event for Payflow payment creation, and that dispatch said event within thecreatePayment()method.Custom modules should be able to subscribe to the
PayPalEvents::PAYFLOW_CREATE_PAYMENTevent and modify the request parameters as needed.Comment #11
shaunole commentedIt appears that the latest test failure is due to a previously existing "Symmetric array destructuring" assignment - this feature was introduced in PHP 7.1 (I'm assuming that the test runner is using PHP 7.0?). This is the offending code block from line 296 of
src/Plugin/Commerce/PaymentGateway/Payflow.php.Otherwise, it appears the tests were successful.
Comment #12
jimmynash commented@shaunole thanks for doing this work. I've found myself needing to conditionally set the paypal comment1 field for a project and having an event subscriber to modify the values before going to paypal would be extremely helpful.
Comment #13
shaunole commentedComment #14
shaunole commentedResolved remaining test failures. We should be good to merge this into the next release.
Comment #17
shaunole commentedComment #18
rszrama commented+1 from me on the approach - we should have request / response events for every API integration. This just needs the docblock at https://git.drupalcode.org/project/commerce_paypal/-/merge_requests/8/di... fixed and it's ready to commit.
Comment #19
shaunole commentedThanks @rszrama. The Dockblocks have been updated. Thanks for the feedback.
The PHP7 test failure is unrelated as its being caused by the
voidreturn type being specified in commerce_paypal/tests/src/Kernel/IPNHandlerTest.php::setUp() function declaration. Including the return type was intentionally introduced in commit https://git.drupalcode.org/project/commerce_paypal/-/commit/0741a59b3203... and released in 8.x-1.0-rc4.Comment #21
rszrama commentedThanks for the updates. Merging this in via the CLI ... I still don't know how to use GitLab to squash / retitle merges. 🤷🏼♂️
Comment #22
shaunole commentedGreat! Thank you @szrama. I appreciate the review and feedback.