Integrating with new Stripe Checkout or Stripe Payment Intents version?

I monetise my forums using a Discourse plugin I wrote to accept payments via Stripe Checkout (version 1).

This was straightforward as Stripe handled the whole payment workflow on the (JavaScript) client-side, with a single callback when the payment succeeded / failed.

With new EU regulations looming, Stripe now mandates their Checkout version 2 implementation, or “Payment Intents”, with a transition deadline of Sept 2019.

This is problematic because (as far as I can see), both of these APIs use a more complex workflow, requiring the consumer to poll their API to wait on payment completion, or use web-hooks.

I’m very nervous about changing my plugin because:

  • I’m not a very experienced Ruby / Ember developer (I ripped most of the code from an existing plugin to create mine)
  • I don’t know whether the Discourse plugin API provides a suitable mechanism for implementing this kind of polling (where the final result is very important)

Does anyone have experience of a) Stripe V2 Checkout or Payment Intents integration with Discourse, or b) handling server polling via a Discourse plugin?

Thanks in advance :+1:

3 Likes

Sounds like you’ll need to ask for donations to get your donations plugin updated. :slight_smile:

I’ve been working on a Stripe plugin myself . And I see it’s v1.

EDIT: Oh!, but maybe I’m on v3: (in plugin.rb):

register_html_builder('server:before-head-close') do
  "<script src='https://js.stripe.com/v3/'></script>"
end

I’m pretty sure that for someone like @angus or @joebuhlig polling and webhooks are not that big a deal, but I’m afraid that I’m about where you are. :frowning:

I’ve been trying to update the Stripe Gem to the latest version like this:

gem 'net-http-persistent', '3.0.1'
gem 'stripe', '4.21.2'

and it is failing like this:

Traceback (most recent call last):
/home/pfaffman/src/discourse/bin/unicorn: Bootsnap::LoadPathCache::FallbackScan
        34: from /home/pfaffman/src/discourse/bin/unicorn:49:in `<main>'
        33: from /home/pfaffman/src/discourse/bin/unicorn:49:in `load'
        32: from /home/pfaffman/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/unicorn-5.5.1/bin/unicorn:128:in `<top (required)>'
        31: from /home/pfaffman/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/unicorn-5.5.1/lib/unicorn/http_server.rb:141:in `start'
        30: from /home/pfaffman/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/unicorn-5.5.1/lib/unicorn/http_server.rb:794:in `build_app!'
        29: from /home/pfaffman/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/unicorn-5.5.1/lib/unicorn.rb:54:in
`block in builder'
        28: from /home/pfaffman/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/unicorn-5.5.1/lib/unicorn.rb:54:in
`eval'
        27: from config.ru:1:in `<main>'
        26: from config.ru:1:in `new'
        25: from /home/pfaffman/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rack-2.0.7/lib/rack/builder.rb:55:in `initialize'
        24: from /home/pfaffman/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rack-2.0.7/lib/rack/builder.rb:55:in `instance_eval'
        23: from config.ru:7:in `block in <main>'
        22: from config.ru:7:in `require'
        21: from /home/pfaffman/src/discourse/config/environment.rb:4:in `<top (required)>'
        20: from /home/pfaffman/src/discourse/config/environment.rb:4:in `require'
        19: from /home/pfaffman/src/discourse/config/application.rb:57:in `<top (required)>'
        18: from /home/pfaffman/src/discourse/config/application.rb:58:in `<module:Discourse>'
        17: from /home/pfaffman/src/discourse/config/application.rb:261:in `<class:Application>'
        16: from lib/discourse.rb:168:in `activate_plugins!'
        15: from lib/discourse.rb:168:in `each'
        14: from lib/discourse.rb:171:in `block in activate_plugins!'
        13: from /home/pfaffman/src/discourse/lib/plugin/instance.rb:490:in `activate!'
        12: from /home/pfaffman/src/discourse/lib/plugin/instance.rb:490:in `instance_eval'
        11: from /home/pfaffman/src/discourse/plugins/lc-billing/plugin.rb:8:in `activate!'
        10: from /home/pfaffman/src/discourse/lib/plugin/instance.rb:564:in `gem'
         9: from /home/pfaffman/src/discourse/lib/plugin_gem.rb:22:in `load'
         8: from /home/pfaffman/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
         7: from /home/pfaffman/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
         6: from /home/pfaffman/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
         5: from /home/pfaffman/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:26:in `require'
         4: from /home/pfaffman/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:40:in `rescue in require'
         3: from /home/pfaffman/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
         2: from /home/pfaffman/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:89:in `register'
         1: from /home/pfaffman/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
/home/pfaffman/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require': cannot load such file -- net-http-persistent (LoadError)

procourse memberships uses 3.28.0, but that’s still making calls to the v1 api.

EDIT: I don’t see a v2 API. API Upgrades | Stripe seems to still show v1. I’ve upgraded to latest according to https://dashboard.stripe.com/test/developers

5 Likes

@ChrisBeach happy to help. If you could create a branch on the plugin and get us started with what you can figure out, I’ll work in / give you some specific pointers to make sure we get over the line before the deadline.

4 Likes

@Angus that is a kind offer that I really appreciate. I’ll let you know when I begin work on the integration.