Skip to content

Instantly share code, notes, and snippets.

@alecbw
Created November 9, 2022 16:46
Show Gist options
  • Save alecbw/930c9a6520f1661662e23ee3d776d553 to your computer and use it in GitHub Desktop.
Save alecbw/930c9a6520f1661662e23ee3d776d553 to your computer and use it in GitHub Desktop.
Simple function to lookup a Stripe checkout session by its ID
def get_stripe_checkout_session(checkout_session_id):
api_url = "https://api.stripe.com/v1/checkout/sessions/"
api_url += checkout_session_id
api_url += "?expand[]=line_items"
api_url += "&expand[]=customer"
api_url += "&expand[]=total_details.breakdown.discounts.discount"
api_url += "&expand[]=payment_intent.charges"
resp = requests.get(
api_url,
headers={"Authorization": "Bearer " + os.environ['STRIPE_RK']}
)
return resp.json()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment