culqi-ruby-oficial 1.0.0 → 1.0.5
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/lib/culqi/card.rb +16 -16
- data/lib/culqi/charge.rb +20 -20
- data/lib/culqi/customer.rb +17 -17
- data/lib/culqi/event.rb +14 -14
- data/lib/culqi/iins.rb +14 -14
- data/lib/culqi/order.rb +18 -17
- data/lib/culqi/plan.rb +16 -16
- data/lib/culqi/refund.rb +15 -15
- data/lib/culqi/subscription.rb +16 -16
- data/lib/culqi/token.rb +37 -15
- data/lib/culqi/transfer.rb +14 -14
- data/lib/culqi/version.rb +3 -3
- data/lib/culqi/yape.rb +13 -13
- data/lib/culqi-ruby.rb +38 -32
- data/lib/operation/confirm_type.rb +24 -19
- data/lib/operation/delete.rb +19 -14
- data/lib/operation/get.rb +57 -14
- data/lib/operation/list.rb +64 -14
- data/lib/operation/post.rb +85 -27
- data/lib/operation/update.rb +22 -17
- data/lib/util/connect.rb +54 -42
- data/lib/util/country-codes.rb +22 -0
- data/lib/util/encrypt-data.rb +49 -49
- data/lib/util/validation/card.rb +38 -0
- data/lib/util/validation/charge.rb +131 -0
- data/lib/util/validation/customer.rb +41 -0
- data/lib/util/validation/error.rb +17 -0
- data/lib/util/validation/helper.rb +40 -0
- data/lib/util/validation/order.rb +78 -0
- data/lib/util/validation/plan.rb +71 -0
- data/lib/util/validation/refund.rb +47 -0
- data/lib/util/validation/subscription.rb +26 -0
- data/lib/util/validation/token.rb +70 -0
- metadata +12 -3
- data/lib/CulqiCRUD.rb +0 -344
- data/lib/test_list.rb +0 -37
data/lib/CulqiCRUD.rb
DELETED
@@ -1,344 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'securerandom'
|
3
|
-
require 'json'
|
4
|
-
|
5
|
-
class CulqiTest < Minitest::Test
|
6
|
-
|
7
|
-
def createTokenEncrypt
|
8
|
-
rsa_key = Culqi.rsa_key
|
9
|
-
rsa_id = Culqi.rsa_id
|
10
|
-
params ={
|
11
|
-
:card_number => '4557880621568322',
|
12
|
-
:cvv => '111',
|
13
|
-
:currency_code => 'PEN',
|
14
|
-
:email => 'test1231@culqi.com',
|
15
|
-
:expiration_month => 11,
|
16
|
-
:expiration_year => 2026
|
17
|
-
}
|
18
|
-
token = Culqi::Token.create(params, rsa_key, rsa_id)
|
19
|
-
puts token
|
20
|
-
return JSON.parse(token)
|
21
|
-
end
|
22
|
-
def createYape
|
23
|
-
params = {
|
24
|
-
:amount => '1000',
|
25
|
-
:fingerprint => '86d3c875769bf62b0471b47853bfda77',
|
26
|
-
:number_phone => '900000001',
|
27
|
-
:otp => '111111'
|
28
|
-
}
|
29
|
-
|
30
|
-
yape = Culqi::Token.create(params)
|
31
|
-
return JSON.parse(yape)
|
32
|
-
|
33
|
-
end
|
34
|
-
def createToken
|
35
|
-
params ={
|
36
|
-
:card_number => '4557880621568322',
|
37
|
-
:cvv => '111',
|
38
|
-
:currency_code => 'PEN',
|
39
|
-
:email => 'test1231@culqi.com',
|
40
|
-
:expiration_month => 11,
|
41
|
-
:expiration_year => 2026
|
42
|
-
}
|
43
|
-
token = Culqi::Token.create(params)
|
44
|
-
puts token
|
45
|
-
return JSON.parse(token)
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
def createCharge
|
50
|
-
params = {
|
51
|
-
:amount => 1000,
|
52
|
-
:capture => false,
|
53
|
-
:currency_code => 'PEN',
|
54
|
-
:description => 'Venta de prueba',
|
55
|
-
:email => 'test'+SecureRandom.uuid+'@culqi.com',
|
56
|
-
:installments => 0,
|
57
|
-
:metadata => ({
|
58
|
-
:test => 'test123'
|
59
|
-
}),
|
60
|
-
:source_id => createToken['id']
|
61
|
-
}
|
62
|
-
charge = Culqi::Charge.create(params)
|
63
|
-
puts charge
|
64
|
-
return JSON.parse(charge)
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
def createChargeEncrypt
|
69
|
-
rsa_key = Culqi.rsa_key
|
70
|
-
rsa_id = Culqi.rsa_id
|
71
|
-
params = {
|
72
|
-
:amount => 1000,
|
73
|
-
:capture => false,
|
74
|
-
:currency_code => 'PEN',
|
75
|
-
:description => 'Venta de prueba',
|
76
|
-
:email => 'test'+SecureRandom.uuid+'@culqi.com',
|
77
|
-
:installments => 0,
|
78
|
-
:metadata => ({
|
79
|
-
:test => 'test123'
|
80
|
-
}),
|
81
|
-
:source_id => createToken['id']
|
82
|
-
}
|
83
|
-
charge = Culqi::Charge.create(params, rsa_key, rsa_id)
|
84
|
-
return JSON.parse(charge)
|
85
|
-
|
86
|
-
end
|
87
|
-
|
88
|
-
def createOrder
|
89
|
-
params = {
|
90
|
-
:amount => 1000,
|
91
|
-
:currency_code => 'PEN',
|
92
|
-
:description => 'Venta de prueba',
|
93
|
-
:order_number => 'pedido-9966690044449',
|
94
|
-
:client_details => ({
|
95
|
-
:first_name => 'Richard',
|
96
|
-
:last_name => 'Hendricks',
|
97
|
-
:email => 'richar3d@piedpiper.com',
|
98
|
-
:phone_number => '+51945145280'
|
99
|
-
}),
|
100
|
-
:expiration_date => '1682039645'
|
101
|
-
}
|
102
|
-
order = Culqi::Order.create(params)
|
103
|
-
puts order
|
104
|
-
return JSON.parse(order)
|
105
|
-
|
106
|
-
end
|
107
|
-
|
108
|
-
def updateOrder
|
109
|
-
id = 'ord_live_q9TujOO4KSf2kRNv'
|
110
|
-
params = {
|
111
|
-
:metadata => ({
|
112
|
-
:dni => '71701978'
|
113
|
-
}),
|
114
|
-
:expiration_date => '1682039645'
|
115
|
-
}
|
116
|
-
order = Culqi::Order.update(id, params)
|
117
|
-
puts order
|
118
|
-
return JSON.parse(order)
|
119
|
-
|
120
|
-
end
|
121
|
-
|
122
|
-
def createOrderEncrypt
|
123
|
-
rsa_key = Culqi.rsa_key
|
124
|
-
rsa_id = Culqi.rsa_id
|
125
|
-
params = {
|
126
|
-
:amount => 1000,
|
127
|
-
:currency_code => 'PEN',
|
128
|
-
:description => 'Venta de prueba',
|
129
|
-
:order_number => 'pedido-999002',
|
130
|
-
:client_details => ({
|
131
|
-
:first_name => 'Richard',
|
132
|
-
:last_name => 'Hendricks',
|
133
|
-
:email => 'richard@piedpiper.com',
|
134
|
-
:phone_number => '+51945145280'
|
135
|
-
}),
|
136
|
-
:expiration_date => '1682039645'
|
137
|
-
}
|
138
|
-
order = Culqi::Order.create(params, rsa_key, rsa_id)
|
139
|
-
return JSON.parse(order)
|
140
|
-
|
141
|
-
end
|
142
|
-
|
143
|
-
def createPlan
|
144
|
-
params = {
|
145
|
-
:amount => 1000,
|
146
|
-
:currency_code => 'PEN',
|
147
|
-
:interval => 'dias',
|
148
|
-
:interval_count => 2,
|
149
|
-
:limit => 10,
|
150
|
-
:metadata => ({
|
151
|
-
:alias => 'plan_test'
|
152
|
-
}),
|
153
|
-
:name => 'plan-test-'+SecureRandom.uuid,
|
154
|
-
:trial_days => 50
|
155
|
-
}
|
156
|
-
|
157
|
-
plan = Culqi::Plan.create(params)
|
158
|
-
|
159
|
-
return JSON.parse(plan)
|
160
|
-
|
161
|
-
end
|
162
|
-
|
163
|
-
def createCustomer
|
164
|
-
params = {
|
165
|
-
:address => 'Avenida Lima 123213',
|
166
|
-
:address_city => 'LIMA',
|
167
|
-
:country_code => 'PE',
|
168
|
-
:email => 'test'+SecureRandom.uuid+'@culqi.com',
|
169
|
-
:first_name => 'William',
|
170
|
-
:last_name => 'Muro',
|
171
|
-
:metadata => ({
|
172
|
-
:other_number => '789953655'
|
173
|
-
}),
|
174
|
-
:phone_number => 998989789
|
175
|
-
}
|
176
|
-
customer = Culqi::Customer.create(params)
|
177
|
-
|
178
|
-
return JSON.parse(customer)
|
179
|
-
|
180
|
-
end
|
181
|
-
|
182
|
-
def createCard
|
183
|
-
params = {
|
184
|
-
:customer_id => createCustomer['id'],
|
185
|
-
:token_id => createToken['id']
|
186
|
-
}
|
187
|
-
card = Culqi::Card.create(params)
|
188
|
-
|
189
|
-
return JSON.parse(card)
|
190
|
-
|
191
|
-
end
|
192
|
-
|
193
|
-
|
194
|
-
def createSubscription
|
195
|
-
params = {
|
196
|
-
:card_id => createCard['id'],
|
197
|
-
:plan_id => createPlan['id']
|
198
|
-
}
|
199
|
-
subscription = Culqi::Subscription.create(params)
|
200
|
-
|
201
|
-
return JSON.parse(subscription)
|
202
|
-
|
203
|
-
end
|
204
|
-
|
205
|
-
def createRefund
|
206
|
-
params = {
|
207
|
-
:amount => 500,
|
208
|
-
:charge_id => createCharge['id'],
|
209
|
-
:reason => 'solicitud_comprador'
|
210
|
-
}
|
211
|
-
refund = Culqi::Refund.create(params)
|
212
|
-
return JSON.parse(refund)
|
213
|
-
end
|
214
|
-
|
215
|
-
def confirmOrder
|
216
|
-
confirmOrder = Culqi::Order.confirm(
|
217
|
-
:order_id => 'ord_live_7QmBi7Sh1ctxAe5s',
|
218
|
-
:order_types => ([
|
219
|
-
"cuotealo",
|
220
|
-
"cip"
|
221
|
-
])
|
222
|
-
)
|
223
|
-
puts confirmOrder
|
224
|
-
return JSON.parse(confirmOrder)
|
225
|
-
end
|
226
|
-
|
227
|
-
def test_create_token_encrypt
|
228
|
-
assert_equal 'token', createTokenEncrypt['object']
|
229
|
-
end
|
230
|
-
def test_create_yape
|
231
|
-
assert_equal 'token', createYape['object']
|
232
|
-
end
|
233
|
-
def test_create_token
|
234
|
-
assert_equal 'token', createToken['object']
|
235
|
-
end
|
236
|
-
|
237
|
-
def test_create_charge
|
238
|
-
assert_equal 'charge', createCharge['object']
|
239
|
-
end
|
240
|
-
|
241
|
-
def test_create_charge_encrypt
|
242
|
-
assert_equal 'charge', createChargeEncrypt['object']
|
243
|
-
end
|
244
|
-
|
245
|
-
def test_create_order
|
246
|
-
assert_equal 'order', createOrder['object']
|
247
|
-
end
|
248
|
-
|
249
|
-
def test_update_order
|
250
|
-
assert_equal 'order', updateOrder['object']
|
251
|
-
end
|
252
|
-
|
253
|
-
def test_create_order_encrypt
|
254
|
-
assert_equal 'order', createOrderEncrypt['object']
|
255
|
-
end
|
256
|
-
|
257
|
-
def test_create_plan
|
258
|
-
assert_equal "plan", createPlan['object']
|
259
|
-
end
|
260
|
-
|
261
|
-
def test_create_customer
|
262
|
-
assert_equal 'customer', createCustomer['object']
|
263
|
-
end
|
264
|
-
|
265
|
-
def test_create_card
|
266
|
-
assert_equal 'card', createCard['object']
|
267
|
-
end
|
268
|
-
|
269
|
-
def test_create_subscription
|
270
|
-
assert_equal 'subscription', createSubscription['object']
|
271
|
-
end
|
272
|
-
|
273
|
-
def test_create_refund
|
274
|
-
assert_equal 'refund', createRefund['object']
|
275
|
-
end
|
276
|
-
|
277
|
-
#CONFIRM ORDER
|
278
|
-
def test_confirm_order
|
279
|
-
assert_equal 'order', confirmOrder['object']
|
280
|
-
end
|
281
|
-
|
282
|
-
# GET RESOURCES
|
283
|
-
|
284
|
-
def test_get_token
|
285
|
-
assert_equal 'token', JSON.parse(Culqi::Token.get(createToken['id']))['object']
|
286
|
-
end
|
287
|
-
|
288
|
-
def test_get_order
|
289
|
-
assert_equal 'order', JSON.parse(Culqi::Token.get(createOrder['id']))['object']
|
290
|
-
end
|
291
|
-
|
292
|
-
def test_get_charge
|
293
|
-
assert_equal 'charge', JSON.parse(Culqi::Charge.get(createCharge['id']))['object']
|
294
|
-
end
|
295
|
-
|
296
|
-
def test_get_plan
|
297
|
-
assert_equal "plan", JSON.parse(Culqi::Plan.get(createPlan['id']))['object']
|
298
|
-
end
|
299
|
-
|
300
|
-
def test_get_customer
|
301
|
-
assert_equal 'customer', JSON.parse(Culqi::Customer.get(createCustomer['id']))['object']
|
302
|
-
end
|
303
|
-
|
304
|
-
def test_get_card
|
305
|
-
assert_equal 'card', JSON.parse(Culqi::Card.get(createCard['id']))['object']
|
306
|
-
end
|
307
|
-
|
308
|
-
def test_get_subscription
|
309
|
-
assert_equal 'subscription', JSON.parse(Culqi::Subscription.get(createSubscription['id']))['object']
|
310
|
-
end
|
311
|
-
|
312
|
-
def test_get_refund
|
313
|
-
assert_equal 'refund', JSON.parse(Culqi::Refund.get(createRefund['id']))['object']
|
314
|
-
end
|
315
|
-
|
316
|
-
# DELETE RESOURCES
|
317
|
-
|
318
|
-
def test_delete_subscription
|
319
|
-
assert_equal true, JSON.parse(Culqi::Subscription.delete(createSubscription['id']))['deleted']
|
320
|
-
end
|
321
|
-
|
322
|
-
def test_delete_plan
|
323
|
-
assert_equal true, JSON.parse(Culqi::Plan.delete(createPlan['id']))['deleted']
|
324
|
-
end
|
325
|
-
|
326
|
-
def test_delete_card
|
327
|
-
assert_equal true, JSON.parse(Culqi::Card.delete(createCard['id']))['deleted']
|
328
|
-
end
|
329
|
-
|
330
|
-
def test_delete_customer
|
331
|
-
assert_equal true, JSON.parse(Culqi::Customer.delete(createCustomer['id']))['deleted']
|
332
|
-
end
|
333
|
-
|
334
|
-
def test_delete_order
|
335
|
-
assert_equal true, JSON.parse(Culqi::Order.delete(createOrder['id']))['deleted']
|
336
|
-
end
|
337
|
-
|
338
|
-
# CAPTURE CHARGE
|
339
|
-
|
340
|
-
def test_capture_charge
|
341
|
-
assert_equal 'charge', JSON.parse(Culqi::Charge.capture(createCharge['id']))['object']
|
342
|
-
end
|
343
|
-
|
344
|
-
end
|
data/lib/test_list.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class TestList < Minitest::Test
|
4
|
-
|
5
|
-
def test_tokens
|
6
|
-
assert_operator JSON.parse(Culqi::Token.list())['data'].count, :>=, 0
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_charges
|
10
|
-
assert_operator JSON.parse(Culqi::Charge.list())['data'].count, :>=, 0
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_plans
|
14
|
-
assert_operator JSON.parse(Culqi::Plan.list())['data'].count, :>=, 0
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_customers
|
18
|
-
assert_operator JSON.parse(Culqi::Customer.list())['data'].count, :>=, 0
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_cards
|
22
|
-
assert_operator JSON.parse(Culqi::Card.list())['data'].count, :>=, 0
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_refunds
|
26
|
-
assert_operator JSON.parse(Culqi::Refund.list())['data'].count, :>=, 0
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_events
|
30
|
-
assert_operator JSON.parse(Culqi::Event.list())['data'].count, :>=, 0
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_transfers
|
34
|
-
assert_operator JSON.parse(Culqi::Transfer.list())['data'].count, :>=, 0
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|