Author Topic: First ecommerce bitshares cart plugin dev cycle complete  (Read 52677 times)

0 Members and 1 Guest are viewing this topic.

Offline jsidhu

  • Hero Member
  • *****
  • Posts: 1335
    • View Profile
The SMF login plugin has a php file that makes a half-hearted attempt at mimicking the interface to google's oauth library.  It isn't the best thing, one place a change a global variable with an error, another place throws an exception.  I can't remember at the moment why this is. The idea is that one could use existing plugins based on oauth (which may be what facebook uses?) and then just swap out this file and do a few lines of change code.

The alternative is learning enough about Wordpress, or any other CMS/forum to implement the hooks.  SMF is a mess. It has a hook system that requires regexps changing out text etc.  So perhaps one would be better just doing it on their own elsewhere without starting with an oauth library.

There is also Nathan's Proof of Concept source code that pretty much does everything although the flow of the code was confusing to me at first.  It is minimal.

Looking at what you want to do ...

"createuser" has to be done in the logic of your code.  You have a Bitshares account, but you create that inside the client.  There is no concept of "logout" only "loginuser" which basically is being authenticated.  So it doesn't even really login, it is only authenticating.  "logout" would be handled by the web-service system.

This is how it works.  You have to create the token with wallet_start_login (or somesuch) and put that in a button with bts:// protocol.  So then user clicks on that button and it is routed to the local wallet.  The local wallet does the crypto-magic and opens a page that goes back to the authentication URL that was passed in the url via the login button.  So then your web-service processes that and decides whether they're logged in or not via another wallet call.
Thanks, Yea im looking at https://github.com/BitShares/qt_wallet/blob/c4e86d2b4fb79b9fdbe98faa6e11c1e994f20cea/login.php

I'm now thinking about creating another set of plugins for each supporting shopping cart (Connect with bitshares).. instead of tying it into the payment gateway... otherwise Id have to have a way to log you in automatically and then theres magic happening that the user generally isn't used to like autocreating an account with a random password such that they wont be able to login again normally unless going thru the payment gateway again.

If you checkout annonymously... tough you can't see your order status (I think this is just how it works and what customers would expect?). You should login first and then checkout if you want persistence on your part of seeing the orders.
« Last Edit: January 22, 2015, 09:30:18 pm by jsidhu »
Hired by blockchain | Developer
delegate: dev.sidhujag

Offline gamey

  • Hero Member
  • *****
  • Posts: 2253
    • View Profile
The SMF login plugin has a php file that makes a half-hearted attempt at mimicking the interface to google's oauth library.  It isn't the best thing, one place a change a global variable with an error, another place throws an exception.  I can't remember at the moment why this is. The idea is that one could use existing plugins based on oauth (which may be what facebook uses?) and then just swap out this file and do a few lines of change code.

The alternative is learning enough about Wordpress, or any other CMS/forum to implement the hooks.  SMF is a mess. It has a hook system that requires regexps changing out text etc.  So perhaps one would be better just doing it on their own elsewhere without starting with an oauth library.

There is also Nathan's Proof of Concept source code that pretty much does everything although the flow of the code was confusing to me at first.  It is minimal.

Looking at what you want to do ...

"createuser" has to be done in the logic of your code.  You have a Bitshares account, but you create that inside the client.  There is no concept of "logout" only "loginuser" which basically is being authenticated.  So it doesn't even really login, it is only authenticating.  "logout" would be handled by the web-service system.

This is how it works.  You have to create the token with wallet_start_login (or somesuch) and put that in a button with bts:// protocol.  So then user clicks on that button and it is routed to the local wallet.  The local wallet does the crypto-magic and opens a page that goes back to the authentication URL that was passed in the url via the login button.  So then your web-service processes that and decides whether they're logged in or not via another wallet call.
I speak for myself and only myself.

Offline jsidhu

  • Hero Member
  • *****
  • Posts: 1335
    • View Profile
Daniel,

Is there a Bitshares Login extension source base somewhere? I'm not talking about this one: https://github.com/brianbowles/Bitshares-SMF-Login or https://github.com/BitShares/Bitshares-SMF-Login (which is behind by 11 commits btw)...

