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

122 lines
3.6 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
2019-05-03 02:22:27 +02:00
* @property string $description
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
{
2019-05-03 02:22:27 +02:00
const OBJECT_NAME = "transfer";
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';
2019-05-03 02:22:27 +02:00
/**
* Possible string representations of the source type of the transfer.
* @link https://stripe.com/docs/api/transfers/object#transfer_object-source_type
*/
const SOURCE_TYPE_ALIPAY_ACCOUNT = 'alipay_account';
const SOURCE_TYPE_BANK_ACCOUNT = 'bank_account';
const SOURCE_TYPE_CARD = 'card';
const SOURCE_TYPE_FINANCING = 'financing';
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
}
/**
2019-05-03 02:22:27 +02:00
* @param string|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
}
/**
2019-05-03 02:22:27 +02:00
* @param string|null $id The ID of the transfer to which the reversal belongs.
2018-03-06 13:52:56 +01:00
* @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
}
/**
2019-05-03 02:22:27 +02:00
* @param string|null $id The ID of the transfer to which the reversal belongs.
2018-03-06 13:52:56 +01:00
* @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
}
/**
2019-05-03 02:22:27 +02:00
* @param string|null $id The ID of the transfer on which to retrieve the reversals.
2018-03-06 13:52:56 +01:00
* @param array|null $params
2017-04-18 05:44:08 +02:00
* @param array|string|null $opts
*
2019-05-03 02:22:27 +02:00
* @return Collection The list of reversals.
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
}
}