diff --git a/inc/class-wooviet-admin-page.php b/inc/class-wooviet-admin-page.php
index 08c33e4..3d32497 100644
--- a/inc/class-wooviet-admin-page.php
+++ b/inc/class-wooviet-admin-page.php
@@ -268,7 +268,8 @@ class WooViet_Admin_Page {
-
diff --git a/inc/class-wooviet-onepay-domestic.php b/inc/class-wooviet-onepay-domestic.php
index e763c66..a69e3d6 100644
--- a/inc/class-wooviet-onepay-domestic.php
+++ b/inc/class-wooviet-onepay-domestic.php
@@ -36,8 +36,8 @@ class WooViet_OnePay_Domestic extends WC_Payment_Gateway {
$this->init_settings();
// Define user set variables.
- $this->title = $this->get_option( 'title' );
- $this->description = $this->get_option( 'description' ) . sprintf( '
', WOO_VIET_URL . 'assets/onepay_domestic.png' );
+ $this->title = $this->get_option( 'title' );
+ $this->description = $this->get_option( 'description' ) . sprintf( '
', WOO_VIET_URL . 'assets/onepay_domestic.png' );
$this->testmode = 'yes' === $this->get_option( 'testmode', 'no' );
$this->merchant_id = $this->get_option( 'merchant_id' );
@@ -45,9 +45,9 @@ class WooViet_OnePay_Domestic extends WC_Payment_Gateway {
$this->secure_secret = $this->get_option( 'secure_secret' );
$this->user = $this->get_option( 'user' );
$this->password = $this->get_option( 'password' );
- $this->debug = 'yes' === $this->get_option( 'debug', 'no' );
+ $this->debug = 'yes' === $this->get_option( 'debug', 'no' );
- self::$log_enabled = $this->debug;
+ self::$log_enabled = $this->debug;
// Process the admin options
add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array(
@@ -130,8 +130,8 @@ class WooViet_OnePay_Domestic extends WC_Payment_Gateway {
$http_args = http_build_query( $args, '', '&' );
// Log data
- $message_log = sprintf('get_pay_url - Order ID: %1$s - http_args: %2$s', $order->get_id(), print_r($args, true) );
- self::log( $message_log);
+ $message_log = sprintf( 'get_pay_url - Order ID: %1$s - http_args: %2$s', $order->get_id(), print_r( $args, true ) );
+ self::log( $message_log );
if ( $this->testmode ) {
return 'https://mtf.onepay.vn/onecomm-pay/vpc.op?' . $http_args;
@@ -255,7 +255,7 @@ class WooViet_OnePay_Domestic extends WC_Payment_Gateway {
);
$order->add_order_note( $order_note );
-
+
// Do action for the order based on the response code from OnePay
// This is an intentional DRY switch - refer to #DRY_vpc_TxnResponseCode below
switch ( $vpc_TxnResponseCode ) {
@@ -273,15 +273,15 @@ class WooViet_OnePay_Domestic extends WC_Payment_Gateway {
}
// Log data
- $message_log = sprintf('process_onepay_response_data - Order ID: %1$s - Order Note: %2$s - http_args: %3$s', $order_id, $order_note, print_r($args, true) );
- self::log( $message_log);
-
+ $message_log = sprintf( 'process_onepay_response_data - Order ID: %1$s - Order Note: %2$s - http_args: %3$s', $order_id, $order_note, print_r( $args, true ) );
+ self::log( $message_log );
+
// Do the last actions based on $type
switch ( $type ) {
case 'return': // Add info from OnePay and redirect to the appropriate URLs
- wc_add_notice( __( 'OnePay info: ', 'woo-viet') . $this->OnePay_getResponseDescription( $vpc_TxnResponseCode ), 'notice' );
+ wc_add_notice( __( 'OnePay info: ', 'woo-viet' ) . $this->OnePay_getResponseDescription( $vpc_TxnResponseCode ), 'notice' );
// This is an intentional DRY switch - refer to #DRY_vpc_TxnResponseCode above
// I need to make sure that `ipn` case below and message_log can be executed as well.
@@ -296,7 +296,7 @@ class WooViet_OnePay_Domestic extends WC_Payment_Gateway {
break;
default:
// For other cases, redirect to the payment page
- wp_redirect( $order->get_checkout_payment_url () );
+ wp_redirect( $order->get_checkout_payment_url() );
break;
}
@@ -441,8 +441,8 @@ class WooViet_OnePay_Domestic extends WC_Payment_Gateway {
}
// Log data
- $message_log = sprintf('handle_onepay_querydr - http_link: %1$s - http_args: %2$s', $http_link, print_r($args, true) );
- self::log( $message_log);
+ $message_log = sprintf( 'handle_onepay_querydr - http_link: %1$s - http_args: %2$s', $http_link, print_r( $args, true ) );
+ self::log( $message_log );
// Connect to OnePay to get the queryDR info
$http_response = wp_remote_get( $http_link );
@@ -457,8 +457,9 @@ class WooViet_OnePay_Domestic extends WC_Payment_Gateway {
* Logging method. - Copied from the WC_Gateway_Paypal Class
*
* @since 1.3.1
+ *
* @param string $message Log message.
- * @param string $level Optional. Default 'info'.
+ * @param string $level Optional. Default 'info'.
* emergency|alert|critical|error|warning|notice|info|debug
*/
public static function log( $message, $level = 'info' ) {
diff --git a/inc/class-wooviet-provinces.php b/inc/class-wooviet-provinces.php
index c7f9b95..d4767dd 100644
--- a/inc/class-wooviet-provinces.php
+++ b/inc/class-wooviet-provinces.php
@@ -139,12 +139,12 @@ class WooViet_Provinces {
}
/**
- * Enqueue provinces scripts
- *
- * Arrange the address field orders to the Vietnam standard in the checkout page: Country - Province - District - Address
- * @author Longkt
- * @since 1.4
- */
+ * Enqueue provinces scripts
+ *
+ * Arrange the address field orders to the Vietnam standard in the checkout page: Country - Province - District - Address
+ * @author Longkt
+ * @since 1.4
+ */
public function load_provinces_scripts() {
// Enqueue province style
wp_enqueue_style( 'woo-viet-provinces-style', WOO_VIET_URL . 'assets/provinces.css' );
diff --git a/inc/class-wooviet-vnd-paypal-express-checkout.php b/inc/class-wooviet-vnd-paypal-express-checkout.php
index 435afb0..b73d894 100644
--- a/inc/class-wooviet-vnd-paypal-express-checkout.php
+++ b/inc/class-wooviet-vnd-paypal-express-checkout.php
@@ -41,12 +41,15 @@ class WooViet_VND_PayPal_Express_Checkout {
$this->ppec_currency = $ppec_currency;
$this->ppec_description = sprintf( __( 'The prices will be converted to %1$s in the PayPal Express Checkout pages with the exchange rate %2$s.', 'woo-viet' ),
- " $this->ppec_currency",
- " $this->ppec_currency / VND = $this->ppec_exchange_rate"
- );
+ " $this->ppec_currency",
+ " $this->ppec_currency / VND = $this->ppec_exchange_rate"
+ );
// Match response currency of PayPal with local order
- add_action( 'woocommerce_paypal_express_checkout_valid_ipn_request', array( $this, 'ppec_match_currency_order' ) );
+ add_action( 'woocommerce_paypal_express_checkout_valid_ipn_request', array(
+ $this,
+ 'ppec_match_currency_order'
+ ) );
// Add exchange rate before send request to PayPal
add_filter( 'woocommerce_paypal_express_checkout_request_body', array( $this, 'ppec_convert_prices' ) );
@@ -58,12 +61,12 @@ class WooViet_VND_PayPal_Express_Checkout {
/**
* Match response currency from PayPal with the order
- *
+ *
* @param $posted_data
*/
public function ppec_match_currency_order( $posted_data ) {
- if( $posted_data['mc_currency'] ) {
+ if ( $posted_data['mc_currency'] ) {
$posted_data['mc_currency'] = $order->get_currency();
}
@@ -71,42 +74,43 @@ class WooViet_VND_PayPal_Express_Checkout {
/**
* @param $params
+ *
* @return mixed
*/
public function ppec_convert_prices( $params ) {
- if( isset( $params['PAYMENTREQUEST_0_CURRENCYCODE'] ) ) {
+ if ( isset( $params['PAYMENTREQUEST_0_CURRENCYCODE'] ) ) {
- $params['PAYMENTREQUEST_0_CURRENCYCODE'] = $this->ppec_currency;
+ $params['PAYMENTREQUEST_0_CURRENCYCODE'] = $this->ppec_currency;
- if( isset( $params['PAYMENTREQUEST_0_AMT'] ) ) {
- $params['PAYMENTREQUEST_0_AMT'] = round( $params['PAYMENTREQUEST_0_AMT'] / $this->ppec_exchange_rate, 2 );
- }
-
- if( isset( $params['PAYMENTREQUEST_0_ITEMAMT'] ) ) {
- $params['PAYMENTREQUEST_0_ITEMAMT'] = round( $params['PAYMENTREQUEST_0_ITEMAMT'] / $this->ppec_exchange_rate, 2 );
- }
-
- if( isset( $params['PAYMENTREQUEST_0_SHIPPINGAMT'] ) ) {
- $params['PAYMENTREQUEST_0_SHIPPINGAMT'] = round( $params['PAYMENTREQUEST_0_SHIPPINGAMT'] / $this->ppec_exchange_rate, 2 );
- }
-
- if( isset( $params['PAYMENTREQUEST_0_TAXAMT'] ) ) {
- $params['PAYMENTREQUEST_0_TAXAMT'] = round( $params['PAYMENTREQUEST_0_TAXAMT'] / $this->ppec_exchange_rate, 2 );
- }
-
- if( isset( $params['PAYMENTREQUEST_0_SHIPDISCAMT'] ) ) {
- $params['PAYMENTREQUEST_0_SHIPDISCAMT'] = round( $params['PAYMENTREQUEST_0_SHIPDISCAMT'] / $this->ppec_exchange_rate, 2 );
- }
-
- $count = 0;
-
- while( isset( $params['L_PAYMENTREQUEST_0_AMT' . $count] ) ) {
- $params['L_PAYMENTREQUEST_0_AMT' . $count] = round( $params['L_PAYMENTREQUEST_0_AMT' . $count] / $this->ppec_exchange_rate, 2 );
- $count++;
- }
+ if ( isset( $params['PAYMENTREQUEST_0_AMT'] ) ) {
+ $params['PAYMENTREQUEST_0_AMT'] = round( $params['PAYMENTREQUEST_0_AMT'] / $this->ppec_exchange_rate, 2 );
}
+ if ( isset( $params['PAYMENTREQUEST_0_ITEMAMT'] ) ) {
+ $params['PAYMENTREQUEST_0_ITEMAMT'] = round( $params['PAYMENTREQUEST_0_ITEMAMT'] / $this->ppec_exchange_rate, 2 );
+ }
+
+ if ( isset( $params['PAYMENTREQUEST_0_SHIPPINGAMT'] ) ) {
+ $params['PAYMENTREQUEST_0_SHIPPINGAMT'] = round( $params['PAYMENTREQUEST_0_SHIPPINGAMT'] / $this->ppec_exchange_rate, 2 );
+ }
+
+ if ( isset( $params['PAYMENTREQUEST_0_TAXAMT'] ) ) {
+ $params['PAYMENTREQUEST_0_TAXAMT'] = round( $params['PAYMENTREQUEST_0_TAXAMT'] / $this->ppec_exchange_rate, 2 );
+ }
+
+ if ( isset( $params['PAYMENTREQUEST_0_SHIPDISCAMT'] ) ) {
+ $params['PAYMENTREQUEST_0_SHIPDISCAMT'] = round( $params['PAYMENTREQUEST_0_SHIPDISCAMT'] / $this->ppec_exchange_rate, 2 );
+ }
+
+ $count = 0;
+
+ while ( isset( $params[ 'L_PAYMENTREQUEST_0_AMT' . $count ] ) ) {
+ $params[ 'L_PAYMENTREQUEST_0_AMT' . $count ] = round( $params[ 'L_PAYMENTREQUEST_0_AMT' . $count ] / $this->ppec_exchange_rate, 2 );
+ $count ++;
+ }
+ }
+
return $params;
}
@@ -117,22 +121,31 @@ class WooViet_VND_PayPal_Express_Checkout {
public function ppec_exchange_rate_info() {
// Check if "Checkout on cart page" is enabled.
- if( 'yes' === wc_gateway_ppec()->settings->cart_checkout_enabled ) {
+ if ( 'yes' === wc_gateway_ppec()->settings->cart_checkout_enabled ) {
add_action( 'woocommerce_proceed_to_checkout', array( $this, 'add_ppec_button_exchange_rate_info' ), 30 );
}
// Check if "Checkout on Single Product" is enabled.
- if( 'yes' === wc_gateway_ppec()->settings->checkout_on_single_product_enabled ) {
- add_action( 'woocommerce_after_add_to_cart_form', array( $this, 'add_ppec_button_exchange_rate_info' ), 30 );
+ if ( 'yes' === wc_gateway_ppec()->settings->checkout_on_single_product_enabled ) {
+ add_action( 'woocommerce_after_add_to_cart_form', array(
+ $this,
+ 'add_ppec_button_exchange_rate_info'
+ ), 30 );
}
// Check if "Enable PayPal Credit" is enabled.
- if( 'yes' === wc_gateway_ppec()->settings->credit_enabled ) {
- add_filter( 'woocommerce_paypal_express_checkout_settings', array( $this, 'add_paypal_credit_exchange_rate_info' ), 11 );
+ if ( 'yes' === wc_gateway_ppec()->settings->credit_enabled ) {
+ add_filter( 'woocommerce_paypal_express_checkout_settings', array(
+ $this,
+ 'add_paypal_credit_exchange_rate_info'
+ ), 11 );
}
// Add the exchange rate info for PPEC in Checkout page
- add_filter( 'option_woocommerce_ppec_paypal_settings', array( $this, 'add_ppec_checkout_exchange_rate_info' ), 11 );
+ add_filter( 'option_woocommerce_ppec_paypal_settings', array(
+ $this,
+ 'add_ppec_checkout_exchange_rate_info'
+ ), 11 );
}
@@ -147,8 +160,9 @@ class WooViet_VND_PayPal_Express_Checkout {
/**
* Display the exchange rate info of PP Credit in Checkout page
- *
+ *
* @param $value
+ *
* @return mixed
*/
public function add_paypal_credit_exchange_rate_info( $value ) {
@@ -163,8 +177,9 @@ class WooViet_VND_PayPal_Express_Checkout {
/**
* Display the exchange rate info of PPEC in Checkout page
- *
+ *
* @param $value
+ *
* @return mixed
*/
public function add_ppec_checkout_exchange_rate_info( $value ) {
@@ -173,8 +188,9 @@ class WooViet_VND_PayPal_Express_Checkout {
$value['description'] .= '
';
$value['description'] .= $this->ppec_description;
}
+
return $value;
-
+
}
}
\ No newline at end of file
diff --git a/inc/class-wooviet-vnd-paypal-standard.php b/inc/class-wooviet-vnd-paypal-standard.php
index 075416a..28adcd8 100644
--- a/inc/class-wooviet-vnd-paypal-standard.php
+++ b/inc/class-wooviet-vnd-paypal-standard.php
@@ -45,7 +45,7 @@ class WooViet_VND_PayPal_Standard {
add_filter( 'option_woocommerce_paypal_settings', array( $this, 'add_exchange_rate_info' ), 11 );
- // Remove checks on currency and gross (total) values
+ // Remove checks on currency and gross (total) values
add_action( 'woocommerce_api_wc_gateway_paypal', array( $this, 'remove_currency_and_total_checks' ), 5 );
@@ -114,30 +114,30 @@ class WooViet_VND_PayPal_Standard {
}
- /**
- * Remove currency and total (gross) amount check in class WC_Gateway_Paypal_IPN_Handler
- *
- * @since 1.4.5
- * @author htdat
- */
+ /**
+ * Remove currency and total (gross) amount check in class WC_Gateway_Paypal_IPN_Handler
+ *
+ * @since 1.4.5
+ * @author htdat
+ */
public function remove_currency_and_total_checks() {
- // Remove these filters https://github.com/woocommerce/woocommerce/blob/3.7.1/includes/gateways/paypal/includes/class-wc-gateway-paypal-ipn-handler.php#L34-L35
- remove_all_filters( 'woocommerce_api_wc_gateway_paypal', 10 );
- remove_all_filters( 'valid-paypal-standard-ipn-request', 10 );
+ // Remove these filters https://github.com/woocommerce/woocommerce/blob/3.7.1/includes/gateways/paypal/includes/class-wc-gateway-paypal-ipn-handler.php#L34-L35
+ remove_all_filters( 'woocommerce_api_wc_gateway_paypal', 10 );
+ remove_all_filters( 'valid-paypal-standard-ipn-request', 10 );
- // Get values for PayPal Standard settings
- // Ref: https://github.com/woocommerce/woocommerce/blob/3.7.1/includes/gateways/paypal/class-wc-gateway-paypal.php#L58-L61
- $paypal_options = get_option( 'woocommerce_paypal_settings' );
- $testmode = 'yes' === $paypal_options['testmode'];
- $receiver_email = is_null( $paypal_options['receiver_email'] ) ? $paypal_options['email'] : $paypal_options['receiver_email'];
+ // Get values for PayPal Standard settings
+ // Ref: https://github.com/woocommerce/woocommerce/blob/3.7.1/includes/gateways/paypal/class-wc-gateway-paypal.php#L58-L61
+ $paypal_options = get_option( 'woocommerce_paypal_settings' );
+ $testmode = 'yes' === $paypal_options['testmode'];
+ $receiver_email = is_null( $paypal_options['receiver_email'] ) ? $paypal_options['email'] : $paypal_options['receiver_email'];
- // Replace it by a child class of WC_Gateway_Paypal_IPN_Handler,
- // which overrides/removes validate_currency() and validate_amount()
- require_once dirname(__FILE__) . '/paypal-standard/class-woo-viet-wc-gateway-paypal-ipn-handler.php.php';
- $handler = new Woo_Viet_WC_Gateway_Paypal_IPN_Handler( $testmode, $receiver_email ); //@todo needs to handle the correct variables
- $handler->check_response();
+ // Replace it by a child class of WC_Gateway_Paypal_IPN_Handler,
+ // which overrides/removes validate_currency() and validate_amount()
+ require_once dirname( __FILE__ ) . '/paypal-standard/class-woo-viet-wc-gateway-paypal-ipn-handler.php.php';
+ $handler = new Woo_Viet_WC_Gateway_Paypal_IPN_Handler( $testmode, $receiver_email ); //@todo needs to handle the correct variables
+ $handler->check_response();
- }
+ }
}
\ No newline at end of file
diff --git a/inc/onepay/domestic-settings.php b/inc/onepay/domestic-settings.php
index 7dbadc5..bf6f761 100644
--- a/inc/onepay/domestic-settings.php
+++ b/inc/onepay/domestic-settings.php
@@ -6,7 +6,7 @@ if ( ! defined( 'ABSPATH' ) ) {
/**
* Settings for 1Pay Gateway.
- * @since 1.3
+ * @since 1.3
*/
return array(
'enabled' => array(
@@ -92,7 +92,7 @@ return array(
/**
* @since 1.3.1
*/
- 'debug' => array(
+ 'debug' => array(
'title' => __( 'Debug log', 'woo-viet' ),
'type' => 'checkbox',
'label' => __( 'Enable logging', 'woo-viet' ),
diff --git a/inc/paypal-standard/class-woo-viet-wc-gateway-paypal-ipn-handler.php.php b/inc/paypal-standard/class-woo-viet-wc-gateway-paypal-ipn-handler.php.php
index 6a87209..d71d96d 100644
--- a/inc/paypal-standard/class-woo-viet-wc-gateway-paypal-ipn-handler.php.php
+++ b/inc/paypal-standard/class-woo-viet-wc-gateway-paypal-ipn-handler.php.php
@@ -11,9 +11,11 @@ if ( class_exists( 'WC_Gateway_Paypal_IPN_Handler' ) ) {
class Woo_Viet_WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_IPN_Handler {
- protected function validate_currency( $order, $currency ) {}
+ protected function validate_currency( $order, $currency ) {
+ }
- protected function validate_amount( $order, $amount ) {}
+ protected function validate_amount( $order, $amount ) {
+ }
}
diff --git a/woo-viet.php b/woo-viet.php
index 640c4f6..95f75ac 100644
--- a/woo-viet.php
+++ b/woo-viet.php
@@ -40,37 +40,37 @@ class WooViet {
* @var array The default settings for the whole plugin
*/
static $default_settings = array(
- 'add_province' =>
+ 'add_province' =>
array(
'enabled' => 'yes',
),
- 'add_city' =>
+ 'add_city' =>
array(
'enabled' => 'yes',
),
- 'change_currency_symbol' =>
+ 'change_currency_symbol' =>
array(
'enabled' => 'yes',
'text' => 'VND',
),
- 'convert_price' =>
+ 'convert_price' =>
array(
'enabled' => 'yes',
'text' => 'K',
),
- 'vnd_paypal_standard' =>
+ 'vnd_paypal_standard' =>
array(
'enabled' => 'yes',
'currency' => 'USD',
'rate' => '22770',
),
- 'add_onepay_domestic' =>
+ 'add_onepay_domestic' =>
array(
'enabled' => 'yes',
),
'vnd_paypal_express_checkout' =>
- array(
- 'enabled' => 'yes',
+ array(
+ 'enabled' => 'yes',
'currency' => 'USD',
'rate' => '22770',
),
@@ -122,7 +122,7 @@ class WooViet {
$this->main();
// Add "Settings" link when the plugin is active
- add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array( $this, 'add_settings_link' ) ) ;
+ add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'add_settings_link' ) );
} else {
// Throw a notice if WooCommerce is NOT active
add_action( 'admin_notices', array( $this, 'notice_if_not_woocommerce' ) );
@@ -211,9 +211,10 @@ class WooViet {
}
// Check if "Support VND for the PayPal Express Checkout gateway" is enabled
- if ( 'yes' == $settings['vnd_paypal_express_checkout']['enabled']
- AND class_exists( 'WC_Gateway_PPEC_Plugin' )
- ) { include( WOO_VIET_DIR . 'inc/class-wooviet-vnd-paypal-express-checkout.php' );
+ if ( 'yes' == $settings['vnd_paypal_express_checkout']['enabled']
+ AND class_exists( 'WC_Gateway_PPEC_Plugin' )
+ ) {
+ include( WOO_VIET_DIR . 'inc/class-wooviet-vnd-paypal-express-checkout.php' );
$this->VND_PayPal_Express_Checkout = new WooViet_VND_PayPal_Express_Checkout(
$settings['vnd_paypal_express_checkout']['rate'],
$settings['vnd_paypal_express_checkout']['currency']
@@ -250,13 +251,13 @@ class WooViet {
/**
* Add "Settings" link in the Plugins list page when the plugin is active
- *
+ *
* @since 1.4
* @author Longkt
*/
public function add_settings_link( $links ) {
$settings = array( '' . __( 'Settings', 'woo-viet' ) . '' );
- $links = array_reverse( array_merge( $links, $settings ) );
+ $links = array_reverse( array_merge( $links, $settings ) );
return $links;
}