Commit 2b5f2eac authored by mr.amirka's avatar mr.amirka
Browse files

refactor

parent bb98ed4c
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* Plugin Name: Lunu WooCommerce - Lunu Cryptocurrencies Payment Gateway Addon * Plugin Name: Lunu WooCommerce - Lunu Cryptocurrencies Payment Gateway Addon
* Plugin URI: https://lunu.io/plugins * Plugin URI: https://lunu.io/plugins
* Description: Payment system plugin. * Description: Payment system plugin.
* Version: 0.2 * Version: 1.0
* Author: lunu.io * Author: lunu.io
* Author URI: https://lunu.io/plugins/ * Author URI: https://lunu.io/plugins/
* Text Domain: lunu-payment * Text Domain: lunu-payment
...@@ -103,7 +103,6 @@ if ( ...@@ -103,7 +103,6 @@ if (
if (!class_exists('WC_Payment_Gateway') || class_exists('WC_Gateway_LunuPayment')) return; if (!class_exists('WC_Payment_Gateway') || class_exists('WC_Gateway_LunuPayment')) return;
add_filter('woocommerce_payment_gateways', 'lunupayment_wc_gateway_add'); add_filter('woocommerce_payment_gateways', 'lunupayment_wc_gateway_add');
// add_action('woocommerce_admin_order_data_after_billing_address', 'lunupayment_wc_admin_order_stats');
// add LunuPayment gateway // add LunuPayment gateway
function lunupayment_wc_gateway_add($methods) { function lunupayment_wc_gateway_add($methods) {
...@@ -113,13 +112,6 @@ if ( ...@@ -113,13 +112,6 @@ if (
return $methods; return $methods;
} }
/*
function lunupayment_wc_admin_order_stats($order) {
return;
}
*/
// Payment Gateway WC Class // Payment Gateway WC Class
class WC_Gateway_LunuPayment extends WC_Payment_Gateway { class WC_Gateway_LunuPayment extends WC_Payment_Gateway {
private $app_id = ''; private $app_id = '';
...@@ -188,8 +180,6 @@ if ( ...@@ -188,8 +180,6 @@ if (
// Re-check // Re-check
if (!$this->title) $this->title = __('Lunu Payment', LUNUPAYMENTWC); if (!$this->title) $this->title = __('Lunu Payment', LUNUPAYMENTWC);
// if (!$this->description) $this->description = __('Secure, anonymous payment with virtual currency', LUNUPAYMENTWC);
return true; return true;
} }
...@@ -229,14 +219,6 @@ if ( ...@@ -229,14 +219,6 @@ if (
'default' => '', 'default' => '',
'description' => __('Redirect to another page after payment is canceled. For example, http://yoursite.com/we_very_wait_you.php', LUNUPAYMENTWC) . "<br><br><br><br><br>" 'description' => __('Redirect to another page after payment is canceled. For example, http://yoursite.com/we_very_wait_you.php', LUNUPAYMENTWC) . "<br><br><br><br><br>"
) )
/*
'description' => array(
'title' => __('Description', LUNUPAYMENTWC),
'type' => 'textarea',
'default' => trim(__('Secure, anonymous payment with virtual currency', LUNUPAYMENTWC), " -"),
'description' => __('Payment method description that the customer will see on your checkout', LUNUPAYMENTWC)
)
*/
); );
return true; return true;
...@@ -279,13 +261,12 @@ if ( ...@@ -279,13 +261,12 @@ if (
update_post_meta($order_id, '_lunupayment_worder_orderpage', $orderpage); update_post_meta($order_id, '_lunupayment_worder_orderpage', $orderpage);
update_post_meta($order_id, '_lunupayment_worder_created', gmdate("d M Y, H:i")); update_post_meta($order_id, '_lunupayment_worder_created', gmdate("d M Y, H:i"));
// update_post_meta( $order_id, '_lunupayment_worder_currencies', $arr );
update_post_meta($order_id, '_lunupayment_worder_amountcrypto', $total); update_post_meta($order_id, '_lunupayment_worder_amountcrypto', $total);
update_post_meta($order_id, '_lunupayment_worder_amountfiat', ($totalFiat ? $totalFiat : $total) ); update_post_meta($order_id, '_lunupayment_worder_amountfiat', ($totalFiat ? $totalFiat : $total) );
} }
// Remove cart // Remove cart
// $woocommerce->cart->empty_cart(); $woocommerce->cart->empty_cart();
// Return redirect // Return redirect
return array( return array(
...@@ -558,14 +539,11 @@ function lunu_payment_create($auth = array( ...@@ -558,14 +539,11 @@ function lunu_payment_create($auth = array(
$auth_token = base64_encode($app_id . ':' . $api_secret); $auth_token = base64_encode($app_id . ':' . $api_secret);
$order_id = $order['id']; $order_id = $order['id'];
$currency = empty($order['currency']) ? 'USD' : $order['currency'];
$now = time(); $now = time();
$expires = $now + (3 * 24 * 60 * 60); $expires = $now + (3 * 24 * 60 * 60);
$data = array( $data = array(
'amount' => $order['amount'], 'amount' => $order['amount'],
// 'currency' => $currency,
'callback_url' => LUNUPAYMENT_CALLBACK_ENDPOINT, 'callback_url' => LUNUPAYMENT_CALLBACK_ENDPOINT,
'description' => 'Order #' . $order_id, 'description' => 'Order #' . $order_id,
'expires' => date("c", $expires), 'expires' => date("c", $expires),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment