Skip to content

Commit d1d2edd

Browse files
committed
Fix tests. Update CustomerResponse to use new 'sources' field.
1 parent 49f2b11 commit d1d2edd

File tree

9 files changed

+343
-18
lines changed

9 files changed

+343
-18
lines changed

src/Api/Accounts.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Stripe\Api;
99

10+
use Stripe\Request\Accounts\CreateAccountRequest;
1011
use Stripe\Response\Accounts\AccountResponse;
1112

1213
class Accounts extends AbstractApi
@@ -21,4 +22,22 @@ public function getAccount()
2122
{
2223
return $this->client->get('account', self::ACCOUNT_RESPONSE_CLASS);
2324
}
25+
26+
/**
27+
* @param CreateAccountRequest $request
28+
* @return AccountResponse
29+
* @link https://stripe.com/docs/api#create_account
30+
*/
31+
public function createAccount(CreateAccountRequest $request)
32+
{
33+
return $this->client->post('accounts', self::ACCOUNT_RESPONSE_CLASS, $request);
34+
}
35+
36+
/**
37+
* @return CreateAccountRequest
38+
*/
39+
public function createAccountRequest()
40+
{
41+
return new CreateAccountRequest();
42+
}
2443
}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<?php
2+
/**
3+
* User: Joe Linn
4+
* Date: 5/31/2015
5+
* Time: 1:08 PM
6+
*/
7+
8+
namespace Stripe\Request\Accounts;
9+
10+
11+
class BankAccountRequest
12+
{
13+
/**
14+
* @var string
15+
*/
16+
protected $country;
17+
18+
/**
19+
* @var string
20+
*/
21+
protected $currency;
22+
23+
/**
24+
* @var string
25+
*/
26+
protected $routingNumber;
27+
28+
/**
29+
* @var string
30+
*/
31+
protected $accountNumber;
32+
33+
/**
34+
* @return string
35+
*/
36+
public function getCountry()
37+
{
38+
return $this->country;
39+
}
40+
41+
/**
42+
* @param string $country
43+
* @return $this
44+
*/
45+
public function setCountry($country)
46+
{
47+
$this->country = $country;
48+
return $this;
49+
}
50+
51+
/**
52+
* @return string
53+
*/
54+
public function getCurrency()
55+
{
56+
return $this->currency;
57+
}
58+
59+
/**
60+
* @param string $currency
61+
* @return $this
62+
*/
63+
public function setCurrency($currency)
64+
{
65+
$this->currency = $currency;
66+
return $this;
67+
}
68+
69+
/**
70+
* @return string
71+
*/
72+
public function getRoutingNumber()
73+
{
74+
return $this->routingNumber;
75+
}
76+
77+
/**
78+
* @param string $routingNumber
79+
* @return $this
80+
*/
81+
public function setRoutingNumber($routingNumber)
82+
{
83+
$this->routingNumber = $routingNumber;
84+
return $this;
85+
}
86+
87+
/**
88+
* @return string
89+
*/
90+
public function getAccountNumber()
91+
{
92+
return $this->accountNumber;
93+
}
94+
95+
/**
96+
* @param string $accountNumber
97+
* @return $this
98+
*/
99+
public function setAccountNumber($accountNumber)
100+
{
101+
$this->accountNumber = $accountNumber;
102+
return $this;
103+
}
104+
}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<?php
2+
/**
3+
* User: Joe Linn
4+
* Date: 5/30/2015
5+
* Time: 1:08 PM
6+
*/
7+
8+
namespace Stripe\Request\Accounts;
9+
10+
11+
class CreateAccountRequest
12+
{
13+
/**
14+
* @var bool
15+
*/
16+
protected $managed;
17+
18+
/**
19+
* @var string
20+
*/
21+
protected $country;
22+
23+
/**
24+
* @var string
25+
*/
26+
protected $email;
27+
28+
/**
29+
* @var BankAccountRequest
30+
*/
31+
protected $bankAccount;
32+
33+
/**
34+
* @return boolean
35+
*/
36+
public function isManaged()
37+
{
38+
return $this->managed;
39+
}
40+
41+
/**
42+
* @param boolean $managed
43+
* @return $this
44+
*/
45+
public function setManaged($managed)
46+
{
47+
$this->managed = $managed;
48+
return $this;
49+
}
50+
51+
/**
52+
* @return string
53+
*/
54+
public function getCountry()
55+
{
56+
return $this->country;
57+
}
58+
59+
/**
60+
* @param string $country
61+
* @return $this
62+
*/
63+
public function setCountry($country)
64+
{
65+
$this->country = $country;
66+
return $this;
67+
}
68+
69+
/**
70+
* @return string
71+
*/
72+
public function getEmail()
73+
{
74+
return $this->email;
75+
}
76+
77+
/**
78+
* @param string $email
79+
* @return $this
80+
*/
81+
public function setEmail($email)
82+
{
83+
$this->email = $email;
84+
return $this;
85+
}
86+
87+
/**
88+
* @return BankAccountRequest
89+
*/
90+
public function getBankAccount()
91+
{
92+
return $this->bankAccount;
93+
}
94+
95+
/**
96+
* @param BankAccountRequest $bankAccount
97+
* @return $this
98+
*/
99+
public function setBankAccount($bankAccount)
100+
{
101+
$this->bankAccount = $bankAccount;
102+
return $this;
103+
}
104+
}

