Ricardo Garcia
Builds for 1 pipeline failed in 0 seconds

Move webhook params

AllCops:
TargetRubyVersion: 2.3
Exclude:
- 'spec/mock/webhooks_requests.rb'
......
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 }] }
OXXO_CHARGE_CREATED = {
"data": {
"object": {
"id":"5514803f241229981e0022e6", "livemode":false,
"created_at":1427406911, "status":"pending_payment", "currency":"MXN",
"description":"Stogies", "reference_id":"9839-wolf_pack",
"failure_code":null, "failure_message":null, "monthly_installments":null,
"object":"charge", "amount":20000, "paid_at":null, "fee":812,
"failure_code":nil, "failure_message":nil, "monthly_installments":nil,
"object":"charge", "amount":20000, "paid_at":nil, "fee":812,
"customer_id":"", "refunds":[], "payment_method": {
"barcode":"38100000000042290121213001160013",
"barcode_url":"http://s3.amazonaws.com/cash_payment_barcodes/" \
"barcode_url":"http://s3.amazonaws.com/cash_payment_barcodes/" +
"38100000000042290121213001160013.png",
"object":"cash_payment", "type":"oxxo", "expires_at":1430006400,
"store_name":"OXXO"
......
......@@ -6,6 +6,7 @@ require 'var'
require 'mocks/var_database_mock'
require 'mocks/var_models_mock'
require 'mocks/webhooks_requests'
ActiveRecord::Base.establish_connection(adapter: 'sqlite3',
database: ':memory:')
......
......@@ -66,7 +66,7 @@ describe Var do
end
it 'handles card charge creation' do
params = { "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 }] }
params = WebHookPostRequest::CARD_CHARGE_CREATED
cardHandler = class_double('Var::ConektaCardHandler')
.as_stubbed_const(transfer_nested_constants: true)
expect(cardHandler).to receive(:analyze).with(params)
......