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