From 616b326077c2fc17bd673900e7c472987e04bf69 Mon Sep 17 00:00:00 2001 From: Nicolas Gleiser Date: Thu, 19 Jan 2023 15:00:43 -0300 Subject: [PATCH] DEN-165 add cf on charges --- Tests/Recurly/Purchase_Test.php | 3 ++- Tests/fixtures/adjustments/show-200.xml | 6 ++++++ Tests/fixtures/purchases/authorize-200.xml | 6 ++++++ Tests/fixtures/purchases/cancel-200.xml | 6 ++++++ Tests/fixtures/purchases/capture-200.xml | 6 ++++++ Tests/fixtures/purchases/create-201.xml | 6 ++++++ Tests/fixtures/purchases/pending-200.xml | 6 ++++++ Tests/fixtures/purchases/preview-200.xml | 6 ++++++ lib/recurly/adjustment.php | 8 +++++++- 9 files changed, 51 insertions(+), 2 deletions(-) diff --git a/Tests/Recurly/Purchase_Test.php b/Tests/Recurly/Purchase_Test.php index 338b1514..62ff4ec4 100644 --- a/Tests/Recurly/Purchase_Test.php +++ b/Tests/Recurly/Purchase_Test.php @@ -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; @@ -63,7 +64,7 @@ public function testXml() { $purchase = $this->mockPurchase(); $this->assertEquals( - "\naba9209a-aa61-4790-8e61-0a2692435fee7z6furn4jvb9
123 Main St.San FranciscoCA94110US555-555-5555
1234abcd
USD10001at_invoiceabcd123automaticUSDCustomer NotesTerms and ConditionsVAT Reverse Charge Notes400 Dolores StSan FranciscoCA94110USHomeDoloresDu MondeaBcD1234moto
\n", + "\naba9209a-aa61-4790-8e61-0a2692435fee7z6furn4jvb9
123 Main St.San FranciscoCA94110US555-555-5555
1234abcd
USD10001at_invoiceabcd123sizesmallautomaticUSDCustomer NotesTerms and ConditionsVAT Reverse Charge Notes400 Dolores StSan FranciscoCA94110USHomeDoloresDu MondeaBcD1234moto
\n", $purchase->xml() ); } diff --git a/Tests/fixtures/adjustments/show-200.xml b/Tests/fixtures/adjustments/show-200.xml index 78cae3a2..f01b01f0 100644 --- a/Tests/fixtures/adjustments/show-200.xml +++ b/Tests/fixtures/adjustments/show-200.xml @@ -12,6 +12,12 @@ Content-Type: application/xml; charset=utf-8 $12 Annual Subscription + + + size + small + + plan 1200 1 diff --git a/Tests/fixtures/purchases/authorize-200.xml b/Tests/fixtures/purchases/authorize-200.xml index ca2b8699..315ff72a 100644 --- a/Tests/fixtures/purchases/authorize-200.xml +++ b/Tests/fixtures/purchases/authorize-200.xml @@ -58,6 +58,12 @@ Location: https://api.recurly.com/v2/invoices at_invoice + + + size + small + + diff --git a/Tests/fixtures/purchases/cancel-200.xml b/Tests/fixtures/purchases/cancel-200.xml index d0159979..2105bce9 100644 --- a/Tests/fixtures/purchases/cancel-200.xml +++ b/Tests/fixtures/purchases/cancel-200.xml @@ -58,6 +58,12 @@ Location: https://api.recurly.com/v2/invoices at_invoice + + + size + small + + diff --git a/Tests/fixtures/purchases/capture-200.xml b/Tests/fixtures/purchases/capture-200.xml index e59dfdeb..4a97bbad 100644 --- a/Tests/fixtures/purchases/capture-200.xml +++ b/Tests/fixtures/purchases/capture-200.xml @@ -58,6 +58,12 @@ Location: https://api.recurly.com/v2/invoices at_invoice + + + size + small + + diff --git a/Tests/fixtures/purchases/create-201.xml b/Tests/fixtures/purchases/create-201.xml index ab7db846..2c1cdeef 100644 --- a/Tests/fixtures/purchases/create-201.xml +++ b/Tests/fixtures/purchases/create-201.xml @@ -70,6 +70,12 @@ Location: https://api.recurly.com/v2/invoices/3704 US Home + + + size + small + + diff --git a/Tests/fixtures/purchases/pending-200.xml b/Tests/fixtures/purchases/pending-200.xml index cd9e9114..6d70697f 100644 --- a/Tests/fixtures/purchases/pending-200.xml +++ b/Tests/fixtures/purchases/pending-200.xml @@ -58,6 +58,12 @@ Location: https://api.recurly.com/v2/invoices at_invoice + + + size + small + + diff --git a/Tests/fixtures/purchases/preview-200.xml b/Tests/fixtures/purchases/preview-200.xml index cd9e9114..6d70697f 100644 --- a/Tests/fixtures/purchases/preview-200.xml +++ b/Tests/fixtures/purchases/preview-200.xml @@ -58,6 +58,12 @@ Location: https://api.recurly.com/v2/invoices at_invoice + + + size + small + + diff --git a/lib/recurly/adjustment.php b/lib/recurly/adjustment.php index 796ed14d..1d9ded80 100644 --- a/lib/recurly/adjustment.php +++ b/lib/recurly/adjustment.php @@ -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); } @@ -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' ); } }