Skip to content

Commit

Permalink
Merge pull request #3018 from sharetribe/stripe-integration
Browse files Browse the repository at this point in the history
Stripe integration
  • Loading branch information
valdis committed Sep 22, 2017
2 parents 1cbc55f + 4172486 commit df5ceeb
Show file tree
Hide file tree
Showing 151 changed files with 4,675 additions and 672 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -44,6 +44,7 @@ coverage/
*.sock
.vagrant
.env
.session.vim

# React on Rails
npm-debug.log*
Expand Down
1 change: 1 addition & 0 deletions .rubocop_todo.yml
Expand Up @@ -95,6 +95,7 @@ Layout/EmptyLineAfterMagicComment:
- 'app/view_utils/icon_map.rb'
- 'app/view_utils/intercom_helper.rb'
- 'features/support/feature_tests/action/paypal.rb'
- 'features/support/feature_tests/action/stripe.rb'
- 'spec/controllers/listings_controller_spec.rb'
- 'spec/models/community_spec.rb'
- 'spec/services/feature_flag_service/api/features_spec.rb'
Expand Down
5 changes: 5 additions & 0 deletions Gemfile
Expand Up @@ -70,6 +70,7 @@ gem 'stringex', '~> 2.7.1'
gem 'paypal-sdk-permissions', '~> 1.96.4'
gem 'paypal-sdk-merchant', '~> 1.116.0'
gem 'airbrake', '~> 6.1.2'
gem 'stripe', '~> 3.0.0'

gem 'jwt', '~> 1.5.6'

Expand Down Expand Up @@ -144,6 +145,8 @@ group :test do

# required for CircleCI automatic test balancing
gem 'rspec_junit_formatter'

gem 'fake_stripe'
end

group :development, :test do
Expand All @@ -164,3 +167,5 @@ gem 'transit-ruby', '~> 0.8.1'
gem 'redcarpet', '~> 3.4.0'

gem 'intercom'

gem 'twitter_cldr'
31 changes: 31 additions & 0 deletions Gemfile.lock
Expand Up @@ -94,6 +94,7 @@ GEM
builder (3.2.3)
byebug (9.0.6)
callsite (0.0.11)
camertron-eprun (1.1.1)
capybara (2.6.2)
addressable
mime-types (>= 1.16)
Expand All @@ -104,6 +105,7 @@ GEM
childprocess (0.7.0)
ffi (~> 1.0, >= 1.0.11)
chunky_png (1.3.8)
cldr-plurals-runtime-rb (1.0.1)
climate_control (0.2.0)
cocaine (0.5.8)
climate_control (>= 0.0.3, < 1.0)
Expand Down Expand Up @@ -139,6 +141,8 @@ GEM
money (~> 6.7)
sixarm_ruby_unaccent (~> 1.1)
unicode_utils (~> 1.4)
crack (0.4.3)
safe_yaml (~> 1.0.0)
css_parser (1.5.0)
addressable
cucumber (2.4.0)
Expand Down Expand Up @@ -193,6 +197,10 @@ GEM
factory_girl_rails (4.8.0)
factory_girl (~> 4.8.0)
railties (>= 3.0.0)
fake_stripe (0.0.12)
capybara
sinatra
webmock
faraday (0.11.0)
multipart-post (>= 1.2, < 3)
faraday-encoding (0.0.4)
Expand Down Expand Up @@ -227,6 +235,7 @@ GEM
haml (5.0.1)
temple (>= 0.8.0)
tilt
hashdiff (0.3.4)
hashie (3.5.5)
hiredis (0.6.1)
htmlentities (4.3.4)
Expand Down Expand Up @@ -297,6 +306,7 @@ GEM
multi_test (0.1.2)
multi_xml (0.6.0)
multipart-post (2.0.0)
mustermann (1.0.0)
mysql2 (0.4.6)
nenv (0.3.0)
netrc (0.11.0)
Expand Down Expand Up @@ -364,6 +374,8 @@ GEM
rack
rack-contrib (1.2.0)
rack (>= 0.9.1)
rack-protection (2.0.0)
rack
rack-test (0.6.3)
rack (>= 1.0)
rails (5.1.1)
Expand Down Expand Up @@ -462,6 +474,7 @@ GEM
ruby-progressbar (1.8.1)
ruby_dep (1.5.0)
rubyzip (1.2.1)
safe_yaml (1.0.4)
sass (3.4.24)
sass-rails (5.0.6)
railties (>= 4.0.0, < 6)
Expand All @@ -474,6 +487,11 @@ GEM
rubyzip (~> 1.0)
websocket (~> 1.0)
shellany (0.0.1)
sinatra (2.0.0)
mustermann (~> 1.0)
rack (~> 2.0)
rack-protection (= 2.0.0)
tilt (~> 2.0)
sitemap_generator (5.3.1)
builder (~> 3.0)
sixarm_ruby_unaccent (1.1.1)
Expand All @@ -487,6 +505,8 @@ GEM
sprockets (>= 3.0.0)
statesman (2.0.1)
stringex (2.7.1)
stripe (3.0.0)
faraday (~> 0.9)
temple (0.8.0)
therubyracer (0.12.3)
libv8 (~> 3.16.14.15)
Expand All @@ -508,6 +528,10 @@ GEM
oj (~> 2.18)
trollop (2.1.2)
truncate_html (0.9.3)
twitter_cldr (4.4.1)
camertron-eprun
cldr-plurals-runtime-rb (~> 1.0)
tzinfo
tzinfo (1.2.3)
thread_safe (~> 0.1)
uglifier (3.2.0)
Expand All @@ -529,6 +553,10 @@ GEM
multi_json
multipart-post (~> 2.0)
trollop (~> 2.0)
webmock (3.0.1)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
websocket (1.2.4)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
Expand Down Expand Up @@ -569,6 +597,7 @@ DEPENDENCIES
dynamic_form (~> 1.1.4)
email_spec (~> 2.1.1)
factory_girl_rails (~> 4.8.0)
fake_stripe
faraday (~> 0.11.0)
faraday-encoding (~> 0.0.4)
faraday_middleware (~> 0.11.0)
Expand Down Expand Up @@ -623,12 +652,14 @@ DEPENDENCIES
sitemap_generator (~> 5.3.1)
statesman (~> 2.0.1)
stringex (~> 2.7.1)
stripe (~> 3.0.0)
therubyracer (~> 0.12.3)
thinking-sphinx (~> 3.3.0)
timecop (~> 0.8.1)
transit-ruby (~> 0.8.1)
truncate_html (~> 0.9.3)
ts-delayed-delta!
twitter_cldr
uglifier (~> 3.2.0)
uuidtools (~> 2.1.5)
web-console (~> 3.5.1)
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/checkout_with_paypal.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/powered_by_stripe.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/stripe_logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 54 additions & 0 deletions app/assets/javascripts/admin/payment_preferences.js
@@ -0,0 +1,54 @@
window.ST = window.ST || {};

