Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements and updates from Bullet Train #194

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

andrewculver
Copy link
Owner

People frequently ask whether Koudoku is still maintained because master hasn't received much attention for a long time. Many people are still actively using Koudoku, but most of my personal efforts with development on it are now limited to keeping it working well in the context of Bullet Train specifically. This work is much easier for me and much less time consuming because I control so much more of the context of the apps that are built on top of Bullet Train (e.g. Rails version, Devise, CanCanCan, Bootstrap, UI, etc.) It also doesn't hurt that I'm compensated financially by folks who run into issues or need new features (e.g. the support we recently added for Rewardful and Link Mink affiliate programs.)

I've kept many of these updates in a separate branch until now. In the short term, this PR can help people understand which things have changed in the bullet-train branch of Koudoku. It's possible that using this branch will help Koudoku work better in modern Rails apps, but I can't be sure because the only modern Rails apps I work on anymore are Bullet Train-based.

The only thing not included in this branch are lots of modifications and customizations made to the .html.erb views. All of those are specific to Bullet Train's UI CSS and are only contained in the private Bullet Train repo. I have no idea off the top of my head what state the views in this repository are in, or which version of Bootstrap they use, etc. If someone wants to provide fixing updates for the latest version of Bootstrap, please send a PR!

@andrewculver andrewculver self-assigned this Oct 16, 2018
@andrewculver
Copy link
Owner Author

Also, if you run into any trouble using this branch, the only other customizations (other than the views) that are in the Bullet Train repo would be around the Subscription model. Here's what it currently looks like in Bullet Train:

class Subscription < ActiveRecord::Base
  include Koudoku::Subscription

  belongs_to :team
  belongs_to :coupon, optional: true

  def active?
    plan.present?
  end

  def push_customer_details_to_stripe
    if subscriptions_enabled?
      unless test_record?

        customer = Stripe::Customer.retrieve(self.stripe_id, api_key: ENV['STRIPE_SECRET_KEY'])
        customer.email = team.formatted_email_address
        customer.description = team.billing_name

        # merge metadata as not to overwrite other people's metadata.
        metadata = JSON.parse(customer.metadata.to_s) || {}
        metadata.merge!(team.stripe_metadata)
        customer.metadata = metadata

        customer.save

        # also update the subscription quantity.
        customer.update_subscription({
          plan: self.plan.stripe_id,
          prorate: Koudoku.prorate,
          quantity: team.subscription_quantity,
        })

      end
    end
  end

  def test_record?
    self.stripe_id == 'cus_938yfhrfv7yzs9f8hed'
  end

end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant