Giter Site home page Giter Site logo

Comments (12)

hsaade-algo avatar hsaade-algo commented on June 1, 2024 1

@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.

arnav13081994 avatar arnav13081994 commented on June 1, 2024

@hsaade-algo Please update to the latest version. I believe this problem has already been fixed.

from dj-stripe.

hsaade-algo avatar hsaade-algo commented on June 1, 2024

@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.

arnav13081994 avatar arnav13081994 commented on June 1, 2024

@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.

hsaade-algo avatar hsaade-algo commented on June 1, 2024

@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.

arnav13081994 avatar arnav13081994 commented on June 1, 2024

@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.

hsaade-algo avatar hsaade-algo commented on June 1, 2024

@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.

arnav13081994 avatar arnav13081994 commented on June 1, 2024

@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.

hsaade-algo avatar hsaade-algo commented on June 1, 2024

@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.

arnav13081994 avatar arnav13081994 commented on June 1, 2024

@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.

hsaade-algo avatar hsaade-algo commented on June 1, 2024

@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.

arnav13081994 avatar arnav13081994 commented on June 1, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.