Changeset 1959692
- Timestamp:
- 10/20/2018 10:25:40 AM (7 years ago)
- Location:
- satoshipay/trunk
- Files:
-
- 3 edited
-
readme.txt (modified) (3 diffs)
-
satoshipay.php (modified) (4 diffs)
-
src/SatoshiPay/Api/Client.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
satoshipay/trunk/readme.txt
r1951997 r1959692 5 5 Requires at least: 4.4.5 6 6 Tested up to: 4.9.8 7 Stable tag: 1. 47 Stable tag: 1.5 8 8 License: MIT 9 9 License URI: https://opensource.org/licenses/MIT … … 80 80 == Changelog == 81 81 82 = 1.5 = 83 84 * Fixed bug where API credentials cannot be added or updated. 85 82 86 = 1.4 = 83 87 … … 88 92 = 1.3 = 89 93 90 * Fixed wrong versioning. 94 * Fixed wrong versioning. 91 95 92 96 = 1.2 = -
satoshipay/trunk/satoshipay.php
r1951997 r1959692 12 12 * Plugin URI: https://wordpress.org/plugins/satoshipay/ 13 13 * Description: Integrates SatoshiPay into WordPress. Quick start: 1) Select SatoshiPay from the left-hand admin menu, 2) add SatoshiPay API credentials, 3) edit a post, 4) activate "Paid Post" in SatoshiPay meta box, 5) set a price, 6) publish and view post. The SatoshiPay widget will appear and allow readers to pay for the post. 14 * Version: 1. 414 * Version: 1.5 15 15 * Author: SatoshiPay 16 16 * Author URI: https://satoshipay.io … … 30 30 // Plugin version, used in user-agent string for API calls; keep in sync with 31 31 // version in plugin description above! 32 define('SATOSHIPAY_VERSION', '1. 4');32 define('SATOSHIPAY_VERSION', '1.5'); 33 33 34 34 // Plugin root file … … 39 39 40 40 // Read environment variables, will override config 41 if (!defined('SATOSHIPAY_API_URL') && getenv('SATOSHIPAY_API_URL')) { 42 define('SATOSHIPAY_API_URL', getenv('SATOSHIPAY_API_URL')); 41 if (!defined('SATOSHIPAY_PRODUCT_SERVICE_URL') && getenv('SATOSHIPAY_PRODUCT_SERVICE_URL')) { 42 define('SATOSHIPAY_PRODUCT_SERVICE_URL', getenv('SATOSHIPAY_PRODUCT_SERVICE_URL')); 43 } 44 if (!defined('SATOSHIPAY_PUBLISHER_SERVICE_URL') && getenv('SATOSHIPAY_PUBLISHER_SERVICE_URL')) { 45 define('SATOSHIPAY_PUBLISHER_SERVICE_URL', getenv('SATOSHIPAY_PUBLISHER_SERVICE_URL')); 43 46 } 44 47 if (!defined('SATOSHIPAY_CLIENT_URL') && getenv('SATOSHIPAY_CLIENT_URL')) { … … 65 68 define('SATOSHIPAY_SCRIPT_POST', plugins_url('assets/js/script_post.js', __FILE__)); 66 69 } 67 if (!defined('SATOSHIPAY_API_URL')) { 68 define('SATOSHIPAY_API_URL', 'https://api.satoshipay.io/mainnet'); 70 if (!defined('SATOSHIPAY_PRODUCT_SERVICE_URL')) { 71 define('SATOSHIPAY_PRODUCT_SERVICE_URL', 'https://api.satoshipay.io/v2'); 72 } 73 if (!defined('SATOSHIPAY_PUBLISHER_SERVICE_URL')) { 74 define('SATOSHIPAY_PUBLISHER_SERVICE_URL', 'https://api.satoshipay.io/mainnet/publisher'); 69 75 } 70 76 if (!defined('SATOSHIPAY_CLIENT_URL')) { -
satoshipay/trunk/src/SatoshiPay/Api/Client.php
r1948680 r1959692 18 18 * @var string 19 19 */ 20 protected $ apiEndpointPrefix = '/v2';21 22 /** 23 * @var string 24 */ 25 protected $ serverUrl = '';20 protected $productServiceUrl = ''; 21 22 /** 23 * @var string 24 */ 25 protected $publisherServiceUrl = ''; 26 26 27 27 /** … … 48 48 * Constructor. 49 49 * 50 * @param array $options $serverUrl 50 * @param array $options $productServiceUrl 51 * @param array $options $publisherServiceUrl 51 52 * @param string $authKey 52 53 * @param string $authSecret … … 54 55 public function __construct(array $config = array()) 55 56 { 56 $this->serverUrl = SATOSHIPAY_API_URL; 57 $this->productServiceUrl = SATOSHIPAY_PRODUCT_SERVICE_URL; 58 $this->publisherServiceUrl = SATOSHIPAY_PUBLISHER_SERVICE_URL; 57 59 $this->defaultMaxProductPrice = SATOSHIPAY_DEFAULT_MAX_PRODUCT_PRICE; 58 60 … … 82 84 $goodData['price'] *= 10000000; 83 85 84 $url = rtrim($this-> serverUrl, '/') . $this->apiEndpointPrefix. '/goods';86 $url = rtrim($this->productServiceUrl, '/') . '/goods'; 85 87 $body = json_encode($goodData); 86 88 $responseData = json_decode($this->post($url, $body), true); … … 108 110 $goodData['price'] *= 10000000; 109 111 110 $url = rtrim($this-> serverUrl, '/') . $this->apiEndpointPrefix. '/goods/' . (string)$goodId;112 $url = rtrim($this->productServiceUrl, '/') . '/goods/' . (string)$goodId; 111 113 $body = json_encode($goodData); 112 114 $responseData = json_decode($this->put($url, $body), true); … … 127 129 return; 128 130 } 129 $url = rtrim($this-> serverUrl, '/') . $this->apiEndpointPrefix. '/goods/' . (string)$goodId;131 $url = rtrim($this->productServiceUrl, '/') . '/goods/' . (string)$goodId; 130 132 $responseData = json_decode($this->delete($url), true); 131 133 return isset($responseData['id']) ? $responseData['id'] : 0; … … 140 142 public function testCredentials() 141 143 { 142 $url = rtrim($this->serverUrl, '/') . $this->apiEndpointPrefix . '/permissions'; 144 $url = rtrim($this->productServiceUrl, '/') . '/permissions'; 145 $args = array( 146 'method' => 'GET' 147 ); 148 143 149 try { 144 150 $request = $this->request($url, $args); … … 158 164 public function batch(array $batchObjects) 159 165 { 160 $url = rtrim($this-> serverUrl, '/') . $this->apiEndpointPrefix. '/batch';166 $url = rtrim($this->productServiceUrl, '/') . '/batch'; 161 167 $body = json_encode(array("requests" => $batchObjects)); 162 168 $responseData = json_decode($this->post($url, $body), true); … … 176 182 return; 177 183 } 178 $url = rtrim($this-> serverUrl, '/') . '/publisher/' . (string)$publisherId . '/limits';184 $url = rtrim($this->publisherServiceUrl, '/') . '/' . (string)$publisherId . '/limits'; 179 185 $responseData = json_decode($this->get($url), true); 180 186 return isset($responseData['maxProductPrice']) ? $responseData['maxProductPrice'] : $this->defaultMaxProductPrice;
Note: See TracChangeset
for help on using the changeset viewer.