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

ENG-1800 #657

Closed
wants to merge 48 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
be4a9fd
Small patch to allow charge immediately on the subscription update ev…
luiscastillocr Jan 19, 2017
5a3cc5d
Make sure there are actually nothing to invoice to the customer and n…
luiscastillocr Jan 19, 2017
21e6d77
Test fix
luiscastillocr Jan 19, 2017
ed56a55
Allow passing coupon codes to customer.create
luiscastillocr Mar 17, 2017
be3cb61
Product, Sku and Order models, actions, and signals
luiscastillocr May 3, 2017
70ebb75
Product, Sku and Orders: more actions, adjustments
luiscastillocr May 4, 2017
884fd3c
Product, Sku and Orders: Allow passing the id when create skus and pr…
luiscastillocr May 5, 2017
a656b35
Product, Sku and Orders: Return Django object on sub and order updates
luiscastillocr May 9, 2017
b1ff095
coupons sync and create methods
luiscastillocr May 16, 2017
c19e742
Sku, Product, Order admin interfaces
luiscastillocr May 23, 2017
cccf85f
Make attributes, metadata and package_dimensions optional
luiscastillocr May 23, 2017
f606088
products and order actions currections, comments in Sku.convert_to_or…
luiscastillocr Jun 1, 2017
c422849
pass the Order instance instead of the stripe order object to actions…
luiscastillocr Jun 2, 2017
ace11ae
Subscription create charge immediately param
luiscastillocr Jun 8, 2017
7ad17c6
sync_order_from_stripe_data refactor
luiscastillocr Jun 8, 2017
5ebcf9b
Order admin correction, user first name and last name in customer column
luiscastillocr Jul 20, 2017
c4c7dba
Missing migration file, invoiceitems.py
luiscastillocr Jan 22, 2018
4487dbc
100% tests passing
luiscastillocr Jan 22, 2018
63770c4
orders actions tests
luiscastillocr Jan 23, 2018
5755a7f
orders actions tests
luiscastillocr Jan 23, 2018
d5a4c5e
coupons and invoiceitems tests
luiscastillocr Jan 24, 2018
f8b7dc3
product tests
luiscastillocr Jan 24, 2018
8f6796e
product tests
luiscastillocr Jan 24, 2018
1746ea1
customers.update, invoiceitems.delete, invoiceitems.retrieve
luiscastillocr Jan 26, 2018
c6c7792
subscription retrieve corrections, sync invoices uncaught exceptions
luiscastillocr Jan 29, 2018
57d7b7d
subscription retrieve
luiscastillocr Jan 30, 2018
6f2851e
support subscriptions with multiple plans, subscriptionitem introduction
luiscastillocr Mar 13, 2018
8204e71
support subscriptions with multiple plans, subscriptionitem introduction
luiscastillocr Apr 13, 2018
1189c1e
support subscriptions with multiple plans
luiscastillocr May 24, 2018
0a15897
horrible mistake fix!
luiscastillocr Jun 5, 2018
2a15ee0
horrible mistake fix!
luiscastillocr Jun 5, 2018
0291ff8
Create invoice item even if the plan does not exist
luiscastillocr Jun 6, 2018
1eb58d9
Discount model, actions.discounts
luiscastillocr Jun 19, 2018
4cd8355
Invoices metadata
luiscastillocr Jun 26, 2018
a59df1e
access customer discount as a dict
luiscastillocr Aug 13, 2018
f5f5206
MultipleObjectsReturned Exception Catch
luiscastillocr Jan 17, 2019
65586cd
MultipleObjectsReturned Exception Catch
luiscastillocr Jan 17, 2019
957f52e
User Discount get_or_create fix
luiscastillocr Oct 21, 2019
bda85a5
Invoices can have no charges associated to it
luiscastillocr Oct 24, 2019
c1a3946
Charges can have None as source, use payment_method instead
luiscastillocr Oct 24, 2019
8446b27
handle plan amount None values
luiscastillocr Apr 20, 2021
f72434d
Support subscriptions pause_collector new field
luiscastillocr Jun 23, 2021
60305da
Support subscriptions pause_collector new field
luiscastillocr Jun 23, 2021
bae3c7e
make Subscription.pause_collection OneToOneField
luiscastillocr Jun 23, 2021
e111f91
actions.invoices.create extra params
luiscastillocr Jun 28, 2022
e51c199
monkey patched the Invoice stripe Struct to make it a DeletableAPIRes…
luiscastillocr Jul 14, 2022
e0efea1
monkey patched the Invoice stripe object to include the void_invoice …
luiscastillocr Jul 18, 2022
9332705
ENG-1800: Set the name field on Stripe using the user's name field in…
allanwr Aug 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
customers.update, invoiceitems.delete, invoiceitems.retrieve
  • Loading branch information
luiscastillocr committed Mar 12, 2018
commit 1746ea1963e3d26af67d34af7023f53fcd461998
4 changes: 4 additions & 0 deletions pinax/stripe/actions/customers.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ def create(user, card=None, plan=settings.PINAX_STRIPE_DEFAULT_PLAN, coupon=None
return _create_without_account(user, card=card, plan=plan, coupon=coupon, charge_immediately=charge_immediately, quantity=quantity)
return _create_with_account(user, stripe_account, card=card, plan=plan, coupon=coupon, charge_immediately=charge_immediately, quantity=quantity)

def update(customer, **kwargs):
stripe_customer = customer.stripe_customer
stripe_customer.update(kwargs)
stripe_customer.save()

def get_customer_for_user(user, stripe_account=None):
"""
Expand Down
41 changes: 39 additions & 2 deletions pinax/stripe/actions/invoiceitems.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import stripe

from django.utils.encoding import smart_str

def create(customer, amount, description, currency="usd", discountable=False, invoice=None, metadata=None, subscription=None):
"""
Expand All @@ -21,6 +21,7 @@ def create(customer, amount, description, currency="usd", discountable=False, in
the data from the Stripe API that represents the invoice item object that
was created
"""

return stripe.InvoiceItem.create(
amount=amount,
customer=customer.stripe_id,
Expand All @@ -30,4 +31,40 @@ def create(customer, amount, description, currency="usd", discountable=False, in
invoice=invoice,
metadata=metadata,
subscription=subscription
)
)

def retrieve(invoiceitem_id):
"""
Retrieve an invoiceitem object from Stripe's API

Stripe throws an exception if the invoiceitem was not found, we are failing this exception
silently and raising any other exception so the developer can know what went wrong.

Args:
invoiceitem_id: the Stripe ID of the invoiceitem you are fetching

Returns:
the data for a order object from the Stripe API
"""
if not invoiceitem_id:
return

try:
return stripe.InvoiceItem.retrieve(invoiceitem_id)
except stripe.InvalidRequestError as e:
if smart_str(e).find("No such invoiceitem") == -1:
raise
else:
# Not Found
return None

def delete(invoiceitem):
"""
delete an invoiceitem

Args:
invoiceitem: the invoiceitem to delete
"""
invoiceitem = retrieve(invoiceitem.id)
if invoiceitem:
invoiceitem.delete()