mirror of
https://github.com/10h30/woo-viet.git
synced 2026-07-12 03:06:29 +09:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 832d8ea491 | |||
| 12649806c3 | |||
| 690312dd87 | |||
| 98d2a83cb1 | |||
| 64bac93cdf |
@@ -25,6 +25,8 @@ class WooViet_VND_PayPal_Standard {
|
||||
*/
|
||||
protected $paypal_currency = 'USD';
|
||||
|
||||
//@todo - declare two vars
|
||||
|
||||
/**
|
||||
* WooViet_VND_PayPal_Standard constructor.
|
||||
*
|
||||
@@ -44,8 +46,12 @@ class WooViet_VND_PayPal_Standard {
|
||||
// Add the exchange rate info for this gateway in the checkout page before proceeding in the PayPal pages
|
||||
add_filter( 'option_woocommerce_paypal_settings', array( $this, 'add_exchange_rate_info' ), 11 );
|
||||
|
||||
// Match currency of Paypal with local order
|
||||
add_action( 'valid-paypal-standard-ipn-request', array( $this, 'match_currency_order' ), 10 );
|
||||
// Match currency and amount between Paypal and WC Order
|
||||
add_action( 'valid-paypal-standard-ipn-request', array( $this, 'match_order_currency_and_amount' ), 5 );
|
||||
|
||||
// Restore currency and amount for WC Order
|
||||
add_action( 'valid-paypal-standard-ipn-request', array( $this, 'restore_order_currency_and_amount' ), 15 );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,17 +117,78 @@ class WooViet_VND_PayPal_Standard {
|
||||
}
|
||||
|
||||
/*
|
||||
* Match response currency from Paypal IPN with the order
|
||||
* Match currency and amount from Paypal IPN with the order
|
||||
*
|
||||
* Topic https://wordpress.org/support/topic/loi-order-bi-on-hold/
|
||||
*
|
||||
* @author Longkt
|
||||
* @since 1.4
|
||||
* @author htdat
|
||||
* @since 1.4.3
|
||||
*/
|
||||
public function match_currency_order($posted) {
|
||||
if($posted['mc_currency']) {
|
||||
$posted['mc_currency'] = $order->get_currency();
|
||||
}
|
||||
public function match_order_currency_and_amount($posted) {
|
||||
|
||||
$order = ! empty( $posted['custom'] ) ? $this->get_paypal_order( $posted['custom'] ) : false;
|
||||
|
||||
if ( $order ) {
|
||||
$this->original_order_currency = $order->get_currency();
|
||||
$this->original_order_total = $order->get_total();
|
||||
|
||||
$order->set_currency( $posted['mc_currency'] );
|
||||
$order->set_total( $posted['mc_gross'] );
|
||||
|
||||
$order->save();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Restore currency and amount of the order after the 'match_order_currency_and_amount' action
|
||||
*
|
||||
* @author htdat
|
||||
* @since 1.4.3
|
||||
*/
|
||||
public function restore_order_currency_and_amount($posted) {
|
||||
|
||||
$order = ! empty( $posted['custom'] ) ? $this->get_paypal_order( $posted['custom'] ) : false;
|
||||
|
||||
if ( $order ) {
|
||||
|
||||
$order->set_currency( $this->original_order_currency );
|
||||
$order->set_total( $this->original_order_total );
|
||||
|
||||
$order->save();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see Grab this code from - can not call it directly https://github.com/woocommerce/woocommerce/blob/f5c2f89af6a9421af8edc2a4aa20d372e5be40f8/includes/gateways/paypal/includes/class-wc-gateway-paypal-response.php#L30
|
||||
*
|
||||
* @since 1.4.3
|
||||
* @author htdat
|
||||
*/
|
||||
protected function get_paypal_order( $raw_custom ) {
|
||||
// We have the data in the correct format, so get the order.
|
||||
$custom = json_decode( $raw_custom );
|
||||
if ( $custom && is_object( $custom ) ) {
|
||||
$order_id = $custom->order_id;
|
||||
$order_key = $custom->order_key;
|
||||
} else {
|
||||
// Nothing was found.
|
||||
WC_Gateway_Paypal::log( 'Order ID and key were not found in "custom".', 'error' );
|
||||
return false;
|
||||
}
|
||||
$order = wc_get_order( $order_id );
|
||||
if ( ! $order ) {
|
||||
// We have an invalid $order_id, probably because invoice_prefix has changed.
|
||||
$order_id = wc_get_order_id_by_order_key( $order_key );
|
||||
$order = wc_get_order( $order_id );
|
||||
}
|
||||
if ( ! $order || $order->get_order_key() !== $order_key ) {
|
||||
WC_Gateway_Paypal::log( 'Order Keys do not match.', 'error' );
|
||||
return false;
|
||||
}
|
||||
return $order;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,6 +8,14 @@ Xem phiên bản tiếng Việt tại đây https://vi.wordpress.org/plugins/woo
|
||||
|
||||
## Changelog
|
||||
|
||||
### 1.4.2 - 2018.04.26 =
|
||||
|
||||
* Fix the fatal error when WooCommerce PayPal Express Checkout Gateway is not active.
|
||||
|
||||
### 1.4.1 - 2018.04.26 =
|
||||
|
||||
* Fix the SVN command, missing some files on WP.org repo.
|
||||
|
||||
### 1.4 - 2018.04.24
|
||||
|
||||
* Fix the on-hold order issue with PayPal Standard.
|
||||
|
||||
+10
-5
@@ -4,7 +4,7 @@ Tags: OnePay WooCommerce, OnePay Vietnam, WooCommerce Vietnam, vietnam, vietname
|
||||
Requires at least: 4.3
|
||||
Tested up to: 4.9.5
|
||||
Requires PHP: 5.6
|
||||
Stable tag: 1.4
|
||||
Stable tag: 1.4.3-dev
|
||||
License: GPLv2 or later
|
||||
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
@@ -16,9 +16,6 @@ Add features to WooCommerce stores having anything related to Vietnam: currency,
|
||||
|
||||
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/).
|
||||
|
||||
= FEATURES =
|
||||
|
||||
* Change the VND currency symbol `đ` to anything, e.g: `VND`, `VNĐ`, `đồng`, etc.
|
||||
@@ -26,7 +23,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.
|
||||
* Support `VND` for [the PayPal Express Checkout gateway](https://docs.woocommerce.com/document/paypal-express-checkout/)
|
||||
* Support `VND` for [the PayPal Express Checkout gateway](https://docs.woocommerce.com/document/paypal-express-checkout/).
|
||||
* 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 =
|
||||
@@ -76,6 +73,14 @@ Follow these steps to install and use the plugin:
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= 1.4.2 - 2018.04.26 =
|
||||
|
||||
* Fix the fatal error when WooCommerce PayPal Express Checkout Gateway is not active.
|
||||
|
||||
= 1.4.1 - 2018.04.26 =
|
||||
|
||||
* Fix the SVN command, missing some files on WP.org repo.
|
||||
|
||||
= 1.4 - 2018.04.24 =
|
||||
|
||||
* Fix the on-hold order issue with PayPal Standard.
|
||||
|
||||
+4
-3
@@ -7,7 +7,7 @@
|
||||
* Author URI: https://profiles.wordpress.org/htdat
|
||||
* Text Domain: woo-viet
|
||||
* Domain Path: /languages
|
||||
* Version: 1.4
|
||||
* Version: 1.4.2
|
||||
*
|
||||
* WC requires at least: 2.6
|
||||
* WC tested up to: 2.3
|
||||
@@ -211,8 +211,9 @@ class WooViet {
|
||||
}
|
||||
|
||||
// Check if "Support VND for the PayPal Express Checkout gateway" is enabled
|
||||
if ( 'yes' == $settings['vnd_paypal_express_checkout']['enabled'] ) {
|
||||
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']
|
||||
|
||||
Reference in New Issue
Block a user