-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support open amount and line item refunds
- Loading branch information
Showing
7 changed files
with
150 additions
and
1 deletion.
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
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
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 |
---|---|---|
|
@@ -121,4 +121,26 @@ public function testGetInvoicePdf() { | |
$result = Recurly_Invoice::getInvoicePdf('1001', 'en-GB', $this->client); | ||
$this->assertEquals(array('/invoices/1001', 'en-GB'), $result); | ||
} | ||
|
||
public function testRefundAmount() { | ||
$this->client->addResponse('POST', 'https://api.recurly.com/v2/invoices/1001/refund', 'invoices/refund-201.xml'); | ||
$invoice = Recurly_Invoice::get('1001', $this->client); | ||
|
||
$refund_invoice = $invoice->refundAmount(1000); | ||
$this->assertEquals($refund_invoice->subtotal_in_cents, -1000); | ||
} | ||
|
||
public function testRefund() { | ||
$this->client->addResponse('POST', 'https://api.recurly.com/v2/invoices/1001/refund', 'invoices/refund-201.xml'); | ||
$invoice = Recurly_Invoice::get('1001', $this->client); | ||
$line_items = $invoice->line_items; | ||
|
||
$adjustment_map = function($line_item) { | ||
return $line_item->toRefundAttributes(); | ||
}; | ||
$adjustments = array_map($adjustment_map, $line_items); | ||
This comment has been minimized.
Sorry, something went wrong.
drewish
|
||
|
||
$refund_invoice = $invoice->refund($adjustments); | ||
$this->assertEquals($refund_invoice->subtotal_in_cents, -1000); | ||
} | ||
} |
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,21 @@ | ||
HTTP/1.1 201 Created | ||
Content-Type: application/xml; charset=utf-8 | ||
Location: https://api.recurly.com/v2/invoices/created-invoice | ||
|
||
<invoice href="https://api.recurly.com/v2/invoices/1001"> | ||
<account href="https://api.recurly.com/v2/accounts/1"/> | ||
<subscription href="https://api.recurly.com/v2/subscriptions/1234567890abcdef"/> | ||
<uuid>012345678901234567890123456789aa</uuid> | ||
<state>collected</state> | ||
<invoice_number type="integer">abcdef1234567890</invoice_number> | ||
<po_number></po_number> | ||
<vat_number></vat_number> | ||
<subtotal_in_cents type="integer">-1000</subtotal_in_cents> | ||
<tax_in_cents type="integer">0</tax_in_cents> | ||
<total_in_cents type="integer">2995</total_in_cents> | ||
<currency>USD</currency> | ||
<created_at type="datetime">2012-05-28T17:44:13Z</created_at> | ||
<closed_at type="datetime">2012-05-28T17:44:13Z</closed_at> | ||
<net_terms type="integer">0</net_terms> | ||
<collection_method>automatic</collection_method> | ||
</invoice> |
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
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
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
Let's get this matching the style of the other change log entries.