Skip to content

Instantly share code, notes, and snippets.

@div
Created October 18, 2014 13:48
Show Gist options
  • Save div/3ebfa4a8fe56dc0ec73b to your computer and use it in GitHub Desktop.
Save div/3ebfa4a8fe56dc0ec73b to your computer and use it in GitHub Desktop.
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