Skip to content

Commit

Permalink
DEN-165 add cf on charges
Browse files Browse the repository at this point in the history
  • Loading branch information
ngleiser committed Jan 19, 2023
1 parent 460b350 commit 616b326
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Tests/Recurly/Purchase_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function mockPurchase() {
$adjustment->currency = 'USD';
$adjustment->quantity = 1;
$adjustment->revenue_schedule_type = 'at_invoice';
$adjustment->custom_fields[] = new RecurlyCustomField('size', 'small');

$purchase->adjustments[] = $adjustment;

Expand All @@ -63,7 +64,7 @@ public function testXml() {
$purchase = $this->mockPurchase();

$this->assertEquals(
"<?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></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",
"<?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",
$purchase->xml()
);
}
Expand Down
6 changes: 6 additions & 0 deletions Tests/fixtures/adjustments/show-200.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ Content-Type: application/xml; charset=utf-8
<description>$12 Annual Subscription</description>
<accounting_code></accounting_code>
<product_code nil="nil"></product_code>
<custom_fields>
<custom_field>
<name>size</name>
<value>small</value>
</custom_field>
</custom_fields>
<origin>plan</origin>
<unit_amount_in_cents type="integer">1200</unit_amount_in_cents>
<quantity type="integer">1</quantity>
Expand Down
6 changes: 6 additions & 0 deletions Tests/fixtures/purchases/authorize-200.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ Location: https://api.recurly.com/v2/invoices
<created_at nil="nil"></created_at>
<updated_at nil="nil"></updated_at>
<revenue_schedule_type>at_invoice</revenue_schedule_type>
<custom_fields>
<custom_field>
<name>size</name>
<value>small</value>
</custom_field>
</custom_fields>
</adjustment>
</line_items>
<transactions type="array">
Expand Down
6 changes: 6 additions & 0 deletions Tests/fixtures/purchases/cancel-200.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ Location: https://api.recurly.com/v2/invoices
<created_at nil="nil"></created_at>
<updated_at nil="nil"></updated_at>
<revenue_schedule_type>at_invoice</revenue_schedule_type>
<custom_fields>
<custom_field>
<name>size</name>
<value>small</value>
</custom_field>
</custom_fields>
</adjustment>
</line_items>
<transactions type="array">
Expand Down
6 changes: 6 additions & 0 deletions Tests/fixtures/purchases/capture-200.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ Location: https://api.recurly.com/v2/invoices
<created_at nil="nil"></created_at>
<updated_at nil="nil"></updated_at>
<revenue_schedule_type>at_invoice</revenue_schedule_type>
<custom_fields>
<custom_field>
<name>size</name>
<value>small</value>
</custom_field>
</custom_fields>
</adjustment>
</line_items>
<transactions type="array">
Expand Down
6 changes: 6 additions & 0 deletions Tests/fixtures/purchases/create-201.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ Location: https://api.recurly.com/v2/invoices/3704
<country>US</country>
<nickname>Home</nickname>
</shipping_address>
<custom_fields>
<custom_field>
<name>size</name>
<value>small</value>
</custom_field>
</custom_fields>
</adjustment>
</line_items>
<transactions type="array">
Expand Down
6 changes: 6 additions & 0 deletions Tests/fixtures/purchases/pending-200.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ Location: https://api.recurly.com/v2/invoices
<created_at nil="nil"></created_at>
<updated_at nil="nil"></updated_at>
<revenue_schedule_type>at_invoice</revenue_schedule_type>
<custom_fields>
<custom_field>
<name>size</name>
<value>small</value>
</custom_field>
</custom_fields>
</adjustment>
</line_items>
<transactions type="array">
Expand Down
6 changes: 6 additions & 0 deletions Tests/fixtures/purchases/preview-200.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ Location: https://api.recurly.com/v2/invoices
<created_at nil="nil"></created_at>
<updated_at nil="nil"></updated_at>
<revenue_schedule_type>at_invoice</revenue_schedule_type>
<custom_fields>
<custom_field>
<name>size</name>
<value>small</value>
</custom_field>
</custom_fields>
</adjustment>
</line_items>
<transactions type="array">
Expand Down
8 changes: 7 additions & 1 deletion lib/recurly/adjustment.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,15 @@
* @property DateTime $start_date A timestamp associated with when the adjustment began.
* @property DateTime $end_date A timestamp associated with when the adjustment ended.
* @property DateTime $created_at A timestamp associated with when the adjustment was created.
* @property Recurly_CustomFieldList $custom_fields Optional custom fields for the adjustment.
*/
class Recurly_Adjustment extends Recurly_Resource
{
public function __construct($href = null, $client = null) {
parent::__construct($href, $client);
$this->custom_fields = new Recurly_CustomFieldList();
}

public static function get($adjustment_uuid, $client = null) {
return Recurly_Base::_get(self::_safeUri(Recurly_Client::PATH_ADJUSTMENTS, $adjustment_uuid), $client);
}
Expand Down Expand Up @@ -122,7 +128,7 @@ protected function getWriteableAttributes() {
'currency', 'unit_amount_in_cents', 'quantity', 'quantity_decimal', 'description',
'accounting_code', 'tax_exempt', 'tax_inclusive', 'tax_code', 'start_date', 'end_date',
'revenue_schedule_type', 'origin', 'product_code', 'credit_reason_code',
'shipping_address', 'shipping_address_id', 'item_code', 'external_sku'
'shipping_address', 'shipping_address_id', 'item_code', 'external_sku', 'custom_fields'
);
}
}

0 comments on commit 616b326

Please sign in to comment.