conekta 2.4.2 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/conekta.rb +1 -0
- data/lib/conekta/checkout.rb +35 -0
- data/lib/conekta/order.rb +18 -18
- data/lib/conekta/util.rb +1 -0
- data/lib/conekta/version.rb +1 -1
- data/spec/conekta/2.0.0/checkout_spec.rb +224 -0
- data/spec/conekta/2.0.0/order_spec.rb +126 -41
- metadata +34 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3092b915bd4a4f22b5f6f25a3a429a9c5e7336c8fc059df11fe682cfd4400444
|
4
|
+
data.tar.gz: 223d90156fe51093ba049abc9c476811c4d2c6017db3625ad30b05f0d55cda02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44a9c41e5590e9ff92a77bbe17c3349d72e0d17669edfda2875e6ff1588cdababa9aa86b4a7cca634ff0acf8f0e185de47451d0be9fa43b3706c43dade91ca87
|
7
|
+
data.tar.gz: '08ea5f89a3edd5120631d744d45dbc168d0c7641975ed935df09db69cbdd1122fda8db31b542ae170f05eed3ee2d33499a3f358f372f30ac8dbdac73775b3729'
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## [2.5.0](https://github.com/conekta/conekta-ruby/releases/tag/2.5.0) - 2020-11-22
|
2
|
+
### Payment link
|
3
|
+
- Add models to support payment link (aka checkout).
|
4
|
+
|
1
5
|
## [2.4.2](https://github.com/conekta/conekta-ruby/releases/tag/2.4.2) - 2020-01-22
|
2
6
|
### Ruby 2.7 Cleanup
|
3
7
|
- Corrects warnings related to translate in Ruby 2.7
|
data/lib/conekta.rb
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
module Conekta
|
2
|
+
class Checkout < Resource
|
3
|
+
include Conekta::Operations::Create
|
4
|
+
include Conekta::Operations::Where
|
5
|
+
include Conekta::Operations::Find
|
6
|
+
include Conekta::Operations::CustomAction
|
7
|
+
|
8
|
+
attr_accessor :_id, :livemode, :company_id, :entity_id, :emails_sent,
|
9
|
+
:sms_sent, :name, :slug, :status, :url,
|
10
|
+
:type, :recurrent, :is_redirect_on_failure,
|
11
|
+
:payments_limit_count, :paid_payments_count,
|
12
|
+
:expires_at, :allowed_payment_methods,
|
13
|
+
:needs_shipping_contact, :monthly_installments_options,
|
14
|
+
:monthly_installments_enabled,
|
15
|
+
:returns_control_on, :on_demand_enabled
|
16
|
+
|
17
|
+
def _url
|
18
|
+
ensure_id
|
19
|
+
|
20
|
+
"/checkouts/#{id}"
|
21
|
+
end
|
22
|
+
|
23
|
+
def send_sms(params = {})
|
24
|
+
custom_action(:post, "sms", params)
|
25
|
+
end
|
26
|
+
|
27
|
+
def send_email(params = {})
|
28
|
+
custom_action(:post, "email", params)
|
29
|
+
end
|
30
|
+
|
31
|
+
def cancel(params = {})
|
32
|
+
custom_action(:put, "cancel", params)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/conekta/order.rb
CHANGED
@@ -9,9 +9,10 @@ module Conekta
|
|
9
9
|
|
10
10
|
attr_accessor :livemode, :amount, :payment_status, :customer_id, :currency,
|
11
11
|
:metadata, :created_at, :updated_at, :tax_lines, :line_items,
|
12
|
-
:shipping_lines, :discount_lines, :shipping_contact, :charges
|
12
|
+
:shipping_lines, :discount_lines, :shipping_contact, :charges,
|
13
|
+
:checkout
|
13
14
|
|
14
|
-
def initialize(id=nil)
|
15
|
+
def initialize(id = nil)
|
15
16
|
@id = id
|
16
17
|
@line_items ||= List.new("LineItem", {})
|
17
18
|
@tax_lines ||= List.new("TaxLine", {})
|
@@ -26,7 +27,7 @@ module Conekta
|
|
26
27
|
super
|
27
28
|
end
|
28
29
|
|
29
|
-
order
|
30
|
+
order = self
|
30
31
|
submodels = [:line_items, :tax_lines, :shipping_lines, :discount_lines,
|
31
32
|
:charges]
|
32
33
|
create_submodels_lists(order, submodels)
|
@@ -34,40 +35,40 @@ module Conekta
|
|
34
35
|
|
35
36
|
#Attribute accessors
|
36
37
|
def create_line_item(params)
|
37
|
-
self.create_member_with_relation(
|
38
|
+
self.create_member_with_relation("line_items", params, self)
|
38
39
|
end
|
39
40
|
|
40
41
|
def create_tax_line(params)
|
41
|
-
self.create_member_with_relation(
|
42
|
+
self.create_member_with_relation("tax_lines", params, self)
|
42
43
|
end
|
43
44
|
|
44
45
|
def create_shipping_line(params)
|
45
|
-
self.create_member_with_relation(
|
46
|
+
self.create_member_with_relation("shipping_lines", params, self)
|
46
47
|
end
|
47
48
|
|
48
49
|
def create_discount_line(params)
|
49
|
-
self.create_member_with_relation(
|
50
|
+
self.create_member_with_relation("discount_lines", params, self)
|
50
51
|
end
|
51
52
|
|
52
53
|
def create_charge(params)
|
53
|
-
self.create_member(
|
54
|
+
self.create_member("charges", params)
|
54
55
|
end
|
55
56
|
|
56
57
|
def create_shipping_contact(params)
|
57
58
|
self.update(shipping_contact: params).shipping_contact
|
58
59
|
end
|
59
60
|
|
60
|
-
|
61
|
-
def authorize_capture(params={})
|
62
|
-
custom_action(:post,
|
61
|
+
#State transitions
|
62
|
+
def authorize_capture(params = {})
|
63
|
+
custom_action(:post, "capture", params)
|
63
64
|
end
|
64
65
|
|
65
|
-
def void(params={})
|
66
|
-
custom_action(:post,
|
66
|
+
def void(params = {})
|
67
|
+
custom_action(:post, "void", params)
|
67
68
|
end
|
68
69
|
|
69
|
-
def refund(params={})
|
70
|
-
custom_action(:post,
|
70
|
+
def refund(params = {})
|
71
|
+
custom_action(:post, "refund", params)
|
71
72
|
end
|
72
73
|
|
73
74
|
private
|
@@ -75,12 +76,11 @@ module Conekta
|
|
75
76
|
def create_submodels_lists(order, submodels)
|
76
77
|
submodels.each do |submodel|
|
77
78
|
self.send(submodel).each do |k, v|
|
78
|
-
v.create_attr(
|
79
|
+
v.create_attr("order", order)
|
79
80
|
|
80
|
-
self.send(submodel).set_val(k,v)
|
81
|
+
self.send(submodel).set_val(k, v)
|
81
82
|
end if self.respond_to?(submodel) && !self.send(submodel).nil?
|
82
83
|
end
|
83
84
|
end
|
84
|
-
|
85
85
|
end
|
86
86
|
end
|
data/lib/conekta/util.rb
CHANGED
@@ -11,6 +11,7 @@ module Conekta
|
|
11
11
|
'card_payment' => ::Conekta::PaymentMethod,
|
12
12
|
'cash_payment' => ::Conekta::PaymentMethod,
|
13
13
|
'charge' => ::Conekta::Charge,
|
14
|
+
'checkout' => ::Conekta::Checkout,
|
14
15
|
'customer' => ::Conekta::Customer,
|
15
16
|
'event' => ::Conekta::Event,
|
16
17
|
'log' => ::Conekta::Log,
|
data/lib/conekta/version.rb
CHANGED
@@ -0,0 +1,224 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Conekta::Checkout do
|
4
|
+
include_context "API 2.0.0"
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
if Conekta.api_base == "https://api.conekta.io"
|
8
|
+
skip("This test should be run in staging.")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:customer_info) do
|
13
|
+
{
|
14
|
+
name: "John Constantine",
|
15
|
+
phone: "4493424352",
|
16
|
+
email: "hola@hola.com",
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
let(:line_items) do
|
21
|
+
[{
|
22
|
+
name: "Box of Cohiba S1s",
|
23
|
+
unit_price: 35000,
|
24
|
+
quantity: 1,
|
25
|
+
}]
|
26
|
+
end
|
27
|
+
|
28
|
+
let(:msi_enabled) do
|
29
|
+
{
|
30
|
+
monthly_installments_enabled: true,
|
31
|
+
monthly_installments_options: [3, 6, 12],
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
let(:recurrent) do
|
36
|
+
{
|
37
|
+
recurrent: true,
|
38
|
+
payments_limit_count: 10,
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
let(:order_template) do
|
43
|
+
{
|
44
|
+
currency: "MXN",
|
45
|
+
line_items: line_items,
|
46
|
+
customer_info: customer_info,
|
47
|
+
metadata: {
|
48
|
+
"mycustomkey": "12345",
|
49
|
+
"othercustomkey": "abcde",
|
50
|
+
},
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
let(:order_template_no_customer) do
|
55
|
+
{
|
56
|
+
currency: "MXN",
|
57
|
+
line_items: line_items,
|
58
|
+
metadata: {
|
59
|
+
"mycustomkey": "12345",
|
60
|
+
"othercustomkey": "abcde",
|
61
|
+
},
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
let(:checkout_data) do
|
66
|
+
{
|
67
|
+
name: "Payment Link Name",
|
68
|
+
type: "PaymentLink",
|
69
|
+
recurrent: false,
|
70
|
+
expired_at: (Time.now + 259200).to_i,
|
71
|
+
allowed_payment_methods: ["cash", "card", "bank_transfer"],
|
72
|
+
needs_shipping_contact: false,
|
73
|
+
order_template: order_template,
|
74
|
+
}
|
75
|
+
end
|
76
|
+
|
77
|
+
let(:checkout_data_no_customer) do
|
78
|
+
{
|
79
|
+
name: "Payment Link Name",
|
80
|
+
type: "PaymentLink",
|
81
|
+
recurrent: false,
|
82
|
+
expired_at: (Time.now + 259200).to_i,
|
83
|
+
allowed_payment_methods: ["cash", "card", "bank_transfer"],
|
84
|
+
needs_shipping_contact: false,
|
85
|
+
order_template: order_template_no_customer,
|
86
|
+
}
|
87
|
+
end
|
88
|
+
|
89
|
+
let(:checkout_invalid_expired_at) do
|
90
|
+
{
|
91
|
+
name: "Payment Link Name",
|
92
|
+
type: "PaymentLink",
|
93
|
+
recurrent: false,
|
94
|
+
expired_at: (Time.now + 3600).to_i,
|
95
|
+
allowed_payment_methods: ["cash", "card", "bank_transfer"],
|
96
|
+
needs_shipping_contact: false,
|
97
|
+
order_template: order_template,
|
98
|
+
}
|
99
|
+
end
|
100
|
+
|
101
|
+
let(:checkout_data_with_msi) do
|
102
|
+
checkout_data.merge(msi_enabled)
|
103
|
+
end
|
104
|
+
|
105
|
+
let(:checkout_data_recurrent) do
|
106
|
+
checkout_data_no_customer.merge(recurrent)
|
107
|
+
end
|
108
|
+
|
109
|
+
context "creating payment link" do
|
110
|
+
it "successful checkout create" do
|
111
|
+
checkout = Conekta::Checkout.create(checkout_data)
|
112
|
+
|
113
|
+
expect(checkout).to be_a(Conekta::Checkout)
|
114
|
+
expect(checkout.id).not_to eq("")
|
115
|
+
expect(checkout.id.length).to eq(36)
|
116
|
+
expect(checkout.type).to eq("PaymentLink")
|
117
|
+
expect(checkout.livemode).to eq(false)
|
118
|
+
expect(checkout.needs_shipping_contact).to eq(false)
|
119
|
+
expect(checkout.monthly_installments_enabled).to eq(false)
|
120
|
+
expect(checkout.slug).not_to eq("")
|
121
|
+
expect(checkout.url).not_to eq("")
|
122
|
+
end
|
123
|
+
|
124
|
+
it "unsuccessful checkout create" do
|
125
|
+
expect {
|
126
|
+
Conekta::Checkout.create({})
|
127
|
+
}.to raise_error(Conekta::ParameterValidationError)
|
128
|
+
end
|
129
|
+
|
130
|
+
it "unsuccessful checkout expired at create" do
|
131
|
+
expect {
|
132
|
+
Conekta::Checkout.create(checkout_invalid_expired_at)
|
133
|
+
}.to raise_error(Conekta::ParameterValidationError)
|
134
|
+
end
|
135
|
+
|
136
|
+
it "successful with monthly installments enabled" do
|
137
|
+
checkout = Conekta::Checkout.create(checkout_data_with_msi)
|
138
|
+
|
139
|
+
expect(checkout).to be_a(Conekta::Checkout)
|
140
|
+
expect(checkout.id).not_to eq("")
|
141
|
+
expect(checkout.id.length).to eq(36)
|
142
|
+
expect(checkout.type).to eq("PaymentLink")
|
143
|
+
expect(checkout.livemode).to eq(false)
|
144
|
+
expect(checkout.needs_shipping_contact).to eq(false)
|
145
|
+
expect(checkout.monthly_installments_enabled).to eq(true)
|
146
|
+
expect(checkout.monthly_installments_options.length).to eq(3)
|
147
|
+
expect(checkout.slug).not_to eq("")
|
148
|
+
expect(checkout.url).not_to eq("")
|
149
|
+
end
|
150
|
+
|
151
|
+
it "successful with recurrent" do
|
152
|
+
checkout = Conekta::Checkout.create(checkout_data_recurrent)
|
153
|
+
|
154
|
+
expect(checkout).to be_a(Conekta::Checkout)
|
155
|
+
expect(checkout.id).not_to eq("")
|
156
|
+
expect(checkout.id.length).to eq(36)
|
157
|
+
expect(checkout.type).to eq("PaymentLink")
|
158
|
+
expect(checkout.livemode).to eq(false)
|
159
|
+
expect(checkout.needs_shipping_contact).to eq(false)
|
160
|
+
expect(checkout.recurrent).to eq(true)
|
161
|
+
expect(checkout.payments_limit_count).to eq(10)
|
162
|
+
expect(checkout.slug).not_to eq("")
|
163
|
+
expect(checkout.url).not_to eq("")
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
context "get" do
|
168
|
+
it "successfully gets checkout" do
|
169
|
+
id = Conekta::Checkout.create(checkout_data).id
|
170
|
+
|
171
|
+
checkout = Conekta::Checkout.find(id)
|
172
|
+
|
173
|
+
expect(checkout).to be_a(Conekta::Checkout)
|
174
|
+
end
|
175
|
+
|
176
|
+
it "test successful checkout where" do
|
177
|
+
checkouts = Conekta::Checkout.where
|
178
|
+
|
179
|
+
expect(checkouts).to be_a(Conekta::List)
|
180
|
+
expect(checkouts.elements_type).to eq("Checkout")
|
181
|
+
expect(checkouts.first).to be_a(Conekta::Checkout)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
context "notifications with payment link" do
|
186
|
+
it "unsuccessful send a checkout sms" do
|
187
|
+
expect {
|
188
|
+
checkout = Conekta::Checkout.create(checkout_data)
|
189
|
+
expect(checkout.sms_sent).to eq(0)
|
190
|
+
|
191
|
+
checkout.send_sms({
|
192
|
+
"phone": "5555555555",
|
193
|
+
})
|
194
|
+
}.to raise_error(Conekta::ProcessingError)
|
195
|
+
end
|
196
|
+
|
197
|
+
it "successfully send a checkout email" do
|
198
|
+
checkout = Conekta::Checkout.create(checkout_data)
|
199
|
+
expect(checkout.emails_sent).to eq(0)
|
200
|
+
|
201
|
+
checkout.send_email({
|
202
|
+
"email": "test@mail.com",
|
203
|
+
})
|
204
|
+
|
205
|
+
checkoutFound = Conekta::Checkout.find(checkout.id)
|
206
|
+
expect(checkoutFound.emails_sent).to eq(1)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
context "cancel checkout request" do
|
211
|
+
it "successful cancel a checkout" do
|
212
|
+
checkout = Conekta::Checkout.create(checkout_data)
|
213
|
+
id = checkout.id
|
214
|
+
expect(checkout.status).to eq("Issued")
|
215
|
+
|
216
|
+
checkout.cancel({
|
217
|
+
"id": id,
|
218
|
+
})
|
219
|
+
|
220
|
+
checkoutFound = Conekta::Checkout.find(id)
|
221
|
+
expect(checkoutFound.status).to eq("Cancelled")
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Conekta::Order do
|
4
4
|
include_context "API 2.0.0"
|
@@ -6,8 +6,8 @@ describe Conekta::Order do
|
|
6
6
|
let(:customer_info) do
|
7
7
|
{
|
8
8
|
name: "John Constantine",
|
9
|
-
phone: "
|
10
|
-
email: "hola@hola.com"
|
9
|
+
phone: "3353319758",
|
10
|
+
email: "hola@hola.com",
|
11
11
|
}
|
12
12
|
end
|
13
13
|
|
@@ -15,7 +15,7 @@ describe Conekta::Order do
|
|
15
15
|
{
|
16
16
|
email: "hola@hola.com",
|
17
17
|
name: "John Constantine",
|
18
|
-
cards: ["tok_test_visa_4242"]
|
18
|
+
cards: ["tok_test_visa_4242"],
|
19
19
|
}
|
20
20
|
end
|
21
21
|
|
@@ -23,9 +23,9 @@ describe Conekta::Order do
|
|
23
23
|
[{
|
24
24
|
payment_method: {
|
25
25
|
type: "oxxo_cash",
|
26
|
-
expires_at: (Time.now + 3600).to_i
|
26
|
+
expires_at: (Time.now + 3600).to_i,
|
27
27
|
},
|
28
|
-
amount: 35000
|
28
|
+
amount: 35000,
|
29
29
|
}]
|
30
30
|
end
|
31
31
|
|
@@ -35,7 +35,7 @@ describe Conekta::Order do
|
|
35
35
|
type: "card",
|
36
36
|
token_id: "tok_test_visa_4242",
|
37
37
|
},
|
38
|
-
amount: 35000
|
38
|
+
amount: 35000,
|
39
39
|
}]
|
40
40
|
end
|
41
41
|
|
@@ -45,17 +45,45 @@ describe Conekta::Order do
|
|
45
45
|
description: "Imported From Mex.",
|
46
46
|
unit_price: 35000,
|
47
47
|
quantity: 1,
|
48
|
-
tags: ["food", "mexican food"]
|
48
|
+
tags: ["food", "mexican food"],
|
49
49
|
}]
|
50
50
|
end
|
51
51
|
|
52
|
+
let(:msi_enabled) do
|
53
|
+
{
|
54
|
+
monthly_installments_enabled: true,
|
55
|
+
monthly_installments_options: [3, 6, 12],
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
let(:save_card_in_checkout) do
|
60
|
+
{
|
61
|
+
on_demand_enabled: true,
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
let(:checkout_data) do
|
66
|
+
{
|
67
|
+
expired_at: (Time.now + 259200).to_i,
|
68
|
+
allowed_payment_methods: ["cash", "card", "bank_transfer"],
|
69
|
+
}
|
70
|
+
end
|
71
|
+
|
72
|
+
let(:checkout_msi) do
|
73
|
+
checkout_data.merge(msi_enabled)
|
74
|
+
end
|
75
|
+
|
76
|
+
let(:checkout_save_card) do
|
77
|
+
checkout_data.merge(save_card_in_checkout)
|
78
|
+
end
|
79
|
+
|
52
80
|
let(:order_data) do
|
53
81
|
{
|
54
|
-
currency:
|
82
|
+
currency: "mxn",
|
55
83
|
line_items: line_items,
|
56
84
|
metadata: {
|
57
|
-
test: true
|
58
|
-
}
|
85
|
+
test: true,
|
86
|
+
},
|
59
87
|
}
|
60
88
|
end
|
61
89
|
|
@@ -67,6 +95,18 @@ describe Conekta::Order do
|
|
67
95
|
order_data.merge(charges: card_charges)
|
68
96
|
end
|
69
97
|
|
98
|
+
let(:order_data_with_checkout) do
|
99
|
+
order_data.merge(checkout: checkout_data)
|
100
|
+
end
|
101
|
+
|
102
|
+
let(:order_data_with_checkout_msi) do
|
103
|
+
order_data.merge(checkout: checkout_msi)
|
104
|
+
end
|
105
|
+
|
106
|
+
let(:order_data_with_checkout_save_card) do
|
107
|
+
order_data.merge(checkout: checkout_save_card)
|
108
|
+
end
|
109
|
+
|
70
110
|
context "creating orders" do
|
71
111
|
it "successful order create" do
|
72
112
|
order = Conekta::Order.create(order_data)
|
@@ -76,7 +116,7 @@ describe Conekta::Order do
|
|
76
116
|
end
|
77
117
|
|
78
118
|
it "unsuccessful order create" do
|
79
|
-
expect{
|
119
|
+
expect {
|
80
120
|
Conekta::Order.create({})
|
81
121
|
}.to raise_error(Conekta::ParameterValidationError)
|
82
122
|
end
|
@@ -84,19 +124,64 @@ describe Conekta::Order do
|
|
84
124
|
context "with charges" do
|
85
125
|
it "successful order create" do
|
86
126
|
order = Conekta::Order.create(order_data_with_charges.
|
87
|
-
|
127
|
+
merge(customer_info: customer_info))
|
88
128
|
|
89
129
|
expect(order).to be_a(Conekta::Order)
|
90
130
|
end
|
91
131
|
|
92
132
|
context "unsuccessful order create" do
|
93
133
|
it "with missing customer_info and customer_id" do
|
94
|
-
expect{
|
134
|
+
expect {
|
95
135
|
Conekta::Order.create(order_data_with_charges)
|
96
136
|
}.to raise_error(Conekta::ParameterValidationError)
|
97
137
|
end
|
98
138
|
end
|
99
139
|
end
|
140
|
+
|
141
|
+
context "with checkout components" do
|
142
|
+
before(:each) do
|
143
|
+
if Conekta.api_base == "https://api.conekta.io"
|
144
|
+
skip("This test should be run in staging.")
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
it "successful order create" do
|
149
|
+
order = Conekta::Order.create(order_data_with_checkout.
|
150
|
+
merge(customer_info: customer_info))
|
151
|
+
|
152
|
+
expect(order).to be_a(Conekta::Order)
|
153
|
+
expect(order.checkout.class.to_s).to eq("Conekta::Checkout")
|
154
|
+
expect(order.checkout.id).not_to eq("")
|
155
|
+
expect(order.checkout.type).to eq("Integration")
|
156
|
+
expect(order.checkout.monthly_installments_enabled).to eq(false)
|
157
|
+
end
|
158
|
+
|
159
|
+
context "with checkout components monthly installments create" do
|
160
|
+
it "with missing customer_info and customer_id" do
|
161
|
+
order = Conekta::Order.create(order_data_with_checkout_msi.
|
162
|
+
merge(customer_info: customer_info))
|
163
|
+
|
164
|
+
expect(order).to be_a(Conekta::Order)
|
165
|
+
expect(order.checkout.class.to_s).to eq("Conekta::Checkout")
|
166
|
+
expect(order.checkout.id).not_to eq("")
|
167
|
+
expect(order.checkout.type).to eq("Integration")
|
168
|
+
expect(order.checkout.monthly_installments_enabled).to eq(true)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
context "with checkout components save card create" do
|
173
|
+
it "with missing customer_info and customer_id" do
|
174
|
+
order = Conekta::Order.create(order_data_with_checkout_save_card.
|
175
|
+
merge(customer_info: customer_info))
|
176
|
+
|
177
|
+
expect(order).to be_a(Conekta::Order)
|
178
|
+
expect(order.checkout.class.to_s).to eq("Conekta::Checkout")
|
179
|
+
expect(order.checkout.id).not_to eq("")
|
180
|
+
expect(order.checkout.type).to eq("Integration")
|
181
|
+
expect(order.checkout.on_demand_enabled).to eq(true)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
100
185
|
end
|
101
186
|
|
102
187
|
context "updating orders" do
|
@@ -109,7 +194,7 @@ describe Conekta::Order do
|
|
109
194
|
end
|
110
195
|
|
111
196
|
it "unsuccessful order update" do
|
112
|
-
expect{
|
197
|
+
expect {
|
113
198
|
order.update(charges: charges)
|
114
199
|
}.to raise_error(Conekta::ParameterValidationError)
|
115
200
|
end
|
@@ -122,32 +207,32 @@ describe Conekta::Order do
|
|
122
207
|
description: "Imported From Mex.",
|
123
208
|
unit_price: 35000,
|
124
209
|
quantity: 1,
|
125
|
-
tags: ["food", "mexican food"]
|
210
|
+
tags: ["food", "mexican food"],
|
126
211
|
}
|
127
212
|
end
|
128
213
|
|
129
214
|
let(:tax_line_params) do
|
130
215
|
{
|
131
216
|
description: "IVA",
|
132
|
-
amount:
|
217
|
+
amount: 600,
|
133
218
|
}
|
134
219
|
end
|
135
220
|
|
136
221
|
let(:shipping_line_params) do
|
137
222
|
{
|
138
|
-
description:
|
139
|
-
amount:
|
223
|
+
description: "Otro Shipping",
|
224
|
+
amount: 40,
|
140
225
|
tracking_number: "TRACK124",
|
141
|
-
carrier:
|
142
|
-
method:
|
226
|
+
carrier: "USPS",
|
227
|
+
method: "Train",
|
143
228
|
}
|
144
229
|
end
|
145
230
|
|
146
231
|
let(:discount_line_params) do
|
147
232
|
{
|
148
233
|
code: "Cupon de descuento",
|
149
|
-
type:
|
150
|
-
amount:
|
234
|
+
type: "loyalty",
|
235
|
+
amount: 10,
|
151
236
|
}
|
152
237
|
end
|
153
238
|
|
@@ -155,9 +240,9 @@ describe Conekta::Order do
|
|
155
240
|
{
|
156
241
|
payment_method: {
|
157
242
|
type: "oxxo_cash",
|
158
|
-
expires_at: (Time.now + 3600).to_i
|
243
|
+
expires_at: (Time.now + 3600).to_i,
|
159
244
|
},
|
160
|
-
amount: 35000
|
245
|
+
amount: 35000,
|
161
246
|
}
|
162
247
|
end
|
163
248
|
|
@@ -174,8 +259,8 @@ describe Conekta::Order do
|
|
174
259
|
state: "Alberta",
|
175
260
|
country: "MX",
|
176
261
|
postal_code: "78219",
|
177
|
-
residential: true
|
178
|
-
}
|
262
|
+
residential: true,
|
263
|
+
},
|
179
264
|
}
|
180
265
|
end
|
181
266
|
|
@@ -183,15 +268,15 @@ describe Conekta::Order do
|
|
183
268
|
|
184
269
|
it "successfully creates charge for order" do
|
185
270
|
other_params = {
|
186
|
-
currency:
|
271
|
+
currency: "mxn",
|
187
272
|
customer_info: {
|
188
|
-
name:
|
189
|
-
phone:
|
190
|
-
email:
|
191
|
-
}
|
273
|
+
name: "John Constantine",
|
274
|
+
phone: "+5213353319758",
|
275
|
+
email: "hola@hola.com",
|
276
|
+
},
|
192
277
|
}
|
193
278
|
|
194
|
-
order
|
279
|
+
order = Conekta::Order.create(order_data.merge(other_params))
|
195
280
|
charge = order.create_charge(charge_params)
|
196
281
|
|
197
282
|
expect(charge.class.to_s).to eq("Conekta::Charge")
|
@@ -206,7 +291,7 @@ describe Conekta::Order do
|
|
206
291
|
end
|
207
292
|
|
208
293
|
it "successfully creates tax line for order" do
|
209
|
-
tax_line
|
294
|
+
tax_line = order.create_tax_line(tax_line_params)
|
210
295
|
new_tax_line = order.create_tax_line(description: "ISR", amount: 2)
|
211
296
|
|
212
297
|
expect(tax_line.class.to_s).to eq("Conekta::TaxLine")
|
@@ -224,7 +309,7 @@ describe Conekta::Order do
|
|
224
309
|
it "successfully creates discount line for order" do
|
225
310
|
discount_line = order.create_discount_line(discount_line_params)
|
226
311
|
|
227
|
-
discount_line.update({amount: 1000})
|
312
|
+
discount_line.update({ amount: 1000 })
|
228
313
|
|
229
314
|
expect(discount_line.class.to_s).to eq("Conekta::DiscountLine")
|
230
315
|
expect(order.discount_lines.class.to_s).to eq("Conekta::List")
|
@@ -257,7 +342,7 @@ describe Conekta::Order do
|
|
257
342
|
|
258
343
|
it "successfully captures an order" do
|
259
344
|
order = Conekta::Order.create(order_data_with_card_charges.
|
260
|
-
|
345
|
+
merge(customer_info: customer_info, pre_authorize: true))
|
261
346
|
expect(order.payment_status).to eq("pre_authorized")
|
262
347
|
|
263
348
|
order.authorize_capture
|
@@ -269,18 +354,18 @@ describe Conekta::Order do
|
|
269
354
|
let(:order_refund) do
|
270
355
|
{
|
271
356
|
amount: 35000,
|
272
|
-
reason: "requested_by_client"
|
357
|
+
reason: "requested_by_client",
|
273
358
|
}
|
274
359
|
end
|
275
360
|
|
276
361
|
it "test successful refund" do
|
277
362
|
order = Conekta::Order.create(order_data_with_card_charges.
|
278
|
-
|
279
|
-
|
363
|
+
merge(customer_info: customer_info).
|
364
|
+
merge(line_items: line_items))
|
280
365
|
begin
|
281
|
-
|
366
|
+
order.refund(order_refund)
|
282
367
|
rescue Exception => e
|
283
|
-
|
368
|
+
puts e.details.map { |d| d.message }
|
284
369
|
end
|
285
370
|
|
286
371
|
refunded_order = Conekta::Order.find(order.id)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: conekta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Conekta
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -128,6 +128,7 @@ files:
|
|
128
128
|
- lib/conekta/address.rb
|
129
129
|
- lib/conekta/card.rb
|
130
130
|
- lib/conekta/charge.rb
|
131
|
+
- lib/conekta/checkout.rb
|
131
132
|
- lib/conekta/conekta_object.rb
|
132
133
|
- lib/conekta/customer.rb
|
133
134
|
- lib/conekta/customer_info.rb
|
@@ -186,6 +187,7 @@ files:
|
|
186
187
|
- spec/conekta/1.0.0/plan_spec.rb
|
187
188
|
- spec/conekta/1.0.0/token_spec.rb
|
188
189
|
- spec/conekta/1.0.0/webhook_spec.rb
|
190
|
+
- spec/conekta/2.0.0/checkout_spec.rb
|
189
191
|
- spec/conekta/2.0.0/customer_spec.rb
|
190
192
|
- spec/conekta/2.0.0/discount_line_spec.rb
|
191
193
|
- spec/conekta/2.0.0/error_spec.rb
|
@@ -221,8 +223,36 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
221
223
|
- !ruby/object:Gem::Version
|
222
224
|
version: '0'
|
223
225
|
requirements: []
|
224
|
-
rubygems_version: 3.0.
|
226
|
+
rubygems_version: 3.0.6
|
225
227
|
signing_key:
|
226
228
|
specification_version: 4
|
227
229
|
summary: This library provides https://api.conekta.io operations
|
228
|
-
test_files:
|
230
|
+
test_files:
|
231
|
+
- spec/conekta/1.0.0/.DS_Store
|
232
|
+
- spec/conekta/1.0.0/card_spec.rb
|
233
|
+
- spec/conekta/1.0.0/charge_spec.rb
|
234
|
+
- spec/conekta/1.0.0/customer_spec.rb
|
235
|
+
- spec/conekta/1.0.0/error_spec.rb
|
236
|
+
- spec/conekta/1.0.0/event_spec.rb
|
237
|
+
- spec/conekta/1.0.0/log_spec.rb
|
238
|
+
- spec/conekta/1.0.0/payout_spec.rb
|
239
|
+
- spec/conekta/1.0.0/plan_spec.rb
|
240
|
+
- spec/conekta/1.0.0/token_spec.rb
|
241
|
+
- spec/conekta/1.0.0/webhook_spec.rb
|
242
|
+
- spec/conekta/2.0.0/checkout_spec.rb
|
243
|
+
- spec/conekta/2.0.0/customer_spec.rb
|
244
|
+
- spec/conekta/2.0.0/discount_line_spec.rb
|
245
|
+
- spec/conekta/2.0.0/error_spec.rb
|
246
|
+
- spec/conekta/2.0.0/line_item_spec.rb
|
247
|
+
- spec/conekta/2.0.0/list_spec.rb
|
248
|
+
- spec/conekta/2.0.0/order_spec.rb
|
249
|
+
- spec/conekta/2.0.0/payee_spec.rb
|
250
|
+
- spec/conekta/2.0.0/shipping_contact_spec.rb
|
251
|
+
- spec/conekta/2.0.0/shipping_line_spec.rb
|
252
|
+
- spec/conekta/2.0.0/source_spec.rb
|
253
|
+
- spec/conekta/2.0.0/tax_line_spec.rb
|
254
|
+
- spec/conekta/2.0.0/transfer_spec.rb
|
255
|
+
- spec/conekta_spec.rb
|
256
|
+
- spec/spec_helper.rb
|
257
|
+
- spec/support/fixtures/orders.json
|
258
|
+
- spec/support/shared_context.rb
|