Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Stripe Order API Support #1722

Closed
eliezerp3 opened this issue Jun 13, 2022 · 32 comments
Closed

New Stripe Order API Support #1722

eliezerp3 opened this issue Jun 13, 2022 · 32 comments
Labels
discussion The premise or details of this issue is open for discussion

Comments

@eliezerp3
Copy link

Hi. I’m planning on migrating over to the new stripe order api (from the session api) once it leaves beta. Will this be supported in this upcoming release (v2.7.0)?

@eliezerp3 eliezerp3 added the discussion The premise or details of this issue is open for discussion label Jun 13, 2022
@arnav13081994
Copy link
Collaborator

Yes.

@eliezerp3
Copy link
Author

Thanks

@eliezerp3
Copy link
Author

@arnav13081994 I tried testing out the new order api (using just the regular stripe package for now) but I got an error that the beta version wasn't a valid version. I see that you merged a pull request to validate beta versions of stripe. Any way we can get a new pre release so I can start testing it in preparation for full release? Appreciate your work here.

@arnav13081994
Copy link
Collaborator

@eliezerp3 You can install the master/main branch like so:

pip install https://github.com/dj-stripe/dj-stripe/archive/master.zip

@eliezerp3
Copy link
Author

How would I do that via poetry?

@eliezerp3
Copy link
Author

All good.

poetry add git+https://github.com/dj-stripe/dj-stripe.git#master

seems to have done the trick. Thanks again.

@arnav13081994
Copy link
Collaborator

Great! You should know that I have not created a PR for Order Webhooks as I couldn't test them locally. They are not yet supported by the Stripe-CLI.

@eliezerp3
Copy link
Author

eliezerp3 commented Jun 15, 2022

@arnav13081994 Yep. Saw that in the order pull request. Guess stripe will have to sort that out. One thing though. After installing master with the poetry command above, I am able to use the models in my code and through the shell (python manage.py shell) but none of the djstripe models are appearing in my admin panel. This was not an issue in the latest pre-release though.

@eliezerp3
Copy link
Author

One thing though. After installing master with the poetry command above, I am able to use the models in my code and through the shell (python manage.py shell) but none of the djstripe models are appearing in my admin panel. This was not an issue in the latest pre-release though.

@arnav13081994 Is this fixed by any chance?

@arnav13081994
Copy link
Collaborator

@eliezerp3 I just raised a PR for this issue: #1728

@arnav13081994
Copy link
Collaborator

arnav13081994 commented Jun 21, 2022

@eliezerp3 Till that PR gets merged you can add the following line to any admin module in your project to fix this issue.

import djstripe.admin.admin

Once the PR gets merged, you could remove it.

@eliezerp3
Copy link
Author

@arnav13081994 Thanks. Sorry to bother you but one more question. I see that the order models was just merged to master; does that mean server webhook’s will work for it or are you still waiting for stripe to implement local cli webhooks?

@arnav13081994
Copy link
Collaborator

Webhooks will not work in the sense that the data will not sync automatically. There wouldn't be any errors though. They were added here so you can always implement them in your code as mentioned in the docs. My plan is to add them as soon as they get a bit easier to test. I am currently not aware of any straightforward way to invoke and test them. If you are please let me know and I'll be more than happy to open a PR for that as well.

@eliezerp3
Copy link
Author

