Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Ruby Gems
/
var
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Ricardo Garcia
2016-07-07 12:50:57 -0500
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c99512fd57544a9689d2c636ab44fb66b9754a5f
c99512fd
1 parent
196dd3f8
Redesigns webhook managment
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
11 deletions
lib/var.rb
spec/var_spec.rb
lib/var.rb
View file @
c99512f
...
...
@@ -28,10 +28,14 @@ module Var
raise
'Malformed hash received'
unless
event
[
:data
]
&&
event
[
:data
][
:object
]
payment
=
event
[
:data
][
:object
]
object
=
Var
.
find_charge
payment
[
:id
]
# object.handle_conekta_event
update_object_var_data
(
object
,
payment
)
object
process_charge_creation_with_card
event
# object = Var.find_charge payment[:id]
# # object.handle_conekta_event
# update_object_var_data(object, payment)
# object
end
def
process_charge_creation_with_card
(
p
)
end
def
update_object_var_data
(
object
,
data
)
...
...
spec/var_spec.rb
View file @
c99512f
...
...
@@ -68,17 +68,23 @@ describe Var do
it
'handles Cargo creado con tarjeta'
do
params
=
{
"data"
:{
"object"
:{
"id"
:"5511d4ce2412294cf6000081"
,
"livemode"
:false
,
"created_at"
:
1427231950
,
"status"
:"pending_payment"
,
"currency"
:"MXN"
,
"description"
:"Stogies"
,
"reference_id"
:"9839-wolf_pack"
,
"failure_code"
:nil
,
"failure_message"
:nil
,
"monthly_installments"
:nil
,
"object"
:"charge"
,
"amount"
:
20000
,
"paid_at"
:nil
,
"fee"
:
963
,
"customer_id"
:""
,
"refunds"
:[]
,
"payment_method"
:{
"name"
:"Jorge Lopez"
,
"exp_month"
:"12"
,
"exp_year"
:"19"
,
"auth_code"
:nil
,
"object"
:"card_payment"
,
"last4"
:"4242"
,
"brand"
:"visa"
},
"details"
:{
"name"
:nil
,
"phone"
:nil
,
"email"
:nil
,
"line_items"
:[]
}},
"previous_attributes"
:{}},
"livemode"
:false
,
"webhook_status"
:"pending"
,
"id"
:"5511d4ce2412294cf6000084"
,
"object"
:"event"
,
"type"
:"charge.created"
,
"created_at"
:
1427231950
,
"webhook_logs"
:[{
"id"
:"webhl_nPzGMBeQmMUu7aQ"
,
"url"
:"http://requestb.in/1em0jsx1"
,
"failed_attempts"
:
0
,
"last_http_response_status"
:
-
1
,
"object"
:"webhook_log"
,
"last_attempted_at"
:
0
}]}
allow
(
Var
).
to
receive
(
:find_charge
).
and_return
chargable_product
allow
(
chargable_product
).
to
receive
(
:update_columns
).
and_return
true
allow
(
chargable_product
).
to
receive
(
:var_payed?
).
and_return
false
allow
(
chargable_product
).
to
receive
(
:var_id
).
and_return
'5511d4ce2412294cf6000081'
expect
(
Var
).
to
receive
(
:process_charge_creation_with_card
).
with
(
params
)
r
=
Var
.
conekta_webhook
params
expect
(
r
).
to
be
true
end
xit
'processes card payment'
do
result
=
Var
.
conekta_webhook
params
expect
(
result
.
var_id
).
to
eq
(
'5511d4ce2412294cf6000081'
)
# allow(Var).to receive(:find_charge).and_return chargable_product
#
# allow(chargable_product).to receive(:update_columns).and_return true
# allow(chargable_product).to receive(:var_payed?).and_return false
# allow(chargable_product).to receive(:var_id).and_return '5511d4ce2412294cf6000081'
# expect(result.var_id).to eq('5511d4ce2412294cf6000081')
# TODO: Define what is actually being teted
pending
end
it
'handles Cargo pagado con tarjeta'
do
...
...
Please
register
or
login
to post a comment