I am trying to add Bitcoin to stripe and this what I made for BitcoinReceiver Stripe Resource.
PHP Code:
<?php
class Stripe_BitcoinReceiver extends Stripe_ApiResource
{
/**
* @return string The class URL for this resource. It needs to be special
* cased because it doesn't fit into the standard resource pattern.
*/
public static function classUrl()
{
return "/v1/bitcoin/receivers";
}
/**
* @return string The instance URL for this resource. It needs to be special
* cased because it doesn't fit into the standard resource pattern.
*/
public function instanceUrl()
{
$result = parent::instanceUrl();
if ($result) {
return $result;
} else {
$id = $this['id'];
$id = Util\Util::utf8($id);
$extn = urlencode($id);
$base = BitcoinReceiver::classUrl();
return "$base/$extn";
}
}
/*
* @return BitcoinReceiver
*/
public static function retrieve($id, $apiKey=null)
{
$class = get_class();
return self::_scopedRetrieve($class, $id, $apiKey);
}
/*
* @return Collection of BitcoinReceivers
*/
public static function all($params=null, $apiKey=null)
{
$class = get_class();
return self::_scopedAll($class, $params, $apiKey);
}
/*
* @return BitcoinReceiver The created Bitcoin Receiver item.
*/
public static function create($params=null, $apiKey=null)
{
$class = get_class();
return self::_scopedCreate($class, $params, $apiKey);
}
/*
* @return BitcoinReceiver The refunded Bitcoin Receiver item.
*/
public function refund($params=null)
{
$requestor = new Stripe_ApiRequestor($this->_apiKey);
$url = $this->instanceUrl() . '/refund';
list($response, $apiKey) = $requestor->request('post', $url, $params);
$this->refreshFrom($response, $apiKey);
return $this;
}
}
Bookmarks