#RafaCitec-checkout

1 messages ยท Page 1 of 1 (latest)

abstract hedge
#

๐Ÿ‘‹ happy to help

white hollow
#

Hello tarzan

#

My question is more about the product than the technique. Can the request for the credit card be disabled if the user enters a coupon that gives them access to my product for 6 months?

#

and when those 6 months have passed, request the credit card for payment if the user wants to continue using the application

#

we want them to use the app before requesting the card, but only for some users

abstract hedge
#

if you're using Checkout this is not possible

#

you'd have to build this functionality yourself in a Custom Flow

white hollow
#

in my app

#

with Stripe ? can't

#

right?

#

Stripe always need a credit card, is right?

abstract hedge
#

if you're using Stripe Checkout then the answer is no. but you can use something else such as Stripe Elements

#

but this means you'd have to build and integrate with Stripe differently with more code to write

white hollow
#

ok thanks, I have another question, this one is more technical

#

I have this code in Python

#

i am doing unit testing

#

and stripe.Webhook.construct_event never returns me a valid object

#

always return None

#

and payload and signature is catch of event in real time

#

this morning

#

but testing say "Webhook signature verification failed, No signatures found matching the expected signature for payload"

#

how you can see payload and signature are of same webhook event

abstract hedge
#

unless the event was sent from Stripe it would be really difficult to test this out

white hollow
#

but with this payload and signarture hardcoded

#

stripe.Webhook.construct_event(
payload=payload,
sig_header=signature,
secret=webhook_secret,
). must not works?

quasi vigil
#

your fixture is wrong really

#

you return an object/dict from that stripe_payload function, which is wrong. The payload must be a String. It must be the exact raw string of a HTTP body. Not a Python dict, not the parsed Event object. A string from the HTTP body.

white hollow
#

Ok, I'm going to try that, how long does it take to close this chat?

quasi vigil
#

we close it when you haven't said anything in a while. Why do you ask?

white hollow
#

not now, but sure that yes in a minutes

quasi vigil
#

to be clear if you want to test this you'll have to set up something so that you can log/obtain/capture the exact raw incoming HTTP body at a low level in your server

#

probably you already have that if your signature verification works in general, so you would just capture an example of the strings you're passing into the construct_event functions in the production code

white hollow
#

same error

#

this is payload and signature

#

as you can see the payload is wrapped in single quotes so python will have defined it as a string

quasi vigil
#

what's the error exactly?

white hollow
quasi vigil
#

so it might be that

white hollow
#

No signatures found matching the expected signature for payload

quasi vigil
#

although I think if it's timing then you get a specific error message about it

white hollow
#

Of course, if they have a verification that the signature was made in the last 5 minutes, I am not doing anything, mocking the signature, it will never work for me

quasi vigil
#

yep!

#

really I just wouldn't unit test this, I don't understand why you're doing it since all you're testing is Stripe's own library

#

wouldn't the correct test be to just mock the Stripe part, have a fixture for what the event object is, and test what your own code does when it's handling the event?

white hollow
#

well, I'm testing a component that has the Stripe library inside, I don't want to test the library, it's collateral damage

quasi vigil
#

yeah I'd still just set up the tests to mock the Stripe parts as much as you can

white hollow
#

Ok, thanks