Skip to content
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

Bug/ts 24 Order notes for transactions id are missing after a new order for admin page is added #20

Merged
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
43 changes: 35 additions & 8 deletions src/Gateways/AbstractGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
use GlobalPayments\Api\Entities\Exceptions\ApiException;
use GlobalPayments\Api\Entities\Reporting\TransactionSummary;
use GlobalPayments\WooCommercePaymentGatewayProvider\Gateways\Requests\RequestArg;
use GlobalPayments\WooCommercePaymentGatewayProvider\Plugin;
use WC_Payment_Gateway_CC;
use WC_Order;
use GlobalPayments\Api\Entities\Transaction;

use GlobalPayments\WooCommercePaymentGatewayProvider\Plugin;

/**
* Shared gateway method implementations
*/
Expand Down Expand Up @@ -140,8 +139,12 @@ abstract class AbstractGateway extends WC_Payment_Gateway_Cc {
*/
public $cvn_reject_conditions;

public function __construct() {
public function __construct( $is_provider = false ) {
if ( $is_provider ) {
return;
}
$this->client = new Clients\SdkClient();

$this->has_fields = true;
$this->supports = array(
'products',
Expand All @@ -165,8 +168,6 @@ public function __construct() {
$this->init_settings();
$this->configure_merchant_settings();
$this->add_hooks();


}

/**
Expand Down Expand Up @@ -315,7 +316,7 @@ public function tokenization_script() {
WC()->version,
true
);

wp_localize_script(
'globalpayments-helper',
'globalpayments_helper_params',
Expand Down Expand Up @@ -745,6 +746,7 @@ protected function add_hooks() {
'admin_enforce_single_gateway'
) );
add_filter( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
add_action( 'woocommerce_new_order', array( $this, 'admin_add_order_note_after_order_created' ));
}

if ( 'no' === $this->enabled ) {
Expand All @@ -769,6 +771,33 @@ protected function add_hooks() {
'woocommerce_available_payment_gateways'
) );
}

}

/**
* Add order note when creating an order from admin with transaction ID
*
* @param int $order_id
*
* @return bool
*/
public function admin_add_order_note_after_order_created( $order_id ) {
if ( ! $order_id ) {
return;
}

$order = wc_get_order( $order_id );
if ( empty( $order) ) {
return;
}
if ( $this->id != $order->get_payment_method() ) {
return;
}
if ( empty( $order->get_transaction_id() )) {
return;
}

$order->add_order_note( __( 'Order created with Transaction ID: ' ) . $order->get_transaction_id() );
}

/**
Expand Down Expand Up @@ -1222,7 +1251,5 @@ public function admin_enqueue_scripts( $hook_suffix ) {
WC()->version
);
}

}

}
2 changes: 1 addition & 1 deletion src/Gateways/ApplePayGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class ApplePayGateway extends AbstractGateway {
public function __construct() {
parent::__construct();

$this->gateway = new GpApiGateway();
$this->gateway = new GpApiGateway( true );
}

public function configure_method_settings() {
Expand Down
2 changes: 1 addition & 1 deletion src/Gateways/GooglePayGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class GooglePayGateway extends AbstractGateway {
public function __construct() {
parent::__construct();

$this->gateway = new GpApiGateway();
$this->gateway = new GpApiGateway( true );
}

public function get_first_line_support_email() {
Expand Down