.fl-builder-content *,.fl-builder-content *:before,.fl-builder-content *:after {-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;}.fl-row:before,.fl-row:after,.fl-row-content:before,.fl-row-content:after,.fl-col-group:before,.fl-col-group:after,.fl-col:before,.fl-col:after,.fl-module:not([data-accepts]):before,.fl-module:not([data-accepts]):after,.fl-module-content:before,.fl-module-content:after {display: table;content: " ";}.fl-row:after,.fl-row-content:after,.fl-col-group:after,.fl-col:after,.fl-module:not([data-accepts]):after,.fl-module-content:after {clear: both;}.fl-clear {clear: both;}.fl-row,.fl-row-content {margin-left: auto;margin-right: auto;min-width: 0;}.fl-row-content-wrap {position: relative;}.fl-builder-mobile .fl-row-bg-photo .fl-row-content-wrap {background-attachment: scroll;}.fl-row-bg-video,.fl-row-bg-video .fl-row-content,.fl-row-bg-embed,.fl-row-bg-embed .fl-row-content {position: relative;}.fl-row-bg-video .fl-bg-video,.fl-row-bg-embed .fl-bg-embed-code {bottom: 0;left: 0;overflow: hidden;position: absolute;right: 0;top: 0;}.fl-row-bg-video .fl-bg-video video,.fl-row-bg-embed .fl-bg-embed-code video {bottom: 0;left: 0px;max-width: none;position: absolute;right: 0;top: 0px;}.fl-row-bg-video .fl-bg-video video {min-width: 100%;min-height: 100%;width: auto;height: auto;}.fl-row-bg-video .fl-bg-video iframe,.fl-row-bg-embed .fl-bg-embed-code iframe {pointer-events: none;width: 100vw;height: 56.25vw; max-width: none;min-height: 100vh;min-width: 177.77vh; position: absolute;top: 50%;left: 50%;-ms-transform: translate(-50%, -50%); -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%);}.fl-bg-video-fallback {background-position: 50% 50%;background-repeat: no-repeat;background-size: cover;bottom: 0px;left: 0px;position: absolute;right: 0px;top: 0px;}.fl-row-bg-slideshow,.fl-row-bg-slideshow .fl-row-content {position: relative;}.fl-row .fl-bg-slideshow {bottom: 0;left: 0;overflow: hidden;position: absolute;right: 0;top: 0;z-index: 0;}.fl-builder-edit .fl-row .fl-bg-slideshow * {bottom: 0;height: auto !important;left: 0;position: absolute !important;right: 0;top: 0;}.fl-row-bg-overlay .fl-row-content-wrap:after {border-radius: inherit;content: '';display: block;position: absolute;top: 0;right: 0;bottom: 0;left: 0;z-index: 0;}.fl-row-bg-overlay .fl-row-content {position: relative;z-index: 1;}.fl-row-default-height .fl-row-content-wrap,.fl-row-custom-height .fl-row-content-wrap {display: -webkit-box;display: -webkit-flex;display: -ms-flexbox;display: flex;min-height: 100vh;}.fl-row-overlap-top .fl-row-content-wrap {display: -webkit-inline-box;display: -webkit-inline-flex;display: -moz-inline-box;display: -ms-inline-flexbox;display: inline-flex;width: 100%;}.fl-row-default-height .fl-row-content-wrap,.fl-row-custom-height .fl-row-content-wrap {min-height: 0;}.fl-row-default-height .fl-row-content,.fl-row-full-height .fl-row-content,.fl-row-custom-height .fl-row-content {-webkit-box-flex: 1 1 auto; -moz-box-flex: 1 1 auto;-webkit-flex: 1 1 auto;-ms-flex: 1 1 auto;flex: 1 1 auto;}.fl-row-default-height .fl-row-full-width.fl-row-content,.fl-row-full-height .fl-row-full-width.fl-row-content,.fl-row-custom-height .fl-row-full-width.fl-row-content {max-width: 100%;width: 100%;}.fl-row-default-height.fl-row-align-center .fl-row-content-wrap,.fl-row-full-height.fl-row-align-center .fl-row-content-wrap,.fl-row-custom-height.fl-row-align-center .fl-row-content-wrap {-webkit-align-items: center;-webkit-box-align: center;-webkit-box-pack: center;-webkit-justify-content: center;-ms-flex-align: center;-ms-flex-pack: center;justify-content: center;align-items: center;}.fl-row-default-height.fl-row-align-bottom .fl-row-content-wrap,.fl-row-full-height.fl-row-align-bottom .fl-row-content-wrap,.fl-row-custom-height.fl-row-align-bottom .fl-row-content-wrap {-webkit-align-items: flex-end;-webkit-justify-content: flex-end;-webkit-box-align: end;-webkit-box-pack: end;-ms-flex-align: end;-ms-flex-pack: end;justify-content: flex-end;align-items: flex-end;}.fl-col-group-equal-height {display: flex;flex-wrap: wrap;width: 100%;}.fl-col-group-equal-height.fl-col-group-has-child-loading {flex-wrap: nowrap;}.fl-col-group-equal-height .fl-col,.fl-col-group-equal-height .fl-col-content {display: flex;flex: 1 1 auto;}.fl-col-group-equal-height .fl-col-content {flex-direction: column;flex-shrink: 1;min-width: 1px;max-width: 100%;width: 100%;}.fl-col-group-equal-height:before,.fl-col-group-equal-height .fl-col:before,.fl-col-group-equal-height .fl-col-content:before,.fl-col-group-equal-height:after,.fl-col-group-equal-height .fl-col:after,.fl-col-group-equal-height .fl-col-content:after{content: none;}.fl-col-group-nested.fl-col-group-equal-height.fl-col-group-align-top .fl-col-content,.fl-col-group-equal-height.fl-col-group-align-top .fl-col-content {justify-content: flex-start;}.fl-col-group-nested.fl-col-group-equal-height.fl-col-group-align-center .fl-col-content,.fl-col-group-equal-height.fl-col-group-align-center .fl-col-content {justify-content: center;}.fl-col-group-nested.fl-col-group-equal-height.fl-col-group-align-bottom .fl-col-content,.fl-col-group-equal-height.fl-col-group-align-bottom .fl-col-content {justify-content: flex-end;}.fl-col-group-equal-height.fl-col-group-align-center .fl-col-group {width: 100%;}.fl-col {float: left;min-height: 1px;}.fl-col-bg-overlay .fl-col-content {position: relative;}.fl-col-bg-overlay .fl-col-content:after {border-radius: inherit;content: '';display: block;position: absolute;top: 0;right: 0;bottom: 0;left: 0;z-index: 0;}.fl-col-bg-overlay .fl-module {position: relative;z-index: 2;}.single:not(.woocommerce).single-fl-builder-template .fl-content {width: 100%;}.fl-builder-layer {position: absolute;top:0;left:0;right: 0;bottom: 0;z-index: 0;pointer-events: none;overflow: hidden;}.fl-builder-shape-layer {z-index: 0;}.fl-builder-shape-layer.fl-builder-bottom-edge-layer {z-index: 1;}.fl-row-bg-overlay .fl-builder-shape-layer {z-index: 1;}.fl-row-bg-overlay .fl-builder-shape-layer.fl-builder-bottom-edge-layer {z-index: 2;}.fl-row-has-layers .fl-row-content {z-index: 1;}.fl-row-bg-overlay .fl-row-content {z-index: 2;}.fl-builder-layer > * {display: block;position: absolute;top:0;left:0;width: 100%;}.fl-builder-layer + .fl-row-content {position: relative;}.fl-builder-layer .fl-shape {fill: #aaa;stroke: none;stroke-width: 0;width:100%;}@supports (-webkit-touch-callout: inherit) {.fl-row.fl-row-bg-parallax .fl-row-content-wrap,.fl-row.fl-row-bg-fixed .fl-row-content-wrap {background-position: center !important;background-attachment: scroll !important;}}@supports (-webkit-touch-callout: none) {.fl-row.fl-row-bg-fixed .fl-row-content-wrap {background-position: center !important;background-attachment: scroll !important;}}.fl-clearfix:before,.fl-clearfix:after {display: table;content: " ";}.fl-clearfix:after {clear: both;}.sr-only {position: absolute;width: 1px;height: 1px;padding: 0;overflow: hidden;clip: rect(0,0,0,0);white-space: nowrap;border: 0;}.fl-builder-content a.fl-button,.fl-builder-content a.fl-button:visited {border-radius: 4px;-moz-border-radius: 4px;-webkit-border-radius: 4px;display: inline-block;font-size: 16px;font-weight: normal;line-height: 18px;padding: 12px 24px;text-decoration: none;text-shadow: none;}.fl-builder-content .fl-button:hover {text-decoration: none;}.fl-builder-content .fl-button:active {position: relative;top: 1px;}.fl-builder-content .fl-button-width-full .fl-button {display: block;text-align: center;}.fl-builder-content .fl-button-width-custom .fl-button {display: inline-block;text-align: center;max-width: 100%;}.fl-builder-content .fl-button-left {text-align: left;}.fl-builder-content .fl-button-center {text-align: center;}.fl-builder-content .fl-button-right {text-align: right;}.fl-builder-content .fl-button i {font-size: 1.3em;height: auto;margin-right:8px;vertical-align: middle;width: auto;}.fl-builder-content .fl-button i.fl-button-icon-after {margin-left: 8px;margin-right: 0;}.fl-builder-content .fl-button-has-icon .fl-button-text {vertical-align: middle;}.fl-icon-wrap {display: inline-block;}.fl-icon {display: table-cell;vertical-align: middle;}.fl-icon a {text-decoration: none;}.fl-icon i {float: right;height: auto;width: auto;}.fl-icon i:before {border: none !important;height: auto;width: auto;}.fl-icon-text {display: table-cell;text-align: left;padding-left: 15px;vertical-align: middle;}.fl-icon-text-empty {display: none;}.fl-icon-text *:last-child {margin: 0 !important;padding: 0 !important;}.fl-icon-text a {text-decoration: none;}.fl-icon-text span {display: block;}.fl-icon-text span.mce-edit-focus {min-width: 1px;}.fl-module img {max-width: 100%;}.fl-photo {line-height: 0;position: relative;}.fl-photo-align-left {text-align: left;}.fl-photo-align-center {text-align: center;}.fl-photo-align-right {text-align: right;}.fl-photo-content {display: inline-block;line-height: 0;position: relative;max-width: 100%;}.fl-photo-img-svg {width: 100%;}.fl-photo-content img {display: inline;height: auto;max-width: 100%;}.fl-photo-crop-circle img {-webkit-border-radius: 100%;-moz-border-radius: 100%;border-radius: 100%;}.fl-photo-caption {font-size: 13px;line-height: 18px;overflow: hidden;text-overflow: ellipsis;}.fl-photo-caption-below {padding-bottom: 20px;padding-top: 10px;}.fl-photo-caption-hover {background: rgba(0,0,0,0.7);bottom: 0;color: #fff;left: 0;opacity: 0;filter: alpha(opacity = 0);padding: 10px 15px;position: absolute;right: 0;-webkit-transition:opacity 0.3s ease-in;-moz-transition:opacity 0.3s ease-in;transition:opacity 0.3s ease-in;}.fl-photo-content:hover .fl-photo-caption-hover {opacity: 100;filter: alpha(opacity = 100);}.fl-builder-pagination,.fl-builder-pagination-load-more {padding: 40px 0;}.fl-builder-pagination ul.page-numbers {list-style: none;margin: 0;padding: 0;text-align: center;}.fl-builder-pagination li {display: inline-block;list-style: none;margin: 0;padding: 0;}.fl-builder-pagination li a.page-numbers,.fl-builder-pagination li span.page-numbers {border: 1px solid #e6e6e6;display: inline-block;padding: 5px 10px;margin: 0 0 5px;}.fl-builder-pagination li a.page-numbers:hover,.fl-builder-pagination li span.current {background: #f5f5f5;text-decoration: none;}.fl-slideshow,.fl-slideshow * {-webkit-box-sizing: content-box;-moz-box-sizing: content-box;box-sizing: content-box;}.fl-slideshow .fl-slideshow-image img {max-width: none !important;}.fl-slideshow-social {line-height: 0 !important;}.fl-slideshow-social * {margin: 0 !important;}.fl-builder-content .bx-wrapper .bx-viewport {background: transparent;border: none;box-shadow: none;-moz-box-shadow: none;-webkit-box-shadow: none;left: 0;}.mfp-wrap button.mfp-arrow,.mfp-wrap button.mfp-arrow:active,.mfp-wrap button.mfp-arrow:hover,.mfp-wrap button.mfp-arrow:focus {background: transparent !important;border: none !important;outline: none;position: absolute;top: 50%;box-shadow: none !important;-moz-box-shadow: none !important;-webkit-box-shadow: none !important;}.mfp-wrap .mfp-close,.mfp-wrap .mfp-close:active,.mfp-wrap .mfp-close:hover,.mfp-wrap .mfp-close:focus {background: transparent !important;border: none !important;outline: none;position: absolute;top: 0;box-shadow: none !important;-moz-box-shadow: none !important;-webkit-box-shadow: none !important;}.admin-bar .mfp-wrap .mfp-close,.admin-bar .mfp-wrap .mfp-close:active,.admin-bar .mfp-wrap .mfp-close:hover,.admin-bar .mfp-wrap .mfp-close:focus {top: 32px!important;}img.mfp-img {padding: 0;}.mfp-counter {display: none;}.mfp-wrap .mfp-preloader.fa {font-size: 30px;}.fl-form-field {margin-bottom: 15px;}.fl-form-field input.fl-form-error {border-color: #DD6420;}.fl-form-error-message {clear: both;color: #DD6420;display: none;padding-top: 8px;font-size: 12px;font-weight: lighter;}.fl-form-button-disabled {opacity: 0.5;}.fl-animation {opacity: 0;}body.fl-no-js .fl-animation {opacity: 1;}.fl-builder-preview .fl-animation,.fl-builder-edit .fl-animation,.fl-animated {opacity: 1;}.fl-animated {animation-fill-mode: both;-webkit-animation-fill-mode: both;}.fl-button.fl-button-icon-animation i {width: 0 !important;opacity: 0;-ms-filter: "alpha(opacity=0)";transition: all 0.2s ease-out;-webkit-transition: all 0.2s ease-out;}.fl-button.fl-button-icon-animation:hover i {opacity: 1! important;-ms-filter: "alpha(opacity=100)";}.fl-button.fl-button-icon-animation i.fl-button-icon-after {margin-left: 0px !important;}.fl-button.fl-button-icon-animation:hover i.fl-button-icon-after {margin-left: 10px !important;}.fl-button.fl-button-icon-animation i.fl-button-icon-before {margin-right: 0 !important;}.fl-button.fl-button-icon-animation:hover i.fl-button-icon-before {margin-right: 20px !important;margin-left: -10px;}@media (max-width: 1200px) {}@media (max-width: 992px) { .fl-col-group.fl-col-group-medium-reversed {display: -webkit-flex;display: flex;-webkit-flex-wrap: wrap-reverse;flex-wrap: wrap-reverse;flex-direction: row-reverse;} }@media (max-width: 768px) { .fl-row-content-wrap {background-attachment: scroll !important;}.fl-row-bg-parallax .fl-row-content-wrap {background-attachment: scroll !important;background-position: center center !important;}.fl-col-group.fl-col-group-equal-height {display: block;}.fl-col-group.fl-col-group-equal-height.fl-col-group-custom-width {display: -webkit-box;display: -webkit-flex;display: flex;}.fl-col-group.fl-col-group-responsive-reversed {display: -webkit-flex;display: flex;-webkit-flex-wrap: wrap-reverse;flex-wrap: wrap-reverse;flex-direction: row-reverse;}.fl-col-group.fl-col-group-responsive-reversed .fl-col:not(.fl-col-small-custom-width) {flex-basis: 100%;width: 100% !important;}.fl-col-group.fl-col-group-medium-reversed:not(.fl-col-group-responsive-reversed) {display: unset;display: unset;-webkit-flex-wrap: unset;flex-wrap: unset;flex-direction: unset;}.fl-col {clear: both;float: none;margin-left: auto;margin-right: auto;width: auto !important;}.fl-col-small:not(.fl-col-small-full-width) {max-width: 400px;}.fl-block-col-resize {display:none;}.fl-row[data-node] .fl-row-content-wrap {margin: 0;padding-left: 0;padding-right: 0;}.fl-row[data-node] .fl-bg-video,.fl-row[data-node] .fl-bg-slideshow {left: 0;right: 0;}.fl-col[data-node] .fl-col-content {margin: 0;padding-left: 0;padding-right: 0;} }@media (min-width: 1201px) {html .fl-visible-large:not(.fl-visible-desktop),html .fl-visible-medium:not(.fl-visible-desktop),html .fl-visible-mobile:not(.fl-visible-desktop) {display: none;}}@media (min-width: 993px) and (max-width: 1200px) {html .fl-visible-desktop:not(.fl-visible-large),html .fl-visible-medium:not(.fl-visible-large),html .fl-visible-mobile:not(.fl-visible-large) {display: none;}}@media (min-width: 769px) and (max-width: 992px) {html .fl-visible-desktop:not(.fl-visible-medium),html .fl-visible-large:not(.fl-visible-medium),html .fl-visible-mobile:not(.fl-visible-medium) {display: none;}}@media (max-width: 768px) {html .fl-visible-desktop:not(.fl-visible-mobile),html .fl-visible-large:not(.fl-visible-mobile),html .fl-visible-medium:not(.fl-visible-mobile) {display: none;}}.fl-col-content {display: flex;flex-direction: column;margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;padding-top: 0px;padding-right: 0px;padding-bottom: 0px;padding-left: 0px;}.fl-row-fixed-width {max-width: 1100px;}.fl-row-content-wrap {margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;padding-top: 20px;padding-right: 20px;padding-bottom: 20px;padding-left: 20px;}.fl-module-content, .fl-module:where(.fl-module:not(:has(> .fl-module-content))) {margin-top: 20px;margin-right: 20px;margin-bottom: 20px;margin-left: 20px;}.page .fl-post-header, .single-fl-builder-template .fl-post-header { display:none; }.fl-node-jvf8h4nm30qc > .fl-row-content-wrap {border-top-width: 1px;border-right-width: 0px;border-bottom-width: 1px;border-left-width: 0px;} .fl-node-jvf8h4nm30qc > .fl-row-content-wrap {margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;} .fl-node-jvf8h4nm30qc > .fl-row-content-wrap {padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;}.fl-node-uc2pr9j6o7b0 > .fl-row-content-wrap {border-top-width: 1px;border-right-width: 0px;border-bottom-width: 1px;border-left-width: 0px;}.fl-node-uc2pr9j6o7b0.fl-row-fixed-width, .fl-node-uc2pr9j6o7b0 .fl-row-fixed-width {max-width: 1254px;} .fl-node-uc2pr9j6o7b0 > .fl-row-content-wrap {margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;} .fl-node-uc2pr9j6o7b0 > .fl-row-content-wrap {padding-top:0px;padding-bottom:200px;}.fl-node-v34l9beruqat {width: 100%;}.fl-node-e3gfy5akl80j {width: 100%;}img.mfp-img {padding-bottom: 40px !important;}.fl-builder-edit .fl-fill-container img {transition: object-position .5s;}.fl-fill-container :is(.fl-module-content, .fl-photo, .fl-photo-content, img) {height: 100% !important;width: 100% !important;}@media (max-width: 768px) { .fl-photo-content,.fl-photo-img {max-width: 100%;} }.fl-node-93wczmxeih64, .fl-node-93wczmxeih64 .fl-photo {text-align: center;} .fl-node-93wczmxeih64.fl-module-photo {margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;}.fl-module-heading .fl-heading {padding: 0 !important;margin: 0 !important;}.fl-node-5bk89rv01fga.fl-module-heading, .fl-node-5bk89rv01fga.fl-module-heading :where(a, q, p, span) {text-align: center;}.fl-builder-content .fl-rich-text strong {font-weight: bold;}.fl-module.fl-rich-text p:last-child {margin-bottom: 0;}.fl-builder-edit .fl-module.fl-rich-text p:not(:has(~ *:not(.fl-block-overlay))) {margin-bottom: 0;}.fl-builder-content-1712 .fl-node-z6uagsmkc8b0 img.fl-photo-img {object-position: center;}.fl-node-z6uagsmkc8b0, .fl-node-z6uagsmkc8b0 .fl-photo {text-align: center;}.fl-node-z6uagsmkc8b0 .fl-photo-content, .fl-node-z6uagsmkc8b0 .fl-photo-img {width: 630px;}.fl-node-z6uagsmkc8b0 .fl-photo-img {border-top-width: 0px;}.fl-node-h4ra90wygdfp.fl-button-wrap, .fl-node-h4ra90wygdfp .fl-button-wrap {text-align: center;}.fl-builder-content .fl-node-h4ra90wygdfp a.fl-button {padding-top: 20px;padding-right: 20px;padding-bottom: 20px;padding-left: 20px;}.fl-builder-content .fl-node-h4ra90wygdfp a.fl-button, .fl-builder-content .fl-node-h4ra90wygdfp a.fl-button:visited, .fl-page .fl-builder-content .fl-node-h4ra90wygdfp a.fl-button, .fl-page .fl-builder-content .fl-node-h4ra90wygdfp a.fl-button:visited {font-family: Helvetica, Verdana, Arial, sans-serif;font-weight: 700;font-size: 21px;text-decoration: underline;font-style: italic;}.fl-builder-content .fl-node-ij5xy4f71usw.fl-module-rich-text.fl-rich-text,.fl-builder-content .fl-node-ij5xy4f71usw.fl-module-rich-text.fl-rich-text * {color: #000000;}.fl-builder-content .fl-node-ij5xy4f71usw.fl-module-rich-text.fl-rich-text, .fl-builder-content .fl-node-ij5xy4f71usw.fl-module-rich-text.fl-rich-text *:not(b, strong) {font-family: "Open Sans", sans-serif;font-weight: 300;font-size: 17px;line-height: 1.5;} .fl-node-ij5xy4f71usw.fl-module-rich-text {margin-top:0px;margin-bottom:0px;}<?phpadd_action('plugins_loaded', 'init_woocommerce_sagepayserver', 0);function init_woocommerce_sagepayserver() {if ( ! class_exists( 'WC_Payment_Gateway' ) ) { return; }load_plugin_textdomain('patsatech-woo-sagepay-server', false, dirname( plugin_basename( __FILE__ ) ) . '/lang');class woocommerce_sagepayserver extends WC_Payment_Gateway{public function __construct() {global $woocommerce;$this->id= 'sagepayserver';$this->method_title= __('SagePay Server', 'patsatech-woo-sagepay-server');$this->icon= apply_filters( 'woocommerce_sagepayserver_icon', '' );$this->has_fields= false;$this->notify_url= add_query_arg( 'wc-api', 'woocommerce_sagepayserver', home_url( '/' ) );$default_card_type_options = array('VISA' => 'VISA','MC' => 'MasterCard','AMEX' => 'American Express','DISC' => 'Discover','DC' => 'Diner's Club','JCB' => 'JCB Card');$this->card_type_options = apply_filters( 'woocommerce_sagepayserver_card_types', $default_card_type_options );// load form fields$this->init_form_fields();// initialise settings$this->init_settings();// variables$this->title= $this->settings['title'];$this->description= $this->settings['description'];$this->vendor_name= $this->settings['vendorname'];$this->mode = $this->settings['mode'];$this->transtype= $this->settings['transtype'];$this->paymentpage= $this->settings['paymentpage'];$this->iframe = $this->settings['iframe'];$this->cardtypes= $this->settings['cardtypes'];if( $this->mode == 'test' ){$this->gateway_url = 'https://test.sagepay.com/gateway/service/vspserver-register.vsp';}else if( $this->mode == 'live' ){$this->gateway_url = 'https://live.sagepay.com/gateway/service/vspserver-register.vsp';}// actionsadd_action( 'init', array( $this, 'successful_request') );add_action( 'woocommerce_api_woocommerce_sagepayserver', array( $this, 'successful_request' ) );add_action( 'woocommerce_receipt_sagepayserver', array( $this, 'receipt_page' ) );add_action( 'woocommerce_update_options_payment_gateways', array( $this, 'process_admin_options' ) );add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );if ( !$this->is_valid_for_use() ) $this->enabled = false;}function get_icon() {global $woocommerce;$icon = '';if ( $this->icon ) {// default behavior$icon = '<img src="' . $this->force_ssl( $this->icon ) . '" alt="' . $this->title . '" />';} elseif ( $this->cardtypes ) {// display icons for the selected card types$icon = '';foreach ( $this->cardtypes as $cardtype ) {if ( file_exists( plugin_dir_path( __FILE__ ) . '/images/card-' . strtolower( $cardtype ) . '.png' ) ) {$icon .= '<img src="' . $this->force_ssl( plugins_url( '/images/card-' . strtolower( $cardtype ) . '.png', __FILE__ ) ) . '" alt="' . strtolower( $cardtype ) . '" />';}}}return apply_filters( 'woocommerce_gateway_icon', $icon, $this->id );}function is_valid_for_use() {if (!in_array(get_woocommerce_currency(), array('USD','AUD','CAD','CHF','DKK','EUR','GBP','HKD','IDR','JPY','LUF','NOK','NZD','SEK','SGD','TRL'))) return false;return true;}public function admin_options(){?><h3><?php _e('SagePay Server', 'patsatech-woo-sagepay-server'); ?></h3><p><?php _e('SagePay Server works by processing Credit Cards on site. So users do not leave your site to enter their payment information.', 'patsatech-woo-sagepay-server'); ?></p><table class="form-table"><?phpif ( $this->is_valid_for_use() ){// Generate the HTML For the settings form.$this->generate_settings_html();}else{?><div class="inline error"><p><strong><?php _e( 'Gateway Disabled', 'woothemes' ); ?></strong>: <?php _e( 'SagePay Server does not support your store currency.', 'woothemes' ); ?></p></div><?php}?></table><!--/.form-table--><?php}public function init_form_fields() {//array to generate admin form$this->form_fields = array('enabled' => array('title' => __( 'Enable/Disable', 'patsatech-woo-sagepay-server' ),'type' => 'checkbox','label' => __( 'Enable SagePay Server', 'patsatech-woo-sagepay-server' ),'default' => 'yes'),'title' => array('title' => __( 'Title', 'patsatech-woo-sagepay-server' ),'type' => 'text','description' => __( 'This is the title displayed to the user during checkout.', 'patsatech-woo-sagepay-server' ),'default' => __( 'SagePay Server', 'patsatech-woo-sagepay-server' )),'description' => array('title' => __( 'Description', 'patsatech-woo-sagepay-server' ),'type' => 'textarea','description' => __( 'This is the description which the user sees during checkout.', 'patsatech-woo-sagepay-server' ),'default' => __("Payment via SagePay, Please enter your credit or debit card below.", 'patsatech-woo-sagepay-server')),'vendorname' => array('title' => __( 'Vendor Name', 'patsatech-woo-sagepay-server' ),'type' => 'text','description' => __( 'Please enter your vendor name provided by SagePay.', 'patsatech-woo-sagepay-server' ),'default' => ''),'mode' => array('title' => __('Mode Type', 'patsatech-woo-sagepay-server'),'type' => 'select','options' => array('test' => 'Test','live' => 'Live'),'default' => 'test','description' => __( 'Select Test or Live modes.', 'patsatech-woo-sagepay-server' )),'paymentpage' => array('title' => __('Payment Page Type', 'patsatech-woo-sagepay-server'),'type' => 'select','options' => array('LOW' => 'LOW','NORMAL' => 'NORMAL'),'default' => 'low','description' => __( 'This is used to indicate what type of payment page should be displayed. <br>LOW returns simpler payment pages which have only one step and minimal formatting. Designed to run in i-Frames. <br>NORMAL returns the normal card selection screen. We suggest you disable i-Frame if you select NORMAL.', 'patsatech-woo-sagepay-server' )),'iframe' => array('title' => __( 'Enable/Disable', 'patsatech-woo-sagepay-server' ),'type' => 'checkbox','label' => __( 'Enable i-Frame Mode', 'patsatech-woo-sagepay-server' ),'default' => 'yes','description' => __( 'Make sure your site is SSL Protected before using this feature.', 'patsatech-woo-sagepay-server' )),'transtype'=> array('title' => __('Transaction Type', 'patsatech-woo-sagepay-server'),'type' => 'select','options' => array('PAYMENT' => __('Payment', 'patsatech-woo-sagepay-server'),'DEFFERRED' => __('Deferred', 'patsatech-woo-sagepay-server'),'AUTHENTICATE' => __('Authenticate', 'patsatech-woo-sagepay-server')),'description' => __( 'Select Payment, Deferred or Authenticated.', 'patsatech-woo-sagepay-server' )),'cardtypes'=> array('title' => __( 'Accepted Cards', 'woothemes' ),'type' => 'multiselect','description' => __( 'Select which card types to accept.', 'woothemes' ),'default' => 'VISA','options' => $this->card_type_options,));}public function generate_sagepayserver_form( $order_id ) {global $woocommerce;$order = new WC_Order( $order_id );if($this->iframe == 'yes'){return '<iframe src="'. esc_url( get_transient('sagepay_server_next_url') ) .'" name="sagepayserver_payment_form" width="100%" height="900px" scrolling="no" ></iframe>';}else{wc_enqueue_js('jQuery("body").block({message: "<img src="'.esc_url( $woocommerce->plugin_url() ).'/assets/images/ajax-loader.gif" alt="Redirecting..." style="float:left; margin-right: 10px;" />'.__('Thank you for your order. We are now redirecting you to verify your card.', 'woothemes').'",overlayCSS:{background: "#fff",opacity: 0.6},css: {padding:20,textAlign:"center",color:"#555",border: "3px solid #aaa",backgroundColor:"#fff",cursor: "wait",lineHeight:"32px"}});jQuery("#submit_sagepayserver_payment_form").click();');return '<form action="'.esc_url( get_transient('sagepay_server_next_url') ).'" method="post" id="sagepayserver_payment_form"><input type="submit" class="button alt" id="submit_sagepayserver_payment_form" value="'.__('Submit', 'woothemes').'" /> <a class="button cancel" href="'.esc_url( $order->get_cancel_order_url() ).'">'.__('Cancel order &amp; restore cart', 'woothemes').'</a></form>';}}function process_payment( $order_id ) {global $woocommerce;$order = new WC_Order( $order_id );$time_stamp = date("ymdHis");$orderid = $this->vendor_name . "-" . $time_stamp . "-" . $order_id;$sd_arg['ReferrerID'] = 'CC923B06-40D5-4713-85C1-700D690550BF';$sd_arg['Amount'] = $order->order_total;$sd_arg['CustomerEMail'] = $order->get_billing_email();$sd_arg['BillingSurname'] = $order->get_billing_last_name();$sd_arg['BillingFirstnames'] = $order->get_billing_first_name();$sd_arg['BillingAddress1'] = $order->get_billing_address_1();$sd_arg['BillingAddress2'] = $order->get_billing_address_2();$sd_arg['BillingCity'] = $order->get_billing_city();if( $order->get_billing_country() == 'US' ){$sd_arg['BillingState'] = $order->get_billing_state();}else{$sd_arg['BillingState'] = '';}$sd_arg['BillingPostCode'] = $order->get_billing_postcode();$sd_arg['BillingCountry'] = $order->get_billing_country();$sd_arg['BillingPhone'] = $order->get_billing_phone();if( $this->cart_has_virtual_product() == true ){$sd_arg['DeliverySurname'] = $order->get_billing_last_name();$sd_arg['DeliveryFirstnames'] = $order->get_billing_first_name();$sd_arg['DeliveryAddress1'] = $order->get_billing_address_1();$sd_arg['DeliveryAddress2'] = $order->get_billing_address_2();$sd_arg['DeliveryCity'] = $order->get_billing_city();if( $order->get_billing_country() == 'US' ){$sd_arg['DeliveryState'] = $order->get_billing_state();}else{$sd_arg['DeliveryState'] = '';}$sd_arg['DeliveryPostCode'] = $order->get_billing_postcode();$sd_arg['DeliveryCountry'] = $order->get_billing_country();}else{$sd_arg['DeliverySurname'] = $order->get_shipping_last_name();$sd_arg['DeliveryFirstnames'] = $order->get_shipping_first_name();$sd_arg['DeliveryAddress1'] = $order->get_shipping_address_1();$sd_arg['DeliveryAddress2'] = $order->get_shipping_address_2();$sd_arg['DeliveryCity'] = $order->get_shipping_city();if( $order->get_shipping_country() == 'US' ){$sd_arg['DeliveryState'] = $order->get_shipping_state();}else{$sd_arg['DeliveryState'] = '';}$sd_arg['DeliveryPostCode'] = $order->get_shipping_postcode();$sd_arg['DeliveryCountry'] = $order->get_shipping_country();}$sd_arg['Description'] = sprintf(__('Order #%s' , 'woothemes'), $order->id);$sd_arg['Currency'] = get_woocommerce_currency();$sd_arg['VPSProtocol'] = 3.00;$sd_arg['Vendor'] = $this->vendor_name;$sd_arg['TxType'] = $this->transtype;$sd_arg['VendorTxCode'] = $orderid;$sd_arg['Profile'] = $this->paymentpage;$sd_arg['NotificationURL'] = $this->notify_url;$post_values = "";foreach( $sd_arg as $key => $value ) {$post_values .= "$key=" . urlencode( $value ) . "&";}$post_values = rtrim( $post_values, "& " );$response = wp_remote_post($this->gateway_url,array('body' => $post_values,'method' => 'POST','headers' => array( 'Content-Type' => 'application/x-www-form-urlencoded' ),'sslverify' => FALSE));if (!is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {$resp = array();$lines = preg_split( '/rn|r|n/', $response['body'] );foreach($lines as $line){$key_value = preg_split( '/=/', $line, 2 );if(count($key_value) > 1){$resp[trim($key_value[0])] = trim($key_value[1]);}}if(isset($resp['Status'])) update_post_meta($order->id, 'Status', $resp['Status']);if(isset($resp['StatusDetail'])) update_post_meta($order->id, 'StatusDetail', $resp['StatusDetail']);if(isset($resp['VPSTxId'])) update_post_meta($order->id, 'VPSTxId', $resp['VPSTxId']);if(isset($resp['CAVV'])) update_post_meta($order->id, 'CAVV', $resp['CAVV']);if(isset($resp['SecurityKey'])) update_post_meta($order->id, 'SecurityKey', $resp['SecurityKey']);if(isset($resp['TxAuthNo'])) update_post_meta($order->id, 'TxAuthNo', $resp['TxAuthNo']);if(isset($resp['AVSCV2'])) update_post_meta($order->id, 'AVSCV2', $resp['AVSCV2']);if(isset($resp['AddressResult'])) update_post_meta($order->id, 'AddressResult', $resp['AddressResult']);if(isset($resp['PostCodeResult'])) update_post_meta($order->id, 'PostCodeResult', $resp['PostCodeResult']);if(isset($resp['CV2Result'])) update_post_meta($order->id, 'CV2Result', $resp['CV2Result']);if(isset($resp['3DSecureStatus'])) update_post_meta($order->id, '3DSecureStatus', $resp['3DSecureStatus']);if(isset($orderid)) update_post_meta($order->id, 'VendorTxCode', $orderid );if ( $resp['Status'] == "OK" ){$order->add_order_note( $resp['StatusDetail'] );set_transient( 'sagepay_server_next_url', $resp['NextURL'] );$redirect = $order->get_checkout_payment_url( true );return array('result' => 'success','redirect'=> $redirect);}else{if(isset($resp['StatusDetail'])){wc_add_notice( sprintf('Transaction Failed. %s - %s', $resp['Status'], $resp['StatusDetail'] ), 'error' );}else{wc_add_notice( sprintf( 'Transaction Failed with %s - unknown error.', $resp['Status'] ), 'error' );}}}else{wc_add_notice( __('Gateway Error. Please Notify the Store Owner about this error.', 'patsatech-woo-sagepay-server'), 'error' );}}function receipt_page( $order ) {global $woocommerce;echo '<p>'.__('Thank you for your order.', 'woothemes').'</p>';echo $this->generate_sagepayserver_form( $order );}function successful_request() {global $woocommerce;$eoln = chr(13) . chr(10);$params = array();$params['Status'] = 'INVALID';if( isset( $_POST['VendorTxCode'] ) ){$vendor_tx_code = explode('-',$_POST['VendorTxCode']);$order = new WC_Order( $vendor_tx_code[2] );if( $_POST['Status'] == 'OK' ){$params = array('Status' => 'OK', 'StatusDetail' => __('Transaction acknowledged.', 'patsatech-woo-sagepay-server') );$redirect_url = $this->get_return_url( $order );$order->add_order_note( __('Sagepay Direct payment completed', 'patsatech-woo-sagepay-server') . ' ( ' . __('Transaction ID: ','patsatech-woo-sagepay-server') . $_POST['VendorTxCode'] . ' )' );$order->payment_complete();}elseif( $_POST['Status'] == 'ABORT' ){$params = array('Status' => 'INVALID', 'StatusDetail' => __('Transaction aborted - ', 'patsatech-woo-sagepay-server') . $_POST['StatusDetail'] );wc_add_notice( __('Aborted by user.', 'patsatech-woo-sagepay-server'), 'error' );$redirect_url = get_permalink( woocommerce_get_page_id( 'checkout' ) );}elseif( $_POST['Status'] == 'ERROR' ){$params = array('Status' => 'INVALID', 'StatusDetail' => __('Transaction errored - ', 'patsatech-woo-sagepay-server') . $_POST['StatusDetail'] );$redirect_url = $order->get_cancel_order_url();}else{$params = array('Status' => 'INVALID', 'StatusDetail' => __('Transaction failed - ', 'patsatech-woo-sagepay-server') . $_POST['StatusDetail'] );$redirect_url = $order->get_cancel_order_url();}}else{$params['StatusDetail'] =__('SagePay Server, No VendorTxCode posted.', 'patsatech-woo-sagepay-server');}$params['RedirectURL'] =$this->force_ssl( $redirect_url );if($this->iframe == 'yes'){$params['RedirectURL'] =add_query_arg( 'page', urlencode( $redirect_url ), $this->force_ssl( WP_PLUGIN_URL ."/" . plugin_basename( dirname(__FILE__) ) . '/includes/pages/redirect.php' ) );}else{$params['RedirectURL'] =$this->force_ssl( $redirect_url );}$param_string = "";foreach( $params as $key => $value ) {$param_string .= $key . "=" . $value. $eoln;}ob_clean();echo $param_string;exit();}private function cart_has_virtual_product() {global $woocommerce;$has_virtual_products = false;$virtual_products = 0;$products = $woocommerce->cart->get_cart();foreach( $products as $product ) {$product_id = $product['product_id'];$is_virtual = get_post_meta( $product_id, '_virtual', true );// Update $has_virtual_product if product is virtualif( $is_virtual == 'yes' )$virtual_products += 1;}if( count($products) == $virtual_products ){$has_virtual_products = true;}return $has_virtual_products;}private function force_ssl($url){if ( 'yes' == get_option( 'woocommerce_force_ssl_checkout' ) ) {$url = str_replace( 'http:', 'https:', $url );}return $url;}}function add_sagepayserver_gateway( $methods ){$methods[] = 'woocommerce_sagepayserver';return $methods;}add_filter('woocommerce_payment_gateways', 'add_sagepayserver_gateway' );}