Total Blog Views: 71
Blog Status: publish
Created By: swazahmad Created at: 08-14-2021
Tags: ruby on rails payment gateway integration UPI integration card payment in ruby on rails indian Upi Integration In ruby on rails
Today We Learn How To handle All UPI/Netbanking/Card transactions using Razorpay
How To handle Custom Payment Take using any UPI using Razorpay.
Register Here and Gain Keys required for configuration, please fill the form carefully so your application gets verified By Razorpay,
For Website Whitelisting Your website should have a minimum below criteria
After Filling in all the details And once everything is okay your account will get verified and you will receive an Email from the Razorpay team you can get Live mode Keys Now
Follow the Below Steps Goto settings
Click On API keys If already present Or You can generate the New One
Please Note Down The Keys
Please Add Below Line In Your Product List Page
<form action="/purchase" method="POST"> <script src="https://checkout.razorpay.com/v1/checkout.js" data-key="<%= "rzp_live_123456" %>" data-amount="<%= product.final_price %>" data-name="ShadBox" data-description="product 1" data-prefill.name="<%= "#{current_user.display_name}" %>" data-prefill.email="<%= "#{current_user.email}" %>" data-theme.color="#041634" > </script> <input type="hidden" value="<%= "#{product.id}" %>" name="product_id"> <input type="hidden" value="<%= "#{current_user.id}" %>" name="user_id"> </form>
You can Update the Above Values Based On your requirement
Update routes.rb file to handle the request from razorpay
post '/purchase' => 'orders#update_payment'
Add update_payment Methods In Orders Controller
class OrdersController < ApplicationController before_action :authenticate_user! def update_payment product = Product.find_by_id(params[:product_id]) payment = current_user.payment_histories.new(product_id: product.id, payment_id: params[:razorpay_payment_id]) if payment.save flash[:alert] = "payment successfully made." redirect_to product_path(product) else flash[:alert] = "Something went wrong please try again later." redirect_to root_path end end end
In the above Code, If payment is successfully captured we created an entry In DB to store Payment Info and we can proceed with the order based on the requirement
List of payment Method Supported by Razorpay Please see below Live App screenshot
Click On link after Login we do have configured Using razorpay Click On pay Button
Razorpay provide a very beautiful Dashboard
Thanks for reading , If queries and Suggestion Please ask in the comment
we have the “Get things executed” lifestyle at our place of work. There are not any excuses, no if’s or however’s in our dictionary. committed to navigating the ship of creativity to create cell answers, we resolve the real-lifestyles troubles of our clients and their clients. Our passion for work has won us many awards, year after 12 months.
© Copyright Shadbox. All Rights Reserved
Rate Blog :
Share on :
Do you have any blog suggestion? please click on the link