These are specifically for SMF integration and there are alot of TODO's and checks still to be implemented... either I can spend a few weeks/month to seperate it out to make a standalone plugin or have the author do this probably in half the time (better idea IMO). Also the fact that it is not "clean" right now is probably best to stay away from integrating into our shopping cart stuff for now (plan for next release once there is a standalone/independent bitshares login plugin). I would imagine it would be as simple as creating a secure connection to the wallet using OAuth and then simply have a bunch of callback functions in php called to "createuser" "loginuser" "logoutuser" or whatenot which each shopping cart/integration application would have to implement in different ways.. similar to what I did with this plugin in userfunctions.php... "completeorder" "cancelorder" all have different meanings to every shopping cart. But the rest of the stuff is common and does not change and thus is not touched, not do I care to touch. Easy development process.

I don't know the state of the SMF integration, but the wallet APIs are relatively simple.     I think a great "bridge" would be to implement an oauth wrapper for BitShares.  You would have to "trust" the oauth provider not to fake accounts though.   

http://bytemaster.bitshares.org/article/2014/12/22/BitShares-Login/

It is already implemented in faucet.bitshares.org as well.

Thanks,

Will take a look!
Hired by blockchain | Developer
delegate: dev.sidhujag

Offline bytemaster

Daniel,

Is there a Bitshares Login extension source base somewhere? I'm not talking about this one: https://github.com/brianbowles/Bitshares-SMF-Login or https://github.com/BitShares/Bitshares-SMF-Login (which is behind by 11 commits btw)...

These are specifically for SMF integration and there are alot of TODO's and checks still to be implemented... either I can spend a few weeks/month to seperate it out to make a standalone plugin or have the author do this probably in half the time (better idea IMO). Also the fact that it is not "clean" right now is probably best to stay away from integrating into our shopping cart stuff for now (plan for next release once there is a standalone/independent bitshares login plugin). I would imagine it would be as simple as creating a secure connection to the wallet using OAuth and then simply have a bunch of callback functions in php called to "createuser" "loginuser" "logoutuser" or whatenot which each shopping cart/integration application would have to implement in different ways.. similar to what I did with this plugin in userfunctions.php... "completeorder" "cancelorder" all have different meanings to every shopping cart. But the rest of the stuff is common and does not change and thus is not touched, not do I care to touch. Easy development process.

I don't know the state of the SMF integration, but the wallet APIs are relatively simple.     I think a great "bridge" would be to implement an oauth wrapper for BitShares.  You would have to "trust" the oauth provider not to fake accounts though.   

http://bytemaster.bitshares.org/article/2014/12/22/BitShares-Login/

It is already implemented in faucet.bitshares.org as well.
For the latest updates checkout my blog: http://bytemaster.bitshares.org
Anything said on these forums does not constitute an intent to create a legal obligation or contract between myself and anyone else.   These are merely my opinions and I reserve the right to change them at any time.

Offline jsidhu

  • Hero Member
  • *****
  • Posts: 1335
    • View Profile
Daniel,

Is there a Bitshares Login extension source base somewhere? I'm not talking about this one: https://github.com/brianbowles/Bitshares-SMF-Login or https://github.com/BitShares/Bitshares-SMF-Login (which is behind by 11 commits btw)...

These are specifically for SMF integration and there are alot of TODO's and checks still to be implemented... either I can spend a few weeks/month to seperate it out to make a standalone plugin or have the author do this probably in half the time (better idea IMO). Also the fact that it is not "clean" right now is probably best to stay away from integrating into our shopping cart stuff for now (plan for next release once there is a standalone/independent bitshares login plugin). I would imagine it would be as simple as creating a secure connection to the wallet using OAuth and then simply have a bunch of callback functions in php called to "createuser" "loginuser" "logoutuser" or whatenot which each shopping cart/integration application would have to implement in different ways.. similar to what I did with this plugin in userfunctions.php... "completeorder" "cancelorder" all have different meanings to every shopping cart. But the rest of the stuff is common and does not change and thus is not touched, not do I care to touch. Easy development process.
« Last Edit: January 22, 2015, 07:25:03 pm by jsidhu »
Hired by blockchain | Developer
delegate: dev.sidhujag

Offline jsidhu

  • Hero Member
  • *****
  • Posts: 1335
    • View Profile
I just confirmed that it works now.. I set drupal 6 and drupal 7 to non demo mode

1) paid with usd, worked as expected
2) paid with bts, didnt accept, worked as expected
Hired by blockchain | Developer
delegate: dev.sidhujag

Offline bytemaster

