Created
November 9, 2022 16:46
-
-
Save alecbw/930c9a6520f1661662e23ee3d776d553 to your computer and use it in GitHub Desktop.
Simple function to lookup a Stripe checkout session by its ID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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