-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #802 from recurly/add_rev_rec_to_purchases
Add RevRec to adjustments/purchases
- Loading branch information
Showing
3 changed files
with
50 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,8 @@ class Recurly_AdjustmentTest extends Recurly_TestCase | |
{ | ||
function defaultResponses() { | ||
return array( | ||
array('GET', '/adjustments/abcdef1234567890', 'adjustments/show-200.xml') | ||
array('GET', '/adjustments/abcdef1234567890', 'adjustments/show-200.xml'), | ||
array('GET', '/adjustments/abcdef1234567890_revrec', 'adjustments/show-200-revrec.xml'), | ||
); | ||
} | ||
|
||
|
@@ -54,6 +55,14 @@ public function testGetAdjustment() { | |
$this->assertEquals(2000, $county->tax_in_cents); | ||
} | ||
|
||
public function testGetAdjustmentWithRevRec() { | ||
$adjustment = Recurly_Adjustment::get('abcdef1234567890_revrec', $this->client); | ||
|
||
$this->assertSame('100', $adjustment->liability_gl_account_code); | ||
$this->assertSame('200', $adjustment->revenue_gl_account_code); | ||
$this->assertSame('5', $adjustment->performance_obligation_id); | ||
} | ||
|
||
public function testDelete() { | ||
$this->client->addResponse('GET', '/adjustments/abcdef1234567890', 'adjustments/show-200.xml'); | ||
$this->client->addResponse('DELETE', 'https://api.recurly.com/v2/adjustments/abcdef1234567890', 'adjustments/destroy-204.xml'); | ||
|
@@ -122,11 +131,14 @@ public function testXml() { | |
$charge->shipping_address->state = "CA"; | ||
$charge->shipping_address->zip = "94110"; | ||
$charge->shipping_address->country = "US"; | ||
$charge->revenue_gl_account_id = 'revenue-gl-account-id'; | ||
$charge->liability_gl_account_id = 'liability_gl_account_id'; | ||
$charge->performance_obligation_id = '6'; | ||
|
||
// This deprecated parameter should be ignored: | ||
$charge->taxable = 0; | ||
|
||
$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>[email protected]</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></adjustment>\n"; | ||
$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>[email protected]</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></adjustment>\n"; | ||
$this->assertEquals($expected, $charge->xml()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
HTTP/1.1 200 OK | ||
Content-Type: application/xml; charset=utf-8 | ||
|
||
<?xml version="1.0" encoding="UTF-8"?> | ||
<adjustment href="https://api.recurly.com/v2/adjustments/abcdef1234567890_revrec" type="charge"> | ||
<account href="https://api.recurly.com/v2/accounts/account"/> | ||
<invoice href="https://api.recurly.com/v2/invoices/1234"/> | ||
<subscription href="https://api.recurly.com/v2/subscriptions/1234567890abcdef"/> | ||
<uuid>abcdef1234567890</uuid> | ||
<state>invoiced</state> | ||
<description>$12 Annual Subscription</description> | ||
<item_code></item_code> | ||
<accounting_code></accounting_code> | ||
<liability_gl_account_code>100</liability_gl_account_code> | ||
<revenue_gl_account_code>200</revenue_gl_account_code> | ||
<performance_obligation_id>5</performance_obligation_id> | ||
<product_code nil="nil"></product_code> | ||
<origin>plan</origin> | ||
<unit_amount_in_cents type="integer">1200</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">1200</total_in_cents> | ||
<currency>USD</currency> | ||
<taxable type="boolean">false</taxable> | ||
<start_date type="datetime">2011-04-30T07:00:00Z</start_date> | ||
<end_date type="datetime">2011-04-30T07:00:00Z</end_date> | ||
<created_at type="datetime">2011-08-31T03:30:00Z</created_at> | ||
</adjustment> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters