Skip to content

Commit 49f2b11

Browse files
committed
Merge pull request #28 from downsider/tax-percentage
Tax percentage
2 parents fa91533 + f059a71 commit 49f2b11

File tree

16 files changed

+187
-32
lines changed

16 files changed

+187
-32
lines changed

src/Api/Invoices.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ public function getInvoice($invoiceId)
4444
* @param bool $closed
4545
* @param string $description
4646
* @param array $metadata
47+
* @param float $taxPercent
4748
* @return InvoiceResponse
4849
* @link https://stripe.com/docs/api/curl#update_plan
4950
*/
50-
public function updateInvoice($invoiceId, $applicationFee = null, $closed = null, $description = null, $metadata = null)
51+
public function updateInvoice($invoiceId, $applicationFee = null, $closed = null, $description = null, $metadata = null, $taxPercent = null)
5152
{
5253
$data = array();
5354
if (!is_null($applicationFee)) {
@@ -62,6 +63,9 @@ public function updateInvoice($invoiceId, $applicationFee = null, $closed = null
6263
if (!is_null($metadata)) {
6364
$data['metadata'] = $metadata;
6465
}
66+
if (!is_null($taxPercent)) {
67+
$data["tax_percent"] = $taxPercent;
68+
}
6569
return $this->client->post('invoices/' . $invoiceId, self::INVOICE_RESPONSE_CLASS, $data);
6670
}
6771

src/Api/Tokens.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,12 @@ public function getToken($tokenId)
5555
* @param string $number
5656
* @param string $expMonth
5757
* @param string $expYear
58+
* @param string $cvc
5859
* @return CreateCardTokenRequest
5960
*/
60-
public function createCardTokenRequest($number, $expMonth, $expYear)
61+
public function createCardTokenRequest($number, $expMonth, $expYear, $cvc = null)
6162
{
62-
return new CreateCardTokenRequest($number, $expMonth, $expYear);
63+
return new CreateCardTokenRequest($number, $expMonth, $expYear, $cvc);
6364
}
6465

6566
/**

src/Request/Cards/CreateCardRequest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ class CreateCardRequest extends UpdateCardRequest
1818
* @param string $number
1919
* @param int $expMonth
2020
* @param int $expYear
21+
* @param mixed $cvc
2122
*/
22-
public function __construct($number, $expMonth, $expYear)
23+
public function __construct($number, $expMonth, $expYear, $cvc = null)
2324
{
2425
$this->number = $number;
2526
$this->expMonth = $expMonth;
2627
$this->expYear = $expYear;
28+
$this->cvc = $cvc;
2729
}
2830

2931
/**

src/Request/Customers/CreateCustomerRequest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ class CreateCustomerRequest extends AbstractCustomerRequest
2525
*/
2626
protected $trialEnd;
2727

28+
/**
29+
* @var float
30+
*/
31+
protected $taxPercent;
32+
2833
/**
2934
* @return string
3035
*/
@@ -78,4 +83,23 @@ public function setTrialEnd($trialEnd)
7883
$this->trialEnd = $trialEnd;
7984
return $this;
8085
}
86+
87+
/**
88+
* @param float $taxPercent
89+
* @return $this
90+
*/
91+
public function setTaxPercent($taxPercent)
92+
{
93+
$this->taxPercent = $taxPercent;
94+
return $this;
95+
}
96+
97+
/**
98+
* @return float
99+
*/
100+
public function getTaxPercent()
101+
{
102+
return $this->taxPercent;
103+
}
104+
81105
}

src/Request/Invoices/CreateInvoiceRequest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ class CreateInvoiceRequest
3535
*/
3636
protected $subscription;
3737

38+
/**
39+
* @var float
40+
*/
41+
protected $taxPercent;
42+
3843
/**
3944
* @param string $customer
4045
*/
@@ -133,5 +138,22 @@ public function getSubscription()
133138
return $this->subscription;
134139
}
135140

141+
/**
142+
* @param float $taxPercent
143+
* @return $this
144+
*/
145+
public function setTaxPercent($taxPercent)
146+
{
147+
$this->taxPercent = $taxPercent;
148+
return $this;
149+
}
150+
151+
/**
152+
* @return float
153+
*/
154+
public function getTaxPercent()
155+
{
156+
return $this->taxPercent;
157+
}
136158

137159
}

src/Request/Subscriptions/CreateSubscriptionRequest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ class CreateSubscriptionRequest
4242
*/
4343
protected $applicationFeePercent;
4444

45+
/**
46+
* @var float
47+
*/
48+
protected $taxPercent;
49+
4550
/**
4651
* @param string $plan
4752
*/
@@ -158,5 +163,23 @@ public function setTrialEnd($trialEnd)
158163
return $this;
159164
}
160165

