Comments (12)
@arnav13081994 None worked, it's alright. I ended up creating a management command that does pretty much the same, and included your expand=['tiers']
for the Price model, worked sweetly.
Thanks for your help!
from dj-stripe.
@hsaade-algo Please update to the latest version. I believe this problem has already been fixed.
from dj-stripe.
@arnav13081994 As far as I know it was fixed in version 2.4.1, even before I even upgraded to my current version. Unfortunately I cannot upgrade immediately to the latest version because of dependencies. Is there anything I can patch or do to fix this temporarily?
from dj-stripe.
@hsaade-algo Are you facing this error? If yes all I can suggest is to install the state of the repo from the HEAD
commits of the linked PRs. But I don't know if there will be other conflicts because a lot of changes have been made since 2.5
.
from dj-stripe.
@arnav13081994 No I am not facing the same error. Not sure if it's worth mentioning, but I use this command to usually sync prices and products: python manage.py djstripe_sync_models Price Product
from dj-stripe.
@hsaade-algo I'm trying to be thorough here, for the price object in question the billing_scheme
is set as tiered
as mentioned in the docs?
Also please run the following commands and let me know the error you get
from djstripe.models import Price
# get object from stripe
stripe_price = Price.stripe_class.api_retrieve(<PRICE_OBJECT_ID_THAT_DOES_NOT_SYNC_CORRECTLY>)
# run manual sync
instance = Price.sync_from_stripe_data(stripe_price)
Please share the error as well as the value of stripe_price
. stripe_price
is the json you get from Stripe.
from dj-stripe.
@arnav13081994 Yes, the billing_scheme
is set as tiered
. This used to be syncing correctly before djstripe's upgrade.
I tried running stripe_price = Price.stripe_class.api_retrieve(<PRICE_OBJECT_ID_THAT_DOES_NOT_SYNC_CORRECTLY>)
, but got the below error:
AttributeError: type object 'Price' has no attribute 'api_retrieve'
So I tried stripe_price = Price.stripe_class.retrieve("corpo_pro_mensuel")
, and here is the JSON object received. When I synced it using instance = Price.sync_from_stripe_data(stripe_price)
, I got no errors.
`<Price price id=corpo_pro_mensuel at 0x7f43de7c1bf0> JSON: {
"active": true,
"billing_scheme": "tiered",
"created": 1626989315,
"currency": "cad",
"custom_unit_amount": null,
"id": "corpo_pro_mensuel",
"livemode": false,
"lookup_key": null,
"metadata": {
"EN_NAME": "Monthly Subscription",
"FR_NAME": "Abonnement mensuel"
},
"nickname": null,
"object": "price",
"product": "prod_JtxM8MfR4QqweG",
"recurring": {
"aggregate_usage": null,
"interval": "month",
"interval_count": 1,
"trial_period_days": null,
"usage_type": "licensed"
},
"tax_behavior": "unspecified",
"tiers_mode": "volume",
"transform_quantity": null,
"type": "recurring",
"unit_amount": null,
"unit_amount_decimal": null
}`
from dj-stripe.
@hsaade-algo Apologies. I made a mistake. You retrieved it the way you're supposed to.
Please also add the kwarg expand=['tiers'] to the stripe retrieve call and run the sync again. That should be enough to reproduce the error. Please share both the json and the error.
from dj-stripe.
@arnav13081994 No issues, there was no errors. Here is the JSON:
<Price price id=corpo_pro_mensuel at 0x7f43de8aab90> JSON: {
"active": true,
"billing_scheme": "tiered",
"created": 1626989315,
"currency": "cad",
"custom_unit_amount": null,
"id": "corpo_pro_mensuel",
"livemode": false,
"lookup_key": null,
"metadata": {
"EN_NAME": "Monthly Subscription",
"FR_NAME": "Abonnement mensuel"
},
"nickname": null,
"object": "price",
"product": "prod_JtxM8MfR4QqweG",
"recurring": {
"aggregate_usage": null,
"interval": "month",
"interval_count": 1,
"trial_period_days": null,
"usage_type": "licensed"
},
"tax_behavior": "unspecified",
"tiers": [
{
"flat_amount": null,
"flat_amount_decimal": null,
"unit_amount": 995,
"unit_amount_decimal": "995",
"up_to": 1
},
{
"flat_amount": null,
"flat_amount_decimal": null,
"unit_amount": 945,
"unit_amount_decimal": "945",
"up_to": 9
},
{
"flat_amount": null,
"flat_amount_decimal": null,
"unit_amount": 895,
"unit_amount_decimal": "895",
"up_to": 25
},
{
"flat_amount": null,
"flat_amount_decimal": null,
"unit_amount": 845,
"unit_amount_decimal": "845",
"up_to": 49
},
{
"flat_amount": null,
"flat_amount_decimal": null,
"unit_amount": 795,
"unit_amount_decimal": "795",
"up_to": null
}
],
"tiers_mode": "volume",
"transform_quantity": null,
"type": "recurring",
"unit_amount": null,
"unit_amount_decimal": null
}
from dj-stripe.
@hsaade-algo There have been way too many changes since 2.5.1 that it would be very difficult to figure out exactly what is causing this issue.
All I can suggest is that you copy the djstripe_sync_models
management command into your codebase and then run it. The classmethod sync_from_stripe_data
is the common entrypoint for all dj-stripe sync functionality, which is good news for you as that part is not failing.
from dj-stripe.
@arnav13081994 ok thanks. So if I understand correctly, I need to copy the content of djstripe_sync_models
into one my apps' management command and run it?
from dj-stripe.
I think you could just add the content from djstripe's management command into some_app/management/commands/djstripe_sync_models.py
. That should effectively override the implementation of 2.5.1
with the one you just copied into your project. But I can't make any promises that just copying it would work, but is sure worth a shot.
In case that doesn't work, I suggest copying the implementation of the management command from release 2.5.1
and comment out the try-except
statements and see the error. Do share with me so that I can understand and hopefully fix your issue.
from dj-stripe.
Related Issues (20)
- How do I do async processing without WEBHOOK_EVENT_CALLBACK? HOT 2
- Creating WebhooksEndpoint locally raises tolerance constraint failed error HOT 5
- How do I use the secret and public keys in settings when configured from admin? HOT 2
- Syncing data from stripe to djstripe_product table HOT 1
- Link LineItem to an Invoice via some foreign key or related manager HOT 1
- Allow passing parameters to Invoice.retry() HOT 1
- What does it mean: " given that dj-stripe holds a copy of all your data regardless."? dj-stripe is who? what data? HOT 1
- dj-stripe 2.8 release HOT 2
- Add support for EU Bank Transfer payment method HOT 1
- `CommandError: Unknown model: djstripe.cd` HOT 1
- Can't create webhook endpoint with the admin HOT 19
- Invoice.discounts sync error HOT 3
- Subscription objects are missing a currency field HOT 2
- When I search on google, I see some ambiguous docs. HOT 1
- "No API key provided" error when adding a Webhook from Django Admin UI HOT 5
- API Key not defaulting to database key, when using _api_create HOT 3
- Upcoming invoice sync fails HOT 3
- Webhook form failing validation for docker stripe/cli
- Billing.unit_amount_decimal returns a database error if the value is more than 7 digits HOT 1
- CI of Project is failing and has been for months. HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dj-stripe.