src/Request/Transfers/CreateTransferRequest.php

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ class CreateTransferRequest
2525
*/
2626
protected $recipient;
2727

28+
/**
29+
* @var string
30+
*/
31+
protected $destination;
32+
2833
/**
2934
* @var string
3035
*/
@@ -43,12 +48,12 @@ class CreateTransferRequest
4348
/**
4449
* @param int $amount
4550
* @param string $currency
46-
* @param string $recipient
51+
* @param string $destination
4752
*/
48-
public function __construct($amount, $currency, $recipient)
53+
public function __construct($amount, $currency, $destination)
4954
{
5055
$this->setAmount($amount)->setCurrency($currency);
51-
$this->setRecipient($recipient);
56+
$this->setDestination($destination);
5257
}
5358

5459
/**
@@ -124,6 +129,7 @@ public function setMetadata($metadata)
124129
}
125130

126131
/**
132+
* @deprecated use destination
127133
* @return string
128134
*/
129135
public function getRecipient()
@@ -132,6 +138,7 @@ public function getRecipient()
132138
}
133139

134140
/**
141+
* @deprecated use destination
135142
* @param string $recipient
136143
* @return $this
137144
*/
@@ -158,4 +165,22 @@ public function setStatementDescription($statementDescription)
158165
$this->statementDescription = $statementDescription;
159166
return $this;
160167
}
168+
169+
/**
170+
* @return string
171+
*/
172+
public function getDestination()
173+
{
174+
return $this->destination;
175+
}
176+
177+
/**
178+
* @param string $destination
179+
* @return $this
180+
*/
181+
public function setDestination($destination)
182+
{
183+
$this->destination = $destination;
184+
return $this;
185+
}
161186
}

src/Response/Customers/CustomerResponse.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class CustomerResponse
3737
* @Type("Stripe\Response\Cards\ListCardsResponse")
3838
* @var ListCardsResponse
3939
*/
40-
protected $cards;
40+
protected $sources;
4141

4242
/**
4343
* @Type("integer")
@@ -61,7 +61,7 @@ class CustomerResponse
6161
* @Type("string")
6262
* @var string
6363
*/
64-
protected $defaultCard;
64+
protected $defaultSource;
6565

6666
/**
6767
* @Type("boolean")
@@ -120,18 +120,18 @@ public function setAccountBalance($accountBalance)
120120
/**
121121
* @return \Stripe\Response\Cards\ListCardsResponse
122122
*/
123-
public function getCards()
123+
public function getSources()
124124
{
125-
return $this->cards;
125+
return $this->sources;
126126
}
127127

128128
/**
129-
* @param \Stripe\Response\Cards\ListCardsResponse $cards
129+
* @param \Stripe\Response\Cards\ListCardsResponse $sources
130130
* @return $this
131131
*/
132-
public function setCards($cards)
132+
public function setSources($sources)
133133
{
134-
$this->cards = $cards;
134+
$this->sources = $sources;
135135
return $this;
136136
}
137137

@@ -174,18 +174,18 @@ public function setCurrency($currency)
174174
/**
175175
* @return string
176176
*/
177-
public function getDefaultCard()
177+
public function getDefaultSource()
178178
{
179-
return $this->defaultCard;
179+
return $this->defaultSource;
180180
}
181181

182182
/**
183-
* @param string $defaultCard
183+
* @param string $defaultSource
184184
* @return $this
185185
*/
186-
public function setDefaultCard($defaultCard)
186+
public function setDefaultSource($defaultSource)
187187
{
188-
$this->defaultCard = $defaultCard;
188+
$this->defaultSource = $defaultSource;
189189
return $this;
190190
}
191191

tests/Api/AccountsTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,13 @@ public function testGetAccount()
3434
$account = $this->accounts->getAccount();
3535
$this->assertInstanceOf(Accounts::ACCOUNT_RESPONSE_CLASS, $account);
3636
}
37+
38+
public function testCreateAccount()
39+
{
40+
$request = $this->accounts->createAccountRequest();
41+
$request->setEmail("bob".$this->randomString()."@loblaw.com");
42+
$account = $this->accounts->createAccount($request);
43+
44+
$this->assertInstanceOf(Accounts::ACCOUNT_RESPONSE_CLASS, $account);
45+
}
3746
}

0 commit comments

Comments
 (0)