Skip to content

Commit

Permalink
Fix tests. Update CustomerResponse to use new 'sources' field.
Browse files Browse the repository at this point in the history
  • Loading branch information
jlinn committed May 31, 2015
1 parent 49f2b11 commit d1d2edd
Show file tree
Hide file tree
Showing 9 changed files with 343 additions and 18 deletions.
19 changes: 19 additions & 0 deletions src/Api/Accounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace Stripe\Api;

use Stripe\Request\Accounts\CreateAccountRequest;
use Stripe\Response\Accounts\AccountResponse;

class Accounts extends AbstractApi
Expand All @@ -21,4 +22,22 @@ public function getAccount()
{
return $this->client->get('account', self::ACCOUNT_RESPONSE_CLASS);
}

/**
* @param CreateAccountRequest $request
* @return AccountResponse
* @link https://stripe.com/docs/api#create_account
*/
public function createAccount(CreateAccountRequest $request)
{
return $this->client->post('accounts', self::ACCOUNT_RESPONSE_CLASS, $request);
}

/**
* @return CreateAccountRequest
*/
public function createAccountRequest()
{
return new CreateAccountRequest();
}
}
104 changes: 104 additions & 0 deletions src/Request/Accounts/BankAccountRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?php
/**
* User: Joe Linn
* Date: 5/31/2015
* Time: 1:08 PM
*/

namespace Stripe\Request\Accounts;


class BankAccountRequest
{
/**
* @var string
*/
protected $country;

/**
* @var string
*/
protected $currency;

/**
* @var string
*/
protected $routingNumber;

/**
* @var string
*/
protected $accountNumber;

/**
* @return string
*/
public function getCountry()
{
return $this->country;
}

/**
* @param string $country
* @return $this
*/
public function setCountry($country)
{
$this->country = $country;
return $this;
}

/**
* @return string
*/
public function getCurrency()
{
return $this->currency;
}

/**
* @param string $currency
* @return $this
*/
public function setCurrency($currency)
{
$this->currency = $currency;
return $this;
}

/**
* @return string
*/
public function getRoutingNumber()
{
return $this->routingNumber;
}

/**
* @param string $routingNumber
* @return $this
*/
public function setRoutingNumber($routingNumber)
{
$this->routingNumber = $routingNumber;
return $this;
}

/**
* @return string
*/
public function getAccountNumber()
{
return $this->accountNumber;
}

/**
* @param string $accountNumber
* @return $this
*/
public function setAccountNumber($accountNumber)
{
$this->accountNumber = $accountNumber;
return $this;
}
}
104 changes: 104 additions & 0 deletions src/Request/Accounts/CreateAccountRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?php
/**
* User: Joe Linn
* Date: 5/30/2015
* Time: 1:08 PM
*/

namespace Stripe\Request\Accounts;


class CreateAccountRequest
{
/**
* @var bool
*/
protected $managed;

/**
* @var string
*/
protected $country;

/**
* @var string
*/
protected $email;

/**
* @var BankAccountRequest
*/
protected $bankAccount;

/**
* @return boolean
*/
public function isManaged()
{
return $this->managed;
}

/**
* @param boolean $managed
* @return $this
*/
public function setManaged($managed)
{
$this->managed = $managed;
return $this;
}

/**
* @return string
*/
public function getCountry()
{
return $this->country;
}

/**
* @param string $country
* @return $this
*/
public function setCountry($country)
{
$this->country = $country;
return $this;
}

/**
* @return string
*/
public function getEmail()
{
return $this->email;
}

/**
* @param string $email
* @return $this
*/
public function setEmail($email)
{
$this->email = $email;
return $this;
}

/**
* @return BankAccountRequest
*/
public function getBankAccount()
{
return $this->bankAccount;
}

/**
* @param BankAccountRequest $bankAccount
* @return $this
*/
public function setBankAccount($bankAccount)
{
$this->bankAccount = $bankAccount;
return $this;
}
}
31 changes: 28 additions & 3 deletions src/Request/Transfers/CreateTransferRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ class CreateTransferRequest
*/
protected $recipient;

/**
* @var string
*/
protected $destination;

/**
* @var string
*/
Expand All @@ -43,12 +48,12 @@ class CreateTransferRequest
/**
* @param int $amount
* @param string $currency
* @param string $recipient
* @param string $destination
*/
public function __construct($amount, $currency, $recipient)
public function __construct($amount, $currency, $destination)
{
$this->setAmount($amount)->setCurrency($currency);
$this->setRecipient($recipient);
$this->setDestination($destination);
}

/**
Expand Down Expand Up @@ -124,6 +129,7 @@ public function setMetadata($metadata)
}

/**
* @deprecated use destination
* @return string
*/
public function getRecipient()
Expand All @@ -132,6 +138,7 @@ public function getRecipient()
}

/**
* @deprecated use destination
* @param string $recipient
* @return $this
*/
Expand All @@ -158,4 +165,22 @@ public function setStatementDescription($statementDescription)
$this->statementDescription = $statementDescription;
return $this;
}

/**
* @return string
*/
public function getDestination()
{
return $this->destination;
}

/**
* @param string $destination
* @return $this
*/
public function setDestination($destination)
{
$this->destination = $destination;
return $this;
}
}
24 changes: 12 additions & 12 deletions src/Response/Customers/CustomerResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class CustomerResponse
* @Type("Stripe\Response\Cards\ListCardsResponse")
* @var ListCardsResponse
*/
protected $cards;
protected $sources;

/**
* @Type("integer")
Expand All @@ -61,7 +61,7 @@ class CustomerResponse
* @Type("string")
* @var string
*/
protected $defaultCard;
protected $defaultSource;

/**
* @Type("boolean")
Expand Down Expand Up @@ -120,18 +120,18 @@ public function setAccountBalance($accountBalance)
/**
* @return \Stripe\Response\Cards\ListCardsResponse
*/
public function getCards()
public function getSources()
{
return $this->cards;
return $this->sources;
}

/**
* @param \Stripe\Response\Cards\ListCardsResponse $cards
* @param \Stripe\Response\Cards\ListCardsResponse $sources
* @return $this
*/
public function setCards($cards)
public function setSources($sources)
{
$this->cards = $cards;
$this->sources = $sources;
return $this;
}

Expand Down Expand Up @@ -174,18 +174,18 @@ public function setCurrency($currency)
/**
* @return string
*/
public function getDefaultCard()
public function getDefaultSource()
{
return $this->defaultCard;
return $this->defaultSource;
}

/**
* @param string $defaultCard
* @param string $defaultSource
* @return $this
*/
public function setDefaultCard($defaultCard)
public function setDefaultSource($defaultSource)
{
$this->defaultCard = $defaultCard;
$this->defaultSource = $defaultSource;
return $this;
}

Expand Down
9 changes: 9 additions & 0 deletions tests/Api/AccountsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,13 @@ public function testGetAccount()
$account = $this->accounts->getAccount();
$this->assertInstanceOf(Accounts::ACCOUNT_RESPONSE_CLASS, $account);
}

public function testCreateAccount()
{
$request = $this->accounts->createAccountRequest();
$request->setEmail("bob".$this->randomString()."@loblaw.com");
$account = $this->accounts->createAccount($request);

$this->assertInstanceOf(Accounts::ACCOUNT_RESPONSE_CLASS, $account);
}
}
Loading

0 comments on commit d1d2edd

Please sign in to comment.