/** * Get a related credit, or all credits * * @param string $sHash (Optional) Hash of credit to get * <br/> Default : null <=> get all related credits * * @throw \Payname\Exception On API Error * * @return Credit|array Requested Credit, or list of all related credits */ public function credit($sHash = null) { if ($sHash) { // hash given => get one $mRes = Credit::get($this->hash, $sHash); } else { // no hash => get all $mRes = Credit::getAll($this->hash); } return $mRes; }
// Directly $oCredit = Credit::get($order, $oNewCredit->hash); echo '<strong>Credit got (directly):</strong>' . "\n"; echo _toHTML($oCredit); // Via payment $oCredit = Payment::get($order)->credit($oNewCredit->hash); echo '<strong>Credit got (via payment):</strong>' . "\n"; echo _toHTML($oCredit); } catch (\Payname\Exception $e) { echo $e . "\n"; } /* Get credit list */ echo '<h2>Get credit list</h2>' . "\n"; try { // Directly $aCredits = Credit::getAll($order); echo '<strong>Credit list (directly):</strong>' . "\n"; echo _toHTML($aCredits); // Via payment $aCredits = Payment::get($order)->credit(); echo '<strong>Credit list (via payment):</strong>' . "\n"; echo _toHTML($aCredits); } catch (\Payname\Exception $e) { echo $e . "\n"; } /* Update credit */ echo '<h2>Update credit</h2>' . "\n"; try { $oCredit = Credit::get($order, $oNewCredit->hash); $oCredit->amount = 1337; $oCredit->due_at = '2015-09-01';