From 9aea300211122404b3714d888cddd28509e4362d Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 9 Aug 2019 11:38:05 -0700 Subject: [PATCH] Remove deprecated methods --- lib/ApplicationFee.php | 13 ---- lib/Charge.php | 73 ---------------------- lib/Customer.php | 78 ----------------------- lib/Recipient.php | 13 ---- lib/Source.php | 13 ---- lib/Transfer.php | 11 ---- tests/Stripe/ApplicationFeeTest.php | 12 ---- tests/Stripe/ChargeTest.php | 61 ------------------ tests/Stripe/CustomerTest.php | 96 ----------------------------- tests/Stripe/RecipientTest.php | 21 ------- tests/Stripe/SourceTest.php | 2 +- tests/Stripe/TransferTest.php | 11 ---- 12 files changed, 1 insertion(+), 403 deletions(-) diff --git a/lib/ApplicationFee.php b/lib/ApplicationFee.php index 4b83071ad..78f776c0a 100644 --- a/lib/ApplicationFee.php +++ b/lib/ApplicationFee.php @@ -32,19 +32,6 @@ class ApplicationFee extends ApiResource const PATH_REFUNDS = '/refunds'; - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return ApplicationFee The refunded application fee. - */ - public function refund($params = null, $opts = null) - { - $this->refunds->create($params, $opts); - $this->refresh(); - return $this; - } - /** * @param string|null $id The ID of the application fee on which to create the refund. * @param array|null $params diff --git a/lib/Charge.php b/lib/Charge.php index 0c3853c96..3ca70b1fc 100644 --- a/lib/Charge.php +++ b/lib/Charge.php @@ -117,20 +117,6 @@ class Charge extends ApiResource const STATUS_PENDING = 'pending'; const STATUS_SUCCEEDED = 'succeeded'; - /** - * @param array|null $params - * @param array|string|null $options - * - * @return Charge The refunded charge. - */ - public function refund($params = null, $options = null) - { - $url = $this->instanceUrl() . '/refund'; - list($response, $opts) = $this->_request('post', $url, $params, $options); - $this->refreshFrom($response, $opts); - return $this; - } - /** * @param array|null $params * @param array|string|null $options @@ -144,63 +130,4 @@ public function capture($params = null, $options = null) $this->refreshFrom($response, $opts); return $this; } - - /** - * @param array|null $params - * @param array|string|null $options - * - * @deprecated Use the `save` method on the Dispute object - * - * @return array The updated dispute. - */ - public function updateDispute($params = null, $options = null) - { - $url = $this->instanceUrl() . '/dispute'; - list($response, $opts) = $this->_request('post', $url, $params, $options); - $this->refreshFrom(['dispute' => $response], $opts, true); - return $this->dispute; - } - - /** - * @param array|string|null $options - * - * @deprecated Use the `close` method on the Dispute object - * - * @return Charge The updated charge. - */ - public function closeDispute($options = null) - { - $url = $this->instanceUrl() . '/dispute/close'; - list($response, $opts) = $this->_request('post', $url, null, $options); - $this->refreshFrom($response, $opts); - return $this; - } - - /** - * @param array|string|null $opts - * - * @return Charge The updated charge. - */ - public function markAsFraudulent($opts = null) - { - $params = ['fraud_details' => ['user_report' => 'fraudulent']]; - $url = $this->instanceUrl(); - list($response, $opts) = $this->_request('post', $url, $params, $opts); - $this->refreshFrom($response, $opts); - return $this; - } - - /** - * @param array|string|null $opts - * - * @return Charge The updated charge. - */ - public function markAsSafe($opts = null) - { - $params = ['fraud_details' => ['user_report' => 'safe']]; - $url = $this->instanceUrl(); - list($response, $opts) = $this->_request('post', $url, $params, $opts); - $this->refreshFrom($response, $opts); - return $this; - } } diff --git a/lib/Customer.php b/lib/Customer.php index a3f7f6311..fcc8e5048 100644 --- a/lib/Customer.php +++ b/lib/Customer.php @@ -65,84 +65,6 @@ public static function getSavedNestedResources() const PATH_SOURCES = '/sources'; const PATH_TAX_IDS = '/tax_ids'; - /** - * @param array|null $params - * - * @return InvoiceItem The resulting invoice item. - */ - public function addInvoiceItem($params = null) - { - $params = $params ?: []; - $params['customer'] = $this->id; - $ii = InvoiceItem::create($params, $this->_opts); - return $ii; - } - - /** - * @param array|null $params - * - * @return array An array of the customer's Invoices. - */ - public function invoices($params = null) - { - $params = $params ?: []; - $params['customer'] = $this->id; - $invoices = Invoice::all($params, $this->_opts); - return $invoices; - } - - /** - * @param array|null $params - * - * @return array An array of the customer's InvoiceItems. - */ - public function invoiceItems($params = null) - { - $params = $params ?: []; - $params['customer'] = $this->id; - $iis = InvoiceItem::all($params, $this->_opts); - return $iis; - } - - /** - * @param array|null $params - * - * @return array An array of the customer's Charges. - */ - public function charges($params = null) - { - $params = $params ?: []; - $params['customer'] = $this->id; - $charges = Charge::all($params, $this->_opts); - return $charges; - } - - /** - * @param array|null $params - * - * @return Subscription The updated subscription. - */ - public function updateSubscription($params = null) - { - $url = $this->instanceUrl() . '/subscription'; - list($response, $opts) = $this->_request('post', $url, $params); - $this->refreshFrom(['subscription' => $response], $opts, true); - return $this->subscription; - } - - /** - * @param array|null $params - * - * @return Subscription The cancelled subscription. - */ - public function cancelSubscription($params = null) - { - $url = $this->instanceUrl() . '/subscription'; - list($response, $opts) = $this->_request('delete', $url, $params); - $this->refreshFrom(['subscription' => $response], $opts, true); - return $this->subscription; - } - /** * @return Customer The updated customer. */ diff --git a/lib/Recipient.php b/lib/Recipient.php index 35a695f50..83b064841 100644 --- a/lib/Recipient.php +++ b/lib/Recipient.php @@ -31,17 +31,4 @@ class Recipient extends ApiResource use ApiOperations\Delete; use ApiOperations\Retrieve; use ApiOperations\Update; - - /** - * @param array|null $params - * - * @return Collection of the Recipient's Transfers - */ - public function transfers($params = null) - { - $params = $params ?: []; - $params['recipient'] = $this->id; - $transfers = Transfer::all($params, $this->_opts); - return $transfers; - } } diff --git a/lib/Source.php b/lib/Source.php index ec5cc4212..f5af360d7 100644 --- a/lib/Source.php +++ b/lib/Source.php @@ -109,19 +109,6 @@ public function detach($params = null, $options = null) } } - /** - * @param array|null $params - * @param array|string|null $options - * - * @return Source The detached source. - * - * @deprecated Use the `detach` method instead. - */ - public function delete($params = null, $options = null) - { - $this->detach($params, $options); - } - /** * @param array|null $params * @param array|string|null $options diff --git a/lib/Transfer.php b/lib/Transfer.php index bf9fa25ce..24ae986f7 100644 --- a/lib/Transfer.php +++ b/lib/Transfer.php @@ -46,17 +46,6 @@ class Transfer extends ApiResource const SOURCE_TYPE_CARD = 'card'; const SOURCE_TYPE_FINANCING = 'financing'; - /** - * @return TransferReversal The created transfer reversal. - */ - public function reverse($params = null, $opts = null) - { - $url = $this->instanceUrl() . '/reversals'; - list($response, $opts) = $this->_request('post', $url, $params, $opts); - $this->refreshFrom($response, $opts); - return $this; - } - /** * @return Transfer The canceled transfer. */ diff --git a/tests/Stripe/ApplicationFeeTest.php b/tests/Stripe/ApplicationFeeTest.php index 2feb4ccd1..1c6350c71 100644 --- a/tests/Stripe/ApplicationFeeTest.php +++ b/tests/Stripe/ApplicationFeeTest.php @@ -28,18 +28,6 @@ public function testIsRetrievable() $this->assertInstanceOf(\Stripe\ApplicationFee::class, $resource); } - public function testIsRefundable() - { - $fee = ApplicationFee::retrieve(self::TEST_RESOURCE_ID); - $this->expectsRequest( - 'post', - '/v1/application_fees/' . $fee->id . '/refunds' - ); - $resource = $fee->refund(); - $this->assertInstanceOf(\Stripe\ApplicationFee::class, $resource); - $this->assertSame($resource, $fee); - } - public function testCanCreateRefund() { $this->expectsRequest( diff --git a/tests/Stripe/ChargeTest.php b/tests/Stripe/ChargeTest.php index f609b50b7..5bcabf1c4 100644 --- a/tests/Stripe/ChargeTest.php +++ b/tests/Stripe/ChargeTest.php @@ -65,18 +65,6 @@ public function testIsUpdatable() $this->assertInstanceOf(\Stripe\Charge::class, $resource); } - public function testCanRefund() - { - $charge = Charge::retrieve(self::TEST_RESOURCE_ID); - $this->expectsRequest( - 'post', - '/v1/charges/' . $charge->id . '/refund' - ); - $resource = $charge->refund(); - $this->assertInstanceOf(\Stripe\Charge::class, $resource); - $this->assertSame($resource, $charge); - } - public function testCanCapture() { $charge = Charge::retrieve(self::TEST_RESOURCE_ID); @@ -88,53 +76,4 @@ public function testCanCapture() $this->assertInstanceOf(\Stripe\Charge::class, $resource); $this->assertSame($resource, $charge); } - - public function testCanUpdateDispute() - { - $charge = Charge::retrieve(self::TEST_RESOURCE_ID); - $this->expectsRequest( - 'post', - '/v1/charges/' . $charge->id . '/dispute' - ); - $resource = $charge->updateDispute(); - $this->assertInstanceOf(\Stripe\Dispute::class, $resource); - } - - public function testCanCloseDispute() - { - $charge = Charge::retrieve(self::TEST_RESOURCE_ID); - $this->expectsRequest( - 'post', - '/v1/charges/' . $charge->id . '/dispute/close' - ); - $resource = $charge->closeDispute(); - $this->assertInstanceOf(\Stripe\Charge::class, $resource); - $this->assertSame($resource, $charge); - } - - public function testCanMarkAsFraudulent() - { - $charge = Charge::retrieve(self::TEST_RESOURCE_ID); - $this->expectsRequest( - 'post', - '/v1/charges/' . $charge->id, - ['fraud_details' => ['user_report' => 'fraudulent']] - ); - $resource = $charge->markAsFraudulent(); - $this->assertInstanceOf(\Stripe\Charge::class, $resource); - $this->assertSame($resource, $charge); - } - - public function testCanMarkAsSafe() - { - $charge = Charge::retrieve(self::TEST_RESOURCE_ID); - $this->expectsRequest( - 'post', - '/v1/charges/' . $charge->id, - ['fraud_details' => ['user_report' => 'safe']] - ); - $resource = $charge->markAsSafe(); - $this->assertInstanceOf(\Stripe\Charge::class, $resource); - $this->assertSame($resource, $charge); - } } diff --git a/tests/Stripe/CustomerTest.php b/tests/Stripe/CustomerTest.php index 3f143483d..73e3d0825 100644 --- a/tests/Stripe/CustomerTest.php +++ b/tests/Stripe/CustomerTest.php @@ -75,102 +75,6 @@ public function testIsDeletable() $this->assertInstanceOf(\Stripe\Customer::class, $resource); } - public function testCanAddInvoiceItem() - { - $customer = Customer::retrieve(self::TEST_RESOURCE_ID); - $this->expectsRequest( - 'post', - '/v1/invoiceitems', - [ - "amount" => 100, - "currency" => "usd", - "customer" => $customer->id - ] - ); - $resource = $customer->addInvoiceItem([ - "amount" => 100, - "currency" => "usd" - ]); - $this->assertInstanceOf(\Stripe\InvoiceItem::class, $resource); - } - - public function testCanListInvoices() - { - $customer = Customer::retrieve(self::TEST_RESOURCE_ID); - $this->expectsRequest( - 'get', - '/v1/invoices', - ["customer" => $customer->id] - ); - $resources = $customer->invoices(); - $this->assertTrue(is_array($resources->data)); - $this->assertInstanceOf(\Stripe\Invoice::class, $resources->data[0]); - } - - public function testCanListInvoiceItems() - { - $customer = Customer::retrieve(self::TEST_RESOURCE_ID); - $this->expectsRequest( - 'get', - '/v1/invoiceitems', - ["customer" => $customer->id] - ); - $resources = $customer->invoiceItems(); - $this->assertTrue(is_array($resources->data)); - $this->assertInstanceOf(\Stripe\InvoiceItem::class, $resources->data[0]); - } - - public function testCanListCharges() - { - $customer = Customer::retrieve(self::TEST_RESOURCE_ID); - $this->expectsRequest( - 'get', - '/v1/charges', - ["customer" => $customer->id] - ); - $resources = $customer->charges(); - $this->assertTrue(is_array($resources->data)); - $this->assertInstanceOf(\Stripe\Charge::class, $resources->data[0]); - } - - public function testCanUpdateSubscription() - { - $customer = Customer::retrieve(self::TEST_RESOURCE_ID); - $this->stubRequest( - 'post', - '/v1/customers/' . $customer->id . '/subscription', - ["plan" => "plan"], - null, - false, - [ - "object" => "subscription", - "id" => "sub_foo" - ] - ); - $resource = $customer->updateSubscription(["plan" => "plan"]); - $this->assertInstanceOf(\Stripe\Subscription::class, $resource); - $this->assertSame("sub_foo", $customer->subscription->id); - } - - public function testCanCancelSubscription() - { - $customer = Customer::retrieve(self::TEST_RESOURCE_ID); - $this->stubRequest( - 'delete', - '/v1/customers/' . $customer->id . '/subscription', - [], - null, - false, - [ - "object" => "subscription", - "id" => "sub_foo" - ] - ); - $resource = $customer->cancelSubscription(); - $this->assertInstanceOf(\Stripe\Subscription::class, $resource); - $this->assertSame("sub_foo", $customer->subscription->id); - } - public function testCanDeleteDiscount() { $customer = Customer::retrieve(self::TEST_RESOURCE_ID); diff --git a/tests/Stripe/RecipientTest.php b/tests/Stripe/RecipientTest.php index cc7f1c7ba..97c1c8dbf 100644 --- a/tests/Stripe/RecipientTest.php +++ b/tests/Stripe/RecipientTest.php @@ -74,25 +74,4 @@ public function testIsDeletable() $resource->delete(); $this->assertInstanceOf(\Stripe\Recipient::class, $resource); } - - public function testCanListTransfers() - { - $recipient = Recipient::retrieve(self::TEST_RESOURCE_ID); - - // stripe-mock does not support this anymore so we stub it - $this->stubRequest( - 'get', - '/v1/transfers', - ["recipient" => $recipient->id], - null, - false, - [ - "object" => "list", - "data" => [["id" => "tr_123", "object" => "transfer"]] - ] - ); - $resources = $recipient->transfers(); - $this->assertTrue(is_array($resources->data)); - $this->assertInstanceOf(\Stripe\Transfer::class, $resources->data[0]); - } } diff --git a/tests/Stripe/SourceTest.php b/tests/Stripe/SourceTest.php index 04efc8e02..49ec9ea47 100644 --- a/tests/Stripe/SourceTest.php +++ b/tests/Stripe/SourceTest.php @@ -96,7 +96,7 @@ public function testIsDetachableWhenAttached() 'delete', '/v1/customers/cus_123/sources/' . $resource->id ); - $resource->delete(); + $resource->detach(); $this->assertInstanceOf(\Stripe\Source::class, $resource); } diff --git a/tests/Stripe/TransferTest.php b/tests/Stripe/TransferTest.php index e561ba701..bf2c501c8 100644 --- a/tests/Stripe/TransferTest.php +++ b/tests/Stripe/TransferTest.php @@ -66,17 +66,6 @@ public function testIsUpdatable() $this->assertInstanceOf(\Stripe\Transfer::class, $resource); } - public function testIsReversable() - { - $resource = Transfer::retrieve(self::TEST_RESOURCE_ID); - $this->expectsRequest( - 'post', - '/v1/transfers/' . $resource->id . '/reversals' - ); - $resource->reverse(); - $this->assertInstanceOf(\Stripe\Transfer::class, $resource); - } - public function testIsCancelable() { $transfer = Transfer::retrieve(self::TEST_RESOURCE_ID);