예제 #1
1
 /**
  * Front-end display of widget.
  *
  * @see WP_Widget::widget()
  *
  * @param array $args     Widget arguments.
  * @param array $instance Saved values from database.
  */
 public function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     echo $before_widget;
     if (!empty($title)) {
         echo $before_title . $title . $after_title;
     }
     $button_defaults = array('name' => '', 'price_string' => '', 'price_currency_iso' => '', 'custom' => '', 'description' => '', 'type' => 'buy_now', 'style' => 'buy_now_large');
     $button_args = array();
     foreach ($instance as $k => $v) {
         if ($k != 'size' && $k != 'title') {
             $button_args[$k] = $v;
         }
     }
     $size = $instance['size'];
     $style = $instance['type'] . '_' . $size;
     $button_args['style'] = $style;
     $transient_name = 'cb_ecc_' . md5(serialize($button_args));
     $cached = get_transient($transient_name);
     if ($cached !== false) {
         // Cached
         echo $cached;
     } else {
         $api_key = wpsf_get_setting('coinbase', 'general', 'api_key');
         $api_secret = wpsf_get_setting('coinbase', 'general', 'api_secret');
         if ($api_key && $api_secret) {
             try {
                 $coinbase = Coinbase::withApiKey($api_key, $api_secret);
                 $button = $coinbase->createButtonWithOptions($button_args)->embedHtml;
             } catch (Exception $e) {
                 $msg = $e->getMessage();
                 error_log($msg);
                 echo "There was an error connecting to Coinbase: {$msg}. Please check your internet connection and API credentials.";
             }
             set_transient($transient_name, $button);
             echo $button;
         } else {
             echo "The Coinbase plugin has not been properly set up - please visit the Coinbase settings page in your administrator console.";
         }
     }
     echo $after_widget;
 }
예제 #2
0
 function after_process()
 {
     global $insert_id, $db, $order;
     $info = $order->info;
     $name = "Order #" . $insert_id;
     $custom = $insert_id;
     $currencyCode = $info['currency'];
     $total = $info['total'];
     $callback = zen_href_link('coinbasepp_callback.php', $parameters = '', $connection = 'NONSSL', $add_session_id = true, $search_engine_safe = true, $static = true);
     $params = array('description' => $name, 'callback_url' => $callback . "?type=" . MODULE_PAYMENT_COINBASE_CALLBACK_SECRET, 'success_url' => $callback . "?type=success", 'cancel_url' => $callback . "?type=cancel", 'info_url' => zen_href_link('index'));
     require_once dirname(__FILE__) . "/coinbase/Coinbase.php";
     $oauth = new Coinbase_Oauth(MODULE_PAYMENT_COINBASE_OAUTH_CLIENTID, MODULE_PAYMENT_COINBASE_OAUTH_CLIENTSECRET, null);
     $tokens = unserialize(MODULE_PAYMENT_COINBASE_OAUTH);
     $coinbase = new Coinbase($oauth, $tokens);
     try {
         $code = $coinbase->createButton($name, $total, $currencyCode, $custom, $params)->button->code;
     } catch (Coinbase_TokensExpiredException $e) {
         try {
             $tokens = $oauth->refreshTokens($tokens);
         } catch (Exception $f) {
             $this->tokenFail($f->getMessage());
         }
         $coinbase = new Coinbase($oauth, $tokens);
         $db->Execute("update " . TABLE_CONFIGURATION . " set configuration_value = '" . $db->prepare_input(serialize($tokens)) . "' where configuration_key = 'MODULE_PAYMENT_COINBASE_OAUTH'");
         $code = $coinbase->createButton($name, $total, $currencyCode, $custom, $params)->button->code;
     }
     $_SESSION['cart']->reset(true);
     $_SESSION['coinbasepp_order_id'] = $insert_id;
     zen_redirect("https://coinbase.com/checkouts/{$code}");
     return false;
 }
