Search code examples
django-rest-frameworkdjango-viewsstripe-paymentsstripe-payment-intent

Don't know what should I write in intent = "" stripe payments django


I was building an donation page as project for collage and reading the stripe documentation on accepting payments and in the starting they say to create Paymentintent.

and provide this code and I don't know what to write in the place of intent = # ...

from flask import Flask, jsonify
app = Flask(__name__)

@app.route('/secret')
def secret():
  intent = # ... Create or retrieve the PaymentIntent
  return jsonify(client_secret=intent.client_secret)

What the documentation is telling is to 'Retrieve the client secret from an endpoint on your server, using the browser’s fetch function.' but I don't understand what it means. I appreciate any help.


Solution

  • Based on your description, it looks like you're following this guide for the payment integration with Stripe.

    If this is the case, Payment Intent client secret should be retrieved from the one that created from the previous step that its response contains client_secret:

    intent = stripe.PaymentIntent.create(
      amount=1099,
      currency="aed",
      automatic_payment_methods={"enabled": True},
    )