Bitcoin Forum
November 12, 2024, 05:47:45 PM *
News: Check out the artwork 1Dq created to commemorate this forum's 15th anniversary
 
   Home   Help Search Login Register More  
Pages: « 1 [2] 3 »  All
  Print  
Author Topic: osCommerce Bitcoin Payment Module  (Read 14649 times)
weex (OP)
Legendary
*
Offline Offline

Activity: 1102
Merit: 1014



View Profile
March 06, 2012, 04:53:41 PM
 #21

I don't know if I've set up everything correctly, but when I run the monitor.py, I get this message:

Code:
[root@grixserver python]# ./monitor.py &
[1] 7588
[root@grixserver python]# Traceback (most recent call last):
  File "./monitor.py", line 169, in <module>
    d.check()
  File "./monitor.py", line 52, in check
    p = Popen(command, stdout=PIPE)
  File "/usr/lib/python2.6/subprocess.py", line 639, in __init__
    errread, errwrite)
  File "/usr/lib/python2.6/subprocess.py", line 1228, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

Ahh, this is because bitcoind is not in your path. Please see: http://www.troubleshooters.com/linux/prepostpath.htm

You can use `which bitcoind` to check that the folder containing bitcoind has been added to the path successfully.
Andrew Vorobyov
Hero Member
*****
Offline Offline

Activity: 558
Merit: 500



View Profile
March 07, 2012, 10:30:58 AM
 #22

Good start... where to send donations?

Next step must be http://www.magentocommerce.com. Anyone interested?
Grix
Hero Member
*****
Offline Offline

Activity: 536
Merit: 500



View Profile WWW
March 07, 2012, 01:55:34 PM
 #23

I don't know if I've set up everything correctly, but when I run the monitor.py, I get this message:

Code:
[root@grixserver python]# ./monitor.py &
[1] 7588
[root@grixserver python]# Traceback (most recent call last):
  File "./monitor.py", line 169, in <module>
    d.check()
  File "./monitor.py", line 52, in check
    p = Popen(command, stdout=PIPE)
  File "/usr/lib/python2.6/subprocess.py", line 639, in __init__
    errread, errwrite)
  File "/usr/lib/python2.6/subprocess.py", line 1228, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

Ahh, this is because bitcoind is not in your path. Please see: http://www.troubleshooters.com/linux/prepostpath.htm

You can use `which bitcoind` to check that the folder containing bitcoind has been added to the path successfully.

Ah, thanks, that did the trick.

I'm almost ready to launch a humble webshop using this, just need to get DNS servers working, and order some stock. Maybe I'll even be fast enough for the little bounty you have going Smiley

BTC: 1Fahk2aa4NS4Qds4VDAL4mpNArDEdV2K5K
LaserShowGen Laser Show Software
Helios Laser Show Hardware
weex (OP)
Legendary
*
Offline Offline

Activity: 1102
Merit: 1014



View Profile
March 07, 2012, 03:59:01 PM
 #24

Good start... where to send donations?

Thanks Andrew. My donation address is 1G9EYbrFYyVeGcG4HJiCYQdXugRBb454dJ

About Magento, it looks quite a bit more complicated than an osCommerce module but the monitor.py script should be useful with some modifications.
Andrew Vorobyov
Hero Member
*****
Offline Offline

Activity: 558
Merit: 500



View Profile
March 07, 2012, 04:35:44 PM
 #25

It's also in PHP
Grix
Hero Member
*****
Offline Offline

Activity: 536
Merit: 500



View Profile WWW
March 07, 2012, 04:41:08 PM
 #26

I've got another bug or misconfig.. Anyone have any idea? When I confirm a test order, I just get this error, and the order doesn't register:

Code:
1054 - Unknown column 'delivery_date' in 'field list'

insert into orders (customers_id, customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_country, customers_telephone, customers_email_address, customers_address_format_id, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country, delivery_address_format_id, delivery_date, billing_name, billing_company, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_country, billing_address_format_id, payment_method, cc_type, cc_owner, cc_number, cc_expires, date_purchased, orders_status, currency, currency_value) values ('1', 'test user test user', '', 'test user', '', 'test user', 'test user', 'test user', 'Antigua and Barbuda', 'test user', '*', '1', 'test user test user', '', 'test user', '', 'test user', 'test user', 'test user', 'Antigua and Barbuda', '1', '', 'test user test user', '', 'test user', '', 'test user', 'test user', 'test user', 'Antigua and Barbuda', '1', 'Bitcoin Payment', '', '', '', '', now(), '1', 'BTC', '0.20208800')

[TEP STOP]

BTC: 1Fahk2aa4NS4Qds4VDAL4mpNArDEdV2K5K
LaserShowGen Laser Show Software
Helios Laser Show Hardware
weex (OP)
Legendary
*
Offline Offline

Activity: 1102
Merit: 1014



View Profile
March 07, 2012, 05:08:31 PM
 #27

I think that's a bug in osCommerce as delivery_date is nowhere in the Bitcoin module. Are you using version 2.3.1? If you're using 3.0, you should probably remove that and start again with 2.3.1 since the osCommerce website says that version is not as complete. And here it appears you've found a bug in it.
Grix
Hero Member
*****
Offline Offline

Activity: 536
Merit: 500



View Profile WWW
March 07, 2012, 05:40:27 PM
Last edit: March 07, 2012, 07:31:34 PM by Grix
 #28

Nah, I'm using 2.3.1. But I found out the module "Coupon codes" was causing the problem, so never mind I guess.

EDIT:

About security.. What would you recommend regarding wallet encryption? I guess the python script's automatic forwarding of payments wouldn't work if the wallet is encrypted, but then again an unencrypted wallet for commercial purposes seems awfully insecure.

BTC: 1Fahk2aa4NS4Qds4VDAL4mpNArDEdV2K5K
LaserShowGen Laser Show Software
Helios Laser Show Hardware
Grix
Hero Member
*****
Offline Offline

Activity: 536
Merit: 500



View Profile WWW
March 07, 2012, 10:54:38 PM
 #29

So I got a couple of things to say..

I enabled encryption on my wallet, and now I can't figure out how to remove it. So I tried editing the python script to decrypt the wallet before doing stuff. But I don't have any python experience, does this look alright?

I added a var on settings.py (BTCPASS, with the password for the wallet in a string)
I added on daemon on monitor.py:

Code:
        def walletpassphrase(self):
                command = self.bitcoind_command[:]
                command.extend(['walletpassphrase',BTCPASS,str(20)])
                p = Popen(command, stdout=PIPE)
                io = p.communicate()[0]


        def walletlock(self):
                command = self.bitcoind_command[:]
                command.extend(['walletlock'])
                p = Popen(command, stdout=PIPE)
                io = p.communicate()[0]

And then I called the functions d.walletpassphrase() and d.walletlock() in the start and end of the while loop.

I don't get any errors, but it's not working either.

Problem 1: I ran two test purchases and nothing happened. The order shows as pending on osC. monitor.log says that none of the bitcoins have been paid in to the addresses, even though bitcoind getbalance says that they are indeed received. When I reach the min amount of transaction confirmations, nothing happens either.

Problem 2: The python script will randomly exit. Sometimes I just come back to the server and notice that the script is not running for no reason.

