Plugin Directory

Changeset 2062352


Ignore:
Timestamp:
04/03/2019 03:28:56 PM (7 years ago)
Author:
empatogen
Message:

Release v1.1.2

Location:
woo-xrp/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • woo-xrp/trunk/includes/class-wcxrp-gateway.php

    r2059248 r2062352  
    77 * @class       WC_Gateway_XRP
    88 * @extends     WC_Payment_Gateway
    9  * @version     1.1.1
     9 * @version     1.1.2
    1010 * @package     WooCommerce/Classes/Payment
    1111 * @author      Jesper Wallin
     
    4242            'cexio'    => 'CEX.IO',
    4343            'coinbase' => 'Coinbase',
     44            'dex'      => 'XRPL DEX',
    4445            'kraken'   => 'Kraken',
    4546            'uphold'   => 'Uphold'
     
    293294        $order = wc_get_order($order_id);
    294295
     296        $ledger = new WCXRP_Ledger(
     297            $this->settings['xrp_node'],
     298            $this->settings['xrp_bypass']
     299        );
     300
    295301        /* specify where to obtain our rates from. */
    296         $rates = new WCXRP_Rates($order->get_currency());
    297         $rate  = $rates->get_rate(
     302        $rates = new WCXRP_Rates(
     303            $ledger,
     304            $this->settings['xrp_account'],
     305            $order->get_currency()
     306        );
     307        $rate = $rates->get_rate(
    298308            $this->settings['exchange'],
    299309            $this->exchanges
  • woo-xrp/trunk/includes/class-wcxrp-ledger.php

    r2059248 r2062352  
    8484        return $data->result;
    8585    }
     86
     87    public function book_offers($account, $currency)
     88    {
     89        $taker_pays['currency'] = $currency;
     90        if ($currency === 'USD') {
     91            $taker_pays['issuer'] = 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B';
     92        } elseif ($currency === 'EUR') {
     93            $taker_pays['issuer'] = 'rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq';
     94        } else {
     95            return false;
     96        }
     97
     98        $payload = json_encode([
     99            'method' => 'book_offers',
     100            'params' => [[
     101                'taker' => $account,
     102                "taker_gets" => [
     103                    "currency" => "XRP"
     104                ],
     105                "taker_pays" => $taker_pays,
     106                "limit" => 50
     107            ]]
     108        ]);
     109
     110        $res = wp_remote_post($this->node, [
     111            'body' => $payload,
     112            'headers' => $this->headers
     113        ]);
     114        if (is_wp_error($res) || $res['response']['code'] !== 200) {
     115            return false;
     116        }
     117        if (($data = json_decode($res['body'])) === null) {
     118            return false;
     119        }
     120
     121        foreach ($data->result->offers as $offer) {
     122            if (!isset($offer->owner_funds)) {
     123                continue;
     124            }
     125
     126            $rate = $offer;
     127            break;
     128        }
     129
     130        return $rate->TakerPays->value / ($rate->TakerGets / 1000000);
     131    }
    86132}
  • woo-xrp/trunk/includes/class-wcxrp-rates.php

    r2059248 r2062352  
    44{
    55    private $ecb_cache = 'woo_ecb_rates.xml';
     6    private $ledger = false;
     7    private $account = false;
     8    private $base_currency = false;
    69
    710    /**
    811     * Rates constructor.
     12     * @param $ledger
     13     * @param $account
    914     * @param $base_currency
    1015     */
    11     public function __construct($base_currency)
    12     {
     16    public function __construct($ledger, $account, $base_currency)
     17    {
     18        $this->ledger = $ledger;
     19        $this->account = trim($account);
    1320        $this->base_currency = strtoupper($base_currency);
    1421    }
     
    476483        }
    477484    }
     485
     486    /**
     487     * Get Exchange rate from dex
     488     * @return bool|float|int
     489     */
     490    private function dex()
     491    {
     492        $src = 'EUR';
     493
     494        if ($this->base_currency === 'USD') {
     495            $src = 'USD';
     496        }
     497        $rate = $this->ledger->book_offers(
     498            $this->account,
     499            $src
     500        );
     501
     502        if ($rate === false) {
     503            return false;
     504        }
     505
     506        return $this->to_base($rate, $src);
     507    }
    478508}
  • woo-xrp/trunk/readme.txt

    r2059279 r2062352  
    3434= Which exchanges is supported? =
    3535
    36 You can specify between [Binance](https://www.binance.com/), [Bitbank](https://bitbank.cc/), [Bitfinex](https://www.bitfinex.com/), [Bitlish](https://bitlish.com/), [BitMEX](https://www.bitmex.com/), [Bitrue](https://www.bitrue.com/), [Bitsane](https://bitsane.com/), [Bitstamp](https://www.bitstamp.net/), [Bittrex](https://www.bittrex.com), [Bitcoin Exchange Thailand](https://bx.in.th/), [CEX.IO](https://cex.io/), [Coinbase](https://www.coinbase.com/), [Kraken](https://www.kraken.com/) or [Uphold](https://uphold.com/) as the exchange to use when fetching the XRP rate when the customer is checking out.
     36You can use the [decentralized exchange (DEX)](https://developers.ripple.com/decentralized-exchange.html) on the XRP Ledger, [Binance](https://www.binance.com/), [Bitbank](https://bitbank.cc/), [Bitfinex](https://www.bitfinex.com/), [Bitlish](https://bitlish.com/), [BitMEX](https://www.bitmex.com/), [Bitrue](https://www.bitrue.com/), [Bitsane](https://bitsane.com/), [Bitstamp](https://www.bitstamp.net/), [Bittrex](https://www.bittrex.com), [Bitcoin Exchange Thailand](https://bx.in.th/), [CEX.IO](https://cex.io/), [Coinbase](https://www.coinbase.com/), [Kraken](https://www.kraken.com/) or [Uphold](https://uphold.com/) as the exchange to get the XRP rate when your customer is checking out.
    3737
    3838= Which base currencies are supported? =
     
    5252== Changelog ==
    5353
     54= 1.1.2 =
     55* Add the decentralized exchange. (DEX)
     56* Fix the text style on the checkout page.
     57
    5458= 1.1.1 =
    5559* Add new exchanges. (Bitsane, CEX.IO, Coinbase, Uphold)
    5660* Add missing sanitation checks for user input.
    57 * Add new order status (Overpaid) for when a customer pays too much.
     61* Add new order status (Overpaid) for when a customer pays too much.
    5862* Fix potential rounding error when processing payments.
    5963* Fix a bug where the payment gateway was loaded twice.
     
    8589== Upgrade notice ==
    8690
     91= 1.1.2 =
     92This version prevents certain themes from breaking the XRP address on the checkout page. It also adds the decentralized exchange that lives on the XRP Ledger.
     93
    8794= 1.1.1 =
    8895This version improves the overall payment processing and making it more robust. It fixes a potential rounding error when handling payments and it makes then webhook service retry multiple times if we're unable to talk to the XRP network. This version also make it easier to see when a customer pays too much, as the order will get the status "Overpaid".
  • woo-xrp/trunk/views/thank_you.php

    r2059248 r2062352  
    55    <tr>
    66        <th><?php _e('XRP Account', 'wc-gateway-xrp'); ?></th>
    7         <td id="xrp_account"><?php echo esc_html(get_option('woocommerce_xrp_settings')['xrp_account']) ?></td>
     7        <td id="xrp_account" style="text-transform: none !important"><?php echo esc_html(get_option('woocommerce_xrp_settings')['xrp_account']) ?></td>
    88    </tr>
    99    <tr>
  • woo-xrp/trunk/woocommerce-xrp.php

    r2059248 r2062352  
    44 * Plugin URI: http://github.com/empatogen/woocommerce-xrp
    55 * Description: A payment gateway for WooCommerce to accept <a href="https://ripple.com/xrp">XRP</a> payments.
    6  * Version: 1.1.1
     6 * Version: 1.1.2
    77 * Author: Jesper Wallin
    88 * Author URI: https://ifconfig.se/
     
    3030
    3131/* define constants */
    32 define('WCXRP_VERSION', '1.1.1');
     32define('WCXRP_VERSION', '1.1.2');
    3333define('WCXRP_TEXTDOMAIN', 'wc-gateway-xrp');
    3434define('WCXRP_NAME', 'Woocommerce XRP');
Note: See TracChangeset for help on using the changeset viewer.