Plugin Directory

Changeset 1024857


Ignore:
Timestamp:
11/13/2014 05:59:50 AM (11 years ago)
Author:
fatzebra
Message:

Bad merge

Location:
woocommerce-fat-zebra-gateway/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • woocommerce-fat-zebra-gateway/trunk/class-wc-fatzebra-masterpass.php

    r1024852 r1024857  
    1717      $this->live_paynow_url = "https://paynow.fatzebra.com.au/v2";
    1818
    19       $this->supports     = array( 'subscriptions', 'products', 'products', 'subscription_cancellation', 'subscription_reactivation', 'subscription_suspension', 'subscription_amount_changes', 'subscription_payment_method_change', 'subscription_date_changes' );
     19      $this->supports     = array( 'subscriptions', 'products', 'refunds', 'subscription_cancellation', 'subscription_reactivation', 'subscription_suspension', 'subscription_amount_changes', 'subscription_payment_method_change', 'subscription_date_changes' );
    2020      $this->params       = array();
    2121
     
    201201    }
    202202
     203    public function process_refund( $order_id, $amount = null, $reason = '' ) {
     204      $payment_gateways = WC()->payment_gateways->get_available_payment_gateways();
     205      if (!isset($payment_gateways['fatzebra'])) {
     206        return false;
     207      }
     208
     209      $gw = $payment_gateways['fatzebra'];
     210      return $gw->process_refund($order_id, $amount, $reason);
     211    }
     212
    203213    /**
    204214    *
     
    227237      switch((int)$_GET['r']) {
    228238        case 1:
    229           $order->payment_complete();
     239          $order->payment_complete($_GET['id']);
    230240          $order->add_order_note("Payment via Fat Zebra (MasterPass) successful. Transaction ID: " . $_GET['id'] .   ". Message: " . $_GET['message']);
    231241          $woocommerce->cart->empty_cart();
  • woocommerce-fat-zebra-gateway/trunk/class-wc-fatzebra-visacheckout.php

    r1024852 r1024857  
    1515      $this->sandbox_url  = "https://gateway.sandbox.fatzebra.com.au/v{$this->api_version}/purchases";
    1616
    17       $this->supports     = array( 'subscriptions', 'products', 'products', 'subscription_cancellation', 'subscription_reactivation', 'subscription_suspension', 'subscription_amount_changes', 'subscription_payment_method_change', 'subscription_date_changes' );
     17      $this->supports     = array( 'subscriptions', 'products', 'refunds', 'subscription_cancellation', 'subscription_reactivation', 'subscription_suspension', 'subscription_amount_changes', 'subscription_payment_method_change', 'subscription_date_changes' );
    1818      $this->params       = array();
    1919
    2020      // Define user set variables
    21       $this->title        = 'VISA Checkout';
     21      $this->title        = 'Visa Checkout';
    2222      $this->description  = in_array("description", $this->settings) ? $this->settings['description'] : "";
    2323
     
    105105        With Visa Checkout, you now have an easier way to pay with your card online, from the company you know and trust. Create an account once and speed through your purchase without re-entering payment or shipping information wherever you see Visa Checkout.
    106106      </p>
     107
     108      <?php if (!empty($callid)) { ?>
     109        <p style='font-weight: bold'>The following card has been selected via Visa Checkout:</p>
     110        <p style='font-size: 20px; padding-left: 40px; margin-top: 20px; font-family: monospace;'>
     111          <?php echo WC()->session->get('visa_wallet_masked_number'); ?>
     112        </p>
     113
     114      <?php } ?>
     115
     116      <style type='text/css'>
     117        #custom-visa-checkout-outer-container{
     118         float: right;
     119        }
     120      </style>
    107121      <?php
    108122
     
    125139            'currency' => get_woocommerce_currency(),
    126140            'order_total' => $woocommerce->cart->total,
    127             'visa_checkout_button' => "<img src='{$visa_base_url}/wallet-services-web/xo/button.png?locale=en_AU&card_brands=" . implode(",", $accepted_cards) . "&style=color&size=213' class='v-button' data-2x-image='{$visa_base_url}/wallet-services-web/xo/button.png?locale=en_AU&card_brands=" . implode(",", $accepted_cards) . "&style=color&size=425' width='213' height='47' role='button' style='float: right; width: auto; clear: both; border: none; background: none; box-shadow: none;'/>",
     141            'visa_checkout_button' => $this->get_visa_checkout_button($accepted_cards),
    128142            'button_text' => 'Pay',
    129143            'review_message' => 'Please select your card and click Pay to complete your order',
     
    257271            }
    258272          }
    259           $order->payment_complete();
     273          $order->payment_complete($result['transaction_id']);
    260274
    261275          // Clear the session values
     
    273287        );
    274288      }
     289    }
     290
     291    public function process_refund( $order_id, $amount = null, $reason = '' ) {
     292      $payment_gateways = WC()->payment_gateways->get_available_payment_gateways();
     293      if (!isset($payment_gateways['fatzebra'])) {
     294        return false;
     295      }
     296
     297      $gw = $payment_gateways['fatzebra'];
     298      return $gw->process_refund($order_id, $amount, $reason);
    275299    }
    276300
     
    490514      endforeach;
    491515    }
     516
     517    function get_visa_checkout_button($accepted_cards) {
     518      return "<style type='text/css'>
     519                #custom-visa-checkout-outer-container{
     520                  position:relative;
     521                  width: 213px;
     522                  display: inline-block;
     523                  margin-top: 5px;
     524                }
     525                #custom-visa-checkout-learn-more{
     526                  width:210px;
     527                  text-align:right;
     528                  margin-top: -10px;
     529                }
     530                #custom-visa-checkout-learn-more-text{
     531                  font:bold 8.5pt arial;
     532                  text-decoration: none;
     533                  color: #0044AA;
     534                }
     535                img#custom-visa-checkout {
     536                  max-width: inherit;
     537                }
     538
     539                .v-button {
     540                  cursor: pointer;
     541                  width: 213px !important;
     542                  box-shadow: none !important;
     543                  border: none !important;
     544                  backgound: none !important;
     545                }
     546              </style>
     547              <div id='custom-visa-checkout-outer-container'>
     548                <img alt='Button' class='v-button' data-2x-image='https://secure.checkout.visa.com/wallet-services-web/xo/button.png?locale=en_AU&amp;card_brands=VISA,MasterCard&amp;style=color&amp;size=425' height='47' id='v-checkout-button' role='button' src='https://secure.checkout.visa.com/wallet-services-web/xo/button.png?locale=en_AU&amp;card_brands=VISA,MasterCard&amp;style=color&amp;size=213' width='213'>
     549                <div id='custom-visa-checkout-learn-more'>
     550                  <a href='javascript:void(0)' id='custom-visa-checkout-learn-more-text' onclick=\"document.getElementById('custom-visa-checkout').style.display='block'\">Learn More</a>
     551                </div>
     552                <img alt='Cart_learnmore_pop-up_left' id='custom-visa-checkout' onclick=\"document.getElementById('custom-visa-checkout').style.display='none';\" src='https://sandbox-assets.secure.checkout.visa.com/VmeCardArts/partner/Cart_LearnMore_Pop-Up_left.png' style='display: none; z-index: 9999; position: absolute; top: -170px; left: 220px; box-shadow: none; width: auto;'>
     553              </div>";
     554    }
    492555  }
    493556
     
    526589            'currency' => get_woocommerce_currency(),
    527590            'order_total' => $amount,
    528             'visa_checkout_button' => "<img src='{$visa_base_url}/wallet-services-web/xo/button.png?locale=en_AU&card_brands=" . implode(",", $accepted_cards) . "&style=color&size=213' class='v-button' data-2x-image='{$visa_base_url}/wallet-services-web/xo/button.png?locale=en_AU&card_brands=" . implode(",", $accepted_cards) . "&style=color&size=425' width='213' height='47' role='button' style='float: right; width: auto; clear: both; border: none; background: none; box-shadow: none;'/>",
     591            'visa_checkout_button' => $gw->get_visa_checkout_button($accepted_cards),
    529592            'inline' => true,
    530593            'shipping' => false,
     
    535598      wp_enqueue_script( 'fz-visacheckout' ); 
    536599      wp_enqueue_script( 'visa-checkout' );
    537 
    538     // Visa Checkout Button
    539     // Visa Checkout INIT
    540     // Handler for callback (process payment, retrieve address details, update order)
    541600  }
    542601
     
    583642    WC()->session->set('visa_wallet_callid', $callid);
    584643    WC()->session->set('visa_wallet_token', $token_result['card_token']);
     644    WC()->session->set('visa_wallet_masked_number', $token_result['card_number']);
    585645
    586646    wc_setcookie('fatzebra_visacheckout_callid', null, time() - 3600);
  • woocommerce-fat-zebra-gateway/trunk/class-wc-fatzebra.php

    r1024852 r1024857  
    368368          }
    369369
    370           $order->payment_complete();
     370          $order->payment_complete($result['transaction_id']);
    371371
    372372          // Store the card token as post meta
     
    398398      $this->params["amount"] = (int)($amount * 100);
    399399      $this->params["reference"] = $order_id . "-" . time(); // It is not possible to simply refund against the order ID as multiple reunds are permitted...
    400       $this->params["transaction_id"] = get_post_meta($order_id, 'Fat Zebra Transaction ID', true); // The original FZ transaction ID
     400      $this->params["transaction_id"] = get_post_meta($order_id, '_transaction_id', true);
    401401      if (empty($this->params['transaction_id'])) {
    402402        $this->params["transaction_id"] = $this->fetch_fatzebra_transaction_id($order_id);
  • woocommerce-fat-zebra-gateway/trunk/images/fatzebra-visacheckout.js

    r1024852 r1024857  
    1 // // Visa Checkout Handling
    2 // var visaCheckoutReady = false;
    3 // function onVmeReady() {
    4 //     visaCheckoutReady = true;
    5 // }
     1// Visa Checkout Handling
     2var visaCheckoutReady = false;
     3function onVmeReady() {
     4    visaCheckoutReady = true;
     5}
    66
    7 // function initVisaCheckout() {
    8 //     if (!visaCheckoutReady) { // Wait until Visa Checkout is ready to init...
    9 //         setTimeout(initVisaCheckout, 500);
    10 //         return false;
    11 //     }
     7function initVisaCheckout() {
     8    if (!visaCheckoutReady) { // Wait until Visa Checkout is ready to init...
     9        setTimeout(initVisaCheckout, 500);
     10        return false;
     11    }
    1212
    13 //     if (fzvisa.checkout_captured == 1) {
    14 //         return false; // Visa Checkout has already been completed on the cart page.
    15 //     } else {
     13    if (fzvisa.checkout_captured == 1) {
     14        return false; // Visa Checkout has already been completed on the cart page.
     15    } else {
    1616
    17 //         V.init({
    18 //             apikey: fzvisa.api_key,
    19 //             settings: {
    20 //                 dataLevel: "SUMMARY",
    21 //                 displayName: fzvisa.website_name,
    22 //                 logoUrl: fzvisa.logo_url
    23 //             },
    24 //             paymentRequest: {
    25 //                 currencyCode: fzvisa.currency,
    26 //                 total: fzvisa.order_total
    27 //             },
    28 //             shipping: {
    29 //                 collectShipping: fzvisa.shipping
    30 //             },
    31 //             review: {
    32 //                 buttonAction: fzvisa.button_text,
    33 //                 message: fzvisa.review_message
    34 //             }
    35 //         });
     17        V.init({
     18            apikey: fzvisa.api_key,
     19            settings: {
     20                dataLevel: "SUMMARY",
     21                displayName: fzvisa.website_name,
     22                logoUrl: fzvisa.logo_url
     23            },
     24            paymentRequest: {
     25                currencyCode: fzvisa.currency,
     26                total: fzvisa.order_total
     27            },
     28            shipping: {
     29                collectShipping: fzvisa.shipping
     30            },
     31            review: {
     32                buttonAction: fzvisa.button_text,
     33                message: fzvisa.review_message
     34            }
     35        });
    3636
    37 //         V.on("payment.success", function(payment) {
    38 //             jQuery('#callid').val(payment.callid);
     37        V.on("payment.success", function(payment) {
     38            jQuery('#callid').val(payment.callid);
    3939
    40 //             if (fzvisa.inline) {
    41 //                 // 'Post' form to wc-api call for processing.. prefill the form and then show the checkout page
    42 //                 jQuery(".checkout-button").click();
    43 //             }
     40            if (fzvisa.inline) {
     41                // 'Post' form to wc-api call for processing.. prefill the form and then show the checkout page
     42                jQuery(".checkout-button").click();
     43                jQuery(".checkout-button").attr("disabled", true).val("Please wait...");
     44            }
    4445
    45 //             jQuery('#encKey').val(payment.encKey);
    46 //             jQuery('#encPaymentData').val(payment.encPaymentData);
     46            jQuery('#encKey').val(payment.encKey);
     47            jQuery('#encPaymentData').val(payment.encPaymentData);
    4748           
    4849
    49 //             jQuery('#place_order').show();
    50 //             jQuery('.v-button').remove();
     50            jQuery('#place_order').show();
     51            jQuery('#custom-visa-checkout-outer-container').remove();
    5152
    52 //             $form = jQuery("form.checkout");
    53 //             $form.submit();
    54 //         });
     53            $form = jQuery("form.checkout");
     54            $form.submit();
     55        });
    5556
    56 //         V.on("payment.cancel", function(payment) {
    57 //             // Cancelled, but we don't need to do anything, the user just needs to choose an alternative
    58 //         });
    59 //         V.on("payment.error", function(payment, error) {
    60 //             // Error - report to user, try again?
    61 //         });
    62 //     }
    63 // }
     57        V.on("payment.cancel", function(payment) {
     58            // Cancelled, but we don't need to do anything, the user just needs to choose an alternative
     59        });
     60        V.on("payment.error", function(payment, error) {
     61            // Error - report to user, try again?
     62        });
     63    }
     64}
    6465
    65 // jQuery( '#order_review' ).on( 'click', '.payment_methods input.input-radio', function() {
    66 //     if ( jQuery( '.payment_methods input.input-radio' ).length > 1 ) {
    67 //         if (fzvisa.checkout_captured == 1) {
    68 //             return;
    69 //         }
    70 //         var id = jQuery(this).val();
    71 //         if (id == 'fatzebra_visacheckout') {
    72 //             if (jQuery('.v-button').length !== 0) return;
    73 //             jQuery('#place_order').hide();
    74 //             jQuery('#place_order').after(fzvisa.visa_checkout_button);
     66jQuery( '#order_review' ).on( 'click', '.payment_methods input.input-radio', function() {
     67    if ( jQuery( '.payment_methods input.input-radio' ).length > 1 ) {
     68        if (fzvisa.checkout_captured == 1) {
     69            return;
     70        }
     71        var id = jQuery(this).val();
     72        if (id == 'fatzebra_visacheckout') {
     73            if (jQuery('#custom-visa-checkout-outer-container').length !== 0) return;
     74            jQuery('#place_order').hide();
     75            jQuery('#place_order').after(fzvisa.visa_checkout_button);
    7576
    76 //             setTimeout(initVisaCheckout, 500);
    77 //         } else {
    78 //             // Remove the visa button and show the place order button again
    79 //             jQuery('.v-button').remove();
    80 //             jQuery('#place_order').show();
    81 //         }
    82 //     }
    83 // });
     77            setTimeout(initVisaCheckout, 500);
     78        } else {
     79            // Remove the visa button and show the place order button again
     80            jQuery('#custom-visa-checkout-outer-container').remove();
     81            jQuery('#place_order').show();
     82        }
     83    }
     84});
    8485
    85 // if (fzvisa.inline) {
    86 //     // Render the 'Checkout' button on the cart page
    87 //     jQuery(".checkout-button").after("<br />").after(fzvisa.visa_checkout_button);
    88 //     jQuery(".checkout-button").append("<input type='hidden' name='callid' id='callid' />");
    89 //     setTimeout(initVisaCheckout, 500);
    90 // }
     86if (fzvisa.inline) {
     87    // Render the 'Checkout' button on the cart page
     88    jQuery(".checkout-button").after("<br />").after(fzvisa.visa_checkout_button);
     89    jQuery(".checkout-button").append("<input type='hidden' name='callid' id='callid' />");
     90    setTimeout(initVisaCheckout, 500);
     91}
  • woocommerce-fat-zebra-gateway/trunk/readme.txt

    r1024852 r1024857  
    33Tags: ecommerce, woocommerce, fatzebra, payment gateway, australia, subscriptions, wcsubscriptions
    44Requires at least: 3.8
    5 Tested up to: 3.8.1
     5Tested up to: 4.0
    66Stable tag: trunk
    77
Note: See TracChangeset for help on using the changeset viewer.