Zen Cart Logo
Forums / Code Collaboration / Adding Bitcoin Check code please

Adding Bitcoin Check code please

Views: 5,697

Results 1 to 1 of 1
21 Jan 2018, 00:07
#1
tmccaff avatar

tmccaff

Zen Follower

Join Date:
Jan 2018
Posts:
157
Plugin Contributions:
0

Adding Bitcoin Check code please

I am trying to add Bitcoin to stripe and this what I made for BitcoinReceiver Stripe Resource.

<?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;
  }
}