-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adds is_sponsorere field for sponsors[#276] * Displays sponsor button on all webpages[#276] A floating Sponsor button is displayed on homepage as well as at the right side of each page if user is not sponsorer * Adds mongoid-paperclip gem for image upload[#276] * Defines routes for sponsorer detail[#277] * defines payment plans for sponsor[#277] * creates sponsorer details model[#277] * creates viewes for sponsor[#277] * testcases for sponsor detail model[#276] * Sponsorer need not to set goal on signup[#276] * triggers the button click on sign up of sponsor[#276] * creates controller for sponsorer detail[#276] * test cases for sponsorer details controller[#276] * modifies partial for sponsor button[#276] * helper for sponsorer detail[#276] * creates sidebar for sponsor[#276] * Associates user model with sponsorer detail[#276] * github signup of sponsor and it's testcases[#276] * Ignores local storage of sponsor profile photos[#276] * Adds stripe gem for recurring payments[#276] * Configures stripe keys for application[#276] * Changes in SponsorerDetail model[#276] changes the type of payment plan from integer to string, adds some extra fields for subscription and changes in validations * Changes the names of SPONSOR config variables[#276] * Modifies sponsorship details form to add stripe checkout[#276] * Creates stripe customer and subscription[#276] * Modifies sponsor dashboard, sidebar and profile[#276] * Adds route for stripe webhook[#276] * Creates stripe controller for handling stripe events with webhook[#276] * Creates mailer to notify sponsor[#276] * Sends an email on payment failure to sponsorer[#276] * Modifies stripe subscription creation[#276] Creates subscription and customer on stripe by one function call only instead of creating it separately * Skips set goal for sponsorer[#276] * Adds validations for stripe subscription details[#276] presence validation on stripe customer id, subscription id, status etc. * client side validation for image upload[#276] verifies whether uploaded file is image only * Replaces create.js.haml with create.html.haml[#276] * Adds update credit card functionality for sponsore[#276] Sponsor can update his credit card details * Minor changes in sponsor index and omniauth controller[#276] * Adds route for updating credit card[#276] * Modifies sponsorer_details factory[#276] * Adds stripe_ruby_mock gem for testing stripe[#276] * Removes presence validation on stripe details[#276] Form is validated before creating stripe subscription so removed the validation on these fields * Shows subscrption details on sponsor index page[#276] Earlier subscription details were shown on users profile page * Adds route for cancel subscription[#276] * Allowes sponsorer to cancel subscription[#276] * Modification in sponsorer detail testcase[#276] * Functional test cases for SponsorerDetail[#276] * Creates Payment model[#276] Stores the details of monthly payment * Creates association between sponsorer detail and payment[#276] * Handles stripe events[#276] * Shows payment details of sponsor[#276] * Optimizes the stripe controller[#276] * Saves payment details of sponsorer[#276] Saves payment detail when invoice payment succeded event triggers * Adds validations for payment model * Minor modifications in sponsorer controller[#276] * Moves subscription deletion code to concern[#276] * Cancels subscription while deleting account[#276] If user is sponsorer and tries to delete his account first cancel his subscription and then delete his account * Creates partial for mail signature[#276] * Yields the mail signature within layout[#276] * Renders the mail signature in the mailers[#276] * Uses different mail signature for sponsor mailer[#276] * Minor changes in sponsor's functional testcase[#276] * Testcase scenarios for stripe controller[#276] * Fixes the javascript reference error[#276] Fixes the error that was causing to fail integration test cases * Fixes the failure and error in test cases[#276] * Fixes the pagination of sponsorer payment details[#276] * Fixes failing test cases of sponsorer detail[#276]
- Loading branch information
1 parent
c82c6d9
commit 128a74c
Showing
65 changed files
with
1,088 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Place all the behaviors and hooks related to the matching controller here. | ||
# All this logic will automatically be available in application.js. | ||
# You can use CoffeeScript in this file: http://coffeescript.org/ | ||
|
||
$(document).on "ready", -> | ||
$('body').on 'change', '.sponsorer_detail_avatar', () -> | ||
inputFile = $(this).val(); | ||
validateFiles(inputFile); | ||
if window.location.pathname == '/sponsorer_details' | ||
showmodal(); | ||
|
||
showmodal = () -> | ||
if modal == "true" | ||
$("#rotate").click(); | ||
|
||
validateFiles = (inputFile) -> | ||
extErrorMessage = 'Only image file with extension: .jpg, .jpeg, .gif or .png is allowed' | ||
allowedExtension = [ | ||
'jpg' | ||
'jpeg' | ||
'gif' | ||
'png' | ||
] | ||
extName = inputFile.split('.').pop() | ||
extError = false | ||
if $.inArray(extName, allowedExtension) == -1 | ||
window.alert extErrorMessage | ||
$(inputFile).val '' | ||
$(this).val '' | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Place all the behaviors and hooks related to the matching controller here. | ||
# All this logic will automatically be available in application.js. | ||
# You can use CoffeeScript in this file: http://coffeescript.org/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Place all the styles related to the SponsorerDetails controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Place all the styles related to the stripe controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module SponsorerHelper | ||
def createStripeCustomer(email, token, plan) | ||
Stripe::Customer.create( | ||
:email => email, | ||
:source => token, | ||
:plan => plan | ||
) | ||
end | ||
|
||
def delete_subscription(subscription_id) | ||
Stripe::Subscription.retrieve(subscription_id).delete | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
class SponsorerDetailsController < ApplicationController | ||
include SponsorerHelper | ||
require "stripe" | ||
# after_action :set_sponsorer, only: [:create] | ||
before_action :authenticate_user! | ||
# before_action :authenticate_sponsor!, except: [:new, :create] | ||
skip_before_action :select_goal | ||
before_action :load_sponsorer, only: [:update_card, :cancel_subscription] | ||
|
||
def index | ||
@user = current_user | ||
@sponsor = @user.sponsorer_detail | ||
if @sponsor | ||
@card = SponsorerDetail.get_credit_card(@sponsor.stripe_customer_id) | ||
@payments = @sponsor.payments.page(params[:page]) | ||
end | ||
end | ||
|
||
def new | ||
@sponsorer_detail = SponsorerDetail.new | ||
end | ||
|
||
def create | ||
@sponsorer = SponsorerDetail.new(sponsorer_params) | ||
@sponsorer.user_id = current_user.id | ||
if @sponsorer.valid? | ||
begin | ||
plan_id = @sponsorer.payment_plan+"-"+@sponsorer.sponsorer_type.downcase | ||
|
||
customer = createStripeCustomer(current_user.email, params[:stripeToken], plan_id) | ||
|
||
@sponsorer.stripe_customer_id = customer.id | ||
|
||
subscription = customer.subscriptions.data.first | ||
@sponsorer.stripe_subscription_id = subscription.id | ||
@sponsorer.subscribed_at = Time.at(subscription.created).to_datetime | ||
@sponsorer.subscription_expires_at = Time.at(subscription.current_period_end).to_datetime | ||
@sponsorer.subscription_status = subscription.status | ||
rescue Stripe::StripeError => e | ||
flash[:error] = e.message | ||
else | ||
if @sponsorer.save | ||
SponsorMailer.notify_subscription_details(@sponsorer.user_id.to_s, @sponsorer.payment_plan, SPONSOR[@sponsorer.sponsorer_type.downcase][@sponsorer.payment_plan]).deliver_later | ||
redirect_to sponsorer_details_path #sponsorer dashboard | ||
flash[:notice] = "saved sponsorship details successfully" | ||
end | ||
end | ||
else | ||
flash[:error] = @sponsorer.errors.full_messages.join(',') | ||
end | ||
end | ||
|
||
def update_card | ||
begin | ||
customer = Stripe::Customer.retrieve(@sponsor.stripe_customer_id) | ||
customer.source = params[:stripeToken] | ||
rescue Stripe::StripeError => e | ||
flash[:error] = e.message | ||
else | ||
customer.save | ||
flash[:notice] = 'Your card has been updated successfully' | ||
end | ||
redirect_to sponsorer_details_path | ||
end | ||
|
||
def cancel_subscription | ||
begin | ||
delete_subscription(@sponsor.stripe_subscription_id) | ||
rescue Stripe::StripeError => e | ||
flash[:error] = e.message | ||
else | ||
flash[:notice] = "Your subscription has been cancelled successfully" | ||
end | ||
redirect_to sponsorer_details_path | ||
end | ||
|
||
private | ||
|
||
def sponsorer_params | ||
params.require(:sponsorer_detail).permit! | ||
end | ||
|
||
def load_sponsorer | ||
@sponsor = SponsorerDetail.find_by(user_id: params[:id]) | ||
end | ||
end |
Oops, something went wrong.