Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 6 additions & 1 deletion recurly/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -927,9 +927,14 @@ class Adjustment(Resource):
'shipping_address',
'shipping_address_id',
'refundable_total_in_cents',
'custom_fields',
)
xml_attribute_attributes = ('type',)
_classes_for_nodename = {'tax_detail': TaxDetail, 'shipping_address': ShippingAddress}
_classes_for_nodename = {
'tax_detail': TaxDetail,
'shipping_address': ShippingAddress,
'custom_field': CustomField,
}

# This can be removed when the `original_adjustment_uuid` is moved to a link
def __getattr__(self, name):
Expand Down
4 changes: 4 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ To run these tests in Python 2.7, use the `unittest` test runner:

$ python -m unittest discover -s tests

To run a specific test, pass the name of the file and the test name prefixed with test class:

$ python tests/test_resources.py TestResources.test_purchase

Under Python 2.6 or earlier, install the `unittest2` distribution and use it
instead:

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
POST https://api.recurly.com/v2/purchases/authorize HTTP/1.1
X-Api-Version: {api-version}
Accept: application/xml
Authorization: Basic YXBpa2V5Og==
User-Agent: {user-agent}
Content-Type: application/xml; charset=utf-8

<?xml version="1.0" encoding="UTF-8"?>
<purchase>
<account>
<account_code>testmock</account_code>
</account>
<adjustments>
<adjustment>
<custom_fields>
<custom_field>
<name>adjustment-size</name>
<value>large</value>
</custom_field>
<custom_field>
<name>adjustment-color</name>
<value>blue</value>
</custom_field>
</custom_fields>
<description>Item 1</description>
<quantity type="integer">1</quantity>
<unit_amount_in_cents type="integer">1000</unit_amount_in_cents>
</adjustment>
<adjustment>
<description>Item 2</description>
<quantity type="integer">2</quantity>
<unit_amount_in_cents type="integer">2000</unit_amount_in_cents>
</adjustment>
</adjustments>
<collection_method>manual</collection_method>
<currency>USD</currency>
<gateway_code>aBcD1234</gateway_code>
</purchase>

HTTP/1.1 200 OK
Content-Type: application/xml; charset=utf-8
Location: https://api.recurly.com/v2/invoices/1021

