Showing
2 changed files
with
21 additions
and
11 deletions
| ... | @@ -28,10 +28,14 @@ module Var | ... | @@ -28,10 +28,14 @@ module Var |
| 28 | raise 'Malformed hash received' unless event[:data] && | 28 | raise 'Malformed hash received' unless event[:data] && |
| 29 | event[:data][:object] | 29 | event[:data][:object] |
| 30 | payment = event[:data][:object] | 30 | payment = event[:data][:object] |
| 31 | - object = Var.find_charge payment[:id] | 31 | + process_charge_creation_with_card event |
| 32 | - # object.handle_conekta_event | 32 | + # object = Var.find_charge payment[:id] |
| 33 | - update_object_var_data(object, payment) | 33 | + # # object.handle_conekta_event |
| 34 | - object | 34 | + # update_object_var_data(object, payment) |
| 35 | + # object | ||
| 36 | + end | ||
| 37 | + | ||
| 38 | + def process_charge_creation_with_card(p) | ||
| 35 | end | 39 | end |
| 36 | 40 | ||
| 37 | def update_object_var_data(object, data) | 41 | def update_object_var_data(object, data) | ... | ... |
| ... | @@ -68,17 +68,23 @@ describe Var do | ... | @@ -68,17 +68,23 @@ describe Var do |
| 68 | it 'handles Cargo creado con tarjeta' do | 68 | it 'handles Cargo creado con tarjeta' do |
| 69 | 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}]} | 69 | 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}]} |
| 70 | 70 | ||
| 71 | - allow(Var).to receive(:find_charge).and_return chargable_product | 71 | + expect(Var).to receive(:process_charge_creation_with_card).with(params) |
| 72 | - allow(chargable_product).to receive(:update_columns).and_return true | 72 | + r = Var.conekta_webhook params |
| 73 | - allow(chargable_product).to receive(:var_payed?).and_return false | 73 | + expect(r).to be true |
| 74 | - allow(chargable_product).to receive(:var_id).and_return '5511d4ce2412294cf6000081' | 74 | + end |
| 75 | + | ||
| 76 | + xit 'processes card payment' do | ||
| 75 | 77 | ||
| 76 | - result = Var.conekta_webhook params | 78 | + # allow(Var).to receive(:find_charge).and_return chargable_product |
| 77 | - expect(result.var_id).to eq('5511d4ce2412294cf6000081') | 79 | + # |
| 80 | + # allow(chargable_product).to receive(:update_columns).and_return true | ||
| 81 | + # allow(chargable_product).to receive(:var_payed?).and_return false | ||
| 82 | + # allow(chargable_product).to receive(:var_id).and_return '5511d4ce2412294cf6000081' | ||
| 83 | + | ||
| 84 | + # expect(result.var_id).to eq('5511d4ce2412294cf6000081') | ||
| 78 | 85 | ||
| 79 | # TODO: Define what is actually being teted | 86 | # TODO: Define what is actually being teted |
| 80 | 87 | ||
| 81 | - pending | ||
| 82 | end | 88 | end |
| 83 | 89 | ||
| 84 | it 'handles Cargo pagado con tarjeta' do | 90 | it 'handles Cargo pagado con tarjeta' do | ... | ... |
-
Please register or login to post a comment