Permalink
Browse files

Add void and refund methods

  • Loading branch information...
1 parent 984ff31 commit c9269f686d6c412bcd18980f9547ff823a012d12 @marcguyer committed Dec 24, 2012
Showing with 64 additions and 0 deletions.
  1. +64 −0 Client.php
View
@@ -667,6 +667,70 @@ public function newOneTimeInvoice($code, $id = null, array $data) {
}
/**
+ * Void or refund invoice
+ *
+ * Voiding and refunding can be a bit tricky. Some billing solutions do not allow refunding while a transaction is "voidable". Transactions are usually voidable only for a short time (less than 24 hours). Some billing solutions do not allow voids. Check out the knowledge base article on the subject for more information: {@link http://support.cheddargetter.com/kb/operational-how-tos/credits-and-refunds-and-voids-oh-my}
+ *
+ * @link https://cheddargetter.com/developers#void-or-refund
+ * @link http://support.cheddargetter.com/kb/operational-how-tos/credits-and-refunds-and-voids-oh-my
+ * @param string $number The unique number of the invoice to be voided/refunded generated by CheddarGetter.
+ * @param string|null $id CG id of the invoice
+ * @return CheddarGetter_Response
+ * @throws CheddarGetter_Response_Exception
+ */
+ public function voidOrRefundInvoice($number, $id = null) {
+ return new CheddarGetter_Response(
+ $this->request(
+ '/invoices/void-or-refund/' . (($id) ? 'id/'.$id : 'number/'.$number),
+ array('bogus' => 'make this a post')
+ )
+ );
+ }
+
+ /**
+ * Void invoice
+ *
+ * Voiding and refunding can be a bit tricky. Some billing solutions do not allow refunding while a transaction is "voidable". Transactions are usually voidable only for a short time (less than 24 hours). Some billing solutions do not allow voids. Check out the knowledge base article on the subject for more information: {@link http://support.cheddargetter.com/kb/operational-how-tos/credits-and-refunds-and-voids-oh-my}
+ *
+ * @link https://cheddargetter.com/developers#void
+ * @link http://support.cheddargetter.com/kb/operational-how-tos/credits-and-refunds-and-voids-oh-my
+ * @param string $number The unique number of the invoice to be voided/refunded generated by CheddarGetter.
+ * @param string|null $id CG id of the invoice
+ * @return CheddarGetter_Response
+ * @throws CheddarGetter_Response_Exception
+ */
+ public function voidInvoice($number, $id = null) {
+ return new CheddarGetter_Response(
+ $this->request(
+ '/invoices/void/' . (($id) ? 'id/'.$id : 'number/'.$number),
+ array('bogus' => 'make this a post')
+ )
+ );
+ }
+
+ /**
+ * Refund invoice
+ *
+ * Voiding and refunding can be a bit tricky. Some billing solutions do not allow refunding while a transaction is "voidable". Transactions are usually voidable only for a short time (less than 24 hours). Some billing solutions do not allow voids. Check out the knowledge base article on the subject for more information: {@link http://support.cheddargetter.com/kb/operational-how-tos/credits-and-refunds-and-voids-oh-my}
+ *
+ * @link https://cheddargetter.com/developers#void
+ * @link http://support.cheddargetter.com/kb/operational-how-tos/credits-and-refunds-and-voids-oh-my
+ * @param string $number The unique number of the invoice to be voided/refunded generated by CheddarGetter.
+ * @param string|null $id CG id of the invoice
+ * @param array $amount The amount to be refunded if a partial refund. If the invoice is to be fully refunded, do not pass the amount.
+ * @return CheddarGetter_Response
+ * @throws CheddarGetter_Response_Exception
+ */
+ public function refundInvoice($number, $id = null, $amount = null) {
+ return new CheddarGetter_Response(
+ $this->request(
+ '/invoices/void/' . (($id) ? 'id/'.$id : 'number/'.$number),
+ array('amount' => $amount)
+ )
+ );
+ }
+
+ /**
* Run an outstanding invoice
*
* An outstanding invoice might be one that hasn't been transacted yet or one that has been attempted unsucessfully.

0 comments on commit c9269f6

Please sign in to comment.