File tree Expand file tree Collapse file tree 2 files changed +27
-7
lines changed Expand file tree Collapse file tree 2 files changed +27
-7
lines changed Original file line number Diff line number Diff line change 33
44from flask import Flask , render_template , request
55
6- app = Flask (__name__ ,static_folder = "static" , static_url_path = '' )
6+ app = Flask (__name__ , static_folder = "static" , static_url_path = '' )
77razorpay_client = razorpay .Client (auth = ("<APP_ID>" , "<APP_SECRET>" ))
88
99
1010@app .route ('/' )
1111def app_create ():
12- return render_template ('app.html' )
12+ data = {
13+ 'amount' : 5100 ,
14+ 'currency' : 'INR' ,
15+ 'receipt' : 'test receipt' ,
16+ 'payment_capture' : 1 ,
17+ 'notes' : {
18+ 'key' : 'value'
19+ }
20+ }
21+
22+ order = razorpay_client .order .create (data )
23+
24+ order_id = order ['id' ]
25+
26+ return render_template ('app.html' , order_id = order_id , amount = data ['amount' ])
1327
1428
1529@app .route ('/charge' , methods = ['POST' ])
1630def app_charge ():
17- amount = 5100
31+ params_dict = dict (request .form .iteritems ())
32+
33+ try :
34+ razorpay_client .utility .verify_payment_signature (params_dict )
35+ except ValueError :
36+ return json .dumps ('Signature Validatioon failed' )
37+
1838 payment_id = request .form ['razorpay_payment_id' ]
19- razorpay_client . payment . capture ( payment_id , amount )
39+
2040 return json .dumps (razorpay_client .payment .fetch (payment_id ))
2141
2242if __name__ == '__main__' :
Original file line number Diff line number Diff line change 66 < form action ="charge " method ="POST ">
77 < script
88 src ="https://checkout.razorpay.com/v1/checkout.js "
9- data-key ="rzp_test_WyK93y9mvps7SN "
10- data-amount ="5100 "
9+ data-key ="rzp_test_1DP5mmOlF5G5ag "
10+ data-amount ="{{amount}} "
1111 data-name ="Daft Punk "
1212 data-description ="Purchase Description "
1313 data-image ="vk.jpg "
1414 data-netbanking ="true "
1515 data-description ="Tron Legacy "
1616 data-prefill.name ="Harshil Mathur "
1717 data-prefill.email ="
[email protected] "
18- data-prefill.contact =" 9999999999 "
18+ data-order_id =" {{order_id}} "
1919 data-notes.shopping_order_id ="21 ">
2020 </ script >
2121 < input type ="hidden " name ="shopping_order_id " value ="21 ">
You can’t perform that action at this time.
0 commit comments