I've followed the README to the letter, and installed version 2.2.0 of the Stripe PHP library - and everything works.
My question is why we need that specific version. Are there breaking changes in later versions of the stripe-php library that means we mustn't advance beyond 2.2.0? Or is it just that this was the latest version when the 7.x-2.x branch was first developed, and nobody's tested with anything more recent?
Specifically, Stripe's changelog implies that they started the new major branch number, 3.x, to signal compatibility with PHP 7.
Drupal core is now aiming for full PHP 7 compatibility, and I like to run on PHP 7 whenever possible.
So, IMO, it would be desirable to get to the place where this module's README can give a 3.x version number of stripe-php to install.
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | uc_stripe.allow_php_v3_2687809_16.patch | 1.75 KB | rfay |
| #15 | uc_stripe.allow_php_v3_2687809_15.patch | 3.03 KB | rfay |
| #9 | uc_stripe.allow_php_v3_2687809_09.patch | 10.8 KB | rfay |
| #6 | uc_stripe-support-multiple-library-versions-2687809-6.patch | 9.26 KB | joelstein |
Comments
Comment #2
jamesoakleyComment #3
rfayEarly on (in the Stripe 1.x timeframe) there were no particular instructions specifying what version of the Stripe PHP library to use, and of course all hell broke loose when 2.x came out with a complete and total rewrite. That's why a specific version of the Stripe library is required.
I don't see why a patch to use the Stripe PHP library 3.x would not be accepted, especially if it didn't break using 2.2.0. If it *did* break using 2.2.0 more work would be required.
Comment #4
jamesoakleyIn that case, I'll work on it - but not just now. I'm working towards getting use of this module stable on a site, so I don't want to change things I don't need to. But once I know everything is running without hitches, I can then work on Stripe PHP 3.x compatibility on a -dev copy, knowing that any issues I run into are only because of that one change.
I'll return to this later. (But that need not prevent someone else from getting started, if it's something others would like to see.)
Comment #5
rfayAs I think about it, I imagine that their change of a key class name in 3.x will break things for existing users, and we'll be forced to go to 7.x-3.x, and that's not the end of the world. But if it doesn't have to be that's OK too.
Comment #6
joelstein commentedHere's a patch which adds support for both Stripe PHP library 2.2.0 and 3.13.0, the latest as of this patch. The great thing about this patch is that it doesn't require existing users to upgrade the Stripe PHP library, but if someone wants to use a newer version, they can.
I'm also the maintainer of the Webform Stripe module, and I was running into conflicts having two versions of the Stripe PHP library installed. With this patch applied to Ubercart Stripe, plus a patch I'm working on for Webform Stripe, the two should be able to play nicely.
Comment #7
rfayI haven't tested yet, but just reading the patch had a couple of questions:
Is the removal of 'lines => 500' intentional?
Could you comment on why the change from 'card' to 'source'? Is it compatible with both versions?
Comment #8
joelstein commented1) Well, the VERSION file included with the Stripe PHP library is only one line long, so I figured it wasn't needed.
2) Some time ago, Stripe changed their API to expect a 'source' attribute rather than 'card', since they now accept non-credit card payments (like Bitcoin). But I tested this setting with both versions of the Stripe PHP library and it worked. Also, in their changelog it shows that the use of the 'source' attribute predates the version of the Stripe API currently used by Ubercart Stripe.
Comment #9
rfayThanks, excellent.
I tested and had just one problem, the caching of the stripe library item, which caused failure trying
So in this patch I added a hook_update_N() to clear that cache item, and updated the README.txt slightly to specify appropriate versions of the PHP library.
I did not test recurring transactions...
Comment #10
joelstein commentedThanks! I tested recurring transactions and the API hasn't changed in this regard.
Comment #12
rfayCommitted #9, thanks.
Comment #13
rfayThere are still 2 problems remaining with this. The 'versions' key is inexplicably deleted in libraries_detect(), so it's not always available.
1. That means that uc_stripe_requirements() runs into a failure to load *sometimes* in
if (!array_key_exists($php_api_version, $info['versions'])) {2. _uc_stripe_prepare_api() may run into trouble trying to get $library['stripe_api_version']
3. libraries_detect() accepts any version higher than the specified version. So our uc_stripe_requirements() *does* do its job to make sure that one of the two required versions i there. But it must be noted that the libraries module does *not* handle this for us.
Normally these situations are resolved by a couple of cache clears and reloads. But they're annoying.
Basically, the fact that we're stashing information in the 'versions' key and expecting to get it (and expecting to find the acceptable library version in there) is a #fail.
Comment #14
rfayOne fairly ugly way to handle this is to call uc_stripe_libraries_info() directly and get the specified info that way. It seems ugly, like we're just storing the information in the wrong place.
Comment #15
rfayWell, here's the approach suggested in #14. Would sure like something prettier.
I can't understand why libraries module deletes the 'versions' key.
Comment #16
rfayHere's a simpler version which accomplishes more with less effort. It turns out that the stripe_api_version key does get copied from the 'versions' key over to the main array based on the version selected. We still have to be more rigid than libraries module about the explicit api required, so have to call our function directly, but this one is a lot less code.
Comment #17
jamesoakleyIt looks like the commit at #9 got included in the 7.x-2.1 point release, even though the problems in #13 surfaced later. Is that going to cause problems for people using 7.x-2.1?
Comment #18
rfayThat would mean the dev was wrong all this time. Would appreciate a patch to fix, since sounds like it needs it.
Comment #19
rfayActually, it looks like #16 just needs to be reviewed and committed.
@JamesOakley if you could review it we can get it in. Now that I remember this, it seems that it was resolved by some cache clears and stuff, but could annoy people.
Comment #20
jamesoakleyI've known this patch needs reviewing for some time, but I've always felt I don't understand enough about the libraries module to know what I'm looking for to be sure the problem from #13 is definitely fixed.
Comment #21
rfayJust testing #16with both versions of Stripe PHP API would be adequate, IMO.
Comment #22
jamesoakleyIf you're happy with this being reviewed at that level, then I'll try and spin up my test instance at the weekend and give both a go.
Given the original problem you encountered was:
any suggestions to rule out that occurring at some point after my simple test that the module works with both versions of the library?
Comment #23
rfayPretty sure this would be a reasonable approach:
* Install one version of the Stripe PHP library, then visit the admin/reports/status page & see if it shows right version, then try a transaction, see if it succeeds
* Install the other, same approach
* Install an unsupported version, see if it gets detected correctly
You may need drush cc in there, and the instructions still say that loudly.
THANKS!
Comment #24
jamesoakleyIn that case, this is now RTBC
Everything worked as it should with 2.2.0 and with 3.13.0 - an order went through correctly and appeared in my Stripe Test Mode dashboard, and the Drupal Admin Status page shows that a supported Stripe library is installed.
When I installed 2.3.0, an order still went through correctly, but the Status page shows that the Stripe library is an unsupported version.
However, when I installed 3.11.0, I got WSOD when I tried to place an order, and (more seriously) when I tried to view the status page. The PHP error log entry read:
PHP Fatal error: Class 'Stripe\StripeObject' not found in /home/{snip}/public_html/sites/all/libraries/stripe/lib/ApiResource.php on line 5In other words, when the version is being checked, I think it's assuming that it's Stripe library 2.x unless it 3.13.0 is exactly what we've got. So wrong versions on the 3.x Stripe branch cause a PHP error rather than reporting the problem elegantly within the status page UI.
However, I still think this issue is RTBC. I've checked without the patch at #16, and the same WSOD occurs with wrong Stripe Library 3.x versions, so this is not a regression with the patch I'm reviewing. So I'd say: commit this, because it makes Stripe 3.x being supported into a more stable feature, and people will be using this now that 7.x-2.1 is released. I've opened a separate issue about reporting unsupported 3.x versions: #2760139: Unsupported 3.x Stripe Library versions cause an error rather than reporting the problem on the Status page
Comment #26
rfayCommitted #16 - Thanks so much for the review and for all your involvement here @JamesOakley.
Comment #27
rfay