Skip to content

Commit

Permalink
Merge pull request #504 from stripe/remi-add-topup-cancel
Browse files Browse the repository at this point in the history
Add support for cancel on Topups
  • Loading branch information
ob-stripe authored Aug 3, 2018
2 parents b87089e + 4a5b132 commit 9739466
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/Topup.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,18 @@ class Topup extends ApiResource
use ApiOperations\Create;
use ApiOperations\Retrieve;
use ApiOperations\Update;

/**
* @param array|null $params
* @param array|string|null $options
*
* @return Topup The canceled topup.
*/
public function cancel($params = null, $options = null)
{
$url = $this->instanceUrl() . '/cancel';
list($response, $opts) = $this->_request('post', $url, $params, $options);
$this->refreshFrom($response, $opts);
return $this;
}
}
11 changes: 11 additions & 0 deletions tests/Stripe/TopupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,15 @@ public function testIsUpdatable()
]);
$this->assertInstanceOf("Stripe\\Topup", $resource);
}

public function testIsCancelable()
{
$resource = Topup::retrieve(self::TEST_RESOURCE_ID);
$this->expectsRequest(
'post',
'/v1/topups/' . self::TEST_RESOURCE_ID . '/cancel'
);
$resource = $resource->cancel();
$this->assertInstanceOf("Stripe\\Topup", $resource);
}
}

0 comments on commit 9739466

Please sign in to comment.