/**
  * 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;
 }
Example #2
0
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';
    $oCredit->update();
    echo '<strong>Updated credit:</strong>' . "\n";
    echo _toHTML($oCredit);
} catch (\Payname\Exception $e) {
    echo $e . "\n";
}
/* Delete credit */
echo '<h2>Delete credit</h2>' . "\n";
try {
    $aDeletionRes = $oNewCredit->delete();
    echo '<strong>Deleted credit:</strong>' . "\n";
    echo _toHTML($aDeletionRes);
} catch (\Payname\Exception $e) {