Last active
August 29, 2015 14:25
-
-
Save kishanio/18479ff7c80321880866 to your computer and use it in GitHub Desktop.
CCAvenue Ruby GEM Usage
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
# application_controller.rb | |
# Create an instance with merchantid, workingkey and redirect url as parameter | |
def ccavenue | |
return @ccavenue = Ccavenue::Payment.new(<TODO: MERCHANT ID>,<TODO: MERCHANT WORKING KEY>,<TODO: REDIRECT URL>) | |
end |
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
# CCAvenue confirmation method. This is called by CCAvenue upon callback. | |
# Method post | |
def payment_confirm | |
# parameter to response is encrypted reponse we get from CCavenue | |
authDesc,verify,data = ccavenue.response(params['encResponse']) | |
# Return parameters: | |
# Auth Description: <String: Payment Failed/Success> | |
# Checksum Verification <Bool: True/False> | |
# Response Data: <HASH/Array: Order_id, amount etc> | |
order_Id = data["Order_Id"][0] | |
end |
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
# Orders page from which user will be redirected to payment gateway. | |
def send_to_ccavenue | |
# Merchant id needed in view | |
@CCAVENUE_MERCHANT_ID = <TODO: MERCHANT ID> | |
# CCAvenue requires a new order id for each request | |
# so if transaction fails we can use #same ones again accross our website. | |
order_id = Time.now.strftime('%d%m%H%L') + <TODO: Order Id> | |
# Parameters: | |
# | |
# order_id | |
# price | |
# billing_name | |
# billing_address | |
# billing_city | |
# billing_zip | |
# billing_state | |
# billing_country | |
# billing_email | |
# billing_phone | |
# billing_notes | |
# delivery_name | |
# delivery_address | |
# delivery_city | |
# delivery_zip | |
# delivery_state | |
# delivery_country | |
# delivery_email | |
# delivery_phone | |
# delivery_notes | |
# | |
# | |
# Mandatory - order_id,price,billing_name,billing_address,billing_city,billing_zip,billing_state,billing_country,billing_email,billing_phone | |
# Optional - billing_notes,delivery_name,delivery_address,delivery_city,delivery_zip,delivery_state,delivery_country,delivery_email,delivery_phone,delivery_notes | |
# Creating encrypted data | |
@encRequest = ccavenue.request(order_id,<TODO: Price>,@order.full_name,"#{@order.address1} ,#{@order.address2}",@order.city,@order.zip,@order.state,@order.country,@order.email,@order.phone) | |
render "<TODO: Redirect Page>" | |
end |
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
<!-- A redirect view has to be renderend that creates a post request for the payment gateway.--> | |
<form id="redirect" method="post" name="redirect" action="http://www.ccavenue.com/shopzone/cc_details.jsp"> | |
<input type="hidden" name="encRequest" value="<%= @encRequest %>"> | |
<input type="hidden" name="Merchant_Id" value="<%=@CCAVENUE_MERCHANT_ID%>"> | |
</form> | |
<script> | |
document.getElementById("redirect").submit(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can refer documentation here