How can I make sure the subscription is paid before allowing the user to use my app? [closed]

只谈情不闲聊 提交于 2020-05-17 04:12:52

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!