예제 #3
0
 function actionExchangeRates()
 {
     $this->layout = '//layouts/none';
     $coinbase = new Coinbase(Yii::app()->params['coinbase']['API_KEY']);
     $exchange_rates = $coinbase->getExchangeRate();
     header('Content-type: application/json');
     echo CJSON::encode($exchange_rates);
     Yii::app()->end();
 }
 function submit()
 {
     require_once dirname(__FILE__) . "/coinbase-php/Coinbase.php";
     $api_key = get_option("coinbase_wpe_api_key");
     $api_secret = get_option("coinbase_wpe_api_secret");
     $coinbase = Coinbase::withApiKey($api_key, $api_secret);
     $callback_secret = get_option("coinbase_wpe_callbacksecret");
     if ($callback_secret == false) {
         $callback_secret = sha1(openssl_random_pseudo_bytes(20));
         update_option("coinbase_wpe_callbacksecret", $callback_secret);
     }
     $callback_url = $this->cart_data['notification_url'];
     $callback_url = add_query_arg('gateway', 'wpsc_merchant_coinbase', $callback_url);
     $callback_url = add_query_arg('callback_secret', $callback_secret, $callback_url);
     $return_url = add_query_arg('sessionid', $this->cart_data['session_id'], $this->cart_data['transaction_results_url']);
     $return_url = add_query_arg('wpsc_coinbase_return', true, $return_url);
     $cancel_url = add_query_arg('cancelled', true, $return_url);
     $params = array('name' => 'Your Order', 'price_string' => $this->cart_data['total_price'], 'price_currency_iso' => $this->cart_data['store_currency'], 'callback_url' => $callback_url, 'custom' => $this->cart_data['session_id'], 'success_url' => $return_url, 'cancel_url' => $cancel_url);
     try {
         $code = $coinbase->createButtonWithOptions($params)->button->code;
     } catch (Exception $e) {
         $msg = $e->getMessage();
         error_log("There was an error creating a coinbase checkout page: {$msg}. Make sure you've connected a merchant account in Coinbase settings.");
         exit;
     }
     wp_redirect("https://coinbase.com/checkouts/{$code}");
     exit;
 }
예제 #5
0
 function __construct()
 {
     require_once 'functions/loader.php';
     $loader = new loader();
     $config = $loader->load('configuration');
     require_once 'functions/classes/coinbase/Coinbase.php';
     $this->provider = Coinbase::withApiKey($config->api_key(), $config->api_secret());
 }
예제 #6
0
 public function __construct(&$app)
 {
     $this->app =& $app;
     $config = $app->config;
     $this->currency = $config->get('paypal.currency');
     require_once './libs/paypal-php-library/PayPal.php';
     require_once './libs/paypal-php-library/Adaptive.php';
     $this->paypal = new angelleye\PayPal\Paypal(array('Sandbox' => $config->get('paypal.mode'), 'APIUsername' => $config->get('paypal.user'), 'APIPassword' => $config->get('paypal.pass'), 'APISignature' => $config->get('paypal.signature'), 'APIVersion' => '97.0', 'APISubject' => ''));
     $this->paypal_adaptive = new angelleye\PayPal\Adaptive(array('Sandbox' => $config->get('paypal.mode'), 'ApplicationID' => 'APP-80W284485P519543T', 'APIUsername' => $config->get('paypal.user'), 'APIPassword' => $config->get('paypal.pass'), 'APISignature' => $config->get('paypal.signature'), 'APIVersion' => '97.0', 'APISubject' => ''));
     require_once './libs/Coinbase/Coinbase.php';
     $this->coinbase = Coinbase::withApiKey($config->get('coinbase.key'), $config->get('coinbase.secret'));
     require_once './libs/Stripe/Stripe.php';
     Stripe::setApiKey($config->get('stripe.secret'));
 }
