Issue
I am integrating razorpay payment gateway in django project but i am getting error while importing razorpay as :- Import razorpay could not be resolved
from django.shortcuts import render
import razorpay # Here i am getting error
from .models import coffee
This is my full code
from django.shortcuts import render
import razorpay
from .models import coffee
# Create your views here.
def index(request):
if request.method=='POST':
Name = request.POST.get("Name")
Amount = int(request.POST.get("Amount")) * 100
client = razorpay.Client(auth= ("rzp_test_YhfEhfejrkkjdkfju","t5MRPkjfijdh23845kejkej"))
payment = client.order.create({'Amount':Amount, 'currency':'INR','payment_capture':'1'})
print(payment)
Coffee = coffee(Name=Name, Amount=Amount , payment_id = payment['id'] )
return render(request,'index.html',{'payment':payment})
return render(request,'index.html')
def success(request):
if request.method == 'POST':
a = request.POST
print(a)
return render(request,"success.html")
This is my terminal
File "D:\Project 3\payment\paymentapp\urls.py", line 18, in <module>
from .import views
File "D:\Project 3\payment\paymentapp\views.py", line 3, in <module>
import razorpay
ModuleNotFoundError: No module named 'razorpay'
Solution
There are few basic thing you have to know before using razorpay gateway in you project first is your amount is considered in paisa so you have to * 100 to converte it in to rupee as I can see you are multiplying * 10 to amount next if you want to use razorpay you must use
pip install razorpay
And I will also recommend you to read the full documentation for using becuase seems that you are missing lot of thing like you have to write JavaScript code handle etc.
https://razorpay.com/docs/payment-gateway/web-integration/standard/
Answered By – Blackranger
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0