Created
October 18, 2014 13:48
-
-
Save div/3ebfa4a8fe56dc0ec73b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PaymentsController < ApplicationController | |
def new | |
payment = order.payments.create!(amount: order.total) | |
response = Payture.init options | |
payment.update session_id: response[:session_id] | |
redirect_to payment.payture_url | |
end | |
end | |
class Payment < ActiveRecord::Base | |
def payture_url | |
"#{Payture.host}Pay?SessionId=#{self.session_id}" | |
end | |
end | |
class NotificationsController < ApplicationController | |
def create | |
payment = Payment.find_by! session_id: params["SessionId"] | |
payment.update(status: :paid) if params['Success'] == 'True' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment