Created
March 1, 2016 06:44
-
-
Save vamsipavanmahesh/9b7e5670b1b1e89f310d 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
$(document).ready(function(){ | |
var options = { | |
"key": "<%= "#{Figaro.env.MERCHANT_KEY_ID}" %>", | |
"amount": "<%= "#{@product.price}" %>", | |
"name": "<%= "#{@product.seller.name}" %>", | |
"description": "<%= "#{@product.description}" %>", | |
"image": "/images/product.jpg", | |
"handler": function (response){ | |
var mapForm = document.createElement("form"); | |
mapForm.target = "_self"; | |
mapForm.method = "POST"; // or "post" if appropriate | |
mapForm.action = "/purchase"; | |
var mapInput = document.createElement("input"); | |
mapInput.type = "text"; | |
mapInput.name = "payment_id"; | |
mapInput.value = response.razorpay_payment_id; | |
mapForm.appendChild(mapInput); | |
var mapInput2 = document.createElement("input"); | |
mapInput2.type = "text"; | |
mapInput2.name = "user_id"; | |
mapInput2.value = "<%= "#{current_user.id}" %>"; | |
var mapInput3 = document.createElement("input"); | |
mapInput3.type = "text"; | |
mapInput3.name = "product_id"; | |
mapInput3.value = "<%= "#{@product.id}" %>"; | |
mapForm.appendChild(mapInput); | |
mapForm.appendChild(mapInput2); | |
mapForm.appendChild(mapInput3); | |
mapForm.submit(); | |
}, | |
"prefill": { | |
"name": "<%= "#{current_user.name}" %>", | |
"email": "<%= "#{current_user.email}" %>" | |
}, | |
"notes": { | |
"address": "Hello World" | |
}, | |
"theme": { | |
"color": "#198F69" | |
} | |
}; | |
$("#rzp-button1").click(function(e){ | |
var rzp1 = new Razorpay(options); | |
rzp1.open(); | |
e.preventDefault(); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment