8000 = 4.1.0 = Now it is compatible to High-Performance Order Storage by committedpro · Pull Request #24 · hit-pay/woocommerce · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

= 4.1.0 = Now it is compatible to High-Performance Order Storage #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
Contributors: HitPay
Tags: hitpay payments, woocommerce, payment gateway, hitpay, pay with hitpay, credit card, paynow, wechatpay, alipay
Requires at least: 4.0
Tested up to: 6.2.2
Stable tag: 4.0.9
Tested up to: 6.4.2
Stable tag: 4.1.0
Requires PHP: 5.5
WC requires at least: 2.4
WC tested up to: 7.8.0
WC tested up to: 8.4.0
License: MIT

HitPay Payment Gateway Plugin allows HitPay merchants to accept PayNow QR, Cards, Apple Pay, Google Pay, WeChatPay, AliPay and GrabPay Payments.
Expand Down Expand Up @@ -219,4 +219,7 @@ The easiest and fastest way is via our live chat on our [website](https://www.hi
- Now it is compatible to block based checkout - Drop-In (Popup) and POS option with Form Build

= 4.0.9 =
- Webhook order_id param changed since some third party plugin intercept this and prevented the webhook execution < 10000 svg aria-label="No newline at end of file" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-no-entry">
- Webhook order_id param changed since some third party plugin intercept this and prevented the webhook execution

= 4.1.0 =
- Now it is compatible to High-Performance Order Storage
14 changes: 10 additions & 4 deletions hitpay-payment-gateway/hitpay-payment-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
/*
Plugin Name: HitPay Payment Gateway
Description: HitPay Payment Gateway Plugin allows HitPay merchants to accept PayNow QR, Cards, Apple Pay, Google Pay, WeChatPay, AliPay and GrabPay Payments. You will need a HitPay account, contact support@hitpay.zendesk.com.
Version: 4.0.9
Version: 4.1.0
Requires at least: 4.0
Tested up to: 6.2.2
Tested up to: 6.4.2
WC requires at least: 2.4
WC tested up to: 7.8.0
WC tested up to: 8.4.0
Requires PHP: 5.5
Author: <a href="https://www.hitpayapp.com>HitPay Payment Solutions Pte Ltd</a>
Author URI: https://www.hitpayapp.com
Expand All @@ -17,14 +17,20 @@
exit; // Exit if accessed directly
}

define('HITPAY_VERSION', '4.0.9');
define('HITPAY_VERSION', '4.1.0');
define('HITPAY_PLUGIN_URL', plugin_dir_url(__FILE__));
define('HITPAY_PLUGIN_PATH', plugin_dir_path(__FILE__));

require_once HITPAY_PLUGIN_PATH . 'vendor/softbuild/hitpay-sdk/src/CurlEmulator.php';

require_once HITPAY_PLUGIN_PATH . 'vendor/autoload.php';

add_action( 'before_woocommerce_init', function() {
if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
}
} );

/**
* Initiate HitPay Mobile Payment once plugin is ready
*/
Expand Down
72 changes: 55 additions & 17 deletions hitpay-payment-gateway/includes/regular-checkout.php
10000
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,52 @@ public function hitpay_load_front_assets() {
}
}
}

public function isHPOSEnabled() {
$status = false;

if (
class_exists( 'Automattic\WooCommerce\Utilities\OrderUtil' ) &&
Automattic\WooCommerce\Utilities\OrderUtil::custom_orders_table_usage_is_enabled()
) {
$status = true;
}

return $status;
}

public function getOrder($order_id) {
if ($this->isHPOSEnabled()) {
$order = wc_get_order( $order_id );
} else {
$order = new WC_Order($order_id);
}

return $order;
}

public function getOrderMetaData($order, $order_id, $key, $single) {
if ($this->isHPOSEnabled()) {
return $order->get_meta( $key, $single );
} else {
return get_post_meta( $order_id, $key, $single );
}
}


