Skip to content

Instantly share code, notes, and snippets.

@suhailvs
Last active September 23, 2019 06:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suhailvs/5a67cac1ccf1df8fcad8360d8c080b6d to your computer and use it in GitHub Desktop.
Save suhailvs/5a67cac1ccf1df8fcad8360d8c080b6d to your computer and use it in GitHub Desktop.
Razor Pay example

create an order id

curl -u rzp_test_uvBhuJZjsXdyn3 https://api.razorpay.com/v1/orders -X POST --data "amount=100" --data "currency=INR" --data "receipt=rcptid #1" --data "payment_capture=0"

password: uEd4IHo8TrQMNwMP8qxLk7Gl

Create Example.html

<button id="rzp-button1">Pay</button>
<script src="https://checkout.razorpay.com/v1/checkout.js"></script>
<script>
    var options = {
        "key": "rzp_test_uvBhuJZjsXdyn3", // Enter the Key ID generated from the Dashboard
        "amount": "100", // Amount is in currency subunits. Default currency is INR. Hence, 50000 refers to 50000 paise or INR 500.
        "currency": "INR",
        "name": "Acme Corp",
        "description": "A Wild Sheep Chase is the third novel by Japanese author  Haruki Murakami",
        "image": "http://lorempixel.com/200/200/",
        "order_id": "order_DLXae45SLMwqTZ",//This is a sample Order ID. Create an Order using Orders API. (https://razorpay.com/docs/payment-gateway/orders/integration/#step-1-create-an-order). Refer the Checkout form table given below
        "handler": function (response){
            alert(response.razorpay_payment_id);
            console.log(JSON.stringify(response));
            // response = {"razorpay_payment_id":"pay_DLXbWV0fmyNBvt","razorpay_order_id":"order_DLXae45SLMwqTZ","razorpay_signature":"7fb8d5ba784b5503dfd70b20d9b7339255057c3f1e93f7c29b2600f3f8504bd7"}
        },
        "prefill": {
            "name": "Suhail vs",
            "email": "suhailvs@gmail.com",
            "contact": "7356775981"
        },
        "notes": {
            "address": "note value"
        },
        "theme": {
            "color": "#F37254"
        }
    };
    var rzp1 = new Razorpay(options);
    document.getElementById('rzp-button1').onclick = function(e){
        rzp1.open();
        e.preventDefault();
    }
</script>

Verify Signature

# pip install razorpay
import razorpay
client = razorpay.Client(auth = ("<YOUR_KEY_ID>", "<YOUR_KEY_SECRET>"))
params_dict = { // params
    'razorpay_order_id': '12122', //
    'razorpay_payment_id': '332’,
    'razorpay_signature': '23233'
}
client.utility.verify_payment_signature(params_dict) // This is the method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment