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

141 lines
3.9 KiB
PHP
Raw Normal View History

2017-04-18 05:44:08 +02:00
<?php
namespace Stripe;
/**
* Class Charge
*
* @property string $id
* @property string $object
* @property int $amount
* @property int $amount_refunded
2018-03-06 13:52:56 +01:00
* @property string $application
* @property string $application_fee
2017-04-18 05:44:08 +02:00
* @property string $balance_transaction
* @property bool $captured
* @property int $created
* @property string $currency
* @property string $customer
2018-03-06 13:52:56 +01:00
* @property string $description
* @property string $destination
* @property string $dispute
* @property string $failure_code
* @property string $failure_message
2017-04-18 05:44:08 +02:00
* @property mixed $fraud_details
2018-03-06 13:52:56 +01:00
* @property string $invoice
2017-04-18 05:44:08 +02:00
* @property bool $livemode
2018-03-06 13:52:56 +01:00
* @property StripeObject $metadata
* @property string $on_behalf_of
* @property string $order
* @property mixed $outcome
2017-04-18 05:44:08 +02:00
* @property bool $paid
2018-03-06 13:52:56 +01:00
* @property string $receipt_email
* @property string $receipt_number
2017-04-18 05:44:08 +02:00
* @property bool $refunded
2018-03-06 13:52:56 +01:00
* @property Collection $refunds
* @property string $review
2017-04-18 05:44:08 +02:00
* @property mixed $shipping
* @property mixed $source
2018-03-06 13:52:56 +01:00
* @property string $source_transfer
* @property string $statement_descriptor
2017-04-18 05:44:08 +02:00
* @property string $status
2018-03-06 13:52:56 +01:00
* @property string $transfer
* @property string $transfer_group
2017-04-18 05:44:08 +02:00
*
* @package Stripe
*/
class Charge extends ApiResource
{
2018-03-06 13:52:56 +01:00
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Retrieve;
use ApiOperations\Update;
2017-04-18 05:44:08 +02:00
/**
* @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
*
* @return Charge The captured charge.
*/
public function capture($params = null, $options = null)
{
$url = $this->instanceUrl() . '/capture';
list($response, $opts) = $this->_request('post', $url, $params, $options);
$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);
2018-03-06 13:52:56 +01:00
$this->refreshFrom(['dispute' => $response], $opts, true);
2017-04-18 05:44:08 +02:00
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)
{
2018-03-06 13:52:56 +01:00
$params = ['fraud_details' => ['user_report' => 'fraudulent']];
2017-04-18 05:44:08 +02:00
$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)
{
2018-03-06 13:52:56 +01:00
$params = ['fraud_details' => ['user_report' => 'safe']];
2017-04-18 05:44:08 +02:00
$url = $this->instanceUrl();
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
}
}