lib/paydunya/checkout/onsite_invoice.rb in paydunya-1.0.5 vs lib/paydunya/checkout/onsite_invoice.rb in paydunya-1.0.6

- old
+ new

@@ -1,46 +1,28 @@ module Paydunya module Onsite class Invoice < Paydunya::Checkout::Invoice - attr_accessor :invoice_token - def initialize - super + def charge(opr_token, confirm_token) + result = send_post_request(Paydunya::Setup.opr_charge_base_url, { + token: opr_token, + confirm_token: confirm_token + }) + rebuild_invoice(result['invoice_data']) if result['response_code'] == '00' + @response_code = result['response_code'] + @response_text = result['response_text'] + result['response_code'] == '00' end - def charge(opr_token,confirm_token) - payload = { - :token => opr_token, - :confirm_token => confirm_token - } - - result = http_json_request(Paydunya::Setup.opr_charge_base_url,payload) - - if result["response_code"] == "00" - rebuild_invoice(result["invoice_data"]) - @response_code = result["response_code"] - @response_text = result["response_text"] - true - else - @response_code = result["response_code"] - @response_text = result["response_text"] - false - end - end - def create(account_alias) - - payload = { - :invoice_data => build_invoice_payload, - :opr_data => { - :account_alias => account_alias - } - } - - result = http_json_request(Paydunya::Setup.opr_base_url,payload) + result = send_post_request(Paydunya::Setup.opr_base_url, { + invoice_data: build_invoice_payload, + opr_data: { + account_alias: account_alias + } + }) create_response(result) end - end end -end \ No newline at end of file +end