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-11 15:49:50 -0500
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
26b4a2798da094b1e3bc33a3042e6393bdf0f65e
26b4a279
1 parent
9a6022c6
Move some mock params to module
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
8 deletions
spec/mocks/webhooks_requests.rb
spec/var_spec.rb
spec/mocks/webhooks_requests.rb
View file @
26b4a27
# Webhooks examples and mocks
module
WebHookPostRequest
CARD_CHARGE_CREATED
=
{
"data"
:
{
"object"
:
{
"id"
:
'5511d4ce2412294cf6000081'
,
"livemode"
:
false
,
"created_at"
:
1_427_231_950
,
"status"
:
'pending_payment'
,
"currency"
:
'MXN'
,
"description"
:
'Stogies'
,
"reference_id"
:
'9839-wolf_pack'
,
"failure_code"
:
nil
,
"failure_message"
:
nil
,
"monthly_installments"
:
nil
,
"object"
:
'charge'
,
"amount"
:
20_000
,
"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"
:
1_427_231_950
,
"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
}]
}
CARD_CHARGE_CREATED
=
{
"data"
:
{
"object"
:
{
"id"
:
'5511d4ce2412294cf6000081'
,
"livemode"
:
false
,
"created_at"
:
1_427_231_950
,
"status"
:
'pending_payment'
,
"currency"
:
'MXN'
,
"description"
:
'Stogies'
,
"reference_id"
:
'9839-wolf_pack'
,
"failure_code"
:
nil
,
"failure_message"
:
nil
,
"monthly_installments"
:
nil
,
"object"
:
'charge'
,
"amount"
:
20_000
,
"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"
:
1_427_231_950
,
"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
}]
}.
freeze
OXXO_CHARGE_CREATED
=
{
"data"
:
{
"object"
:
{
...
...
@@ -23,5 +25,9 @@ module WebHookPostRequest
"created_at"
:
1427406911
,
"webhook_logs"
:[
{
"id"
:"webhl_PBmYvkfdNDYKezJ"
,
"url"
:"http://requestb.in/u3n4ywu3"
,
"failed_attempts"
:
0
,
"last_http_response_status"
:
-
1
,
"object"
:"webhook_log"
,
"last_attempted_at"
:
0
}]}
"object"
:"webhook_log"
,
"last_attempted_at"
:
0
}]}.
freeze
SPEI_CHARGE_CREATED
=
{
"data"
:
{
"object"
:
{
"id"
:
'551499322412292eec002159'
,
"livemode"
:
false
,
"created_at"
:
1_427_413_298
,
"status"
:
'pending_payment'
,
"currency"
:
'MXN'
,
"description"
:
'Stogies'
,
"reference_id"
:
'9839-wolf_pack'
,
"failure_code"
:
nil
,
"failure_message"
:
nil
,
"monthly_installments"
:
nil
,
"object"
:
'charge'
,
"amount"
:
20_000
,
"paid_at"
:
nil
,
"fee"
:
928
,
"customer_id"
:
''
,
"refunds"
:
[],
"payment_method"
:
{
"clabe"
:
'646180111800012432'
,
"bank"
:
'STP'
,
"issuing_account_holder"
:
nil
,
"issuing_account_tax_id"
:
nil
,
"issuing_account_bank"
:
nil
,
"issuing_account_number"
:
nil
,
"receiving_account_holder"
:
nil
,
"receiving_account_tax_id"
:
nil
,
"receiving_account_number"
:
'646180111800012432'
,
"receiving_account_bank"
:
'STP'
,
"reference_number"
:
nil
,
"description"
:
nil
,
"tracking_code"
:
nil
,
"executed_at"
:
nil
,
"object"
:
'bank_transfer_payment'
,
"type"
:
'spei'
,
"expires_at"
:
1_435_189_298
},
"details"
:
{
"name"
:
'Wolverine'
,
"phone"
:
'403-342-0642'
,
"email"
:
'logan@x-men.org'
,
"line_items"
:
[]
}
},
"previous_attributes"
:
{}
},
"livemode"
:
false
,
"webhook_status"
:
'pending'
,
"id"
:
'551499322412292eec00215c'
,
"object"
:
'event'
,
"type"
:
'charge.created'
,
"created_at"
:
1_427_413_298
,
"webhook_logs"
:
[{
"id"
:
'webhl_ENPXoFkKWyDqTAt'
,
"url"
:
'http://requestb.in/151xj4r1'
,
"failed_attempts"
:
0
,
"last_http_response_status"
:
-
1
,
"object"
:
'webhook_log'
,
"last_attempted_at"
:
1_427_413_285
}]
}
CARD_CHARGE_PAID
=
{
"data"
:
{
"object"
:
{
"id"
:
'5511d4ce2412294cf6000081'
,
"livemode"
:
false
,
"created_at"
:
1_427_231_950
,
"status"
:
'paid'
,
"currency"
:
'MXN'
,
"description"
:
'Stogies'
,
"reference_id"
:
'9839-wolf_pack'
,
"failure_code"
:
nil
,
"failure_message"
:
nil
,
"monthly_installments"
:
nil
,
"object"
:
'charge'
,
"amount"
:
20_000
,
"paid_at"
:
1_427_231_952
,
"fee"
:
963
,
"customer_id"
:
''
,
"refunds"
:
[],
"payment_method"
:
{
"name"
:
'Jorge Lopez'
,
"exp_month"
:
'12'
,
"exp_year"
:
'19'
,
"auth_code"
:
'000000'
,
"object"
:
'card_payment'
,
"last4"
:
'4242'
,
"brand"
:
'visa'
},
"details"
:
{
"name"
:
nil
,
"phone"
:
nil
,
"email"
:
nil
,
"line_items"
:
[]
}
},
"previous_attributes"
:
{
"payment_method"
:
{}
}
},
"livemode"
:
false
,
"webhook_status"
:
'pending'
,
"id"
:
'5511d4d02412294cf6000088'
,
"object"
:
'event'
,
"type"
:
'charge.paid'
,
"created_at"
:
1_427_231_952
,
"webhook_logs"
:
[{
"id"
:
'webhl_m5kgkhmgETe6Y4s'
,
"url"
:
'http://requestb.in/1em0jsx1'
,
"failed_attempts"
:
0
,
"last_http_response_status"
:
-
1
,
"object"
:
'webhook_log'
,
"last_attempted_at"
:
0
}]
}.
freeze
end
...
...
spec/var_spec.rb
View file @
26b4a27
...
...
@@ -74,8 +74,7 @@ describe Var do
end
it
'handles oxxo charge creation'
do
null
=
nil
params
=
{
"data"
:
{
"object"
:
{
"id"
:
'5514803f241229981e0022e6'
,
"livemode"
:
false
,
"created_at"
:
1_427_406_911
,
"status"
:
'pending_payment'
,
"currency"
:
'MXN'
,
"description"
:
'Stogies'
,
"reference_id"
:
'9839-wolf_pack'
,
"failure_code"
:
null
,
"failure_message"
:
null
,
"monthly_installments"
:
null
,
"object"
:
'charge'
,
"amount"
:
20_000
,
"paid_at"
:
null
,
"fee"
:
812
,
"customer_id"
:
''
,
"refunds"
:
[],
"payment_method"
:
{
"barcode"
:
'38100000000042290121213001160013'
,
"barcode_url"
:
'http://s3.amazonaws.com/cash_payment_barcodes/38100000000042290121213001160013.png'
,
"object"
:
'cash_payment'
,
"type"
:
'oxxo'
,
"expires_at"
:
1_430_006_400
,
"store_name"
:
'OXXO'
},
"details"
:
{
"name"
:
'Wolverine'
,
"phone"
:
'403-342-0642'
,
"email"
:
'logan@x-men.org'
,
"line_items"
:
[]
}
},
"previous_attributes"
:
{}
},
"livemode"
:
false
,
"webhook_status"
:
'pending'
,
"id"
:
'5514803f241229981e0022e9'
,
"object"
:
'event'
,
"type"
:
'charge.created'
,
"created_at"
:
1_427_406_911
,
"webhook_logs"
:
[{
"id"
:
'webhl_PBmYvkfdNDYKezJ'
,
"url"
:
'http://requestb.in/u3n4ywu3'
,
"failed_attempts"
:
0
,
"last_http_response_status"
:
-
1
,
"object"
:
'webhook_log'
,
"last_attempted_at"
:
0
}]
}
params
=
WebHookPostRequest
::
OXXO_CHARGE_CREATED
oxxoHandler
=
class_double
(
'Var::ConektaOxxoHandler'
)
.
as_stubbed_const
(
transfer_nested_constants:
true
)
expect
(
oxxoHandler
).
to
receive
(
:analyze
).
with
(
params
)
...
...
@@ -83,8 +82,7 @@ describe Var do
end
it
'handles SPEI charge creation'
do
null
=
nil
params
=
{
"data"
:
{
"object"
:
{
"id"
:
'551499322412292eec002159'
,
"livemode"
:
false
,
"created_at"
:
1_427_413_298
,
"status"
:
'pending_payment'
,
"currency"
:
'MXN'
,
"description"
:
'Stogies'
,
"reference_id"
:
'9839-wolf_pack'
,
"failure_code"
:
null
,
"failure_message"
:
null
,
"monthly_installments"
:
null
,
"object"
:
'charge'
,
"amount"
:
20_000
,
"paid_at"
:
null
,
"fee"
:
928
,
"customer_id"
:
''
,
"refunds"
:
[],
"payment_method"
:
{
"clabe"
:
'646180111800012432'
,
"bank"
:
'STP'
,
"issuing_account_holder"
:
null
,
"issuing_account_tax_id"
:
null
,
"issuing_account_bank"
:
null
,
"issuing_account_number"
:
null
,
"receiving_account_holder"
:
null
,
"receiving_account_tax_id"
:
null
,
"receiving_account_number"
:
'646180111800012432'
,
"receiving_account_bank"
:
'STP'
,
"reference_number"
:
null
,
"description"
:
null
,
"tracking_code"
:
null
,
"executed_at"
:
null
,
"object"
:
'bank_transfer_payment'
,
"type"
:
'spei'
,
"expires_at"
:
1_435_189_298
},
"details"
:
{
"name"
:
'Wolverine'
,
"phone"
:
'403-342-0642'
,
"email"
:
'logan@x-men.org'
,
"line_items"
:
[]
}
},
"previous_attributes"
:
{}
},
"livemode"
:
false
,
"webhook_status"
:
'pending'
,
"id"
:
'551499322412292eec00215c'
,
"object"
:
'event'
,
"type"
:
'charge.created'
,
"created_at"
:
1_427_413_298
,
"webhook_logs"
:
[{
"id"
:
'webhl_ENPXoFkKWyDqTAt'
,
"url"
:
'http://requestb.in/151xj4r1'
,
"failed_attempts"
:
0
,
"last_http_response_status"
:
-
1
,
"object"
:
'webhook_log'
,
"last_attempted_at"
:
1_427_413_285
}]
}
params
=
WebHookPostRequest
::
SPEI_CHARGE_CREATED
speiHandler
=
class_double
(
'Var::ConektaSpeiHandler'
)
.
as_stubbed_const
(
transfer_nested_constants:
true
)
expect
(
speiHandler
).
to
receive
(
:analyze
).
with
(
params
)
...
...
@@ -92,8 +90,7 @@ describe Var do
end
it
'handles card payment'
do
null
=
nil
params
=
{
"data"
:
{
"object"
:
{
"id"
:
'5511d4ce2412294cf6000081'
,
"livemode"
:
false
,
"created_at"
:
1_427_231_950
,
"status"
:
'paid'
,
"currency"
:
'MXN'
,
"description"
:
'Stogies'
,
"reference_id"
:
'9839-wolf_pack'
,
"failure_code"
:
null
,
"failure_message"
:
null
,
"monthly_installments"
:
null
,
"object"
:
'charge'
,
"amount"
:
20_000
,
"paid_at"
:
1_427_231_952
,
"fee"
:
963
,
"customer_id"
:
''
,
"refunds"
:
[],
"payment_method"
:
{
"name"
:
'Jorge Lopez'
,
"exp_month"
:
'12'
,
"exp_year"
:
'19'
,
"auth_code"
:
'000000'
,
"object"
:
'card_payment'
,
"last4"
:
'4242'
,
"brand"
:
'visa'
},
"details"
:
{
"name"
:
null
,
"phone"
:
null
,
"email"
:
null
,
"line_items"
:
[]
}
},
"previous_attributes"
:
{
"payment_method"
:
{}
}
},
"livemode"
:
false
,
"webhook_status"
:
'pending'
,
"id"
:
'5511d4d02412294cf6000088'
,
"object"
:
'event'
,
"type"
:
'charge.paid'
,
"created_at"
:
1_427_231_952
,
"webhook_logs"
:
[{
"id"
:
'webhl_m5kgkhmgETe6Y4s'
,
"url"
:
'http://requestb.in/1em0jsx1'
,
"failed_attempts"
:
0
,
"last_http_response_status"
:
-
1
,
"object"
:
'webhook_log'
,
"last_attempted_at"
:
0
}]
}
params
=
WebHookPostRequest
::
CARD_CHARGE_PAID
cardHandler
=
class_double
(
'Var::ConektaCardHandler'
)
.
as_stubbed_const
(
transfer_nested_constants:
true
)
expect
(
cardHandler
).
to
receive
(
:analyze
).
with
(
params
)
...
...
Please
register
or
login
to post a comment