Builds for
1 pipeline
failed
in
0 seconds
Fixed new merge conflict
Showing
4 changed files
with
12 additions
and
8 deletions
1 | module WebHookPostRequest | 1 | module WebHookPostRequest |
2 | + 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 }] } | ||
2 | OXXO_CHARGE_CREATED = { | 3 | OXXO_CHARGE_CREATED = { |
3 | "data": { | 4 | "data": { |
4 | "object": { | 5 | "object": { |
5 | "id":"5514803f241229981e0022e6", "livemode":false, | 6 | "id":"5514803f241229981e0022e6", "livemode":false, |
6 | "created_at":1427406911, "status":"pending_payment", "currency":"MXN", | 7 | "created_at":1427406911, "status":"pending_payment", "currency":"MXN", |
7 | "description":"Stogies", "reference_id":"9839-wolf_pack", | 8 | "description":"Stogies", "reference_id":"9839-wolf_pack", |
8 | - "failure_code":null, "failure_message":null, "monthly_installments":null, | 9 | + "failure_code":nil, "failure_message":nil, "monthly_installments":nil, |
9 | - "object":"charge", "amount":20000, "paid_at":null, "fee":812, | 10 | + "object":"charge", "amount":20000, "paid_at":nil, "fee":812, |
10 | "customer_id":"", "refunds":[], "payment_method": { | 11 | "customer_id":"", "refunds":[], "payment_method": { |
11 | "barcode":"38100000000042290121213001160013", | 12 | "barcode":"38100000000042290121213001160013", |
12 | - "barcode_url":"http://s3.amazonaws.com/cash_payment_barcodes/" \ | 13 | + "barcode_url":"http://s3.amazonaws.com/cash_payment_barcodes/" + |
13 | "38100000000042290121213001160013.png", | 14 | "38100000000042290121213001160013.png", |
14 | "object":"cash_payment", "type":"oxxo", "expires_at":1430006400, | 15 | "object":"cash_payment", "type":"oxxo", "expires_at":1430006400, |
15 | "store_name":"OXXO" | 16 | "store_name":"OXXO" | ... | ... |
... | @@ -6,6 +6,7 @@ require 'var' | ... | @@ -6,6 +6,7 @@ require 'var' |
6 | 6 | ||
7 | require 'mocks/var_database_mock' | 7 | require 'mocks/var_database_mock' |
8 | require 'mocks/var_models_mock' | 8 | require 'mocks/var_models_mock' |
9 | +require 'mocks/webhooks_requests' | ||
9 | 10 | ||
10 | ActiveRecord::Base.establish_connection(adapter: 'sqlite3', | 11 | ActiveRecord::Base.establish_connection(adapter: 'sqlite3', |
11 | database: ':memory:') | 12 | database: ':memory:') | ... | ... |
... | @@ -66,7 +66,7 @@ describe Var do | ... | @@ -66,7 +66,7 @@ describe Var do |
66 | end | 66 | end |
67 | 67 | ||
68 | it 'handles card charge creation' do | 68 | it 'handles card charge creation' do |
69 | - 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 }] } | 69 | + params = WebHookPostRequest::CARD_CHARGE_CREATED |
70 | cardHandler = class_double('Var::ConektaCardHandler') | 70 | cardHandler = class_double('Var::ConektaCardHandler') |
71 | .as_stubbed_const(transfer_nested_constants: true) | 71 | .as_stubbed_const(transfer_nested_constants: true) |
72 | expect(cardHandler).to receive(:analyze).with(params) | 72 | expect(cardHandler).to receive(:analyze).with(params) |
... | @@ -129,10 +129,10 @@ describe Var do | ... | @@ -129,10 +129,10 @@ describe Var do |
129 | 129 | ||
130 | it 'handles payout paid' do | 130 | it 'handles payout paid' do |
131 | null = nil | 131 | null = nil |
132 | - params = {"data":{"object":{"livemode":true, "currency":"MXN", "method":{"id":"pytmtd_hqsxocPm8CZoNu", "created_at":1467992925, "payee_id":nil, "_type":"BankTransferPayoutMethod", "object":"bank_transfer_payout_method", "account_number":"072580002374915018", "account_holder":"UKKO SOLUTIONS SA DE CV", "bank":"Banco Mercantil del Norte, S.A."}, "object":"transfer", "amount":453320, "id":"577fcb5d7b823b818e001791", "created_at":1467992925, "status":"scheduled", "statement_reference":"3121951", "statement_description":"Conekta 3121951"}, "previous_attributes":{}}, "livemode":true, "webhook_status":"pending", "webhook_logs":[{"id":"webhl_nKYa1YWSLNhrWLU", "url":"http://kipping.mx/conekta_webhook", "failed_attempts":0, "last_http_response_status":-1, "object":"webhook_log", "last_attempted_at":1468265161}], "id":"5783f2c67b823b46ee0021af", "object":"event", "type":"payout.paid_out", "created_at":1468265158, "webhook":{"data":{"object":{"livemode":true, "currency":"MXN", "method":{"id":"pytmtd_hqsxocPm8CZoNu", "created_at":1467992925, "payee_id":nil, "_type":"BankTransferPayoutMethod", "object":"bank_transfer_payout_method", "account_number":"072580002374915018", "account_holder":"UKKO SOLUTIONS SA DE CV", "bank":"Banco Mercantil del Norte, S.A."}, "object":"transfer", "amount":453320, "id":"577fcb5d7b823b818e001791", "created_at":1467992925, "status":"scheduled", "statement_reference":"3121951", "statement_description":"Conekta 3121951"}, "previous_attributes":{}}, "livemode":true, "webhook_status":"pending", "webhook_logs":[{"id":"webhl_nKYa1YWSLNhrWLU", "url":"http://kipping.mx/conekta_webhook", "failed_attempts":0, "last_http_response_status":-1, "object":"webhook_log", "last_attempted_at":1468265161}], "id":"5783f2c67b823b46ee0021af", "object":"event", "type":"payout.paid_out", "created_at":1468265158}} | 132 | + params = { "object": { "livemode": true, "currency": 'MXN', "method": { "id": 'pytmtd_MymQ7favB2hQJC', "created_at": 1_467_832_748, "payee_id": null, "_type": 'BankTransferPayoutMethod', "object": 'bank_transfer_payout_method', "account_number": '072580002374915018', "account_holder": 'UKKO SOLUTIONS SA DE CV', "bank": 'Banco Mercantil del Norte, S.A.' }, "object": 'transfer', "amount": 303_534, "id": '577d59ac243c7fee8100146d', "created_at": 1_467_832_748, "status": 'scheduled', "statement_reference": '4632539', "statement_description": 'Conekta 4632539' }, "previous_attributes": {} } |
133 | - payoutHandler = class_double("Var::ConektaPayoutHandler"). | 133 | + payout_handler = class_double('Var::ConektaPayoutHandler') |
134 | - as_stubbed_const(transfer_nested_constants: true) | 134 | + .as_stubbed_const(transfer_nested_constants: true) |
135 | - expect(payoutHandler).to receive(:analyze).with(params) | 135 | + expect(payout_handler).to receive(:analyze).with(params) |
136 | Var.conekta_webhook(params) | 136 | Var.conekta_webhook(params) |
137 | end | 137 | end |
138 | 138 | ... | ... |
-
Please register or login to post a comment