Skip to content

Commit

Permalink
readme, unlicense, extrainfo added
Browse files Browse the repository at this point in the history
  • Loading branch information
mikegogulski committed Nov 19, 2010
1 parent 6dc368e commit 470f3f0
Show file tree
Hide file tree
Showing 6 changed files with 250 additions and 28 deletions.
18 changes: 16 additions & 2 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
<dictionary>
<key>LaunchConfigHandle</key>
<value>&lt;project&gt;/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
Expand All @@ -20,9 +25,18 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
<dictionary>
<key>LaunchConfigHandle</key>
<value>&lt;project&gt;/.externalToolBuilders/Builder.launch</value>
</dictionary>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.php.core.PHPNature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
</projectDescription>
142 changes: 142 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
bitcoin-virtuemart
==================

A [Bitcoin](Bitcoin) payment processor plugin for the
[VirtueMart](VirtueMart) shopping cart for [Joomla!](Joomla).

Version: @@bitcoin-virtuemart-version@@

Features
--------

* Generates a new bitcoin address for every order
* Provides payment address to customer on site at checkout, plus in a
subsequent email
* Configurable timeout after which unpaid transactions will be canceled
automatically
* Configurable number of Bitcoin network confirmations after which an order
is considered paid
* HTTP or HTTPS access to bitcoind

Requirements
------------

### Base requirements
* Joomla! 1.5
* VirtueMart 1.1.x

