I am referring to SQLAlchemy fields directly. I am able to save
but not the date for some reason. I need to display complete information about the subscription to end user.
@app.route('/webhook' methods=['POST']
def webhook():
event_json = json.loads(request.data)
event = stripe.Event.retrieve(event_json['id'])
if event.type == 'invoice.payment_succeeded':
invoice = event.data.object
...........
How to integrate the response with other views like cancel/subscription views?
Do I need to include all the other views with webhooks on stripe side?
Because I need all my views to show expiry, due date, invoice number etc.
So lets say I have a subscription views for yearly package like below then how to connect json synchronised element for next due date.
@app.route('/yearly', methods=['GET', 'POST'])
def yearly_charged_rec(user_id=None):
if not user_authorized():
return redirect('/')
if request.method == 'POST':
data = get_profile_data(session['auth_token'])
profile_data = data['StudentProfile']
student = get_profile_data(session['auth_token'])['StudentProfile']
stripe_token = request.form['stripeToken']
email = request.form['stripeEmail']
customer = stripe.Customer.create(
email=email,
source=request.form['stripeToken']
)
try:
subscription = stripe.Subscription.create(
plan="yearlyrec",
)
student_ids
package = Package(
student_email=request.form['stripeEmail'],
is_active=True,
package_type='yearlyrec',
)
dbase.session.add(package)
dbase.session.commit()
except stripe.error.CardError as e:
body = e.json_body
err = body['error']
expiry=??
due_date = ??
return render_template('/profile/charge/monthlycharge.html', expiry=expiry, due_date=due_date)
This way I can upload my models with the required information and can upload user related fields in my templates easily.
So assumption is to get data from webhook and post it to each view...or do I need to include all the views links in Stripe webhooks?
Hope information was presented in meaningful way.