-
Notifications
You must be signed in to change notification settings - Fork 858
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding support for Issuing resources in the API
- Loading branch information
1 parent
879ab79
commit 875cb48
Showing
16 changed files
with
614 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
namespace Stripe\Issuing; | ||
|
||
/** | ||
* Class Authorization | ||
* | ||
* @property string $id | ||
* @property string $object | ||
* @property bool $approved | ||
* @property string $authorization_method | ||
* @property int $authorized_amount | ||
* @property string $authorized_currency | ||
* @property \Stripe\Collection $balance_transactions | ||
* @property Card $card | ||
* @property Cardholder $cardholder | ||
* @property int $created | ||
* @property int $held_amount | ||
* @property string $held_currency | ||
* @property bool $is_held_amount_controllable | ||
* @property bool $livemode | ||
* @property mixed $merchant_data | ||
* @property \Stripe\StripeObject $metadata | ||
* @property int $pending_authorized_amount | ||
* @property int $pending_held_amount | ||
* @property mixed $request_history | ||
* @property string $status | ||
* @property mixed $request_history | ||
* @property \Stripe\Collection $transactions | ||
* @property mixed $verification_data | ||
* | ||
* @package Stripe\Issuing | ||
*/ | ||
class Authorization extends \Stripe\ApiResource | ||
{ | ||
const OBJECT_NAME = "issuing.authorization"; | ||
|
||
use \Stripe\ApiOperations\All; | ||
use \Stripe\ApiOperations\Retrieve; | ||
use \Stripe\ApiOperations\Update; | ||
|
||
/** | ||
* @param array|null $params | ||
* @param array|string|null $options | ||
* | ||
* @return Authorization The approved authorization. | ||
*/ | ||
public function approve($params = null, $options = null) | ||
{ | ||
$url = $this->instanceUrl() . '/approve'; | ||
list($response, $opts) = $this->_request('post', $url, $params, $options); | ||
$this->refreshFrom($response, $opts); | ||
return $this; | ||
} | ||
|
||
/** | ||
* @param array|null $params | ||
* @param array|string|null $options | ||
* | ||
* @return Authorization The declined authorization. | ||
*/ | ||
public function decline($params = null, $options = null) | ||
{ | ||
$url = $this->instanceUrl() . '/decline'; | ||
list($response, $opts) = $this->_request('post', $url, $params, $options); | ||
$this->refreshFrom($response, $opts); | ||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
namespace Stripe\Issuing; | ||
|
||
/** | ||
* Class Card | ||
* | ||
* @property string $id | ||
* @property string $object | ||
* @property mixed $authorization_controls | ||
* @property mixed $billing | ||
* @property string $brand | ||
* @property Cardholder $cardholder | ||
* @property int $created | ||
* @property string $currency | ||
* @property int $exp_month | ||
* @property int $exp_year | ||
* @property string $last4 | ||
* @property bool $livemode | ||
* @property \Stripe\StripeObject $metadata | ||
* @property string $name | ||
* @property mixed $shipping | ||
* @property string $status | ||
* @property string $type | ||
* | ||
* @package Stripe\Issuing | ||
*/ | ||
class Card extends \Stripe\ApiResource | ||
{ | ||
const OBJECT_NAME = "issuing.card"; | ||
|
||
use \Stripe\ApiOperations\All; | ||
use \Stripe\ApiOperations\Create; | ||
use \Stripe\ApiOperations\Retrieve; | ||
use \Stripe\ApiOperations\Update; | ||
|
||
/** | ||
* @param array|null $params | ||
* @param array|string|null $options | ||
* | ||
* @return CardDetails The card details associated with that issuing card. | ||
*/ | ||
public function details($params = null, $options = null) | ||
{ | ||
$url = $this->instanceUrl() . '/details'; | ||
list($response, $opts) = $this->_request('get', $url, $params, $options); | ||
$obj = \Stripe\Util\Util::convertToStripeObject($response, $opts); | ||
$obj->setLastResponse($response); | ||
return $obj; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Stripe\Issuing; | ||
|
||
/** | ||
* Class CardDetails | ||
* | ||
* @property string $id | ||
* @property string $object | ||
* @property Card $card | ||
* @property string $cvc | ||
* @property int $exp_month | ||
* @property int $exp_year | ||
* @property string $number | ||
* | ||
* @package Stripe\Issuing | ||
*/ | ||
class CardDetails extends \Stripe\ApiResource | ||
{ | ||
const OBJECT_NAME = "issuing.card_details"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace Stripe\Issuing; | ||
|
||
/** | ||
* Class Cardholder | ||
* | ||
* @property string $id | ||
* @property string $object | ||
* @property mixed $billing | ||
* @property int $created | ||
* @property string $email | ||
* @property bool $livemode | ||
* @property \Stripe\StripeObject $metadata | ||
* @property string $name | ||
* @property string $phone_number | ||
* @property string $status | ||
* @property string $type | ||
* | ||
* @package Stripe\Issuing | ||
*/ | ||
class Cardholder extends \Stripe\ApiResource | ||
{ | ||
const OBJECT_NAME = "issuing.cardholder"; | ||
|
||
use \Stripe\ApiOperations\All; | ||
use \Stripe\ApiOperations\Create; | ||
use \Stripe\ApiOperations\Retrieve; | ||
use \Stripe\ApiOperations\Update; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace Stripe\Issuing; | ||
|
||
/** | ||
* Class Dispute | ||
* | ||
* @property string $id | ||
* @property string $object | ||
* @property int $amount | ||
* @property int $created | ||
* @property string $currency | ||
* @property mixed $evidence | ||
* @property bool $livemode | ||
* @property \Stripe\StripeObject $metadata | ||
* @property string $reason | ||
* @property string $status | ||
* @property Transaction $transaction | ||
* | ||
* @package Stripe\Issuing | ||
*/ | ||
class Dispute extends \Stripe\ApiResource | ||
{ | ||
const OBJECT_NAME = "issuing.dispute"; | ||
|
||
use \Stripe\ApiOperations\All; | ||
use \Stripe\ApiOperations\Create; | ||
use \Stripe\ApiOperations\Retrieve; | ||
use \Stripe\ApiOperations\Update; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Stripe\Issuing; | ||
|
||
/** | ||
* Class Transaction | ||
* | ||
* @property string $id | ||
* @property string $object | ||
* @property int $amount | ||
* @property string $authorization | ||
* @property string $balance_transaction | ||
* @property string $card | ||
* @property string $cardholder | ||
* @property int $created | ||
* @property string $currency | ||
* @property string $dispute | ||
* @property bool $livemode | ||
* @property mixed $merchant_data | ||
* @property \Stripe\StripeObject $metadata | ||
* @property string $type | ||
* | ||
* @package Stripe\Issuing | ||
*/ | ||
class Transaction extends \Stripe\ApiResource | ||
{ | ||
const OBJECT_NAME = "issuing.transaction"; | ||
|
||
use \Stripe\ApiOperations\All; | ||
use \Stripe\ApiOperations\Create; | ||
use \Stripe\ApiOperations\Retrieve; | ||
use \Stripe\ApiOperations\Update; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
|
||
namespace Stripe\Issuing; | ||
|
||
class AuthorizationTest extends \Stripe\TestCase | ||
{ | ||
const TEST_RESOURCE_ID = 'iauth_123'; | ||
|
||
public function testIsListable() | ||
{ | ||
$this->expectsRequest( | ||
'get', | ||
'/v1/issuing/authorizations' | ||
); | ||
$resources = Authorization::all(); | ||
$this->assertTrue(is_array($resources->data)); | ||
$this->assertInstanceOf("Stripe\\Issuing\\Authorization", $resources->data[0]); | ||
} | ||
|
||
public function testIsRetrievable() | ||
{ | ||
$this->expectsRequest( | ||
'get', | ||
'/v1/issuing/authorizations/' . self::TEST_RESOURCE_ID | ||
); | ||
$resource = Authorization::retrieve(self::TEST_RESOURCE_ID); | ||
$this->assertInstanceOf("Stripe\\Issuing\\Authorization", $resource); | ||
} | ||
|
||
public function testIsSaveable() | ||
{ | ||
$resource = Authorization::retrieve(self::TEST_RESOURCE_ID); | ||
$resource->metadata["key"] = "value"; | ||
|
||
$this->expectsRequest( | ||
'post', | ||
'/v1/issuing/authorizations/' . self::TEST_RESOURCE_ID | ||
); | ||
$resource->save(); | ||
$this->assertInstanceOf("Stripe\\Issuing\\Authorization", $resource); | ||
} | ||
|
||
public function testIsUpdatable() | ||
{ | ||
$this->expectsRequest( | ||
'post', | ||
'/v1/issuing/authorizations/' . self::TEST_RESOURCE_ID, | ||
["metadata" => ["key" => "value"]] | ||
); | ||
$resource = Authorization::update(self::TEST_RESOURCE_ID, [ | ||
"metadata" => ["key" => "value"], | ||
]); | ||
$this->assertInstanceOf("Stripe\\Issuing\\Authorization", $resource); | ||
} | ||
|
||
public function testIsApprovable() | ||
{ | ||
$resource = Authorization::retrieve(self::TEST_RESOURCE_ID); | ||
|
||
$this->expectsRequest( | ||
'post', | ||
'/v1/issuing/authorizations/' . self::TEST_RESOURCE_ID . '/approve' | ||
); | ||
$resource = $resource->approve(); | ||
$this->assertInstanceOf("Stripe\\Issuing\\Authorization", $resource); | ||
} | ||
|
||
public function testIsDeclinable() | ||
{ | ||
$resource = Authorization::retrieve(self::TEST_RESOURCE_ID); | ||
|
||
$this->expectsRequest( | ||
'post', | ||
'/v1/issuing/authorizations/' . self::TEST_RESOURCE_ID . '/decline' | ||
); | ||
$resource = $resource->decline(); | ||
$this->assertInstanceOf("Stripe\\Issuing\\Authorization", $resource); | ||
} | ||
} |
Oops, something went wrong.