Thursday, August 25, 2016

Udio Payment Gateway

Udio Payment Gateway provide you dashbord where you can set all your seting like declare response path, set environment (like http://localhost:3000/, staging and production).
Udio provide you string (SecretKey,  merchant_id,  apikey,  ip_address,  merchant_refID) for different  environment.
We can use either SHA1 or SHA256
Create your checksum like:-
#data = SecretKey + merchant_id + '|' + apikey + '|' + ip_address + '|' + merchant_refID + '|' + currency_code + '|'+ amount + '|' + checksum_method + '|' + authorize_user;
 data = "60cc3b1d0881500d442a21ec80533763" + "TSV62256424" + '|' + "332fe7ee6c5bee8a85a1a6494d6c2e44" + '|' + "114.79.157.124" + '|' + "42311528708732" + '|' + "INR" + '|' + "#{(sprintf "%.2f",  self.amount).gsub('.', '')}" + '|' + "SHA256" + '|' + "1"
 hash = Digest::SHA256.hexdigest(data)
 self.checksum = hash
 self.checksum
Step 1:
class V2::OrdersController < ApplicationController
    def create
      params[:order][:pay_type]="udio"
      format.html {
        session['order_id'] = @order.id
        redirect_to new_v2_udio_responce_path(:id=>@order.id,:type => "udio")
      }
    end
  end

Step 2:
app/controllers/v2/ccavenues_controller.rb 

class V2::CcavenueResponcesController < ApplicationController
    def new
      if params[:type].present? and params[:type] == "udio"
        session[:order_type] = 'udio'
      end
    end
    # hear find order . now pass the parameter in udio form  
    def create
      if session[:order_type] == 'udio'
      @order = Order.find_by_txnid(params[:order_id])
      end
     if params[:status] == "0" and params[:status_msg] == "Success"
       @order.update_column(:order_status,"pending")
      redirect_to thank_you_advance_payment_path(@order)
    else
      redirect_to failure_advance_payments_path
    end
  end

  end

Step 3:
app/views/udio/_form.html.haml

 !!!
  %html
    %body
     

= form_tag "http://pay.sandbox.shmart.in/pay_merchant/hostedcheckout", :method => "post", :id => "pay", :style=>'display:none' do
 = hidden_field_tag "currency_code", "INR"
 = hidden_field_tag "apikey", "332fe7ee6c5bee8a85a1a6494d6c2e44"
 = hidden_field_tag "amount", "#{(sprintf "%.2f", @order.amount).gsub('.', '')}"
 = hidden_field_tag "merchant_refID", "42311528708732"
 = hidden_field_tag "merchant_id", "TSV62256424"
 = hidden_field_tag "checksum_method", "SHA256"
 = hidden_field_tag "ip_address", "114.79.157.124"
 = hidden_field_tag "email", "#{@order.email}"
 = hidden_field_tag "mobileNo", "#{@order.mobile}"
 = hidden_field_tag "f_name", "#{@order.first_name.to_s}"
 = hidden_field_tag "addr", "dfsdfsdf"
 = hidden_field_tag "city", "Mumbai"
 = hidden_field_tag "state", "Maharashtra"
 = hidden_field_tag "zipcode","400045"
 = hidden_field_tag "country", "India"
 = hidden_field_tag "show_shipping_addr", "0"
 = hidden_field_tag "authorize_user", "1"
 = hidden_field_tag "udf1", "#{@order.txnid}"
 = hidden_field_tag "checksum", "#{@order.checksum}"
 = hidden_field_tag "rurl", "http://localhost:3000/udio_responces"
 %center
  = submit_tag "Pay Now", :style => "display:block;", :class => "pink-button"

:javascript
 var obj = document.getElementById("pay");
 obj.submit();


1 comment:

  1. Online Payment Gateway Qatar provides the most versatile method for processing sales. From any online computer terminal you have the ability to process.

    ReplyDelete