<?xml version="1.0" encoding="UTF-8"?>
<invoice_collection>
<charge_invoice href="https://api.recurly.com/v2/invoices/1021">
<account href="https://api.recurly.com/v2/accounts/03f2dad7-e0d3-4856-acbb-fa7a7ce26683"/>
<address>
<address1>123 Main St</address1>
<address2 nil="nil"></address2>
<city>New Orleans</city>
<state>LA</state>
<zip>70114</zip>
<country>US</country>
<phone nil="nil"></phone>
</address>
<subscriptions href="https://api.recurly.com/v2/invoices/1021/subscriptions"/>
<uuid>40625fdaa006a398c444204ae5bd42a3</uuid>
<state>processing</state>
<invoice_number_prefix></invoice_number_prefix>
<invoice_number type="integer">1021</invoice_number>
<po_number nil="nil"></po_number>
<vat_number nil="nil"></vat_number>
<subtotal_in_cents type="integer">6000</subtotal_in_cents>
<tax_in_cents type="integer">0</tax_in_cents>
<total_in_cents type="integer">6000</total_in_cents>
<subtotal_after_discount_in_cents type="integer">6000</subtotal_after_discount_in_cents>
<currency>USD</currency>
<created_at type="datetime">2023-01-16T12:20:37Z</created_at>
<updated_at type="datetime">2023-01-16T12:20:37Z</updated_at>
<attempt_next_collection_at nil="nil"></attempt_next_collection_at>
<closed_at type="datetime">2023-01-16T12:20:37Z</closed_at>
<terms_and_conditions nil="nil"></terms_and_conditions>
<customer_notes nil="nil"></customer_notes>
<recovery_reason nil="nil"></recovery_reason>
<net_terms type="integer">0</net_terms>
<collection_method>automatic</collection_method>
<line_items type="array">
<adjustment href="https://api.recurly.com/v2/adjustments/40625fda8b836c4ff51e764ef795fb87" type="charge">
<account href="https://api.recurly.com/v2/accounts/03f2dad7-e0d3-4856-acbb-fa7a7ce26683" />
<invoice href="https://api.recurly.com/v2/invoices/1021" />
<uuid>40625fda8b836c4ff51e764ef795fb87</uuid>
<state>invoiced</state>
<description>Item 1</description>
<accounting_code nil="nil"></accounting_code>
<product_code nil="nil"></product_code>
<origin>debit</origin>
<unit_amount_in_cents type="integer">1000</unit_amount_in_cents>
<quantity type="integer">1</quantity>
<discount_in_cents type="integer">0</discount_in_cents>
<tax_in_cents type="integer">0</tax_in_cents>
<total_in_cents type="integer">1000</total_in_cents>
<currency>USD</currency>
<taxable type="boolean">false</taxable>
<start_date type="datetime">2023-01-06T12:20:37Z</start_date>
<end_date nil="nil"></end_date>
<created_at type="datetime">2023-01-16T12:20:37Z</created_at>
<updated_at type="datetime">2023-01-16T12:20:37Z</updated_at>
<revenue_schedule_type></revenue_schedule_type>
<custom_fields type="array">
<custom_field>
<name>adjustment-size</name>
<value>large</value>
</custom_field>
<custom_field>
<name>adjustment-color</name>
<value>blue</value>
</custom_field>
</custom_fields>
</adjustment>
<adjustment href="https://api.recurly.com/v2/adjustments/40625fda8ea4dbb77b2b8d4a5d8a9ac2" type="charge">
<account href="https://api.recurly.com/v2/accounts/03f2dad7-e0d3-4856-acbb-fa7a7ce26683" />
<invoice href="https://api.recurly.com/v2/invoices/1021" />
<uuid>
40625fda8ea4dbb77b2b8d4a5d8a9ac2</uuid>
<state>invoiced</state>
<description>Item 2</description>
<accounting_code nil="nil"></accounting_code>
<product_code nil="nil"></product_code>
<origin>
debit</origin>
<unit_amount_in_cents type="integer">2000</unit_amount_in_cents>
<quantity type="integer">2</quantity>
<discount_in_cents type="integer">0</discount_in_cents>
<tax_in_cents type="integer">0</tax_in_cents>
<total_in_cents type="integer">
4000</total_in_cents>
<currency>USD</currency>
<taxable type="boolean">false</taxable>
<start_date type="datetime">2023-01-06T12:20:37Z</start_date>
<end_date nil="nil"></end_date>
<created_at type="datetime">
2023-01-16T12:20:37Z</created_at>
<updated_at type="datetime">2023-01-16T12:20:37Z</updated_at>
<revenue_schedule_type></revenue_schedule_type>
<shipping_address>
<address1>123
Main St</address1>
<address2 nil="nil"></address2>
<city>New Orleans</city>
<state>LA</state>
<zip>70114</zip>
<country>US</country>
<nickname>Work</nickname>
<phone nil="nil"></phone>
</shipping_address>
<custom_fields type="array"></custom_fields>
</adjustment>
</line_items>
<transactions type="array">
<transaction href="https://api.recurly.com/v2/transactions/40625fdb0d71f87624a285476ba7d73d" type="credit_card">
<account href="https://api.recurly.com/v2/accounts/03f2dad7-e0d3-4856-acbb-fa7a7ce26683"/>
<invoice href="https://api.recurly.com/v2/invoices/1021"/>
<subscriptions href="https://api.recurly.com/v2/transactions/40625fdb0d71f87624a285476ba7d73d/subscriptions"/>
<uuid>40625fdb0d71f87624a285476ba7d73d</uuid>
<action>authorization</action>
<amount_in_cents type="integer">6000</amount_in_cents>
<tax_in_cents type="integer">0</tax_in_cents>
<currency>USD</currency>
<status>success</status>
<payment_method>credit_card</payment_method>
<reference>3523411</reference>
<source>subscription</source>
<recurring type="boolean">false</recurring>
<test type="boolean">true</test>
<voidable type="boolean">true</voidable>
<refundable type="boolean">true</refundable>
<ip_address nil="nil"></ip_address>
<gateway_type>test</gateway_type>
<origin>api</origin>
<description nil="nil"></description>
<message>Successful test transaction</message>
<approval_code nil="nil"></approval_code>
<failure_type nil="nil"></failure_type>
<gateway_error_codes nil="nil"></gateway_error_codes>
<cvv_result code="M">Match</cvv_result>
<avs_result code="D">Street address and postal code match.</avs_result>
<avs_result_street nil="nil"></avs_result_street>
<avs_result_postal nil="nil"></avs_result_postal>
<created_at type="datetime">2023-01-16T12:20:37Z</created_at>
<collected_at type="datetime">2023-01-16T12:20:37Z</collected_at>
<updated_at type="datetime">2023-01-16T12:20:37Z</updated_at>
<details>
<account>
<account_code>03f2dad7-e0d3-4856-acbb-fa7a7ce26683</account_code>
<first_name nil="nil"></first_name>
<last_name nil="nil"></last_name>
<company nil="nil"></company>
<email nil="nil"></email>
<billing_info type="credit_card">
<first_name>Verena</first_name>
<last_name>Example</last_name>
<address1>123 Main St</address1>
<address2 nil="nil"></address2>
<city>New Orleans</city>
<state>LA</state>
<zip>70114</zip>
<country>US</country>
<phone nil="nil"></phone>
<vat_number nil="nil"></vat_number>
<card_type>Visa</card_type>
<year type="integer">2020</year>
<month type="integer">11</month>
<first_six>411111</first_six>
<last_four>1111</last_four>
</billing_info>
</account>
</details>
</transaction>
</transactions>
<a name="refund" href="https://api.recurly.com/v2/invoices/1021/refund" method="post"/>
</charge_invoice>
<credit_invoices type="array"></credit_invoices>
</invoice_collection>
Loading