Changeset 2062352
- Timestamp:
- 04/03/2019 03:28:56 PM (7 years ago)
- Location:
- woo-xrp/trunk
- Files:
-
- 6 edited
-
includes/class-wcxrp-gateway.php (modified) (3 diffs)
-
includes/class-wcxrp-ledger.php (modified) (1 diff)
-
includes/class-wcxrp-rates.php (modified) (2 diffs)
-
readme.txt (modified) (3 diffs)
-
views/thank_you.php (modified) (1 diff)
-
woocommerce-xrp.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
woo-xrp/trunk/includes/class-wcxrp-gateway.php
r2059248 r2062352 7 7 * @class WC_Gateway_XRP 8 8 * @extends WC_Payment_Gateway 9 * @version 1.1. 19 * @version 1.1.2 10 10 * @package WooCommerce/Classes/Payment 11 11 * @author Jesper Wallin … … 42 42 'cexio' => 'CEX.IO', 43 43 'coinbase' => 'Coinbase', 44 'dex' => 'XRPL DEX', 44 45 'kraken' => 'Kraken', 45 46 'uphold' => 'Uphold' … … 293 294 $order = wc_get_order($order_id); 294 295 296 $ledger = new WCXRP_Ledger( 297 $this->settings['xrp_node'], 298 $this->settings['xrp_bypass'] 299 ); 300 295 301 /* 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( 298 308 $this->settings['exchange'], 299 309 $this->exchanges -
woo-xrp/trunk/includes/class-wcxrp-ledger.php
r2059248 r2062352 84 84 return $data->result; 85 85 } 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 } 86 132 } -
woo-xrp/trunk/includes/class-wcxrp-rates.php
r2059248 r2062352 4 4 { 5 5 private $ecb_cache = 'woo_ecb_rates.xml'; 6 private $ledger = false; 7 private $account = false; 8 private $base_currency = false; 6 9 7 10 /** 8 11 * Rates constructor. 12 * @param $ledger 13 * @param $account 9 14 * @param $base_currency 10 15 */ 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); 13 20 $this->base_currency = strtoupper($base_currency); 14 21 } … … 476 483 } 477 484 } 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 } 478 508 } -
woo-xrp/trunk/readme.txt
r2059279 r2062352 34 34 = Which exchanges is supported? = 35 35 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 thecustomer is checking out.36 You 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. 37 37 38 38 = Which base currencies are supported? = … … 52 52 == Changelog == 53 53 54 = 1.1.2 = 55 * Add the decentralized exchange. (DEX) 56 * Fix the text style on the checkout page. 57 54 58 = 1.1.1 = 55 59 * Add new exchanges. (Bitsane, CEX.IO, Coinbase, Uphold) 56 60 * 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. 58 62 * Fix potential rounding error when processing payments. 59 63 * Fix a bug where the payment gateway was loaded twice. … … 85 89 == Upgrade notice == 86 90 91 = 1.1.2 = 92 This 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 87 94 = 1.1.1 = 88 95 This 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 5 5 <tr> 6 6 <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> 8 8 </tr> 9 9 <tr> -
woo-xrp/trunk/woocommerce-xrp.php
r2059248 r2062352 4 4 * Plugin URI: http://github.com/empatogen/woocommerce-xrp 5 5 * Description: A payment gateway for WooCommerce to accept <a href="https://ripple.com/xrp">XRP</a> payments. 6 * Version: 1.1. 16 * Version: 1.1.2 7 7 * Author: Jesper Wallin 8 8 * Author URI: https://ifconfig.se/ … … 30 30 31 31 /* define constants */ 32 define('WCXRP_VERSION', '1.1. 1');32 define('WCXRP_VERSION', '1.1.2'); 33 33 define('WCXRP_TEXTDOMAIN', 'wc-gateway-xrp'); 34 34 define('WCXRP_NAME', 'Woocommerce XRP');
Note: See TracChangeset
for help on using the changeset viewer.