16 Commits

Author SHA1 Message Date
Dat Hoang d6ecbfe806 Merge pull request #32 from htdat/1.3.1-dev
Merge 1.3.1
2017-07-09 11:54:20 +07:00
htdat 26d9e4ba24 Add the changeling, update the stable tag 2017-07-09 11:52:03 +07:00
htdat 6c333e5abe Create the plugin icon #11 2017-07-09 11:47:33 +07:00
htdat 187dd5bf2b Increase the version number 2017-07-03 23:59:33 +07:00
htdat c22f935e96 Update survey links - #29 2017-07-03 23:58:37 +07:00
htdat 4e78194ba9 Add the questionnaire after 4 weeks - the coding part - #29 2017-07-03 14:15:04 +07:00
htdat d44605827a Small grammar fix 2017-07-03 12:32:13 +07:00
htdat 83a1dafdf0 Add the screenshot for OnePay #24 2017-07-03 12:00:40 +07:00
htdat 0c43ee467d Fix: Error in WooCommerce 3.0.x - order->id - #24 2017-07-02 18:08:37 +07:00
htdat fac3a9709f Save the log. See the PayPal Standard gateway #24 2017-07-02 17:59:13 +07:00
htdat 2e4c7b6265 Improve the link to the OnePay setting 2017-07-02 16:27:43 +07:00
htdat 53eec6c1eb Add more notes about the plugin implementing QueryDR, IPN and Return URL. Make sure to follow all guides. #24 2017-07-02 16:26:37 +07:00
htdat 282734961a File readme.txt in the new design of WordPress.org #25 2017-07-02 16:05:53 +07:00
Dat Hoang 12fae4d63f Update the compatible tag 4.8 2017-06-18 18:10:14 +07:00
Dat Hoang ad1cda5d85 Update the compatible tag 4.8 2017-06-18 18:09:48 +07:00
Dat Hoang f694d19ffb Merge pull request #23 from htdat/1.3-dev
Add 1.3 - ready for releasing
2017-04-22 16:42:13 +07:00
10 changed files with 181 additions and 11 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