### PHP requirements:
* PHP5
* cURL support
* SSL support (if you're using HTTPS to talk to bitcoind)

### Other requirements:
* Access to create a cronjob on your web server (or elsewhere)
* wget or the curl commandline tool on the machine running the cronjob

Limitations
-----------

* It is assumed that Bitcoin is the *only* currency accepted.
* All prices are assumed to be in Bitcoins, and no currency conversions are
performed.
* A cronjob is required to check for payment receipt, at least until
bitcoind allows attaching a JSON-RPC callback to an address.
* Emailing the bitcoin address requires an extra email to be sent (modifying
the order confirmation message VirtueMart sends would be preferable, but
the API doesn't support that).
* Validation of bitcoind's generated address is based only on its length.
The PHP solution available requires the GMP extension to be installed.
* Orders for downloadables are not tagged as "shipped" once paid.
* The Bitcoin address associated with a transaction is stored in a database
field not intended for it.
* No localization support.

Installation
------------

* Install Joomla! <http://help.joomla.org/content/category/15/99/132/>.
* Install VirtueMart (a PDF file included in the distribution explains the
process).
* Untar the distribution archive in your Joomla! installation's base
directory.

Configuration
-------------

* Log into your Joomla! installation as an administrator.
* Click Components -> VirtueMart on the main menu.
* At left, click Store -> List Payment Methods.
* Click Bitcoin in the list.
* Click the checkbox next to "Name" at the top of the list, then clear the
Bitcoin checkbox.
* Click "Unpublish" at top.
* On the "Payment Method Form" tab, configure as follows:
* Active - checked
* Payment Method Name - Bitcoin
* Code - BC
* Payment class name - ps_bitcoin
* Payment method type - HTML-Form based (e.g. PayPal)
* Now click to the "Configuration" tab and proceed as follows:
* Configure your bitcoind server information.
* If you are using HTTPS to talk to bitcoind and would like to validate
the connection using bitcoind's own SSL certificate, enter the
absolute path to the certificate file (server.cert) you've uploaded
to the server.
* Configure your payment timeout and number of transaction confirmations
required.
* *Note the instruction to create a cronjob.* The cronjob is what
queries bitcoind periodically to see if pending orders have been paid. The
cronjob is mandatory.
* Leave the "Order status" options at their defaults:
* Successful = Confirmed
* Uncompleted = Pending
* Failed = Cancelled
* Copy and paste all of the code from `extrainfo.php` in the distribution
archive's root directory into the "Payment Extra Info" box.
* Save.
* Create the Bitcoin currency:
* Assuming you're still in the VirtueMart component, click Admin ->
List Currencies at left.
* Click New at top right.
* Enter:
* Currency name: Bitcoin
* Currency code: BTC
* Save.
* Set the store-wide currency:
* Click Store -> Edit Store
* In the "Currency Display Style" box:
* Open "Currency" and select Bitcoin.
* Enter "BTC" as the Currency Symbol.
* Under "List of accepted currencies" click Bitcoin and make sure
that all other currencies are deselected.
* Save.

Donate
------

* Bitcoin payments: 1MU97wyf7msCVdaapneW2dW1uXP7oEQsFA
* Gifts via other methods: <http://www.nostate.com/support-nostatecom/>

Authors
-------

* [Mike Gogulski](http://github.com/mikegogulski) -
<http://www.nostate.com/> <http://www.gogulski.com/>

Credits
-------

* jsonrpc
* PayCific

License
-------

bitcoin-virtuemart is free and unencumbered public domain software. For more
information, see <http://unlicense.org/> or the accompanying UNLICENSE file.


[Bitcoin]: http://www.bitcoin.org/
[VirtueMart]: http://www.virtuemart.net/
[Joomla]: http://www.joomla.org/
24 changes: 24 additions & 0 deletions UNLICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <http://unlicense.org/>
38 changes: 38 additions & 0 deletions extrainfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
include_once(CLASSPATH . "payment/ps_bitcoin.cfg.php");
require_once(CLASSPATH . "ps_order.php");
$tot = number_format($db->f("order_total"), 2, ".", "");
$addr = $_SESSION["bitcoin_address"];
$oid = $db->f("order_id");
$addrinfo = "To make your payment and complete your order, please send BTC " . $tot . " to Bitcoin address " . $addr;
$confirminfo = "Your payment will be confirmed when " . BITCOIN_CONFIRMS . " confirmation";
if (BITCOIN_CONFIRMS != 1)
$confirminfo .= "s";
$confirminfo .= " of the transaction ha";
if (BITCOIN_CONFIRMS != 1)
$confirminfo .= "ve";
else
$confirminfo .= "s";
$confirminfo .= " been received.";
$confirminfo .= " If payment is not received within " . BITCOIN_TIMEOUT . " hours, your order will be canceled automatically.";
// TODO: better address validation
if (strlen($addr) >= 27 && strlen($addr) <= 40) {
$q = "UPDATE #__vm_order_payment SET order_payment_name='" . $addr . "' WHERE order_id='" . $oid . "'";
$db->query($q);
echo "<p><strong>" . $addrinfo . "</strong><p>";
echo "<p>" . $confirminfo . "</p>";

$d['include_comment'] = "Y";
$d['order_comment'] = $addrinfo . ". " . $confirminfo;
$d['current_order_status'] = "P";
$d['order_status'] = "P";
$d['notify_customer'] = "Y";
$d['order_id'] = $oid;
$order = new ps_order;
// TODO: hackish but it gets the info to the customer. revisit.
$order->order_status_update($d);

} else {
$vmLogger->err("Shopping cart expired.");
}
?>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
die('Shoo!');
/**
*
* @version 0.9.0
* @version @@bitcoin-virtuemart-version@@
* @package Bitcoin payment processor for VirtueMart
* @subpackage ps_bitcoin
* @copyright Copyright (C) 2010 by Mike Gogulski - All rights reversed
Expand Down Expand Up @@ -103,59 +103,59 @@ function show_configuration() {
</td>
<td><?php echo PHPSHOP_ADMIN_CFG_BITCOIN_SCHEME_EXPLAIN ?></td>
</tr>
<tr class="row1">

<tr class="row0">
<td><strong><?php echo PHPSHOP_ADMIN_CFG_BITCOIN_CERTIFICATE ?></strong></td>
<td><input type="text" name="BITCOIN_CERTIFICATE" class="inputbox" value="<?php echo BITCOIN_CERTIFICATE ?>" /></td>
<td><?php echo PHPSHOP_ADMIN_CFG_BITCOIN_CERTIFICATE_EXPLAIN ?></td>
</tr>
<tr class="row0">

<tr class="row1">
<td><strong><?php echo PHPSHOP_ADMIN_CFG_BITCOIN_USERNAME ?></strong></td>
<td><input type="text" name="BITCOIN_USERNAME" class="inputbox" value="<?php echo BITCOIN_USERNAME ?>" /></td>
<td><?php echo PHPSHOP_ADMIN_CFG_BITCOIN_USERNAME_EXPLAIN ?></td>
</tr>
<tr class="row1">

<tr class="row0">
<td><strong><?php echo PHPSHOP_ADMIN_CFG_BITCOIN_PASSWORD ?></strong></td>
<td><input type="text" name="BITCOIN_PASSWORD" class="inputbox" value="<?php echo BITCOIN_PASSWORD ?>" /></td>
<td><?php echo PHPSHOP_ADMIN_CFG_BITCOIN_PASSWORD_EXPLAIN ?>
</td>
</tr>
<tr class="row0">
<tr class="row1">
<td><strong><?php echo PHPSHOP_ADMIN_CFG_BITCOIN_HOST ?></strong></td>
<td><input type="text" name="BITCOIN_HOST" class="inputbox" value="<?php echo BITCOIN_HOST ?>" /></td>
<td><?php echo PHPSHOP_ADMIN_CFG_BITCOIN_HOST_EXPLAIN ?></td>
</tr>
<tr class="row1">

<tr class="row0">
<td><strong><?php echo PHPSHOP_ADMIN_CFG_BITCOIN_PORT ?></strong></td>
<td><input type="text" name="BITCOIN_PORT" class="inputbox" value="<?php echo BITCOIN_PORT ?>" /></td>
<td><?php echo PHPSHOP_ADMIN_CFG_BITCOIN_PORT_EXPLAIN ?></td>
</tr>
<tr class="row0">

<tr class="row1">
<td><strong><?php echo PHPSHOP_ADMIN_CFG_BITCOIN_TIMEOUT ?></strong></td>
<td><input type="text" name="BITCOIN_TIMEOUT" class="inputbox" value="<?php echo BITCOIN_TIMEOUT ?>" /></td>
<td><?php echo PHPSHOP_ADMIN_CFG_BITCOIN_TIMEOUT_EXPLAIN ?>
</td>
</tr>
<tr class="row1">

<tr class="row0">
<td><strong><?php echo PHPSHOP_ADMIN_CFG_BITCOIN_CONFIRMS ?></strong></td>
<td><input type="text" name="BITCOIN_CONFIRMS" class="inputbox" value="<?php echo BITCOIN_CONFIRMS ?>" /></td>
<td><?php echo PHPSHOP_ADMIN_CFG_BITCOIN_CONFIRMS_EXPLAIN ?>
</td>
</tr>
<tr class="row0">

<tr class="row1">
<td><strong><?php echo PHPSHOP_ADMIN_CFG_BITCOIN_CRON_SECRET ?></strong></td>
<td><input type="text" name="BITCOIN_CRON_SECRET" class="inputbox" value="<?php echo BITCOIN_CRON_SECRET ?>" /></td>
<td><?php echo PHPSHOP_ADMIN_CFG_BITCOIN_CRON_SECRET_EXPLAIN ?>
</td>
</tr>
<tr class="row1">

<tr class="row0">
<td><strong><?php echo PHPSHOP_ADMIN_CFG_BITCOIN_STATUS_SUCCESS ?></strong></td>
<td>
<select name="BITCOIN_VERIFIED_STATUS" class="inputbox" >
Expand Down Expand Up @@ -183,7 +183,7 @@ function show_configuration() {
<td><?php echo PHPSHOP_ADMIN_CFG_BITCOIN_STATUS_SUCCESS_EXPLAIN ?>
</td>
</tr>
<tr class="row0">
<tr class="row1">
<td><strong><?php echo VM_ADMIN_CFG_BITCOIN_STATUS_PENDING ?></strong></td>
<td>
<select name="BITCOIN_PENDING_STATUS" class="inputbox" >
Expand All @@ -201,7 +201,7 @@ function show_configuration() {
</td>
<td><?php echo VM_ADMIN_CFG_BITCOIN_STATUS_PENDING_EXPLAIN ?></td>
</tr>
<tr class="row1">
<tr class="row0">
<td><strong><?php echo PHPSHOP_ADMIN_CFG_BITCOIN_STATUS_INVALID ?></strong></td>
<td>
<select name="BITCOIN_INVALID_STATUS" class="inputbox" >
Expand Down Expand Up @@ -282,6 +282,7 @@ function write_configuration(&$d) {

/**
* create a jsonrpc_client object to talk to the bitcoin server and return it, or false on failure
* @return boolean|jsonrpc_client
*/
function get_bitcoin_client() {
require_once(CLASSPATH . 'payment/ps_bitcoin.cfg.php');
Expand All @@ -305,10 +306,13 @@ function get_bitcoin_client() {
return $client;
}

/**************************************************************************
** name: process_payment()
** returns: true on success
***************************************************************************/
/**
* Process the payment
* @param string $order_number
* @param float $order_total
* @param array $d
* @return boolean true if bitcoin
*/
function process_payment($order_number, $order_total, &$d) {
// TODO: handle conversions via to-be-written converter script
// it's also available as global $vendor_currency
Expand All @@ -331,7 +335,7 @@ function process_payment($order_number, $order_total, &$d) {
}

$address = $r->value()->scalarVal();

// TODO: better address validation
// https://www.bitcoin.org/smf/index.php?topic=1026.0 has PHP code, but it depends on the GMP extension
if (!$address || empty($address) || strlen($address) < 27 || strlen($address) > 40) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Bitcoin cronjob script
* Until bitcoind supports attaching a JSON-RPC callback to an address, we're stuck with this
*
* @version 0.9.0
* @version @@bitcoin-virtuemart-version@@
* @package Bitcoin payment processor for VirtueMart
* @subpackage checkout.bitcoin_cronjob
* @copyright Copyright (C) 2010 by Mike Gogulski - All rights reversed
Expand Down

0 comments on commit 470f3f0

Please sign in to comment.