@arnav13081994 The easiest way to test them is to use a tool like localtunnel (https://theboroer.github.io/localtunnel-www/) which gives you a temporary access to any local port to the web with one command (and then add that address to the test stripe webhook). I find it way easier to use then stripe cli anyway.

Just to be clear; manual syncing using Order.sync_from_stripe_data(order_data) will work, right?

@eliezerp3
Copy link
Author

eliezerp3 commented Jun 22, 2022

@arnav13081994 Also, just to let you know; just tried new master branch and clicking the Order model in the admin page (or even just running "Order.objects.all()" in the shell) is showing the below error message.

ProgrammingError at /api/admin/djstripe/order/
relation "djstripe_order" does not exist
LINE 1: SELECT COUNT(*) AS "__count" FROM "djstripe_order"

@jleclanche
Copy link
Member

@eliezerp3 you will need to run the migrations, but they've been squashed so youll need to roll them back first or start from a fresh db.

When we release the beta version there will be a small upgrade guide.

@eliezerp3
Copy link
Author

@jleclanche Thanks. Just deleted and re-created as it was dev database anyway. Any chance production release of v2.7 will be by end of next week?

@jleclanche
Copy link
Member

I'm aiming for a beta release next week. Production will follow in the weeks after.

@arnav13081994
Copy link
Collaborator

@eliezerp3 Are you able to get the Test webhook events using localtunnel or ngrok without having the local stripe server running?

@eliezerp3
Copy link
Author

@arnav13081994 Yes. Just add the public url ngrok gives u with path to webhook, don't check the "Listen to events on connected accounts", change server to use that webhook secret. Local tunnel seems too be down at the moment but I confirmed ngrok does work.

@arnav13081994
Copy link
Collaborator

@eliezerp3 I must be doing something wrong because I literally had the same setup and wasn't able to get any webhook event on my localhost. It's the same setup I use whenever I work with any app webhook.

I'll try again and let you know.

@eliezerp3
Copy link
Author

eliezerp3 commented Jun 24, 2022

@arnav13081994 Weird. All I can say is make sure your using the test webhooks, check to listen to all events and you leave the “Listen to events on connected accounts” checkbox unchecked.

@arnav13081994
Copy link
Collaborator

@eliezerp3 I just unchecked the “Listen to events on connected accounts” checkbox and now magically my localhost is receiving all the events! Is this a bug or a feature?

@eliezerp3
Copy link
Author

@arnav13081994 I had the same experience and the same question lol. If you find out let me know.

@arnav13081994
Copy link
Collaborator

@eliezerp3 Turns out the mistake I was making was not including the stripe_account header in my API calls. I followed the exact same setup to create another test webhook except that this time I checked the “Listen to events on connected accounts” checkbox and then created an Order on a Connected Account and it hit my ngrok url. So I think for Connect webhooks the stripe_account header should always be populated and not sending it would not be considered an event on the Platform Account. Atleast that's what I gather from this experience.

@eliezerp3
Copy link
Author

@arnav13081994 Interesting. Guess the easiest way to do it is just to have 2 webhooks pointing to the same stripe webhook endpoint; one with the box checked and one without. Weird they wouldn’t give an option to default it to primary account though.

@eliezerp3
Copy link
Author

@arnav13081994 Can I just confirm that with the 2.7 beta release, all of the order events will auto sync with the local order model. And also do I still need to make 2 webhooks (one with connected account checkbox checked and one without) in production (and when using ngrok)?

@arnav13081994
Copy link
Collaborator

@eliezerp3 They should get synced automatically. I don't know about needing to create multiple webhooks in production as stripes behaviour may be different. You'd need to test that.

@eliezerp3
Copy link
Author

@arnav13081994 Thank you for the beta and all your help and looking forward for the 2.7 full release

@eliezerp3
Copy link
Author

eliezerp3 commented Jul 3, 2022

@arnav13081994 Just to let you know; I just downloaded beta and after running make migrations I'm getting

Migrations for 'djstripe':
  /usr/local/lib/python3.10/site-packages/djstripe/migrations/0012_alter_taxrate_options.py
    - Change Meta options on taxrate

Seems all migrations haven't been made.

Also, stripe models are still not in the admin panel (without manually adding them)

And lastly, let me know if you would rather I post beta issues on this thread or make new issues lol (or neither and wait for a more official release)

@arnav13081994
Copy link
Collaborator

@eliezerp3 please create new issues.

@jleclanche This migration would need to be added to the next release.

@arnav13081994
Copy link
Collaborator

arnav13081994 commented Oct 11, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion The premise or details of this issue is open for discussion
Projects
None yet
Development

No branches or pull requests

3 participants