Plugin Directory

Changeset 2303953


Ignore:
Timestamp:
05/13/2020 07:05:25 AM (6 years ago)
Author:
paybybankdevs
Message:

update paybybank and add error log message for remote post

Location:
paybybank/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • paybybank/trunk/README.txt

    r2303949 r2303953  
    44Tags: paybybank, woocomemrce, e-commerce, ecommerce, sales, sell, store, payments
    55Requires at least: 4.6
    6 Tested up to: 5.3.2
    7 Stable tag: 1.4
     6Tested up to: 5.4.1
     7Stable tag: 1.5
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    102102== Changelog ==
    103103
     104= 1.0.2 =
     105*Release Date - 24 January 2020*
     106* Add error log for POST requests to locate error.
     107
    104108= 1.0.1 =
    105109*Release Date - 24 January 2020*
  • paybybank/trunk/admin/class-dc-paybybank-admin.php

    r2231509 r2303953  
    5959     * Display field value on the order edit page
    6060     *
    61      * @param $order
     61     * @param WC_Order $order
    6262     */
    6363    public function dc_paybybank_checkout_field_display_admin_order_meta( $order ) {
    64         $method = get_post_meta( $order->id, '_payment_method', true );
     64        $method = get_post_meta( $order->get_id(), '_payment_method', true );
    6565        if ( $method != 'dc-paybybank' ) {
    6666            return;
    6767        }
    6868
    69         $reference_code = get_post_meta( $order->id, 'dc_reference_code', true );
     69        $reference_code = get_post_meta( $order->get_id(), 'dc_reference_code', true );
    7070
    7171        echo '<p><strong>' . __( 'PayByBank Reference Code', 'dc-paybybank' ) . ':</strong> ' . $reference_code . '</p>';
     
    157157            $base_path = DC_PAYBYBANK_BASE_PATH;
    158158        }
    159         $result = wp_remote_get( $base_path . DC_PAYBYBANK_SUBMIT_ORDER_PATH . $gateway->api_key . '/' . $order->get_id(), array( 'sslverify' => false ) );
     159        $result       = wp_remote_get( $base_path . DC_PAYBYBANK_SUBMIT_ORDER_PATH . $gateway->api_key . '/' . $order->get_id(), array( 'sslverify' => false ) );
    160160        $final_result = json_decode( $result['body'], true );
    161161        if ( is_array( $final_result ) && sizeof( $final_result ) == 1 ) {
     
    171171    }
    172172
     173    /**
     174     * @param $location
     175     *
     176     * @return string
     177     */
    173178    public function set_dc_paybybank_success_message( $location ) {
    174179        return add_query_arg( 'message', 12, $location );
    175180    }
    176181
     182    /**
     183     * @param $location
     184     *
     185     * @return string
     186     */
    177187    public function set_dc_paybybank_failure_message( $location ) {
    178188        return add_query_arg( 'message', 13, $location );
    179189    }
    180190
     191    /**
     192     * @param $location
     193     *
     194     * @return string
     195     */
    181196    public function set_dc_paybybank_pending_message( $location ) {
    182197        return add_query_arg( 'message', 14, $location );
     
    255270    public function dc_paybybank_add_email_instructions( $order, $sent_to_admin, $plain_text, $email ) {
    256271        $gateway = new WC_Gateway_DC_PayByBank();
    257         if ( $gateway->instructions && ! $sent_to_admin && 'dc-paybybank' == $order->payment_method && 'wc-' . $order->get_status() == $gateway->order_status ) {
     272        if ( $gateway->instructions && ! $sent_to_admin && 'dc-paybybank' == $order->get_payment_method() && 'wc-' . $order->get_status() == $gateway->order_status ) {
    258273            echo wpautop( wptexturize( $gateway->instructions ) ) . PHP_EOL;
    259274        }
    260275
    261276        $reference_code = get_post_meta( $order->get_id(), 'dc_reference_code', true );
    262         if ( 'wc-' . $order->get_status() == $gateway->order_status && 'dc-paybybank' == $order->payment_method ) {
     277        if ( 'wc-' . $order->get_status() == $gateway->order_status && 'dc-paybybank' == $order->get_payment_method() ) {
    263278            if ( ! $sent_to_admin ) {
    264279                echo wpautop( wptexturize( __( 'To pay for your order and execute it promptly with no additional procedures and no payment costs, you can make payments to your bank via e-banking or phone banking by selecting Payments> PayByBank and entering the payment code below and the exact one amount of payment. <br> We will automatically receive your payment and your order will be forwarded immediately. <br> There are no payment costs, as long as the bank is Greek and you choose to pay via web banking or phone banking or your bank\'s app and not in a physical store. This applies to all Greek banks. <br> <br> Please pay the bank of your choice with the following payment code:', 'dc-paybybank' ) . ' <b>' . $reference_code . '</b>' ) );
     
    266281                echo wpautop( wptexturize( __( 'PayByBank Reference Code', 'dc-paybybank' ) . ' : ' . $reference_code ) );
    267282            }
    268         } else if ( $order->get_status() == 'paybybank-paid' && 'dc-paybybank' == $order->payment_method ) {
     283        } else if ( $order->get_status() == 'paybybank-paid' && 'dc-paybybank' == $order->get_payment_method() ) {
    269284            echo wpautop( wptexturize( __( 'Order paid successfully by PayByBank.', 'dc-paybybank' ) ) );
    270285        }
    271286    }
    272287
     288    /**
     289     * Register PayByBank paid status
     290     */
    273291    public function dc_paybybank_register_paybybank_paid_order_status() {
    274292        register_post_status( 'wc-paybybank-paid', array(
     
    281299    }
    282300
    283     public function dc_paybybank_add__paybybank_paid_to_order_statuses( $order_statuses ) {
     301    /**
     302     * Add new paid status in WooCommerce orders
     303     *
     304     * @param $order_statuses
     305     *
     306     * @return array
     307     */
     308    public function dc_paybybank_add_paybybank_paid_to_order_statuses( $order_statuses ) {
    284309
    285310        $new_order_statuses = array();
     
    297322    }
    298323
     324    /**
     325     * Email instructions override
     326     *
     327     * @param $order_id
     328     * @param $order
     329     */
    299330    public function dc_paybybank_email_order_status_paybybank_paid( $order_id, $order ) {
    300331
  • paybybank/trunk/dc-paybybank.php

    r2232835 r2303953  
    1111 * Plugin URI:        https://www.paybybank.gr/el/companies/e-commerce/verified_plugins
    1212 * Description:       Adds PayByBank payment as a payment gateway for WooCommerce.
    13  * Version:           1.0.1
     13 * Version:           1.0.2
     14 * Requires at least: 4.4
     15 * Tested up to: 5.4
     16 * WC requires at least: 3.3.0
     17 * WC tested up to: 4.1.0
    1418 * Author:            Digital Challenge
    1519 * Author URI:        https://www.dicha.gr
     
    2630
    2731/**
    28  * Currently plugin version.
    29  * Start at version 1.0.0 and use SemVer - https://semver.org
    30  * Rename this for your plugin and update it as you release new versions.
    31  */
    32 define( 'DC_PAYBYBANK_VERSION', '1.0.1' );
    33 define( 'DC_PAYBYBANK_BASE_TEST_PATH', 'https://testapi.e-paylink.com/gateway/rest/api/v1' );
    34 define( 'DC_PAYBYBANK_BASE_PATH', 'https://www.wu-online.gr/gateway/rest/api/v1' );
    35 define( 'DC_PAYBYBANK_SUBMIT_ORDER_PATH', '/order/merchant/' );
    36 
    37 /**
    38  * The code that runs during plugin activation.
    39  * This action is documented in includes/class-dc-paybybank-activator.php
    40  */
    41 function activate_dc_paybybank() {
    42     require_once plugin_dir_path( __FILE__ ) . 'includes/class-dc-paybybank-activator.php';
    43     Dc_Paybybank_Activator::activate();
     32 * Check if WooCommerce is active
     33 **/
     34if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
     35
     36    /**
     37     * Currently plugin version.
     38     * Start at version 1.0.0 and use SemVer - https://semver.org
     39     * Rename this for your plugin and update it as you release new versions.
     40     */
     41    define( 'DC_PAYBYBANK_VERSION', '1.0.2' );
     42    define( 'DC_PAYBYBANK_BASE_TEST_PATH', 'https://testapi.e-paylink.com/gateway/rest/api/v1' );
     43    define( 'DC_PAYBYBANK_BASE_PATH', 'https://www.wu-online.gr/gateway/rest/api/v1' );
     44    define( 'DC_PAYBYBANK_SUBMIT_ORDER_PATH', '/order/merchant/' );
     45
     46    /**
     47     * The code that runs during plugin activation.
     48     * This action is documented in includes/class-dc-paybybank-activator.php
     49     */
     50    function activate_dc_paybybank() {
     51        require_once plugin_dir_path( __FILE__ ) . 'includes/class-dc-paybybank-activator.php';
     52        Dc_Paybybank_Activator::activate();
     53    }
     54
     55    /**
     56     * The code that runs during plugin deactivation.
     57     * This action is documented in includes/class-dc-paybybank-deactivator.php
     58     */
     59    function deactivate_dc_paybybank() {
     60        require_once plugin_dir_path( __FILE__ ) . 'includes/class-dc-paybybank-deactivator.php';
     61        Dc_Paybybank_Deactivator::deactivate();
     62    }
     63
     64    register_activation_hook( __FILE__, 'activate_dc_paybybank' );
     65    register_deactivation_hook( __FILE__, 'deactivate_dc_paybybank' );
     66
     67    /**
     68     * The core plugin class that is used to define internationalization,
     69     * admin-specific hooks, and public-facing site hooks.
     70     */
     71    require plugin_dir_path( __FILE__ ) . 'includes/class-dc-paybybank.php';
     72
     73    /**
     74     * Begins execution of the plugin.
     75     *
     76     * Since everything within the plugin is registered via hooks,
     77     * then kicking off the plugin from this point in the file does
     78     * not affect the page life cycle.
     79     *
     80     * @since    1.0.0
     81     */
     82    function run_dc_paybybank() {
     83
     84        $plugin = new Dc_Paybybank();
     85        $plugin->run();
     86
     87    }
     88
     89    run_dc_paybybank();
     90
     91    /**
     92     * PayByBank Payment Gateway.
     93     *
     94     * Creates the PayByBank Payment Gateway.
     95     */
     96    add_action( 'plugins_loaded', 'init_dc_paybybank_gateway_class' );
     97    function init_dc_paybybank_gateway_class() {
     98
     99        class WC_Gateway_DC_PayByBank extends WC_Payment_Gateway {
     100
     101            public $domain;
     102            public $api_key;
     103            public $mode;
     104            public $instructions;
     105            public $payment_code_life;
     106            public $order_status;
     107            public $extra_fee;
     108
     109            /**
     110             * Constructor for the gateway.
     111             */
     112            public function __construct() {
     113
     114                $this->domain = 'dc-paybybank';
     115
     116                $this->id                 = 'dc-paybybank';
     117                $this->icon               = apply_filters( 'woocommerce_paybybank_gateway_icon', '' );
     118                $this->has_fields         = false;
     119                $this->method_title       = __( 'PayByBank', $this->domain );
     120                $this->method_description = __( 'Allows payments with PayByBank.', $this->domain );
     121
     122
     123                // Load the settings.
     124                $this->init_form_fields();
     125                $this->init_settings();
     126
     127                // Define user set variables
     128                $this->title             = $this->get_option( 'title' );
     129                $this->description       = $this->get_option( 'description' );
     130                $this->instructions      = $this->get_option( 'instructions' );
     131                $this->api_key           = $this->get_option( 'api_key' );
     132                $this->mode              = $this->get_option( 'mode' );
     133                $this->payment_code_life = $this->get_option( 'payment_code_life' );
     134                $this->order_status      = $this->get_option( 'order_status', 'processing' );
     135                $this->extra_fee         = $this->get_option( 'extra_fee' );
     136
     137                // Actions
     138                add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array(
     139                    $this,
     140                    'process_admin_options'
     141                ) );
     142
     143            }
     144
     145            /**
     146             * Initialise Gateway Settings Form Fields.
     147             */
     148            public function init_form_fields() {
     149
     150
     151                $this->form_fields = array(
     152                    'enabled'           => array(
     153                        'title'   => __( 'Enable/Disable', $this->domain ),
     154                        'type'    => 'checkbox',
     155                        'label'   => __( 'Enable PayByBank Payment', $this->domain ),
     156                        'default' => 'no'
     157                    ),
     158                    'title'             => array(
     159                        'title'       => __( 'Title', $this->domain ),
     160                        'type'        => 'text',
     161                        'description' => __( 'This controls the title which the user sees during checkout.', $this->domain ),
     162                        'default'     => __( 'PayByBank Payment', $this->domain ),
     163                    ),
     164                    'order_status'      => array(
     165                        'title'       => __( 'Order Status', $this->domain ),
     166                        'type'        => 'select',
     167                        'class'       => 'wc-enhanced-select',
     168                        'description' => __( 'Choose whether status you wish after checkout.', $this->domain ),
     169                        'default'     => 'wc-processing',
     170                        'options'     => wc_get_order_statuses()
     171                    ),
     172                    'api_key'           => array(
     173                        'title'       => __( 'API Key', $this->domain ),
     174                        'type'        => 'text',
     175                        'description' => __( 'The API key provided by PayByBank', $this->domain ),
     176                        'default'     => '',
     177                        'desc_tip'    => true,
     178                    ),
     179                    'mode'              => array(
     180                        'title'       => __( 'Mode', $this->domain ),
     181                        'type'        => 'checkbox',
     182                        'label'       => __( 'Enable test mode', $this->domain ),
     183                        'description' => __( 'This controls the payment mode as TEST or LIVE.', $this->domain ),
     184                        'default'     => 'yes'
     185                    ),
     186                    'payment_code_life' => array(
     187                        'title'       => __( 'Payment Code Life', $this->domain ),
     188                        'type'        => 'text',
     189                        'description' => __( 'The life of Payment Code in Hours. Default is 720 hours (30 days)', $this->domain ),
     190                    ),
     191                    'extra_fee'         => array(
     192                        'title'       => __( 'Extra Fee', $this->domain ),
     193                        'type'        => 'text',
     194                        'description' => __( 'Set the extra fee (if applicable) for this payment method. Leave empty if you don\'t want to add extra fee for this payment method', $this->domain ),
     195                    ),
     196                    'description'       => array(
     197                        'title'       => __( 'Description', $this->domain ),
     198                        'type'        => 'textarea',
     199                        'description' => __( 'Payment method description that the customer will see on your checkout.', $this->domain ),
     200                        'default'     => __( 'Once you have completed your order, you will receive a PayByBank online payment code. You will receive the password and email you have provided. Then log in with your online banking or telephone banking at any Greek bank you choose PayByBank for payments and enter the code to complete the payment.', $this->domain ),
     201                    ),
     202                    'instructions'      => array(
     203                        'title'       => __( 'Instructions', $this->domain ),
     204                        'type'        => 'textarea',
     205                        'description' => __( 'Instructions that will be added to the thank you page and emails.', $this->domain ),
     206                    )
     207                );
     208            }
     209
     210            /**
     211             * Process the payment and return the result.
     212             *
     213             * @param int $order_id
     214             *
     215             * @return array
     216             */
     217            public function process_payment( $order_id ) {
     218
     219                $order = wc_get_order( $order_id );
     220                // Custom function to make the call to API to create the reference code for payment
     221                $this->create_reference_code( $order );
     222
     223                $status = 'wc-' === substr( $this->order_status, 0, 3 ) ? substr( $this->order_status, 3 ) : $this->order_status;
     224
     225                // Set order status
     226                $order->update_status( $status, __( 'Checkout with PayByBank payment.', $this->domain ) );
     227
     228                // Reduce stock levels
     229                wc_reduce_stock_levels( $order_id );
     230
     231                // Remove cart
     232                WC()->cart->empty_cart();
     233
     234                // Return thankyou redirect
     235                return array(
     236                    'result'   => 'success',
     237                    'redirect' => $this->get_return_url( $order )
     238                );
     239            }
     240
     241            /**
     242             * Create reference code for PayByBank from POST request
     243             *
     244             * @param WC_Order $order
     245             */
     246            public function create_reference_code( WC_Order $order ) {
     247                if ( $this->mode == 'yes' ) {
     248                    $base_path = DC_PAYBYBANK_BASE_TEST_PATH;
     249                } else {
     250                    $base_path = DC_PAYBYBANK_BASE_PATH;
     251                }
     252
     253                $result = wp_remote_post( $base_path . DC_PAYBYBANK_SUBMIT_ORDER_PATH . $this->api_key .
     254                                          '?merchant_order_id=' . $order->get_id() . '&merchant_customer_id=' .
     255                                          $order->get_customer_id() . '&amount=' . $order->get_total() . '&payment_code_life=' . $this->payment_code_life,
     256                    array( 'sslverify' => false ) );
     257                if ( is_array( $result ) ) {
     258                    $final_result = json_decode( $result['body'], true );
     259                    update_post_meta( $order->get_id(), 'dc_reference_code', $final_result['omtTransactionBank']['bankPaymentCode'] );
     260                } else {
     261                    error_log( __( 'PayByBank error: Problem during POST request - ', $this->domain ) . $result->get_error_message() );
     262                }
     263            }
     264        }
     265    }
    44266}
    45 
    46 /**
    47  * The code that runs during plugin deactivation.
    48  * This action is documented in includes/class-dc-paybybank-deactivator.php
    49  */
    50 function deactivate_dc_paybybank() {
    51     require_once plugin_dir_path( __FILE__ ) . 'includes/class-dc-paybybank-deactivator.php';
    52     Dc_Paybybank_Deactivator::deactivate();
    53 }
    54 
    55 register_activation_hook( __FILE__, 'activate_dc_paybybank' );
    56 register_deactivation_hook( __FILE__, 'deactivate_dc_paybybank' );
    57 
    58 /**
    59  * The core plugin class that is used to define internationalization,
    60  * admin-specific hooks, and public-facing site hooks.
    61  */
    62 require plugin_dir_path( __FILE__ ) . 'includes/class-dc-paybybank.php';
    63 
    64 /**
    65  * Begins execution of the plugin.
    66  *
    67  * Since everything within the plugin is registered via hooks,
    68  * then kicking off the plugin from this point in the file does
    69  * not affect the page life cycle.
    70  *
    71  * @since    1.0.0
    72  */
    73 function run_dc_paybybank() {
    74 
    75     $plugin = new Dc_Paybybank();
    76     $plugin->run();
    77 
    78 }
    79 
    80 run_dc_paybybank();
    81 
    82 /**
    83  * PayByBank Payment Gateway.
    84  *
    85  * Creates the PayByBank Payment Gateway.
    86  */
    87 add_action( 'plugins_loaded', 'init_dc_paybybank_gateway_class' );
    88 function init_dc_paybybank_gateway_class() {
    89 
    90     class WC_Gateway_DC_PayByBank extends WC_Payment_Gateway {
    91 
    92         public $domain;
    93         public $api_key;
    94         public $mode;
    95         public $instructions;
    96         public $payment_code_life;
    97         public $order_status;
    98         public $extra_fee;
    99 
    100         /**
    101          * Constructor for the gateway.
    102          */
    103         public function __construct() {
    104 
    105             $this->domain = 'dc-paybybank';
    106 
    107             $this->id                 = 'dc-paybybank';
    108             $this->icon               = apply_filters( 'woocommerce_paybybank_gateway_icon', '' );
    109             $this->has_fields         = false;
    110             $this->method_title       = __( 'PayByBank', $this->domain );
    111             $this->method_description = __( 'Allows payments with PayByBank.', $this->domain );
    112 
    113 
    114             // Load the settings.
    115             $this->init_form_fields();
    116             $this->init_settings();
    117 
    118             // Define user set variables
    119             $this->title             = $this->get_option( 'title' );
    120             $this->description       = $this->get_option( 'description' );
    121             $this->instructions      = $this->get_option( 'instructions' );
    122             $this->api_key           = $this->get_option( 'api_key' );
    123             $this->mode              = $this->get_option( 'mode' );
    124             $this->payment_code_life = $this->get_option( 'payment_code_life' );
    125             $this->order_status      = $this->get_option( 'order_status', 'processing' );
    126             $this->extra_fee         = $this->get_option( 'extra_fee' );
    127 
    128             // Actions
    129             add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array(
    130                 $this,
    131                 'process_admin_options'
    132             ) );
    133 
    134         }
    135 
    136         /**
    137          * Initialise Gateway Settings Form Fields.
    138          */
    139         public function init_form_fields() {
    140 
    141 
    142             $this->form_fields = array(
    143                 'enabled'           => array(
    144                     'title'   => __( 'Enable/Disable', $this->domain ),
    145                     'type'    => 'checkbox',
    146                     'label'   => __( 'Enable PayByBank Payment', $this->domain ),
    147                     'default' => 'no'
    148                 ),
    149                 'title'             => array(
    150                     'title'       => __( 'Title', $this->domain ),
    151                     'type'        => 'text',
    152                     'description' => __( 'This controls the title which the user sees during checkout.', $this->domain ),
    153                     'default'     => __( 'PayByBank Payment', $this->domain ),
    154                 ),
    155                 'order_status'      => array(
    156                     'title'       => __( 'Order Status', $this->domain ),
    157                     'type'        => 'select',
    158                     'class'       => 'wc-enhanced-select',
    159                     'description' => __( 'Choose whether status you wish after checkout.', $this->domain ),
    160                     'default'     => 'wc-processing',
    161                     'options'     => wc_get_order_statuses()
    162                 ),
    163                 'api_key'           => array(
    164                     'title'       => __( 'API Key', $this->domain ),
    165                     'type'        => 'text',
    166                     'description' => __( 'The API key provided by PayByBank', $this->domain ),
    167                     'default'     => '',
    168                     'desc_tip'    => true,
    169                 ),
    170                 'mode'              => array(
    171                     'title'       => __( 'Mode', $this->domain ),
    172                     'type'        => 'checkbox',
    173                     'label'       => __( 'Enable test mode', $this->domain ),
    174                     'description' => __( 'This controls the payment mode as TEST or LIVE.', $this->domain ),
    175                     'default'     => 'yes'
    176                 ),
    177                 'payment_code_life' => array(
    178                     'title'       => __( 'Payment Code Life', $this->domain ),
    179                     'type'        => 'text',
    180                     'description' => __( 'The life of Payment Code in Hours. Default is 720 hours (30 days)', $this->domain ),
    181                 ),
    182                 'extra_fee'         => array(
    183                     'title'       => __( 'Extra Fee', $this->domain ),
    184                     'type'        => 'text',
    185                     'description' => __( 'Set the extra fee (if applicable) for this payment method. Leave empty if you don\'t want to add extra fee for this payment method', $this->domain ),
    186                 ),
    187                 'description'       => array(
    188                     'title'       => __( 'Description', $this->domain ),
    189                     'type'        => 'textarea',
    190                     'description' => __( 'Payment method description that the customer will see on your checkout.', $this->domain ),
    191                     'default'     => __( 'Once you have completed your order, you will receive a PayByBank online payment code. You will receive the password and email you have provided. Then log in with your online banking or telephone banking at any Greek bank you choose PayByBank for payments and enter the code to complete the payment.', $this->domain ),
    192                 ),
    193                 'instructions'      => array(
    194                     'title'       => __( 'Instructions', $this->domain ),
    195                     'type'        => 'textarea',
    196                     'description' => __( 'Instructions that will be added to the thank you page and emails.', $this->domain ),
    197                 )
    198             );
    199         }
    200 
    201         /**
    202          * Process the payment and return the result.
    203          *
    204          * @param int $order_id
    205          *
    206          * @return array
    207          */
    208         public function process_payment( $order_id ) {
    209 
    210             $order = wc_get_order( $order_id );
    211             // Custom function to make the call to API to create the reference code for payment
    212             $this->create_reference_code( $order );
    213 
    214             $status = 'wc-' === substr( $this->order_status, 0, 3 ) ? substr( $this->order_status, 3 ) : $this->order_status;
    215 
    216             // Set order status
    217             $order->update_status( $status, __( 'Checkout with PayByBank payment.', $this->domain ) );
    218 
    219             // Reduce stock levels
    220             $order->reduce_order_stock();
    221 
    222             // Remove cart
    223             WC()->cart->empty_cart();
    224 
    225             // Return thankyou redirect
    226             return array(
    227                 'result'   => 'success',
    228                 'redirect' => $this->get_return_url( $order )
    229             );
    230         }
    231 
    232         public function create_reference_code( WC_Order $order ) {
    233             if ( $this->mode == 'yes' ) {
    234                 $base_path = DC_PAYBYBANK_BASE_TEST_PATH;
    235             } else {
    236                 $base_path = DC_PAYBYBANK_BASE_PATH;
    237             }
    238 
    239             $result       = wp_remote_post( $base_path . DC_PAYBYBANK_SUBMIT_ORDER_PATH . $this->api_key .
    240                                             '?merchant_order_id=' . $order->get_id() . '&merchant_customer_id=' .
    241                                             $order->get_customer_id() . '&amount=' . $order->get_total() . '&payment_code_life=' . $this->payment_code_life,
    242                 array( 'sslverify' => false ) );
    243             $final_result = json_decode( $result['body'], true );
    244 
    245             update_post_meta( $order->get_id(), 'dc_reference_code', $final_result['omtTransactionBank']['bankPaymentCode'] );
    246         }
    247     }
    248 }
  • paybybank/trunk/includes/class-dc-paybybank.php

    r2231022 r2303953  
    156156        $this->loader->add_filter( 'woocommerce_email_before_order_table', $plugin_admin, 'dc_paybybank_add_email_instructions', 10, 4 );
    157157        $this->loader->add_filter( 'woocommerce_thankyou_dc-paybybank', $plugin_admin, 'dc_paybybank_add_thankyou_message', 10, 3 );
    158         if ( $_GET['page'] == 'wc-settings' && $_GET['tab'] == 'checkout' && $_GET['section'] == 'dc-paybybank' ) {
     158        if ( isset( $_GET['page'] ) && $_GET['page'] == 'wc-settings' && $_GET['tab'] == 'checkout' && $_GET['section'] == 'dc-paybybank' ) {
    159159            $this->loader->add_filter( 'woocommerce_gateway_method_description', $plugin_admin, 'filter_woocommerce_settings_api_form_fields_id', 10, 1 );
    160160        }
    161161        $this->loader->add_action( 'init', $plugin_admin, 'dc_paybybank_register_paybybank_paid_order_status' );
    162         $this->loader->add_filter( 'wc_order_statuses', $plugin_admin, 'dc_paybybank_add__paybybank_paid_to_order_statuses', 10, 3 );
     162        $this->loader->add_filter( 'wc_order_statuses', $plugin_admin, 'dc_paybybank_add_paybybank_paid_to_order_statuses', 10, 3 );
    163163        $this->loader->add_action( 'woocommerce_order_status_paybybank-paid', $plugin_admin, 'dc_paybybank_email_order_status_paybybank_paid', 20, 2 );
    164164
Note: See TracChangeset for help on using the changeset viewer.