conekta 0.5.2 → 0.5.3

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.
@@ -0,0 +1,67 @@
1
+ require 'spec_helper'
2
+
3
+ describe Conekta::Error do
4
+ let(:card) { { cards: ["tok_test_visa_4242"] } }
5
+
6
+ it "test no id error" do
7
+ expect { Conekta::Charge.find(nil) }.to raise_error(
8
+ Conekta::Error, "Could not get the id of Charge instance."
9
+ )
10
+ end
11
+
12
+ it "test no connection error" do
13
+ api_url = Conekta::api_base
14
+ Conekta::api_base = 'http://localhost:3001'
15
+
16
+ expect { Conekta::Customer.create(card) }.to raise_error(
17
+ Conekta::NoConnectionError, "Could not connect to http://localhost:3001."
18
+ )
19
+
20
+ # cleanup
21
+ Conekta::api_base = api_url
22
+ end
23
+
24
+ it "test api error" do
25
+ expect { Conekta::Customer.create({ cards: {0=>"tok_test_visa_4242"} }) }.to \
26
+ raise_error(Conekta::ParameterValidationError)
27
+ end
28
+
29
+ it "test authentication error" do
30
+ Conekta::api_key = ""
31
+ expect { Conekta::Customer.create({ cards: ["tok_test_visa_4242"] }) }.to \
32
+ raise_error(Conekta::AuthenticationError)
33
+
34
+ # cleanup
35
+ Conekta.api_key = '1tv5yJp3xnVZ7eK67m4h'
36
+ end
37
+
38
+ it "test parameter validation error" do
39
+ expect { Conekta::Plan.create({id: 'gold-plan'}) }.to raise_error(
40
+ Conekta::ParameterValidationError
41
+ )
42
+ end
43
+
44
+ it "test processing error" do
45
+ charge = nil
46
+ charges = Conekta::Charge.where()
47
+ charges.each do |(k,v)|
48
+ if v.status == "pre_authorized"
49
+ charge = v
50
+ break
51
+ end
52
+ end
53
+ begin
54
+ if charge
55
+ charge.capture
56
+ end
57
+ rescue Conekta::Error => e
58
+ expect(e.class_name).to eq("ProcessingError")
59
+ end
60
+ end
61
+
62
+ it "test resource not found error" do
63
+ expect { Conekta::Charge.find(1) }.to raise_error(
64
+ Conekta::ResourceNotFoundError
65
+ )
66
+ end
67
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe Conekta::Event do
4
+ it "test succesful where" do
5
+ events = Conekta::Event.where
6
+ expect(events.class_name).to eq("ConektaObject")
7
+ expect(events[0].class_name).to eq("Event")
8
+ if !events[0].webhook_logs.empty?
9
+ expect(events[0].webhook_logs.first.class_name).to eq("WebhookLog")
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+ # require 'conekta'
3
+
4
+ describe Conekta::Payee do
5
+
6
+ describe 'an instance' do
7
+ let(:payee_attributes) do
8
+ {
9
+ name: "John Doe", email: "j_d@radcorp.com", phone: "555555555",
10
+ billing_address:{
11
+ company_name: 'Rad Corp',
12
+ tax_id: 'tax121212abc',
13
+ street1: 'Guadalupe 73',
14
+ street2: 'Despacho 32',
15
+ street3: 'Condesa',
16
+ city: 'Cuauhtemoc',
17
+ state: 'DF',
18
+ country: 'MX',
19
+ zip: '06100'
20
+ }
21
+ }
22
+ end
23
+
24
+ it 'creates successfully' do
25
+ payee = Conekta::Payee.create(payee_attributes)
26
+ expect(payee).to be_a(Conekta::Payee)
27
+ end
28
+
29
+ describe ':payout_methods' do
30
+ let!(:payee) { Conekta::Payee.create(payee_attributes) }
31
+ let(:bank_attributes) do
32
+ {
33
+ account_number: '032180000118359719',
34
+ account_holder: 'J D - Radcorp',
35
+ description: 'Conekta To JD',
36
+ statement_description: 'Conekta To JD 111111111',
37
+ statement_reference: '111111111'
38
+ }
39
+ end
40
+
41
+ it 'can create payout methods' do
42
+ payout_method = payee.create_payout_method(bank_attributes)
43
+ expect(payout_method).to be_a(Conekta::Method)
44
+ # I'm sure this should be a Conekta::PayoutMethod,
45
+ # just not sure why it's reporting back as a Conekta::Method
46
+ end
47
+
48
+ it 'assigns default_payout_method_id to first payout method created' do
49
+ payout_method = payee.create_payout_method(bank_attributes)
50
+ # refetch the payee object
51
+ payee = Conekta::Payee.find(payout_method.payee_id)
52
+ expect(payee.default_payout_method_id).to eq(payout_method.id)
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,59 @@
1
+ require 'spec_helper'
2
+
3
+ describe Conekta::Payout do
4
+ let(:payee_attributes) do
5
+ {
6
+ name: "John Doe", email: "j_d@radcorp.com", phone: "555555555",
7
+ billing_address:{
8
+ company_name: 'Rad Corp',
9
+ tax_id: 'tax121212abc',
10
+ street1: 'Guadalupe 73',
11
+ street2: 'Despacho 32',
12
+ street3: 'Condesa',
13
+ city: 'Cuauhtemoc',
14
+ state: 'DF',
15
+ country: 'MX',
16
+ zip: '06100'
17
+ }
18
+ }
19
+ end
20
+
21
+ let(:bank_attributes) do
22
+ {
23
+ account_number: '032180000118359719',
24
+ account_holder: 'J D - Radcorp',
25
+ description: 'Conekta To JD',
26
+ statement_description: 'Conekta To JD 111111111',
27
+ statement_reference: '111111111'
28
+ }
29
+ end
30
+
31
+ describe 'an instance' do
32
+ before do
33
+ payee = Conekta::Payee.create(payee_attributes)
34
+ payout_method = payee.create_payout_method(bank_attributes)
35
+
36
+ @payee = Conekta::Payee.find(payee.id)
37
+ end
38
+
39
+ it 'is created successfully' do
40
+ payout = Conekta::Payout.create(
41
+ amount: 5000, currency: "MXN", payee: @payee.id
42
+ )
43
+ expect(payout).to be_a(Conekta::Payout)
44
+ end
45
+
46
+ it 'can be retrieved by :id' do
47
+ transaction = Conekta::Payout.create(
48
+ amount: 5000, currency: "MXN", payee: @payee.id
49
+ )
50
+ # refetch payout
51
+ payout = Conekta::Payout.find(transaction.id)
52
+ expect(payout).to be_a(Conekta::Payout)
53
+ end
54
+
55
+ it 'has a :method attribute' do
56
+ expect(@payee.payout_methods.first).to be_a(Conekta::Method)
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+
3
+ describe Conekta::Plan do
4
+ context "get/where" do
5
+ it "test succesful get plan" do
6
+ plans = Conekta::Plan.where
7
+ p = plans.first;
8
+ plan = Conekta::Plan.find(p.id)
9
+ expect(plan).to be_a(Conekta::Plan)
10
+ end
11
+
12
+ it "test succesful where" do
13
+ plans = Conekta::Plan.where
14
+ expect(plans.class_name).to eq("ConektaObject")
15
+ expect(plans.first).to be_a(Conekta::Plan)
16
+ end
17
+ end
18
+
19
+ context "creating plans" do
20
+ it "test succesful create plan" do
21
+ plan = Conekta::Plan.create(
22
+ id: ((0...8).map { (65 + rand(26)).chr }.join),
23
+ name: "Gold Plan",
24
+ amount: 10000,
25
+ currency: "MXN",
26
+ interval: "month",
27
+ frequency: 10,
28
+ trial_period_days: 15,
29
+ expiry_count: 12
30
+ )
31
+ expect(plan).to be_a(Conekta::Plan)
32
+ end
33
+ end
34
+
35
+ context "updating plans" do
36
+ it "test update plan" do
37
+ plans = Conekta::Plan.where
38
+ plan = plans.first
39
+ plan.update({name: "Silver Plan"})
40
+ expect(plan.name).to eq("Silver Plan")
41
+ end
42
+ end
43
+
44
+ context "deleting plans" do
45
+ it "test delete plan" do
46
+ plans = Conekta::Plan.where
47
+ plan = plans.first
48
+ plan.delete
49
+ expect(plan.deleted).to eq(true)
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,4 @@
1
+ require 'spec_helper'
2
+
3
+ describe Conekta::Token do
4
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe Conekta::Webhook do
4
+ let!(:events) do
5
+ {
6
+ events: [
7
+ "charge.created", "charge.paid", "charge.under_fraud_review",
8
+ "charge.fraudulent", "charge.refunded", "charge.created", "customer.created",
9
+ "customer.updated", "customer.deleted", "webhook.created", "webhook.updated",
10
+ "webhook.deleted", "charge.chargeback.created", "charge.chargeback.updated",
11
+ "charge.chargeback.under_review", "charge.chargeback.lost", "charge.chargeback.won",
12
+ "payout.created", "payout.retrying", "payout.paid_out", "payout.failed",
13
+ "plan.created", "plan.updated", "plan.deleted", "subscription.created",
14
+ "subscription.paused", "subscription.resumed", "subscription.canceled",
15
+ "subscription.expired", "subscription.updated", "subscription.paid",
16
+ "subscription.payment_failed", "payee.created", "payee.updated",
17
+ "payee.deleted", "payee.payout_method.created",
18
+ "payee.payout_method.updated", "payee.payout_method.deleted"
19
+ ]
20
+ }
21
+ end
22
+ let(:url) { { url: "http://localhost:3000/my_listener" } }
23
+
24
+ it "succesfully gets charge" do
25
+ webhook = Conekta::Webhook.create(url.merge(events))
26
+ expect(webhook.webhook_url).to eq(url[:url])
27
+ webhook = Conekta::Webhook.find(webhook.id)
28
+ expect(webhook.webhook_url).to eq(url[:url])
29
+ webhook.update({url: "http://localhost:2000/my_listener"})
30
+ expect(webhook.webhook_url).to eq("http://localhost:2000/my_listener")
31
+ webhook.delete
32
+ end
33
+ end
@@ -1,418 +1,23 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
- describe :conekta_tests do
3
- Conekta.api_key = '1tv5yJp3xnVZ7eK67m4h'
4
- describe :payouts_tests do
5
- p "payout tests"
6
- before :each do
7
- @valid_payment_method = {amount: 2000, currency: 'mxn', description: 'Some desc'}
8
- @invalid_payment_method = {amount: 10, currency: 'mxn', description: 'Some desc'}
9
- @valid_visa_card = {card: 'tok_test_visa_4242'}
10
- end
11
- it "succesful get payout" do
12
- payee = Conekta::Payee.create(name: "John Doe",
13
- email: "j_d@radcorp.com",
14
- phone: "555555555",
15
- bank: {
16
- account_number: '032180000118359719',
17
- account_holder: 'J D - Radcorp',
18
- description: 'Conekta To JD',
19
- statement_description: 'Conekta To JD 111111111',
20
- statement_reference: '111111111'
21
- },
22
- billing_address:{
23
- company_name: 'Rad Corp',
24
- tax_id: 'tax121212abc',
25
- street1: 'Guadalupe 73',
26
- street2: 'Despacho 32',
27
- street3: 'Condesa',
28
- city: 'Cuauhtemoc',
29
- state: 'DF',
30
- country: 'MX',
31
- zip: '06100'
32
- })
33
- payee.class.class_name.should eq("Payee")
34
-
35
- payee.phone.should eq("555555555")
36
- payee.payout_methods.first.account_number.should eq('032180000118359719')
37
- payee.payout_methods.first.account_holder.should eq('J D - Radcorp')
38
- payee.payout_methods.first.bank.should eq('ixe')
39
- payee.default_payout_method_id.should_not eq(nil)
1
+ require 'spec_helper'
40
2
 
