Schema for setting up a monthly subscription - ruby-on-rails

I have an app which lists venues. Each venue can be either free or premium and so have different privileges. I would like to be able to link the premium upgrade to a payment but am struggling with how to do it.
Im pretty sure I'll end up using chargify or spreedly for the payments but what should the schema look like?
I'm thinking a monthly subscription would be best so should I set up another table of subscriptions and have a record generated each time a subscription is created or amended? So a venue would have many subscriptions and would it be sensible for each subscription record to have a boolean expired field with switches 28 days after it is generated?.
Thanks for any help.

Use Stripe. It integrates very well with Rails and has incredible (and sensible) documentation. Ryan Bates also did an excellent RailsCast on integrating Stripe with Rails, and his example is for a monthly subscription so you should be able to just follow along.
http://railscasts.com/episodes/288-billing-with-stripe

In the SaaS Rails Kit here's what I have:
Account (loaded by subdomain) has_one Subscription
Subscription has a datetime field, next_renewal_at, which gets set a month ahead every time billing happens successfully.
SubscriptionPayment (belongs_to Subscription) gets created every time a successful billing happens.
I don't know why your Venue would have many Subscriptions, but basically in my approach each Subscription has a billing token (provided by Stripe) that is used for charging a credit card.

Related

How to send payment to the customer from Stripe account using API in Rails?

One of my client Ruby on Rails project have a functionality of get payment from customer in his stripe account.
Now, He needs to pay that payment to the item owner after deducted commission. So, how we can pay from stripe account to particular customer account using API in Rails?
I have checked many API's but not clear which exactly use for it.
Any one have a idea or experience in it?
Thanks
See the Stripe guide on Using Checkout with Rails.
I am not positive if a customer token can be used to send funds to, but if so or not, the following still applies.
If the customer has a connected account (or customer token), you can then use "transfer" to transfer the funds to them.

App pay - multiple payees (payment receivers)

I am new to the payment area in app. Say in an App like Ritual or Open Table, I want the end user to be able to pay to multiple payees (just like the two apps I mentioned that you can pay to any listed restaurants), how can I achieve that?
From what I understand, each payee could have an merchant ID. If I want to make payment to multiple payees, do I have to obtain all their merchant ID? Or do I collect payment and then transfer to each payees?
Or, is it as app developers, we pick a payment solution (like Stripe or Braintree), and ask the participating restaurant to provide their bank info for receiving payment, and when the end users are paying, they pay directly to the restaurant's bank account through the payment solution.
Thanks.
Not sure if I understand this, why do you need multiple payee? Isn't the customer would just pay he merchant? As long as you can get the merchant ID and their account number, there should not be any issue. No?
Never mind the question, it's basically what I described in the last paragraph of my question
Blockquote
As app developers, we pick a payment solution (like Stripe or Braintree), and ask the participating restaurant to provide their bank info for receiving payment, and when the end users are paying, they pay directly to the restaurant's bank account through the payment solution.

Braintree - How can I transfer funds to another customer

Hello I am integrating braintree in my rails app. I have two roles and one of them pays the amount with a sale transaction to the merchant account. But my scenario is like that I have to then give some of the share to another user for which of course I need to transfer funds to that user account.
Can anyone tell me how am I suppose to do that?
There is a product called the Braintree Marketplace that might solve your problem. The only issue here is that your other user would need to be signed up as a sub-merchant.

Integrating Paypal Rest SDK into Rails app --

I'm a fairly new developer and this is my first time integrating a rest API with an app. The goal is to implement a subscription process where a user can select from a choice of 4 subscriptions and then submit a payment through Paypal or stripe, but I'm struggling to understand how PayPal's rest API works. I've read their documentation and looked at some examples which gave me an idea of where to start. However, I had a few questions that I couldn't seem to find the answer to online:
Are subscription plans that are created through the rest API permanently associated with the account they have been created on?
If they are permanent, how can I avoid hardcoding the Plan ID? This seems like bad practice even though it is done in some of the examples.
When should I be generating new tokens? Every time they expire? Every time a user wants to subscribe to a plan?
How do I automatically execute agreements after they have been created? (I assume executing the agreement is what makes it active and begins the collection of payment).
Thanks, it would be nice to get some clarification on some of this stuff.

Is it possible to use koudoku for one-time payments?

This post references: https://github.com/andrewculver/koudoku
I'd like to use Koudoku for one time payments as opposed to recurring billing. I do not see any way to do this.
Koudoku is specifically designed for recurring subscriptions.
If you're just looking to do one-off payments, I recommend just following the standard Stripe tutorial for a payments page.
To support returning customers or additional purchases, I recommend simply using Devise for authentication and then saving whatever the resulting Stripe customer ID is from the first purchase in the user model, so you can run additional charges against the same card in the future.

Resources