Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Despite #2337561: Add an alter data hook to all Paypal Payment methods requesting a hook for all payment methods that issue seems to have been closed after only providing a hook for PPS.
It would be good if we could also have a hook to alter the NVP requests that the EC method uses so that we can make use of NVP fields such as PAYMENTREQUEST_n_NOTETEXT
.
Comment | File | Size | Author |
---|---|---|---|
#3 | interdiff-2504523-2-3.txt | 4.49 KB | morbiD |
#3 | paypal_payment-nvp-alter-hook-2504523-2.patch | 3.95 KB | morbiD |
#2 | paypal_payment-nvp-alter-hook-2504523-1.patch | 2.43 KB | morbiD |
#1 | paypal_payment-nvp-alter-hook-2504523-0.patch | 2.43 KB | morbiD |
Comments
Comment #1
morbiD CreditAttribution: morbiD commentedHow does this patch look?
The only thing I wondered about is whether it matters which function called
paymentNVP()
. If somebody implementing the hook needs to know whether the request is asetExpressCheckout()
or adoExpressCheckoutPayment()
then the hook would need to be supplied with some context about that, or perhaps there should be separate hooks for each request function?Comment #2
morbiD CreditAttribution: morbiD commentedI realised the hook parameters were the wrong way round. The
drupal_alter()
documentation specifies that the data to be altered should come first with context items afterwards.Amended patch attached.
I think the PPS hook added in #2337561: Add an alter data hook to all Paypal Payment methods actually has the same problem should you wish to correct it (not that it makes any practical difference).
Comment #3
morbiD CreditAttribution: morbiD commentedI did some further work to split this out into separate hooks since there are differences in the NVP field specifications for
SetExpressCheckout
andDoExpressCheckoutPayment
, plus I added links to PayPal's NVP field documentation in my hook documentation.I also decided to pass a cloned
$payment
object to the hooks so that hook implementations can't modify the original payment object.