예제 #7
0
 public function getHtml($api_admin, $invoice_id, $subscription)
 {
     $invoice = $api_admin->invoice_get(array('id' => $invoice_id));
     $buyer = $invoice['buyer'];
     $p = array(':id' => sprintf('%05s', $invoice['nr']), ':serie' => $invoice['serie'], ':title' => $invoice['lines'][0]['title']);
     $title = __('Payment for invoice :serie:id [:title]', $p);
     $number = $invoice['nr'];
     $form = '';
     if (!isset($_GET['status'])) {
         $ch = curl_init();
         $coinbase = Coinbase::withApiKey($this->config['Coinbase_api'], $this->config['Coinbase_secret']);
         $response = $coinbase->createButton($title, $invoice['total'], $invoice['currency'], $invoice_id, array("description" => $title, "callback_url" => $this->config['return_url'], "cancel_url" => $this->config['cancel_url']));
         return "<a href='https://coinbase.com/checkouts/" . $response->button->code . "'>Pay</a>";
     }
     return $form;
 }
 public function callbackAction()
 {
     require_once Mage::getModuleDir('coinbase-php', 'Coinbase_Coinbase') . "/coinbase-php/Coinbase.php";
     $secret = $_REQUEST['secret'];
     $postBody = json_decode(file_get_contents('php://input'));
     $correctSecret = Mage::getStoreConfig('payment/Coinbase/callback_secret');
     // To verify this callback is legitimate, we will:
     //   a) check with Coinbase the submitted order information is correct.
     $apiKey = Mage::getStoreConfig('payment/Coinbase/api_key');
     $apiSecret = Mage::getStoreConfig('payment/Coinbase/api_secret');
     $coinbase = Coinbase::withApiKey($apiKey, $apiSecret);
     $cbOrderId = $postBody->order->id;
     $orderInfo = $coinbase->getOrder($cbOrderId);
     if (!$orderInfo) {
         Mage::log("Coinbase: incorrect callback with incorrect Coinbase order ID {$cbOrderId}.");
         header("HTTP/1.1 500 Internal Server Error");
         return;
     }
     //   b) using the verified order information, check which order the transaction was for using the custom param.
     $orderId = $orderInfo->custom;
     $order = Mage::getModel('sales/order')->load($orderId);
     if (!$order) {
         Mage::log("Coinbase: incorrect callback with incorrect order ID {$orderId}.");
         header("HTTP/1.1 500 Internal Server Error");
         return;
     }
     //   c) check the secret URL parameter.
     if ($secret !== $correctSecret) {
         Mage::log("Coinbase: incorrect callback with incorrect secret parameter {$secret}.");
         header("HTTP/1.1 500 Internal Server Error");
         return;
     }
     // The callback is legitimate. Update the order's status in the database.
     $payment = $order->getPayment();
     $payment->setTransactionId($cbOrderId)->setPreparedMessage("Paid with Coinbase order {$cbOrderId}.")->setShouldCloseParentTransaction(true)->setIsTransactionClosed(0);
     if ("completed" == $orderInfo->status) {
         $payment->registerCaptureNotification($orderInfo->total_native->cents / 100);
     } else {
         $cancelReason = $postBody->cancellation_reason;
         $order->registerCancellation("Coinbase order {$cbOrderId} cancelled: {$cancelReason}");
     }
     Mage::dispatchEvent('coinbase_callback_received', array('status' => $orderInfo->status, 'order_id' => $orderId));
     $order->save();
 }
예제 #9
0
 public function authorize(Varien_Object $payment, $amount)
 {
     require_once Mage::getModuleDir('coinbase-php', 'Coinbase_Coinbase') . "/coinbase-php/Coinbase.php";
     // Step 1: Use the Coinbase API to create redirect URL.
     $apiKey = Mage::getStoreConfig('payment/Coinbase/api_key');
     $apiSecret = Mage::getStoreConfig('payment/Coinbase/api_secret');
     if ($apiKey == null || $apiSecret == null) {
         throw new Exception("Before using the Coinbase plugin, you need to enter an API Key and Secret in Magento Admin > Configuration > System > Payment Methods > Coinbase.");
     }
     $coinbase = Coinbase::withApiKey($apiKey, $apiSecret);
     $order = $payment->getOrder();
     $currency = $order->getBaseCurrencyCode();
     $callbackSecret = Mage::getStoreConfig('payment/Coinbase/callback_secret');
     if ($callbackSecret == "generate") {
         // Important to keep the callback URL a secret
         $callbackSecret = md5('secret_' . mt_rand());
         Mage::getModel('core/config')->saveConfig('payment/Coinbase/callback_secret', $callbackSecret)->cleanCache();
         Mage::app()->getStore()->resetConfig();
     }
     $successUrl = Mage::getStoreConfig('payment/Coinbase/custom_success_url');
     $cancelUrl = Mage::getStoreConfig('payment/Coinbase/custom_cancel_url');
     if ($successUrl == false) {
         $successUrl = Mage::getUrl('coinbase_coinbase') . 'redirect/success/';
     }
     if ($cancelUrl == false) {
         $cancelUrl = Mage::getUrl('coinbase_coinbase') . 'redirect/cancel/';
     }
     $name = "Order #" . $order['increment_id'];
     $custom = $order->getId();
     $params = array('description' => 'Order #' . $order['increment_id'], 'callback_url' => Mage::getUrl('coinbase_coinbase') . 'callback/callback/?secret=' . $callbackSecret, 'success_url' => $successUrl, 'cancel_url' => $cancelUrl, 'info_url' => Mage::getBaseUrl());
     // Generate the code
     try {
         $code = $coinbase->createButton($name, $amount, $currency, $custom, $params)->button->code;
     } catch (Exception $e) {
         throw new Exception("Could not generate checkout page. Double check your API Key and Secret. " . $e->getMessage());
     }
     $redirectUrl = 'https://coinbase.com/checkouts/' . $code;
     // Step 2: Redirect customer to payment page
     $payment->setIsTransactionPending(true);
     // Set status to Payment Review while waiting for Coinbase postback
     Mage::getSingleton('customer/session')->setRedirectUrl($redirectUrl);
     return $this;
 }
