Skip to content

Commit

Permalink
chore: Add all() method to the Setup Intents API
Browse files Browse the repository at this point in the history
Signed-off-by: Bruno Gaspar <[email protected]>
  • Loading branch information
brunogaspar committed Sep 10, 2019
1 parent 95b8183 commit 5acee32
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Api/SetupIntents.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,15 @@ public function cancel($setupIntentId, array $parameters = [])
{
return $this->_post("setup_intents/{$setupIntentId}/cancel", $parameters);
}

/**
* Lists all setup intents.
*
* @param array $parameters
* @return array
*/
public function all(array $parameters = [])
{
return $this->_get('setup_intents', $parameters);
}
}
19 changes: 19 additions & 0 deletions tests/Api/SetupIntentsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,23 @@ public function it_can_cancel_an_existing_setup_intent()

$this->assertSame('canceled', $setupIntent['status']);
}

/** @test */
public function it_can_retrieve_all_setup_intents()
{
$customer1 = $this->createCustomer();
$customer2 = $this->createCustomer();

$this->createSetupIntent();
$this->createSetupIntent(['customer' => $customer1['id']]);
$this->createSetupIntent();
$this->createSetupIntent(['customer' => $customer2['id']]);

$setupIntents1 = $this->stripe->setupIntents()->all(['customer' => $customer1['id']]);
$setupIntents2 = $this->stripe->setupIntents()->all(['customer' => $customer1['id']]);

$this->assertCount(1, $setupIntents1['data']);

$this->assertCount(1, $setupIntents2['data']);
}
}
5 changes: 5 additions & 0 deletions tests/FunctionalTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,4 +316,9 @@ protected function createTestManagedAccount()
'tos_acceptance' => [ 'date' => time(), 'ip' => '127.0.0.1'],
]);
}

public function createSetupIntent(array $parameters = [])
{
return $this->stripe->setupIntents()->create($parameters);
}
}

0 comments on commit 5acee32

Please sign in to comment.