Plugin Directory

Changeset 2442211


Ignore:
Timestamp:
12/18/2020 10:47:54 AM (5 years ago)
Author:
quadpay
Message:
  • Fix - fixed issue with checking QuadPay status for on hold and pending orders
  • Tweak - added time settings for order check
  • Tweak - added detailed log and order notes messages
  • Tweak - added "Discover" as a credit card option in QuadPay checkout button
Location:
quadpay-gateway-for-woocommerce
Files:
15 added
2 edited

Legend:

Unmodified
Added
Removed
  • quadpay-gateway-for-woocommerce/trunk/quadpay.php

    r2433401 r2442211  
    55Author: QuadPay, Inc.
    66Author URI: https://www.quadpay.com
    7 Version: 1.3.8
     7Version: 1.3.9
    88WC requires at least: 3.1.0
    99WC tested up to: 4.8.0
     
    8585         */
    8686        private $configurationUrl;
     87        /**
     88         * @var string
     89         */
     90        private $order_check_time;
    8791
    8892        /**
     
    136140            }
    137141
    138             $this->description = __('Pay in 4 interest-free installments. Credit and debit cards accepted: Visa, Mastercard, Amex','woo_quadpay');
     142            $this->description = __('Pay in 4 interest-free installments. Credit and debit cards accepted: Visa, Mastercard, Amex, Discover','woo_quadpay');
    139143
    140144            self::$log_enabled  = $this->get_option( 'logging' ) === 'yes' ? true : false;
     
    167171            $this->minimum_amount                    = $this->get_option( 'quadpay-amount-minimum' );
    168172            $this->maximum_amount                    = $this->get_option( 'quadpay-maximum-amount' );
     173            // Default value 24h
     174            $this->order_check_time                =
     175                ( !empty( $this->get_option( 'order_check_time' ) ) ? $this->get_option( 'order_check_time' ) : 'DAY_IN_SECONDS');
    169176
    170177        }
     
    227234                    'type'        => 'select',
    228235                    'options'     => $env_values,
    229                     'description' => __( 'When in in Test/Sandbox mode, no transactions will actually be processed.', 'woo_quadpay' ),
     236                    'description' => __( 'When in Test/Sandbox mode, no transactions will actually be processed.', 'woo_quadpay' ),
    230237                ),
    231238                'client_id'       => array(
     
    248255                    'default'     => 'no',
    249256                    'desc_tip'    => true,
     257                ),
     258                'order_check_settings' => array(
     259                    'title'       => __( 'Order Check', 'woo_quadpay ' ),
     260                    'type'        => 'title',
     261                    'description' => __( '' ),
     262                ),
     263                'order_check_time'                  => array(
     264                    'title'       => __( 'Order Check Timeframe', 'woo_quadpay' ),
     265                    'label'       => __( 'Order Check Timeframe', 'woo_quadpay' ),
     266                    'type'        => 'select',
     267                    'options'     => array(
     268                            'DAY_IN_SECONDS'   => __( '24h hours', 'woo_quadpay' ),
     269                            'WEEK_IN_SECONDS'  => __( 'One Week', 'woo_quadpay' ),
     270                            'MONTH_IN_SECONDS' => __( 'One Month', 'woo_quadpay' ),
     271                            'YEAR_IN_SECONDS'  => __( 'One Year', 'woo_quadpay' ),
     272                    ),
     273                    'description' => __( 'How far back should authorized, not captured orders be checked for status change.', 'woo_quadpay' ),
    250274                ),
    251275                'widget_settings' => array(
     
    929953                self::$log->add( 'quadpay', $message );
    930954            }
     955
     956            if( WP_DEBUG && WP_DEBUG_LOG )
     957                error_log( $message );
     958
    931959        }
    932960
     
    10281056        public function check_on_hold_orders() {
    10291057
     1058            $this->log( 'Start checking On Hold orders' );
     1059
    10301060            // Get ON-HOLD orders that are "pending" at QuadPay that need to be checked whether approved or denied
    1031             $args = array(
    1032                 'status'         => 'on-hold',
    1033                 'type'           => 'shop_order',
    1034                 'date_created'   => '>' . ( time() - DAY_IN_SECONDS ),
    1035                 'limit'          => -1,
    1036                 'payment_method' => 'quadpay',
    1037             );
     1061            $args = array(
     1062                'status'         => 'on-hold',
     1063                'type'           => 'shop_order',
     1064                'date_created'   => '>' . ( time() - constant( $this->order_check_time ) ),
     1065                'limit'          => -1,
     1066                'payment_method' => 'quadpay',
     1067            );
     1068
     1069
     1070
    10381071            $on_hold_orders = wc_get_orders( $args );
    10391072
    10401073            if ( empty( $on_hold_orders ) ) {
     1074
     1075                $this->log( 'No On Hold orders found (' . $this->order_check_time . ')' );
     1076                $this->log( 'End checking On Hold orders' );
     1077
    10411078                return;
    10421079            }
     1080
     1081            $this->log( count( $on_hold_orders ) . ' On Hold orders found' );
    10431082
    10441083            foreach ( $on_hold_orders as $order ) {
     
    11001139                    if ( strtotime( 'now' ) - strtotime( $order_date ) > 3600 ) {
    11011140
    1102                         $order->add_order_note( sprintf( __( 'On Hold Order Expired' ) ) );
     1141                        $order->add_order_note( sprintf( __( 'On Hold Order Expired at QuadPay' ) ) );
    11031142                        $order->update_status( 'cancelled' );
    11041143
     
    13671406     * Process custom WooCommerce Order Actions: Check payment status on QuadPay
    13681407     *
    1369      * @param object $order
     1408     * @param $order
    13701409     *
    13711410     * @since 1.3.0
     
    14071446        $response_code = wp_remote_retrieve_response_code( $response );
    14081447
    1409         // Check status of order
     1448        $response_message = wp_remote_retrieve_response_message( $response );
     1449
     1450        // Check status of order
    14101451        if ( $response_code == 200 ) {
    14111452
    14121453            // Check status of order
    1413             if ( $body->orderStatus == "Approved" ) {
     1454            if ( 'Approved' == $body->orderStatus ) {
    14141455
    14151456                $order->add_order_note( sprintf( __( 'Checked payment status with QuadPay. Payment approved. QuadPay Order ID: %s', 'woo_quadpay' ), $body->orderId ) );
    14161457                $order->payment_complete( $order_id );
    14171458
    1418             } elseif ( $body->orderStatus == "Created" ) {
     1459            } elseif ( 'Created' == $body->orderStatus ) {
    14191460
    14201461                $order->add_order_note( __( 'Checked payment status with QuadPay. Still pending approval.', 'woo_quadpay' ) );
    14211462                $order->update_status( 'pending' );
    14221463
    1423             } elseif ( $body->orderStatus == 'Abandoned' ) {
     1464            } elseif ( 'Abandoned' == $body->orderStatus ) {
    14241465
    14251466                $order->add_order_note( sprintf( __( 'Checked payment status with QuadPay. Payment %s. QuadPay Order ID: %s', 'woo_quadpay' ), strtolower( $body->orderStatus ), $body->orderId ) );
     
    14351476        } else {
    14361477
    1437             $order->add_order_note( 'Can\'t check order payment status on QuadPay, try again later.' );
     1478            $order->add_order_note( 'Can\'t check order payment status on QuadPay (response message: ' . $response_message . ').' );
    14381479
    14391480        }
  • quadpay-gateway-for-woocommerce/trunk/readme.txt

    r2433401 r2442211  
    5353* none
    5454
     55= 1.3.9 =
     56* Fix - fixed issue with checking QuadPay status for on hold and pending orders
     57* Tweak - added time settings for order check
     58* Tweak - added detailed log and order notes messages
     59* Tweak - added "Discover" as a credit card option in QuadPay checkout button
     60
    5561== Changelog ==
    5662= 1.3.8 =
Note: See TracChangeset for help on using the changeset viewer.