Changeset 2850806
- Timestamp:
- 01/19/2023 01:21:03 AM (3 years ago)
- Location:
- sargapay/trunk
- Files:
-
- 7 edited
-
admin/class-sargapay-admin.php (modified) (3 diffs)
-
includes/class-sargapay.php (modified) (2 diffs)
-
paymentGateway/cardano/assets/js/hotWallets.js (modified) (2 diffs)
-
paymentGateway/cardano/class-sargapay-confirm-payment.php (modified) (1 diff)
-
paymentGateway/cardano/class-sargapay-gateway.php (modified) (8 diffs)
-
readme.txt (modified) (1 diff)
-
sargapay.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sargapay/trunk/admin/class-sargapay-admin.php
r2827431 r2850806 337 337 } else { 338 338 $api_call = $gateway->check_API_KEY(1, $blockfrost_test_key); 339 if ($api_call === 1) return __('Error: blockforst testnet api call failed ', 'sargapay');339 if ($api_call === 1) return __('Error: blockforst testnet api call failed >>>' . $api_call, 'sargapay'); 340 340 } 341 341 } else { … … 367 367 368 368 $markup = $request->get_param('markup'); 369 if (empty($markup)) { 370 return __('Error: markup can\'t be empty', 'sargapay'); 371 } else if (!is_numeric($markup)) { 369 if (!is_numeric($markup)) { 372 370 return __('Error: markup is not a number', 'sargapay'); 373 371 } … … 376 374 if (empty($time_wait)) { 377 375 return __('Error: time to wait can\'t be empty', 'sargapay'); 378 } else if (!is_numeric($ markup)) {376 } else if (!is_numeric($time_wait)) { 379 377 return __('Error: time to wait is not a number', 'sargapay'); 380 378 } -
sargapay/trunk/includes/class-sargapay.php
r2827431 r2850806 144 144 require_once SARGAPAY_PATH . 'paymentGateway/cardano/functions/sargapay-thank-you-page.php'; 145 145 require_once SARGAPAY_PATH . 'paymentGateway/cardano/functions/sargapay-cancel-order.php'; 146 require_once SARGAPAY_PATH . 'paymentGateway/cardano/functions/sargapay-cardano-currency.php'; 146 147 147 148 add_action('plugins_loaded', [$this, 'sargapay_init_gateway_class']); 148 149 // Add QR and Payment Address to thank you page 149 150 add_filter('woocommerce_thankyou_order_received_text', 'sargapay_thank_you_text', 20, 2); 151 add_filter('woocommerce_currencies', 'add_sarga_cardano_currency'); 152 add_filter('woocommerce_currency_symbol', 'add_sarga_cardano_currency_symbol', 10, 2); 150 153 } 151 154 … … 227 230 $this->loader->add_action('admin_menu', $plugin_admin, 'add_admin_menu'); 228 231 $this->loader->add_action('wp_register_script', $plugin_admin, 'register_admin_resources'); 229 $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_resources'); 232 $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_resources'); 230 233 $this->loader->add_action('init', $plugin_admin, 'register_admin_resources'); 231 234 $this->loader->add_action('init', $plugin_admin, 'add_translation_json'); -
sargapay/trunk/paymentGateway/cardano/assets/js/hotWallets.js
r2827431 r2850806 61 61 const amount = BigInt(amount_span.innerText * 1000000) 62 62 63 const net = network == 1 ? "Mainnet" : " Testnet"63 const net = network == 1 ? "Mainnet" : "Preview" 64 64 const url = `https://cardano-${net.toLowerCase()}.blockfrost.io/api/v0` 65 65 const lucid = await Lucid.new(new Blockfrost(url, apikey), net) … … 84 84 85 85 console.log(txHash) 86 const explorerUrl = network == 1 ? "https://cexplorer.io/tx/" : "https:// testnet.cexplorer.io/tx/"86 const explorerUrl = network == 1 ? "https://cexplorer.io/tx/" : "https://preview.cexplorer.io/tx/" 87 87 88 88 //Notify Success -
sargapay/trunk/paymentGateway/cardano/class-sargapay-confirm-payment.php
r2827431 r2850806 119 119 $stake_key = substr($payment_address, 53, -6); 120 120 } else { 121 $url_network = 'https://cardano-testnet.blockfrost.io/api/v0/';121 $url_network = "https://cardano-preview.blockfrost.io/api/v0/"; 122 122 $api_key = WC()->payment_gateways->payment_gateways()['sargapay_cardano']->blockfrost_test_key; 123 123 $stake_key = substr($payment_address, 58, -6); -
sargapay/trunk/paymentGateway/cardano/class-sargapay-gateway.php
r2827431 r2850806 224 224 { 225 225 if ($testmode == 1) { 226 $url = "https://cardano- testnet.blockfrost.io/api/v0/";226 $url = "https://cardano-preview.blockfrost.io/api/v0/"; 227 227 $network = "TESTNET"; 228 228 } else { … … 260 260 } 261 261 262 public function payment_fields() 263 { 264 // Get supported currencies 262 private function getCurrency() 263 { 264 $result = new stdClass(); 265 266 if (strtolower(get_woocommerce_currency()) === "sargacardano") { 267 $result->currency = "ADA"; 268 $result->symbol = get_woocommerce_currency_symbol(); 269 return $result; 270 } 271 272 // Get supported currencies coingeeko 265 273 $request = wp_remote_retrieve_body(wp_remote_get('https://api.coingecko.com/api/v3/simple/supported_vs_currencies')); 266 274 $supported_currencies = json_decode($request, true); 267 // check if the wc currency is supported if is not we remplace it with the plugin options currency 275 276 // check if the wc currency is supported if is not we remplace it with the plugin options currency 268 277 if (in_array(strtolower(get_woocommerce_currency()), $supported_currencies)) { 269 $ currency = get_woocommerce_currency();270 $ symbol = get_woocommerce_currency_symbol();278 $result->currency = get_woocommerce_currency(); 279 $result->symbol = get_woocommerce_currency_symbol(); 271 280 } else { 272 281 $currency = $this->currency; 273 $currency === "USD" ? $symbol = "$" : $symbol = "€"; 274 } 275 $request = wp_remote_retrieve_body(wp_remote_get('https://api.coingecko.com/api/v3/simple/price?ids=cardano&vs_currencies=' . $currency)); 276 $data = json_decode($request, true); 277 if (count($data) == 1) { 282 switch ($currency) { 283 case "ADA": 284 $result->symbol = "₳"; 285 break; 286 case "EUR": 287 $result->symbol = "€"; 288 break; 289 default: 290 $result->symbol = "$"; 291 break; 292 } 293 } 294 295 return $result; 296 } 297 298 public function payment_fields() 299 { 300 $currencyObj = $this->getCurrency(); 301 $currency = $currencyObj->currency; 302 $symbol = $currencyObj->symbol; 303 if ($currency !== "ADA") { 304 $request = wp_remote_retrieve_body(wp_remote_get('https://api.coingecko.com/api/v3/simple/price?ids=cardano&vs_currencies=' . $currency)); 305 $data = json_decode($request, true); 306 } 307 if ($currency === "ADA" || count($data) == 1) { 278 308 if ($this->testmode) { 279 309 ?> … … 290 320 $cryptoMarkup = $cryptoMarkupPercent / 100.0; 291 321 $cryptoPriceRatio = 1.0 + $cryptoMarkup; 292 $fiat = $data['cardano'][array_key_first($data['cardano'])]; 322 323 $fiat = $currency === "ADA" ? 1 : $data['cardano'][array_key_first($data['cardano'])]; 293 324 global $wp; 294 if (isset($wp->query_vars['order-pay'])){325 if (isset($wp->query_vars['order-pay'])) { 295 326 $order_id = $wp->query_vars['order-pay']; 296 327 $order = new WC_Order($order_id); 297 328 $fiat_total_order = $order->get_total(); 298 } else{329 } else { 299 330 $fiat_total_order = WC()->cart->get_totals()["total"]; 300 331 } … … 304 335 <p><?php echo esc_html($instrucciones); ?></p> 305 336 <div style='text-align:center;'> 306 <p><?php echo __("Currency", 'sargapay') . " = " . esc_html($currency); ?></p> 307 <p><?php echo __("ADA Price", 'sargapay') . " = " . esc_html($symbol) . " " . esc_html($fiat); ?></p> 337 <?php if ($currency !== "ADA") { ?> 338 <p><?php echo __("Currency", 'sargapay') . " = " . esc_html($currency); ?></p> 339 <p><?php echo __("ADA Price", 'sargapay') . " = " . esc_html($symbol) . " " . esc_html($fiat); ?></p> 340 <?php } ?> 308 341 <p><?php echo __("ADA Total", 'sargapay') . " = " . esc_html($total_ada) . "*"; ?></p> 309 342 </div> … … 332 365 { 333 366 global $woocommerce; 334 $order = new WC_Order($order_id); 367 $order = new WC_Order($order_id); 335 368 // Mark as on-hold (we're awaiting the confirmations) 336 369 $order->update_status('on-hold', __('Awaiting valid payment', 'woocommerce')); … … 338 371 // GENERATE PAYMENT ADDRESS 339 372 $total_ada = 0; 340 // Get supported currencies 341 $request = wp_remote_retrieve_body(wp_remote_get('https://api.coingecko.com/api/v3/simple/supported_vs_currencies')); 342 $supported_currencies = json_decode($request, true); 343 // check if the wc currency is supported if is not we remplace it with the plugin options currency 344 if (in_array(strtolower(get_woocommerce_currency()), $supported_currencies)) { 345 $currency = get_woocommerce_currency(); 346 } else { 347 $currency = $this->currency; 348 } 349 $request = wp_remote_retrieve_body(wp_remote_get('https://api.coingecko.com/api/v3/simple/price?ids=cardano&vs_currencies=' . $currency)); 350 $data = json_decode($request, true); 351 if (count($data) == 1) { 373 $currencyObj = $this->getCurrency(); 374 $currency = $currencyObj->currency; 375 if ($currency !== "ADA") { 376 $request = wp_remote_retrieve_body(wp_remote_get('https://api.coingecko.com/api/v3/simple/price?ids=cardano&vs_currencies=' . $currency)); 377 $data = json_decode($request, true); 378 } 379 if ($currency === "ADA" || count($data) == 1) { 352 380 353 381 $cryptoMarkupPercent = $this->markup; … … 359 387 $cryptoMarkup = $cryptoMarkupPercent / 100.0; 360 388 $cryptoPriceRatio = 1.0 + $cryptoMarkup; 361 $fiat = $ data['cardano'][array_key_first($data['cardano'])];389 $fiat = $currency === "ADA" ? 1 : $data['cardano'][array_key_first($data['cardano'])]; 362 390 $fiat_total_order = WC()->cart->get_totals()["total"]; 363 391 $cryptoTotalPreMarkup = round($fiat_total_order / $fiat, 6, PHP_ROUND_HALF_UP); … … 382 410 383 411 if ($wpdb->last_error === "" && isset($get_key[0]->pay_address)) { 384 $pay_address = $get_key[0]->pay_address;385 412 $id = $get_key[0]->id; 386 413 // Update data -
sargapay/trunk/readme.txt
r2827431 r2850806 69 69 == Changelog == 70 70 71 = 2.1 = 72 * Add Cardano Currency to WooCommerce 73 * Fix markup error 74 * Update Testnet to Preview Testnet Network 75 71 76 = 2.0 = 72 77 * Admin Dashboard UI -
sargapay/trunk/sargapay.php
r2827447 r2850806 17 17 * Plugin URI: https://sargatxet.cloud/sargapay-cardano/ 18 18 * Description: WordPress payment gateway for crypto. 19 * Version: 2. 0.019 * Version: 2.1.0 20 20 * Author: Sargatxet 21 21 * Author URI: https://sargatxet.cloud/ … … 62 62 define('SARGAPAY_PATH', plugin_dir_path(__FILE__)); 63 63 define('SARGAPAY_URL', plugin_dir_url(__FILE__)); 64 define('SARGAPAY_VERSION', '2. 0.0');64 define('SARGAPAY_VERSION', '2.1.0'); 65 65 66 66 add_filter('cron_schedules', 'sargapay_cron_hook');
Note: See TracChangeset
for help on using the changeset viewer.