(function(module) {

var initPaymentTabs = function(min_price, fee_error_message) {
$(".tab-link").click(function(){
$(".tab-link").removeClass("active");
$(this).addClass("active");
$(".tab-content").hide();
$("#"+$(this).data('tab')).show();
return false;
});

$("#config_paypal_toggle").click(function(){
$(".connect-row").hide();
$(".payment-tabs").show();
$(".tab-link.paypal").click();
return false;
});

$("#config_stripe_toggle").click(function(){
$(".connect-row").hide();
$(".payment-tabs").show();
$(".tab-link.stripe").click();
return false;
});

$("#transaction_preferences_form_paypal, #transaction_preferences_form_stripe").each(function() {
$(this).validate({
errorPlacement: function(error, element) {
error.appendTo(element.parent());
},
rules: {
"payment_preferences_form[commission_from_seller]": {
required: true,
number_min: 0,
number_max: 100,
number_no_decimals: true
},
"payment_preferences_form[minimum_transaction_fee]": {
required: true,
number_max: min_price,
number_min: 0,
}
},
messages: {
"payment_preferences_form[minimum_transaction_fee]": fee_error_message
}
});
})
};
module.initPaymentTabs = initPaymentTabs;

})(window.ST);
2 changes: 2 additions & 0 deletions app/assets/javascripts/application.js
Expand Up @@ -72,6 +72,7 @@
//= require admin/listing_shapes
//= require admin/settings.js
//= require admin/emails.js
//= require admin/payment_preferences.js
//= require payment_math
//= require dropdown
//= require jquery.nouislider
Expand All @@ -90,4 +91,5 @@
//= require listing_form
//= require radio_buttons
//= require new_layout
//= require stripe_form
//= require_self
14 changes: 14 additions & 0 deletions app/assets/javascripts/kassi.js
Expand Up @@ -904,3 +904,17 @@ function enableSamePageScroll() {
return [];
}
}

function autoSetMinimalPriceFromCountry() {
var _minimal_commissions = {USD: 50, AUD: 50, BRL: 50, GBP: 50, CAD: 50, CZK: 1500, DKK: 500, EUR: 50, HKD: 500, HUF: 10000, ILS: 200, JPY: 50, MXN: 500, MYR: 200, TWD: 1500, NZD: 50, NOK: 500, PHP: 2000, PLN: 200, RUB: 1500, SGD: 100, SEK: 500, CHF: 100, THB: 1500, TRY: 150};
var _min_price = $("#payment_preferences_form_minimum_listing_price");
$("#payment_preferences_form_marketplace_currency").change(function(){
var currency = $(this).val();
var min_tx = _minimal_commissions[currency] / 100;
var cur_tx = parseFloat(_min_price.val());
if(isNaN(cur_tx) || min_tx > cur_tx) {
_min_price.val(min_tx.toFixed(2))
}
_min_price.next(".paypal-preferences-currency-label").text(currency);
}).trigger('change');
}
8 changes: 4 additions & 4 deletions app/assets/javascripts/paypal_account_settings.js
Expand Up @@ -29,7 +29,7 @@ window.ST = window.ST || {};

module.initializePayPalPreferencesForm = function(formId, commissionRange) {
var $form = $('#' + formId);
var $currency = $form.find('#paypal_preferences_form_marketplace_currency');
var $currency = $form.find('#payment_preferences_form_marketplace_currency');
var $currencyLabels = $form.find('.paypal-preferences-currency-label');
var $warning = $form.find('.paypal-currency-change-warning-text');

Expand All @@ -43,16 +43,16 @@ window.ST = window.ST || {};
error.appendTo(element.parent());
},
rules: {
"paypal_preferences_form[commission_from_seller]": {
"payment_preferences_form[commission_from_seller]": {
required: true,
number_min: commissionRange[0],
number_max: commissionRange[1],
number_no_decimals: true
},
"paypal_preferences_form[minimum_listing_price]": {
"payment_preferences_form[minimum_listing_price]": {
required: true
},
"paypal_preferences_form[minimum_transaction_fee]": {
"payment_preferences_form[minimum_transaction_fee]": {
required: true,
number_min: 0
}
Expand Down

0 comments on commit df5ceeb

Please sign in to comment.