Class: Payr::BillsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Payr::BillsController
- Defined in:
- app/controllers/payr/bills_controller.rb
Constant Summary collapse
- UNPROCESSED =
"unprocessed"- PAID =
"paid"- REFUSED =
"refused"- CANCELLED =
"cancelled"- SIGN_ERROR =
"bad_signature"- NO_ERROR =
"00000"
Instance Method Summary collapse
Instance Method Details
#cancelled ⇒ Object
39 40 41 |
# File 'app/controllers/payr/bills_controller.rb', line 39 def cancelled change_status params[:ref], CANCELLED, params[:error] end |
#failure ⇒ Object
53 54 55 |
# File 'app/controllers/payr/bills_controller.rb', line 53 def failure change_status params[:ref], SIGN_ERROR, params[:error] end |
#ipn ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'app/controllers/payr/bills_controller.rb', line 43 def ipn if params[:error] == NO_ERROR change_status params[:ref], PAID else @bill = Payr::Bill.find(params[:ref]) @bill.update_attribute(:error_code, params[:error]) end render nothing: true, :status => 200, :content_type => 'text/html' end |
#paid ⇒ Object
31 32 33 |
# File 'app/controllers/payr/bills_controller.rb', line 31 def paid change_status params[:ref], PAID end |
#pay ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/payr/bills_controller.rb', line 11 def pay @bill = Payr::Bill.new(buyer_id: params[:buyer][:id], amount: params[:total_price], article_id: params[:article_id], state: UNPROCESSED, bill_reference: params[:bill_reference]) @payr = Payr::Client.new if @bill.save @paybox_params = @payr.get_paybox_params_from command_id: @bill.id, buyer_email: params[:buyer][:email], total_price: params[:total_price], callbacks: { paid: payr_bills_paid_url, refused: payr_bills_refused_url, cancelled: payr_bills_cancelled_url, ipn: payr_bills_ipn_url } end end |
#refused ⇒ Object
35 36 37 |
# File 'app/controllers/payr/bills_controller.rb', line 35 def refused change_status params[:ref], REFUSED, params[:error] end |