public function configure(array $options) { $this->accountId = $options['coinbaseAccountId']; $this->apiKey = $options['coinbaseApiKey']; $this->apiSecret = $options['coinbaseApiSecret']; $this->repurchase = $options['coinbaseRepurchaseEnabled']; $this->paymentMethodId = $options['coinbasePaymentMethodId']; try { $this->coinbase = Coinbase::withApiKey($this->apiKey, $this->apiSecret); } catch (\Exception $e) { throw new \ConfigurationException($e->getMessage()); } }
public function execute(array $matches, $url, $rest) { #$post = Container::dispense("Environment\\Post"); $apikey = $this->getWallet('coinbaseApiKey'); $apisecret = $this->getWallet('coinbaseApiSecret'); $errors = ''; $balance = ''; # Start with an empty array of payment methods $paymentMethods = array('payment_methods' => array()); try { $coinbase = Coinbase::withApiKey($apikey, $apisecret); $paymentMethods = $coinbase->getPaymentMethods(); } catch (\Exception $e) { if (strpos($e->getMessage(), '401') > -1) { $errors = "Coinbase Authentication Failed."; } else { $errors = "Error: " . $e->getMessage(); } } echo JSON::encode(['methods' => $paymentMethods, 'errors' => $errors]); return true; }