41
- payee.payout_methods.first.description.should eq('Conekta To JD')
42
- payee.payout_methods.first.statement_description.should eq('Conekta To JD 111111111')
43
- payee.payout_methods.first.statement_reference.should eq('111111111')
3
+ describe Conekta do
4
+ describe ".config" do
5
+ it "sets the api key initializer style" do
6
+ Conekta.config { |c| c.api_key = "abc" }
44
7
 
45
- payee.billing_address.company_name.should eq('Rad Corp')
46
- payee.billing_address.tax_id.should eq('tax121212abc')
47
- payee.billing_address.zip.should eq('06100')
8
+ expect(Conekta.api_key).to eq("abc")
9
+ end
48
10
 
49
- payout = Conekta::Payout.create(amount: 5000,
50
- currency: "MXN",
51
- payee: payee.id)
52
- payout.class.class_name.should eq("Payout")
53
- payout.amount.should eq(5000)
54
- payout.currency.should eq("MXN")
11
+ it "sets the api version initializer style" do
12
+ Conekta.config { |c| c.api_version = "1.0" }
55
13
 
56
- payout.method.account_number.should eq('032180000118359719')
57
- payout.method.account_holder.should eq('J D - Radcorp')
58
- payout.method.bank.should eq('ixe')
59
- payout.transactions.count.should eq(0)
60
- end
61
- end
62
- describe :charge_tests do
63
- p "charge tests"
64
- before :each do
65
- @valid_payment_method = {amount: 2000, currency: 'mxn', description: 'Some desc'}
66
- @invalid_payment_method = {amount: 10, currency: 'mxn', description: 'Some desc'}
67
- @valid_visa_card = {card: 'tok_test_visa_4242'}
68
- end
69
- it "succesful get charge" do
70
- pm = @valid_payment_method
71
- card = @valid_visa_card
72
- cpm = Conekta::Charge.create(pm.merge(card))
73
- cpm.status.should eq("paid")
74
- pm = Conekta::Charge.find(cpm.id)
75
- pm.class.class_name.should eq("Charge")
76
- end
77
- it "test succesful where" do
78
- charges = Conekta::Charge.where
79
- charges.class.class_name.should eq("ConektaObject")
80
- charges[0].class.class_name.should eq("Charge")
81
- end
82
- it "tests succesful bank pm create" do
83
- pm = @valid_payment_method
84
- bank = {bank: {'type' => 'banorte'}}
85
- bpm = Conekta::Charge.create(pm.merge(bank))
86
- bpm.status.should eq("pending_payment")
87
- end
88
- it "tests succesful card pm create" do
89
- pm = @valid_payment_method
90
- card = @valid_visa_card
91
- cpm = Conekta::Charge.create(pm.merge(card))
92
- cpm.status.should eq("paid")
93
- end
94
- it "tests succesful oxxo pm create" do
95
- pm = @valid_payment_method
96
- oxxo = {cash: {'type' => 'oxxo'}}
97
- bpm = Conekta::Charge.create(pm.merge(oxxo))
98
- bpm.status.should eq("pending_payment")
99
- end
100
- it "test unsuccesful pm create" do
101
- pm = @invalid_payment_method
102
- card = @valid_visa_card
103
- begin
104
- cpm = Conekta::Charge.create(pm.merge(card))
105
- rescue Conekta::Error => e
106
- e.message.should eq("The minimum for card payments is 3 pesos. Check that the amount is in cents as explained in the documentation.")
107
- end
108
- end
109
- it "test susccesful refund" do
110
- pm = @valid_payment_method
111
- card = @valid_visa_card
112
- cpm = Conekta::Charge.create(pm.merge(card))
113
- cpm.status.should eq("paid")
114
- cpm.refund
115
- cpm.status.should eq("refunded")
116
- end
117
- it "test unsusccesful refund" do
118
- pm = @valid_payment_method
119
- card = @valid_visa_card
120
- cpm = Conekta::Charge.create(pm.merge(card))
121
- cpm.status.should eq("paid")
122
- begin
123
- cpm.refund(3000)
124
- rescue Conekta::Error => e
125
- e.message.should eq("The order does not exist or the amount to refund is invalid")
126
- end
127
- end
128
- it "tests succesful card pm create" do
129
- pm = @valid_payment_method
130
- card = @valid_visa_card
131
- capture = {capture: false}
132
- cpm = Conekta::Charge.create(pm.merge(card).merge(capture))
133
- cpm.status.should eq("pre_authorized")
134
- cpm.capture
135
- cpm.status.should eq("paid")
136
- end
137
- end
138
- describe :customer_tests do
139
- p "customer tests"
140
- it "successful customer create" do
141
- customer = Conekta::Customer.create({
142
- :cards => ["tok_test_visa_4242"],
143
- })
144
- customer.class.class_name.should eq("Customer")
145
- end
146
- it "successful customer get" do
147
- c = Conekta::Customer.create({
148
- :cards => ["tok_test_visa_4242"],
149
- })
150
- customer = Conekta::Customer.find(c.id)
151
- customer.class.class_name.should eq("Customer")
152
- end
153
- it "successful customer where" do
154
- customers = Conekta::Customer.where
155
- customers.class.class_name.should eq("ConektaObject")
156
- customers[0].class.class_name.should eq("Customer")
157
- end
158
- it "successful customer delete" do
159
- customer = Conekta::Customer.create({
160
- :cards => ["tok_test_visa_4242"],
161
- })
162
- customer.delete
163
- customer.deleted.should eq(true)
164
- end
165
- it "successful customer update" do
166
- customer = Conekta::Customer.create({
167
- :cards => ["tok_test_visa_4242"],
168
- })
169
- customer.update({name: 'Logan', email: 'logan@x-men.org'})
170
- customer.name.should eq('Logan')
171
- end
172
- it "successful customer update" do
173
- begin
174
- customer = Conekta::Customer.create({
175
- :cards => ["tok_test_visa_4241"],
176
- })
177
- rescue Conekta::Error => e
178
- e.message.should eq("Object tok_test_visa_4241 could not be found.")
179
- end
180
- end
181
- it "add card to customer" do
182
- customer = Conekta::Customer.create({
183
- :cards => ["tok_test_visa_4242"],
184
- })
185
- card = customer.create_card(:token => 'tok_test_visa_1881')
186
- customer.cards.count.should eq(2)
187
- customer.cards.last.last4.should eq('1881')
188
- end
189
- it "test delete card" do
190
- customer = Conekta::Customer.create({
191
- :cards => ["tok_test_visa_4242"],
192
- })
193
- card = customer.cards[0].delete
194
- card.deleted.should eq(true)
195
- end
196
- it "test update card" do
197
- customer = Conekta::Customer.create({
198
- :cards => ["tok_test_visa_4242"],
199
- })
200
- customer.cards[0].update({token: 'tok_test_mastercard_4444', active: false})
201
- customer.cards[0].last4.should eq('4444')
202
- end
203
- it "test succesful create subscription" do
204
- customer = Conekta::Customer.create({
205
- :cards => ["tok_test_visa_4242"],
206
- })
207
- subscription = customer.create_subscription({plan: 'gold-plan'})
208
- subscription.class.class_name.should eq('Subscription')
209
- end
210
- it "test succesful update subscription" do
211
- customer = Conekta::Customer.create({
212
- :cards => ["tok_test_visa_4242"],
213
- })
214
- subscription = customer.create_subscription({plan: 'gold-plan'})
215
- begin
216
- plan = Conekta::Plan.find('gold-plan2')
217
- rescue Conekta::Error => e
218
- plan = Conekta::Plan.create({
219
- id: "gold-plan2",
220
- name: "Gold Plan",
221
- amount: 10000,
222
- currency: "MXN",
223
- interval: "month",
224
- frequency: 1,
225
- trial_period_days: 15,
226
- expiry_count: 12
227
- })
228
- end
229
- subscription.update({plan: plan.id})
230
- subscription.plan_id.should eq('gold-plan2')
14
+ expect(Conekta.api_version).to eq("1.0")
231
15
  end
