Open Source Payments Enabled via Stripe Connect

Hey guys - I’ve been working on a Sharetribe site for a client for a few months. One of the biggest challenges is integrating a payment system.

Stripe Connect looked to be the perfect solution as it allows marketplace integration where sellers can receive money into their own Stripe accounts (and you receive a fee) without your app having to deal with the flow of cash.

I’ve got a basic setup, which I’ll try my best to maintain inline with Sharetribe updates here on github.

This can serve as a good start if you need to use the open source version of Sharetribe. Disclaimer: use at your own risk - this integration is not as solid as the Paypal integration Sharetribe has built, and you are likely to come across bugs.

I’d love to see this become a collaborative effort among Sharetribe OS developers, with pull requests for new features and bug fixes. There are many features we can build that could potentially feed back into the main Sharetribe OS, so I would love to see some pull requests / suggestions for anything you build on top of it!

Credit to developer Shoaib Malik for his work on this integration.

9 Likes

This is a fantastic attitude, thanks for sharing. I’m gonna try this, test, and collaborate the best I can. My goal is to implement the managed accounts, so, this is a welcome first step. Congratulations!

Awesome! Yeah managed accounts would be great to implement, it looks to be a really robust system.

This implementation does not have testing built in at this stage, but yeah it’s definitely a start!

Hi Jarvis,
I did install, but I could’t create new listing (user or admin), and the page turns all blank. At the console it is possible to see an GET error resulting to a 500 internal server error.

About the stripe connect integration, It looks it was able to connect via oauth at the first time.

Could you check this error?

thanks

Will have a look mate

It looks like there is a problem with this method currency at the file app/views/listings/form/_price_currency.haml

So, I’ve changed the references to this file back to the original one bellow, and the form is working again:
listings/form/currency_selector

Do you think I’m gonna have problem in future with stripe integration keeping this solution?

bellow the firebug response log:

NoMethodError at /pt-BR/listings/new_form_content

