awesto / djangoshop-stripe

Stripe Payment Provider Integration for django-shop
MIT License
12 stars 9 forks source link

Stripe API version should be specified #6

Closed abannerjee closed 7 years ago

abannerjee commented 7 years ago

Came across the following error:

  File "~/djangoshop-stripe-subscriptions/shop_stripe/payment.py", line 55, in charge
    raise stripe.error.InvalidRequestError(msg.format(**charge))
TypeError: __init__() takes at least 3 arguments (2 given)

After some digging, It turned out we were on an older Stripe API version ('2015-02-16'), and payment.py was relying on a newer version. (specifically this line https://github.com/awesto/djangoshop-stripe/blob/master/shop_stripe/payment.py#L47)

With the latest API changes, the charge object 'status' attribute takes the value 'succeeded' instead of 'paid'. (https://stripe.com/docs/api/python#charge_object)

One solution would be to just update the Stripe API version on our side. Without knowing what else is affected by that change, I ended up just setting stripe.api_version in payment.py.

Would suggest mentioning the stripe api requirement in the Readme and/or hardcoding the api version.

jrief commented 7 years ago

Thanks for reporting. I just released an intermediate version which requires stripe-1.37. Later on, I will migrate the projects to the latest version of stripe.

jrief commented 7 years ago

I'm currently upgrading this app to use the Python stripe library 1.53.0. If a payment is charged successfully, Stripe returns a charge object with charge['status'] == 'succeeded'.

This also is, what the docs say:

The status of the payment is either succeeded, pending, or failed.

How did you manage to get a return of charge['status'] == 'succeeded'?

abannerjee commented 7 years ago

Hmm, good question. So I know we specify stripe==1.51.0 for our apps and it seems somehow that is the version of stripe which is used in djangoshop-stripe even though the install_requires 'stripe>=1.37.0,<1.38'

Tested this by creating a breakpoint in djangoshop-stripe payment.py with the following result:

(Pdb) stripe.VERSION
'1.51.0'
jrief commented 7 years ago

Today I will release djangoshop-stripe version 0.3.0 You can test it from GitHub, it uses the latest version from Stripe and angular-stripe

(just for curiosity, on which site do you deploy django-SHOP?)

abannerjee commented 7 years ago

We're in the process of updating our main site (www.nimbisservices.com) which will be using django-SHOP but is currently not deployed.