• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

stripe / stripe-php / 9294314605

29 May 2024 11:10PM UTC coverage: 60.461% (-0.9%) from 61.377%
9294314605

Pull #1699

github

web-flow
Merge 5dab33188 into 3533dc330
Pull Request #1699: Update generated code for beta

1026 of 1732 new or added lines in 117 files covered. (59.24%)

15 existing lines in 3 files now uncovered.

3436 of 5683 relevant lines covered (60.46%)

2.22 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/lib/GiftCards/Transaction.php
1
<?php
2

3
// File generated from our OpenAPI spec
4

5
namespace Stripe\GiftCards;
6

7
/**
8
 * A gift card transaction represents a single transaction on a referenced gift card.
9
 * A transaction is in one of three states, <code>confirmed</code>, <code>held</code> or <code>canceled</code>. A <code>confirmed</code>
10
 * transaction is one that has added/deducted funds. A <code>held</code> transaction has created a
11
 * temporary hold on funds, which can then be cancelled or confirmed. A <code>held</code> transaction
12
 * can be confirmed into a <code>confirmed</code> transaction, or canceled into a <code>canceled</code> transaction.
13
 * A <code>canceled</code> transaction has no effect on a gift card's balance.
14
 *
15
 * @property string $id Unique identifier for the object.
16
 * @property string $object String representing the object's type. Objects of the same type share the same value.
17
 * @property null|int $amount The amount of this transaction. A positive value indicates that funds were added to the gift card. A negative value indicates that funds were removed from the gift card.
18
 * @property null|int $confirmed_at Time at which the transaction was confirmed. Measured in seconds since the Unix epoch.
19
 * @property null|int $created Time at which the object was created. Measured in seconds since the Unix epoch.
20
 * @property null|\Stripe\StripeObject $created_by The related Stripe objects that created this gift card transaction.
21
 * @property null|string $currency Three-letter <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency code</a>, in lowercase. Must be a <a href="https://stripe.com/docs/currencies">supported currency</a>.
22
 * @property null|string $description An arbitrary string attached to the object. Often useful for displaying to users.
23
 * @property null|string $gift_card The gift card that this transaction occurred on
24
 * @property null|\Stripe\StripeObject $metadata Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
25
 * @property null|string $status Status of this transaction, one of <code>held</code>, <code>confirmed</code>, or <code>canceled</code>.
26
 * @property null|string $transfer_group A string that identifies this transaction as part of a group. See the <a href="https://stripe.com/docs/connect/separate-charges-and-transfers">Connect documentation</a> for details.
27
 */
28
class Transaction extends \Stripe\ApiResource
29
{
30
    const OBJECT_NAME = 'gift_cards.transaction';
31

32
    use \Stripe\ApiOperations\Update;
33

34
    const STATUS_CANCELED = 'canceled';
35
    const STATUS_CONFIRMED = 'confirmed';
36
    const STATUS_HELD = 'held';
37
    const STATUS_INVALID = 'invalid';
38

39
    /**
40
     * Create a gift card transaction.
41
     *
42
     * @param null|mixed $params
43
     * @param null|mixed $options
44
     */
NEW
45
    public static function create($params = null, $options = null)
×
46
    {
NEW
47
        self::_validateParams($params);
×
NEW
48
        $url = static::classUrl();
×
NEW
49
        list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
×
NEW
50
        $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
×
NEW
51
        $obj->setLastResponse($response);
×
52

NEW
53
        return $obj;
×
54
    }
55

56
    /**
57
     * List gift card transactions for a gift card.
58
     *
59
     * @param null|mixed $params
60
     * @param null|mixed $opts
61
     */
NEW
62
    public static function all($params = null, $opts = null)
×
63
    {
NEW
64
        return static::_requestPage('/v1/gift_cards/transactions', \Stripe\Collection::class, $params, $opts);
×
65
    }
66

67
    /**
68
     * Retrieves the gift card transaction.
69
     *
70
     * @param mixed $id
71
     * @param null|mixed $opts
72
     */
NEW
73
    public static function retrieve($id, $opts = null)
×
74
    {
NEW
75
        $opts = \Stripe\Util\RequestOptions::parse($opts);
×
NEW
76
        $instance = new static($id, $opts);
×
NEW
77
        $instance->refresh();
×
78

NEW
79
        return $instance;
×
80
    }
81

82
    /**
83
     * Update a gift card transaction.
84
     *
85
     * @param mixed $id
86
     * @param null|mixed $params
87
     * @param null|mixed $opts
88
     */
NEW
89
    public static function update($id, $params = null, $opts = null)
×
90
    {
NEW
91
        self::_validateParams($params);
×
NEW
92
        $url = static::resourceUrl($id);
×
NEW
93
        list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
×
NEW
94
        $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
×
NEW
95
        $obj->setLastResponse($response);
×
96

NEW
97
        return $obj;
×
98
    }
99

100
    /**
101
     * @param null|array $params
102
     * @param null|array|string $opts
103
     *
104
     * @throws \Stripe\Exception\ApiErrorException if the request fails
105
     *
106
     * @return \Stripe\GiftCards\Transaction the canceled transaction
107
     */
108
    public function cancel($params = null, $opts = null)
×
109
    {
110
        $url = $this->instanceUrl() . '/cancel';
×
111
        list($response, $opts) = $this->_request('post', $url, $params, $opts);
×
112
        $this->refreshFrom($response, $opts);
×
113

114
        return $this;
×
115
    }
116

117
    /**
118
     * @param null|array $params
119
     * @param null|array|string $opts
120
     *
121
     * @throws \Stripe\Exception\ApiErrorException if the request fails
122
     *
123
     * @return \Stripe\GiftCards\Transaction the confirmed transaction
124
     */
125
    public function confirm($params = null, $opts = null)
×
126
    {
127
        $url = $this->instanceUrl() . '/confirm';
×
128
        list($response, $opts) = $this->_request('post', $url, $params, $opts);
×
129
        $this->refreshFrom($response, $opts);
×
130

131
        return $this;
×
132
    }
133
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2024 Coveralls, Inc