diff --git a/README.md b/README.md index c2aa24c..92b93f3 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,21 @@ use Stripe\Stripe; $stripe = new Stripe("your_api_key"); ``` +#### Charges calls +```php +// create a charge +$request = $stripe->charges->createChargeRequest(350, "usd")->setCustomer($customer->getId()); +$stripe->charges->createCharge($request); + +//Without a Customer +$card Request = new CreateCardRequest($number, $expMonth, $expYear, $cvc); +$request = $stripe->charges->createChargeRequest(350, "usd")->setCard($card); +$stripe->charges->createCharge($request); + +// retrieve a charge +$charge = $stripe->charges->getCharge("charge_id"); +``` + #### Customers calls ```php use Stripe\Request\Cards\CreateCardRequest; @@ -37,15 +52,5 @@ $customerId = $customer->getId(); $customer = $stripe->customers()->getCustomer("customer_id"); ``` -#### Charges calls -```php -// create a charge -$request = $stripe->charges->createChargeRequest(350, "usd")->setCustomer($customer->getId()); -$stripe->charges->createCharge($request); - -// retrieve a charge -$charge = $stripe->charges->getCharge("charge_id"); -``` - ## Development Status Currently, all Stripe API calls which do not require [Stripe Connect](https://stripe.com/docs/connect) have been implemented. Documentation and Stripe Connect calls are next on the to-do list. diff --git a/docs/api/accounts.md b/docs/api/accounts.md index 3a6b1cd..78eada7 100644 --- a/docs/api/accounts.md +++ b/docs/api/accounts.md @@ -1,5 +1,36 @@ # [Accounts](https://github.com/jlinn/stripe-api-php/blob/master/src/Api/Accounts.php) -## Retrieve account data +## Retrieve default account data ```php $account = $stripe->accounts->getAccount(); +``` + +## Create an account +The `createAccount()` method takes a [`CreateAccountRequest`](https://github.com/jlinn/stripe-api-php/blob/master/src/Request/Accounts/CreateAccountRequest.php) object as its only parameter. This parameter is optional. +```php +$newAccount = new CreateAccountRequest(); +$newAccount->setManaged(true); +$request = $stripe->accounts->createAccount($newAccount); +``` + +## Retrieve a connected account +```php +$customer = $stripe->accounts->getConnectedAccount("account_id"); +``` + +## Update an account +The `UpdateAccount()` method takes an [`UpdateAccountRequest`](https://github.com/jlinn/stripe-api-php/blob/master/src/Request/Accounts/UpdateAccountRequest.php) object as its second parameter. +```php +$newAccount = new UpdateAccountRequest(); +$newAccount->setManaged(false); +$request = $stripe->accounts->updateAccount($accountId, $newAccount); +``` + +## Delete an account +```php +$stripe->accounts->deleteAccount("$accountId"); +``` + +## List accounts +```php +$accounts = $stripe->accounts->listAccounts(); ``` \ No newline at end of file diff --git a/src/Api/Accounts.php b/src/Api/Accounts.php index 5c33c57..d58c488 100644 --- a/src/Api/Accounts.php +++ b/src/Api/Accounts.php @@ -8,13 +8,19 @@ namespace Stripe\Api; use Stripe\Request\Accounts\CreateAccountRequest; +use Stripe\Request\Accounts\UpdateAccountRequest; +use Stripe\Request\ListRequest; use Stripe\Response\Accounts\AccountResponse; +use Stripe\Response\Accounts\ListAccountsResponse; +use Stripe\Response\DeleteResponse; class Accounts extends AbstractApi { const ACCOUNT_RESPONSE_CLASS = 'Stripe\Response\Accounts\AccountResponse'; + const LIST_ACCOUNT_RESPONSE_CLASS = 'Stripe\Response\Accounts\ListAccountsResponse'; /** + * Retrieves default/main account * @return AccountResponse * @link https://stripe.com/docs/api/curl#retrieve_account */ @@ -33,6 +39,47 @@ public function createAccount(CreateAccountRequest $request) return $this->client->post('accounts', self::ACCOUNT_RESPONSE_CLASS, $request); } + /** + * @param string $accountId + * @return AccountResponse + * @link https://stripe.com/docs/api/curl#retrieve_account + */ + public function getConnectedAccount($accountId) + { + return $this->client->get($this->buildUrl($accountId), self::ACCOUNT_RESPONSE_CLASS); + } + + /** + * @param string $accountId + * @param UpdateAccountRequest $request + * @return AccountResponse + * @link https://stripe.com/docs/api/curl#update_account + */ + public function updateAccount($accountId, UpdateAccountRequest $request) + { + return $this->client->post($this->buildUrl($accountId), self::ACCOUNT_RESPONSE_CLASS, $request); + } + + /** + * @param string $accountId + * @return DeleteResponse + * @link https://stripe.com/docs/api/curl#delete_account + */ + public function deleteConnectedAccount($accountId) + { + return $this->client->delete($this->buildUrl($accountId), self::DELETE_RESPONSE_CLASS); + } + + /** + * @param ListRequest $request + * @return ListAccountsResponse + * @link https://stripe.com/docs/api/curl#list_accounts + */ + public function listConnectedAccounts(ListRequest $request = null) + { + return $this->client->get('accounts', self::LIST_ACCOUNT_RESPONSE_CLASS, null, $this->listRequestToParams($request)); + } + /** * @return CreateAccountRequest */ @@ -40,4 +87,13 @@ public function createAccountRequest() { return new CreateAccountRequest(); } + + /** + * @param string $customerId + * @return string + */ + protected function buildUrl($customerId) + { + return 'accounts/' . $customerId; + } } diff --git a/src/Request/Accounts/CreateAccountRequest.php b/src/Request/Accounts/CreateAccountRequest.php index 540fa06..72dad9c 100644 --- a/src/Request/Accounts/CreateAccountRequest.php +++ b/src/Request/Accounts/CreateAccountRequest.php @@ -8,6 +8,8 @@ namespace Stripe\Request\Accounts; +use Stripe\Request\LegalEntity\CreateLegalEntityRequest; + class CreateAccountRequest { /** @@ -27,9 +29,95 @@ class CreateAccountRequest /** * @var BankAccountRequest + * @deprecated Use external accounts instead of bank account. Changed in API. */ protected $bankAccount; + /** + * @var CreateExternalAccountRequest + */ + protected $externalAccount; + + /** + * @var CreateLegalEntityRequest + */ + protected $legalEntity; + + /** + * @var string + */ + protected $businessLogo; + + /** + * @var string + */ + protected $businessName; + + /** + * @var string + */ + protected $businessPrimaryColor; + + /** + * @var string + */ + protected $businessUrl; + + /** + * @var bool + */ + protected $debitNegativeBalances; + + /** + * @var CreateDeclineChargeRequest + */ + protected $declineChargeOn; + + /** + * @var string + */ + protected $defaultCurrency; + + /** + * @var array + */ + protected $metadata; + + /** + * @var string + */ + protected $productDescription; + + /** + * @var string + */ + protected $statementDescriptor; + + /** + * @var string + */ + protected $supportEmail; + + /** + * @var string + */ + protected $supportPhone; + + /** + * @var string + */ + protected $supportUrl; + + /** + * @var CreateTransferScheduleRequest + */ + protected $transferSchedule; + + /** + * @var CreateTOSAcceptance + */ + protected $tosAcceptance; + /** * @return boolean */ @@ -84,6 +172,313 @@ public function setEmail($email) return $this; } + /** + * @return CreateExternalAccountRequest + */ + public function getExternalAccount() + { + return $this->externalAccount; + } + + /** + * @param CreateExternalAccountRequest $externalAccount + * @return CreateAccountRequest + */ + public function setExternalAccount($externalAccount) + { + $this->externalAccount = $externalAccount; + return $this; + } + + /** + * @return CreateLegalEntityRequest + */ + public function getLegalEntity() + { + return $this->legalEntity; + } + + /** + * @param CreateLegalEntityRequest $legalEntity + * @return CreateAccountRequest + */ + public function setLegalEntity($legalEntity) + { + $this->legalEntity = $legalEntity; + return $this; + } + + /** + * @return CreateTOSAcceptance + */ + public function getTosAcceptance() + { + return $this->tosAcceptance; + } + + /** + * @param CreateTOSAcceptance $tosAcceptance + * @return CreateAccountRequest + */ + public function setTosAcceptance($tosAcceptance) + { + $this->tosAcceptance = $tosAcceptance; + return $this; + } + + /** + * @return string + */ + public function getBusinessLogo() + { + return $this->businessLogo; + } + + /** + * @param string $businessLogo + * @return CreateAccountRequest + * @deprecated Use external accounts instead of bank accounts. + */ + public function setBusinessLogo($businessLogo) + { + $this->businessLogo = $businessLogo; + return $this; + } + + /** + * @return string + */ + public function getBusinessName() + { + return $this->businessName; + } + + /** + * @param string $businessName + * @return CreateAccountRequest + */ + public function setBusinessName($businessName) + { + $this->businessName = $businessName; + return $this; + } + + /** + * @return string + */ + public function getBusinessPrimaryColor() + { + return $this->businessPrimaryColor; + } + + /** + * @param string $businessPrimaryColor + * @return CreateAccountRequest + */ + public function setBusinessPrimaryColor($businessPrimaryColor) + { + $this->businessPrimaryColor = $businessPrimaryColor; + return $this; + } + + /** + * @return string + */ + public function getBusinessUrl() + { + return $this->businessUrl; + } + + /** + * @param string $businessUrl + * @return CreateAccountRequest + */ + public function setBusinessUrl($businessUrl) + { + $this->businessUrl = $businessUrl; + return $this; + } + + /** + * @return boolean + */ + public function isDebitNegativeBalances() + { + return $this->debitNegativeBalances; + } + + /** + * @param boolean $debitNegativeBalances + * @return CreateAccountRequest + */ + public function setDebitNegativeBalances($debitNegativeBalances) + { + $this->debitNegativeBalances = $debitNegativeBalances; + return $this; + } + + /** + * @return CreateDeclineChargeRequest + */ + public function getDeclineChargeOn() + { + return $this->declineChargeOn; + } + + /** + * @param CreateDeclineChargeRequest $declineChargeOn + * @return CreateAccountRequest + */ + public function setDeclineChargeOn($declineChargeOn) + { + $this->declineChargeOn = $declineChargeOn; + return $this; + } + + /** + * @return string + */ + public function getDefaultCurrency() + { + return $this->defaultCurrency; + } + + /** + * @param string $defaultCurrency + * @return CreateAccountRequest + */ + public function setDefaultCurrency($defaultCurrency) + { + $this->defaultCurrency = $defaultCurrency; + return $this; + } + + /** + * @return array + */ + public function getMetadata() + { + return $this->metadata; + } + + /** + * @param array $metadata + * @return CreateAccountRequest + */ + public function setMetadata($metadata) + { + $this->metadata = $metadata; + return $this; + } + + /** + * @return string + */ + public function getProductDescription() + { + return $this->productDescription; + } + + /** + * @param string $productDescription + * @return CreateAccountRequest + */ + public function setProductDescription($productDescription) + { + $this->productDescription = $productDescription; + return $this; + } + + /** + * @return string + */ + public function getStatementDescriptor() + { + return $this->statementDescriptor; + } + + /** + * @param string $statementDescriptor + * @return CreateAccountRequest + */ + public function setStatementDescriptor($statementDescriptor) + { + $this->statementDescriptor = $statementDescriptor; + return $this; + } + + /** + * @return string + */ + public function getSupportEmail() + { + return $this->supportEmail; + } + + /** + * @param string $supportEmail + * @return CreateAccountRequest + */ + public function setSupportEmail($supportEmail) + { + $this->supportEmail = $supportEmail; + return $this; + } + + /** + * @return string + */ + public function getSupportPhone() + { + return $this->supportPhone; + } + + /** + * @param string $supportPhone + * @return CreateAccountRequest + */ + public function setSupportPhone($supportPhone) + { + $this->supportPhone = $supportPhone; + return $this; + } + + /** + * @return string + */ + public function getSupportUrl() + { + return $this->supportUrl; + } + + /** + * @param string $supportUrl + * @return CreateAccountRequest + */ + public function setSupportUrl($supportUrl) + { + $this->supportUrl = $supportUrl; + return $this; + } + + /** + * @return CreateTransferScheduleRequest + */ + public function getTransferSchedule() + { + return $this->transferSchedule; + } + + /** + * @param CreateTransferScheduleRequest $transferSchedule + * @return CreateAccountRequest + */ + public function setTransferSchedule($transferSchedule) + { + $this->transferSchedule = $transferSchedule; + return $this; + } + /** * @return BankAccountRequest */ @@ -94,11 +489,13 @@ public function getBankAccount() /** * @param BankAccountRequest $bankAccount - * @return $this + * @return CreateAccountRequest + * @deprecated API calls are being changed to external accounts */ public function setBankAccount($bankAccount) { $this->bankAccount = $bankAccount; return $this; } + } \ No newline at end of file diff --git a/src/Request/Accounts/CreateDeclineChargeRequest.php b/src/Request/Accounts/CreateDeclineChargeRequest.php new file mode 100644 index 0000000..44d1bce --- /dev/null +++ b/src/Request/Accounts/CreateDeclineChargeRequest.php @@ -0,0 +1,63 @@ +avsFailure = $avsFailure; + $this->cvcFailure = $cvcFailure; + } + + /** + * @return boolean + */ + public function isAvsFailure() + { + return $this->avsFailure; + } + + /** + * @param boolean $avsFailure + * @return CreateDeclineChargeRequest + */ + public function setAvsFailure($avsFailure) + { + $this->avsFailure = $avsFailure; + return $this; + } + + /** + * @return boolean + */ + public function isCvcFailure() + { + return $this->cvcFailure; + } + + /** + * @param boolean $cvcFailure + * @return CreateDeclineChargeRequest + */ + public function setCvcFailure($cvcFailure) + { + $this->cvcFailure = $cvcFailure; + return $this; + } + + +} \ No newline at end of file diff --git a/src/Request/Accounts/CreateExternalAccountRequest.php b/src/Request/Accounts/CreateExternalAccountRequest.php new file mode 100644 index 0000000..fb2f6b8 --- /dev/null +++ b/src/Request/Accounts/CreateExternalAccountRequest.php @@ -0,0 +1,184 @@ +accountNumber = $accountNumber; + $this->country = $country; + $this->currency = $currency; + $this->object = $object; + } + + /** + * @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; + } + + /** + * @return string + */ + public function getObject() + { + return $this->object; + } + + /** + * @param string $object + * @return CreateExternalAccountRequest + */ + public function setObject($object) + { + $this->object = $object; + return $this; + } + + /** + * @return string + */ + public function getAccountHolderType() + { + return $this->accountHolderType; + } + + /** + * @param string $accountHolderType + * @return CreateExternalAccountRequest + */ + public function setAccountHolderType($accountHolderType) + { + $this->accountHolderType = $accountHolderType; + return $this; + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @param string $name + * @return CreateExternalAccountRequest + */ + public function setName($name) + { + $this->name = $name; + return $this; + } + +} \ No newline at end of file diff --git a/src/Request/Accounts/CreateTOSAcceptance.php b/src/Request/Accounts/CreateTOSAcceptance.php new file mode 100644 index 0000000..bbb7edf --- /dev/null +++ b/src/Request/Accounts/CreateTOSAcceptance.php @@ -0,0 +1,79 @@ +date; + } + + /** + * @param DateTime $date + * @return CreateTOSAcceptance + */ + public function setDate(DateTime $date) + { + $this->date = $date->getTimestamp(); + return $this; + } + + /** + * @return string + */ + public function getIp() + { + return $this->ip; + } + + /** + * @param string $ip + * @return CreateTOSAcceptance + */ + public function setIp($ip) + { + $this->ip = $ip; + return $this; + } + + /** + * @return string + */ + public function getUserAgent() + { + return $this->userAgent; + } + + /** + * @param string $userAgent + * @return CreateTOSAcceptance + */ + public function setUserAgent($userAgent) + { + $this->userAgent = $userAgent; + return $this; + } + +} \ No newline at end of file diff --git a/src/Request/Accounts/CreateTransferScheduleRequest.php b/src/Request/Accounts/CreateTransferScheduleRequest.php new file mode 100644 index 0000000..8cb0f5c --- /dev/null +++ b/src/Request/Accounts/CreateTransferScheduleRequest.php @@ -0,0 +1,102 @@ +delayDays; + } + + /** + * @param int $delayDays + * @return CreateTransferScheduleRequest + */ + public function setDelayDays($delayDays) + { + $this->delayDays = $delayDays; + return $this; + } + + /** + * @return string + */ + public function getInterval() + { + return $this->interval; + } + + /** + * @param string $interval + * @return CreateTransferScheduleRequest + */ + public function setInterval($interval) + { + $this->interval = $interval; + return $this; + } + + /** + * @return int + */ + public function getMonthlyAnchor() + { + return $this->monthlyAnchor; + } + + /** + * @param int $monthlyAnchor + * @return CreateTransferScheduleRequest + */ + public function setMonthlyAnchor($monthlyAnchor) + { + $this->monthlyAnchor = $monthlyAnchor; + return $this; + } + + /** + * @return string + */ + public function getWeeklyAnchor() + { + return $this->weeklyAnchor; + } + + /** + * @param string $weeklyAnchor + * @return CreateTransferScheduleRequest + */ + public function setWeeklyAnchor($weeklyAnchor) + { + $this->weeklyAnchor = $weeklyAnchor; + return $this; + } + +} \ No newline at end of file diff --git a/src/Request/Accounts/UpdateAccountRequest.php b/src/Request/Accounts/UpdateAccountRequest.php new file mode 100644 index 0000000..e8e7d65 --- /dev/null +++ b/src/Request/Accounts/UpdateAccountRequest.php @@ -0,0 +1,13 @@ +city; + } + + /** + * @param string $city + * @return CreateAddressRequest + */ + public function setCity($city) + { + $this->city = $city; + return $this; + } + + /** + * @return string + */ + public function getCountry() + { + return $this->country; + } + + /** + * @param string $country + * @return CreateAddressRequest + */ + public function setCountry($country) + { + $this->country = $country; + return $this; + } + + /** + * @return string + */ + public function getLine1() + { + return $this->line1; + } + + /** + * @param string $line1 + * @return CreateAddressRequest + */ + public function setLine1($line1) + { + $this->line1 = $line1; + return $this; + } + + /** + * @return string + */ + public function getLine2() + { + return $this->line2; + } + + /** + * @param string $line2 + * @return CreateAddressRequest + */ + public function setLine2($line2) + { + $this->line2 = $line2; + return $this; + } + + /** + * @return string + */ + public function getPostalCode() + { + return $this->postalCode; + } + + /** + * @param string $postalCode + * @return CreateAddressRequest + */ + public function setPostalCode($postalCode) + { + $this->postalCode = $postalCode; + return $this; + } + + /** + * @return string + */ + public function getState() + { + return $this->state; + } + + /** + * @param string $state + * @return CreateAddressRequest + */ + public function setState($state) + { + $this->state = $state; + return $this; + } + + + +} \ No newline at end of file diff --git a/src/Request/LegalEntity/CreateDOBRequest.php b/src/Request/LegalEntity/CreateDOBRequest.php new file mode 100644 index 0000000..4eed993 --- /dev/null +++ b/src/Request/LegalEntity/CreateDOBRequest.php @@ -0,0 +1,87 @@ +day = $dob->format('j'); + $this->month = $dob->format('n'); + $this->year = $dob->format('Y'); + } + + /** + * @return int + */ + public function getDay() + { + return $this->day; + } + + /** + * @param int $day + * @return CreateDOBRequest + */ + public function setDay($day) + { + $this->day = $day; + return $this; + } + + /** + * @return int + */ + public function getMonth() + { + return $this->month; + } + + /** + * @param int $month + * @return CreateDOBRequest + */ + public function setMonth($month) + { + $this->month = $month; + return $this; + } + + /** + * @return int + */ + public function getYear() + { + return $this->year; + } + + /** + * @param int $year + * @return CreateDOBRequest + */ + public function setYear($year) + { + $this->year = $year; + return $this; + } + +} \ No newline at end of file diff --git a/src/Request/LegalEntity/CreateLegalEntityRequest.php b/src/Request/LegalEntity/CreateLegalEntityRequest.php new file mode 100644 index 0000000..715e3f0 --- /dev/null +++ b/src/Request/LegalEntity/CreateLegalEntityRequest.php @@ -0,0 +1,263 @@ +additionalOwners; + } + + /** + * @param array $additionalOwners + * @return CreateLegalEntityRequest + */ + public function setAdditionalOwners($additionalOwners) + { + $this->additionalOwners = $additionalOwners; + return $this; + } + + /** + * @return string + */ + public function getAddress() + { + return $this->address; + } + + /** + * @param string $address + * @return CreateLegalEntityRequest + */ + public function setAddress($address) + { + $this->address = $address; + return $this; + } + + /** + * @return string + */ + public function getBusinessName() + { + return $this->businessName; + } + + /** + * @param string $businessName + * @return CreateLegalEntityRequest + */ + public function setBusinessName($businessName) + { + $this->businessName = $businessName; + return $this; + } + + /** + * @return CreateDOBRequest + */ + public function getDob() + { + return $this->dob; + } + + /** + * @param CreateDOBRequest $dob + * @return CreateLegalEntityRequest + */ + public function setDob($dob) + { + $this->dob = $dob; + return $this; + } + + /** + * @return string + */ + public function getFirstName() + { + return $this->firstName; + } + + /** + * @param string $firstName + * @return CreateLegalEntityRequest + */ + public function setFirstName($firstName) + { + $this->firstName = $firstName; + return $this; + } + + /** + * @return string + */ + public function getLastName() + { + return $this->lastName; + } + + /** + * @param string $lastName + * @return CreateLegalEntityRequest + */ + public function setLastName($lastName) + { + $this->lastName = $lastName; + return $this; + } + + /** + * @return CreateAddressRequest + */ + public function getPersonalAddress() + { + return $this->personalAddress; + } + + /** + * @param CreateAddressRequest $personalAddress + * @return CreateLegalEntityRequest + */ + public function setPersonalAddress($personalAddress) + { + $this->personalAddress = $personalAddress; + return $this; + } + + /** + * @return string + */ + public function getPersonalIdNumberProvided() + { + return $this->personalIdNumberProvided; + } + + /** + * @param string $personalIdNumberProvided + * @return CreateLegalEntityRequest + */ + public function setPersonalIdNumberProvided($personalIdNumberProvided) + { + $this->personalIdNumberProvided = $personalIdNumberProvided; + return $this; + } + + /** + * @return string + */ + public function getSsnLast4Provided() + { + return $this->ssnLast4Provided; + } + + /** + * @param string $ssnLast4Provided + * @return CreateLegalEntityRequest + */ + public function setSsnLast4Provided($ssnLast4Provided) + { + $this->ssnLast4Provided = $ssnLast4Provided; + return $this; + } + + /** + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * @param string $type + * @return CreateLegalEntityRequest + */ + public function setType($type) + { + $this->type = $type; + return $this; + } + + /** + * @return array + */ + public function getVerification() + { + return $this->verification; + } + + /** + * @param array $verification + * @return CreateLegalEntityRequest + */ + public function setVerification($verification) + { + $this->verification = $verification; + return $this; + } + +} \ No newline at end of file diff --git a/src/Response/Accounts/AccountResponse.php b/src/Response/Accounts/AccountResponse.php index 379c6de..140a75c 100644 --- a/src/Response/Accounts/AccountResponse.php +++ b/src/Response/Accounts/AccountResponse.php @@ -8,6 +8,7 @@ namespace Stripe\Response\Accounts; use JMS\Serializer\Annotation\Type; +use Stripe\Response\LegalEntity\LegalEntityResponse; class AccountResponse { @@ -51,13 +52,13 @@ class AccountResponse * @Type("boolean") * @var bool */ - protected $chargeEnabled; + protected $chargesEnabled; /** * @Type("boolean") * @var bool */ - protected $transferEnabled; + protected $transfersEnabled; /** * @Type("array") @@ -84,21 +85,111 @@ class AccountResponse protected $object; /** - * @param boolean $chargeEnabled + * @Type("Stripe\Response\LegalEntity\LegalEntityResponse") + * @var LegalEntityResponse + */ + protected $legalEntity; + + /** + * @Type("Stripe\Response\Accounts\ListExternalAccountsResponse") + * @var ListExternalAccountsResponse + */ + protected $externalAccounts; + + /** + * @Type("string") + * @var string + */ + protected $businessLogo; + + /** + * @Type("string") + * @var string + */ + protected $businessName; + + /** + * @Type("string") + * @var string + */ + protected $businessPrimaryColor; + + /** + * @Type("string") + * @var string + */ + protected $businessUrl; + + /** + * @Type("boolean") + * @var bool + */ + protected $debitNegativeBalances; + + /** + * @Type("Stripe\Response\Accounts\DeclineChargeOnResponse") + * @var DeclineChargeOnResponse + */ + protected $declineChargeOn; + + /** + * @Type("array") + * @var array + */ + protected $metadata; + + /** + * @Type("string") + * @var string + */ + protected $productDescription; + + /** + * @Type("string") + * @var string + */ + protected $supportEmail; + + /** + * @Type("string") + * @var string + */ + protected $supportPhone; + + /** + * @Type("string") + * @var string + */ + protected $supportUrl; + + /** + * @Type("Stripe\Response\Accounts\TransferScheduleResponse") + * @var TransferScheduleResponse + */ + protected $transferSchedule; + + /** + * @Type("boolean") + * @var bool + */ + protected $managed; + + /** + * @param boolean $chargesEnabled * @return $this */ - public function setChargeEnabled($chargeEnabled) + public function setChargesEnabled($chargesEnabled) { - $this->chargeEnabled = $chargeEnabled; + $this->chargesEnabled = $chargesEnabled; return $this; } /** * @return boolean */ - public function getChargeEnabled() + public function getChargesEnabled() { - return $this->chargeEnabled; + return $this->chargesEnabled; } /** @@ -282,20 +373,291 @@ public function getTimezone() } /** - * @param boolean $transferEnabled + * @param boolean $transfersEnabled * @return $this */ - public function setTransferEnabled($transferEnabled) + public function setTransferEnabled($transfersEnabled) { - $this->transferEnabled = $transferEnabled; + $this->transfersEnabled = $transfersEnabled; return $this; } /** * @return boolean */ - public function getTransferEnabled() + public function getTransfersEnabled() + { + return $this->transfersEnabled; + } + + /** + * @return LegalEntityResponse + */ + public function getLegalEntity() { - return $this->transferEnabled; + return $this->legalEntity; } + + /** + * @param LegalEntityResponse $legalEntity + * @return AccountResponse + */ + public function setLegalEntity($legalEntity) + { + $this->legalEntity = $legalEntity; + return $this; + } + + /** + * @return ListExternalAccountsResponse + */ + public function getExternalAccounts() + { + return $this->externalAccounts; + } + + /** + * @param ListExternalAccountsResponse $externalAccounts + * @return AccountResponse + */ + public function setExternalAccounts($externalAccounts) + { + $this->externalAccounts = $externalAccounts; + return $this; + } + + /** + * @return string + */ + public function getBusinessLogo() + { + return $this->businessLogo; + } + + /** + * @param string $businessLogo + * @return AccountResponse + */ + public function setBusinessLogo($businessLogo) + { + $this->businessLogo = $businessLogo; + return $this; + } + + /** + * @return string + */ + public function getBusinessName() + { + return $this->businessName; + } + + /** + * @param string $businessName + * @return AccountResponse + */ + public function setBusinessName($businessName) + { + $this->businessName = $businessName; + return $this; + } + + /** + * @return string + */ + public function getBusinessPrimaryColor() + { + return $this->businessPrimaryColor; + } + + /** + * @param string $businessPrimaryColor + * @return AccountResponse + */ + public function setBusinessPrimaryColor($businessPrimaryColor) + { + $this->businessPrimaryColor = $businessPrimaryColor; + return $this; + } + + /** + * @return string + */ + public function getBusinessUrl() + { + return $this->businessUrl; + } + + /** + * @param string $businessUrl + * @return AccountResponse + */ + public function setBusinessUrl($businessUrl) + { + $this->businessUrl = $businessUrl; + return $this; + } + + /** + * @return boolean + */ + public function isDebitNegativeBalances() + { + return $this->debitNegativeBalances; + } + + /** + * @param boolean $debitNegativeBalances + * @return AccountResponse + */ + public function setDebitNegativeBalances($debitNegativeBalances) + { + $this->debitNegativeBalances = $debitNegativeBalances; + return $this; + } + + /** + * @return DeclineChargeOnResponse + */ + public function getDeclineChargeOn() + { + return $this->declineChargeOn; + } + + /** + * @param DeclineChargeOnResponse $declineChargeOn + * @return AccountResponse + */ + public function setDeclineChargeOn($declineChargeOn) + { + $this->declineChargeOn = $declineChargeOn; + return $this; + } + + /** + * @return array + */ + public function getMetadata() + { + return $this->metadata; + } + + /** + * @param array $metadata + * @return AccountResponse + */ + public function setMetadata($metadata) + { + $this->metadata = $metadata; + return $this; + } + + /** + * @return string + */ + public function getProductDescription() + { + return $this->productDescription; + } + + /** + * @param string $productDescription + * @return AccountResponse + */ + public function setProductDescription($productDescription) + { + $this->productDescription = $productDescription; + return $this; + } + + /** + * @return string + */ + public function getSupportEmail() + { + return $this->supportEmail; + } + + /** + * @param string $supportEmail + * @return AccountResponse + */ + public function setSupportEmail($supportEmail) + { + $this->supportEmail = $supportEmail; + return $this; + } + + /** + * @return mixed + */ + public function getSupportPhone() + { + return $this->supportPhone; + } + + /** + * @param mixed $supportPhone + * @return AccountResponse + */ + public function setSupportPhone($supportPhone) + { + $this->supportPhone = $supportPhone; + return $this; + } + + /** + * @return string + */ + public function getSupportUrl() + { + return $this->supportUrl; + } + + /** + * @param string $supportUrl + * @return AccountResponse + */ + public function setSupportUrl($supportUrl) + { + $this->supportUrl = $supportUrl; + return $this; + } + + /** + * @return TransferScheduleResponse + */ + public function getTransferSchedule() + { + return $this->transferSchedule; + } + + /** + * @param TransferScheduleResponse $transferSchedule + * @return AccountResponse + */ + public function setTransferSchedule($transferSchedule) + { + $this->transferSchedule = $transferSchedule; + return $this; + } + + /** + * @return boolean + */ + public function isManaged() + { + return $this->managed; + } + + /** + * @param boolean $managed + * @return AccountResponse + */ + public function setManaged($managed) + { + $this->managed = $managed; + return $this; + } + } diff --git a/src/Response/Accounts/DeclineChargeOnResponse.php b/src/Response/Accounts/DeclineChargeOnResponse.php new file mode 100644 index 0000000..58a18e6 --- /dev/null +++ b/src/Response/Accounts/DeclineChargeOnResponse.php @@ -0,0 +1,59 @@ +avsFailure; + } + + /** + * @param boolean $avsFailure + * @return DeclineChargeOnResponse + */ + public function setAvsFailure($avsFailure) + { + $this->avsFailure = $avsFailure; + return $this; + } + + /** + * @return boolean + */ + public function isCvcFailure() + { + return $this->cvcFailure; + } + + /** + * @param boolean $cvcFailure + * @return DeclineChargeOnResponse + */ + public function setCvcFailure($cvcFailure) + { + $this->cvcFailure = $cvcFailure; + return $this; + } + +} \ No newline at end of file diff --git a/src/Response/Accounts/ExternalAccountResponse.php b/src/Response/Accounts/ExternalAccountResponse.php new file mode 100644 index 0000000..2a780f8 --- /dev/null +++ b/src/Response/Accounts/ExternalAccountResponse.php @@ -0,0 +1,317 @@ +object; + } + + /** + * @param string $object + * @return ExternalAccountResponse + */ + public function setObject($object) + { + $this->object = $object; + return $this; + } + + /** + * @return string + */ + public function getCountry() + { + return $this->country; + } + + /** + * @param string $country + * @return ExternalAccountResponse + */ + public function setCountry($country) + { + $this->country = $country; + return $this; + } + + /** + * @return string + */ + public function getCurrency() + { + return $this->currency; + } + + /** + * @param string $currency + * @return ExternalAccountResponse + */ + public function setCurrency($currency) + { + $this->currency = $currency; + return $this; + } + + /** + * @return string + */ + public function getRoutingNumber() + { + return $this->routingNumber; + } + + /** + * @param string $routingNumber + * @return ExternalAccountResponse + */ + public function setRoutingNumber($routingNumber) + { + $this->routingNumber = $routingNumber; + return $this; + } + + /** + * @return string + */ + public function getAccountNumber() + { + return $this->accountNumber; + } + + /** + * @param string $accountNumber + * @return ExternalAccountResponse + */ + public function setAccountNumber($accountNumber) + { + $this->accountNumber = $accountNumber; + return $this; + } + + /** + * @return string + */ + public function getAccountHolderType() + { + return $this->accountHolderType; + } + + /** + * @param string $accountHolderType + * @return ExternalAccountResponse + */ + public function setAccountHolderType($accountHolderType) + { + $this->accountHolderType = $accountHolderType; + return $this; + } + + /** + * @return string + */ + public function getBankName() + { + return $this->bankName; + } + + /** + * @param string $bankName + * @return ExternalAccountResponse + */ + public function setBankName($bankName) + { + $this->bankName = $bankName; + return $this; + } + + /** + * @return boolean + */ + public function isDefaultForCurrency() + { + return $this->defaultForCurrency; + } + + /** + * @param boolean $defaultForCurrency + * @return ExternalAccountResponse + */ + public function setDefaultForCurrency($defaultForCurrency) + { + $this->defaultForCurrency = $defaultForCurrency; + return $this; + } + + /** + * @return string + */ + public function getFingerprint() + { + return $this->fingerprint; + } + + /** + * @param string $fingerprint + * @return ExternalAccountResponse + */ + public function setFingerprint($fingerprint) + { + $this->fingerprint = $fingerprint; + return $this; + } + + /** + * @return string + */ + public function getLast4() + { + return $this->last4; + } + + /** + * @param string $last4 + * @return ExternalAccountResponse + */ + public function setLast4($last4) + { + $this->last4 = $last4; + return $this; + } + + /** + * @return array + */ + public function getMetadata() + { + return $this->metadata; + } + + /** + * @param array $metadata + * @return ExternalAccountResponse + */ + public function setMetadata($metadata) + { + $this->metadata = $metadata; + return $this; + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @param string $name + * @return ExternalAccountResponse + */ + public function setName($name) + { + $this->name = $name; + return $this; + } + + /** + * @return string + */ + public function getStatus() + { + return $this->status; + } + + /** + * @param string $status + * @return ExternalAccountResponse + */ + public function setStatus($status) + { + $this->status = $status; + return $this; + } + +} \ No newline at end of file diff --git a/src/Response/Accounts/ListAccountsResponse.php b/src/Response/Accounts/ListAccountsResponse.php new file mode 100644 index 0000000..ea0a29e --- /dev/null +++ b/src/Response/Accounts/ListAccountsResponse.php @@ -0,0 +1,34 @@ +") + * @var AccountResponse[] + */ + protected $data; + + /** + * @return AccountResponse[] + */ + public function getData() + { + return $this->data; + } + + /** + * @param AccountResponse[] $data + * @return $this + */ + public function setData($data) + { + $this->data = $data; + return $this; + } +} \ No newline at end of file diff --git a/src/Response/Accounts/ListExternalAccountsResponse.php b/src/Response/Accounts/ListExternalAccountsResponse.php new file mode 100644 index 0000000..78bd377 --- /dev/null +++ b/src/Response/Accounts/ListExternalAccountsResponse.php @@ -0,0 +1,33 @@ +") + * @var ExternalAccountResponse[] + */ + protected $data; + + /** + * @return ExternalAccountResponse[] + */ + public function getData() + { + return $this->data; + } + + /** + * @param ExternalAccountResponse[] $data + * @return $this + */ + public function setData($data) + { + $this->data = $data; + return $this; + } +} \ No newline at end of file diff --git a/src/Response/Accounts/TransferScheduleResponse.php b/src/Response/Accounts/TransferScheduleResponse.php new file mode 100644 index 0000000..f74fab1 --- /dev/null +++ b/src/Response/Accounts/TransferScheduleResponse.php @@ -0,0 +1,107 @@ +delayDays; + } + + /** + * @param int $delayDays + * @return TransferScheduleResponse + */ + public function setDelayDays($delayDays) + { + $this->delayDays = $delayDays; + return $this; + } + + /** + * @return string + */ + public function getInterval() + { + return $this->interval; + } + + /** + * @param string $interval + * @return TransferScheduleResponse + */ + public function setInterval($interval) + { + $this->interval = $interval; + return $this; + } + + /** + * @return int + */ + public function getMonthlyAnchor() + { + return $this->monthlyAnchor; + } + + /** + * @param int $monthlyAnchor + * @return TransferScheduleResponse + */ + public function setMonthlyAnchor($monthlyAnchor) + { + $this->monthlyAnchor = $monthlyAnchor; + return $this; + } + + /** + * @return string + */ + public function getWeeklyAnchor() + { + return $this->weeklyAnchor; + } + + /** + * @param string $weeklyAnchor + * @return TransferScheduleResponse + */ + public function setWeeklyAnchor($weeklyAnchor) + { + $this->weeklyAnchor = $weeklyAnchor; + return $this; + } + +} \ No newline at end of file diff --git a/src/Response/LegalEntity/AddressResponse.php b/src/Response/LegalEntity/AddressResponse.php new file mode 100644 index 0000000..31522bc --- /dev/null +++ b/src/Response/LegalEntity/AddressResponse.php @@ -0,0 +1,153 @@ +city; + } + + /** + * @param string $city + * @return AddressResponse + */ + public function setCity($city) + { + $this->city = $city; + return $this; + } + + /** + * @return string + */ + public function getCountry() + { + return $this->country; + } + + /** + * @param string $country + * @return AddressResponse + */ + public function setCountry($country) + { + $this->country = $country; + return $this; + } + + /** + * @return string + */ + public function getLine1() + { + return $this->line1; + } + + /** + * @param string $line1 + * @return AddressResponse + */ + public function setLine1($line1) + { + $this->line1 = $line1; + return $this; + } + + /** + * @return string + */ + public function getLine2() + { + return $this->line2; + } + + /** + * @param string $line2 + * @return AddressResponse + */ + public function setLine2($line2) + { + $this->line2 = $line2; + return $this; + } + + /** + * @return string + */ + public function getPostalCode() + { + return $this->postalCode; + } + + /** + * @param string $postalCode + * @return AddressResponse + */ + public function setPostalCode($postalCode) + { + $this->postalCode = $postalCode; + return $this; + } + + /** + * @return string + */ + public function getState() + { + return $this->state; + } + + /** + * @param string $state + * @return AddressResponse + */ + public function setState($state) + { + $this->state = $state; + return $this; + } + +} \ No newline at end of file diff --git a/src/Response/LegalEntity/DOBResponse.php b/src/Response/LegalEntity/DOBResponse.php new file mode 100644 index 0000000..2ad0501 --- /dev/null +++ b/src/Response/LegalEntity/DOBResponse.php @@ -0,0 +1,83 @@ +day; + } + + /** + * @param int $day + * @return DOBResponse + */ + public function setDay($day) + { + $this->day = $day; + return $this; + } + + /** + * @return int + */ + public function getMonth() + { + return $this->month; + } + + /** + * @param int $month + * @return DOBResponse + */ + public function setMonth($month) + { + $this->month = $month; + return $this; + } + + /** + * @return int + */ + public function getYear() + { + return $this->year; + } + + /** + * @param int $year + * @return DOBResponse + */ + public function setYear($year) + { + $this->year = $year; + return $this; + } + +} \ No newline at end of file diff --git a/src/Response/LegalEntity/LegalEntityResponse.php b/src/Response/LegalEntity/LegalEntityResponse.php new file mode 100644 index 0000000..2bcf8dc --- /dev/null +++ b/src/Response/LegalEntity/LegalEntityResponse.php @@ -0,0 +1,274 @@ +additionalOwners; + } + + /** + * @param array $additionalOwners + * @return LegalEntityResponse + */ + public function setAdditionalOwners($additionalOwners) + { + $this->additionalOwners = $additionalOwners; + return $this; + } + + /** + * @return AddressResponse + */ + public function getAddress() + { + return $this->address; + } + + /** + * @param string $address + * @return LegalEntityResponse + */ + public function setAddress($address) + { + $this->address = $address; + return $this; + } + + /** + * @return string + */ + public function getBusinessName() + { + return $this->businessName; + } + + /** + * @param string $businessName + * @return LegalEntityResponse + */ + public function setBusinessName($businessName) + { + $this->businessName = $businessName; + return $this; + } + + /** + * @return DOBResponse + */ + public function getDob() + { + return $this->dob; + } + + /** + * @param DOBResponse $dob + * @return LegalEntityResponse + */ + public function setDob($dob) + { + $this->dob = $dob; + return $this; + } + + /** + * @return string + */ + public function getFirstName() + { + return $this->firstName; + } + + /** + * @param string $firstName + * @return LegalEntityResponse + */ + public function setFirstName($firstName) + { + $this->firstName = $firstName; + return $this; + } + + /** + * @return string + */ + public function getLastName() + { + return $this->lastName; + } + + /** + * @param string $lastName + * @return LegalEntityResponse + */ + public function setLastName($lastName) + { + $this->lastName = $lastName; + return $this; + } + + /** + * @return AddressResponse + */ + public function getPersonalAddress() + { + return $this->personalAddress; + } + + /** + * @param AddressResponse $personalAddress + * @return LegalEntityResponse + */ + public function setPersonalAddress($personalAddress) + { + $this->personalAddress = $personalAddress; + return $this; + } + + /** + * @return string + */ + public function getPersonalIdNumberProvided() + { + return $this->personalIdNumberProvided; + } + + /** + * @param string $personalIdNumberProvided + * @return LegalEntityResponse + */ + public function setPersonalIdNumberProvided($personalIdNumberProvided) + { + $this->personalIdNumberProvided = $personalIdNumberProvided; + return $this; + } + + /** + * @return string + */ + public function getSsnLast4Provided() + { + return $this->ssnLast4Provided; + } + + /** + * @param string $ssnLast4Provided + * @return LegalEntityResponse + */ + public function setSsnLast4Provided($ssnLast4Provided) + { + $this->ssnLast4Provided = $ssnLast4Provided; + return $this; + } + + /** + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * @param string $type + * @return LegalEntityResponse + */ + public function setType($type) + { + $this->type = $type; + return $this; + } + + /** + * @return array + */ + public function getVerification() + { + return $this->verification; + } + + /** + * @param array $verification + * @return LegalEntityResponse + */ + public function setVerification($verification) + { + $this->verification = $verification; + return $this; + } +} \ No newline at end of file diff --git a/tests/Api/AccountsTest.php b/tests/Api/AccountsTest.php index e5dea72..d35201d 100644 --- a/tests/Api/AccountsTest.php +++ b/tests/Api/AccountsTest.php @@ -9,6 +9,16 @@ use Stripe\Api\Accounts; +use Stripe\Request\Accounts\CreateAccountRequest; +use Stripe\Request\Accounts\CreateDeclineChargeRequest; +use Stripe\Request\Accounts\CreateExternalAccountRequest; +use Stripe\Request\Accounts\CreateTOSAcceptance; +use Stripe\Request\Accounts\CreateTransferScheduleRequest; +use Stripe\Request\Accounts\UpdateAccountRequest; +use Stripe\Request\LegalEntity\CreateAddressRequest; +use Stripe\Request\LegalEntity\CreateDOBRequest; +use Stripe\Request\LegalEntity\CreateLegalEntityRequest; +use Stripe\Request\ListRequest; use Stripe\Tests\StripeTestCase; class AccountsTest extends StripeTestCase @@ -19,14 +29,24 @@ class AccountsTest extends StripeTestCase protected $accounts; /** - * @var string + * @var CreateAccountRequest */ - protected $customerId; + protected $request; protected function setUp() { parent::setUp(); $this->accounts = new Accounts($this->client); + $request = $this->accounts->createAccountRequest(); + $request->setEmail("bob".$this->randomString()."@loblaw.com"); + $request->setManaged(true); + $this->request = $this->accounts->createAccount($request); + } + + protected function tearDown() + { + parent::tearDown(); + $this->client->delete('accounts/' . $this->request->getId()); } public function testGetAccount() @@ -36,11 +56,136 @@ public function testGetAccount() } public function testCreateAccount() + { + $this->assertInstanceOf(Accounts::ACCOUNT_RESPONSE_CLASS, $this->request); + } + + public function testAdvancedCreateAccount() + { + $country = 'US'; + $currency = 'usd'; + $routingNumber = '110000000'; + $state = 'IN'; + $address = '5555 Test Dr.'; + $businessName = 'Test'; + $firstName = 'Aaron'; + $lastName = 'Woodland'; + $type = 'individual'; + $dob = new \DateTime('1975-01-01'); + $managed = true; + $cvc = true; + $avs = true; + $delayDays = 3; + $interval = 'daily'; + + $bankAccountRequest = new CreateExternalAccountRequest('000123456789', $country, $currency); + $bankAccountRequest->setRoutingNumber($routingNumber); + $addressRequest = new CreateAddressRequest(); + $addressRequest->setState($state); + $addressRequest->setLine1($address); + $legalEntity = new CreateLegalEntityRequest(); + $legalEntity->setBusinessName($businessName); + $legalEntity->setFirstName($firstName); + $legalEntity->setLastName($lastName); + $legalEntity->setAddress($addressRequest); + $legalEntity->setType($type); + $legalEntity->setDob(new CreateDOBRequest($dob)); + $tosAcceptance = new CreateTOSAcceptance(); + $tosAcceptance->setDate(new \DateTime()); + $tosAcceptance->setIp('127.0.0.1'); + $accountRequest = new CreateAccountRequest(); + $accountRequest->setManaged($managed); + $accountRequest->setExternalAccount($bankAccountRequest); + $accountRequest->setLegalEntity($legalEntity); + $accountRequest->setTosAcceptance($tosAcceptance); + $declineCharge = new CreateDeclineChargeRequest(true, true); + $accountRequest->setDeclineChargeOn($declineCharge); + $transferSchedule = new CreateTransferScheduleRequest(); + $transferSchedule->setDelayDays($delayDays); + $transferSchedule->setInterval($interval); + $accountRequest->setTransferSchedule($transferSchedule); + + $response = $this->accounts->createAccount($accountRequest); + + $this->assertInstanceOf(Accounts::ACCOUNT_RESPONSE_CLASS, $response); + foreach ($response->getExternalAccounts()->getData() as $account) { + $this->assertInstanceOf('Stripe\Response\Accounts\ExternalAccountResponse', $account); + $this->assertEquals($country, $account->getCountry()); + $this->assertEquals($currency, $account->getCurrency()); + $this->assertEquals($routingNumber, $account->getRoutingNumber()); + } + + $this->assertInstanceOf('Stripe\Response\LegalEntity\LegalEntityResponse', $response->getLegalEntity()); + $this->assertInstanceOf('Stripe\Response\LegalEntity\AddressResponse', $response->getLegalEntity()->getAddress()); + $this->assertInstanceOf('Stripe\Response\LegalEntity\DOBResponse', $response->getLegalEntity()->getDob()); + $this->assertEquals($state, $response->getLegalEntity()->getAddress()->getState()); + $this->assertEquals($address, $response->getLegalEntity()->getAddress()->getLine1()); + $this->assertEquals($businessName, $response->getLegalEntity()->getBusinessName()); + $this->assertEquals($firstName, $response->getLegalEntity()->getFirstName()); + $this->assertEquals($lastName, $response->getLegalEntity()->getLastName()); + $this->assertEquals($type, $response->getLegalEntity()->getType()); + $this->assertEquals($managed, $response->isManaged()); + $this->assertInstanceOf('Stripe\Response\Accounts\DeclineChargeOnResponse', $response->getDeclineChargeOn()); + $this->assertEquals($cvc, $response->getDeclineChargeOn()->isCvcFailure()); + $this->assertEquals($avs, $response->getDeclineChargeOn()->isAvsFailure()); + $this->assertInstanceOf('Stripe\Response\Accounts\TransferScheduleResponse', $response->getTransferSchedule()); + $this->assertEquals($delayDays, $response->getTransferSchedule()->getDelayDays()); + $this->assertEquals($interval, $response->getTransferSchedule()->getInterval()); + $this->client->delete('accounts/' . $response->getId()); + + } + + public function testGetConnectedAccount() + { + $getResponse = $this->accounts->getConnectedAccount($this->request->getId()); + + $this->assertInstanceOf(Accounts::ACCOUNT_RESPONSE_CLASS, $getResponse); + $this->assertEquals($getResponse->getId(), $getResponse->getId()); + } + + public function testUpdateAccount() + { + $email = "foo@bar.com"; + $request = new UpdateAccountRequest(); + $request->setEmail($email); + $updateResponse = $this->accounts->updateAccount($this->request->getId(), $request); + + $this->assertInstanceOf(Accounts::ACCOUNT_RESPONSE_CLASS, $updateResponse); + $this->assertEquals($email, $updateResponse->getEmail()); + } + + public function testDeleteAccount() { $request = $this->accounts->createAccountRequest(); $request->setEmail("bob".$this->randomString()."@loblaw.com"); - $account = $this->accounts->createAccount($request); + $request->setManaged(true); + $deleteAccount = $this->accounts->createAccount($request); - $this->assertInstanceOf(Accounts::ACCOUNT_RESPONSE_CLASS, $account); + $deleteResponse = $this->accounts->deleteConnectedAccount($deleteAccount->getId()); + + $this->assertInstanceOf(Accounts::DELETE_RESPONSE_CLASS, $deleteResponse); + $this->assertTrue($deleteResponse->getDeleted()); + $this->assertEquals($deleteAccount->getId(), $deleteResponse->getId()); + } + + public function testListAccounts() + { + $request = $this->accounts->createAccountRequest(); + $request->setEmail("bob".$this->randomString()."@loblaw.com"); + $request->setManaged(true); + $account1 = $this->accounts->createAccount($request); + $account2 = $this->accounts->createAccount($request); + $account3 = $this->accounts->createAccount($request); + + $request = new ListRequest(); + $request->setLimit(2); + $list = $this->accounts->listConnectedAccounts($request); + + $this->assertInstanceOf(Accounts::LIST_ACCOUNT_RESPONSE_CLASS, $list); + $this->assertEquals(2, sizeof($list->getData())); + + $this->accounts->deleteConnectedAccount($account1->getId()); + $this->accounts->deleteConnectedAccount($account2->getId()); + $this->accounts->deleteConnectedAccount($account3->getId()); } } diff --git a/tests/Api/BalanceTest.php b/tests/Api/BalanceTest.php index 9ce067b..1c42d7d 100644 --- a/tests/Api/BalanceTest.php +++ b/tests/Api/BalanceTest.php @@ -49,8 +49,6 @@ public function testGetBalance() public function testGetBalanceTransaction() { - $this->markTestSkipped("Unable to set up external accounts for testing."); - $createAccountRequest = $this->accounts->createAccountRequest(); $createAccountRequest->setEmail("foo".$this->randomString()."@bar.com"); $createAccountRequest->setCountry("US"); @@ -60,9 +58,10 @@ public function testGetBalanceTransaction() $bankAccountRequest->setAccountNumber($this::ACCOUNT_NUMBER); $bankAccountRequest->setRoutingNumber($this::ROUTING_NUMBER); $createAccountRequest->setBankAccount($bankAccountRequest); - $this->accounts->createAccount($createAccountRequest); + $createAccountRequest->setManaged(true); + $account = $this->accounts->createAccount($createAccountRequest); - $transfer = $this->transfers->createTransfer($this->transfers->createTransferRequest(350, "usd", "self")); + $transfer = $this->transfers->createTransfer($this->transfers->createTransferRequest(100, "usd", $account->getId())); $this->assertInstanceOf(Transfers::TRANSFER_RESPONSE_CLASS, $transfer); diff --git a/tests/Api/CouponsTest.php b/tests/Api/CouponsTest.php index c209b95..39d9e20 100644 --- a/tests/Api/CouponsTest.php +++ b/tests/Api/CouponsTest.php @@ -67,12 +67,18 @@ public function testDeleteCoupon() public function testListCoupons() { + $duration = 'once'; + $percentOff = 50; + $request = $this->coupons->createCouponRequest($duration)->setPercentOff($percentOff); + $createResponse = $this->coupons->createCoupon($request); + $request = new ListRequest(); $request->setLimit(1); $listResponse = $this->coupons->listCoupons($request); $this->assertInstanceOf(Coupons::LIST_COUPONS_RESPONSE_CLASS, $listResponse); $this->assertEquals(1, sizeof($listResponse->getData())); + $this->client->delete('coupons/' . $createResponse->getId()); } /** diff --git a/tests/Api/CustomersTest.php b/tests/Api/CustomersTest.php index 317d5c8..9435b8f 100644 --- a/tests/Api/CustomersTest.php +++ b/tests/Api/CustomersTest.php @@ -31,15 +31,16 @@ public function testCreateCustomer() { $balance = -500; $description = "testing"; - $taxRate = 12.3; + //$taxRate = 12.3; $request = new CreateCustomerRequest(); - $request->setAccountBalance($balance)->setDescription($description)->setTaxPercent($taxRate); + $request->setAccountBalance($balance)->setDescription($description); + //->setTaxPercent($taxRate); $response = $this->customers->createCustomer($request); $this->assertInstanceOf(Customers::CUSTOMER_RESPONSE_CLASS, $response); $this->assertEquals($balance, $response->getAccountBalance()); $this->assertEquals($description, $request->getDescription()); - $this->assertEquals($taxRate, $request->getTaxPercent()); + //$this->assertEquals($taxRate, $request->getTaxPercent()); $this->client->delete('customers/' . $response->getId()); } diff --git a/tests/Api/InvoicesTest.php b/tests/Api/InvoicesTest.php index c24e0e0..4c66f36 100644 --- a/tests/Api/InvoicesTest.php +++ b/tests/Api/InvoicesTest.php @@ -76,11 +76,11 @@ public function testUpdateInvoice() $request = $this->invoices->createInvoiceRequest($this->customerId); $invoice = $this->invoices->createInvoice($request); - $updatedInvoice = $this->invoices->updateInvoice($invoice->getId(), null, false, 'Updated Description', array('updated' => 'metadata'), 0.2); + $updatedInvoice = $this->invoices->updateInvoice($invoice->getId(), null, true, 'Updated Description', array('updated' => 'metadata'), 0.2); $this->assertInstanceOf(Invoices::INVOICE_RESPONSE_CLASS, $updatedInvoice); $this->assertEquals(null, $updatedInvoice->getApplicationFee()); - $this->assertEquals(false, $updatedInvoice->getClosed()); + $this->assertEquals(true, $updatedInvoice->getClosed()); $this->assertEquals('Updated Description', $updatedInvoice->getDescription()); $this->assertEquals(array('updated' => 'metadata'), $updatedInvoice->getMetadata()); $this->assertEquals(0.2, $updatedInvoice->getTaxPercent());