Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/externals/stripe-php/lib/Stripe/Card.php
12256 views
1
<?php
2
3
class Stripe_Card extends Stripe_ApiResource
4
{
5
public static function constructFrom($values, $apiKey=null)
6
{
7
$class = get_class();
8
return self::scopedConstructFrom($class, $values, $apiKey);
9
}
10
11
/**
12
* @return string The instance URL for this resource. It needs to be special
13
* cased because it doesn't fit into the standard resource pattern.
14
*/
15
public function instanceUrl()
16
{
17
$id = $this['id'];
18
if (!$id) {
19
$class = get_class($this);
20
$msg = "Could not determine which URL to request: $class instance "
21
. "has invalid ID: $id";
22
throw new Stripe_InvalidRequestError($msg, null);
23
}
24
25
if (isset($this['customer'])) {
26
27
$parent = $this['customer'];
28
$base = self::classUrl('Stripe_Customer');
29
} else if (isset($this['recipient'])) {
30
31
$parent = $this['recipient'];
32
$base = self::classUrl('Stripe_Recipient');
33
} else {
34
35
return null;
36
}
37
38
$parent = Stripe_ApiRequestor::utf8($parent);
39
$id = Stripe_ApiRequestor::utf8($id);
40
41
$parentExtn = urlencode($parent);
42
$extn = urlencode($id);
43
return "$base/$parentExtn/cards/$extn";
44
}
45
46
/**
47
* @param array|null $params
48
*
49
* @return Stripe_Card The deleted card.
50
*/
51
public function delete($params=null)
52
{
53
$class = get_class();
54
return self::_scopedDelete($class, $params);
55
}
56
57
/**
58
* @return Stripe_Card The saved card.
59
*/
60
public function save()
61
{
62
$class = get_class();
63
return self::_scopedSave($class);
64
}
65
}
66
67
68