dolibarr/htdocs/includes/stripe/lib/Transfer.php

109 lines
3.1 KiB
PHP
Raw Normal View History

2017-04-18 05:44:08 +02:00
<?php
namespace Stripe;
/**
* Class Transfer
*
* @property string $id
* @property string $object
* @property int $amount
* @property int $amount_reversed
* @property string $balance_transaction
* @property int $created
* @property string $currency
2018-03-06 13:52:56 +01:00
* @property string $destination
* @property string $destination_payment
2017-04-18 05:44:08 +02:00
* @property bool $livemode
2018-03-06 13:52:56 +01:00
* @property StripeObject $metadata
* @property Collection $reversals
2017-04-18 05:44:08 +02:00
* @property bool $reversed
2018-03-06 13:52:56 +01:00
* @property string $source_transaction
* @property string $source_type
* @property string $transfer_group
2017-04-18 05:44:08 +02:00
*
* @package Stripe
*/
class Transfer extends ApiResource
{
2018-03-06 13:52:56 +01:00
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\NestedResource;
use ApiOperations\Retrieve;
use ApiOperations\Update;
const PATH_REVERSALS = '/reversals';
2017-04-18 05:44:08 +02:00
/**
2018-03-06 13:52:56 +01:00
* @return TransferReversal The created transfer reversal.
2017-04-18 05:44:08 +02:00
*/
2018-03-06 13:52:56 +01:00
public function reverse($params = null, $opts = null)
2017-04-18 05:44:08 +02:00
{
2018-03-06 13:52:56 +01:00
$url = $this->instanceUrl() . '/reversals';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
2017-04-18 05:44:08 +02:00
}
/**
2018-03-06 13:52:56 +01:00
* @return Transfer The canceled transfer.
2017-04-18 05:44:08 +02:00
*/
2018-03-06 13:52:56 +01:00
public function cancel()
2017-04-18 05:44:08 +02:00
{
2018-03-06 13:52:56 +01:00
$url = $this->instanceUrl() . '/cancel';
list($response, $opts) = $this->_request('post', $url);
$this->refreshFrom($response, $opts);
return $this;
2017-04-18 05:44:08 +02:00
}
/**
2018-03-06 13:52:56 +01:00
* @param array|null $id The ID of the transfer on which to create the reversal.
2017-04-18 05:44:08 +02:00
* @param array|null $params
* @param array|string|null $opts
*
2018-03-06 13:52:56 +01:00
* @return TransferReversal
2017-04-18 05:44:08 +02:00
*/
2018-03-06 13:52:56 +01:00
public static function createReversal($id, $params = null, $opts = null)
2017-04-18 05:44:08 +02:00
{
2018-03-06 13:52:56 +01:00
return self::_createNestedResource($id, static::PATH_REVERSALS, $params, $opts);
2017-04-18 05:44:08 +02:00
}
/**
2018-03-06 13:52:56 +01:00
* @param array|null $id The ID of the transfer to which the reversal belongs.
* @param array|null $reversalId The ID of the reversal to retrieve.
2017-04-18 05:44:08 +02:00
* @param array|null $params
2018-03-06 13:52:56 +01:00
* @param array|string|null $opts
2017-04-18 05:44:08 +02:00
*
2018-03-06 13:52:56 +01:00
* @return TransferReversal
2017-04-18 05:44:08 +02:00
*/
2018-03-06 13:52:56 +01:00
public static function retrieveReversal($id, $reversalId, $params = null, $opts = null)
2017-04-18 05:44:08 +02:00
{
2018-03-06 13:52:56 +01:00
return self::_retrieveNestedResource($id, static::PATH_REVERSALS, $reversalId, $params, $opts);
2017-04-18 05:44:08 +02:00
}
/**
2018-03-06 13:52:56 +01:00
* @param array|null $id The ID of the transfer to which the reversal belongs.
* @param array|null $reversalId The ID of the reversal to update.
* @param array|null $params
* @param array|string|null $opts
*
* @return TransferReversal
2017-04-18 05:44:08 +02:00
*/
2018-03-06 13:52:56 +01:00
public static function updateReversal($id, $reversalId, $params = null, $opts = null)
2017-04-18 05:44:08 +02:00
{
2018-03-06 13:52:56 +01:00
return self::_updateNestedResource($id, static::PATH_REVERSALS, $reversalId, $params, $opts);
2017-04-18 05:44:08 +02:00
}
/**
2018-03-06 13:52:56 +01:00
* @param array|null $id The ID of the transfer on which to retrieve the reversals.
* @param array|null $params
2017-04-18 05:44:08 +02:00
* @param array|string|null $opts
*
2018-03-06 13:52:56 +01:00
* @return TransferReversal
2017-04-18 05:44:08 +02:00
*/
2018-03-06 13:52:56 +01:00
public static function allReversals($id, $params = null, $opts = null)
2017-04-18 05:44:08 +02:00
{
2018-03-06 13:52:56 +01:00
return self::_allNestedResources($id, static::PATH_REVERSALS, $params, $opts);
2017-04-18 05:44:08 +02:00
}
}