Created
June 28, 2016 06:24
-
-
Save vamsipavanmahesh/295bc1c15d1330185bece6a0b7d62ab7 to your computer and use it in GitHub Desktop.
This file contains 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
require 'razorpay' | |
class PaymentController < ApplicationController | |
# TODO talk to razorpay, looks like vuneralibility | |
skip_before_action :verify_authenticity_token | |
before_action :set_payment_id, only: [:update] | |
def update | |
payment_obj = Razorpay::Payment.fetch(@payment_id) | |
if payment_obj.status == "authorized" | |
if payment_obj.amount == amount | |
payment_obj.capture({amount: amount}) | |
p "payment is successfull" | |
p "payment method is #{payment_obj.method_missing(:method)}" | |
@payment_method = payment_obj.method_missing(:method) | |
else | |
p "payment is tampered" | |
# raise an exception here | |
end | |
else | |
p "payment un authorized" | |
# raise an exception here | |
end | |
end | |
private | |
def set_payment_id | |
byebug | |
@payment_id = params[:razorpay_payment_id] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment