Skip to content

Commit

Permalink
Merge pull request #28 from downsider/tax-percentage
Browse files Browse the repository at this point in the history
Tax percentage
  • Loading branch information
jlinn committed May 29, 2015
2 parents fa91533 + f059a71 commit 49f2b11
Show file tree
Hide file tree
Showing 16 changed files with 187 additions and 32 deletions.
6 changes: 5 additions & 1 deletion src/Api/Invoices.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ public function getInvoice($invoiceId)
* @param bool $closed
* @param string $description
* @param array $metadata
* @param float $taxPercent
* @return InvoiceResponse
* @link https://stripe.com/docs/api/curl#update_plan
*/
public function updateInvoice($invoiceId, $applicationFee = null, $closed = null, $description = null, $metadata = null)
public function updateInvoice($invoiceId, $applicationFee = null, $closed = null, $description = null, $metadata = null, $taxPercent = null)
{
$data = array();
if (!is_null($applicationFee)) {
Expand All @@ -62,6 +63,9 @@ public function updateInvoice($invoiceId, $applicationFee = null, $closed = null
if (!is_null($metadata)) {
$data['metadata'] = $metadata;
}
if (!is_null($taxPercent)) {
$data["tax_percent"] = $taxPercent;
}
return $this->client->post('invoices/' . $invoiceId, self::INVOICE_RESPONSE_CLASS, $data);
}

Expand Down
5 changes: 3 additions & 2 deletions src/Api/Tokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ public function getToken($tokenId)
* @param string $number
* @param string $expMonth
* @param string $expYear
* @param string $cvc
* @return CreateCardTokenRequest
*/
public function createCardTokenRequest($number, $expMonth, $expYear)
public function createCardTokenRequest($number, $expMonth, $expYear, $cvc = null)
{
return new CreateCardTokenRequest($number, $expMonth, $expYear);
return new CreateCardTokenRequest($number, $expMonth, $expYear, $cvc);
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/Request/Cards/CreateCardRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ class CreateCardRequest extends UpdateCardRequest
* @param string $number
* @param int $expMonth
* @param int $expYear
* @param mixed $cvc
*/
public function __construct($number, $expMonth, $expYear)
public function __construct($number, $expMonth, $expYear, $cvc = null)
{
$this->number = $number;
$this->expMonth = $expMonth;
$this->expYear = $expYear;
$this->cvc = $cvc;
}

/**
Expand Down
24 changes: 24 additions & 0 deletions src/Request/Customers/CreateCustomerRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ class CreateCustomerRequest extends AbstractCustomerRequest
*/
protected $trialEnd;

/**
* @var float
*/
protected $taxPercent;

/**
* @return string
*/
Expand Down Expand Up @@ -78,4 +83,23 @@ public function setTrialEnd($trialEnd)
$this->trialEnd = $trialEnd;
return $this;
}

/**
* @param float $taxPercent
* @return $this
*/
public function setTaxPercent($taxPercent)
{
$this->taxPercent = $taxPercent;
return $this;
}

/**
* @return float
*/
public function getTaxPercent()
{
return $this->taxPercent;
}

}
22 changes: 22 additions & 0 deletions src/Request/Invoices/CreateInvoiceRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ class CreateInvoiceRequest
*/
protected $subscription;

/**
* @var float
*/
protected $taxPercent;

/**
* @param string $customer
*/
Expand Down Expand Up @@ -133,5 +138,22 @@ public function getSubscription()
return $this->subscription;
}

/**
* @param float $taxPercent
* @return $this
*/
public function setTaxPercent($taxPercent)
{
$this->taxPercent = $taxPercent;
return $this;
}

/**
* @return float
*/
public function getTaxPercent()
{
return $this->taxPercent;
}

}
23 changes: 23 additions & 0 deletions src/Request/Subscriptions/CreateSubscriptionRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ class CreateSubscriptionRequest
*/
protected $applicationFeePercent;

/**
* @var float
*/
protected $taxPercent;

/**
* @param string $plan
*/
Expand Down Expand Up @@ -158,5 +163,23 @@ public function setTrialEnd($trialEnd)
return $this;
}

/**
* @param float $taxPercent
* @return $this
*/
public function setTaxPercent($taxPercent)
{
$this->taxPercent = $taxPercent;
return $this;
}

/**
* @return float
*/
public function getTaxPercent()
{
return $this->taxPercent;
}


}
4 changes: 3 additions & 1 deletion src/Request/Tokens/CreateCardTokenRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,14 @@ class CreateCardTokenRequest
* @param string $number
* @param string $expMonth
* @param string $expYear
* @param string|null $cvc
*/
public function __construct($number, $expMonth, $expYear)
public function __construct($number, $expMonth, $expYear, $cvc = null)
{
$this->number = $number;
$this->expMonth = $expMonth;
$this->expYear = $expYear;
$this->cvc = $cvc;
}

/**
Expand Down
49 changes: 49 additions & 0 deletions src/Response/Invoices/InvoiceResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,18 @@ class InvoiceResponse
*/
protected $forgiven;

/**
* @Type("float")
* @var float
*/
protected $taxPercent;

/**
* @Type("integer")
* @var int
*/
protected $tax;

/**
* @param int $amountDue
* @return $this
Expand Down Expand Up @@ -635,4 +647,41 @@ public function setForgiven($forgiven)
$this->forgiven = $forgiven;
return $this;
}

/**
* @param int $tax
* @return $this
*/
public function setTax($tax)
{
$this->tax = $tax;
return $this;
}

/**
* @return int
*/
public function getTax()
{
return $this->tax;
}

/**
* @param float $taxPercent
* @return $this
*/
public function setTaxPercent($taxPercent)
{
$this->taxPercent = $taxPercent;
return $this;
}

/**
* @return float
*/
public function getTaxPercent()
{
return $this->taxPercent;
}

}
25 changes: 25 additions & 0 deletions src/Response/Subscriptions/SubscriptionResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ class SubscriptionResponse
*/
protected $trialStart;

/**
* @Type("float")
* @var float
*/
protected $taxPercent;

/**
* @return PlanResponse
*/
Expand Down Expand Up @@ -396,4 +402,23 @@ public function setTrialStart($trialStart)
$this->trialStart = $trialStart;
return $this;
}

/**
* @param float $taxPercent
* @return $this
*/
public function setTaxPercent($taxPercent)
{
$this->taxPercent = $taxPercent;
return $this;
}

/**
* @return float
*/
public function getTaxPercent()
{
return $this->taxPercent;
}

}
20 changes: 10 additions & 10 deletions tests/Api/CardsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected function tearDown()
public function testCreateCard()
{
$cardNumber = self::VISA_1;
$request = new CreateCardRequest($cardNumber, 1, 2020);
$request = new CreateCardRequest($cardNumber, 1, 2020, 123);
$response = $this->cards->createCard($this->customerId, $request);

$this->assertInstanceOf('Stripe\Response\Cards\CardResponse', $response);
Expand All @@ -56,7 +56,7 @@ public function testCreateCard()
// test error handling

$cardNumber = self::INCORRECT_NUMBER;
$request = new CreateCardRequest($cardNumber, 1, 2020);
$request = new CreateCardRequest($cardNumber, 1, 2020, 123);
$exceptionThrown = false;
try {
$this->cards->createCard($this->customerId, $request);
Expand All @@ -66,7 +66,7 @@ public function testCreateCard()
$this->assertTrue($exceptionThrown);

$cardNumber = self::CARD_DECLINED;
$request = new CreateCardRequest($cardNumber, 1, 2020);
$request = new CreateCardRequest($cardNumber, 1, 2020, 123);
$exceptionThrown = false;
try {
$this->cards->createCard($this->customerId, $request);
Expand All @@ -76,7 +76,7 @@ public function testCreateCard()
$this->assertTrue($exceptionThrown);

$cardNumber = self::VISA_1;
$request = new CreateCardRequest($cardNumber, 13, 2020);
$request = new CreateCardRequest($cardNumber, 13, 2020, 123);
$exceptionThrown = false;
try {
$this->cards->createCard($this->customerId, $request);
Expand All @@ -85,7 +85,7 @@ public function testCreateCard()
}
$this->assertTrue($exceptionThrown);

$request = new CreateCardRequest($cardNumber, 12, 1984);
$request = new CreateCardRequest($cardNumber, 12, 1984, 123);
$exceptionThrown = false;
try {
$this->cards->createCard($this->customerId, $request);
Expand All @@ -107,7 +107,7 @@ public function testCreateCard()

public function testUpdateCard()
{
$createResponse = $this->cards->createCard($this->customerId, new CreateCardRequest(self::VISA_1, 1, 2020));
$createResponse = $this->cards->createCard($this->customerId, new CreateCardRequest(self::VISA_1, 1, 2020, 123));
$request = new UpdateCardRequest();
$request->setExpYear(2021);
$updateResponse = $this->cards->updateCard($this->customerId, $createResponse->getId(), $request);
Expand All @@ -118,7 +118,7 @@ public function testUpdateCard()

public function testGetCard()
{
$createResponse = $this->cards->createCard($this->customerId, new CreateCardRequest(self::VISA_1, 1, 2020));
$createResponse = $this->cards->createCard($this->customerId, new CreateCardRequest(self::VISA_1, 1, 2020, 123));
$card = $this->cards->getCard($this->customerId, $createResponse->getId());

$this->assertInstanceOf('Stripe\Response\Cards\CardResponse', $card);
Expand All @@ -129,8 +129,8 @@ public function testListCards()
{
$request = new ListRequest();
$request->setLimit(1);
$this->cards->createCard($this->customerId, new CreateCardRequest(self::VISA_1, 1, 2020));
$this->cards->createCard($this->customerId, new CreateCardRequest(self::MASTERCARD_1, 2, 2020));
$this->cards->createCard($this->customerId, new CreateCardRequest(self::VISA_1, 1, 2020, 123));
$this->cards->createCard($this->customerId, new CreateCardRequest(self::MASTERCARD_1, 2, 2020, 123));
$cards = $this->cards->listCards($this->customerId, $request);

$this->assertInstanceOf(Cards::LIST_CARDS_RESPONSE_CLASS, $cards);
Expand All @@ -143,7 +143,7 @@ public function testListCards()

public function testDeleteCard()
{
$createResponse = $this->cards->createCard($this->customerId, new CreateCardRequest(self::VISA_1, 1, 2020));
$createResponse = $this->cards->createCard($this->customerId, new CreateCardRequest(self::VISA_1, 1, 2020, 123));
$deleteResponse = $this->cards->deleteCard($this->customerId, $createResponse->getId());

$this->assertTrue($deleteResponse->getDeleted());
Expand Down
Loading

0 comments on commit 49f2b11

Please sign in to comment.