Coder Social home page Coder Social logo

woocommerce-stellar's Introduction

IMPORTANT: This code is made available in the hope that it will be useful, but without any warranty. See the GNU General Public License for more details. Automattic or WooCommerce support services are also not available to assist with the use of this code.

WooCommerce Stellar Gateway

Stellar is a protocol for sending and receiving money in any pair of currencies.

With the WooCommerce Stellar extension, you can accept payment for orders in your WooCommerce store using the Stellar protocol (and currency).

Stellar WooCommerce Video

After installing the extension, you will be able to sell in any currency which your Stellar account can accept.

You can add new currencies to your account using the official Stellar Account Viewer.

The Stellar protocol also has a built in currency, named Lumens, with the currency code XLM. The WooCommerce Stellar extension adds XLM as an option for your store's currency.

To sell items in XLM:

  1. Go to: WooCommerce > Settings > General administration screen
  2. In the Currency field, search for Stellar
  3. Select Stellar (XLM)
  4. Save the settings

But you don't have to sell in Stellar to use Stellar, you can (theoretically) sell in any currency, that's what's so stellar about Stellar!

Demo Store

Want to try it out?

Purchase a Stellar collector item from the Prospress Stellar Store.

The proceeds of every sale are donated to the Stellar foundation.

Installation

  1. Upload the plugin's files to the /wp-content/plugins/ directory of your WordPress site
  2. Activate the plugin through the Plugins menu in WordPress
  3. Visit the WooCommerce > Settings > Checkout > Stellar administration screen
  4. Select Enable Stellar.
  5. Enter your Stellar Address
  6. Save your settings

You're ready to start selling via Stellar!

Optional: set your store's currency to Stellar (XLM).

FAQs

Why is my Stellar account showing as invalid?

Your Stellar account may display as invalid if:

  1. you have entered an incorrect Stellar address
  2. your account has a balance of 0 Stellar - to avoid spam accounts, accounts must have a minimum of 20 Stellar

Why isn't Stellar displaying as a payment method?

When you enter you account address, the extension will check your account to see which currencies it accepts.

If your store's currency is not in the set of currencies your Stellar account accepts, then the extension will not display Stellar as a payment method on checkout.

To have it display, you can either:

  1. change your store's currency to Stellar (XLM)
  2. add the store's currency to your Stellar account

What currencies can I accept via Stellar?

Stellar will attempt to find a path between the currency/currencies your customer holds a balance in, and the currency you are selling in.

In theory, this means Stellar can be used to sell in any currency.

In practice, your customers may only be able to pay in currencies in which they already hold a balance. Because the Stellar network is still young, the available paths between currencies are limited. You may have trouble selling in less popular currencies, like AUD or NZD, to customers who do not hold a balance in this currency. Rest assured, things are moving fast and it won't be too long before your customers in Hanoi can pay in Dong (VND), while you'll receive it in the mighty greenback (USD).

How can I add new currencies to my Stellar account?

  1. Login to your Stellar Dashboard
  2. Click the add a currency link (displayed under your balance)
  3. Enter the full URL of a Stellar gateway which supports multiple currencies (list of gateways)
  4. Add the gateway to your account

Refer to the Stellar docs article for more information on adding currencies to your account.

Stellar Add Currency screenshot

How can I sell with Stellar from multiple WooCommerce Stores?

To sell from multiple WooCommerce stores, you will need to create a new Stellar account for each store.

Because the Stellar protocol only accepts numerical Destination Tags, there is no way to prefix them for different stores (e.g. JFK-12358 or SFO-1321).

This restriction makes it unfeasible to use the same Stellar account on more than one site. The good news is, creating a Stellar account is both easy and free. You'll just need to seed each account with a few hundred Stellar before you can use them to accept payments.

What is this pesky notice about Destination Tags?

The WooCommerce Stellar extension uses Destination Tags to match an order with a payment.

Stellar accounts can be configured to require Destination Tags on all incoming payments or accept payments without a corresponding Destination Tag.

If a Stellar account does not require Destination Tags, customers are able to make a payment that can not be matched with an order. This means a store manager will need to manually find the payment in their account and mark the order in WooCommerce as paid.

When a Stellar address is saved on WooCommerce > Settings > Checkout > Stellar administration screen, the extension checks the account to see if it requires Destination Tags.

