merchant_sidekick 0.4.2
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.
- data/.gitignore +12 -0
- data/Changelog.md +38 -0
- data/Gemfile +2 -0
- data/MIT-LICENSE +19 -0
- data/README.md +88 -0
- data/Rakefile +10 -0
- data/lib/merchant_sidekick.rb +45 -0
- data/lib/merchant_sidekick/active_merchant/credit_card_payment.rb +117 -0
- data/lib/merchant_sidekick/active_merchant/gateways/authorize_net_gateway.rb +26 -0
- data/lib/merchant_sidekick/active_merchant/gateways/base.rb +29 -0
- data/lib/merchant_sidekick/active_merchant/gateways/bogus_gateway.rb +19 -0
- data/lib/merchant_sidekick/active_merchant/gateways/paypal_gateway.rb +43 -0
- data/lib/merchant_sidekick/addressable/address.rb +400 -0
- data/lib/merchant_sidekick/addressable/addressable.rb +353 -0
- data/lib/merchant_sidekick/buyer.rb +99 -0
- data/lib/merchant_sidekick/gateway.rb +81 -0
- data/lib/merchant_sidekick/install.rb +19 -0
- data/lib/merchant_sidekick/invoice.rb +179 -0
- data/lib/merchant_sidekick/line_item.rb +128 -0
- data/lib/merchant_sidekick/migrations/addressable.rb +47 -0
- data/lib/merchant_sidekick/migrations/billing.rb +100 -0
- data/lib/merchant_sidekick/migrations/shopping_cart.rb +28 -0
- data/lib/merchant_sidekick/money.rb +38 -0
- data/lib/merchant_sidekick/order.rb +244 -0
- data/lib/merchant_sidekick/payment.rb +59 -0
- data/lib/merchant_sidekick/purchase_invoice.rb +180 -0
- data/lib/merchant_sidekick/purchase_order.rb +350 -0
- data/lib/merchant_sidekick/railtie.rb +7 -0
- data/lib/merchant_sidekick/sales_invoice.rb +56 -0
- data/lib/merchant_sidekick/sales_order.rb +122 -0
- data/lib/merchant_sidekick/sellable.rb +88 -0
- data/lib/merchant_sidekick/seller.rb +93 -0
- data/lib/merchant_sidekick/shopping_cart/cart.rb +225 -0
- data/lib/merchant_sidekick/shopping_cart/line_item.rb +152 -0
- data/lib/merchant_sidekick/version.rb +3 -0
- data/merchant_sidekick.gemspec +37 -0
- data/spec/address_spec.rb +153 -0
- data/spec/addressable_spec.rb +250 -0
- data/spec/buyer_spec.rb +203 -0
- data/spec/cart_line_item_spec.rb +58 -0
- data/spec/cart_spec.rb +213 -0
- data/spec/config/merchant_sidekick.yml +10 -0
- data/spec/credit_card_payment_spec.rb +175 -0
- data/spec/fixtures/addresses.yml +97 -0
- data/spec/fixtures/line_items.yml +18 -0
- data/spec/fixtures/orders.yml +24 -0
- data/spec/fixtures/payments.yml +17 -0
- data/spec/fixtures/products.yml +12 -0
- data/spec/fixtures/users.yml +11 -0
- data/spec/gateway_spec.rb +136 -0
- data/spec/invoice_spec.rb +79 -0
- data/spec/line_item_spec.rb +65 -0
- data/spec/order_spec.rb +85 -0
- data/spec/payment_spec.rb +14 -0
- data/spec/purchase_invoice_spec.rb +70 -0
- data/spec/purchase_order_spec.rb +191 -0
- data/spec/sales_invoice_spec.rb +58 -0
- data/spec/sales_order_spec.rb +107 -0
- data/spec/schema.rb +28 -0
- data/spec/sellable_spec.rb +34 -0
- data/spec/seller_spec.rb +201 -0
- data/spec/spec_helper.rb +255 -0
- metadata +201 -0
@@ -0,0 +1,10 @@
|
|
1
|
+
test:
|
2
|
+
authorize_net_gateway:
|
3
|
+
login_id: foo
|
4
|
+
transaction_key: bar
|
5
|
+
mode: test
|
6
|
+
paypal_gateway:
|
7
|
+
api_username: seller_XYZ_biz_api1.example.com
|
8
|
+
api_password: ABCDEFG123456789
|
9
|
+
signature: AsPC9BjkCyDFQXbStoZcgqH3hpacAX3IenGazd35.nEnXJKR9nfCmJDu
|
10
|
+
mode: test
|
@@ -0,0 +1,175 @@
|
|
1
|
+
require File.expand_path("../spec_helper", __FILE__)
|
2
|
+
|
3
|
+
describe MerchantSidekick::ActiveMerchant::CreditCardPayment, "gateway" do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
MerchantSidekick::Gateway.config = nil
|
7
|
+
MerchantSidekick::Gateway.gateway = nil
|
8
|
+
MerchantSidekick::Gateway.default_gateway = nil
|
9
|
+
MerchantSidekick::ActiveMerchant::CreditCardPayment.gateway = nil
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should assign an active merchant gateway instance" do
|
13
|
+
MerchantSidekick::ActiveMerchant::CreditCardPayment.gateway = ActiveMerchant::Billing::BogusGateway.new
|
14
|
+
MerchantSidekick::ActiveMerchant::CreditCardPayment.gateway.should be_instance_of(::ActiveMerchant::Billing::BogusGateway)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should return active merchant gateway instance using merchant sidekick gateway type authorize_net_gateway" do
|
18
|
+
MerchantSidekick::ActiveMerchant::CreditCardPayment.gateway = :authorize_net_gateway
|
19
|
+
MerchantSidekick::ActiveMerchant::CreditCardPayment.gateway.should be_instance_of(::ActiveMerchant::Billing::AuthorizeNetGateway)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should return active merchant gateway instance using merchant sidekick gateway type paypal_gateway" do
|
23
|
+
MerchantSidekick::ActiveMerchant::CreditCardPayment.gateway = :paypal_gateway
|
24
|
+
MerchantSidekick::ActiveMerchant::CreditCardPayment.gateway.should be_instance_of(::ActiveMerchant::Billing::PaypalGateway)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should return active merchant gateway assigned as merchant sidekick default gateway" do
|
28
|
+
MerchantSidekick::Gateway.default_gateway = ActiveMerchant::Billing::BogusGateway.new
|
29
|
+
MerchantSidekick::ActiveMerchant::CreditCardPayment.gateway.should be_instance_of(::ActiveMerchant::Billing::BogusGateway)
|
30
|
+
end
|
31
|
+
|
32
|
+
after(:each) do
|
33
|
+
MerchantSidekick::Gateway.config = nil
|
34
|
+
MerchantSidekick::Gateway.gateway = nil
|
35
|
+
MerchantSidekick::ActiveMerchant::CreditCardPayment.gateway = nil
|
36
|
+
end
|
37
|
+
|
38
|
+
after(:all) do
|
39
|
+
MerchantSidekick::Gateway.default_gateway = ActiveMerchant::Billing::BogusGateway.new
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
describe MerchantSidekick::ActiveMerchant::CreditCardPayment, "authorization" do
|
45
|
+
|
46
|
+
def setup
|
47
|
+
@amount = Money.new(100, 'USD')
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should succeed" do
|
51
|
+
transaction do
|
52
|
+
auth = MerchantSidekick::ActiveMerchant::CreditCardPayment.authorize(
|
53
|
+
@amount,
|
54
|
+
credit_card(valid_credit_card_attributes)
|
55
|
+
)
|
56
|
+
auth.success.should == true
|
57
|
+
auth.action.should == 'authorization'
|
58
|
+
auth.message.should == ActiveMerchant::Billing::BogusGateway::SUCCESS_MESSAGE
|
59
|
+
auth[:reference].should == ActiveMerchant::Billing::BogusGateway::AUTHORIZATION
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should fail" do
|
64
|
+
transaction do
|
65
|
+
auth = MerchantSidekick::ActiveMerchant::CreditCardPayment.authorize(
|
66
|
+
@amount,
|
67
|
+
credit_card(invalid_credit_card_attributes)
|
68
|
+
)
|
69
|
+
auth.success.should == false
|
70
|
+
auth.action.should == 'authorization'
|
71
|
+
auth.message.should == ActiveMerchant::Billing::BogusGateway::FAILURE_MESSAGE
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should error" do
|
76
|
+
transaction do
|
77
|
+
auth = MerchantSidekick::ActiveMerchant::CreditCardPayment.authorize(
|
78
|
+
@amount,
|
79
|
+
credit_card(valid_credit_card_attributes(:number => '3'))
|
80
|
+
)
|
81
|
+
auth.success.should == false
|
82
|
+
auth.action.should == 'authorization'
|
83
|
+
auth.message.should == ActiveMerchant::Billing::BogusGateway::ERROR_MESSAGE
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
describe MerchantSidekick::ActiveMerchant::CreditCardPayment, "capture" do
|
90
|
+
|
91
|
+
def setup
|
92
|
+
@amount = Money.new(100, 'USD')
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should capture successfully" do
|
96
|
+
transaction do
|
97
|
+
capt = MerchantSidekick::ActiveMerchant::CreditCardPayment.capture(
|
98
|
+
@amount,
|
99
|
+
'123'
|
100
|
+
)
|
101
|
+
capt.success.should == true
|
102
|
+
capt.action.should == 'capture'
|
103
|
+
capt.message.should == ActiveMerchant::Billing::BogusGateway::SUCCESS_MESSAGE
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should fail capture" do
|
108
|
+
transaction do
|
109
|
+
capt = MerchantSidekick::ActiveMerchant::CreditCardPayment.capture(
|
110
|
+
@amount,
|
111
|
+
'2'
|
112
|
+
)
|
113
|
+
capt.success.should == false
|
114
|
+
capt.action.should == 'capture'
|
115
|
+
capt.message.should == ActiveMerchant::Billing::BogusGateway::FAILURE_MESSAGE
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should error capture" do
|
120
|
+
transaction do
|
121
|
+
capt = MerchantSidekick::ActiveMerchant::CreditCardPayment.capture(
|
122
|
+
@amount,
|
123
|
+
'1'
|
124
|
+
)
|
125
|
+
capt.success.should == false
|
126
|
+
capt.action.should == 'capture'
|
127
|
+
capt.message.should == ActiveMerchant::Billing::BogusGateway::CAPTURE_ERROR_MESSAGE
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
|
133
|
+
describe MerchantSidekick::ActiveMerchant::CreditCardPayment, "transfer method" do
|
134
|
+
|
135
|
+
def setup
|
136
|
+
@amount = Money.new(100, 'USD')
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should sucessfully transfer" do
|
140
|
+
transaction do
|
141
|
+
capt = MerchantSidekick::ActiveMerchant::CreditCardPayment.transfer(
|
142
|
+
@amount,
|
143
|
+
'account@test.tst'
|
144
|
+
)
|
145
|
+
capt.success.should == true
|
146
|
+
capt.action.should == 'transfer'
|
147
|
+
capt.message.should == ActiveMerchant::Billing::BogusGateway::SUCCESS_MESSAGE
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
it "should return error" do
|
152
|
+
transaction do
|
153
|
+
capt = MerchantSidekick::ActiveMerchant::CreditCardPayment.transfer(
|
154
|
+
@amount,
|
155
|
+
'error@error.tst'
|
156
|
+
)
|
157
|
+
capt.success.should == false
|
158
|
+
capt.action.should == 'transfer'
|
159
|
+
capt.message.should == ActiveMerchant::Billing::BogusGateway::ERROR_MESSAGE
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
it "should fail" do
|
164
|
+
transaction do
|
165
|
+
capt = MerchantSidekick::ActiveMerchant::CreditCardPayment.transfer(
|
166
|
+
@amount,
|
167
|
+
'fail@error.tst'
|
168
|
+
)
|
169
|
+
capt.success.should == false
|
170
|
+
capt.action.should == 'transfer'
|
171
|
+
capt.message.should == ActiveMerchant::Billing::BogusGateway::FAILURE_MESSAGE
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
paid_order_billing_address:
|
2
|
+
id: 2
|
3
|
+
first_name: Erik
|
4
|
+
last_name: Bolton
|
5
|
+
street: 223 Riverside St.
|
6
|
+
city: Baltimore
|
7
|
+
province: North Carolina
|
8
|
+
province_code: NC
|
9
|
+
postal_code: 12345
|
10
|
+
country_code: USA
|
11
|
+
country: United States of America
|
12
|
+
type: BillingAddress
|
13
|
+
addressable_id: 2
|
14
|
+
addressable_type: MerchantSidekick::Order
|
15
|
+
paid_order_shipping_address:
|
16
|
+
id: 3
|
17
|
+
first_name: Sam
|
18
|
+
last_name: Body
|
19
|
+
street: 11 1st St
|
20
|
+
city: Somewhere
|
21
|
+
province: NA
|
22
|
+
province_code: NA
|
23
|
+
postal_code: 12345
|
24
|
+
country_code: USA
|
25
|
+
country: USA
|
26
|
+
type: ShippingAddress
|
27
|
+
addressable_id: 2
|
28
|
+
addressable_type: MerchantSidekick::Order
|
29
|
+
paid_order_origin_address:
|
30
|
+
id: 4
|
31
|
+
company_name: Coal Headware
|
32
|
+
street: 500 Lobster Dr.
|
33
|
+
city: Portland
|
34
|
+
province: Washington
|
35
|
+
province_code: WA
|
36
|
+
postal_code: 78543
|
37
|
+
country_code: USA
|
38
|
+
country: USA
|
39
|
+
type: OriginAddress
|
40
|
+
addressable_id: 2
|
41
|
+
addressable_type: MerchantSidekick::Order
|
42
|
+
sam_billing:
|
43
|
+
id: 5
|
44
|
+
first_name: Sam
|
45
|
+
last_name: Body
|
46
|
+
street: 1 Billing Way
|
47
|
+
city: Somewhere
|
48
|
+
province: NA
|
49
|
+
province_code: NA
|
50
|
+
postal_code: 12345
|
51
|
+
country_code: USA
|
52
|
+
country: USA
|
53
|
+
type: BillingAddress
|
54
|
+
addressable_id: 1
|
55
|
+
addressable_type: User
|
56
|
+
sam_shipping:
|
57
|
+
id: 6
|
58
|
+
first_name: Sam
|
59
|
+
last_name: Body
|
60
|
+
street: 500 Shipping Blvd.
|
61
|
+
city: Somewhere
|
62
|
+
province: NA
|
63
|
+
province_code: NA
|
64
|
+
postal_code: 12345
|
65
|
+
country_code: USA
|
66
|
+
country: USA
|
67
|
+
type: ShippingAddress
|
68
|
+
addressable_id: 1
|
69
|
+
addressable_type: User
|
70
|
+
sally_billing:
|
71
|
+
id: 7
|
72
|
+
first_name: Sally
|
73
|
+
last_name: Sellers
|
74
|
+
street: 105 Billing St.
|
75
|
+
city: San Francisco
|
76
|
+
province: California
|
77
|
+
province_code: CA
|
78
|
+
postal_code: 94084
|
79
|
+
country_code: US
|
80
|
+
country: United States of America
|
81
|
+
type: BillingAddress
|
82
|
+
addressable_id: 2
|
83
|
+
addressable_type: User
|
84
|
+
sally_shipping:
|
85
|
+
id: 8
|
86
|
+
first_name: Sally
|
87
|
+
last_name: Sellers
|
88
|
+
street: 3523 Shipping Ave.
|
89
|
+
city: Portland
|
90
|
+
province: Oregon
|
91
|
+
province_code: OR
|
92
|
+
postal_code: 12345
|
93
|
+
country_code: US
|
94
|
+
country: United States of America
|
95
|
+
type: ShippingAddress
|
96
|
+
addressable_id: 2
|
97
|
+
addressable_type: User
|
@@ -0,0 +1,18 @@
|
|
1
|
+
sams_widget:
|
2
|
+
id: 1
|
3
|
+
order_id: 1
|
4
|
+
sellable_id: 1
|
5
|
+
sellable_type: Product
|
6
|
+
net_cents: 2995
|
7
|
+
tax_cents: 0
|
8
|
+
gross_cents: 2995
|
9
|
+
currency: USD
|
10
|
+
sams_knob:
|
11
|
+
id: 2
|
12
|
+
order_id: 1
|
13
|
+
sellable_id: 2
|
14
|
+
sellable_type: Product
|
15
|
+
net_cents: 399
|
16
|
+
tax_cents: 0
|
17
|
+
gross_cents: 399
|
18
|
+
currency: USD
|
@@ -0,0 +1,24 @@
|
|
1
|
+
sams_widget:
|
2
|
+
id: 1
|
3
|
+
buyer_id: 1
|
4
|
+
buyer_type: BuyingUser
|
5
|
+
status: created
|
6
|
+
net_cents: 2995
|
7
|
+
tax_cents: 0
|
8
|
+
gross_cents: 2995
|
9
|
+
currency: USD
|
10
|
+
type: MerchantSidekick::PurchaseOrder
|
11
|
+
paid:
|
12
|
+
id: 2
|
13
|
+
buyer_id: 1
|
14
|
+
buyer_type: BuyingUser
|
15
|
+
type: MerchantSidekick::PurchaseOrder
|
16
|
+
unpaid:
|
17
|
+
id: 3
|
18
|
+
buyer_id: 1
|
19
|
+
buyer_type: BuyingUser
|
20
|
+
net_cents: 12321
|
21
|
+
tax_cents: 0
|
22
|
+
gross_cents: 12321
|
23
|
+
currency: USD
|
24
|
+
type: MerchantSidekick::PurchaseOrder
|
@@ -0,0 +1,17 @@
|
|
1
|
+
first:
|
2
|
+
id: 1
|
3
|
+
payable_id: 2
|
4
|
+
payable_type: Order
|
5
|
+
cents: 9995
|
6
|
+
currency: USD
|
7
|
+
confirmation: 100000001
|
8
|
+
created_at: <%= 6.minutes.ago.to_s :db %>
|
9
|
+
updated_at: <%= 6.minutes.ago.to_s :db %>
|
10
|
+
authorized:
|
11
|
+
id: 2
|
12
|
+
payable_id: 1
|
13
|
+
payable_type: Order
|
14
|
+
cents: 14995
|
15
|
+
currency: USD
|
16
|
+
confirmation: 12345
|
17
|
+
updated_at: <%= 1.week.ago.to_s :db %>
|
@@ -0,0 +1,136 @@
|
|
1
|
+
require File.expand_path("../spec_helper", __FILE__)
|
2
|
+
|
3
|
+
describe MerchantSidekick::Gateway do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
MerchantSidekick::Gateway.default_gateway = nil
|
7
|
+
MerchantSidekick::Gateway.config = nil
|
8
|
+
MerchantSidekick::Gateway.config_path = nil
|
9
|
+
MerchantSidekick::Gateway.gateway = nil
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should have a config file name" do
|
13
|
+
MerchantSidekick::Gateway.should respond_to(:config_file_name)
|
14
|
+
MerchantSidekick::Gateway.config_file_name.should == "merchant_sidekick.yml"
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should have a config path" do
|
18
|
+
MerchantSidekick::Gateway.should respond_to(:config_path)
|
19
|
+
Pathname.new(MerchantSidekick::Gateway.config_path).basename.to_s.should == "merchant_sidekick.yml"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should have a default gateway" do
|
23
|
+
MerchantSidekick::Gateway.should respond_to(:default_gateway)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should have a type" do
|
27
|
+
MerchantSidekick::Gateway.should respond_to(:type)
|
28
|
+
MerchantSidekick::Gateway.type.should == :gateway
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should have a config" do
|
32
|
+
MerchantSidekick::Gateway.should respond_to(:config)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should read from default config" do
|
36
|
+
MerchantSidekick::Gateway.config.should be_instance_of(Hash)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should throw a runtime error on unassigned default gateway" do
|
40
|
+
lambda {MerchantSidekick::Gateway.default_gateway}.should raise_error(RuntimeError)
|
41
|
+
end
|
42
|
+
|
43
|
+
after(:all) do
|
44
|
+
MerchantSidekick::Gateway.default_gateway = ActiveMerchant::Billing::BogusGateway.new
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
describe MerchantSidekick::ActiveMerchant::Gateways::AuthorizeNetGateway do
|
51
|
+
|
52
|
+
before(:each) do
|
53
|
+
MerchantSidekick::Gateway.default_gateway = nil
|
54
|
+
MerchantSidekick::Gateway.config = nil
|
55
|
+
MerchantSidekick::Gateway.config_path = nil
|
56
|
+
MerchantSidekick::Gateway.gateway = nil
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should read config" do
|
60
|
+
MerchantSidekick::ActiveMerchant::Gateways::AuthorizeNetGateway.config[:login_id].should == "foo"
|
61
|
+
MerchantSidekick::ActiveMerchant::Gateways::AuthorizeNetGateway.config[:transaction_key].should == "bar"
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should return active merchant authorize_net gateway instance" do
|
65
|
+
2.times {MerchantSidekick::ActiveMerchant::Gateways::AuthorizeNetGateway.gateway.should be_instance_of(::ActiveMerchant::Billing::AuthorizeNetGateway)}
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should return active merchant gateway instance for default_gateway type" do
|
69
|
+
MerchantSidekick::default_gateway = :authorize_net_gateway
|
70
|
+
MerchantSidekick::default_gateway.should be_instance_of(::ActiveMerchant::Billing::AuthorizeNetGateway)
|
71
|
+
MerchantSidekick::Gateway.default_gateway.should be_instance_of(::ActiveMerchant::Billing::AuthorizeNetGateway)
|
72
|
+
end
|
73
|
+
|
74
|
+
after(:all) do
|
75
|
+
MerchantSidekick::Gateway.default_gateway = ActiveMerchant::Billing::BogusGateway.new
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
describe MerchantSidekick::ActiveMerchant::Gateways::PaypalGateway do
|
82
|
+
|
83
|
+
before(:each) do
|
84
|
+
MerchantSidekick::Gateway.default_gateway = nil
|
85
|
+
MerchantSidekick::Gateway.config = nil
|
86
|
+
MerchantSidekick::Gateway.config_path = nil
|
87
|
+
MerchantSidekick::Gateway.gateway = nil
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should read config" do
|
91
|
+
MerchantSidekick::ActiveMerchant::Gateways::PaypalGateway.config[:api_username].should == "seller_XYZ_biz_api1.example.com"
|
92
|
+
MerchantSidekick::ActiveMerchant::Gateways::PaypalGateway.config[:api_password].should == "ABCDEFG123456789"
|
93
|
+
MerchantSidekick::ActiveMerchant::Gateways::PaypalGateway.config[:signature].should == "AsPC9BjkCyDFQXbStoZcgqH3hpacAX3IenGazd35.nEnXJKR9nfCmJDu"
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should return active merchant paypal gateway instance" do
|
97
|
+
2.times {MerchantSidekick::ActiveMerchant::Gateways::PaypalGateway.gateway.should be_instance_of(::ActiveMerchant::Billing::PaypalGateway)}
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should return active merchant gateway instance for default_gateway type" do
|
101
|
+
MerchantSidekick::default_gateway = :paypal_gateway
|
102
|
+
MerchantSidekick::default_gateway.should be_instance_of(::ActiveMerchant::Billing::PaypalGateway)
|
103
|
+
MerchantSidekick::Gateway.default_gateway.should be_instance_of(::ActiveMerchant::Billing::PaypalGateway)
|
104
|
+
end
|
105
|
+
|
106
|
+
after(:all) do
|
107
|
+
MerchantSidekick::Gateway.default_gateway = ActiveMerchant::Billing::BogusGateway.new
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
|
113
|
+
describe MerchantSidekick::ActiveMerchant::Gateways::BogusGateway do
|
114
|
+
|
115
|
+
before(:each) do
|
116
|
+
MerchantSidekick::Gateway.default_gateway = nil
|
117
|
+
MerchantSidekick::Gateway.config = nil
|
118
|
+
MerchantSidekick::Gateway.config_path = nil
|
119
|
+
MerchantSidekick::Gateway.gateway = nil
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should return active merchant paypal gateway instance" do
|
123
|
+
2.times {MerchantSidekick::ActiveMerchant::Gateways::BogusGateway.gateway.should be_instance_of(::ActiveMerchant::Billing::BogusGateway)}
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should return active merchant gateway instance for default_gateway type" do
|
127
|
+
MerchantSidekick::default_gateway = :bogus_gateway
|
128
|
+
MerchantSidekick::default_gateway.should be_instance_of(::ActiveMerchant::Billing::BogusGateway)
|
129
|
+
MerchantSidekick::Gateway.default_gateway.should be_instance_of(::ActiveMerchant::Billing::BogusGateway)
|
130
|
+
end
|
131
|
+
|
132
|
+
after(:all) do
|
133
|
+
MerchantSidekick::Gateway.default_gateway = ActiveMerchant::Billing::BogusGateway.new
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|