Пример #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;
 }
 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;
 }
Пример #3
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());
 }
Пример #4
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'));
 }
Пример #5
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();
 }
Пример #7
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;
 }
 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;
 }
Пример #9
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.";
     }
 }
 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}");
 }
Пример #11
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>
Пример #12
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.