If the account does not require Destination Tags, the WooCommerce Stellar extension encourages you to configure your account to require Destination Tags and avoid transactions that can not be automatically matched.

The notice asks for my Secret Key. Isn't it dangerous to share my Secret Key?

Yes!

The Destination Tags notice provides a convenient way to configure your account to require Destination Tags (as there is no graphical interface available via the Stellar client to set this, yet).

In order to configure your account, the extension needs your Stellar Secret Key.

The extension tries to be as secure as possible with your sensitive key. It sends it directly from your browser to Stellar.org. It does not send your key to your web server, or any other web server, and it definitely does not store your key anywhere.

This greatly reduces the risk of your secret key being stolen by an attacker; however, if you have malicious code running in your browser, for example, some JavaScript served by a hacked WordPress plugin, that code will be able to steal your Secret Key (and do all sorts of other nasty things with your site).

If you would prefer not to enter your Secret Key in your browser, you can configure your account manually using the AccountSet API command.

Where can I find my Stellar account's Secret Key?

  1. Login to your Stellar Dashboard
  2. Click your username in the header menu
  3. Scroll to the bottom of the Settings page
  4. Click Reveal next to the Secret Key setting

For a visual guide, checkout the screenshots section.

I'm having trouble, where can I get help?

If you've found a bug in the extension or have a feature request, please open a new issue.

If you have a general question, post a topic in the WordPress.org WooCommerce Stellar Forum.

License

The WooCommerce Stellar extension is released under the GPLv3 license.

Copyright (C) 2014 Prospress, Inc.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with WooCommerce Stellar Gateway. If not, see http://www.gnu.org/licenses/.


woocommerce-stellar's People

Contributors

thenbrent avatar mattallan avatar tcope25 avatar

Stargazers

MAD CITY MULTIMEDIA avatar p1slave avatar Nikolay Kolev avatar Makafui G. Dzivenu avatar Adnan Siddiqi avatar Luke Cavanagh avatar  avatar Fredrik Forsmo avatar  avatar Noah Spirakus avatar Joyce Kim avatar Sébastien Dumont avatar  avatar

Watchers

César D. Rodas avatar Ron Rennick avatar Jason Conroy avatar Sébastien Dumont avatar Joyce Kim avatar James Cloos avatar Sarah avatar Noah Spirakus avatar Zack Bishop avatar Nick avatar  avatar Joey Ricketts avatar Kai-Li Yen  avatar  avatar Ronn Davis avatar MAD CITY MULTIMEDIA avatar

woocommerce-stellar's Issues

Create Settings Object in WC_Stellar

At the moment, a number of functions within WC_Stellar call get_option( 'woocommerce_stellar_settings' ) to access the gateway's settings. We can centralise that in WC_Stellar::__construct() to make just the only function call and also save repeating ourselves (in case we need to change the settings key or something later).

WooCommerce Active Check

Add a check on activation for WooCommerce, and if it's not active display a notice with a link on how to install it.

Payments in USD then convert to XLM

The problem of using the currency XLM is that I cannot accept payments using other cryptocurrencies or "normal" currencies. So the best option will be:

  1. Accept the payment in USD
  2. Do some math (exchange rate) and convert the USD price to XLM.
  3. The client pays in XLM.

I would help, but I don't have idea how to code for now :(

Remove loop when confirming payment

Because Stellar doesn't take as long to confirm a transaction (like Bitcoin) we don't really need to add the countdown or loop confirmation. Instead, we can just check when the button is clicked.

Add check for destination tag requirement in admin

When the Stellar settings page is loaded with a account ID, check if the account requires destination tags. If it doesn't, include an admin header explaining why it should and potentially a button to set it from the admin.

Design of Stellar Settings Page

To improve the design of the WooCommerce > Settings > Checkout > Stellar admin screen, we should:

  • remove the banner at the top of screen
  • include information about signing up (using /templates/checkout/stellar-registration.php or similar)

Confirm Transaction

@seb86 it's close, very close.

The only issue is that it's not confirming the transaction. I made a few fixes to the JS, but think the JSON is being malformed.

I'll have a look again tomorrow unless you get to it first. :)

Use of custom order status

@seb86 we don't need to use the custom wc-verify-stellar order status. WooCommerce's pending status is semantically accurate and it has other benefits, like allowing the customer to change their mind after placing the order to use a different payment method.

