Plugin Directory

Changeset 1554761


Ignore:
Timestamp:
12/14/2016 03:59:02 PM (9 years ago)
Author:
nimblepayments
Message:

New version 3.0.0

Location:
nimblepayments/trunk
Files:
1 added
11 edited

Legend:

Unmodified
Added
Removed
  • nimblepayments/trunk/css/nimble_setting.css

    r1534878 r1554761  
    4747    background-color: white;*/
    4848}
     49.nimble-authorization {
     50    text-align: center;
     51}
  • nimblepayments/trunk/css/wp-nimble-backend.css

    r1435886 r1554761  
    161161    font-size: 1.8em;
    162162}
     163.nimble-authorization {
     164    border: solid 1px #ccc;
     165    max-width: 400px;
     166    margin: 0 auto;
     167    border-radius: 15px;
     168    background-color: #e7e7e7;
     169}
     170.nimble-authorization #np-oauth3-disassociate {
     171    background: #a3b745;
     172    border-color: #829237 #727f30 #727f30;
     173    color: #fff;
     174    -webkit-box-shadow: 0 1px 0 #727f30;
     175    box-shadow: 0 1px 0 #727f30;
     176    text-shadow: 0 -1px 1px #727f30,1px 0 1px #727f30,0 1px 1px #727f30,-1px 0 1px #727f30;
     177    opacity: 0.75;
     178}
  • nimblepayments/trunk/includes/class-wc-gateway-nimble.php

    r1534878 r1554761  
    125125   
    126126    function process_stored_card_payment($order){
    127     // Mark as nimble-pending (we're awaiting the payment)
    128         $order->update_status('nimble-pending', __('Awaiting payment via Nimble Payments.', 'woocommerce-nimble-payments')); //LANG: ORDER NOTE PENDING
     127        // Mark as nimble-pending (we're awaiting the payment)
     128        $order->update_status('nimble-pending');
    129129        try{
    130130            $nimbleApi = $this->inicialize_nimble_api();
     
    270270            $order = wc_get_order( $order_id );
    271271           
    272            
    273             if ($order->needs_payment()){
     272            if ("wc-nimble-pending" == $order->post_status){
    274273                if ( isset($_GET[$this->storedcard_field]) ){
    275274                    //STORED CARD PAYMENT
     
    278277                } else {
    279278                    //BASIC PAYMENT
     279                    $order->add_order_note(__('Payment processed.', 'woocommerce-nimble-payments')); //LANG: ORDER NOTE ON_HOLD
    280280                    $order->payment_complete();
    281 
    282                     //Email sending
    283                     WC_Emails::instance();
    284                     $email_actions = apply_filters( 'woocommerce_email_actions', array(
    285                         'woocommerce_order_status_pending_to_processing',
    286                         ) );
    287                     if (in_array('woocommerce_order_status_pending_to_processing', $email_actions)){
    288                         do_action('woocommerce_order_status_pending_to_processing_notification', $order_id);
    289                     }
     281                    $this->sendMail($order_id);
    290282                    //END BASIC PAYMENT
    291283                }
     
    302294            switch ($_GET['payment_status']){
    303295                case 'error':
     296                    global $wp;
     297                    $order_id = $wp->query_vars['order-pay'];
     298                    $order = wc_get_order( $order_id );
     299                    if ("wc-nimble-pending" == $order->post_status){
     300                        //$this->change_order_status( $order );
     301                        $order->update_status('pending', __('Denied card.', 'woocommerce-nimble-payments')); //LANG: ORDER NOTE DENIED
     302                    }
    304303                    $message = __( 'Card payment was rejected. Please try again.', 'woocommerce-nimble-payments' ); //LANG: CARD PAYMENT REJECTED
    305304                    echo '<div class="woocommerce-error">' . $message . '</div>';
     
    318317            $order = wc_get_order( $order_id );
    319318            // Mark as nimble-pending (we're awaiting the payment)
    320             $order->update_status('nimble-pending', __('Awaiting payment via Nimble Payments.', 'woocommerce-nimble-payments')); //LANG: ORDER NOTE PENDING
     319            $order->update_status('nimble-pending');
    321320           
    322321            try{
     
    329328                $payment = $this->set_payment_info($order);
    330329
    331                 $response = NimbleAPIPayments::SendPaymentClient($nimbleApi, $payment);
     330                $response = NimbleAPIPayments::sendPaymentClient($nimbleApi, $payment);
    332331                //Save transaction_id to this order
    333332                if ( isset($response["data"]) && isset($response["data"]["id"])){
     
    336335
    337336                if (!isset($response["data"]) || !isset($response["data"]["paymentUrl"])){
    338                     $order->update_status('nimble-failed', __('Could not connect to the bank. Code ERR_CONEX.', 'woocommerce-nimble-payments')); //LANG: ORDER NOTE 404
     337                    $order->update_status('pending', __('Could not connect to the bank. Code ERR_CONEX.', 'woocommerce-nimble-payments')); //LANG: ORDER NOTE 404
    339338                    $message = __('Unable to process payment. An error has occurred. ERR_CONEX code. Please try later.', 'woocommerce-nimble-payments'); //LANG: SDK RETURN 404
    340339                } else{
     
    345344            }
    346345            catch (Exception $e) {
    347                 $order->update_status('nimble-failed', __('An error has occurred. Code ERR_PAG.', 'woocommerce-nimble-payments')); //LANG: ORDER NOTE ERROR
     346                $order->update_status('pending', __('An error has occurred. Code ERR_PAG.', 'woocommerce-nimble-payments')); //LANG: ORDER NOTE ERROR
    348347                $message = __('Unable to process payment. An error has occurred. ERR_PAG code. Please try later.', 'woocommerce-nimble-payments'); //LANG: SDK ERROR MESSAGE
    349348            }
     
    367366        if ( ( "yes" == $this->get_option('enabled')) && $this->get_option($this->status_field_name) && ! $oWoocommerceNimblePayments->isOauth3Enabled() ){
    368367            Woocommerce_Nimble_Payments::authorize_notice();
     368        }
     369
     370        if ( ( "yes" == $this->get_option('enabled')) && $this->get_option($this->status_field_name) && $oWoocommerceNimblePayments->isOauth3Enabled() ){
     371            Woocommerce_Nimble_Payments::disassociate();
    369372        }
    370373       
     
    602605        switch ($state){
    603606            case 'SETTLED':
     607                //PAYMENT COMPLETE
     608                $order->add_order_note(__('Payment processed and settled .', 'woocommerce-nimble-payments')); //LANG: ORDER NOTE SETTLED
     609                $order->payment_complete();
     610                $this->sendMail($order_id);
     611                break;
    604612            case 'ON_HOLD':
    605613                //PAYMENT COMPLETE
     614                $order->add_order_note(__('Payment processed.', 'woocommerce-nimble-payments')); //LANG: ORDER NOTE ON_HOLD
    606615                $order->payment_complete();
    607 
    608                 //Email sending
    609                 WC_Emails::instance();
    610                 $email_actions = apply_filters( 'woocommerce_email_actions', array(
    611                     'woocommerce_order_status_pending_to_processing',
    612                     ) );
    613                 if (in_array('woocommerce_order_status_pending_to_processing', $email_actions)){
    614                     do_action('woocommerce_order_status_pending_to_processing_notification', $order_id);
    615                 }
     616                $this->sendMail($order_id);
    616617                break;
    617618            case 'ABANDONED':
     619                $order->update_status('pending', __('Checkout page abandoned.', 'woocommerce-nimble-payments')); //LANG: ORDER NOTE ABANDONED
     620                break;
    618621            case 'DENIED':
    619                 //PAYMENT DENIED OR ABANDONED
    620                 $order->update_status( 'wc-nimble-denied' );
     622                $order->update_status('pending', __('Card denied.', 'woocommerce-nimble-payments')); //LANG: ORDER NOTE DENIED
    621623                break;
    622624            case 'CANCELLED':
    623                 //PAYMENT CANCELLED
    624                 $order->update_status( 'cancelled' );
     625            case 'NOT_FOUND':
     626            case 'PAGE_NOT_LOADED':
     627                $order->update_status('pending', __('Payment cancelled.', 'woocommerce-nimble-payments')); //LANG: ORDER NOTE CANCELLED
    625628                break;
    626629            case 'ERROR':
    627                 //PAYMENT ERROR
    628                 $order->update_status( 'failed' );
     630                $order->update_status('pending', __('Payment error.', 'woocommerce-nimble-payments')); //LANG: ORDER NOTE ERROR
    629631                break;
    630             case 'NOT_FOUND':
    631632            default:
    632633                break;
     634        }
     635    }
     636
     637    /**
     638     * Email sending
     639     */
     640    private function sendMail($order_id) {
     641        WC_Emails::instance();
     642        $email_actions = apply_filters( 'woocommerce_email_actions', array(
     643            'woocommerce_order_status_pending_to_processing',
     644            ) );
     645        if (in_array('woocommerce_order_status_pending_to_processing', $email_actions)){
     646            do_action('woocommerce_order_status_pending_to_processing_notification', $order_id);
    633647        }
    634648    }
  • nimblepayments/trunk/js/nimble-payments.js

    r1435914 r1554761  
    5656        });
    5757    }
     58
     59    //Button link Disassociate
     60    jQuery("#np-oauth3-disassociate.button").click(function(event) {
     61        event.preventDefault();
     62        jQuery.ajax({
     63            type: 'POST',
     64            dataType: 'json',
     65            url: ajaxurl,
     66            data: {
     67                'action': 'nimble_payments_oauth3_disassociate'
     68            },
     69            success: function (data) {
     70                location.reload();
     71            },
     72            error: function (data) {
     73                console.log(data);
     74            }
     75        });
     76    });
    5877});
  • nimblepayments/trunk/lang/woocommerce-nimble-payments-es_ES.po

    r1435886 r1554761  
    44"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/woocommerce-"
    55"nimble-payments\n"
    6 "POT-Creation-Date: 2016-06-08 13:04:16+00:00\n"
    7 "PO-Revision-Date: 2016-06-08 15:35+0100\n"
     6"POT-Creation-Date: 2016-12-13 16:24:34+00:00\n"
     7"PO-Revision-Date: 2016-12-13 17:26+0100\n"
    88"Last-Translator: Carlos Mendoza <cmendoza@opensistemas.com>\n"
    99"Language-Team: Opensistemas <acasado@opensistemas.com>\n"
     
    2222msgstr "Nimble Payments by BBVA"
    2323
    24 #. #-#-#-#-#  woocommerce-nimble-payments.pot (Nimble Payments 1.0.8)  #-#-#-#-#
     24#. #-#-#-#-#  myfile.pot (Nimble Payments 3.0.0)  #-#-#-#-#
    2525#. Plugin Name of the plugin/theme
    2626#: includes/class-wc-gateway-nimble.php:30
     
    3232msgstr "Paga de manera segura con tarjeta con la garantía de BBVA."
    3333
    34 #: includes/class-wc-gateway-nimble.php:128
    35 #: includes/class-wc-gateway-nimble.php:310
    36 msgid "Awaiting payment via Nimble Payments."
    37 msgstr "Esperando pago via Nimble Payments."
    38 
    39 #: includes/class-wc-gateway-nimble.php:223
     34#: includes/class-wc-gateway-nimble.php:233
    4035msgid "Enable/Disable"
    4136msgstr "Habilitar/Deshabilitar"
    4237
    43 #: includes/class-wc-gateway-nimble.php:224
     38#: includes/class-wc-gateway-nimble.php:234
    4439msgid "Enable Nimble Payments"
    4540msgstr "Habilitar Nimble Payments"
    4641
    47 #: includes/class-wc-gateway-nimble.php:230
     42#: includes/class-wc-gateway-nimble.php:240
    4843msgid "API Client ID"
    4944msgstr "API Client ID"
    5045
    51 #: includes/class-wc-gateway-nimble.php:232
    52 #: includes/class-wc-gateway-nimble.php:239
     46#: includes/class-wc-gateway-nimble.php:242
     47#: includes/class-wc-gateway-nimble.php:249
    5348msgid "Obtained from https://www.nimblepayments.com"
    5449msgstr "Cópialo de tu pasarela en https://www.nimblepayments.com"
    5550
    56 #: includes/class-wc-gateway-nimble.php:237
     51#: includes/class-wc-gateway-nimble.php:247
    5752msgid "Client Secret"
    5853msgstr "Client Secret"
    5954
    60 #: includes/class-wc-gateway-nimble.php:294
     55#: includes/class-wc-gateway-nimble.php:284
     56#: includes/class-wc-gateway-nimble.php:615
     57msgid "Payment processed."
     58msgstr "Pago aceptado."
     59
     60#: includes/class-wc-gateway-nimble.php:306
     61msgid "Denied card."
     62msgstr "Tarjeta denegada."
     63
     64#: includes/class-wc-gateway-nimble.php:308
    6165msgid "Card payment was rejected. Please try again."
    6266msgstr "Se ha rechazado el pago. Por favor, inténtalo de nuevo."
    6367
    64 #: includes/class-wc-gateway-nimble.php:328
     68#: includes/class-wc-gateway-nimble.php:342
    6569msgid "Could not connect to the bank. Code ERR_CONEX."
    6670msgstr "Error al conectar a Nimbe Payments. Código ERR_CONEX."
    6771
    68 #: includes/class-wc-gateway-nimble.php:329
     72#: includes/class-wc-gateway-nimble.php:343
    6973msgid ""
    7074"Unable to process payment. An error has occurred. ERR_CONEX code. Please try "
     
    7478"ERR_CONEX. Por favor, inténtalo mas tarde."
    7579
    76 #: includes/class-wc-gateway-nimble.php:337
     80#: includes/class-wc-gateway-nimble.php:351
    7781msgid "An error has occurred. Code ERR_PAG."
    7882msgstr "Error en el pago. Código ERR_PAG."
    7983
    80 #: includes/class-wc-gateway-nimble.php:338
     84#: includes/class-wc-gateway-nimble.php:352
    8185msgid ""
    8286"Unable to process payment. An error has occurred. ERR_PAG code. Please try "
     
    8690"Por favor, inténtalo mas tarde."
    8791
    88 #: includes/class-wc-gateway-nimble.php:372
     92#: includes/class-wc-gateway-nimble.php:386
    8993msgid "Need an Nimble Payments account?"
    9094msgstr ""
     
    9296"de forma completamente online."
    9397
    94 #: includes/class-wc-gateway-nimble.php:374
     98#: includes/class-wc-gateway-nimble.php:388
    9599msgid "Signup now"
    96100msgstr "Regístrate"
    97101
    98 #: includes/class-wc-gateway-nimble.php:376
     102#: includes/class-wc-gateway-nimble.php:390
    99103msgid "Already registered"
    100104msgstr "Ya estoy registrado"
    101105
    102 #: includes/class-wc-gateway-nimble.php:385
     106#: includes/class-wc-gateway-nimble.php:399
    103107msgid "Data invalid gateway to accept payments."
    104108msgstr ""
     
    106110"una pasarela de Test."
    107111
    108 #: includes/class-wc-gateway-nimble.php:393
     112#: includes/class-wc-gateway-nimble.php:407
    109113#: templates/nimble-checkout-payment-method.php:26
    110114#: templates/nimble-checkout-thankyou.php:55
     
    112116msgstr "Pago con tarjeta"
    113117
    114 #: includes/class-wc-gateway-nimble.php:424
     118#: includes/class-wc-gateway-nimble.php:438
    115119msgid "Invalid refund amount"
    116120msgstr ""
    117121
    118 #: includes/class-wc-gateway-nimble.php:428
    119 #: includes/class-wc-gateway-nimble.php:485
     122#: includes/class-wc-gateway-nimble.php:442
     123#: includes/class-wc-gateway-nimble.php:498
    120124msgid "Refund Failed: You must authorize the advanced options Nimble Payments."
    121125msgstr ""
     
    123127"Payments."
    124128
    125 #: includes/class-wc-gateway-nimble.php:508
     129#: includes/class-wc-gateway-nimble.php:521
    126130msgid "Refund Failed: "
    127131msgstr "Falló la devolución: "
    128132
    129 #: includes/class-wc-gateway-nimble.php:563
     133#: includes/class-wc-gateway-nimble.php:576
    130134msgid "Could not pay with the selected card."
    131135msgstr "No se ha podido pagar con la tarjeta seleccionada."
    132136
    133 #: nimblepayments.php:161
     137#: includes/class-wc-gateway-nimble.php:609
     138msgid "Payment processed and settled ."
     139msgstr "Pago aceptado y liquidado."
     140
     141#: includes/class-wc-gateway-nimble.php:620
     142msgid "Checkout page abandoned."
     143msgstr "Página de checkout abandonada."
     144
     145#: includes/class-wc-gateway-nimble.php:623
     146msgid "Card denied."
     147msgstr "Tarjeta denegada."
     148
     149#: includes/class-wc-gateway-nimble.php:628
     150msgid "Payment cancelled."
     151msgstr "Pago cancelado."
     152
     153#: includes/class-wc-gateway-nimble.php:631
     154msgid "Payment error."
     155msgstr "Error en el pago."
     156
     157#: nimblepayments.php:175 nimblepayments.php:178
     158msgid "Update Nimble Payments plugin 3.0.0."
     159msgstr "Actualización del plugin Nimble Payments 3.0.0."
     160
     161#: nimblepayments.php:237
    134162msgid "Refund in progress"
    135163msgstr "Devolución en progreso"
    136164
    137 #: nimblepayments.php:162
     165#: nimblepayments.php:238
    138166msgid "Refund Failed"
    139167msgstr "Falló la devolución"
    140168
    141 #: nimblepayments.php:238 nimblepayments.php:251
     169#: nimblepayments.php:314 nimblepayments.php:327
    142170msgid "Operation rejected."
    143171msgstr "Operación denegada."
    144172
    145 #: nimblepayments.php:239
     173#: nimblepayments.php:315
    146174msgid "You have not activated your payment gateway Nimble Payments."
    147175msgstr "No has configurado tu pasarela Nimble Payments."
    148176
    149 #: nimblepayments.php:241
     177#: nimblepayments.php:317
    150178msgid "Activate"
    151179msgstr "Activar"
    152180
    153 #: nimblepayments.php:252
     181#: nimblepayments.php:328
    154182msgid ""
    155183"You have not yet WooCommerce authorized to perform operations on Nimble "
     
    157185msgstr "Todavía no has autorizado a Woocommerce en Nimble Payments."
    158186
    159 #: nimblepayments.php:254 templates/nimble-oauth-form.php:17
     187#: nimblepayments.php:330 templates/nimble-oauth-form.php:17
    160188#: templates/nimble-oauth-form.php:19
    161189msgid "Authorize Woocommerce"
    162190msgstr "Autorizar a Woocommerce"
    163191
    164 #: nimblepayments.php:319 nimblepayments.php:327
     192#: nimblepayments.php:404 nimblepayments.php:411
    165193msgctxt "Order status"
    166 msgid "Pending Payment (Nimble Payments)"
    167 msgstr "Pago Pendiente (Nimble Payments)"
    168 
    169 #: nimblepayments.php:320 nimblepayments.php:335
    170 msgctxt "Order status"
    171 msgid "Failed (Nimble Payments)"
    172 msgstr "Fallido (Nimble Payments)"
    173 
    174 #: nimblepayments.php:332
    175 msgid "Pending Payment (Nimble Payments) <span class=\"count\">(%s)</span>"
    176 msgid_plural ""
    177 "Pending Payment (Nimble Payments) <span class=\"count\">(%s)</span>"
    178 msgstr[0] "Pago Pendiente (Nimble Payments) <span class=\"count\">(%s)</span>"
    179 msgstr[1] ""
    180 "Pagos Pendientes (Nimble Payments) <span class=\"count\">(%s)</span>"
    181 
    182 #: nimblepayments.php:340
    183 msgid "Failed (Nimble Payments) <span class=\"count\">(%s)</span>"
    184 msgid_plural "Failed (Nimble Payments) <span class=\"count\">(%s)</span>"
    185 msgstr[0] "Fallido (Nimble Payments) <span class=\"count\">(%s)</span>"
    186 msgstr[1] "Fallidos (Nimble Payments) <span class=\"count\">(%s)</span>"
    187 
    188 #: nimblepayments.php:535 templates/nimble-oauth-form.php:12
     194msgid "Processing transaction"
     195msgstr "Cursando pago"
     196
     197#: nimblepayments.php:416
     198msgid "Processing Payment <span class=\"count\">(%s)</span>"
     199msgid_plural "Processing Payment <span class=\"count\">(%s)</span>"
     200msgstr[0] "Cursando pago <span class=\"count\">(%s)</span>"
     201msgstr[1] "Cursando pagos <span class=\"count\">(%s)</span>"
     202
     203#: nimblepayments.php:624 templates/nimble-oauth-form.php:12
    189204#: templates/nimble-summary.php:19
    190205msgid "Nimble Payments Summary"
     
    234249msgid "Total available"
    235250msgstr "Total disponible"
     251
     252#: templates/nimble-gateway-footer.php:10
     253msgid "Ecommerce linked to Nimble Payments"
     254msgstr "Tienda vinculada a Nimble Payments"
     255
     256#: templates/nimble-gateway-footer.php:12
     257msgid "Disassociate"
     258msgstr "Desvincular"
    236259
    237260#: templates/nimble-oauth-form.php:13
     
    291314msgstr "BBVA"
    292315
     316#~ msgid "Abandoned checkout page."
     317#~ msgstr "Página de checkout abandonada."
     318
     319#~ msgid "Error."
     320#~ msgstr "Error."
     321
     322#~ msgid "Awaiting payment via Nimble Payments."
     323#~ msgstr "Esperando pago via Nimble Payments."
     324
     325#~ msgctxt "Order status"
     326#~ msgid "Pending Payment (Nimble Payments)"
     327#~ msgstr "Pago Pendiente (Nimble Payments)"
     328
     329#~ msgctxt "Order status"
     330#~ msgid "Failed (Nimble Payments)"
     331#~ msgstr "Fallido (Nimble Payments)"
     332
     333#~ msgid "Pending Payment (Nimble Payments) <span class=\"count\">(%s)</span>"
     334#~ msgid_plural ""
     335#~ "Pending Payment (Nimble Payments) <span class=\"count\">(%s)</span>"
     336#~ msgstr[0] ""
     337#~ "Pago Pendiente (Nimble Payments) <span class=\"count\">(%s)</span>"
     338#~ msgstr[1] ""
     339#~ "Pagos Pendientes (Nimble Payments) <span class=\"count\">(%s)</span>"
     340
    293341#, fuzzy
    294342#~ msgid "Nimble Payments Account"
     
    299347#~ msgid "NimblePayments"
    300348#~ msgstr "Nimble Payments"
    301 
    302 #~ msgid "WooCommerce Nimble Payments"
    303 #~ msgstr "WooCommerce Nimble Payments"
    304349
    305350#~ msgctxt "Order status"
  • nimblepayments/trunk/lang/woocommerce-nimble-payments.pot

    r1435886 r1554761  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: Nimble Payments 1.0.8\n"
     5"Project-Id-Version: Nimble Payments 3.0.0\n"
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/woocommerce-"
    77"nimble-payments\n"
    8 "POT-Creation-Date: 2016-06-08 13:04:16+00:00\n"
     8"POT-Creation-Date: 2016-12-13 16:24:34+00:00\n"
    99"MIME-Version: 1.0\n"
    1010"Content-Type: text/plain; charset=UTF-8\n"
     
    1818msgstr ""
    1919
    20 #. #-#-#-#-#  woocommerce-nimble-payments.pot (Nimble Payments 1.0.8)  #-#-#-#-#
     20#. #-#-#-#-#  myfile.pot (Nimble Payments 3.0.0)  #-#-#-#-#
    2121#. Plugin Name of the plugin/theme
    2222#: includes/class-wc-gateway-nimble.php:30
     
    2828msgstr ""
    2929
    30 #: includes/class-wc-gateway-nimble.php:128
    31 #: includes/class-wc-gateway-nimble.php:310
    32 msgid "Awaiting payment via Nimble Payments."
    33 msgstr ""
    34 
    35 #: includes/class-wc-gateway-nimble.php:223
     30#: includes/class-wc-gateway-nimble.php:233
    3631msgid "Enable/Disable"
    3732msgstr ""
    3833
    39 #: includes/class-wc-gateway-nimble.php:224
     34#: includes/class-wc-gateway-nimble.php:234
    4035msgid "Enable Nimble Payments"
    4136msgstr ""
    4237
    43 #: includes/class-wc-gateway-nimble.php:230
     38#: includes/class-wc-gateway-nimble.php:240
    4439msgid "API Client ID"
    4540msgstr ""
    4641
    47 #: includes/class-wc-gateway-nimble.php:232
    48 #: includes/class-wc-gateway-nimble.php:239
     42#: includes/class-wc-gateway-nimble.php:242
     43#: includes/class-wc-gateway-nimble.php:249
    4944msgid "Obtained from https://www.nimblepayments.com"
    5045msgstr ""
    5146
    52 #: includes/class-wc-gateway-nimble.php:237
     47#: includes/class-wc-gateway-nimble.php:247
    5348msgid "Client Secret"
    5449msgstr ""
    5550
    56 #: includes/class-wc-gateway-nimble.php:294
     51#: includes/class-wc-gateway-nimble.php:284
     52#: includes/class-wc-gateway-nimble.php:615
     53msgid "Payment processed."
     54msgstr ""
     55
     56#: includes/class-wc-gateway-nimble.php:306
     57msgid "Denied card."
     58msgstr ""
     59
     60#: includes/class-wc-gateway-nimble.php:308
    5761msgid "Card payment was rejected. Please try again."
    5862msgstr ""
    5963
    60 #: includes/class-wc-gateway-nimble.php:328
     64#: includes/class-wc-gateway-nimble.php:342
    6165msgid "Could not connect to the bank. Code ERR_CONEX."
    6266msgstr ""
    6367
    64 #: includes/class-wc-gateway-nimble.php:329
     68#: includes/class-wc-gateway-nimble.php:343
    6569msgid ""
    6670"Unable to process payment. An error has occurred. ERR_CONEX code. Please try "
     
    6872msgstr ""
    6973
    70 #: includes/class-wc-gateway-nimble.php:337
     74#: includes/class-wc-gateway-nimble.php:351
    7175msgid "An error has occurred. Code ERR_PAG."
    7276msgstr ""
    7377
    74 #: includes/class-wc-gateway-nimble.php:338
     78#: includes/class-wc-gateway-nimble.php:352
    7579msgid ""
    7680"Unable to process payment. An error has occurred. ERR_PAG code. Please try "
     
    7882msgstr ""
    7983
    80 #: includes/class-wc-gateway-nimble.php:372
     84#: includes/class-wc-gateway-nimble.php:386
    8185msgid "Need an Nimble Payments account?"
    8286msgstr ""
    8387
    84 #: includes/class-wc-gateway-nimble.php:374
     88#: includes/class-wc-gateway-nimble.php:388
    8589msgid "Signup now"
    8690msgstr ""
    8791
    88 #: includes/class-wc-gateway-nimble.php:376
     92#: includes/class-wc-gateway-nimble.php:390
    8993msgid "Already registered"
    9094msgstr ""
    9195
    92 #: includes/class-wc-gateway-nimble.php:385
     96#: includes/class-wc-gateway-nimble.php:399
    9397msgid "Data invalid gateway to accept payments."
    9498msgstr ""
    9599
    96 #: includes/class-wc-gateway-nimble.php:393
     100#: includes/class-wc-gateway-nimble.php:407
    97101#: templates/nimble-checkout-payment-method.php:26
    98102#: templates/nimble-checkout-thankyou.php:55
     
    100104msgstr ""
    101105
    102 #: includes/class-wc-gateway-nimble.php:424
     106#: includes/class-wc-gateway-nimble.php:438
    103107msgid "Invalid refund amount"
    104108msgstr ""
    105109
    106 #: includes/class-wc-gateway-nimble.php:428
    107 #: includes/class-wc-gateway-nimble.php:485
     110#: includes/class-wc-gateway-nimble.php:442
     111#: includes/class-wc-gateway-nimble.php:498
    108112msgid "Refund Failed: You must authorize the advanced options Nimble Payments."
    109113msgstr ""
    110114
    111 #: includes/class-wc-gateway-nimble.php:508
     115#: includes/class-wc-gateway-nimble.php:521
    112116msgid "Refund Failed: "
    113117msgstr ""
    114118
    115 #: includes/class-wc-gateway-nimble.php:563
     119#: includes/class-wc-gateway-nimble.php:576
    116120msgid "Could not pay with the selected card."
    117121msgstr ""
    118122
    119 #: nimblepayments.php:161
     123#: includes/class-wc-gateway-nimble.php:609
     124msgid "Payment processed and settled ."
     125msgstr ""
     126
     127#: includes/class-wc-gateway-nimble.php:620
     128msgid "Checkout page abandoned."
     129msgstr ""
     130
     131#: includes/class-wc-gateway-nimble.php:623
     132msgid "Card denied."
     133msgstr ""
     134
     135#: includes/class-wc-gateway-nimble.php:628
     136msgid "Payment cancelled."
     137msgstr ""
     138
     139#: includes/class-wc-gateway-nimble.php:631
     140msgid "Payment error."
     141msgstr ""
     142
     143#: nimblepayments.php:175 nimblepayments.php:178
     144msgid "Update Nimble Payments plugin 3.0.0."
     145msgstr ""
     146
     147#: nimblepayments.php:237
    120148msgid "Refund in progress"
    121149msgstr ""
    122150
    123 #: nimblepayments.php:162
     151#: nimblepayments.php:238
    124152msgid "Refund Failed"
    125153msgstr ""
    126154
    127 #: nimblepayments.php:238 nimblepayments.php:251
     155#: nimblepayments.php:314 nimblepayments.php:327
    128156msgid "Operation rejected."
    129157msgstr ""
    130158
    131 #: nimblepayments.php:239
     159#: nimblepayments.php:315
    132160msgid "You have not activated your payment gateway Nimble Payments."
    133161msgstr ""
    134162
    135 #: nimblepayments.php:241
     163#: nimblepayments.php:317
    136164msgid "Activate"
    137165msgstr ""
    138166
    139 #: nimblepayments.php:252
     167#: nimblepayments.php:328
    140168msgid ""
    141169"You have not yet WooCommerce authorized to perform operations on Nimble "
     
    143171msgstr ""
    144172
    145 #: nimblepayments.php:254 templates/nimble-oauth-form.php:17
     173#: nimblepayments.php:330 templates/nimble-oauth-form.php:17
    146174#: templates/nimble-oauth-form.php:19
    147175msgid "Authorize Woocommerce"
    148176msgstr ""
    149177
    150 #: nimblepayments.php:319 nimblepayments.php:327
     178#: nimblepayments.php:404 nimblepayments.php:411
    151179msgctxt "Order status"
    152 msgid "Pending Payment (Nimble Payments)"
    153 msgstr ""
    154 
    155 #: nimblepayments.php:320 nimblepayments.php:335
    156 msgctxt "Order status"
    157 msgid "Failed (Nimble Payments)"
    158 msgstr ""
    159 
    160 #: nimblepayments.php:332
    161 msgid "Pending Payment (Nimble Payments) <span class=\"count\">(%s)</span>"
    162 msgid_plural ""
    163 "Pending Payment (Nimble Payments) <span class=\"count\">(%s)</span>"
     180msgid "Processing transaction"
     181msgstr ""
     182
     183#: nimblepayments.php:416
     184msgid "Processing Payment <span class=\"count\">(%s)</span>"
     185msgid_plural "Processing Payment <span class=\"count\">(%s)</span>"
    164186msgstr[0] ""
    165187msgstr[1] ""
    166188
    167 #: nimblepayments.php:340
    168 msgid "Failed (Nimble Payments) <span class=\"count\">(%s)</span>"
    169 msgid_plural "Failed (Nimble Payments) <span class=\"count\">(%s)</span>"
    170 msgstr[0] ""
    171 msgstr[1] ""
    172 
    173 #: nimblepayments.php:535 templates/nimble-oauth-form.php:12
     189#: nimblepayments.php:624 templates/nimble-oauth-form.php:12
    174190#: templates/nimble-summary.php:19
    175191msgid "Nimble Payments Summary"
     
    220236msgstr ""
    221237
     238#: templates/nimble-gateway-footer.php:10
     239msgid "Ecommerce linked to Nimble Payments"
     240msgstr ""
     241
     242#: templates/nimble-gateway-footer.php:12
     243msgid "Disassociate"
     244msgstr ""
     245
    222246#: templates/nimble-oauth-form.php:13
    223247msgid ""
  • nimblepayments/trunk/lib/Nimble/api/NimbleAPICredentials.php

    r1435914 r1554761  
    11<?php
    2 require_once(__DIR__.'/../base/NimbleAPIConfig.php');
     2require_once(dirname(__FILE__).'/../base/NimbleAPIConfig.php');
     3require_once 'NimbleAPIEnvironment.php';
    34
    4 /**
    5  * Class responsible for performing payments services.
    6  */
    75class NimbleAPICredentials
    86{
    9 
    107    /**
    11      * Validates mode corresponds with credentials
    12      *
    13      * @param type $NimbleApi
    14      * @return type
    15      * @throws Exception
     8     * DEPRECATED
    169     */
    1710    public static function check($NimbleApi)
    1811    {
    19        
    20         if (empty($NimbleApi)) {
    21             throw new Exception('$NimbleApi parameter is empty.');
    22         }
    23    
    24         try {
    25             //HEADERS
    26             //$this->authorization->buildAuthorizationHeader('tsec');
    27             $NimbleApi->authorization->addHeader('Content-Type', 'application/json');
    28             $NimbleApi->authorization->addHeader('Accept', 'application/json');
    29            
    30             $NimbleApi->setUri('check');
    31             $NimbleApi->method = 'GET';
    32             $response = $NimbleApi->restApiCall();
    33             return $response;
    34         } catch (Exception $e) {
    35             throw new Exception('Error in NimbleAPICredentials::check(): ' . $e);
    36         }
     12       return NimbleAPIEnvironment::verification($NimbleApi);
    3713    }
    3814}
  • nimblepayments/trunk/lib/Nimble/api/NimbleAPIPayments.php

    r1435914 r1554761  
    99 * @filesource
    1010 */
    11 require_once(__DIR__ . '/../base/NimbleAPIConfig.php');
     11require_once(dirname(__FILE__) . '/../base/NimbleAPIConfig.php');
    1212
    1313/**
     
    5050
    5151    /**
    52      * Method updateCustomerData
     52     * Method updateCustomerData (DEPRECATED)
    5353     *
    5454     * @param object $NimbleApi
     
    5858     */
    5959    public static function updateCustomerData($NimbleApi, $transaction_id, $new_order_id) {
     60        self::updateMerchantOrderId($NimbleApi, $transaction_id, $new_order_id);
     61    }
     62   
     63    /**
     64     * Method updateMerchantOrderId
     65     *
     66     * @param object $NimbleApi
     67     * @param array $transaction_id
     68     * @param array $new_order_id
     69     * @return array
     70     */
     71    public static function updateMerchantOrderId($NimbleApi, $transaction_id, $new_order_id) {
    6072
    6173        if (empty($NimbleApi)) {
     
    206218     * @return array
    207219     */
    208     public static function getPayment($NimbleApi, $IdTransaction) {
     220    public static function getPayment($NimbleApi, $IdTransaction, $extendedData = false) {
    209221
    210222        if (empty($NimbleApi)) {
     
    221233            $NimbleApi->authorization->addHeader('Accept', 'application/json');
    222234           
    223             $NimbleApi->uri = 'v2/payments/' . $IdTransaction;
     235            $query_params = ($extendedData) ? '?extendedData=true' : '';
     236            $NimbleApi->uri = 'v2/payments/' . $IdTransaction . $query_params;
    224237            $NimbleApi->method = 'GET';
    225238            $response = $NimbleApi->restApiCall();
     
    234247     *
    235248     * @param object $NimbleApi
    236      * @param array $filters (fromDate, toDate, merchantOrderId, state, hasRefunds, extendedData, hasDisputes,
     249     * @param array $filters (fromDate, toDate, merchantOrderId, status, hasRefunds, extendedData, hasDisputes,
    237250     *                        entryReference, itemReference, itemsPerPage)
    238251     * @return array
     
    261274   
    262275    /**
    263      * Method getPaymentsDisputes
     276     * Method getPaymentDisputes
    264277     *
    265278     * @param object $NimbleApi
     
    267280     * @return array
    268281     */
    269     public static function getPaymentsDisputes($NimbleApi, $IdTransaction) {
     282    public static function getPaymentDisputes($NimbleApi, $IdTransaction) {
    270283
    271284        if (empty($NimbleApi)) {
  • nimblepayments/trunk/nimblepayments.php

    r1534878 r1554761  
    55Plugin URI: https://www.nimblepayments.com
    66Description: Nimble Payments is an online payment gateway supported by BBVA that enables you to accept online payments flexibly and safely.
    7 Version: 2.1.0
     7Version: 3.0.0
    88Author: BBVA
    99Author URI:
     
    3838    protected static $gateway = null;
    3939    protected static $params = null;
     40    protected $default_options = array(
     41        'version' => '0',
     42        'token' => '',
     43        'refreshToken' => ''
     44    );
    4045
    4146    static function & getInstance() {
     
    5964           
    6065            add_action( 'woocommerce_init', array( $this, 'gateway_loaded'), 0);
     66
     67            add_action( 'wp_loaded', array( $this, 'check_init'), 99 );
    6168           
    6269            add_action( 'admin_menu', array( $this, 'nimble_menu'));
     
    6572           
    6673            add_action( 'init', array( $this, 'register_post_status' ), 9 );
    67            
     74
    6875            add_filter( 'woocommerce_valid_order_statuses_for_payment', array( $this, 'valid_order_statuses_for_payment' ) );
    69            
     76
    7077            add_filter( 'woocommerce_valid_order_statuses_for_payment_complete', array( $this, 'valid_order_statuses_for_payment' ) );
    7178           
     
    8087            add_action( 'wp_ajax_nimble_payments_oauth3', array( $this, 'ajax_oauth3' ) );
    8188           
     89            add_action( 'wp_ajax_nimble_payments_oauth3_disassociate', array( $this, 'ajax_oauth3_disassociate' ) );
     90
    8291            add_action( 'wp_ajax_nimble_payments_gateway', array( $this, 'ajax_gateway' ) );
    8392           
     
    8695            //Custom template checkout/payment-method.php
    8796            add_filter( 'wc_get_template', array( $this, 'filter_templates_checkout' ), 10, 3);
    88            
    89             add_action( 'manage_shop_order_posts_custom_column', array( $this, 'render_shop_order_columns' ), 1, 2 );
    90            
     97
    9198            $this->load_settings();
    9299        }
    93100    }
    94    
    95     function render_shop_order_columns($column_name, $post_id){
    96         global $post;
    97        
    98         switch ( $column_name ) {
    99             case 'order_status' :
    100                 $pending_statuses = array ('wc-nimble-pending', 'wc-nimble-failed');
    101                 if ( self::$gateway && in_array($post->post_status, $pending_statuses) ){
    102                     self::$gateway->change_order_status($post_id);
     101
     102    public function load_settings(){
     103        //Plugin options
     104        $this->options = array_merge($this->default_options, get_option($this->options_name, array()));
     105        $this->oauth3_enabled = ( $this->options['token'] != '' );
     106        $this->gateway_enabled = $this->isGatewayEnabled();
     107    }
     108
     109    public function check_init() {
     110        //Plugin version
     111        $header_options = get_file_data(__FILE__, array('version' => 'Version'), 'plugin' );
     112
     113        // Upgrade Plugin
     114        if ( version_compare( $this->options['version'], $header_options['version'], '<' ) && $this->isGatewayEnabled() ) {
     115            $this->upgrade_version();
     116            $this->options['version'] = $header_options['version'];
     117            update_option($this->options_name, $this->options);
     118        }
     119
     120        // Check Nimble-Pending Orders
     121        if ( isset( $this->options['check_orders'] ) && $this->options['check_orders'] && $this->isGatewayEnabled() ) {
     122            $this->check_orders();
     123            unset($this->options['check_orders']);
     124            update_option($this->options_name, $this->options);
     125        }
     126    }
     127
     128    private function np_get_orders( $args = array() ) {
     129        $orders = array();
     130        global $woocommerce;
     131        if( version_compare( $woocommerce->version, '2.6.0', ">=" ) ) {
     132            $orders = wc_get_orders( $args );
     133        } else {
     134            if (!isset($args['status'])) {
     135                return array();
     136            }
     137            $where_clause = "post_status ";
     138            if (is_array($args['status'])) {
     139                $where_clause .= "in (";
     140                foreach ($args['status'] as $status) {
     141                    $where_clause .= "'".$status."', ";
    103142                }
    104                 break;
    105         }
    106     }
    107    
    108     function load_settings(){
    109         //Plugin options
    110         $options = get_option($this->options_name);
    111         $this->oauth3_enabled = ( $options && isset($options['token']) ) ? true : false;
    112         $this->gateway_enabled = $this->isGatewayEnabled();
    113    
    114     //Plugin version
    115     $this->options = get_file_data(__FILE__, array('Version' => 'Version'), 'plugin' );
     143                $where_clause = substr($where_clause, 0, -2);
     144                $where_clause .= ");";
     145            } else {
     146                $where_clause .= "= '".$args['status']."';";
     147            }
     148            global $wpdb;
     149            $orders_id = $wpdb->get_results("select ID from {$wpdb->prefix}posts where {$where_clause}");
     150            foreach ($orders_id as $id) {
     151                $order = $this->np_get_order( $id );
     152                array_push( $orders, $order );
     153            }
     154        }
     155        return $orders;
     156    }
     157
     158    private function np_get_order( $order_id ) {
     159        global $woocommerce;
     160        $order = false;
     161        if( version_compare( $woocommerce->version, '2.2.0', "<" ) ) {
     162            $order = wc_get_order( $order_id );
     163        } else {
     164            $order = new WC_Order( $order_id );
     165        }
     166        return $order;
     167    }
     168   
     169    private function upgrade_version() {
     170        if ( version_compare( $this->options['version'], '3.0.0', '<' ) ) {
     171            $older_orders = $this->np_get_orders( array( 'status' => array('wc-nimble-denied', 'wc-nimble-failed'), 'limit' => -1, 'order' => 'ASC' ) );
     172            foreach ($older_orders as $order) {
     173                switch ($order->post_status) {
     174                    case 'wc-nimble-denied':
     175                        $order->update_status('pending', __('Update Nimble Payments plugin 3.0.0.', 'woocommerce-nimble-payments')); //LANG: OLD DENIED ORDER STATUS
     176                        break;
     177                    case 'wc-nimble-failed':
     178                        $order->update_status('nimble-pending', __('Update Nimble Payments plugin 3.0.0.', 'woocommerce-nimble-payments')); //LANG: OLD FAILED ORDER STATUS
     179                        self::$gateway->change_order_status($order->id);
     180                        break;
     181                }
     182            }
     183        }
     184        /*FOR FUTURE VERSIONS
     185        if ( version_compare( $this->options['version'], 'X.X.X', '<' ) ) {
     186            UPGRADE CODE HERE
     187        }*/
     188    }
     189
     190    private function check_orders() {
     191        $orders = $this->np_get_orders( array( 'status' => 'wc-nimble-pending', 'limit' => -1, 'order' => 'ASC' ) );
     192        foreach ($orders as $order_number => $order) {
     193            self::$gateway->change_order_status($order->id);
     194        }
    116195    }
    117196
    118197    function get_plugin_version(){
    119         if ( isset($this->options['Version']) ){
    120             return $this->options['Version'];
    121         }
    122         return '';
     198        return $this->options['version'];
    123199    }
    124200   
     
    138214    function admin_enqueue_scripts($hook) {
    139215        global $post;
    140         wp_enqueue_script('nimble-payments-js', plugins_url("js/nimble-payments.js", __FILE__), array('jquery'), '20160329');
     216        wp_enqueue_script('nimble-payments-js', plugins_url("js/nimble-payments.js", __FILE__), array('jquery'), '20161023');
    141217       
    142218        //Custom JS for refunds
     
    257333        <?php
    258334    }
     335
     336
     337    static function disassociate(){
     338        ?>
     339            <div id="np-authorize-message" class="updated wc-nimble-message"><div class="squeezer">
     340                    <h4><?php _e('Ecommerce linked to Nimble Payments', 'woocommerce-nimble-payments'); ?></h4>
     341                    <p class="submit">
     342                        <a id="np-oauth3-disassociate" class="button" href="#"><?php _e('Disassociate', 'woocommerce-nimble-payments'); ?></a>
     343                    </p>
     344            </div></div>
     345        <?php
     346    }
    259347   
    260348    function ajax_oauth3(){
     
    264352        die();
    265353    }
     354
     355    public function ajax_oauth3_disassociate() {
     356        $this->oauth3_enabled = false;
     357        $this->options['token'] = '';
     358        $this->options['refreshToken'] = '';
     359        update_option($this->options_name, $this->options);
     360    }
    266361   
    267362    static function get_gateway_url(){
     
    286381   
    287382    static function activar_plugin() {
     383        $header_options = get_file_data(__FILE__, array('version' => 'Version'), 'plugin' );
     384        update_option('nimble_payments_options', $header_options);
    288385    }
    289386   
     
    307404   
    308405    function add_your_gateway_class( $methods ) {
    309     $methods[] = 'WC_Gateway_Nimble';
    310     return $methods;
     406        $methods[] = 'WC_Gateway_Nimble';
     407        return $methods;
    311408    }
    312409   
     
    317414    function add_custom_statuses($order_statuses){
    318415        $new_statuses = array(
    319         'wc-nimble-pending'    => _x( 'Pending Payment (Nimble Payments)', 'Order status', 'woocommerce-nimble-payments' ), //LANG: PENDING STATUS
    320         'wc-nimble-failed'     => _x( 'Failed (Nimble Payments)', 'Order status', 'woocommerce-nimble-payments' ), //LANG: FAILED STATUS
    321                 'wc-nimble-denied'     => _x( 'Denied (Nimble Payments)', 'Order status', 'woocommerce-nimble-payments' ), //LANG: DENIED STATUS
    322     );
     416            'wc-nimble-pending'    => _x( 'Processing transaction', 'Order status', 'woocommerce-nimble-payments' ), //LANG: PENDING STATUS
     417        );
    323418        return array_merge($order_statuses, $new_statuses);
    324419    }
     
    326421    function register_post_status() {
    327422        register_post_status('wc-nimble-pending', array(
    328             'label' =>  _x( 'Pending Payment (Nimble Payments)', 'Order status', 'woocommerce-nimble-payments' ), //LANG: PENDING STATUS
     423            'label' =>  _x( 'Processing transaction', 'Order status', 'woocommerce-nimble-payments' ), //LANG: PENDING STATUS
    329424            'public'    => false,
    330425            'exclude_from_search'   =>  false,
    331426            'show_in_admin_all_list'    => true,
    332427            'show_in_admin_status_list' =>  true,
    333             'label_count' => _n_noop('Pending Payment (Nimble Payments) <span class="count">(%s)</span>', 'Pending Payment (Nimble Payments) <span class="count">(%s)</span>', 'woocommerce') //LANG: PENDING STATUS LIST
     428            'label_count' => _n_noop('Processing Payment <span class="count">(%s)</span>', 'Processing Payment <span class="count">(%s)</span>', 'woocommerce') //LANG: PENDING STATUS LIST
    334429        ));
    335         register_post_status('wc-nimble-failed', array(
    336             'label' =>  _x( 'Failed (Nimble Payments)', 'Order status', 'woocommerce-nimble-payments' ), //LANG: FAILED STATUS
    337             'public'    => false,
    338             'exclude_from_search'   =>  false,
    339             'show_in_admin_all_list'    => true,
    340             'show_in_admin_status_list' =>  true,
    341             'label_count'   =>    _n_noop('Failed (Nimble Payments) <span class="count">(%s)</span>', 'Failed (Nimble Payments) <span class="count">(%s)</span>', 'woocommerce') //LANG: FAILED LIST
    342         ));
    343         register_post_status('wc-nimble-denied', array(
    344             'label' =>  _x( 'Denied (Nimble Payments)', 'Order status', 'woocommerce-nimble-payments' ), //LANG: DENIED STATUS
    345             'public'    => false,
    346             'exclude_from_search'   =>  false,
    347             'show_in_admin_all_list'    => true,
    348             'show_in_admin_status_list' =>  true,
    349             'label_count'   =>    _n_noop('Denied (Nimble Payments) <span class="count">(%s)</span>', 'Denied (Nimble Payments) <span class="count">(%s)</span>', 'woocommerce') //LANG: FAILED LIST
    350         ));
    351     }
    352    
     430    }
     431
    353432    function valid_order_statuses_for_payment($order_statuses){
    354         $order_statuses[]='nimble-pending';
    355         $order_statuses[]='nimble-failed';
    356         return $order_statuses;
    357     }
     433       $order_statuses[]='nimble-pending';
     434       return $order_statuses;
     435   }
    358436   
    359437    function filter_templates_checkout($located, $template_name, $args){
     
    416494        if ( self::$gateway ){
    417495            try {
    418                 $options = get_option($this->options_name);
    419                 if (is_array($options) && isset($options['login']) && $options['login']){
    420                     $params = wp_parse_args($options, self::$params);
     496                if (isset($this->options['login']) && $this->options['login']){
     497                    unset($this->options['login']);
     498                    $params = wp_parse_args($this->options, self::$params);
    421499                    $nimble_api = new WP_NimbleAPI($params);
    422                     $options = array(
    423                         'token' => $nimble_api->authorization->getAccessToken(),
    424                         'refreshToken' => $nimble_api->authorization->getRefreshToken()
     500                    $this->options = array_merge($this->options,
     501                            array(
     502                                'token' => $nimble_api->authorization->getAccessToken(),
     503                                'refreshToken' => $nimble_api->authorization->getRefreshToken()
     504                            )
    425505                    );
    426                     if ( empty($options['token']) || empty($options['refreshToken']) ){
    427                         delete_option($this->options_name);
    428                     } else {
    429                         update_option($this->options_name, $options);
     506                    if ( empty($this->options['token']) || empty($this->options['refreshToken']) ){
     507                        $this->options['token'] = '';
     508                        $this->options['refreshToken'] = '';
    430509                    }
     510                    update_option($this->options_name, $this->options);
    431511                    $this->oauth3_enabled = true;
    432512                }
     
    441521     */
    442522    function login_actions($user_login, $user){
     523        // For refreshToken ::: hook woocommerce_init
    443524        if ( user_can($user, 'manage_options') ){
    444525            $options = get_option($this->options_name);
     
    448529            }
    449530        }
     531        // For Check Nimble-Pending Orders ::: hook wp_loaded
     532        $is_admin = in_array('administrator', $user->roles);
     533        if ( self::$gateway && $is_admin ) {
     534            $options = get_option($this->options_name);
     535            if (is_array($options)){
     536                $options['check_orders'] = true;
     537                update_option($this->options_name, $options);
     538            }
     539        }
    450540    }
    451541   
     
    456546        if ( self::$gateway ){
    457547            try {
    458                 $options = get_option($this->options_name);
     548                $options = $this->options;
    459549                unset($options['refreshToken']);
    460550                $params = wp_parse_args($options, self::$params);
     
    479569        if ( self::$gateway ){
    480570            try {
    481                 $options = get_option($this->options_name);
     571                $options = $this->options;
    482572                unset($options['refreshToken']);
    483573                $params = wp_parse_args($options, self::$params);
     
    498588    function manageApiError($response){
    499589        $this->oauth3_enabled = false;
    500         delete_option($this->options_name);
     590        $this->options['token'] = '';
     591        $this->options['refreshToken'] = '';
     592        update_option($this->options_name, $this->options);
    501593    }
    502594   
     
    548640        //Show resumen
    549641        if ( $this->oauth3_enabled ){
    550             //var_dump(get_option($this->options_name));
    551642            $this->getResumen();
    552             //delete_option($this->options_name);
    553643        }
    554644        //Show Authentication URL to AOUTH3
  • nimblepayments/trunk/readme.txt

    r1534878 r1554761  
    4848== Changelog ==
    4949
     50= 3.0.0 =
     51* Nueva opción para desvincular la tienda con la pasarela de Nimble Payments.
     52* Mejoras en la definición de los estados de los pedidos
     53* Otras correcciones menores.
     54
    5055= 2.1.0 =
    5156* Nuevos estados para los pedidos (Denegado).
     
    7075== Upgrade Notice ==
    7176
     77= 3.0.0 =
     78Actualización importante. Descubre las nuevas funcionalidades de la nueva versión.
     79
    7280= 2.1.0 =
    7381Mantente actualizado.
Note: See TracChangeset for help on using the changeset viewer.