예제 #10
0
<?php

/** 
 * Copyright: dtbaker 2012
 * Licence: Please check CodeCanyon.net for licence details. 
 * More licence clarification available here:  http://codecanyon.net/wiki/support/legal-terms/licensing-terms/ 
 * Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4
 * Envato: 4ffca17e-861e-4921-86c3-8931978c40ca
 * Package Date: 2015-11-25 02:55:20 
 * IP Address: 67.79.165.254
 */
require_once 'includes/plugin_paymethod_coinbase/lib/Coinbase.php';
$coinbase = array("secret_key" => module_config::c('payment_method_coinbase_api_key'), "publishable_key" => module_config::c('payment_method_coinbase_secret_key'));
$coinbase = Coinbase::withApiKey(module_config::c('payment_method_coinbase_api_key'), module_config::c('payment_method_coinbase_secret_key'));
if (isset($invoice_id) && $invoice_id && isset($payment_amount) && $payment_amount > 0 && isset($description)) {
    $button_options = array("description" => $description, "custom_secure" => true, "variable_price" => true, "auto_redirect" => true, 'success_url' => module_invoice::link_public_payment_complete($invoice_id), 'cancel_url' => module_invoice::link_public($invoice_id), 'callback_url' => full_link(_EXTERNAL_TUNNEL . '?m=paymethod_coinbase&h=event_ipn&method=coinbase'));
    $custom_code = module_paymethod_coinbase::get_payment_key($invoice_id, $invoice_payment_id);
    if (isset($is_subscription) && isset($invoice_payment_subscription_id) && $invoice_payment_subscription_id && $is_subscription && isset($is_subscription['coinbase_period'])) {
        $button_options['type'] = 'subscription';
        $button_options['repeat'] = $is_subscription['coinbase_period'];
        $custom_code = module_paymethod_coinbase::get_payment_key($invoice_id, $invoice_payment_id, $invoice_payment_subscription_id);
    }
    $response = $coinbase->createButton($description, $payment_amount, $currency_code, $custom_code, $button_options);
    if (isset($response->button->code) && strlen($response->button->code)) {
        redirect_browser('https://coinbase.com/checkouts/' . $response->button->code);
    }
    //echo $response->embedHtml;
}
?>

