I would like to accept payments on my NextJS + Rails (backend) application. The Rails backend handles bookings and has a few tables (user, bookings, etc). I want it to be as 'easy' as possible so Stripe Checkout seems to be a good fit.
However, I struggle to understand if I need to set up Stripe only using NextJS (front + NextJS API), or if I should do the backend part using the Rails server.
The Stripe docs only show the Stripe set up with NextJS (front) and NextJS api.
Thanks in advance for your help!
Hello 👋🏻 While the term “easy” is subjective, I think Stripe Checkout with Prebuilt Checkout page flow would be an ideal choice. It has a pretty solid guide to get started [1] as well as it requires a lot less code and offers various customization options.
All you have to do is;
Build a form on your NextJS frontend that makes a POST request on your backend
Build a route on your rails app that creates a Stripe Checkout session [2]
Then redirect the users to the Stripe hosted
checkout page
Stripe will take care of accepting the payments and sending users back to your app [3].
While there are no official example docs on Stripe Integration with Rails, you can tweak the Ruby + Sinatra snippets to fit into your rails app.
[1] https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=checkout
[2] https://stripe.com/docs/api/checkout/sessions/create?lang=ruby
[3] https://stripe.com/docs/api/checkout/sessions/create?lang=ruby#create_checkout_session-success_url
[4] https://stripe.com/docs/api/checkout/sessions/create?lang=ruby#create_checkout_session-cancel_url
[5] https://stripe.com/partners/pay-rails
Related
I am building a Ruby on Rails (Rails - v4.2.3 & Ruby 2.2.2) App which consumes an existing REST API.
The aforementioned API is written in PHP.
I need help regarding how to manage the authentication?
On searching through various forums I came across these two gems
https://github.com/lynndylanhurley/devise_token_auth
https://github.com/gonzalo-bulnes/simple_token_authentication
The problem I am facing with both is that they require my app to have a users model configured (using Devise).
However My app is primarily a front end for the Existing REST API, so if I do configure my own User model, I will end up with two Data Stores (One for the APP I make and the other for the existing API).
I wish to consume the external API and not have any native models for my APP.
I believe I can use ActiveResource for this (I need more reputation points to post a link to the gem, sorry I cannot do that right now, I am new to StackOverflow):
However I am not sure how to go about managing the security of the application. More specifically what measures can I take to prevent the authentication information from being viewed in plaintext while it is being transmitted to my API server for authentication?
Thank You.
Use HTTPS on your API. If your external API is using HTTPS then user info wouldn't be sent in plaintext from your rails app.
Don't forget to use HTTPS for your rails app too, as that is more important.
I would like to integrate stripe payment system to my octopress blog. The problem is that octopress is used to build static web sites, and integration stripe requires to add new Controllers (dynamic) to handle user payments.
how can I add such a controller without breaking the octopress file structure.
regards,
I'm not familiar with octopress. But I'm assuming it's similar to Wordpress, and whenever I want to use rails functionality on a wordpress application, I create a subdomain that points to my rails app using a service like dnsimple.
So if someone visits railsapp.mywebsiteurl.com they will receive a response from my rails application. However, if someone visits www.mywebsiteurl.com they will get a response from octopress.
I'm trying to achieve an integration between a Rails app (the core of my website, at domain.com and www.domain.com) and a Wordpress Network (multisite, at *.domain.com).
For that I need to build a Single Sign On process.
I have found a plugin : Rails Integration Api, but i didn't find the article or readme describing the rails part. The process is based on the recuperation of the cookie, created in rails.
So my questions will be :
Do you know any pointers to achieve a Rails - Wordpress SSO integration ?
Do you know some good resources about implementing Wordpress SSO, for any backend ?
Thanks in advance.
That plugin looks like it's looking to the cookie set by your Rails app. If you look at the cookies that are set after you login to that app, do any of them jump out at you as being the auth session cookie?
Also, here's the article referenced in the plugin about configuring the Rails side: http://web.archive.org/web/20090116063054/http://greenfabric.com/page/integration_api_home_page
It looks like it's been defunct for a while (only available thru archive.org) but maybe that will help you put the puzzle together.
Here's a blog post outlining setting up Wordpress as an Oauth provider and authenticating a rails application against it. http://www.objectpartners.com/2014/02/18/single-sign-on-with-rails-wordpress-and-oauth2/
I want to create a public live chat application using rails 3.
I found some example on rails 2. Any one can tell you a good example / tutorial to develop a live chat application using rails 3.
I encountered several roadblocks as I tried to implement a public and private chat system in my rails 3 app. I looked at faye, juggernaut, node.js and more. Eventually after trying several approaches I was able to implement a system that works great:
1) I started by following the video guide to faye messaging in Railscast 260 as mentioned by Devin M. I was able to quickly setup a rails app that persisted messages, and a chat server that pushed these new messages out to all the clients. The biggest problem was security. I had no control over access to the chat server.
2) This lead me to using the private pub gem by Ryan Bates in Railscast 316 - which helps to secure your faye server by verifying the client's signature. This worked for securing the server but I ran into issues trying to verify the actual user with my authentication system and adding 'who's online' functionality. I worked on a hack of private pub to pass in the user details when authenticating but could not get things to work smoothly.
3) In the end I decided to move the chat server to pusher - a hosted API for real-time apps. I followed this tutorial on how to create a real-time survey in rails to get a feel for how to set things up. Although not directly about setting up a chat system - this tutorial along with what I had already setup from the Railscasts above (and the easy-to-read pusher docs), allowed me to quickly setup a secure rails 3 chat app - complete with authentication, 'who's online', status messages and more. The best part is...I don't have to deal with managing the chat server.
Hope this helps someone going through the same process as me.
You can get the basics down with Railscast 260, I assume a background in Rails/Ruby already and some knowedge of jQuery/JavaScript. The screencast has a text version here and the source is here, it's also on GitHub.
I'd start by checking out Ilya Grigorik's em-synchony + examples and looking at the code for the Hector private chat server gem.
I am wondering how to integrate node.js on a rails app (for learning purpose).
Based on Michael Hartl tutorial (http://railstutorial.org/) I realized a basic twitter clone with rails and want to get user microposts in real-time without the use of comet or juggernaut. (the application is hosted on heroku)
For the moment, I only see example with node.js frameworks (http://howtonode.org/grasshopper-shoutbox) but nothing merged with a ruby on rails app.
I would be very thankful if someone knows a good tutorial or give me some points to start in order to accomplish this.
Thanks!
As Shripad said, I'd consider trying to build your app with Node by itself. Geddy will feel familiar (getting started anyway) if you have experience with Rails. Note: I do not have experience on a real world app with Geddy, but it is the best Rails-like framework I've seen so far. For persistence you can use SQLite, PostgreSQL or CouchDB, just like you would with Rails. I thought about how to communicate between a Rails app and Node without any intermediary. In our work project we're using Redis as an intermediary between Rails and Node. Rails publishes messages to Redis, Node pulls messages from Redis. I could not find a good way or example projects to avoid the middle communication layer on a personal project, so I went with the same setup. The good news is Node Redis modules are written and once you get everything installed, it is easy to test out pushing messages back and forth.
If you are looking at creating real-time apps then go with node.js (high concurrency) alone. You really cannot integrate node.js into a rails app. You can however have a node server setup on another port with an api and websockets configured and then have your rails app communicate with that server. It is PITA to do that kind of setup. You rather build the entire web app in node itself. However, if you want anything rails specific that does not use juggernaut then i would suggest http://www.pusherapp.com.
Its extremely easy to setup server push using Pusher.
It already did. Not really NodeJs but a framework built on top if it. Yada, yada, yada... check this out: https://github.com/1602/express-on-railway
**Run node along side your rails server**
If you want to intergrate your Rails app with Node you could use the node-rails gem
Node Rails will enable you to run a Node server along side your Rails application and have the two share authentication NodeRails assumes you are using Devise for your authentication. Node-Rails uses [redis gem][2] , so you will need to have that installed.
Learn more about using npm packages on Rails.