Bitshares login can auto create account on cart.  We will add ability to share shipping address automatically from wallet.
How will it share this address? For some systems i need to specify valid addresses like zipcodes etc to be able to create the account in the shopping cart. If the address is encrypted then im guessing its not given to the shopping cart but the vendor would have to open up the wallet transaction manually to see the address in the bitshares client?

When the BitShares login process makes the POST request to complete the handshake it will provide the information to the site *if* this site asked for it.
For the latest updates checkout my blog: http://bytemaster.bitshares.org
Anything said on these forums does not constitute an intent to create a legal obligation or contract between myself and anyone else.   These are merely my opinions and I reserve the right to change them at any time.

Offline jsidhu

  • Hero Member
  • *****
  • Posts: 1335
    • View Profile
Bitshares login can auto create account on cart.  We will add ability to share shipping address automatically from wallet.
How will it share this address? For some systems i need to specify valid addresses like zipcodes etc to be able to create the account in the shopping cart. If the address is encrypted then im guessing its not given to the shopping cart but the vendor would have to open up the wallet transaction manually to see the address in the bitshares client?
Hired by blockchain | Developer
delegate: dev.sidhujag

Offline jsidhu

  • Hero Member
  • *****
  • Posts: 1335
    • View Profile
I have just tested Drupal 7's checkout and the "Pay Now" link opened my wallet with "BitUSD" rather than "USD" thus I couldn't just click "send".

Then when it took me to my order history it displayed a price of "$0.00".

When I attempted to view the order details it said I didn't have access.   Note: I did not login or register an account. 

All of these shopping carts seem to want users to "log in" and the "log in" / "account creation" process causes a lot of people to lose business.  I highly recommend integrating BitShares login with each of these carts.

Ok so i removed the bit prefix so now it will come up as USD for your order... Your order did show as complete and it shows you have an account so maybe it created it when you checked out and then you needed to login to see order status... Anyways ill look into bitshares login to improve annonymous checkouts.
Hired by blockchain | Developer
delegate: dev.sidhujag

Offline bubble789

  • Full Member
  • ***
  • Posts: 91
    • View Profile
This is what I was talking about.
paypal check out experience, you just need to choose a bitshare account (which you use for shopping) and shipping details are filled in for you.
good that BM has plan for it :)

Bitshares login can auto create account on cart.  We will add ability to share shipping address automatically from wallet.

Offline alt

  • Hero Member
  • *****
  • Posts: 2821
    • View Profile
  • BitShares: baozi
Bitshares login can auto create account on cart.  We will add ability to share shipping address automatically from wallet.
great!  +5% +5% +5%

Offline robrigo

ok cool can you explain comment about bitusd... shouldnt wallet be sent bitusd becase that is the asset name?

bitUSD is referred to as USD on the blockchain. The GUI names it bitUSD in the market, but in your account it is just USD.
Hmm so usd would show up in the pay to wallet dialog? Its not usd though it really is bitusd so why call it usd?
The gui calls it bitusd yet I cant pay by selecting "bitusd"?

bitUSD is the brand. USD is the asset identifier on the blockchain. From the console:

blockchain_list_assets USD

Code: [Select]
ID    SYMBOL NAME                    DESCRIPTION                                     ISSUER                          ISSUED    SUPPLY                     
===========================================================================================================================================================
22    USD    United States Dollar    1 United States dollar                          MARKET                          N/A       810,420.5383 USD

Offline jsidhu

  • Hero Member
  • *****
  • Posts: 1335
    • View Profile
ok cool can you explain comment about bitusd... shouldnt wallet be sent bitusd becase that is the asset name?

bitUSD is referred to as USD on the blockchain. The GUI names it bitUSD in the market, but in your account it is just USD.
Hmm so usd would show up in the pay to wallet dialog? Its not usd though it really is bitusd so why call it usd?
The gui calls it bitusd yet I cant pay by selecting "bitusd"?
« Last Edit: January 22, 2015, 02:30:50 am by jsidhu »
Hired by blockchain | Developer
delegate: dev.sidhujag

Offline robrigo

ok cool can you explain comment about bitusd... shouldnt wallet be sent bitusd becase that is the asset name?

bitUSD is referred to as USD on the blockchain. The GUI names it bitUSD in the market, but in your account it is just USD.

Offline jsidhu

  • Hero Member
  • *****
  • Posts: 1335
    • View Profile
ok cool can you explain comment about bitusd... shouldnt wallet be sent bitusd becase that is the asset name?
Hired by blockchain | Developer
delegate: dev.sidhujag