232
- it "test unsuccesful create subscription" do
233
- customer = Conekta::Customer.create({
234
- :cards => ["tok_test_visa_4242"],
235
- })
236
- begin
237
- subscription = customer.create_subscription({plan: 'unexistent-plan'})
238
- rescue Conekta::Error => e
239
- e.message.should eq("Object Plan unexistent-plan could not be found.")
240
- end
241
- end
242
- it "test succesful pause subscription" do
243
- customer = Conekta::Customer.create({
244
- :cards => ["tok_test_visa_4242"],
245
- })
246
- subscription = customer.create_subscription({plan: 'gold-plan'})
247
- subscription.pause
248
- subscription.status.should eq('paused')
249
- end
250
- it "test succesful resume subscription" do
251
- customer = Conekta::Customer.create({
252
- :cards => ["tok_test_visa_4242"],
253
- })
254
- subscription = customer.create_subscription({plan: 'gold-plan'})
255
- subscription.resume
256
- subscription.status.should eq('active')
257
- end
258
- it "test succesful cancel subscription" do
259
- customer = Conekta::Customer.create({
260
- :cards => ["tok_test_visa_4242"],
261
- })
262
- subscription = customer.create_subscription({plan: 'gold-plan'})
263
- subscription.cancel
264
- subscription.status.should eq('canceled')
265
- end
266
- end
267
- describe :error_tests do
268
- p "error tests"
269
- it "test no id error" do
270
- begin
271
- charge = Conekta::Charge.find(nil)
272
- rescue Conekta::Error => e
273
- e.message.should eq('Could not get the id of Charge instance.')
274
- end
275
- end
276
- it "test no connection error" do
277
- api_url = Conekta::api_base
278
- Conekta::api_base = 'http://localhost:3001'
279
- begin
280
- customer = Conekta::Customer.create({cards: ["tok_test_visa_4242"]})
281
- rescue Exception => e
282
- e.class_name.should eq("NoConnectionError")
283
- end
284
- Conekta::api_base = api_url
285
- end
286
- it "test api error" do
287
- begin
288
- customer = Conekta::Customer.create({cards: {0=>"tok_test_visa_4242"}})
289
- rescue Conekta::Error => e
290
- e.class_name.should eq("ParameterValidationError")
291
- end
292
- end
293
- it "test authentication error" do
294
- Conekta::api_key = ""
295
- begin
296
- customer = Conekta::Customer.create({cards: ["tok_test_visa_4242"]})
297
- rescue Conekta::Error => e
298
- e.class_name.should eq("AuthenticationError")
299
- end
300
- Conekta.api_key = '1tv5yJp3xnVZ7eK67m4h'
301
- end
302
- it "test parameter validation error" do
303
- begin
304
- plan = Conekta::Plan.create({id: 'gold-plan'})
305
- rescue Conekta::Error => e
306
- e.class_name.should eq("ParameterValidationError")
307
- end
308
- end
309
- it "test processing error" do
310
- charge = nil
311
- charges = Conekta::Charge.where()
312
- charges.each do |(k,v)|
313
- if v.status == "pre_authorized"
314
- charge = v
315
- break
316
- end
317
- end
318
- begin
319
- if charge
320
- charge.capture
321
- end
322
- rescue Conekta::Error => e
323
- e.class_name.should eq("ProcessingError")
324
- end
325
- end
326
- it "test resource not found error" do
327
- begin
328
- charge = Conekta::Charge.find(1)
329
- rescue Conekta::Error => e
330
- e.class_name.should eq("ResourceNotFoundError")
331
- end
332
- end
333
- end
334
- describe :event_tests do
335
- p "event tests"
336
- it "test succesful where" do
337
- events = Conekta::Event.where
338
- events.class_name.should eq("ConektaObject")
339
- events[0].class_name.should eq("Event")
340
- if !events[0].webhook_logs.empty?
341
- events[0].webhook_logs.first.class_name.should eq("WebhookLog")
342
- end
343
- end
344
- end
345
- describe :token_tests do
346
- p "token tests"
347
- end
348
- describe :plan_tests do
349
- p "plan tests"
350
- it "test succesful get plan" do
351
- plans = Conekta::Plan.where
352
- p = plans.first;
353
- plan = Conekta::Plan.find(p.id)
354
- plan.class_name.should eq("Plan")
355
- end
356
- it "test succesful where" do
357
- plans = Conekta::Plan.where
358
- plans.class_name.should eq("ConektaObject")
359
- plans.first.class_name.should eq("Plan")
360
- end
361
- it "test succesful create plan" do
362
- plans = Conekta::Plan.where
363
- plan = Conekta::Plan.create({
364
- id: ((0...8).map { (65 + rand(26)).chr }.join),
365
- name: "Gold Plan",
366
- amount: 10000,
367
- currency: "MXN",
368
- interval: "month",
369
- frequency: 10,
370
- trial_period_days: 15,
371
- expiry_count: 12
372
- }
373
- )
374
- plan.class_name.should eq("Plan")
375
- end
376
- it "test update plan" do
377
- plans = Conekta::Plan.where
378
- plan = plans.first
379
- plan.update({name: "Silver Plan"})
380
- plan.name.should eq("Silver Plan")
381
- end
382
- it "test delete plan" do
383
- plans = Conekta::Plan.where
384
- plan = plans.first
385
- plan.delete
386
- plan.deleted.should eq(true)
387
- end
388
- end
389
- describe :webhook_tests do
390
- p "webhook tests"
391
- before :each do
392
- @events = { events: ["charge.created", "charge.paid", "charge.under_fraud_review",
393
- "charge.fraudulent", "charge.refunded", "charge.created", "customer.created",
394
- "customer.updated", "customer.deleted", "webhook.created", "webhook.updated",
395
- "webhook.deleted", "charge.chargeback.created", "charge.chargeback.updated",
396
- "charge.chargeback.under_review", "charge.chargeback.lost", "charge.chargeback.won",
397
- "payout.created", "payout.retrying", "payout.paid_out", "payout.failed",
398
- "plan.created", "plan.updated", "plan.deleted", "subscription.created",
399
- "subscription.paused", "subscription.resumed", "subscription.canceled",
400
- "subscription.expired", "subscription.updated", "subscription.paid",
401
- "subscription.payment_failed", "payee.created", "payee.updated",
402
- "payee.deleted", "payee.payout_method.created",
403
- "payee.payout_method.updated", "payee.payout_method.deleted"] }
404
- @url = { url: "http://localhost:3000/my_listener" }
405
- end
406
- it "succesful get charge" do
407
- events = @events
408
- url = @url
409
- webhook = Conekta::Webhook.create(url.merge(events))
410
- webhook.webhook_url.should eq(url[:url])
411
- webhook = Conekta::Webhook.find(webhook.id)
412
- webhook.webhook_url.should eq(url[:url])
413
- webhook.update({url: "http://localhost:2000/my_listener"})
414
- webhook.webhook_url.should eq("http://localhost:2000/my_listener")
415
- webhook.delete
16
+
17
+ it "sets the api locale initializer style" do
18
+ Conekta.config { |c| c.locale = "es" }
19
+
20
+ expect(Conekta.locale).to eq("es")
416
21
  end
417
22
  end
418
23
  end