public function admin_order_totals( $order_id ){
$order = new WC_Order($order_id);
$order = $this->getOrder($order_id);

if ($order->get_payment_method() == $this->id) {
$order_id = $order->get_id();
$payment_method = '';
$payment_request_id = get_post_meta( $order_id, 'HitPay_payment_request_id', true );
$payment_request_id = $this->getOrderMetaData($order, $order_id, 'HitPay_payment_request_id', true );

if (!empty($payment_request_id)) {
$payment_method = get_post_meta( $order_id, 'HitPay_payment_method', true );
$fees = get_post_meta( $order_id, 'HitPay_fees', true );

$payment_method = $this->getOrderMetaData($order, $order_id, 'HitPay_payment_method', true );

$fees = $this->getOrderMetaData($order, $order_id, 'HitPay_fees', true );
if (empty($payment_method) || empty($fees)) {
try {
$hitpay_client = new Client(
Expand All @@ -145,7 +180,7 @@ public function admin_order_totals( $order_id ){
}

if (!empty($payment_method)) {
$HitPay_currency = get_post_meta( $order_id, 'HitPay_currency', true );
$HitPay_currency = $this->getOrderMetaData($order, $order_id, 'HitPay_currency', true );
?>
<table class="wc-order-totals" style="border-top: 1px solid #999; margin-top:12px; padding-top:12px">
<tbody>
Expand Down Expand Up @@ -746,7 +781,7 @@ public function filterTerminalIds()
*/
public function thankyou_page($order_id) {
if ($this->customize) {
$order = new WC_Order($order_id);
$order = $this->getOrder($order_id);

$thankyoupage_ui_enabled = 1;
$style = $this->style;
Expand Down Expand Up @@ -903,8 +938,10 @@ public function get_payment_staus() {
if ($order_id == 0) {
throw new \Exception( __('Order not found.', $this->domain));
}

$order = $this->getOrder($order_id);

$payment_status = get_post_meta( $order_id, 'HitPay_WHS', true );
$payment_status = $this->getOrderMetaData($order, $order_id, 'HitPay_WHS', true );
if ($payment_status && !empty($payment_status)) {
$status = $payment_status;
}
Expand All @@ -929,7 +966,7 @@ public function return_from_hitpay() {
}

$order_id = (int)sanitize_text_field($_GET['hitpay_order_id']);
$order = new WC_Order($order_id);
$order = $this->getOrder($order_id);

if (isset($_GET['status'])) {
$status = sanitize_text_field($_GET['status']);
Expand Down Expand Up @@ -968,15 +1005,16 @@ public function web_hook_handler() {
}

$order_id = (int)sanitize_text_field($_GET['hitpay_order_id']);

$order = $this->getOrder($order_id);

if ($order_id > 0) {
$HitPay_webhook_triggered = (int)get_post_meta( $order_id, 'HitPay_webhook_triggered', true);
$HitPay_webhook_triggered = (int)$this->getOrderMetaData($order, $order_id, 'HitPay_webhook_triggered', true);
if ($HitPay_webhook_triggered == 1) {
exit;
}
}

$order = new WC_Order($order_id);

$order_data = $order->get_data();

$order->add_meta_data('HitPay_webhook_triggered', 1);
Expand All @@ -990,13 +1028,13 @@ public function web_hook_handler() {
if (Client::generateSignatureArray($salt, $data) == $_POST['hmac']) {
$this->log('hmac check passed');

$HitPay_payment_id = get_post_meta( $order_id, 'HitPay_payment_id', true );
$HitPay_payment_id = $this->getOrderMetaData($order, $order_id, 'HitPay_payment_id', true );

if (!$HitPay_payment_id || empty($HitPay_payment_id)) {
$this->log('saved payment not valid');
}

$HitPay_is_paid = get_post_meta( $order_id, 'HitPay_is_paid', true );
$HitPay_is_paid = $this->getOrderMetaData($order, $order_id, 'HitPay_is_paid', true );

if (!$HitPay_is_paid) {
$status = sanitize_text_field($_POST['status']);
Expand Down Expand Up @@ -1092,13 +1130,13 @@ public function web_hook_handler() {
}

public function process_refund($orderId, $amount = NULL, $reason = '') {
$order = wc_get_order($orderId);
$order = $this->getOrder($orderId);
$amount = (float)strip_tags(trim($amount));
$amountValue = number_format($amount, 2);

try {
$HitPay_transaction_id = get_post_meta( $orderId, 'HitPay_transaction_id', true );
$HitPay_is_refunded = get_post_meta( $orderId, 'HitPay_is_refunded', true );
$HitPay_transaction_id = $this->getOrderMetaData($order, $orderId, 'HitPay_transaction_id', true );
$HitPay_is_refunded = $this->getOrderMetaData($order, $orderId, 'HitPay_is_refunded', true );
if ($HitPay_is_refunded == 1) {
throw new Exception(__('Only one refund allowed per transaction by HitPay Gateway.', $this->domain));
}
Expand Down Expand Up @@ -1173,7 +1211,7 @@ public function getMode()
public function process_payment($order_id) {
global $woocommerce;

$order = wc_get_order($order_id);
$order = $this->getOrder($order_id);

$order_data = $order->get_data();
$order_total = $order->get_total();
Expand Down
11 changes: 7 additions & 4 deletions hitpay-payment-gateway/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
Contributors: HitPay
Tags: hitpay payments, woocommerce, payment gateway, hitpay, pay with hitpay, credit card, paynow, wechatpay, alipay
Requires at least: 4.0
Tested up to: 6.2.2
Stable tag: 4.0.8
Tested up to: 6.4.2
Stable tag: 4.1.0
Requires PHP: 5.5
WC requires at least: 2.4
WC tested up to: 7.8.0
WC tested up to: 8.4.0
License: MIT

HitPay Payment Gateway Plugin allows HitPay merchants to accept PayNow QR, Cards, Apple Pay, Google Pay, WeChatPay, AliPay and GrabPay Payments.
Expand Down Expand Up @@ -192,4 +192,7 @@ The easiest and fastest way is via our live chat on our [website](https://www.hi
- Now it is compatible to block based checkout - Drop-In (Popup) and POS option with Form Build

= 4.0.9 =
- Webhook order_id param changed since some third party plugin intercept this and prevented the webhook execution
- Webhook order_id param changed since some third party plugin intercept this and prevented the webhook execution

= 4.1.0 =
- Now it is compatible to High-Performance Order Storage
0