Error paying via coinbase. Please try again.
        // Admin connecting OAuth account
        $hostPart = "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s://" : "://") . $_SERVER['HTTP_HOST'];
        $pathParts = explode("?", $_SERVER['REQUEST_URI']);
        $url = $hostPart . $pathParts[0] . "?type=oauth&after=" . urlencode($_GET['after']);
        $oauth = new Coinbase_Oauth(MODULE_PAYMENT_COINBASE_OAUTH_CLIENTID, MODULE_PAYMENT_COINBASE_OAUTH_CLIENTSECRET, $url);
        try {
            $tokens = $oauth->getTokens($_GET['code']);
        } catch (Exception $e) {
            echo 'Could not authenticate. Please try again. ' . $e->getMessage();
            return;
        }
        global $db;
        $db->Execute("update " . TABLE_CONFIGURATION . " set configuration_value = '" . $db->prepare_input(serialize($tokens)) . "' where configuration_key = 'MODULE_PAYMENT_COINBASE_OAUTH'");
        zen_redirect($hostPart . $_GET['after']);
    } else {
        if ($type == MODULE_PAYMENT_COINBASE_CALLBACK_SECRET) {
            // From Coinbase - callback
            $postBody = json_decode(file_get_contents('php://input'));
            $coinbase = new Coinbase(new Coinbase_Oauth(MODULE_PAYMENT_COINBASE_OAUTH_CLIENTID, MODULE_PAYMENT_COINBASE_OAUTH_CLIENTSECRET, null), unserialize(MODULE_PAYMENT_COINBASE_OAUTH));
            $orderId = $postBody->order->id;
            $order = $coinbase->getOrder($orderId);
            if ($order == null) {
                // Callback is no good
                header("HTTP/1.1 500 Internal Server Error");
                return;
            }
            // Update order status
            $db->Execute("update " . TABLE_ORDERS . " set orders_status = " . MODULE_PAYMENT_COINBASE_COMPLETE_STATUS_ID . " where orders_id = " . intval($order->custom));
        }
    }
}
 public function paybybitcoin()
 {
     // $token = Input::get('token');
     // $owner_id = Input::get('id');
     // $request_id = Input::get('request_id');
     // $validator = Validator::make(
     // 	array(
     // 		'token' => $token,
     // 		'owner_id' => $owner_id,
     // 	),
     // 	array(
     // 		'token' => 'required',
     // 		'owner_id' => 'required|integer',
     // 	)
     // );
     // if ($validator->fails()) {
     // 	$error_messages = $validator->messages()->all();
     // 		$response_array = array('success' => false, 'error' => 'Invalid Input', 'error_code' => 401, 'error_messages' => $error_messages );
     // 		$response_code = 200;
     // } else {
     // 	$is_admin = $this->isAdmin($token);
     // 	if ($owner_data = $this->getOwnerData($owner_id, $token, $is_admin)) {
     // 		// check for token validity
     // 		if (is_token_active($owner_data->token_expiry) || $is_admin) {
     $coinbaseAPIKey = Config::get('app.coinbaseAPIKey');
     $coinbaseAPISecret = Config::get('app.coinbaseAPISecret');
     // coinbase
     $coinbase = Coinbase::withApiKey($coinbaseAPIKey, $coinbaseAPISecret);
     // $balance = $coinbase->getBalance() . " BTC";
     $user = $coinbase->getUser();
     // $contacts = $coinbase->getContacts("user");
     // $currencies = $coinbase->getCurrencies();
     // $rates = $coinbase->getExchangeRate();
     // $paymentButton = $coinbase->createButton(
     //     "Request ID",
     //     "19.99",
     //     "USD",
     //     "TRACKING_CODE_1",
     //     array(
     //            "description" => "My 19.99 USD donation to PL",
     //            "cancel_url" => "http://localhost:8000/user/acceptbitcoin",
     //            "success_url" => "http://localhost:8000/user/acceptbitcoin"
     //        )
     // );
     Log::info('user = '******'success' => true);
     // 		}else{
     // 			$response_array = array('success' => false);
     // 			Log::error('1');
     // 		}
     // 	}else{
     // 		$response_array = array('success' => false);
     // 		Log::error('2');
     // 	}
     // }
     $response_code = 200;
     $response = Response::json($response_array, $response_code);
     return $response;
 }