+1 -1
View File
@@ -106,7 +106,7 @@ class WooViet_Admin_Page {
if ( 'VND' == get_woocommerce_currency() ) {
_e( 'OnePay can work on your site.', 'woo-viet' );
echo '<br/>';
echo sprintf( __( 'Please configure this gateway under <a href="%s">WooCommerce -> Settings -> Checkout</a>.', 'woo-viet' ), admin_url( 'admin.php?page=wc-settings&tab=checkout' ) );
echo sprintf( __( 'Please configure this gateway under <a href="%s">WooCommerce -> Settings -> Checkout</a>.', 'woo-viet' ), admin_url( 'admin.php?page=wc-settings&tab=checkout&section=wooviet_onepay_domestic' ) );
} else {
_e( '<span style="color: red" ">This gateway is not active on your site. Because OnePay supports VND only.</span>', 'woo-viet' );
}
+107
View File
@@ -0,0 +1,107 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Manage the notices of the plugin
*
* @author htdat
* @since 1.3.1
*
*/
class WooViet_Notices {
var $settings = '';
static $default_settings = array(
'installation_time' => 0,
'displaying_survey_after_4_weeks' => 'not_yet',
);
/**
* WooViet_Notices constructor.
*/
public function __construct() {
$this->settings = self::get_settings();
$this->set_installation_time();
$this->manage_displaying_survey_after_4_weeks();
}
public function get_settings() {
$settings = get_option( 'woo-viet_notices', self::$default_settings );
$settings = wp_parse_args( $settings, self::$default_settings );
return $settings;
}
/**
* Set the installation time
*/
public function set_installation_time() {
if ( ! $this->settings['installation_time'] ) {
$this->settings['installation_time'] = time();
$this->save_settings();
}
}
/**
* Save settings for this classe
*/
public function save_settings() {
update_option( 'woo-viet_notices', $this->settings );
}
/**
* Manage the notice 'displaying_survey_after_4_weeks'
*/
public function manage_displaying_survey_after_4_weeks() {
$display_time = $this->settings['installation_time'] + ( 4 * 7 * 24 * 60 * 60 ); // 4 weeks; 7 days; 24 hours; 60 mins; 60 secs
// Manage the dismiss action
if ( isset( $_GET['wooviet_dismiss'] )
&&
( 'displaying_survey_after_4_weeks' == $_GET['wooviet_dismiss'] )
) {
$this->settings['displaying_survey_after_4_weeks'] = 'done';
$this->save_settings();
}
// Display the message
if ( $display_time < time() &&
'not_yet' == $this->settings['displaying_survey_after_4_weeks']
) {
add_action( 'admin_notices', array( $this, 'add_displaying_survey_after_4_weeks' ) );
}
}
/**
* The HTML code to display in the admin notice
*/
public function add_displaying_survey_after_4_weeks() {
$line1 = __( 'Please help us to improve Woo Viet.', 'woo-viet' );
$line2 = __( 'Rate us!', 'woo-viet' );
$line3 = __( 'Or run a short survery:', 'woo-viet' );
$line4 = '<a href="https://goo.gl/forms/QIMkNrRIxgERBBcm2" target="_blank">tiếng Việt</a> - <a href="https://goo.gl/forms/N4GxvBtaIg6iryx43" target="_blank">English</a>';
$line5 = __( 'Dismiss this notice', 'woo-viet' );
$link = admin_url( 'admin.php?page=woo-viet&wooviet_dismiss=displaying_survey_after_4_weeks' );
printf( '
<div class="notice notice-success">
<p><strong>%1$s</strong></p>
<p><strong>
<a href="https://wordpress.org/support/plugin/woo-viet/reviews/?filter=5#new-post" target="_blank">%2$s</a> %3$s %4$s
</strong></p>
<p>
<a href="%6$s">%5$s</a>
</p>
</div>
', $line1, $line2, $line3, $line4, $line5, $link );
}
}
+40 -2
View File
@@ -12,6 +12,12 @@ if ( ! defined( 'ABSPATH' ) ) {
*
*/
class WooViet_OnePay_Domestic extends WC_Payment_Gateway {
/** @var bool Whether or not logging is enabled */
public static $log_enabled = false;
/** @var WC_Logger Logger instance */
public static $log = false;
/**
* Constructor for the gateway.
*/
@@ -39,6 +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' );
self::$log_enabled = $this->debug;
// Process the admin options
add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array(
@@ -96,9 +105,9 @@ class WooViet_OnePay_Domestic extends WC_Payment_Gateway {
'Title' => __( 'OnePay Payment Title', 'woo-viet' ),
'vpc_Merchant' => $this->merchant_id,
'vpc_AccessCode' => $this->access_code,
'vpc_MerchTxnRef' => sprintf( '%1$s_%2$s', $order->id, date( 'YmdHis' ) ),
'vpc_MerchTxnRef' => sprintf( '%1$s_%2$s', $order->get_id(), date( 'YmdHis' ) ),
'vpc_OrderInfo' => substr(
sprintf( 'Order #%1$s - %2$s', $order->id, get_home_url() ),
sprintf( 'Order #%1$s - %2$s', $order->get_id(), get_home_url() ),
0,
32 ), // Limit 32 characters
'vpc_Amount' => $order->get_total() * 100, // Multiplying 100 is a requirement from OnePay
@@ -120,6 +129,10 @@ class WooViet_OnePay_Domestic extends WC_Payment_Gateway {
$args['vpc_SecureHash'] = $vpc_SecureHash;
$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);
if ( $this->testmode ) {
return 'https://mtf.onepay.vn/onecomm-pay/vpc.op?' . $http_args;
} else {
@@ -246,7 +259,11 @@ class WooViet_OnePay_Domestic extends WC_Payment_Gateway {
if ( "0" == $vpc_TxnResponseCode ) {
$order->payment_complete();
}
// 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);
// Return the info
switch ( $type ) {
case 'return':
@@ -391,6 +408,10 @@ class WooViet_OnePay_Domestic extends WC_Payment_Gateway {
$http_link = 'https://onepay.vn/onecomm-pay/Vpcdps.op?' . $http_args;
}
// 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);
// Connect to OnePay to get the queryDR info
$http_response = wp_remote_get( $http_link );
parse_str( wp_remote_retrieve_body( $http_response ), $args_response );
@@ -400,4 +421,21 @@ 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'.
* emergency|alert|critical|error|warning|notice|info|debug
*/
public static function log( $message, $level = 'info' ) {
if ( self::$log_enabled ) {
if ( empty( self::$log ) ) {
self::$log = wc_get_logger();
}
self::$log->log( $level, $message, array( 'source' => __CLASS__ ) );
}
}
}
+10
View File
@@ -89,5 +89,15 @@ return array(
sprintf( 'URL: <code>%s</code>', WooViet_OnePay_Domestic::get_onepay_ipn_url() ) . '<p/>' .
sprintf( __( '%sContact OnePay%s to configure this URL on its site. <strong>This is required based on its guidelines.</strong>', 'woo-viet' ), '<a href="http://onepay.com.vn/home/en/contact-us.html">', '</a>' ),
),
/**
* @since 1.3.1
*/
'debug' => array(
'title' => __( 'Debug log', 'woo-viet' ),
'type' => 'checkbox',
'label' => __( 'Enable logging', 'woo-viet' ),
'default' => 'no',
'description' => sprintf( __( 'Log events, such as IPN requests, inside %s', 'woo-viet' ), '<code>' . WC_Log_Handler_File::get_log_file_path( 'WooViet_OnePay_Domestic' ) . '</code>' ),
),
);
+7 -2
View File
@@ -5,7 +5,7 @@
| Contributors | htdat |
|Tags| WooCommerce Vietnam, vietnam, vietnamese, vietnam provinces, paypal for vietnam dong, vnd, vietnam dong, vietnam currency, vietnam customization |
| Requires at least | 4.3 |
| Tested up to | 4.7 |
| Tested up to | 4.8 |
| Stable tag | 1.3 |
| License | GPLv2 or later |
| License URI | https://www.gnu.org/licenses/gpl-2.0.html |
@@ -74,6 +74,11 @@ Follow these steps to install and use the plugin:
## Changelog
### 1.3.1 - 2017.07.09
* Improve the OnePay domestic gateway.
* Add the plugin icon and banner.
* Add the questionnaire after 4 weeks of installation.
### 1.3 - 2017.04.22
* Add [the OnePay domestic (local ATM cards) gateway](http://onepay.com.vn/)
@@ -87,4 +92,4 @@ Follow these steps to install and use the plugin:
### 1.0
* First release.
* Upload to WordPress.org
* Upload to WordPress.org
+10 -4
View File
@@ -2,8 +2,8 @@
Contributors: htdat
Tags: OnePay WooCommerce, OnePay Vietnam, WooCommerce Vietnam, vietnam, vietnamese, vietnam provinces, paypal for vietnam dong, vnd, vietnam dong, vietnam currency, vietnam customization
Requires at least: 4.3
Tested up to: 4.7.4
Stable tag: 1.3
Tested up to: 4.8
Stable tag: 1.3.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -13,7 +13,7 @@ Add features to WooCommerce stores having anything related to Vietnam: currency,
**"Woo Viet - WooCommerce for Vietnam" brings the features that help to run WooCommerce stores and customize them for Vietnam much easier.**
Xem phiên bản tiếng Việt tại đây https://vi.wordpress.org/plugins/woo-viet/
Xem phiên bản tiếng Việt tại đây [https://vi.wordpress.org/plugins/woo-viet/](https://vi.wordpress.org/plugins/woo-viet/)
**NEW FEATURE**:
Add [the OnePay domestic (local ATM cards) gateway](http://onepay.com.vn/).
@@ -25,7 +25,7 @@ Add [the OnePay domestic (local ATM cards) gateway](http://onepay.com.vn/).
* Add districts to Vietnam provinces.
* Convert `000` of prices to `K` (or anything). E.g: `50000` (VND) will be `50K` (VND), or `50 thousand` (VND).
* Support `VND` for [the PayPal Standard gateway](https://docs.woocommerce.com/document/paypal-standard/). Convert `VND` prices to any PayPal supported currency before sending visitors to the PayPal pages.
* Add [the OnePay domestic (local ATM cards) gateway](http://onepay.com.vn/).
* Add [the OnePay domestic (local ATM cards) gateway](http://onepay.com.vn/). Implement all methods in [the official documents](https://mtf.onepay.vn/developer/?page=modul_noidia_php): QueryDR, IPN, and Return URL.
= ROAD MAP =
@@ -71,9 +71,15 @@ Follow these steps to install and use the plugin:
2. Prices are changed to "K", and the symbol is now "VND".
3. List provinces and districts when selecting Vietnam.
4. Let clients know about the currency conversion before switching to the PayPal pages.
5. OnePay domestic (local ATM cards) gateway.
== Changelog ==
= 1.3.1 - 2017.07.092 =
* Improve the OnePay domestic gateway.
* Add the plugin icon and banner.
* Add the questionnaire after 4 weeks of installation.
= 1.3 - 2017.04.22 =
* Add [the OnePay domestic (local ATM cards) gateway](http://onepay.com.vn/).
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

+6 -2
View File
@@ -7,7 +7,7 @@
* Author URI: https://profiles.wordpress.org/htdat
* Text Domain: woo-viet
* Domain Path: /languages
* Version: 1.3
* Version: 1.3.1
* License: GPLv2+
*/
@@ -92,7 +92,7 @@ class WooViet {
public function notice_if_not_woocommerce() {
$class = 'notice notice-error';
$message = __( 'Woo Viet is not running because WooCommerce is not active. Please activate both plugins',
$message = __( 'Woo Viet is not running because WooCommerce is not active. Please activate both plugins.',
'woo-viet' );
printf( '<div class="%1$s"><p><strong>%2$s</strong></p></div>', $class, $message );
@@ -133,6 +133,10 @@ class WooViet {
include( WOO_VIET_DIR . 'inc/class-wooviet-admin-page.php' );
$this->Admin_Page = new WooViet_Admin_Page();
// Add the notices class
include( WOO_VIET_DIR . 'inc/class-wooviet-notices.php' );
new WooViet_Notices();
}
$settings = self::get_settings();