- Content
API v2 Python Client Upgrade Guide
This page is provided as an upgrade guide to all users of the official python client.
Two aspects of the upgrade process are covered:
- Given that version designations for client libraries do not support the same versioning system as the v2 API, we have provided a version mapping table directly below. You can use this table in order to determine which version of the v2 API that a specific client library version is utilizing.
- Breaking changes to client libraries are normally applied with a bump in the
minorversion. As an example, suppose you wish to upgrade from2.5.2to2.9.2while preserving current functionality: apply all changes listed in (2.6.0, 2.7.0,..., 2.9.0). A guide to breaking changes between all versions of the client library can be found below.
We recommend that you first identify the version of the client library required based on the associated API version denoted in the Client Library Mapping Table (directly below), and then refer to the Guide to Breaking Changes section in order to identify next steps to upgrade.
Version Mapping Table
| API Version | Client Version (First) | Client Version (Last) |
|---|---|---|
| 2.6 (and below) | 2.0.0 | 2.5.2 |
| 2.7 | None | None |
| 2.8 | 2.6.0 | 2.6.3 |
| 2.9 | 2.7.1 | 2.7.1 |
| 2.10 | 2.8.0 | 2.8.0 |
| 2.11 | 2.8.1 | 2.8.1 |
| 2.12 | 2.8.2 | 2.8.3 |
| 2.13 | 2.8.4 | 2.8.6 |
| 2.14 | 2.8.7 | 2.8.8 |
| 2.15 | 2.9.0 | 2.9.0 |
| 2.16 | 2.9.1 | 2.9.1 |
| 2.17 | 2.9.2 | 2.9.3 |
| 2.18 | 2.9.4 | 2.9.4 |
| 2.19 | 2.9.5 | 2.9.6 |
| 2.20 | 2.9.7 | 2.9.7 |
| 2.21 | 2.9.8 | 2.9.8 |
| 2.22 | 2.9.9 | 2.9.11 |
| 2.24 | 2.9.12 | 2.9.13 |
| 2.25 | 2.9.14 | 2.9.15 |
| 2.26 | 2.9.16 | 2.9.16 |
| 2.27 | 2.9.17 | 2.9.17 |
| 2.28 | 2.9.18 | 2.9.18 |
| 2.29 | 2.9.19 |
Guide to Breaking Changes
2.9.0
- Older Recurly.js token signing is not longer supported. You should upgrade to version 4 of Recurly.js.
- Removes support for Python 3.3. You should upgrade to a supported version of Python.
2.8.0
-
InvoiceCollection
When creating invoices or using
mark_failed(), we now return anInvoiceCollectionobject rather than anInvoice. If you wish to upgrade your application without changing functionality, we recommend that you use thecharge_invoiceon theInvoiceCollection. Example:# Change This: invoice = account.invoice() # To this collection = account.invoice() invoice = collection.charge_invoiceCalls that now return
InvoiceCollectioninstead ofInvoice:Purchase#invoice()Purchase#preview()Purchase#authorize()Account#invoice()Account#build_invoice()
Furthermore,
Invoice#mark_failed()no longer updates the invoice but rather returns a newInvoiceCollectionobject:# Change This: invoice.mark_failed() # To this collection = invoice.mark_failed() failed_invoice = collection.charge_invoice -
Invoice#original_invoice removed
Invoice#original_invoicewas removed in favor ofInvoice#original_invoices. If you want to maintain functionality, change your code grab the first invoice from that endpoint:# Change this original_invoice = invoice.original_invoice() # To this original_invoice = invoice.original_invoices()[0] -
Invoice
subtotal_*changesWe have renamed two of the invoice subtotal fields to more clearly reflect their values:
- Renamed
subtotal_in_centstosubtotal_before_discount_in_cents - Renamed
subtotal_after_discount_in_centstosubtotal_in_cents
- Renamed
-
Invoice Refund –
refund_apply_orderchanged torefund_methodIf you were using
Invoice#refundorInvoice#refund_amountand explicitly setting the secondrefund_apply_orderparameter, then you may need to change value to fit the newrefund_methodformat. The values for this have changed from (credit,transaction) to (credit_first,transaction_first)If you don’t explicitly set the
refund_apply_orderlike in these two calls, no change is needed:invoice.refund(line_items); invoice.refund_amount(1000);If you do set the second param, you’ll need to change:
credittocredit_firsttransactiontotransaction_first
Examples:
# Change `credit`: invoice.refund(line_items, 'credit'); invoice.refund_amount(1000, 'credit'); # To `credit_first` invoice.refund(line_items, 'credit_first'); invoice.refund_amount(1000, 'credit_first'); # Change `transaction` invoice.refund(line_items, 'transaction'); invoice.refund_amount(1000, 'transaction'); # To `transaction_first` invoice.refund(line_items, 'transaction_first'); invoice.refund_amount(1000, 'transaction_first'); -
Invoice States
If you are checking
Invoice#stateanywhere, you will want to check that you have the new correct values.collectedhas changed topaidandopenhas changed topending. Example:# Change this if invoice.state == 'collected': #To this if invoice.state == 'paid':# Change this if invoice.state == 'open': # To this if invoice.state == 'pending':This also affects the
Invoice.all_collectedandInvoice.all_openfunctions. Example:# Change this Invoice.all_collected() # To this Invoice.all_paid()# Change this Invoice.all_open() # To this Invoice.all_pending()
2.7.0
-
The
subscriptionlink on an instance ofAdjustmentis now only created if adjustment is originating from a subscription plan charge, setup fee, add on, trial or proration credit. It is no longer created for other adjustments. -
Instances of
TransactionandInvoiceno longer have asubscriptionlink and you must now use thesubscriptionslink.# Change this sub = invoice.subscription() # To this, take the first subscription sub = invoice.subscriptions()[0]
2.6.0
Country Codes
All country fields must now contain valid
2 letter ISO 3166 country codes. If your country
code fails validation, you will receive a validation error. This affects any endpoint where an
address is collected.
Purchase Currency
The purchases endpoint can create and invoice multiple adjustments at once but our invoices can only contain items in one currency. To make this explicit the currency can no longer be provided on an adjustment, it must be set once for the entire purchase:
purchase = recurly.Purchase(
# The purchase object is the only place you can set the currency:
currency = 'USD',
account = recurly.Account(
account_code = 'someone',
),
adjustments = [
# Remove this currency
# You can no longer set the currency on adjustment level
recurly.Adjustment(currency='USD', unit_amount_in_cents=1000, description='Item 1',
quantity=1),
]
)
2.5.0
- Since the X-Records header was removed in the pagination endpoint, you can no longer call
len()on a Page and expect it to return a cached response. From now on you need to explicitly call thecount()class method on a Page. See PR #202 for more information. - For
POST /v2/subscriptionsSendingNonefortotal_billing_cyclesattribute will now override plantotal_billing_cyclessetting and will make subscription renew forever. Omitting the attribute will cause the setting to default to the value of plantotal_billing_cycles.
2.4.0
Python 2.6 is no longer supported.
2.3.0
No breaking changes to address.
2.2.0
Removed adjustment.taxable in favor of adjustment.tax_exempt. Keep in mind that these two fields are both booleans but logically inverse.