I suspect the reason you wanted to use a wc-verify-stellar status was to use in the query for orders awaiting payment via Stellar with the Cron job; however, you can query using the standard pending status and checking the payment_method post meta value instead.

WooCommerce Stellar Plugin doesn't work.

Hi, Thank you for your share.
I've installed this plugin in wordpress 4.2.3 and the following warning has been appeared.

"Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'WC_Stellar' not found in C:\xampp\htdocs\wordpress\wp-includes\plugin.php on line 496"

Why this happens and what's the solution?
Thanx.

Saving Settings Bugs

When saving the settings:

  • if no Address was previously input, when adding an address, we still receive the "Please enter.." error (despite the address having been successfully entered)
  • if no address is currently entered, but previously there was an address that did not require destionation tags, the "Your Stellar account allows transactions without a Destination Tag" notice is displayed (despite their being no Stellar Account set)
  • the previous accounts currencies are not wiped unless they are replaced by new currencies (i.e. if checking for currencies fails, the previous currency values are displayed, despite being for a different account)

Notice when no account address set

Before setting an account address, the extension throws the notice:

PHP Notice:  Undefined index: account_address in /Users/thenbrent/Dropbox/MAMP/htdocs/subs20/wp-content/plugins/woocommerce-stellar/woocommerce-stellar-gateway.php on line 414

Documentation

We need to write up some documentation on:

  • how to add a currency to your Stellar account via the Stellar Client: https://cloudup.com/cGwJdZNIx9x
  • how/where to find the Secret Key on the Stellar client settings page

Cache Account Currencies

With #22, we show the Stellar payment method only when the Stellar account accepts the currency for the transaction; however, we're polling the API every time checkout is loaded.

There's a couple of issues with this:

  1. currencies probably won't change that often, so we should cache them in the WP database rather than polling the server every time someone hits the checkout; and
  2. if the Stellard we check against is down, then the API request will return a WP error, which means Stellar won't be available as a payment method, so even though the transaction might be for a valid currency, the customer can't place the order because Stellard is down (and it does seem to go down quite a bit atm). Using a cached copy of the allowed currencies (in in the payment gateway options) prevents this.

I think we can safely request the account's currencies only when the WC Stellar settings are saved or updated (e.g. the WooCommerce > Settings > Checkout > Stellar from is submitted).

We can also display the valid currencies on the WooCommerce > Settings > Checkout > Stellar settings page so an admin knows what currencies are supported on that store (and we can prompt them to update their settings if they have added new currencies).

Handle Activation with WooCommerce is not installed

There is code to disable the plugin and handle deactivation when WooCommerce is not active - but it doesn't work.

Activation causes the error: PHP Fatal error: Call to undefined function deactivate_plugins().

Subscriptions has some pretty good code to return from the main woocommerce-subscriptions.php plugin file if WooCommerce isn't active (meaning Subscriptions can remain active, but not doing anything when WooCommerce is active to save having to reactivate it when WooCommerce is activated).

This code can be used in Stellar extension too.

Notices with Currency Display

[06-Oct-2014 23:36:23 UTC] PHP Warning:  implode() [<a href='function.implode'>function.implode</a>]: Invalid arguments passed in /wp-content/plugins/woocommerce-stellar/includes/class-wc-gateway-stellar.php on line 124
[06-Oct-2014 23:36:23 UTC] PHP Warning:  array_pop() expects parameter 1 to be array, null given in /wp-content/plugins/woocommerce-stellar/includes/class-wc-gateway-stellar.php on line 124

Remove Stellar PHP SDK

Although creating a PHP SDK is a great idea, none of the functions in the SDK worked, and only 1 was required by the actually plugin.

The two that didn't work have been removed, but we can also refactor the remaining two methods in Stellar and move them into WC_Stellar.

This also make it easier to implement #8 because we know that WP HTTP API functions will be available within WC_Stellar.

Efficiency of WP Cron Check

At the moment, the woocommerce_stellar_cron_job() function loops over orders awaiting payment and polls the Stellar API for each order. However, we really only need to poll the Stellar API once and loop over those transactions. We also only need to loop over the transactions since we last checked the ledger.

To do this, we need to refactor the validate_stellar_payment() to separate the logic for getting a list of transactions by order ID.

Add WP.org readme.txt file

With FAQs, installation instructions, details of Stellar, including registration link, and a few screenshots.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.