From c1fa7bfc2ffdaa327ffc160d07f511c471e3062f Mon Sep 17 00:00:00 2001 From: Aaron Valandra Date: Tue, 29 Dec 2015 15:25:13 -0600 Subject: [PATCH 01/10] Updated accounts documentation to support new account functionality. --- docs/api/accounts.md | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) 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 From 8bd5def0d448cc57b476d1da09dabe204f4ab233 Mon Sep 17 00:00:00 2001 From: Aaron Valandra Date: Tue, 29 Dec 2015 15:35:43 -0600 Subject: [PATCH 02/10] Updated accounts to now support getting individual, updating, deleting, and listing accounts. Updated the accounts request to now support TOS and legal entities. Created new objects to support TOS, DOB, Address, and LegalEntity. Extended CreateAccountRequest to create UpdateAccountRequest. Fixed an issue with spelling on the AccountResponse. ChargeEnabled and TransferEnabled should of been ChargesEnabled and TransfersEnabled. Added legal entity to Account Response. Added responses for DOB, Address, Legal entity, and list accounts. --- src/Api/Accounts.php | 56 ++++ src/Request/Accounts/CreateAccountRequest.php | 48 +++ src/Request/Accounts/CreateTOSAcceptance.php | 79 +++++ src/Request/Accounts/UpdateAccountRequest.php | 13 + .../LegalEntity/CreateAddressRequest.php | 150 ++++++++++ src/Request/LegalEntity/CreateDOBRequest.php | 87 ++++++ .../LegalEntity/CreateLegalEntityRequest.php | 263 +++++++++++++++++ src/Response/Accounts/AccountResponse.php | 29 +- .../Accounts/ListAccountsResponse.php | 34 +++ src/Response/LegalEntity/AddressResponse.php | 153 ++++++++++ src/Response/LegalEntity/DOBResponse.php | 83 ++++++ .../LegalEntity/LegalEntityResponse.php | 274 ++++++++++++++++++ 12 files changed, 1267 insertions(+), 2 deletions(-) create mode 100644 src/Request/Accounts/CreateTOSAcceptance.php create mode 100644 src/Request/Accounts/UpdateAccountRequest.php create mode 100644 src/Request/LegalEntity/CreateAddressRequest.php create mode 100644 src/Request/LegalEntity/CreateDOBRequest.php create mode 100644 src/Request/LegalEntity/CreateLegalEntityRequest.php create mode 100644 src/Response/Accounts/ListAccountsResponse.php create mode 100644 src/Response/LegalEntity/AddressResponse.php create mode 100644 src/Response/LegalEntity/DOBResponse.php create mode 100644 src/Response/LegalEntity/LegalEntityResponse.php 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..c02036f 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 { /** @@ -30,6 +32,16 @@ class CreateAccountRequest */ protected $bankAccount; + /** + * @var CreateLegalEntityRequest + */ + protected $legalEntity; + + /** + * @var CreateTOSAcceptance + */ + protected $tosAcceptance; + /** * @return boolean */ @@ -101,4 +113,40 @@ public function setBankAccount($bankAccount) $this->bankAccount = $bankAccount; 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; + } } \ 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/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..00a238c 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") @@ -83,6 +84,12 @@ class AccountResponse */ protected $object; + /** + * @Type("Stripe\Response\LegalEntity\LegalEntityResponse") + * @var LegalEntityResponse + */ + protected $legalEntity; + /** * @param boolean $chargeEnabled * @return $this @@ -298,4 +305,22 @@ public function getTransferEnabled() { return $this->transferEnabled; } + + /** + * @return LegalEntityResponse + */ + public function getLegalEntity() + { + return $this->legalEntity; + } + + /** + * @param LegalEntityResponse $legalEntity + * @return AccountResponse + */ + public function setLegalEntity($legalEntity) + { + $this->legalEntity = $legalEntity; + return $this; + } } 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/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..6ad9069 --- /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 string + */ + 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 From 9fb9ab77c0247bde2d924d3b48ff2dd09ec3ceec Mon Sep 17 00:00:00 2001 From: Aaron Valandra Date: Tue, 29 Dec 2015 15:54:22 -0600 Subject: [PATCH 03/10] Fixed a problem where the test needed to set closed to true. --- tests/Api/InvoicesTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Api/InvoicesTest.php b/tests/Api/InvoicesTest.php index c24e0e0..e330ee6 100644 --- a/tests/Api/InvoicesTest.php +++ b/tests/Api/InvoicesTest.php @@ -76,7 +76,7 @@ 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()); From 430f146f75439bdac250b8e438cea88b4527e314 Mon Sep 17 00:00:00 2001 From: Aaron Valandra Date: Tue, 29 Dec 2015 15:55:40 -0600 Subject: [PATCH 04/10] Fixed an issue when setting the tax rate with a customer. Based upon a new stripe update - https://stripe.com/docs/upgrades#2015-10-16 , the taxRate can't be set unless it is provided with a plan. --- tests/Api/CustomersTest.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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()); } From de4f4486ffe460d3143801c6ffab1021d0bb2822 Mon Sep 17 00:00:00 2001 From: Aaron Valandra Date: Tue, 29 Dec 2015 16:30:03 -0600 Subject: [PATCH 05/10] Added stripe tests for handling accounts --- tests/Api/AccountsTest.php | 63 +++++++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 4 deletions(-) diff --git a/tests/Api/AccountsTest.php b/tests/Api/AccountsTest.php index e5dea72..5ae06e9 100644 --- a/tests/Api/AccountsTest.php +++ b/tests/Api/AccountsTest.php @@ -9,6 +9,9 @@ use Stripe\Api\Accounts; +use Stripe\Request\Accounts\CreateAccountRequest; +use Stripe\Request\Accounts\UpdateAccountRequest; +use Stripe\Request\ListRequest; use Stripe\Tests\StripeTestCase; class AccountsTest extends StripeTestCase @@ -19,14 +22,18 @@ 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); } public function testGetAccount() @@ -37,10 +44,58 @@ public function testGetAccount() public function testCreateAccount() { + $this->assertInstanceOf(Accounts::ACCOUNT_RESPONSE_CLASS, $this->request); + } + + public function testGetConnectedAccount() + { + $getResponse = $this->accounts->getConnectedAccount($this->request->getId()); + + $this->assertInstanceOf(Accounts::ACCOUNT_RESPONSE_CLASS, $getResponse); + $this->assertEquals($getResponse->getId(), $getResponse->getId()); + + $this->accounts->deleteConnectedAccount($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()); + + $this->client->delete('accounts/' . $updateResponse->getId()); + } + + public function testDeleteAccount() + { + $deleteResponse = $this->accounts->deleteConnectedAccount($this->request->getId()); + + $this->assertInstanceOf(Accounts::DELETE_RESPONSE_CLASS, $deleteResponse); + $this->assertTrue($deleteResponse->getDeleted()); + $this->assertEquals($this->request->getId(), $deleteResponse->getId()); + } + + public function testListAccounts() + { + $account1 = $this->request; $request = $this->accounts->createAccountRequest(); $request->setEmail("bob".$this->randomString()."@loblaw.com"); - $account = $this->accounts->createAccount($request); + $request->setManaged(true); + $account2 = $this->accounts->createAccount($request); + $this->accounts->createAccount($request); - $this->assertInstanceOf(Accounts::ACCOUNT_RESPONSE_CLASS, $account); + $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()); } } From abbad5529d8675f1c7690c48db2f7a05095e2073 Mon Sep 17 00:00:00 2001 From: Aaron Valandra Date: Tue, 29 Dec 2015 16:35:28 -0600 Subject: [PATCH 06/10] Updated readme to include more relevant information at the top. Added a short example to show how to charge someone without the customer information... --- README.md | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) 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. From d50890c02779c4b72d85407c3c7b4c8b0932a0ad Mon Sep 17 00:00:00 2001 From: Aaron Valandra Date: Tue, 29 Dec 2015 17:33:13 -0600 Subject: [PATCH 07/10] Updated getters and setters with plural change of chargesEnabled and transfersEnabled. --- src/Response/Accounts/AccountResponse.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Response/Accounts/AccountResponse.php b/src/Response/Accounts/AccountResponse.php index 00a238c..ac69e6a 100644 --- a/src/Response/Accounts/AccountResponse.php +++ b/src/Response/Accounts/AccountResponse.php @@ -91,21 +91,21 @@ class AccountResponse protected $legalEntity; /** - * @param boolean $chargeEnabled + * @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; } /** @@ -289,21 +289,21 @@ 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->transferEnabled; + return $this->transfersEnabled; } /** From 338cf9be0abab05332b784b6fb61b58d1ea5acf4 Mon Sep 17 00:00:00 2001 From: Aaron Valandra Date: Wed, 30 Dec 2015 10:03:46 -0600 Subject: [PATCH 08/10] Deprecated bank accounts in Account request. Added external acocunts - https://stripe.com/docs/upgrades#2015-10-01 --- src/Request/Accounts/CreateAccountRequest.php | 39 ++- .../Accounts/CreateExternalAccountRequest.php | 184 ++++++++++ src/Response/Accounts/AccountResponse.php | 8 +- .../Accounts/ExternalAccountResponse.php | 317 ++++++++++++++++++ .../Accounts/ListExternalAccountsResponse.php | 33 ++ 5 files changed, 573 insertions(+), 8 deletions(-) create mode 100644 src/Request/Accounts/CreateExternalAccountRequest.php create mode 100644 src/Response/Accounts/ExternalAccountResponse.php create mode 100644 src/Response/Accounts/ListExternalAccountsResponse.php diff --git a/src/Request/Accounts/CreateAccountRequest.php b/src/Request/Accounts/CreateAccountRequest.php index c02036f..4772361 100644 --- a/src/Request/Accounts/CreateAccountRequest.php +++ b/src/Request/Accounts/CreateAccountRequest.php @@ -29,9 +29,15 @@ class CreateAccountRequest /** * @var BankAccountRequest + * @deprecated Use external accounts instead of bank account. Changed in API. */ protected $bankAccount; + /** + * @var CreateExternalAccountRequest + */ + protected $externalAccount; + /** * @var CreateLegalEntityRequest */ @@ -97,20 +103,20 @@ public function setEmail($email) } /** - * @return BankAccountRequest + * @return CreateExternalAccountRequest */ - public function getBankAccount() + public function getExternalAccount() { - return $this->bankAccount; + return $this->externalAccount; } /** - * @param BankAccountRequest $bankAccount - * @return $this + * @param CreateExternalAccountRequest $externalAccount + * @return CreateAccountRequest */ - public function setBankAccount($bankAccount) + public function setExternalAccount($externalAccount) { - $this->bankAccount = $bankAccount; + $this->externalAccount = $externalAccount; return $this; } @@ -149,4 +155,23 @@ public function setTosAcceptance($tosAcceptance) $this->tosAcceptance = $tosAcceptance; return $this; } + + /** + * @return BankAccountRequest + */ + public function getBankAccount() + { + return $this->bankAccount; + } + + /** + * @param BankAccountRequest $bankAccount + * @return CreateAccountRequest + * @deprecated Use external accounts instead of bank accounts. + */ + public function setBankAccount($bankAccount) + { + $this->bankAccount = $bankAccount; + 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/Response/Accounts/AccountResponse.php b/src/Response/Accounts/AccountResponse.php index ac69e6a..991256c 100644 --- a/src/Response/Accounts/AccountResponse.php +++ b/src/Response/Accounts/AccountResponse.php @@ -90,6 +90,12 @@ class AccountResponse */ protected $legalEntity; + /** + * @Type("Stripe\Response\Accounts\ListExternalAccountsResponse") + * @var ListExternalAccountsResponse + */ + protected $externalAccounts; + /** * @param boolean $chargesEnabled * @return $this @@ -323,4 +329,4 @@ public function setLegalEntity($legalEntity) $this->legalEntity = $legalEntity; 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/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 From b4775a4fe2a3b072200738591ff8d17b2b7e5fab Mon Sep 17 00:00:00 2001 From: Aaron Valandra Date: Wed, 30 Dec 2015 11:17:02 -0600 Subject: [PATCH 09/10] Added all account information including decline charge and transfer schedule. Added isManaged to response. Updated tests accordingly. --- src/Request/Accounts/CreateAccountRequest.php | 317 ++++++++++++++++- .../Accounts/CreateDeclineChargeRequest.php | 63 ++++ .../CreateTransferScheduleRequest.php | 102 ++++++ src/Response/Accounts/AccountResponse.php | 333 +++++++++++++++++- .../Accounts/DeclineChargeOnResponse.php | 59 ++++ .../Accounts/TransferScheduleResponse.php | 107 ++++++ .../LegalEntity/LegalEntityResponse.php | 2 +- tests/Api/AccountsTest.php | 106 +++++- 8 files changed, 1073 insertions(+), 16 deletions(-) create mode 100644 src/Request/Accounts/CreateDeclineChargeRequest.php create mode 100644 src/Request/Accounts/CreateTransferScheduleRequest.php create mode 100644 src/Response/Accounts/DeclineChargeOnResponse.php create mode 100644 src/Response/Accounts/TransferScheduleResponse.php diff --git a/src/Request/Accounts/CreateAccountRequest.php b/src/Request/Accounts/CreateAccountRequest.php index 4772361..7561c1f 100644 --- a/src/Request/Accounts/CreateAccountRequest.php +++ b/src/Request/Accounts/CreateAccountRequest.php @@ -43,6 +43,76 @@ class CreateAccountRequest */ 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 */ @@ -157,21 +227,256 @@ public function setTosAcceptance($tosAcceptance) } /** - * @return BankAccountRequest + * @return string */ - public function getBankAccount() + public function getBusinessLogo() { - return $this->bankAccount; + return $this->businessLogo; } /** - * @param BankAccountRequest $bankAccount + * @param string $businessLogo * @return CreateAccountRequest * @deprecated Use external accounts instead of bank accounts. */ - public function setBankAccount($bankAccount) + public function setBusinessLogo($businessLogo) { - $this->bankAccount = $bankAccount; + $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; + } + } \ 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/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/Response/Accounts/AccountResponse.php b/src/Response/Accounts/AccountResponse.php index 991256c..140a75c 100644 --- a/src/Response/Accounts/AccountResponse.php +++ b/src/Response/Accounts/AccountResponse.php @@ -96,6 +96,84 @@ class AccountResponse */ 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 @@ -329,4 +407,257 @@ public function setLegalEntity($legalEntity) $this->legalEntity = $legalEntity; return $this; } -} \ No newline at end of file + + /** + * @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/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/LegalEntityResponse.php b/src/Response/LegalEntity/LegalEntityResponse.php index 6ad9069..2bcf8dc 100644 --- a/src/Response/LegalEntity/LegalEntityResponse.php +++ b/src/Response/LegalEntity/LegalEntityResponse.php @@ -93,7 +93,7 @@ public function setAdditionalOwners($additionalOwners) } /** - * @return string + * @return AddressResponse */ public function getAddress() { diff --git a/tests/Api/AccountsTest.php b/tests/Api/AccountsTest.php index 5ae06e9..d35201d 100644 --- a/tests/Api/AccountsTest.php +++ b/tests/Api/AccountsTest.php @@ -10,7 +10,14 @@ 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; @@ -36,6 +43,12 @@ protected function setUp() $this->request = $this->accounts->createAccount($request); } + protected function tearDown() + { + parent::tearDown(); + $this->client->delete('accounts/' . $this->request->getId()); + } + public function testGetAccount() { $account = $this->accounts->getAccount(); @@ -47,14 +60,87 @@ 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()); - - $this->accounts->deleteConnectedAccount($getResponse->getId()); } public function testUpdateAccount() @@ -66,27 +152,30 @@ public function testUpdateAccount() $this->assertInstanceOf(Accounts::ACCOUNT_RESPONSE_CLASS, $updateResponse); $this->assertEquals($email, $updateResponse->getEmail()); - - $this->client->delete('accounts/' . $updateResponse->getId()); } public function testDeleteAccount() { - $deleteResponse = $this->accounts->deleteConnectedAccount($this->request->getId()); + $request = $this->accounts->createAccountRequest(); + $request->setEmail("bob".$this->randomString()."@loblaw.com"); + $request->setManaged(true); + $deleteAccount = $this->accounts->createAccount($request); + + $deleteResponse = $this->accounts->deleteConnectedAccount($deleteAccount->getId()); $this->assertInstanceOf(Accounts::DELETE_RESPONSE_CLASS, $deleteResponse); $this->assertTrue($deleteResponse->getDeleted()); - $this->assertEquals($this->request->getId(), $deleteResponse->getId()); + $this->assertEquals($deleteAccount->getId(), $deleteResponse->getId()); } public function testListAccounts() { - $account1 = $this->request; $request = $this->accounts->createAccountRequest(); $request->setEmail("bob".$this->randomString()."@loblaw.com"); $request->setManaged(true); + $account1 = $this->accounts->createAccount($request); $account2 = $this->accounts->createAccount($request); - $this->accounts->createAccount($request); + $account3 = $this->accounts->createAccount($request); $request = new ListRequest(); $request->setLimit(2); @@ -97,5 +186,6 @@ public function testListAccounts() $this->accounts->deleteConnectedAccount($account1->getId()); $this->accounts->deleteConnectedAccount($account2->getId()); + $this->accounts->deleteConnectedAccount($account3->getId()); } } From 8a440f230fa01fc7f053b189b156bc81842727ce Mon Sep 17 00:00:00 2001 From: Aaron Valandra Date: Wed, 30 Dec 2015 11:54:22 -0600 Subject: [PATCH 10/10] Updated tests... Fixed testListCoupons, no coupon was created before list was ran, hence no coupons and why test failed. Updated balance test to work now since creating accounts is supported through API. Fixed a minor issue with invoice test where closed was set to false when it should of been true. Must of deleted setBankAccount and getBankAccount. Marked them as deprecated now.... --- src/Request/Accounts/CreateAccountRequest.php | 19 +++++++++++++++++++ tests/Api/BalanceTest.php | 7 +++---- tests/Api/CouponsTest.php | 6 ++++++ tests/Api/InvoicesTest.php | 2 +- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/Request/Accounts/CreateAccountRequest.php b/src/Request/Accounts/CreateAccountRequest.php index 7561c1f..72dad9c 100644 --- a/src/Request/Accounts/CreateAccountRequest.php +++ b/src/Request/Accounts/CreateAccountRequest.php @@ -479,4 +479,23 @@ public function setTransferSchedule($transferSchedule) return $this; } + /** + * @return BankAccountRequest + */ + public function getBankAccount() + { + return $this->bankAccount; + } + + /** + * @param BankAccountRequest $bankAccount + * @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/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/InvoicesTest.php b/tests/Api/InvoicesTest.php index e330ee6..4c66f36 100644 --- a/tests/Api/InvoicesTest.php +++ b/tests/Api/InvoicesTest.php @@ -80,7 +80,7 @@ public function testUpdateInvoice() $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());