Skip to content

Commit 70513fe

Browse files
Merge pull request #853 from recurly/include_vertex_transaction_type
Update tests and models to include vertex_transaction_type for accurate tax calculations in adjustments, invoices, and purchases.
2 parents 4f816ae + 6852171 commit 70513fe

File tree

6 files changed

+12
-6
lines changed

6 files changed

+12
-6
lines changed

Tests/Recurly/Adjustment_Test.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,12 @@ public function testXml() {
138138
$charge->performance_obligation_id = '6';
139139
$charge->origin_tax_address_source = 'origin';
140140
$charge->destination_tax_address_source = 'destination';
141+
$charge->vertex_transaction_type = 'sale';
141142

142143
// This deprecated parameter should be ignored:
143144
$charge->taxable = 0;
144145

145-
$expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<adjustment><currency>USD</currency><unit_amount_in_cents>5000</unit_amount_in_cents><quantity>1</quantity><quantity_decimal>1.2</quantity_decimal><description>Charge for extra bandwidth</description><accounting_code>bandwidth</accounting_code><tax_exempt>false</tax_exempt><tax_code>fake-tax-code</tax_code><origin>external_gift_card</origin><product_code>abc123</product_code><shipping_address><address1>123 Main St.</address1><city>San Francisco</city><state>CA</state><zip>94110</zip><country>US</country><phone>555-555-5555</phone><email>verena@example.com</email><nickname>Work</nickname><first_name>Verena</first_name><last_name>Example</last_name><company>Recurly Inc.</company></shipping_address><shipping_address_id>123456789</shipping_address_id><revenue_gl_account_id>revenue-gl-account-id</revenue_gl_account_id><liability_gl_account_id>liability_gl_account_id</liability_gl_account_id><performance_obligation_id>6</performance_obligation_id><origin_tax_address_source>origin</origin_tax_address_source><destination_tax_address_source>destination</destination_tax_address_source></adjustment>\n";
146+
$expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<adjustment><currency>USD</currency><unit_amount_in_cents>5000</unit_amount_in_cents><quantity>1</quantity><quantity_decimal>1.2</quantity_decimal><description>Charge for extra bandwidth</description><accounting_code>bandwidth</accounting_code><tax_exempt>false</tax_exempt><tax_code>fake-tax-code</tax_code><origin>external_gift_card</origin><product_code>abc123</product_code><shipping_address><address1>123 Main St.</address1><city>San Francisco</city><state>CA</state><zip>94110</zip><country>US</country><phone>555-555-5555</phone><email>verena@example.com</email><nickname>Work</nickname><first_name>Verena</first_name><last_name>Example</last_name><company>Recurly Inc.</company></shipping_address><shipping_address_id>123456789</shipping_address_id><revenue_gl_account_id>revenue-gl-account-id</revenue_gl_account_id><liability_gl_account_id>liability_gl_account_id</liability_gl_account_id><performance_obligation_id>6</performance_obligation_id><origin_tax_address_source>origin</origin_tax_address_source><destination_tax_address_source>destination</destination_tax_address_source><vertex_transaction_type>sale</vertex_transaction_type></adjustment>\n";
146147
$this->assertEquals($expected, $charge->xml());
147148
}
148149
}

