Skip to content

Commit 837e0aa

Browse files
committed
Rename Stripe cardToken parameter to token
1 parent 623b293 commit 837e0aa

File tree

9 files changed

+37
-21
lines changed

9 files changed

+37
-21
lines changed

src/Omnipay/Common/Message/AbstractRequest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,14 @@ public function setCard($value)
141141
return $this->setParameter('card', $value);
142142
}
143143

144-
public function getCardToken()
144+
public function getToken()
145145
{
146-
return $this->getParameter('cardToken');
146+
return $this->getParameter('token');
147147
}
148148

149-
public function setCardToken($value)
149+
public function setToken($value)
150150
{
151-
return $this->setParameter('cardToken', $value);
151+
return $this->setParameter('token', $value);
152152
}
153153

154154
public function getCardReference()

src/Omnipay/Stripe/Message/AbstractRequest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,22 @@ public function setApiKey($value)
2828
return $this->setParameter('apiKey', $value);
2929
}
3030

31+
/**
32+
* @deprecated
33+
*/
34+
public function getCardToken()
35+
{
36+
return $this->getParameter('token');
37+
}
38+
39+
/**
40+
* @deprecated
41+
*/
42+
public function setCardToken($value)
43+
{
44+
return $this->setParameter('token', $value);
45+
}
46+
3147
abstract public function getEndpoint();
3248

3349
public function getHttpMethod()

src/Omnipay/Stripe/Message/AuthorizeRequest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ public function getData()
2828

2929
if ($this->getCardReference()) {
3030
$data['customer'] = $this->getCardReference();
31-
} elseif ($this->getCardToken()) {
32-
$data['card'] = $this->getCardToken();
31+
} elseif ($this->getToken()) {
32+
$data['card'] = $this->getToken();
3333
} elseif ($this->getCard()) {
3434
$data['card'] = $this->getCardData();
3535
} else {
36-
// one of cardReference, cardToken, or card is required
36+
// one of cardReference, token, or card is required
3737
$this->validate('card');
3838
}
3939

src/Omnipay/Stripe/Message/CreateCardRequest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ public function getData()
2121
$data = array();
2222
$data['description'] = $this->getDescription();
2323

24-
if ($this->getCardToken()) {
25-
$data['card'] = $this->getCardToken();
24+
if ($this->getToken()) {
25+
$data['card'] = $this->getToken();
2626
} elseif ($this->getCard()) {
2727
$data['card'] = $this->getCardData();
2828
$data['email'] = $this->getCard()->getEmail();
2929
} else {
30-
// one of cardToken, or card is required
30+
// one of token or card is required
3131
$this->validate('card');
3232
}
3333

src/Omnipay/Stripe/Message/UpdateCardRequest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public function getData()
2121
$data = array();
2222
$data['description'] = $this->getDescription();
2323

24-
if ($this->getCardToken()) {
25-
$data['card'] = $this->getCardToken();
24+
if ($this->getToken()) {
25+
$data['card'] = $this->getToken();
2626
} elseif ($this->getCard()) {
2727
$data['card'] = $this->getCardData();
2828
$data['email'] = $this->getCard()->getEmail();

tests/Omnipay/Common/Message/AbstractRequestTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ public function testSetCardWithArray()
4747
$this->assertSame('1234', $card->getNumber());
4848
}
4949

50-
public function testCardToken()
50+
public function testToken()
5151
{
52-
$this->assertSame($this->request, $this->request->setCardToken('12345'));
53-
$this->assertSame('12345', $this->request->getCardToken());
52+
$this->assertSame($this->request, $this->request->setToken('12345'));
53+
$this->assertSame('12345', $this->request->getToken());
5454
}
5555

5656
public function testCardReference()

tests/Omnipay/Stripe/Message/AuthorizeRequestTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ public function testDataWithCardReference()
5151
$this->assertSame('xyz', $data['customer']);
5252
}
5353

54-
public function testDataWithCardToken()
54+
public function testDataWithToken()
5555
{
56-
$this->request->setCardToken('xyz');
56+
$this->request->setToken('xyz');
5757
$data = $this->request->getData();
5858

5959
$this->assertSame('xyz', $data['card']);

tests/Omnipay/Stripe/Message/CreateCardRequestTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ public function testCard()
3636
$this->request->getData();
3737
}
3838

39-
public function testDataWithCardToken()
39+
public function testDataWithToken()
4040
{
41-
$this->request->setCardToken('xyz');
41+
$this->request->setToken('xyz');
4242
$data = $this->request->getData();
4343

4444
$this->assertSame('xyz', $data['card']);

tests/Omnipay/Stripe/Message/UpdateCardRequestTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ public function testEndpoint()
2626
$this->assertSame('https://api.stripe.com/v1/customers/cus_1MZSEtqSghKx99', $this->request->getEndpoint());
2727
}
2828

29-
public function testDataWithCardToken()
29+
public function testDataWithToken()
3030
{
31-
$this->request->setCardToken('xyz');
31+
$this->request->setToken('xyz');
3232
$data = $this->request->getData();
3333

3434
$this->assertSame('xyz', $data['card']);

0 commit comments

Comments
 (0)