问题
I am working on an intelligent cloud platform able to analyse data of the users. I am going to use Stripe payments and subscription plan. Everything seems to be working properly, but I have some uncertainty.
I wonder how can I check whether the subscription has been paid before allowing the user into my app?
I have to be 100% sure because if I let the user in without the payment I will have to pay for my service costs out of pocket.
I need to verify his payment when I create a subscription, after the account setup.
At this moment I create subscription in my Django backend in this way:
customer = stripe.Customer.create(
email=user.email,
source=request.data['token']
)
subscription = stripe.Subscription.create(
customer=customer.id,
items=[
{
'plan': ‘myexampleplan’,
'quantity': request.data['amount'],
},
],
expand=['latest_invoice.payment_intent'],
)
# At this point I want to have confirmation of whether I already have his money.
I guess that this information is contained in the subscription object but I am not sure.
I need this to happen every month, so that I never have to pay for my services costs out of my pocket.
来源:https://stackoverflow.com/questions/61641486/how-can-i-make-sure-the-subscription-is-paid-before-allowing-the-user-to-use-my