@@ -2581,8 +2581,8 @@ class Price(StripeObject):
25812581 _id_prefix = 'price_'
25822582
25832583 def __init__ (self , id = None , active = None , currency = None , metadata = None ,
2584- nickname = None , product = None , recurring = None , unit_amount = None ,
2585- ** kwargs ):
2584+ nickname = None , product = None , product_data = None ,
2585+ recurring = None , unit_amount = None , ** kwargs ):
25862586 if kwargs :
25872587 raise UserError (400 , 'Unexpected ' + ', ' .join (kwargs .keys ()))
25882588
@@ -2609,6 +2609,10 @@ def __init__(self, id=None, active=None, currency=None, metadata=None,
26092609 # TODO: Add support for "meter" and "usage_type".
26102610 if product is not None :
26112611 Product ._api_retrieve (product ) # to return 404 if not existant
2612+ if product_data is not None :
2613+ assert isinstance (product_data , dict )
2614+ assert 'name' in product_data
2615+ product = Product (name = product_data ['name' ]).id
26122616
26132617 super ().__init__ (id )
26142618
@@ -3357,8 +3361,10 @@ def _update(self, metadata=None, items=None, trial_end=None,
33573361 ) or (
33583362 self .price and
33593363 (
3360- self .price .interval != old_price .interval or
3361- self .price .interval_count != old_price .interval_count
3364+ self .price .recurring .get ('interval' ) !=
3365+ old_price .recurring .get ('interval' ) or
3366+ self .price .recurring .get ('interval_count' ) !=
3367+ old_price .recurring .get ('interval_count' )
33623368 )
33633369 )
33643370 if create_an_invoice :
@@ -3458,7 +3464,7 @@ def _current_period(self):
34583464 'week' : timedelta (weeks = 1 ),
34593465 'month' : relativedelta (months = 1 ),
34603466 'year' : relativedelta (years = 1 )
3461- }[self .price .interval ]
3467+ }[self .price .recurring [ ' interval' ] ]
34623468 if self .price is None :
34633469 assert self .plan is not None
34643470 if self .plan .interval == 'day' :
0 commit comments