Skip to content

Instantly share code, notes, and snippets.

@jaraco
Created May 31, 2018 15:29
Show Gist options
  • Save jaraco/6e17679a4bb3fe9868b90674e2409a17 to your computer and use it in GitHub Desktop.
Save jaraco/6e17679a4bb3fe9868b90674e2409a17 to your computer and use it in GitHub Desktop.
import stripe
stripe.api_key = '...'
disc = stripe.Coupon.create(amount_off=189, currency='USD', duration='forever', id='nice-discount')
cust = stripe.Customer.create(description="nice customer")
prod = stripe.Product.create(name="Individual Lite", type='service')
plan = stripe.Plan.create(nickname='Monthly', amount=199, currency='USD', product=prod, interval='month')
sub = stripe.Subscription.create(customer=cust, items=[dict(plan=plan, quantity=0)], coupon=disc)
item, = sub['items']['data']
item.quantity += 1
item.save().quantity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment