Skip to content

Commit 90dbe53

Browse files
committed
Adding Vertex Transaction Type for Purchases
1 parent ade585d commit 90dbe53

File tree

3 files changed

+207
-0
lines changed

3 files changed

+207
-0
lines changed

recurly/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,6 +1055,7 @@ class Adjustment(Resource):
10551055
'revenue_gl_account_code',
10561056
'revenue_gl_account_id',
10571057
'performance_obligation_id',
1058+
'vertex_transaction_type',
10581059
)
10591060
xml_attribute_attributes = ('type',)
10601061
_classes_for_nodename = {
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
POST https://api.recurly.com/v2/purchases HTTP/1.1
2+
X-Api-Version: {api-version}
3+
Accept: application/xml
4+
Authorization: Basic YXBpa2V5Og==
5+
User-Agent: {user-agent}
6+
Content-Type: application/xml; charset=utf-8
7+
8+
<?xml version="1.0" encoding="UTF-8"?>
9+
<purchase>
10+
<account>
11+
<account_code>testmock</account_code>
12+
</account>
13+
<adjustments>
14+
<adjustment>
15+
<unit_amount_in_cents type="integer">500</unit_amount_in_cents>
16+
<vertex_transaction_type>lease</vertex_transaction_type>
17+
</adjustment>
18+
</adjustments>
19+
<currency>USD</currency>
20+
</purchase>
21+

22+
HTTP/1.1 201 Created
23+
Content-Type: application/xml; charset=utf-8
24+
Location: https://api.recurly.com/v2/invoices/1359
25+
26+
<?xml version="1.0" encoding="UTF-8"?>
27+
<invoice_collection>
28+
<charge_invoice href="https://api.recurly.com/v2/invoices/1359">
29+
<account href="https://api.recurly.com/v2/accounts/testmock"/>
30+
<dunning_campaign_id nil="nil"></dunning_campaign_id>
31+
<business_entity href="https://api.recurly.com/v2/business_entities/t58pm17a74k6"/>
32+
<address>
33+
<name_on_account nil="nil"></name_on_account>
34+
<first_name>test</first_name>
35+
<last_name>mock</last_name>
36+
<company></company>
37+
<address1>test</address1>
38+
<address2></address2>
39+
<city>San Francisco</city>
40+
<state>CA</state>
41+
<zip>94016</zip>
42+
<country>US</country>
43+
<phone></phone>
44+
</address>
45+
<uuid>6f4654a0444808153e65594a08b9e7a2</uuid>
46+
<state>paid</state>
47+
<invoice_number_prefix></invoice_number_prefix>
48+
<invoice_number type="integer">1359</invoice_number>
49+
<vat_number></vat_number>
50+
<tax_in_cents type="integer">51</tax_in_cents>
51+
<total_in_cents type="integer">551</total_in_cents>
52+
<currency>USD</currency>
53+
<created_at type="datetime">2024-02-23T19:55:22Z</created_at>
54+
<updated_at type="datetime">2024-02-23T19:55:22Z</updated_at>
55+
<attempt_next_collection_at nil="nil"></attempt_next_collection_at>
56+
<closed_at type="datetime">2024-02-23T19:55:22Z</closed_at>
57+
<customer_notes nil="nil"></customer_notes>
58+
<recovery_reason nil="nil"></recovery_reason>
59+
<gateway_code nil="nil"></gateway_code>
60+
<subtotal_before_discount_in_cents type="integer">500</subtotal_before_discount_in_cents>
61+
<subtotal_in_cents type="integer">500</subtotal_in_cents>
62+
<discount_in_cents type="integer">0</discount_in_cents>
63+
<due_on type="datetime">2024-02-23T19:55:22Z</due_on>
64+
<balance_in_cents type="integer">0</balance_in_cents>
65+
<type>charge</type>
66+
<origin>purchase</origin>
67+
<credit_invoices href="https://api.recurly.com/v2/invoices/1359/credit_invoices"/>
68+
<refundable_total_in_cents type="integer">551</refundable_total_in_cents>
69+
<credit_payments type="array">
70+
</credit_payments>
71+
<net_terms type="integer">0</net_terms>
72+
<collection_method>automatic</collection_method>
73+
<po_number nil="nil"></po_number>
74+
<terms_and_conditions nil="nil"></terms_and_conditions>
75+
<tax_type>usst</tax_type>
76+
<tax_region>CA</tax_region>
77+
<tax_rate type="float">0.1025</tax_rate>
78+
<used_tax_service type="boolean">true</used_tax_service>
79+
<line_items type="array">
80+
<adjustment href="https://api.recurly.com/v2/adjustments/6f46549f12d532b7579250425881a3ba" type="charge">
81+
<account href="https://api.recurly.com/v2/accounts/testmock"/>
82+
<bill_for_account href="https://api.recurly.com/v2/accounts/testmock"/>
83+
<item_code nil="nil"></item_code>
84+
<external_sku nil="nil"></external_sku>
85+
<invoice href="https://api.recurly.com/v2/invoices/1359"/>
86+
<credit_adjustments href="https://api.recurly.com/v2/adjustments/6f46549f12d532b7579250425881a3ba/credit_adjustments"/>
87+
<refundable_total_in_cents type="integer">551</refundable_total_in_cents>
88+
<uuid>6f46549f12d532b7579250425881a3ba</uuid>
89+
<state>invoiced</state>
90+
<description nil="nil"></description>
91+
<accounting_code nil="nil"></accounting_code>
92+
<product_code nil="nil"></product_code>
93+
<origin>debit</origin>
94+
<unit_amount_in_cents type="integer">500</unit_amount_in_cents>
95+
<quantity type="integer">1</quantity>
96+
<discount_in_cents type="integer">0</discount_in_cents>
97+
<tax_in_cents type="integer">51</tax_in_cents>
98+
<total_in_cents type="integer">551</total_in_cents>
99+
<tax_inclusive type="boolean">false</tax_inclusive>
100+
<currency>USD</currency>
101+
<proration_rate nil="nil"></proration_rate>
102+
<tax_type>usst</tax_type>
103+
<tax_region>CA</tax_region>
104+
<tax_rate type="float">0.1025</tax_rate>
105+
<tax_exempt type="boolean">false</tax_exempt>
106+
<tax_code nil="nil"></tax_code>
107+
<start_date type="datetime">2024-02-23T19:55:20Z</start_date>
108+
<end_date nil="nil"></end_date>
109+
<created_at type="datetime">2024-02-23T19:55:22Z</created_at>
110+
<updated_at type="datetime">2024-02-23T19:55:22Z</updated_at>
111+
<revenue_schedule_type></revenue_schedule_type>
112+
<custom_fields type="array">
113+
</custom_fields>
114+
<vertex_transaction_type>lease</vertex_transaction_type>
115+
</adjustment>
116+
</line_items>
117+
<transactions type="array">
118+
<transaction href="https://api.recurly.com/v2/transactions/6f4654a1a6ba44d5272c794d0d9bd5ef" type="credit_card">
119+
<account href="https://api.recurly.com/v2/accounts/testmock"/>
120+
<invoice href="https://api.recurly.com/v2/invoices/1359"/>
121+
<uuid>6f4654a1a6ba44d5272c794d0d9bd5ef</uuid>
122+
<action>purchase</action>
123+
<amount_in_cents type="integer">551</amount_in_cents>
124+
<tax_in_cents type="integer">51</tax_in_cents>
125+
<currency>USD</currency>
126+
<status>success</status>
127+
<payment_method>credit_card</payment_method>
128+
<reference>8996822</reference>
129+
<source>transaction</source>
130+
<recurring type="boolean">false</recurring>
131+
<test type="boolean">true</test>
132+
<voidable type="boolean">true</voidable>
133+
<refundable type="boolean">true</refundable>
134+
<ip_address>172.22.0.1</ip_address>
135+
<gateway_type>test</gateway_type>
136+
<origin>api</origin>
137+
<description nil="nil"></description>
138+
<message>Successful test transaction</message>
139+
<approval_code nil="nil"></approval_code>
140+
<failure_type nil="nil"></failure_type>
141+
<gateway_error_codes nil="nil"></gateway_error_codes>
142+
<cvv_result code="" nil="nil"/>
143+
<avs_result code="D">Street address and postal code match.</avs_result>
144+
<avs_result_street nil="nil"></avs_result_street>
145+
<avs_result_postal nil="nil"></avs_result_postal>
146+
<created_at type="datetime">2024-02-23T19:55:21Z</created_at>
147+
<collected_at type="datetime">2024-02-23T19:55:22Z</collected_at>
148+
<updated_at type="datetime">2024-02-23T19:55:22Z</updated_at>
149+
<backup_payment_method_used type="boolean">false</backup_payment_method_used>
150+
<details>
151+
<account>
152+
<account_code>testmock</account_code>
153+
<first_name></first_name>
154+
<last_name></last_name>
155+
<company></company>
156+
<email></email>
157+
<billing_info type="credit_card">
158+
<first_name>test</first_name>
159+
<last_name>mock</last_name>
160+
<address1>test</address1>
161+
<address2></address2>
162+
<city>San Francisco</city>
163+
<state>CA</state>
164+
<zip>94016</zip>
165+
<country>US</country>
166+
<phone></phone>
167+
<vat_number></vat_number>
168+
<card_type>Visa</card_type>
169+
<year type="integer">2030</year>
170+
<month type="integer">12</month>
171+
<first_six>411111</first_six>
172+
<last_four>1111</last_four>
173+
</billing_info>
174+
</account>
175+
</details>
176+
</transaction>
177+
</transactions>
178+
<a name="refund" href="https://api.recurly.com/v2/invoices/1359/refund" method="post"/>
179+
</charge_invoice>
180+
<credit_invoices type="array">
181+
</credit_invoices>
182+
</invoice_collection>

tests/test_resources.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,30 @@ def create_purchase():
473473
self.assertEqual(adjustment.revenue_gl_account_code, 'firstrev')
474474
self.assertEqual(adjustment.performance_obligation_id, '5')
475475

476+
def test_purchase_with_vertex_transaction_type(self):
477+
account_code = 'test%s' % self.test_id
478+
def create_purchase():
479+
return Purchase(
480+
account = Account(
481+
account_code = account_code,
482+
),
483+
adjustments = [
484+
recurly.Adjustment(
485+
currency = 'USD',
486+
vertex_transaction_type='lease',
487+
unit_amount_in_cents=500
488+
)
489+
]
490+
)
491+
492+
with self.mock_request('purchase/invoiced-with-vertex-transaction-type.xml'):
493+
collection = create_purchase().invoice()
494+
adjustment = collection.charge_invoice.line_items[0]
495+
496+
self.assertIsInstance(collection, InvoiceCollection)
497+
self.assertIsInstance(collection.charge_invoice, Invoice)
498+
self.assertEqual(adjustment.vertex_transaction_type, 'lease')
499+
476500
def test_account(self):
477501
account_code = 'test%s' % self.test_id
478502
with self.mock_request('account/does-not-exist.xml'):

0 commit comments

Comments
 (0)