diff --git a/init.php b/init.php index cd2e023e8..d919fcd09 100644 --- a/init.php +++ b/init.php @@ -79,6 +79,7 @@ require(dirname(__FILE__) . '/lib/Refund.php'); require(dirname(__FILE__) . '/lib/SKU.php'); require(dirname(__FILE__) . '/lib/Source.php'); +require(dirname(__FILE__) . '/lib/SourceTransaction.php'); require(dirname(__FILE__) . '/lib/Subscription.php'); require(dirname(__FILE__) . '/lib/SubscriptionItem.php'); require(dirname(__FILE__) . '/lib/ThreeDSecure.php'); diff --git a/lib/Source.php b/lib/Source.php index 372d0b333..e5c14a477 100644 --- a/lib/Source.php +++ b/lib/Source.php @@ -116,7 +116,22 @@ public function delete($params = null, $options = null) * @param array|null $params * @param array|string|null $options * - * @return BankAccount The verified bank account. + * @return Collection The list of source transactions. + */ + public function sourceTransactions($params = null, $options = null) + { + $url = $this->instanceUrl() . '/source_transactions'; + list($response, $opts) = $this->_request('get', $url, $params, $options); + $obj = Util\Util::convertToStripeObject($response, $opts); + $obj->setLastResponse($response); + return $obj; + } + + /** + * @param array|null $params + * @param array|string|null $options + * + * @return Source The verified source. */ public function verify($params = null, $options = null) { diff --git a/lib/SourceTransaction.php b/lib/SourceTransaction.php new file mode 100644 index 000000000..a0c8d776b --- /dev/null +++ b/lib/SourceTransaction.php @@ -0,0 +1,13 @@ + 'Stripe\\Refund', 'sku' => 'Stripe\\SKU', 'source' => 'Stripe\\Source', + 'source_transaction' => 'Stripe\\SourceTransaction', 'subscription' => 'Stripe\\Subscription', 'subscription_item' => 'Stripe\\SubscriptionItem', 'three_d_secure' => 'Stripe\\ThreeDSecure', diff --git a/tests/SourceTransactionTest.php b/tests/SourceTransactionTest.php new file mode 100644 index 000000000..6bbff94cb --- /dev/null +++ b/tests/SourceTransactionTest.php @@ -0,0 +1,36 @@ +mockRequest( + 'GET', + '/v1/sources/src_foo/source_transactions', + array(), + array( + 'object' => 'list', + 'url' => '/v1/sources/src_foo/source_transactions', + 'data' => array( + array( + 'id' => 'srctxn_bar', + 'object' => 'source_transaction', + ), + ), + 'has_more' => false, + ) + ); + + $source = \Stripe\Source::constructFrom( + array('id' => 'src_foo', 'object' => 'source'), + new \Stripe\Util\RequestOptions() + ); + + $transactions = $source->sourceTransactions(); + + $this->assertTrue(is_array($transactions->data)); + $this->assertSame('source_transaction', $transactions->data[0]->object); + } +}