public function testXml() { $charge = new Recurly_Adjustment(); $charge->account_code = '1'; $charge->description = 'Charge for extra bandwidth'; $charge->unit_amount_in_cents = 5000; // $50.00 $charge->currency = 'USD'; $charge->quantity = 1; $charge->accounting_code = 'bandwidth'; // This deprecated parameter should be ignored: $charge->taxable = 0; $expected = "<?xml version=\"1.0\"?>\n<adjustment><currency>USD</currency><unit_amount_in_cents>5000</unit_amount_in_cents><quantity>1</quantity><description>Charge for extra bandwidth</description><accounting_code>bandwidth</accounting_code></adjustment>\n"; $this->assertEquals($expected, $charge->xml()); }
public static function init() { Recurly_Adjustment::$_writeableAttributes = array( 'currency','unit_amount_in_cents','quantity','description', 'accounting_code','tax_exempt','tax_code' ); Recurly_Adjustment::$_nestedAttributes = array( 'invoice' ); }
public function credit($amount, $details = "") { $dollars = format_money($amount, true); try { error_log("About to credit user {$dollars} for {$details}.", 0); $credit = new Recurly_Adjustment(); $credit->account_code = $this->recurlyAccount->account_code; $credit->currency = "USD"; $credit->unit_amount_in_cents = -$amount; $credit->description = $details; $credit->create(); if ($credit->uuid) { return true; } else { throw new Exception('transaction failed'); } } catch (Exception $e) { issue_log($this->account->account_code, "Issue crediting user [{$dollars} for {$details}]. " . $e->getMessage(), MemberIssueType::BILLING); } }