166+
/**
167+
* @param float $taxPercent
168+
* @return $this
169+
*/
170+
public function setTaxPercent($taxPercent)
171+
{
172+
$this->taxPercent = $taxPercent;
173+
return $this;
174+
}
175+
176+
/**
177+
* @return float
178+
*/
179+
public function getTaxPercent()
180+
{
181+
return $this->taxPercent;
182+
}
183+
161184

162185
}

src/Request/Tokens/CreateCardTokenRequest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,14 @@ class CreateCardTokenRequest
6969
* @param string $number
7070
* @param string $expMonth
7171
* @param string $expYear
72+
* @param string|null $cvc
7273
*/
73-
public function __construct($number, $expMonth, $expYear)
74+
public function __construct($number, $expMonth, $expYear, $cvc = null)
7475
{
7576
$this->number = $number;
7677
$this->expMonth = $expMonth;
7778
$this->expYear = $expYear;
79+
$this->cvc = $cvc;
7880
}
7981

8082
/**

src/Response/Invoices/InvoiceResponse.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,18 @@ class InvoiceResponse
168168
*/
169169
protected $forgiven;
170170

171+
/**
172+
* @Type("float")
173+
* @var float
174+
*/
175+
protected $taxPercent;
176+
177+
/**
178+
* @Type("integer")
179+
* @var int
180+
*/
181+
protected $tax;
182+
171183
/**
172184
* @param int $amountDue
173185
* @return $this
@@ -635,4 +647,41 @@ public function setForgiven($forgiven)
635647
$this->forgiven = $forgiven;
636648
return $this;
637649
}
650+
651+
/**
652+
* @param int $tax
653+
* @return $this
654+
*/
655+
public function setTax($tax)
656+
{
657+
$this->tax = $tax;
658+
return $this;
659+
}
660+
661+
/**
662+
* @return int
663+
*/
664+
public function getTax()
665+
{
666+
return $this->tax;
667+
}
668+
669+
/**
670+
* @param float $taxPercent
671+
* @return $this
672+
*/
673+
public function setTaxPercent($taxPercent)
674+
{
675+
$this->taxPercent = $taxPercent;
676+
return $this;
677+
}
678+
679+
/**
680+
* @return float
681+
*/
682+
public function getTaxPercent()
683+
{
684+
return $this->taxPercent;
685+
}
686+
638687
}

src/Response/Subscriptions/SubscriptionResponse.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ class SubscriptionResponse
109109
*/
110110
protected $trialStart;
111111

112+
/**
113+
* @Type("float")
114+
* @var float
115+
*/
116+
protected $taxPercent;
117+
112118
/**
113119
* @return PlanResponse
114120
*/
@@ -396,4 +402,23 @@ public function setTrialStart($trialStart)
396402
$this->trialStart = $trialStart;
397403
return $this;
398404
}
405+
406+
/**
407+
* @param float $taxPercent
408+
* @return $this
409+
*/
410+
public function setTaxPercent($taxPercent)
411+
{
412+
$this->taxPercent = $taxPercent;
413+
return $this;
414+
}
415+
416+
/**
417+
* @return float
418+
*/
419+
public function getTaxPercent()
420+
{
421+
return $this->taxPercent;
422+
}
423+
399424
}

tests/Api/CardsTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ protected function tearDown()
4747
public function testCreateCard()
4848
{
4949
$cardNumber = self::VISA_1;
50-
$request = new CreateCardRequest($cardNumber, 1, 2020);
50+
$request = new CreateCardRequest($cardNumber, 1, 2020, 123);
5151
$response = $this->cards->createCard($this->customerId, $request);
5252

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

5858
$cardNumber = self::INCORRECT_NUMBER;
59-
$request = new CreateCardRequest($cardNumber, 1, 2020);
59+
$request = new CreateCardRequest($cardNumber, 1, 2020, 123);
6060
$exceptionThrown = false;
6161
try {
6262
$this->cards->createCard($this->customerId, $request);
@@ -66,7 +66,7 @@ public function testCreateCard()
6666
$this->assertTrue($exceptionThrown);
6767

6868
$cardNumber = self::CARD_DECLINED;
69-
$request = new CreateCardRequest($cardNumber, 1, 2020);
69+
$request = new CreateCardRequest($cardNumber, 1, 2020, 123);
7070
$exceptionThrown = false;
7171
try {
7272
$this->cards->createCard($this->customerId, $request);
@@ -76,7 +76,7 @@ public function testCreateCard()
7676
$this->assertTrue($exceptionThrown);
7777

7878
$cardNumber = self::VISA_1;
79-
$request = new CreateCardRequest($cardNumber, 13, 2020);
79+
$request = new CreateCardRequest($cardNumber, 13, 2020, 123);
8080
$exceptionThrown = false;
8181
try {
8282
$this->cards->createCard($this->customerId, $request);
@@ -85,7 +85,7 @@ public function testCreateCard()
8585
}
8686
$this->assertTrue($exceptionThrown);
8787

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

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

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

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

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

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

149149
$this->assertTrue($deleteResponse->getDeleted());

0 commit comments

Comments
 (0)