mirror of
https://github.com/10h30/woo-viet.git
synced 2026-07-12 03:06:29 +09:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 26d9e4ba24 | |||
| 6c333e5abe | |||
| 187dd5bf2b | |||
| c22f935e96 | |||
| 4e78194ba9 | |||
| d44605827a | |||
| 83a1dafdf0 | |||
| 0c43ee467d | |||
| fac3a9709f | |||
| 2e4c7b6265 | |||
| 53eec6c1eb | |||
| 282734961a | |||
| 12fae4d63f | |||
| ad1cda5d85 | |||
| f694d19ffb |
Binary file not shown.
|
After Width: | Height: | Size: 49 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 7.9 KiB |
@@ -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§ion=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' );
|
||||
}
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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__ ) );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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>' ),
|
||||
),
|
||||
|
||||
);
|
||||
@@ -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
@@ -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/).
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 58 KiB |
+6
-2
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user