Support PayPal Adaptive Payments (Chained Payments)

Created on 5 September 2013, about 12 years ago
Updated 18 August 2025, about 2 months ago

In a recent project I developed a module that allows for setting up PayPal chained payments as a payment gateway in Drupal Commerce. I used rszrama's commerce_paypal_wps as my starting point (major props to Ryan - awesome code to work from!) and leveraged as much from the parent commerce_paypal module as I could.

I've tested the module pretty extensively with sandbox credentials and it appears to be working well.

In its current form, it could be offered up to the community as a submodule in this project, or a stand-alone module with a commerce_paypal dependency. Looking for rszrama's feedback on which route to go there.

PayPal's chained payments uses the Adaptive Payments API, which differs pretty vastly in terms of how variables get sent to PayPal, what those variables are, and what variables come back to the site via the IPN. Because of this I had to abandon certain parts of commerce_paypal's standard IPN processing.

In a general sense, my module reaches out to PayPal with a definition of the paychain, receives a paykey, then drops the buyer on PayPal's site, with the paykey, to complete the transaction. The module then harvests the IPN from PayPal and if everything checks out, creates the payment transactions on the order, bringing the order to a fully-paid state, with a new field on the Payments tab showing who was paid what (shows the "receiver email address" for each payment in the chain).

I also designed the module in such a way that you can define the paychain using tokens (assuming you have token installed) - so who gets paid what percentage of the order could be dynamic and specific to each order.

Currently, this module is sitting in my GitHub account here:
https://github.com/chrisolof/commerce_paypal_chained

If it's possible this could become a submodule in this project (like commerce_paypal_wps), I could submit a patch against 7.x-2.x-dev - just let me know. For now, I'll keep working on it in GitHub.

Caveats:
- Currently the module does not handle defining time-delays in the pay chain (might be easy to add), nor does it handle chained refunds (could be complex to add).
- The module requires the web server have cURL support in PHP (reaching out for the paykey is done through cURL).
- The module could use better watchdog/error reporting in instances where a paykey does not come back from paypal.
- The module could use additional validation surrounding the paychain definition so we never reach out to PayPal with an invalid paychain.

✨ Feature request
Status

Closed: outdated

Version

2.0

Component

PayPal / IPN

Created by

πŸ‡ΊπŸ‡ΈUnited States chrisolof

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024