Skip to content

Commit

Permalink
Bug/ts 24 Order notes for transactions id are missing after a new ord…
Browse files Browse the repository at this point in the history
…er for admin page is added (#20)

* add order note after order created

* debug status

* TS-24: add order note when has T_id

* TR-24: [Integrations]: allow gateway instantiation without wp custom functionality

Co-authored-by: apetrovici <[email protected]>
  • Loading branch information
javiercrac and apetrovici authored Jun 22, 2022
1 parent 80492c5 commit 4eaf4aa
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 10 deletions.
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

0 comments on commit 4eaf4aa

Please sign in to comment.