예제 #13
0
 function testPaginatedResource()
 {
     $requestor = new MockCoinbase_Requestor();
     $requestor->returns('doCurlRequest', array("statusCode" => 200, "body" => '
     {
       "current_user": {
         "id": "5011f33df8182b142400000e",
         "email": "*****@*****.**",
         "name": "User Two"
       },
       "balance": {
         "amount": "50.00000000",
         "currency": "BTC"
       },
       "total_count": 2,
       "num_pages": 1,
       "current_page": 1,
       "transactions": [
         {
           "transaction": {
             "id": "5018f833f8182b129c00002f",
             "created_at": "2012-08-01T02:34:43-07:00",
             "amount": {
               "amount": "-1.10000000",
               "currency": "BTC"
             },
             "request": true,
             "status": "pending",
             "sender": {
               "id": "5011f33df8182b142400000e",
               "name": "User Two",
               "email": "*****@*****.**"
             },
             "recipient": {
               "id": "5011f33df8182b142400000a",
               "name": "User One",
               "email": "*****@*****.**"
             }
           }
         },
         {
           "transaction": {
             "id": "5018f833f8182b129c00002e",
             "created_at": "2012-08-01T02:36:43-07:00",
             "hsh": "9d6a7d1112c3db9de5315b421a5153d71413f5f752aff75bf504b77df4e646a3",
             "amount": {
               "amount": "-1.00000000",
               "currency": "BTC"
             },
             "request": false,
             "status": "complete",
             "sender": {
               "id": "5011f33df8182b142400000e",
               "name": "User Two",
               "email": "*****@*****.**"
             },
             "recipient_address": "37muSN5ZrukVTvyVh3mT5Zc5ew9L9CBare"
           }
         }
      ]
     }'));
     $coinbase = new Coinbase("");
     $coinbase->setRequestor($requestor);
     $response = $coinbase->getTransactions();
     $this->assertEqual($response->transactions[0]->id, '5018f833f8182b129c00002f');
     $this->assertEqual($response->transactions[1]->id, '5018f833f8182b129c00002e');
 }
예제 #14
0
function PricerrTheme_gateways_get_purchase_this_lnk_coinbase($pid, $extrs)
{
    $price = get_post_meta($pid, 'price', true);
    if (empty($price)) {
        $price = get_option('PricerrTheme_job_fixed_amount');
    }
    $post_au = get_post($pid);
    $job_title = $post_au->post_title;
    //---------------------------------------------------
    $extr_ttl = 0;
    $xtra_stuff = '';
    $extras = $extrs;
    $extras = explode("|", $extras);
    if (count($extras)) {
        foreach ($extras as $myitem) {
            if (!empty($myitem)) {
                $extra_price = get_post_meta($pid, 'extra' . $myitem . '_price', true);
                $extr_ttl += $extra_price;
                $xtra_stuff .= '|' . $myitem;
            }
        }
    }
    $shipping = get_post_meta($pid, 'shipping', true);
    if (empty($shipping)) {
        $shipping = 0;
    }
    $total = $shipping + $extr_ttl + $price;
    //----------------------------------------
    global $current_user;
    get_currentuserinfo();
    $uid = $current_user->ID;
    $tm = time();
    $cst = $pid . '|' . $uid . '|' . $tm . $xtra_stuff;
    $custom_id = time() . $pid . $uid;
    update_option('coinbase_thing_' . $custom_id, $cst);
    $opt = get_option('PricerrTheme_coinbase_enable');
    if ($opt == "yes") {
        $_CLIENT_ID = get_option('PricerrTheme_coinbase_id');
        $_CLIENT_SECRET = get_option('PricerrTheme_client_secret_key');
        include dirname(__FILE__) . '/coinbase_php/lib/coinbase.php';
        //-------------------------------------------------------------------------------------
        $redirectUrl = str_replace("http://", "https://", plugins_url('PricerrTheme_gateways/coinbase/coinbase_redirect.php'));
        //get_bloginfo('siteurl') . "/?bitcoins=1";
        $coinbaseOauth = new Coinbase_OAuth($_CLIENT_ID, $_CLIENT_SECRET, $redirectUrl);
        $args = array('name' => $job_title, 'price_string' => $total, 'price_currency_iso' => get_option('PricerrTheme_currency'), "callback_url" => get_bloginfo('siteurl') . "?my_custom_button_callback_coinbase=1", 'custom' => $custom_id, 'description' => $job_title, 'type' => 'buy_now', 'style' => 'buy_now_large');
        $tokens = get_option('coinbase_tokens');
        if ($tokens) {
            try {
                $coinbase = new Coinbase($coinbaseOauth, $tokens);
                $button = $coinbase->createButtonWithOptions($args)->embedHtml;
            } catch (Coinbase_TokensExpiredException $e) {
                $tokens = $coinbaseOauth->refreshTokens($tokens);
                update_option('coinbase_tokens', $tokens);
                $coinbase = new Coinbase($coinbaseOauth, $tokens);
                $button = $coinbase->createButtonWithOptions($args)->embedHtml;
            }
            echo $button;
            //return $button;
        } else {
            //return "The Coinbase plugin has not been properly set up - please visit the Coinbase settings page in your administrator console.";
            echo 'Please set coinbase up right. From backend.';
        }
        ?>
    
   <!-- <a href="<?php 
        bloginfo('siteurl');
        ?>
/?pay_by_payfast=1&jobid=<?php 
        echo $pid;
        ?>
&extras=<?php 
        echo $extrs;
        ?>
" class="post_bid_btn"><?php 
        _e('Pay by Payfast', 'pr_gateways');
        ?>
</a> &nbsp;
    -->
    
    
    
    
    <?php 
    }
}
예제 #15
0
 function shortcode($atts, $content = null)
 {
     $defaults = array('name' => 'test', 'price_string' => '1.23', 'price_currency_iso' => 'USD', 'custom' => 'Order123', 'description' => 'Sample description', 'type' => 'buy_now', 'style' => 'buy_now_large', 'text' => 'Pay with Bitcoin', 'choose_price' => false, 'variable_price' => false, 'price1' => '0.0', 'price2' => '0.0', 'price3' => '0.0', 'price4' => '0.0', 'price5' => '0.0');
     $args = shortcode_atts($defaults, $atts, 'coinbase_button');
     // Clear default price suggestions
     for ($i = 1; $i <= 5; $i++) {
         if ($args["price{$i}"] == '0.0') {
             unset($args["price{$i}"]);
         }
     }
     $transient_name = 'cb_ecc_' . md5(serialize($args));
     $cached = get_transient($transient_name);
     if ($cached !== false) {
         return $cached;
     }
     $api_key = wpsf_get_setting('coinbase', 'general', 'api_key');
     $api_secret = wpsf_get_setting('coinbase', 'general', 'api_secret');
     if ($api_key && $api_secret) {
         try {
             $coinbase = Coinbase::withApiKey($api_key, $api_secret);
             $button = $coinbase->createButtonWithOptions($args)->embedHtml;
         } catch (Exception $e) {
             $msg = $e->getMessage();
             error_log($msg);
             return "There was an error connecting to Coinbase: {$msg}. Please check your internet connection and API credentials.";
         }
         set_transient($transient_name, $button);
         return $button;
     } else {
         return "The Coinbase plugin has not been properly set up - please visit the Coinbase settings page in your administrator console.";
     }
 }
예제 #16
0
<?php

include "header.php";
include "coinbase-php/lib/Coinbase.php";
$coinbase = Coinbase::withApiKey($_ENV['COINBASE_API_KEY'], $_ENV['COINBASE_API_SECRET']);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
    <title></title>
</head>

<body>
    <div class="container-wrapper container-top container-wrapper-prime">
        <div class="container container-top">
            <div class="row">
                <div class="col-md-12 center">
                    <h1>Mine Primecoin</h1>
                </div>
            </div><!-- end row -->
        </div><!-- end container -->
    </div>

    <div class="clear"></div>

    <div class="container" id="content">
        <div class="row">
            <div class="col-md-8">
                <h3>Free Mining Guides</h3>
                <p>Trying to get started mining on your own computer or in the cloud? Here are some simple foolproof guides that will help you through the process step by step.</p>
 function process_payment($order_id)
 {
     require_once plugin_dir_path(__FILE__) . 'coinbase-php' . DIRECTORY_SEPARATOR . 'Coinbase.php';
     global $woocommerce;
     $order = new WC_Order($order_id);
     $success_url = add_query_arg('return_from_coinbase', true, $this->get_return_url($order));
     // Coinbase mangles the order param so we have to put it somewhere else and restore it on init
     $cancel_url = add_query_arg('return_from_coinbase', true, $order->get_cancel_order_url());
     $cancel_url = add_query_arg('cancelled', true, $cancel_url);
     $cancel_url = add_query_arg('order_key', $order->order_key, $cancel_url);
     $params = array('name' => 'Order #' . $order_id, 'price_string' => $order->get_total(), 'price_currency_iso' => get_woocommerce_currency(), 'callback_url' => $this->notify_url, 'custom' => $order_id, 'success_url' => $success_url, 'cancel_url' => $cancel_url);
     $api_key = $this->get_option('apiKey');
     $api_secret = $this->get_option('apiSecret');
     if ($api_key == '' || $api_secret == '') {
         if (version_compare($woocommerce->version, '2.1', '>=')) {
             wc_add_notice(__('Sorry, but there was an error processing your order. Please try again or try a different payment method. (plugin not configured)', 'coinbase-woocommerce'), 'error');
         } else {
             $woocommerce->add_error(__('Sorry, but there was an error processing your order. Please try again or try a different payment method. (plugin not configured)', 'coinbase-woocommerce'));
         }
         return;
     }
     try {
         $coinbase = Coinbase::withApiKey($api_key, $api_secret);
         $code = $coinbase->createButtonWithOptions($params)->button->code;
     } catch (Exception $e) {
         $order->add_order_note(__('Error while processing coinbase payment:', 'coinbase-woocommerce') . ' ' . var_export($e, TRUE));
         if (version_compare($woocommerce->version, '2.1', '>=')) {
             wc_add_notice(__('Sorry, but there was an error processing your order. Please try again or try a different payment method.', 'coinbase-woocommerce'), 'error');
         } else {
             $woocommerce->add_error(__('Sorry, but there was an error processing your order. Please try again or try a different payment method.', 'coinbase-woocommerce'));
         }
         return;
     }
     return array('result' => 'success', 'redirect' => "https://coinbase.com/checkouts/{$code}");
 }
예제 #18
0
파일: core.php 프로젝트: bitoncoin/faucet-1
function sendCoinbaseMoney($address, $balance)
{
    global $apiKey, $cashoutMessage, $fee;
    $balance = $balance / SUB_UNIT;
    try {
        $coinbase = new Coinbase($apiKey);
        $response = $coinbase->sendMoney($address, sprintf("%.8f", $balance), $cashoutMessage, $fee > 0 ? $fee / SUB_UNIT : null);
    } catch (Exception $e) {
        $response = $e->getMessage();
        if (strpos($response, "You don't have that much") !== false) {
            throw new NoCashException($response, 0, $e);
        } else {
            throw new Exception($response, 0, $e);
        }
    }
    return $response;
}
예제 #19
0
<?php

require_once dirname(__FILE__) . '/../lib/Coinbase.php';
// Create an application at https://coinbase.com/oauth/applications and set these values accordingly
$_CLIENT_ID = "83a481f96bf28ea4bed1ee8bdc49ba4265609efa40d40477c2a57e913c479065";
$_CLIENT_SECRET = "a8dda20b94d09e84e8fefa5e7560133d9c5af9da93ec1d3e79ad0843d2920bbb";
// Note: your redirect URL should use HTTPS.
$_REDIRECT_URL = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
$coinbaseOauth = new Coinbase_OAuth($_CLIENT_ID, $_CLIENT_SECRET, $_REDIRECT_URL);
if (isset($_GET['code'])) {
    // Request tokens
    $tokens = $coinbaseOauth->getTokens($_GET['code']);
    // The user is now authenticated! Access and refresh tokens are in $tokens
    // Store these tokens safely, and use them to make Coinbase API requests in the future.
    // For example:
    $coinbase = new Coinbase($coinbaseOauth, $tokens);
    try {
        echo 'Balance: ' . $coinbase->getBalance() . '<br>';
        echo $coinbase->createButton("Alpaca socks", "10.00", "CAD")->embedHtml;
    } catch (Coinbase_TokensExpiredException $e) {
        $newTokens = $coinbaseOauth->refreshTokens($tokens);
        // Store $newTokens and retry request
    }
} else {
    // Redirect to Coinbase authorization page
    // The provided parameters specify the access your application will have to the
    // user's account; for a full list, see https://coinbase.com/docs/api/overview
    // You can pass as many scopes as you would like
    echo "<a href=\"" . $coinbaseOauth->createAuthorizeUrl("balance", "buttons") . "\">Connect with Coinbase</a>";
}