Skip to content

Commit

Permalink
Add charge parameter to subscription termination functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Suarez committed Oct 11, 2018
1 parent 9198e34 commit beae221
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions lib/recurly/subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,24 +103,31 @@ public function updateAtRenewal() {

/**
* Terminate the subscription immediately and issue a full refund of the last renewal
*
* @param Boolean charge If true, unbilled usage is billed on final invoice, else negative usage record created to zero out final invoice.
*/
public function terminateAndRefund() {
$this->terminate('full');
public function terminateAndRefund($charge = true) {
$this->terminate('full', $charge);
}
/**
* Terminate the subscription immediately and issue a prorated/partial refund of the last renewal
*
* @param Boolean charge If true, unbilled usage is billed on final invoice, else negative usage record created to zero out final invoice.
*/
public function terminateAndPartialRefund() {
$this->terminate('partial');
public function terminateAndPartialRefund($charge = true) {
$this->terminate('partial', $charge);
}
/**
* Terminate the subscription immediately without a refund
*
* @param Boolean charge If true, unbilled usage is billed on final invoice, else negative usage record created to zero out final invoice.
*/
public function terminateWithoutRefund() {
$this->terminate('none');
public function terminateWithoutRefund($charge = true) {
$this->terminate('none', $charge);
}
private function terminate($refundType) {
$this->_save(Recurly_Client::PUT, $this->uri() . '/terminate?refund=' . $refundType);
private function terminate($refundType, $charge) {
$chargeString = ($charge) ? 'true' : 'false';
$this->_save(Recurly_Client::PUT, $this->uri() . '/terminate?refund=' . $refundType . '&charge=' . $chargeString);
}

/**
Expand Down

0 comments on commit beae221

Please sign in to comment.