spree_gateway 2.2.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +5 -17
- data/Gemfile +1 -1
- data/README.md +9 -3
- data/app/models/spree/billing_integration.rb +21 -0
- data/app/models/spree/gateway/authorize_net.rb +31 -1
- data/app/models/spree/gateway/authorize_net_cim.rb +128 -47
- data/app/models/spree/gateway/balanced_gateway.rb +3 -5
- data/app/models/spree/gateway/braintree_gateway.rb +55 -18
- data/app/models/spree/gateway/cyber_source.rb +10 -0
- data/app/models/spree/gateway/migs.rb +11 -0
- data/app/models/spree/gateway/payflow_pro.rb +1 -0
- data/app/models/spree/gateway/pin_gateway.rb +45 -0
- data/app/models/spree/gateway/spreedly_core_gateway.rb +10 -0
- data/app/models/spree/gateway/stripe_gateway.rb +29 -6
- data/app/models/spree/gateway/usa_epay_transaction.rb +9 -0
- data/config/routes.rb +1 -1
- data/db/migrate/20111118164631_create_skrill_transactions.rb +1 -2
- data/lib/assets/javascripts/spree/frontend/spree_gateway.js +1 -0
- data/{app → lib}/assets/stylesheets/spree/frontend/spree_gateway.css +0 -0
- data/{app/controllers → lib/controllers/frontend}/spree/checkout_controller_decorator.rb +1 -1
- data/{app/controllers → lib/controllers/frontend}/spree/skrill_status_controller.rb +0 -0
- data/lib/spree_gateway.rb +1 -1
- data/lib/spree_gateway/engine.rb +56 -25
- data/{app/views → lib/views/backend}/spree/admin/log_entries/_braintree.html.erb +0 -0
- data/{app/views → lib/views/backend}/spree/admin/log_entries/_stripe.html.erb +0 -0
- data/{app/views → lib/views/backend}/spree/admin/payments/source_forms/_quickcheckout.html.erb +0 -0
- data/lib/views/backend/spree/admin/payments/source_forms/_stripe.html.erb +1 -0
- data/{app/views → lib/views/backend}/spree/admin/payments/source_views/_quickcheckout.html.erb +0 -0
- data/{app/views → lib/views/backend}/spree/admin/payments/source_views/_stripe.html.erb +0 -0
- data/{app/views → lib/views/frontend}/spree/checkout/payment/_quickcheckout.html.erb +2 -2
- data/lib/views/frontend/spree/checkout/payment/_stripe.html.erb +90 -0
- data/spec/factories/payment_method_factory.rb +0 -1
- data/spec/features/stripe_checkout_spec.rb +15 -4
- data/spec/models/gateway/authorize_net_cim_spec.rb +6 -6
- data/spec/models/gateway/authorize_net_spec.rb +6 -6
- data/spec/models/gateway/balanced_gateway_spec.rb +1 -1
- data/spec/models/gateway/beanstream_spec.rb +1 -1
- data/spec/models/gateway/braintree_gateway_spec.rb +147 -31
- data/spec/models/gateway/cyber_source_spec.rb +11 -0
- data/spec/models/gateway/eway_spec.rb +3 -3
- data/spec/models/gateway/maxipago_spec.rb +1 -1
- data/spec/models/gateway/pay_junction_spec.rb +2 -2
- data/spec/models/gateway/payflow_pro_spec.rb +2 -2
- data/spec/models/gateway/pin_gateway_spec.rb +4 -6
- data/spec/models/gateway/stripe_gateway_spec.rb +90 -9
- data/spec/models/gateway/{usa_epay_spec.rb → usa_epay_transaction_spec.rb} +9 -9
- data/spec/spec_helper.rb +5 -2
- data/spree_gateway.gemspec +15 -16
- metadata +89 -98
- data/Versionfile +0 -7
- data/app/assets/javascripts/spree/frontend/spree_gateway.js +0 -3
- data/app/assets/javascripts/store/gateway/stripe.js.coffee +0 -58
- data/app/assets/javascripts/store/spree_gateway.js +0 -2
- data/app/models/spree/gateway/fatzebra.rb +0 -15
- data/app/models/spree/gateway/linkpoint.rb +0 -28
- data/app/models/spree/gateway/samurai.rb +0 -63
- data/app/models/spree/gateway/usa_epay.rb +0 -9
- data/app/views/spree/admin/payments/source_forms/_stripe.html.erb +0 -1
- data/app/views/spree/checkout/payment/_stripe.html.erb +0 -21
- data/config/initializers/savon.rb +0 -3
- data/spec/models/gateway/fatzebra_spec.rb +0 -51
- data/spec/models/gateway/linkpoint_spec.rb +0 -62
- data/spec/models/gateway/samurai_spec.rb +0 -17
- data/spec/models/savon_spec.rb +0 -9
data/Versionfile
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
"2.2.x" => { :branch => "2-2-stable" }
|
2
|
-
"2.1.x" => { :branch => "2-1-stable" }
|
3
|
-
"2.0.x" => { :branch => "2-0-stable" }
|
4
|
-
"1.3.x" => { :branch => "1-3-stable" }
|
5
|
-
"1.2.x" => { :branch => "1-2-stable" }
|
6
|
-
"1.1.x" => { :branch => "1-1-stable" }
|
7
|
-
"1.0.x" => { :branch => "1-0-stable" }
|
@@ -1,58 +0,0 @@
|
|
1
|
-
# Inspired by https://stripe.com/docs/stripe.js
|
2
|
-
|
3
|
-
# Map cc types from stripe to spree
|
4
|
-
mapCC = (ccType) ->
|
5
|
-
if (ccType == 'MasterCard')
|
6
|
-
'mastercard'
|
7
|
-
else if (ccType == 'Visa')
|
8
|
-
'visa'
|
9
|
-
else if (ccType == 'American Express')
|
10
|
-
'amex'
|
11
|
-
else if (ccType == 'Discover')
|
12
|
-
'discover'
|
13
|
-
else if (ccType == 'Diners Club')
|
14
|
-
'dinersclub'
|
15
|
-
else if (ccType == 'JCB')
|
16
|
-
'jcb'
|
17
|
-
|
18
|
-
|
19
|
-
$(document).ready ->
|
20
|
-
# For errors that happen later.
|
21
|
-
Spree.stripePaymentMethod.prepend("<div id='stripeError' class='errorExplanation' style='display:none'></div>")
|
22
|
-
|
23
|
-
$('.continue').click ->
|
24
|
-
$('#stripeError').hide()
|
25
|
-
if Spree.stripePaymentMethod.is(':visible')
|
26
|
-
expiration = $('.cardExpiry:visible').payment('cardExpiryVal')
|
27
|
-
params = $.extend(
|
28
|
-
{
|
29
|
-
number: $('.cardNumber:visible').val(),
|
30
|
-
cvc: $('.cardCode:visible').val(),
|
31
|
-
exp_month: expiration.month || 0,
|
32
|
-
exp_year: expiration.year || 0,
|
33
|
-
},
|
34
|
-
Spree.stripeAdditionalInfo
|
35
|
-
)
|
36
|
-
|
37
|
-
Stripe.card.createToken(params, stripeResponseHandler);
|
38
|
-
return false
|
39
|
-
|
40
|
-
stripeResponseHandler = (status, response) ->
|
41
|
-
if response.error
|
42
|
-
$('#stripeError').html(response.error.message)
|
43
|
-
$('#stripeError').show()
|
44
|
-
else
|
45
|
-
Spree.stripePaymentMethod.find('#card_number, #card_expiry, #card_code').prop("disabled" , true)
|
46
|
-
Spree.stripePaymentMethod.find(".ccType").prop("disabled", false)
|
47
|
-
Spree.stripePaymentMethod.find(".ccType").val(mapCC(response.card.type))
|
48
|
-
|
49
|
-
# token contains id, last4, and card type
|
50
|
-
token = response['id'];
|
51
|
-
# insert the token into the form so it gets submitted to the server
|
52
|
-
paymentMethodId = Spree.stripePaymentMethod.prop('id').split("_")[2]
|
53
|
-
Spree.stripePaymentMethod.append("<input type='hidden' class='stripeToken' name='payment_source[" + paymentMethodId + "][gateway_payment_profile_id]' value='" + token + "'/>");
|
54
|
-
Spree.stripePaymentMethod.append("<input type='hidden' class='stripeToken' name='payment_source[" + paymentMethodId + "][last_digits]' value='" + response.card.last4 + "'/>");
|
55
|
-
Spree.stripePaymentMethod.append("<input type='hidden' class='stripeToken' name='payment_source[" + paymentMethodId + "][month]' value='" + response.card.exp_month + "'/>");
|
56
|
-
Spree.stripePaymentMethod.append("<input type='hidden' class='stripeToken' name='payment_source[" + paymentMethodId + "][year]' value='" + response.card.exp_year + "'/>");
|
57
|
-
# Spree.stripePaymentMethod.append("<input type='hidden' class='stripeToken' name='payment_source[" + paymentMethodId + "][cc_type]' value='" + mapCC(response.card.type) + "'/>");
|
58
|
-
Spree.stripePaymentMethod.parents("form").get(0).submit();
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
class Gateway::Fatzebra < Gateway
|
3
|
-
preference :username, :string, default: "TEST"
|
4
|
-
preference :token, :string, default: "TEST"
|
5
|
-
|
6
|
-
def provider_class
|
7
|
-
ActiveMerchant::Billing::FatZebraGateway
|
8
|
-
end
|
9
|
-
|
10
|
-
# Currently no auth/capture, but coming soon...
|
11
|
-
def auto_capture?
|
12
|
-
true
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
class Gateway::Linkpoint < Gateway
|
3
|
-
preference :login, :string
|
4
|
-
preference :pem, :text
|
5
|
-
|
6
|
-
def provider_class
|
7
|
-
ActiveMerchant::Billing::LinkpointGateway
|
8
|
-
end
|
9
|
-
|
10
|
-
[:authorize, :purchase, :capture, :void, :credit].each do |method|
|
11
|
-
define_method(method) do |*args|
|
12
|
-
options = add_discount_to_subtotal(args.extract_options!)
|
13
|
-
provider.public_send(method, *args << options)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
# Linkpoint ignores the discount, but it will return an error if the
|
20
|
-
# chargetotal is different from the sum of the subtotal, tax and
|
21
|
-
# shipping totals.
|
22
|
-
def add_discount_to_subtotal(options)
|
23
|
-
subtotal = options.fetch(:subtotal)
|
24
|
-
discount = options.fetch(:discount)
|
25
|
-
options.merge(subtotal: subtotal + discount, discount: 0)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
class Gateway::Samurai < Gateway
|
3
|
-
preference :login, :string
|
4
|
-
preference :password, :string
|
5
|
-
preference :processor_token, :string
|
6
|
-
|
7
|
-
def provider_class
|
8
|
-
ActiveMerchant::Billing::SamuraiGateway
|
9
|
-
end
|
10
|
-
|
11
|
-
def payment_profiles_supported?
|
12
|
-
true
|
13
|
-
end
|
14
|
-
|
15
|
-
def purchase(money, creditcard, gateway_options)
|
16
|
-
gateway_options[:billing_reference] = gateway_options[:order_id]
|
17
|
-
gateway_options[:customer_reference] = gateway_options[:customer]
|
18
|
-
gateway_options[:description] = "Spree Order"
|
19
|
-
provider.purchase(money, creditcard.gateway_customer_profile_id, gateway_options)
|
20
|
-
end
|
21
|
-
|
22
|
-
def authorize(money, creditcard, gateway_options)
|
23
|
-
gateway_options[:billing_reference] = gateway_options[:order_id]
|
24
|
-
gateway_options[:customer_reference] = gateway_options[:customer]
|
25
|
-
gateway_options[:description] = "Spree Order"
|
26
|
-
provider.authorize(money, creditcard.gateway_customer_profile_id, gateway_options)
|
27
|
-
end
|
28
|
-
|
29
|
-
def capture(authorization, creditcard, gateway_options)
|
30
|
-
gateway_options[:billing_reference] = gateway_options[:order_id]
|
31
|
-
gateway_options[:customer_reference] = gateway_options[:customer]
|
32
|
-
gateway_options[:description] = "Spree Order"
|
33
|
-
provider.capture(nil, authorization.response_code, {})
|
34
|
-
end
|
35
|
-
|
36
|
-
def credit(money, creditcard, response_code, gateway_options)
|
37
|
-
provider.credit(money, response_code, {})
|
38
|
-
end
|
39
|
-
|
40
|
-
def void(response_code, gateway_options)
|
41
|
-
provider.void(response_code, {})
|
42
|
-
end
|
43
|
-
|
44
|
-
def create_profile(payment)
|
45
|
-
return unless payment.source.gateway_customer_profile_id.nil?
|
46
|
-
|
47
|
-
options = {}
|
48
|
-
options[:email] = payment.order.email
|
49
|
-
options[:address] = {}
|
50
|
-
options[:address][:address1] = payment.order.bill_address.address1
|
51
|
-
options[:address][:address2] = payment.order.bill_address.address2
|
52
|
-
options[:address][:city] = payment.order.bill_address.city
|
53
|
-
options[:address][:state] = payment.order.bill_address.state.abbr
|
54
|
-
options[:address][:zip] = payment.order.bill_address.zipcode
|
55
|
-
response = provider.store(payment.source, options)
|
56
|
-
if response.success?
|
57
|
-
payment.source.update_attributes!(:gateway_customer_profile_id => response.params['payment_method_token'])
|
58
|
-
else
|
59
|
-
payment.send(:gateway_error, response.message)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
<%= render "spree/admin/payments/source_forms/gateway", payment_method: payment_method %>
|
@@ -1,21 +0,0 @@
|
|
1
|
-
<%= render "spree/checkout/payment/gateway", :payment_method => payment_method %>
|
2
|
-
|
3
|
-
<script type="text/javascript" src="https://js.stripe.com/v2/"></script>
|
4
|
-
<script type="text/javascript">
|
5
|
-
Stripe.setPublishableKey("<%= payment_method.preferred_publishable_key %>");
|
6
|
-
</script>
|
7
|
-
<script>
|
8
|
-
Spree.stripePaymentMethod = $('#payment_method_' + <%= payment_method.id %>)
|
9
|
-
</script>
|
10
|
-
<%= javascript_include_tag "store/gateway/stripe" %>
|
11
|
-
<script>
|
12
|
-
Spree.stripeAdditionalInfo = {
|
13
|
-
name: "<%= @order.bill_address.full_name %>",
|
14
|
-
address_line_1: "<%= @order.bill_address.address1 %>",
|
15
|
-
address_line_2: "<%= @order.bill_address.address2 %>",
|
16
|
-
address_city: "<%= @order.bill_address.city %>",
|
17
|
-
address_state: "<%= @order.bill_address.state_text %>",
|
18
|
-
address_zip: "<%= @order.bill_address.zipcode %>",
|
19
|
-
address_country: "<%= @order.bill_address.country %>"
|
20
|
-
}
|
21
|
-
</script>
|
@@ -1,51 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Spree::Gateway::Fatzebra do
|
4
|
-
|
5
|
-
before do
|
6
|
-
Spree::Gateway.update_all(active: false)
|
7
|
-
@gateway = Spree::Gateway::Fatzebra.create!(name: 'Fat Zebra Gateway', environment: 'sandbox', active: true)
|
8
|
-
@gateway.set_preference(:username, 'TEST')
|
9
|
-
@gateway.set_preference(:token, 'TEST')
|
10
|
-
@gateway.save!
|
11
|
-
|
12
|
-
country = create(:country, name: 'Australia', iso_name: 'Australia', iso3: 'AUS', iso: 'AU', numcode: 61)
|
13
|
-
state = create(:state, name: 'Victoria', abbr: 'VIC', country: country)
|
14
|
-
address = create(:address,
|
15
|
-
firstname: 'Ronald C',
|
16
|
-
lastname: 'Robot',
|
17
|
-
address1: '1234 My Street',
|
18
|
-
address2: 'Apt 1',
|
19
|
-
city: 'Melbourne',
|
20
|
-
zipcode: '3000',
|
21
|
-
phone: '88888888',
|
22
|
-
state: state,
|
23
|
-
country: country
|
24
|
-
)
|
25
|
-
|
26
|
-
order = create(:order_with_totals, bill_address: address, ship_address: address, last_ip_address: '127.0.0.1')
|
27
|
-
order.update!
|
28
|
-
|
29
|
-
credit_card = create(:credit_card,
|
30
|
-
verification_value: '123',
|
31
|
-
number: '5123456789012346',
|
32
|
-
month: 5,
|
33
|
-
year: Time.now.year + 1,
|
34
|
-
name: 'Ronald C Robot'
|
35
|
-
)
|
36
|
-
|
37
|
-
@payment = create(:payment, source: credit_card, order: order, payment_method: @gateway, amount: 10.00)
|
38
|
-
@payment.payment_method.environment = 'test'
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'can purchase' do
|
42
|
-
@payment.purchase!
|
43
|
-
expect(@payment.state).to eq 'completed'
|
44
|
-
end
|
45
|
-
|
46
|
-
context '.auto_capture?' do
|
47
|
-
it 'return true' do
|
48
|
-
expect(@gateway.auto_capture?).to be_true
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Spree::Gateway::Linkpoint do
|
4
|
-
let(:gateway) { described_class.create!(name: 'Linkpoint') }
|
5
|
-
let(:provider) { double('provider') }
|
6
|
-
let(:money) { double('money') }
|
7
|
-
let(:credit_card) { double('credit_card') }
|
8
|
-
let(:identification) { double('identification') }
|
9
|
-
let(:options) { { subtotal: 3, discount: -1 } }
|
10
|
-
|
11
|
-
before do
|
12
|
-
gateway.provider_class.stub(new: provider)
|
13
|
-
end
|
14
|
-
|
15
|
-
context '.provider_class' do
|
16
|
-
it 'is a Linkpoint gateway' do
|
17
|
-
expect(gateway.provider_class).to eq ::ActiveMerchant::Billing::LinkpointGateway
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
context '#authorize' do
|
22
|
-
it 'adds the discount to the subtotal' do
|
23
|
-
provider.should_receive(:authorize)
|
24
|
-
.with(money, credit_card, subtotal: 2, discount: 0)
|
25
|
-
gateway.authorize(money, credit_card, options)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context '#purchase' do
|
30
|
-
it 'adds the discount to the subtotal' do
|
31
|
-
provider.should_receive(:purchase)
|
32
|
-
.with(money, credit_card, subtotal: 2, discount: 0)
|
33
|
-
gateway.purchase(money, credit_card, options)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
context '#capture' do
|
38
|
-
let(:authorization) { double('authorization') }
|
39
|
-
|
40
|
-
it 'adds the discount to the subtotal' do
|
41
|
-
provider.should_receive(:capture)
|
42
|
-
.with(money, authorization, subtotal: 2, discount: 0)
|
43
|
-
gateway.capture(money, authorization, options)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
context '#void' do
|
48
|
-
it 'adds the discount to the subtotal' do
|
49
|
-
provider.should_receive(:void)
|
50
|
-
.with(identification, subtotal: 2, discount: 0)
|
51
|
-
gateway.void(identification, options)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
context '#credit' do
|
56
|
-
it 'adds the discount to the subtotal' do
|
57
|
-
provider.should_receive(:credit)
|
58
|
-
.with(money, identification, subtotal: 2, discount: 0)
|
59
|
-
gateway.credit(money, identification, options)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Spree::Gateway::Samurai do
|
4
|
-
let(:gateway) { Spree::Gateway::Samurai.create!(name: 'Samurai') }
|
5
|
-
|
6
|
-
context '.provider_class' do
|
7
|
-
it 'is a Samurai gateway' do
|
8
|
-
expect(gateway.provider_class).to eq ::ActiveMerchant::Billing::SamuraiGateway
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
context '.payment_profiles_supported?' do
|
13
|
-
it 'return true' do
|
14
|
-
expect(gateway.payment_profiles_supported?).to be_true
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|