#andrelum-webhooks
1 messages · Page 1 of 1 (latest)
so this is a common error and there are lots of reasons for it
first thing, are you sure the webhook_secret is the right one for the endpoint being used?
second thing, the payload you pass has to match exactly the raw POST body we sent you. It's incredibly common for frameworks in your code to 'helpfully' convert the incoming body to a parsed JSON object, but you can't pass that to the function or it will fail(because things like the ordering and whitespace will change).
the webhook secret was copied from my terminal when i did 'stripe listen' so i dont think that is wrong.
as for the payload, all i am doing is using django's self.request.data...
{'id': 'evt_1Kjg5iIF3yJmpI9eEnSXmIL3', 'object': 'event', 'api_version': '2020-08-27', 'created': 1648802662, 'data': {'object': {'id': 'cs_test_a1Mgkyi8G613KoiJf1FpqRCUibnlbRnq8eei0shBdXJyptMsnHJJ11xzPQ', 'object': 'checkout.session', 'after_expiration': None, 'allow_promotion_codes': None, 'amount_subtotal': 2085, 'amount_total': 2585, 'automatic_tax': {'enabled': False, 'status': None}, 'billing_address_collection': None, 'cancel_url': 'http://None/payment/404/', 'client_reference_id': None, 'consent': None, 'consent_collection': None, 'currency': 'sgd', 'customer': 'cus_LQX9mcwoFbuRYM', 'customer_creation': 'always', 'customer_details': {'address': {'city': None, 'country': 'SG', 'line1': None, 'line2': None, 'postal_code': None, 'state': None}, 'email': 'andre@reluvate.com', 'name': 'sdfsf', 'phone': None, 'tax_exempt': 'none', 'tax_ids': []}, 'customer_email': 'andre@reluvate.com', 'expires_at': 1648889031, 'livemode': False, 'locale': None, 'metadata': {'hashed_session_order_id': 'gAAAAABiRrtHfrLvVEJUlqhwS_hm9KBA96KXzf_0ig3TZYKuWjheHMeEDIF1vKJ0R_BQ_HDbyn9i8oKS_EKqqLeWsuKVcWkZ_Q=='}, 'mode': 'payment', 'payment_intent': 'pi_3Kjg5DIF3yJmpI9e1TLMqR15', 'payment_link': None,
'payment_method_options': {}, 'payment_method_types': ['card'], 'payment_status': 'paid', 'phone_number_collection': {'enabled': False}, 'recovered_from': None, 'setup_intent': None, 'shipping': None, 'shipping_address_collection': None, 'shipping_options': [{'shipping_amount': 500, 'shipping_rate': 'shr_1Kjg5DIF3yJmpI9eMZXV3UbV'}], 'shipping_rate': 'shr_1Kjg5DIF3yJmpI9eMZXV3UbV', 'status': 'complete', 'submit_type': None, 'subscription': None, 'success_url': 'http://None/payment/successful?tracker=gAAAAABiRrtHfrLvVEJUlqhwS_hm9KBA96KXzf_0ig3TZYKuWjheHMeEDIF1vKJ0R_BQ_HDbyn9i8oKS_EKqqLeWsuKVcWkZ_Q==', 'total_details': {'amount_discount': 0, 'amount_shipping': 500, 'amount_tax': 0}, 'url': None}}, 'livemode': False, 'pending_webhooks': 2, 'request': {'id': None, 'idempotency_key': None}, 'type': 'checkout.session.completed'}
this is the payload im passing in ^
so there are no spaces in that
so maybe self.request.data is a parsed version?
https://github.com/stripe/stripe-python/issues/424#issuecomment-845283439 that probably helps
alright
just fixed it
self.request.body.decode('utf-8') seems to work
i have another question
sure, what's up?
does this mean i am able to customize my own checkout preview page? to display my own items and discounts on the left of the payment form?
well you wouldn't be using our Checkout product then, you'd be embedding the PaymentElement(just the inputs you see in the top right) into your own custom page that you build.
what do you mean by your checkout product? the rest of the process should be the same right?
haha i believe i asked u the same thing yesterday
isnt using the custom order flow the thing that i want? the difference is that instead of embedding my own code into stripe's checkout page, i am embedding stripe's payment form into my own page
I do remember yes
I mean you're only embedding the payment part, so then you have to build everything else(line item display, discounts/coupons/tax/customer information collection etc) yourself so it's more complex. Maybe that's what you want and it's a valid option! It's the difference between the two tabs in the main page in the docs.