Reputation: 31
Hello I am beginner in Django while trying to create Subscription with stripe i am getting error as
InvalidRequestError at /stripe/create-checkout-session Request req_M2eko0H9LwXvDz: You must provide at least one recurring price in
subscription mode when using prices.
This is my views.py code snippet.
`checkout_session = stripe.checkout.Session.create( success_url=request.build_absolute_uri(reverse('main:complete') ) + "?session_id={CHECKOUT_SESSION_ID}", cancel_url=request.build_absolute_uri(reverse('main:cancelled_transaction')), client_reference_id=request.user.id if request.user.is_authenticated else None, customer_email = email, payment_method_types=['card'],
line_items=[
{
'quantity': 1,
'price_data':{
'product':'PRODUCT_ID',
'unit_amount':settings.STRIPE_PRICE_ID,
'currency':'INR',
# 'recurring':'DAY'
}
}
],
mode='subscription',
) `
I have tried to use https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-price_data-recurring in my code.
Upvotes: 3
Views: 8695
Reputation: 31
When adding any subscription product in stripe portal payment mode it should be recurring, which is highlighted below the image, this will help you solve your issue
But avoid …
And if you want to subscribe mode to pay, you must do the recurring mode, and the bar will be allowed to repeat the payment once the subscription ends
Upvotes: 0
Reputation: 2520
This could also happen if the subscription product that you're using isn't configured correctly. In my case, I was using the type "user decides what to pay" instead of the standard pricing, which in fact has the "recurring" configuration needed, as pointed out by orakaro.
Upvotes: 2
Reputation: 1971
It's because you don't specify the recurring parameter to declare this is a recurring price, as the error says. Note that you can view your request in Stripe Dashboard: https://dashboard.stripe.com/test/logs/req_M2eko0H9LwXvDz
Upvotes: 1