undefined method `currency' for #<Community:0x007fb6131518e8>

app/views/listings/form/_price_currency.haml, line 2

    1   .price-currency
>   2     = Money.new(1, @current_community.currency).symbol

App backtrace

  • app/views/listings/form/_price_currency.haml:2:in `_app_views_listings_form__price_currency_haml__3584991212720584972_70209991509900’

  • app/views/listings/form/_price.haml:5:in `_app_views_listings_form__price_haml__914039169557392058_70209988384200’

  • app/views/listings/form/_form_content.haml:5:in `block in _app_views_listings_form__form_content_haml___3512097573837912441_70209966650260’

  • app/views/listings/form/_form_content.haml:3:in `_app_views_listings_form__form_content_haml___3512097573837912441_70209966650260’

  • app/controllers/listings_controller.rb:663:in `form_content’

  • app/controllers/listings_controller.rb:267:in `new_form_content’

  • lib/jsroutes_middleware.rb:48:in `call’

  • lib/rack_middleware/marketplace_lookup.rb:33:in `call’

  • lib/rack_middleware/custom_cookie_renamer.rb:11:in `call’

  • lib/rack_middleware/enforce_ssl.rb:23:in `call’

Hey mate - yep that’s right, thanks for flagging.

That’s fixed now.

No, there shouldn’t be any more references to “currency”, only “default_currency”, so you should be good to go.

youre welcome!

before you return, I’ve followed one more error with listing not showing up, but being recorded at db. I’ve found a new if show_manage_availability script at line 173 in /app/views/listings/_listing_actions.haml, just commented, and everything went right.

just to let you know, now I’ve followed your tips and changed for the correct method mentioned, and got another error. This time, the listing won’t be recorded at DB and a new error came up from the file /app/view_utils/listing_form_view_utils.rb:30 , with the :currency_required symbol.

I can’t figure out what is this, maybe something with the currency automated process when the language/ country is changed? I saw that you put AUD as default in this case, and I have to change to BRL directly in the DB.

regards

First of all, thanks for sharing the Stripe integration, I really appreciate it :smile:

I was trying your code in my local, added the API keys in the admin section, and everything is fine.

But when I try to connect with my Stripe account, I keep getting the following error:

What I’ve tried:

@Jarvis_Johnson What am I doing wrong? :frowning:

Thanks in advance!

this works for me, give a try:
http://localhost:3000/connect/oauth
http://localhost:3000/connect/confirm

1 Like

IT WORKS, THANK YOU! :smiley: You rock man!

I get the currency_required method when I try to create a listing, but I’ll check the code if I can find something about that. I’ll update if I find the error.

EDIT: Nvm, the error was because I didn’t add a bank account where I’ll receive the payments.

Yep that’s right - /connect/confirm

I’ll update that in the README.

Also, working on the issues with currency. Thanks for pointing those out. I’ll let you know when sorted.

Cheers

Thanks, nice to hear!

For the currency issue, you are missing the following commit in your branch. 788b17b92588dea88804845278862ef8dc966453

Cheers

Yep - few migrations missing there.

The code relied on ‘default_currency’, but that’s all removed in favour of ‘currency’.

All should be fixed now, so checkout the latest commit.

Thanks guys

Very good Jarvis! Tks!

1 Like

thanks for this - having a nightmare as a non techie figuring out the stripe integration intricacies!

2 Likes

@Jarvis_Johnson Have you had a chance to play with the new top bar? I’m getting a prerender error whenever I try to enable it. I’ve not been around long enough to follow the development process that resulted in the new top bar - any light you can shed?

ERROR in SERVER PRERENDERING
when prerendering TopbarApp with props: {"logo":{"href":"/","text":"Name","image":null,"image_highres":null},"search":{"search_placeholder":null,"mode":"keyword"},"search_path":"/","menu":{"links":[{"link":"/","title":"Home","priority":-1},{"link":"/en/infos/about","title":"About","priority":0},{"link":"/en/user_feedbacks/new","title":"Contact us","priority":1},{"link":"/en/invitations/new","title":"Invite new members","priority":2}],"limit_priority_links":null},"locales":{"current_locale_ident":"en","current_locale":"en","available_locales":[{"locale_name":"English","locale_ident":"en","change_locale_uri":"/change_locale?locale=en\u0026redirect_uri=admin%2Fnew_layout"}]},"avatarDropdown":{"avatar":{"image":null,"givenName":"D","familyName":"D"}},"newListingButton":{"text":"Post a new listing"},"i18n":{"locale":"en","defaultLocale":"en"},"marketplace":{"marketplace_color1":"#4a90e2","location":"/en/admin/new_layout"},"user":{"loggedInUsername":"user","isAdmin":true},"unReadMessagesCount":0}
js_code was:
(function() {
var railsContext = {"inMailer":false,"i18nLocale":"en","i18nDefaultLocale":"en","href":"url","location":"/en/admin/new_layout","scheme":"http","host":"url","port":null,"pathname":"/en/admin/new_layout","search":null,"httpAcceptLanguage":"en-GB,en-US;q=0.8,en;q=0.6","marketplaceId":1,"loggedInUsername":"blaked","marketplace_color1":"#4a90e2","marketplace_color2":"#2ab865","serverSide":true};

var props = {"logo":{"href":"/","text":"name","image":null,"image_highres":null},"search":{"search_placeholder":null,"mode":"keyword"},"search_path":"/","menu":{"links":[{"link":"/","title":"Home","priority":-1},{"link":"/en/infos/about","title":"About","priority":0},{"link":"/en/user_feedbacks/new","title":"Contact us","priority":1},{"link":"/en/invitations/new","title":"Invite new members","priority":2}],"limit_priority_links":null},"locales":{"current_locale_ident":"en","current_locale":"en","available_locales":[{"locale_name":"English","locale_ident":"en","change_locale_uri":"/change_locale?locale=en\u0026redirect_uri=admin%2Fnew_layout"}]},"avatarDropdown":{"avatar":{"image":null,"givenName":"D","familyName":"D"}},"newListingButton":{"text":"Post a new listing"},"i18n":{"locale":"en","defaultLocale":"en"},"marketplace":{"marketplace_color1":"#4a90e2","location":"/en/admin/new_layout"},"user":{"loggedInUsername":"D","isAdmin":true},"unReadMessagesCount":0};
return ReactOnRails.serverRenderReactComponent({
    name: 'TopbarApp',
    domNodeId: 'topbar-container',
    props: props,
    trace: true,
    railsContext: railsContext
});
})()

console messages:

<script>
console.log.apply(console, ["[SERVER] RENDERED TopbarApp to dom node with id: topbar-container with railsContext:","{\"inMailer\":false,\"i18nLocale\":\"en\",\"i18nDefaultLocale\":\"en\",\"href\":\"http://url/en/admin/new_layout\",\"location\":\"/en/admin/new_layout\",\"scheme\":\"http\",\"host\":\"url\",\"port\":null,\"pathname\":\"/en/admin/new_layout\",\"search\":null,\"httpAcceptLanguage\":\"en-GB,en-US;q=0.8,en;q=0.6\",\"marketplaceId\":1,\"loggedInUsername\":\"blaked\",\"marketplace_color1\":\"#4a90e2\",\"marketplace_color2\":\"#2ab865\",\"serverSide\":true}"]);
console.error.apply(console, ["[SERVER] Exception in rendering!"]);
console.error.apply(console, ["[SERVER] message: touchClass is not defined"]);
console.error.apply(console, ["[SERVER] stack: ReferenceError: touchClass is not defined\n    at AvatarDropdown.render (<eval>:60910:87)\n    at <eval>:22956:22\n    at measureLifeCyclePerf (<eval>:22237:13)\n    at ReactCompositeComponentMixin._renderValidatedComponentWithoutOwnerOrContext (<eval>:22955:28)\n    at ReactCompositeComponentMixin._renderValidatedComponent (<eval>:22982:35)\n    at ReactCompositeComponentMixin.performInitialMount (<eval>:22524:31)\n    at ReactCompositeComponentMixin.mountComponent (<eval>:22420:22)\n    at Object.ReactReconciler.mountComponent (<eval>:13145:36)\n    at ReactDOMComponent.ReactMultiChild.Mixin.mountChildren (<eval>:21560:45)\n    at ReactDOMComponent.Mixin._createContentMarkup (<eval>:17167:33)"]);
</script>

Is this in the Stripe Connect version? Either way, I’m wondering if you aren’t using the Webpack build (bundle exec foreman start -f Procfile.hot)? That should take care of building that topbar as it is built in React and needs Webpack to load.

That’s my thought but I’m not a master with the React side of things :joy:

This is fixed now; I’ve merged Sharetribe latest version (6.2) into Sharetribe-Stripe-Connect as well