Problem 3: When I start the script, sometimes (maybe when it's waiting for payment), I get an "insufficient funds" error message.

Problem 4: I'd like to display prices as USD on my website, it's more convenient than BTC. But when I complete an order of 6 dollars when the currency is set to dollars, monitor.py expects 6 bitcoins instead.

Some of these problems are probably the fault of my messing around in the python file. If you could make a proper version with the changes I suggested, I would be very grateful.

BTC: 1Fahk2aa4NS4Qds4VDAL4mpNArDEdV2K5K
LaserShowGen Laser Show Software
Helios Laser Show Hardware
weex (OP)
Legendary
*
Offline Offline

Activity: 1102
Merit: 1014



View Profile
March 07, 2012, 11:28:17 PM
 #30

Thanks Grix for working so hard on this. I think we may have a better time squashing bugs if you create issues at at the github repo but we'll see what we can do here until then.

So I got a couple of things to say..

I enabled encryption on my wallet, and now I can't figure out how to remove it. So I tried editing the python script to decrypt the wallet before doing stuff. But I don't have any python experience, does this look alright?


I'll have to admit I have not attempted to do wallet encryption on bitcoind. Part of the monitor script is to send funds to an off-server address and I would encourage you to use that first. Your exposure then is just whatever has been received in the past hour or two.


I added a var on settings.py (BTCPASS, with the password for the wallet in a string)
I added on daemon on monitor.py:

Code:
        def walletpassphrase(self):
                command = self.bitcoind_command[:]
                command.extend(['walletpassphrase',BTCPASS,str(20)])
                p = Popen(command, stdout=PIPE)
                io = p.communicate()[0]


        def walletlock(self):
                command = self.bitcoind_command[:]
                command.extend(['walletlock'])
                p = Popen(command, stdout=PIPE)
                io = p.communicate()[0]

And then I called the functions d.walletpassphrase() and d.walletlock() in the start and end of the while loop.

I don't get any errors, but it's not working either.

Problem 1: I ran two test purchases and nothing happened. The order shows as pending on osC. monitor.log says that none of the bitcoins have been paid in to the addresses, even though bitcoind getbalance says that they are indeed received. When I reach the min amount of transaction confirmations, nothing happens either.

Is the orders_status_history table showing bitcoin addresses in the comments field? If you do a bitcoind getbalance on the account holding that address does it show funds received at that address? I wonder if the funds are being sent off before they are seen by the receiving part of the script.

Problem 2: The python script will randomly exit. Sometimes I just come back to the server and notice that the script is not running for no reason.


To be sure, error handling can be improved. To help troubleshoot I would suggest you install screen and run bitcoind in a screen session. Then when bitcoind quits an error message should appear in that screen session.


Problem 3: When I start the script, sometimes (maybe when it's waiting for payment), I get an "insufficient funds" error message.

This would make sense if the script was attempting to send out BTC that no longer exist.

Problem 4: I'd like to display prices as USD on my website, it's more convenient than BTC. But when I complete an order of 6 dollars when the currency is set to dollars, monitor.py expects 6 bitcoins instead.

Check out this addon http://addons.oscommerce.com/info/3333

If you set Bitcoin as your default currency, it will always display the amount in Bitcoins. If this data is present in the order_total table after you put in an order we should be able to pick that up. Regardless USD totals should never be expected in BTC so that would be a good bug to file.

Some of these problems are probably the fault of my messing around in the python file. If you could make a proper version with the changes I suggested, I would be very grateful.

Actually it is great that you're making changes and testing them. You might even want to fork the project on github and push commits to your forked repo. Once reviewed and tested, those commits could then be pulled into my branch via github's Pull Request feature.
weex (OP)
Legendary
*
Offline Offline

Activity: 1102
Merit: 1014



View Profile
March 07, 2012, 11:31:36 PM
 #31

About security.. What would you recommend regarding wallet encryption? I guess the python script's automatic forwarding of payments wouldn't work if the wallet is encrypted, but then again an unencrypted wallet for commercial purposes seems awfully insecure.

Having this script work with wallet encryption is a nice-to-have. Let's get it tested without first.

With the part of the script that sends funds off-server, I think the risk is minimal. We also request a new address for every order so there's not much value to having stolen the keys at some time in the past.
Grix
Hero Member
*****
Offline Offline

Activity: 536
Merit: 500



View Profile WWW
March 08, 2012, 12:06:52 PM
 #32

I just woke up today and saw that monitor.py suddenly had registered the payment I made yesterday. So I guess that's ok. However, it was only about 1 btc out of 6 btc because of the currency issue. Thanks for the addon link, that'll probably fix it.

About the encryption, I don't think it's possible to unencrypt the wallet.. If I just delete wallet.dat after unloading funds, will bitcoind just create a new one and everything will continue as normal?

I've never used github, so I don't know how to use it Smiley

BTC: 1Fahk2aa4NS4Qds4VDAL4mpNArDEdV2K5K
LaserShowGen Laser Show Software
Helios Laser Show Hardware
weex (OP)
Legendary
*
Offline Offline

Activity: 1102
Merit: 1014



View Profile
March 08, 2012, 04:56:02 PM
 #33

I just woke up today and saw that monitor.py suddenly had registered the payment I made yesterday. So I guess that's ok. However, it was only about 1 btc out of 6 btc because of the currency issue. Thanks for the addon link, that'll probably fix it.

About the encryption, I don't think it's possible to unencrypt the wallet.. If I just delete wallet.dat after unloading funds, will bitcoind just create a new one and everything will continue as normal?

I've never used github, so I don't know how to use it Smiley
Bitcoind will create another wallet.dat if you delete that one. I would make double sure it shows zero balance and would probably keep a labeled copy of it somewhere just in case. They're small valuable files!

I have a store running now but have a few polishes to make on it before giving the link.
Grix
Hero Member
*****
Offline Offline

Activity: 536
Merit: 500



View Profile WWW
March 08, 2012, 06:07:31 PM
 #34

I'm having more trouble, with addresses. My site does not provide the correct address when I check out, and it seems the "Display Price in Default Currency" addon just caused more problems..

I just cleared my orders database, made a new wallet and restarted monitor.py. Then  I made a test order. First of all, I had set the currency to USD to test out the addon, but at the checkout it said "Order total in BTC: 6 BTC" when the total was 6 USD. So that's not working properly.

I then made another order with BTC currency, and paid for it. The address I was given was "1GAeYv******".

Then I visited "order history" on my site. There, the payment address was completely different. It was "1CHkpay******". Monitor.log reports waiting for payment to the latter address, not the one I was given at checkout.

And there's more!

This is monitor.log:
Code:
2012-03-08 20:51:02,065 INFO Check for 1.211 BTC to be sent to 1QJJq*
2012-03-08 20:51:02,070 INFO Amount still needed: 1.211
2012-03-08 20:51:02,070 INFO Check for 6.00 BTC to be sent to 1QJJq*
2012-03-08 20:51:02,077 INFO Amount still needed: 6.00
2012-03-08 20:51:02,077 INFO Check for 1.211 BTC to be sent to 1CHkpa*
2012-03-08 20:51:02,084 INFO Amount still needed: 1.211
2012-03-08 20:51:02,084 INFO Check for 6.00 BTC to be sent to 1CHkpa*
2012-03-08 20:51:02,089 INFO Amount still needed: 6.00

I don't know where the 1QJJ payment request come from. But I do know that's an address of the last wallet I had, I remember the address. Somehow it's still there after clearing the orders table in the database. Are the more tables that the python script uses?

Also, as you can see, both addresses are waiting for both 1.211 BTC (which is correct), AND 6 BTC (which is the USD amount). I guess this is caused by the "Display Price in Default Currency", but I can't see how it would affect the bitcoin payment..

BTC: 1Fahk2aa4NS4Qds4VDAL4mpNArDEdV2K5K
LaserShowGen Laser Show Software
Helios Laser Show Hardware
weex (OP)
Legendary
*
Offline Offline

Activity: 1102
Merit: 1014



View Profile
March 08, 2012, 07:08:07 PM
 #35

Oh yes, you'll need to delete those records from the orders_status_history table.
Grix
Hero Member
*****
Offline Offline

Activity: 536
Merit: 500



View Profile WWW
March 08, 2012, 08:43:59 PM
 #36

Ok, everything seems to be working OK now, except for the problem about the wrong addresses. Do you have any idea what could be wrong? Have you tested the addon successfully yourself?

EDIT: Ok, I'll try to use github for bug reports and feature suggestions from now on.

BTC: 1Fahk2aa4NS4Qds4VDAL4mpNArDEdV2K5K
LaserShowGen Laser Show Software
Helios Laser Show Hardware
weex (OP)
Legendary
*
Offline Offline

Activity: 1102
Merit: 1014



View Profile
March 08, 2012, 09:19:51 PM
 #37

I'm not sure about the wrong addresses. You're saying that each new order shows one address on the order confirmation page but inserts another into the orders_status_history table(the one the python script checks)?

I have tested it on two machines now and it is working. I did modify the Display Addon in Default Currency addon so it always displayed in USD. I made the following changes at line 28 of /includes/modules/order_total/ot_total_defaultcurrency.php:

Code:
    
    #if ($order->info['currency'] != DEFAULT_CURRENCY){
    if ($order->info['currency'] != 'USD'){

    $this->output[] = array('title' => $this->title . ':',
                            #'text' => '<b>' . $currencies->format($order->info['total'], false, DEFAULT_CURRENCY, $order->info['currency_value']) . '</b>',
                            'text' => '<b>' . $currencies->format($order->info['total'], false, 'USD', $order->info['currency_value']) . '</b>',

and then in the languages file at /includes/languages/english/modules/order_total/ot_total_defaultcurrency.php:

Code:
#define('MODULE_ORDER_TOTAL_TOTAL_DEFAULTCURRENCY_TITLE', 'Equivalent total in ' . DEFAULT_CURRENCY);
#define('MODULE_ORDER_TOTAL_TOTAL_DEFAULTCURRENCY_DESCRIPTION', 'Display Additional Order Total in ' . DEFAULT_CURRENCY);
define('MODULE_ORDER_TOTAL_TOTAL_DEFAULTCURRENCY_TITLE', 'Equivalent total in USD');
define('MODULE_ORDER_TOTAL_TOTAL_DEFAULTCURRENCY_DESCRIPTION', 'Display Additional Order Total in USD');

I'm not sure if this addon with these changes should be included with the module but hopefully putting them here is helpful. I'm going to run through the procedure soon and update it so nobody else has to fiddle with tables like orders_status_history, etc.
Grix
Hero Member
*****
Offline Offline

Activity: 536
Merit: 500



View Profile WWW
March 08, 2012, 09:28:45 PM
 #38

Thanks for the currency mod.

btw, check github, I've added a little pull request. I've not used github before though, so I don't know if I did it right or not.

I also created an issue about the addresses. I'll investigate more  Wink

BTC: 1Fahk2aa4NS4Qds4VDAL4mpNArDEdV2K5K
LaserShowGen Laser Show Software
Helios Laser Show Hardware
weex (OP)
Legendary
*
Offline Offline

Activity: 1102
Merit: 1014



View Profile
March 08, 2012, 11:37:36 PM
 #39

The issue of the wrong addresses has been fixed. This happened when payment was made before confirmation due the way bitcoind hands out addresses per account. If an address is used it thinks you should use a new one. So to get around this, the module creates a new account and address for each visit to the confirmation page.
weex (OP)
Legendary
*
Offline Offline

Activity: 1102
Merit: 1014



View Profile
March 09, 2012, 12:31:13 AM
 #40

I have setup a test store at http://Owneo.com

Note there is no SSL but on the upside, you only have to fill in an email, country, and password to register for checkout.
Pages: « 1 [2] 3 »  All
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!