Tests/Recurly/Invoice_Test.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,10 @@ public function testUpdateInvoice() {
238238
$invoice->vat_reverse_charge_notes = "can't be changed when invoice was not a reverse charge";
239239
$invoice->net_terms = '60';
240240
$invoice->gateway_code = 'A new gateway code';
241+
$invoice->vertex_transaction_type = 'rental';
241242

242243
$this->assertEquals(
243-
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<invoice><address><first_name>Spongebob</first_name><last_name>Squarepants</last_name><name_on_account>Patrick Star</name_on_account><company>Krusty Krab</company><address1>124 Conch Street</address1><address2>Pineapple</address2><city>Bikini Bottom</city><state>Dead Eye Gulch</state><zip>96970</zip><country>Pacific Ocean</country><phone>509-990-3551</phone></address><terms_and_conditions>Never disclose the location of the Krabby Patty secret formula.</terms_and_conditions><customer_notes>Is this the Krusty Krab?</customer_notes><vat_reverse_charge_notes>can't be changed when invoice was not a reverse charge</vat_reverse_charge_notes><net_terms>60</net_terms><po_number>3699</po_number><gateway_code>A new gateway code</gateway_code></invoice>\n",
244+
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<invoice><address><first_name>Spongebob</first_name><last_name>Squarepants</last_name><name_on_account>Patrick Star</name_on_account><company>Krusty Krab</company><address1>124 Conch Street</address1><address2>Pineapple</address2><city>Bikini Bottom</city><state>Dead Eye Gulch</state><zip>96970</zip><country>Pacific Ocean</country><phone>509-990-3551</phone></address><terms_and_conditions>Never disclose the location of the Krabby Patty secret formula.</terms_and_conditions><customer_notes>Is this the Krusty Krab?</customer_notes><vat_reverse_charge_notes>can't be changed when invoice was not a reverse charge</vat_reverse_charge_notes><net_terms>60</net_terms><po_number>3699</po_number><gateway_code>A new gateway code</gateway_code><vertex_transaction_type>rental</vertex_transaction_type></invoice>\n",
244245
$invoice->xml()
245246
);
246247
$invoice->update();

Tests/Recurly/Purchase_Test.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,10 @@ public function mockPurchase() {
6363

6464
public function testXml() {
6565
$purchase = $this->mockPurchase();
66+
$purchase->vertex_transaction_type = 'lease';
6667

6768
$this->assertEquals(
68-
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<purchase><account><account_code>aba9209a-aa61-4790-8e61-0a2692435fee</account_code><billing_info><token_id>7z6furn4jvb9</token_id></billing_info><address><address1>123 Main St.</address1><city>San Francisco</city><state>CA</state><zip>94110</zip><country>US</country><phone>555-555-5555</phone></address><dunning_campaign_id>1234abcd</dunning_campaign_id></account><adjustments><adjustment><currency>USD</currency><unit_amount_in_cents>1000</unit_amount_in_cents><quantity>1</quantity><revenue_schedule_type>at_invoice</revenue_schedule_type><product_code>abcd123</product_code><custom_fields><custom_field><name>size</name><value>small</value></custom_field></custom_fields></adjustment></adjustments><collection_method>automatic</collection_method><currency>USD</currency><customer_notes>Customer Notes</customer_notes><terms_and_conditions>Terms and Conditions</terms_and_conditions><vat_reverse_charge_notes>VAT Reverse Charge Notes</vat_reverse_charge_notes><shipping_address><address1>400 Dolores St</address1><city>San Francisco</city><state>CA</state><zip>94110</zip><country>US</country><nickname>Home</nickname><first_name>Dolores</first_name><last_name>Du Monde</last_name></shipping_address><gateway_code>aBcD1234</gateway_code><transaction_type>moto</transaction_type></purchase>\n",
69+
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<purchase><account><account_code>aba9209a-aa61-4790-8e61-0a2692435fee</account_code><billing_info><token_id>7z6furn4jvb9</token_id></billing_info><address><address1>123 Main St.</address1><city>San Francisco</city><state>CA</state><zip>94110</zip><country>US</country><phone>555-555-5555</phone></address><dunning_campaign_id>1234abcd</dunning_campaign_id></account><adjustments><adjustment><currency>USD</currency><unit_amount_in_cents>1000</unit_amount_in_cents><quantity>1</quantity><revenue_schedule_type>at_invoice</revenue_schedule_type><product_code>abcd123</product_code><custom_fields><custom_field><name>size</name><value>small</value></custom_field></custom_fields></adjustment></adjustments><collection_method>automatic</collection_method><currency>USD</currency><customer_notes>Customer Notes</customer_notes><terms_and_conditions>Terms and Conditions</terms_and_conditions><vat_reverse_charge_notes>VAT Reverse Charge Notes</vat_reverse_charge_notes><shipping_address><address1>400 Dolores St</address1><city>San Francisco</city><state>CA</state><zip>94110</zip><country>US</country><nickname>Home</nickname><first_name>Dolores</first_name><last_name>Du Monde</last_name></shipping_address><gateway_code>aBcD1234</gateway_code><transaction_type>moto</transaction_type><vertex_transaction_type>lease</vertex_transaction_type></purchase>\n",
6970
$purchase->xml()
7071
);
7172
}

lib/recurly/adjustment.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
* @property DateTime $end_date A timestamp associated with when the adjustment ended.
4747
* @property DateTime $created_at A timestamp associated with when the adjustment was created.
4848
* @property Recurly_CustomFieldList $custom_fields Optional custom fields for the adjustment.
49+
* @property string $vertex_transaction_type Optional field for Vertex merchants. The Vertex "transaction type" input contributes towards accurate tax calculation by identifying the transaction as a standard sale, a rental, or a lease. Either 'sale', 'rental', or 'lease'.
4950
*/
5051
class Recurly_Adjustment extends Recurly_Resource
5152
{
@@ -160,7 +161,7 @@ protected function getWriteableAttributes() {
160161
'revenue_schedule_type', 'origin', 'product_code', 'credit_reason_code',
161162
'shipping_address', 'shipping_address_id', 'item_code', 'external_sku', 'custom_fields',
162163
'revenue_gl_account_id', 'liability_gl_account_id', 'performance_obligation_id',
163-
'origin_tax_address_source', 'destination_tax_address_source'
164+
'origin_tax_address_source', 'destination_tax_address_source', 'vertex_transaction_type'
164165
);
165166
}
166167
}

lib/recurly/invoice.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
* @property int $credit_customer_notes Allows merchant to set customer notes on a credit invoice. Will only be rejected if type is set to "charge", otherwise will be ignored if no credit invoice is created.
4848
* @property string $dunning_campaign_id Unique ID to identify the dunning campaign used when dunning the invoice.
4949
* @property boolean $used_tax_service If taxes are enabled for the site, it will be true when the invoice had a successful response from the tax service and `false` when the invoice was not sent to tax service due to a lack of address or enabled jurisdiction or was processed without tax due to a non-blocking error returned from the tax service.
50+
* @property string $vertex_transaction_type Optional field for Vertex merchants. The Vertex "transaction type" input contributes towards accurate tax calculation by identifying the transaction as a standard sale, a rental, or a lease. Either 'sale', 'rental', or 'lease'.
5051
*/
5152
class Recurly_Invoice extends Recurly_Resource
5253
{
@@ -267,7 +268,7 @@ protected function getWriteableAttributes() {
267268
return array(
268269
'address', 'billing_info', 'billing_info_uuid', 'terms_and_conditions', 'customer_notes', 'vat_reverse_charge_notes',
269270
'collection_method', 'net_terms', 'net_terms_type', 'po_number', 'currency', 'credit_customer_notes',
270-
'gateway_code'
271+
'gateway_code', 'vertex_transaction_type'
271272
);
272273
}
273274

lib/recurly/purchase.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* @property string $gateway_code Optional base36 encoded id for the gateway you wish to use for this transaction.
2121
* @property Recurly_ShippingFee[] $shipping_fees Optional array of shipping fees to apply to the purchase.
2222
* @property string $transaction_type Indicates type of resulting transaction. accepted_values: "moto".
23+
* @property string $vertex_transaction_type Optional field for Vertex merchants. The Vertex "transaction type" input contributes towards accurate tax calculation by identifying the transaction as a standard sale, a rental, or a lease. Either 'sale', 'rental', or 'lease'.
2324
*/
2425
class Recurly_Purchase extends Recurly_Resource
2526
{
@@ -120,7 +121,7 @@ protected function getWriteableAttributes() {
120121
'account', 'adjustments', 'billing_info_uuid', 'collection_method', 'currency', 'po_number',
121122
'net_terms', 'net_terms_type', 'subscriptions', 'gift_card', 'coupon_codes', 'customer_notes',
122123
'terms_and_conditions', 'vat_reverse_charge_notes', 'shipping_address', 'shipping_address_id',
123-
'gateway_code', 'shipping_fees', 'transaction_type'
124+
'gateway_code', 'shipping_fees', 'transaction_type', 'vertex_transaction_type'
124125
);
125126
}
126127
}

0 commit comments

Comments
 (0)