Plugin Directory

Changeset 3328029


Ignore:
Timestamp:
07/15/2025 08:37:46 AM (9 months ago)
Author:
thegeneration
Message:

Tagging version 4.0.3

Location:
svea-webpay-for-woocommerce
Files:
12 edited
25 copied

Legend:

Unmodified
Added
Removed
  • svea-webpay-for-woocommerce/tags/4.0.3/assets/js/frontend.min.js

    r3319942 r3328029  
    1 "use strict";jQuery(document).ready(function(i){var n=[],r=!1,a=!1,o=!1,d="sveawebpay_invoice",l="sveawebpay_invoice_b2b",c="sveawebpay_part_pay",g=i('[name="payment_method"]:checked').val()||!1,m=i('[name="billing_country"]').val()||!1,_=(void 0!==Svea.sameShippingAsBilling[g]&&Svea.sameShippingAsBilling[g]&&i(".woocommerce form.woocommerce-checkout").addClass("hide-shipping-fields"),0!=Svea.onlyOneAllowedCountry&&(m=Svea.onlyOneAllowedCountry),Svea.isPayPage&&(m=Svea.customerCountry,i(".payment_methods, .svea-get-address-button-container").addClass("is-pay-page")),i(".payment_methods, .svea-get-address-button-container").addClass("payment-method-"+g).addClass("country-"+(m?m.toLowerCase():"false")),!1);function v(e){if(e.length<=0)return"";for(var s="",t=0;t<e.length;++t){var a=e[t];s+='<option value="'+a.addressSelector+'">',"business"==a.customerType.toLowerCase()?s+=a.fullName+", ":"person"==a.customerType.toLowerCase()&&(s+=a.lastName+", "+a.firstName+" "),s+=a.street+" "+a.zipCode+" "+a.locality+"</option>"}return s}function u(e){0<String(e.firstName).length&&i("#billing_first_name").val(String(e.firstName)).change().trigger("keydown"),0<String(e.lastName).length&&i("#billing_last_name").val(String(e.lastName)).change().trigger("keydown"),"business"==String(e.customerType).toLowerCase()&&i("#billing_company").val(String(e.fullName)).change().trigger("keydown"),0<String(e.street).length&&i("#billing_address_1").val(String(e.street)).change().trigger("keydown"),0<String(e.coAddress).length&&i("#billing_address_2").val(String(e.coAddress)).change().trigger("keydown"),0<String(e.zipCode).length&&i("#billing_postcode").val(String(e.zipCode)).change().trigger("keydown"),0<String(e.locality).length&&i("#billing_city").val(String(e.locality)).change().trigger("keydown"),0<String(e.phoneNumber).length&&i("#billing_phone").val(String(e.phoneNumber)).change().trigger("keydown"),a=!0}function b(e){e?(i("#billing_address_1, #billing_address_2, #billing_postcode, \t\t\t\t#billing_city").prop("readonly",!1),i("#billing_address_1, #billing_address_2, #billing_postcode, \t\t\t\t#billing_city").removeClass("disabled-input")):(i("#billing_address_1, #billing_address_2, \t\t\t\t#billing_postcode, #billing_city").prop("readonly",!0),i("#billing_address_1, #billing_address_2, \t\t\t\t#billing_postcode, #billing_city").addClass("disabled-input"))}function p(e,s,t){switch(e){case"SE":case"DK":switch(s){case d:if("individual"===t)return;break;case c:return}}return 1}function b(e){e?(i("#billing_first_name, #billing_last_name, #billing_address_1, \t\t\t\t#billing_address_2, #billing_postcode, #billing_city").prop("readonly",!1),i("#billing_first_name, #billing_last_name, #billing_address_1, \t\t\t\t#billing_address_2, #billing_postcode, #billing_city").removeClass("disabled-input")):(i("#billing_first_name, #billing_last_name, #billing_address_1, \t\t\t\t#billing_address_2, #billing_postcode, #billing_city").prop("readonly",!0),i("#billing_first_name, #billing_last_name, #billing_address_1, \t\t\t\t#billing_address_2, #billing_postcode, #billing_city").addClass("disabled-input"))}function h(){i("#billing_first_name, #billing_last_name, #billing_address_1, \t\t\t\t#billing_address_2, #billing_postcode, #billing_city").val([])}0<i(".svea-get-address-button-container.get-address-shortcode").length&&(i(".payment_method_"+d).is(":visible")||i(".payment_method_"+l).is(":visible")?i(".svea-get-address-button-container.get-address-shortcode").removeClass("invoice-not-available"):i(".svea-get-address-button-container.get-address-shortcode").addClass("invoice-not-available")),i(".svea-get-address-button-container.get-address-shortcode").is(":visible")&&(_=i("[name='svea_get_address_customer_type']:checked").val(),i('[name="iv_billing_customer_type"]').val(_),i(".payment_methods, .svea-get-address-button-container").addClass("customer-type-"+_)),p(m,g,_)?p(m,g,_)&&b(!0):(b(!1),a||h()),i(document).on("change",".woocommerce form.woocommerce-checkout .woocommerce-billing-fields :input",function(e){a=!1}),i(document).on("keydown",'[name="svea_billing_ssn"], [name="svea_billing_org_number"], [name="iv_billing_org_number"], [name="iv_billing_ssn"], [name="pp_billing_ssn"]',function(e){var s=i(e.target);13==(e.which||e.keyCode||0)&&(e.preventDefault(),(e=($container=s.closest(".svea-fields, .svea-get-address-button-container")).find(".svea-get-address-button")).is(":visible"))&&e.click()}),i(document).on("change",'[name="svea_billing_ssn"]',function(e){i("[name='iv_billing_ssn'], [name='pp_billing_ssn']").val(i(this).val())}),i(document).on("change",'[name="svea_billing_org_number"]',function(e){i("[name='iv_billing_org_number'], [name='pp_billing_org_number']").val(i(this).val())}),i(document).on("click",".svea-get-address-button",function(e){e.preventDefault();var s,e=g,t=(i(this),i(this).closest(".svea-get-address-button-container")),a=i(".svea-get-address-button-container.get-address-shortcode").is(":visible");i(".svea-invoice-fields, .svea-part-pay-fields");o||(a&&(e=d),"individual"==_||e==c?(s=i(a?"[name='svea_billing_ssn']":"[name='"+(e==d?"iv":"pp")+"_billing_ssn']").val(),t.addClass("getting-address"),o=!0,i.post(Svea.ajaxUrl,{action:"svea_get_address",pers_nr:s,country_code:m,payment_type:e,security:Svea.gaSecurity},function(e){t.removeClass("getting-address"),o=!1,void 0===e.resultcode||void 0===e.customerIdentity?(t.append('<div class="svea-message error">'+Phrases.could_not_get_address+"</div>"),t.addClass("getting-address-error"),setTimeout(function(){t.find(".svea-message.error").remove(),t.removeClass("getting-address-error")},5e3)):"Error"==e.resultcode||"NoSuchEntity"==e.resultcode?(t.append('<div class="svea-message error">'+e.errormessage+"</div>"),t.addClass("getting-address-error"),setTimeout(function(){t.find(".svea-message.error").remove(),t.removeClass("getting-address-error")},5e3)):(u(e.customerIdentity[0]),t.append('<div class="svea-message success">'+Phrases.your_address_was_found+"</div>"),t.addClass("getting-address-success"),setTimeout(function(){t.find(".svea-message.success").remove(),t.removeClass("getting-address-success")},5e3))})):"company"==_&&(s=i(a?"[name='svea_billing_org_number']":"[name='"+(e==d||e==l?"iv":"pp")+"_billing_org_number_"+e+"']").val(),t.addClass("getting-address"),o=!0,i.post(Svea.ajaxUrl,{action:"svea_get_address",org_nr:s,country_code:m,payment_type:e,security:Svea.gaSecurity},function(e){t.removeClass("getting-address"),o=!1,void 0===e.resultcode||void 0===e.customerIdentity?(t.append('<div class="svea-message error">'+Phrases.could_not_get_address+"</div>"),t.addClass("getting-address-error"),setTimeout(function(){t.find(".svea-message.error").remove(),t.removeClass("getting-address-error")},5e3)):"Error"==e.resultcode||"NoSuchEntity"==e.resultcode?(t.append('<div class="svea-message error">'+e.errormessage+"</div>"),t.addClass("getting-address-error"),setTimeout(function(){t.find(".svea-message.error").remove(),t.removeClass("getting-address-error")},5e3)):(e=e.customerIdentity,i(".org-address-selector").html(v(e)),n=e,i(".address-selector").val(e[0].addressSelector),u(e[0]),r=e[0],t.addClass("getting-address-success"),t.append('<div class="svea-message success">'+Phrases.your_address_was_found+"</div>"),setTimeout(function(){t.find(".svea-message.success").remove(),t.removeClass("getting-address-success")},5e3))})))}),Svea.isPayPage&&i('.payment_methods [name="payment_method"]').on("change",function(){var e=g||!1;g=i('[name="payment_method"]:checked').val(),_=i('[name="iv_billing_customer_type"]').val()||!1,i(".payment_methods, .svea-get-address-button-container").removeClass("payment-method-"+e).addClass("payment-method-"+g).removeClass("customer-type-"+_).addClass("customer-type-"+_),r=!1,n=[],i(".org-address-selector").html("")}),i(document).on("updated_checkout",function(){0<i(".svea-get-address-button-container.get-address-shortcode").length&&(i(".payment_method_"+d).is(":visible")?i(".svea-get-address-button-container.get-address-shortcode").removeClass("invoice-not-available"):i(".svea-get-address-button-container.get-address-shortcode").addClass("invoice-not-available")),i(".svea-get-address-button-container.get-address-shortcode").is(":visible")&&(i("[name='iv_billing_ssn'], [name='pp_billing_ssn']").val(i("[name='svea_billing_ssn']").val()),i("[name='iv_billing_org_number']").val(i("[name='svea_billing_org_number']").val()),i('[name="iv_billing_customer_type"]').val(i('[name="svea_get_address_customer_type"]:checked').val()));var e=m||!1,s=g||!1,t=_||!1;0==Svea.onlyOneAllowedCountry&&(m=i('[name="billing_country"]').val()),g=i('[name="payment_method"]:checked').val(),_=i('[name="iv_billing_customer_type"]').val()||"individual",i(".payment_methods, .svea-get-address-button-container").removeClass("country-"+(e?e.toLowerCase():"false")).addClass("country-"+(m?m.toLowerCase():"false")).removeClass("payment-method-"+s).addClass("payment-method-"+g),i(".svea-get-address-button-container.get-address-shortcode").is(":visible")&&(_=i('[name="iv_billing_customer_type"]').val()||"individual"),i(".payment_methods, .svea-get-address-button-container").removeClass("customer-type-"+t).addClass("customer-type-"+_),!1!==r&&0<n.length&&(i(".org-address-selector").html(v(n)),i(".org-address-selector").val(r.addressSelector),i(".address-selector").val(r.addressSelector)),void 0!==Svea.sameShippingAsBilling[g]&&Svea.sameShippingAsBilling[g]?i(".woocommerce .woocommerce-checkout").hasClass("hide-shipping-fields")||i(".woocommerce .woocommerce-checkout").addClass("hide-shipping-fields"):i(".woocommerce .woocommerce-checkout").hasClass("hide-shipping-fields")&&i(".woocommerce .woocommerce-checkout").removeClass("hide-shipping-fields"),e===m&&g===s||(r=!1,n=[],i(".org-address-selector").html(""),p(m,g,_)?p(m,g,_)&&b(!0):(b(!1),a||h()))}),i(document).on("change",'[name="payment_method"]',function(){i("body").trigger("update_checkout")}),i(document).on("change",'[name="billing_country"]',function(){var e=m||!1;m=i('[name="billing_country"]').val(),i(".payment_methods, .svea-get-address-button-container").removeClass("country-"+(e?e.toLowerCase():"false")).addClass("country-"+(m?m.toLowerCase():"false")),p(m,g,_)?p(m,g,_)&&b(!0):(b(!1),a||h())});var s=null;i(document).on("change",'.invoice-customer-type select, [name="svea_get_address_customer_type"]',function(){var e;o?null!=s&&i(this).val(s.val()):(e=_||!1,_=i(this).val()||!1,i(".payment_methods, .svea-get-address-button-container").removeClass("customer-type-"+e).addClass("customer-type-"+_),s=i(this),p(m,g,_)?p(m,g,_)&&b(!0):(b(!1),a||h()))}),i(document).on("change",'[name="svea_get_address_customer_type"]',function(){i("[name='iv_billing_customer_type']").val(i(this).val()),s=i(this),i("body").trigger("update_checkout")}),i(document).on("change",".org-address-selector",function(){for(var e=0;e<n.length;++e){var s=n[e];if(s.addressSelector==i(".org-address-selector").val())return i(".address-selector").val(i(".org-address-selector").val()),u(s),void(r=s)}}),i(document).on("change",".birth-date-month, .birth-date-day, .birth-date-year",function(){var e=i(this).parents(".svea-part-pay-fields, .svea-invoice-fields"),s=parseInt(e.find(".birth-date-year").val()),t=parseInt(e.find(".birth-date-month").val()),a=parseInt(e.find(".birth-date-day").val()),n=new Date(s,t,0).getDate();e.find(".birth-date-day option").each(function(){parseInt(i(this).val())>n?i(this).prop("disabled",!0):i(this).prop("disabled",!1)}),n<a&&e.find(".birth-date-day").val(n)})});
     1"use strict";jQuery(document).ready(function(i){var n=[],r=!1,a=!1,o=!1,d="sveawebpay_invoice",l="sveawebpay_invoice_b2b",c="sveawebpay_part_pay",g=i('[name="payment_method"]:checked').val()||!1,m=i('[name="billing_country"]').val()||!1,_=(void 0!==Svea.sameShippingAsBilling[g]&&Svea.sameShippingAsBilling[g]&&i(".woocommerce form.woocommerce-checkout").addClass("hide-shipping-fields"),0!=Svea.onlyOneAllowedCountry&&(m=Svea.onlyOneAllowedCountry),Svea.isPayPage&&(m=Svea.customerCountry,i(".payment_methods, .svea-get-address-button-container").addClass("is-pay-page")),i(".payment_methods, .svea-get-address-button-container").addClass("payment-method-"+g).addClass("country-"+(m?m.toLowerCase():"false")),!1);function v(e){if(e.length<=0)return"";for(var s="",t=0;t<e.length;++t){var a=e[t];s+='<option value="'+a.addressSelector+'">',"business"==a.customerType.toLowerCase()?s+=a.fullName+", ":"person"==a.customerType.toLowerCase()&&(s+=a.lastName+", "+a.firstName+" "),s+=a.street+" "+a.zipCode+" "+a.locality+"</option>"}return s}function u(e){0<String(e.firstName).length&&i("#billing_first_name").val(String(e.firstName)).change().trigger("keydown"),0<String(e.lastName).length&&i("#billing_last_name").val(String(e.lastName)).change().trigger("keydown"),"business"==String(e.customerType).toLowerCase()&&i("#billing_company").val(String(e.fullName)).change().trigger("keydown"),0<String(e.street).length&&i("#billing_address_1").val(String(e.street)).change().trigger("keydown"),0<String(e.coAddress).length&&i("#billing_address_2").val(String(e.coAddress)).change().trigger("keydown"),0<String(e.zipCode).length&&i("#billing_postcode").val(String(e.zipCode)).change().trigger("keydown"),0<String(e.locality).length&&i("#billing_city").val(String(e.locality)).change().trigger("keydown"),0<String(e.phoneNumber).length&&i("#billing_phone").val(String(e.phoneNumber)).change().trigger("keydown"),a=!0}function b(e){e?(i("#billing_address_1, #billing_address_2, #billing_postcode, \t\t\t\t#billing_city").prop("readonly",!1),i("#billing_address_1, #billing_address_2, #billing_postcode, \t\t\t\t#billing_city").removeClass("disabled-input")):(i("#billing_address_1, #billing_address_2, \t\t\t\t#billing_postcode, #billing_city").prop("readonly",!0),i("#billing_address_1, #billing_address_2, \t\t\t\t#billing_postcode, #billing_city").addClass("disabled-input"))}function p(e,s,t){switch(e){case"SE":case"DK":switch(s){case d:if("individual"===t)return;break;case c:return}}return 1}function b(e){e?(i("#billing_first_name, #billing_last_name, #billing_address_1, \t\t\t\t#billing_address_2, #billing_postcode, #billing_city").prop("readonly",!1),i("#billing_first_name, #billing_last_name, #billing_address_1, \t\t\t\t#billing_address_2, #billing_postcode, #billing_city").removeClass("disabled-input")):(i("#billing_first_name, #billing_last_name, #billing_address_1, \t\t\t\t#billing_address_2, #billing_postcode, #billing_city").prop("readonly",!0),i("#billing_first_name, #billing_last_name, #billing_address_1, \t\t\t\t#billing_address_2, #billing_postcode, #billing_city").addClass("disabled-input"))}function h(){i("#billing_first_name, #billing_last_name, #billing_address_1, \t\t\t\t#billing_address_2, #billing_postcode, #billing_city").val([])}0<i(".svea-get-address-button-container.get-address-shortcode").length&&(i(".payment_method_"+d).is(":visible")||i(".payment_method_"+l).is(":visible")?i(".svea-get-address-button-container.get-address-shortcode").removeClass("invoice-not-available"):i(".svea-get-address-button-container.get-address-shortcode").addClass("invoice-not-available")),i(".svea-get-address-button-container.get-address-shortcode").is(":visible")&&(_=i("[name='svea_get_address_customer_type']:checked").val(),i('[name="iv_billing_customer_type"]').val(_),i(".payment_methods, .svea-get-address-button-container").addClass("customer-type-"+_)),p(m,g,_)?p(m,g,_)&&b(!0):(b(!1),a||h()),i(document).on("change",".woocommerce form.woocommerce-checkout .woocommerce-billing-fields :input",function(e){a=!1}),i(document).on("keydown",'[name="svea_billing_ssn"], [name="svea_billing_org_number"], [name="iv_billing_org_number"], [name="iv_billing_ssn"], [name="pp_billing_ssn"]',function(e){var s=i(e.target);13==(e.which||e.keyCode||0)&&(e.preventDefault(),(e=($container=s.closest(".svea-fields, .svea-get-address-button-container")).find(".svea-get-address-button")).is(":visible"))&&e.click()}),i(document).on("change",'[name="svea_billing_ssn"]',function(e){i("[name='iv_billing_ssn'], [name='pp_billing_ssn']").val(i(this).val())}),i(document).on("change",'[name="svea_billing_org_number"]',function(e){i("[name='iv_billing_org_number'], [name='pp_billing_org_number']").val(i(this).val())}),i(document).on("click",".svea-get-address-button",function(e){e.preventDefault();var s,e=g,t=(i(this),i(this).closest(".svea-get-address-button-container")),a=i(".svea-get-address-button-container.get-address-shortcode").is(":visible");i(".svea-invoice-fields, .svea-part-pay-fields");o||(a&&(e=d),"individual"==_||e==c?(s=i(a?"[name='svea_billing_ssn']":"[name='"+(e==d?"iv":"pp")+"_billing_ssn']").val(),t.addClass("getting-address"),o=!0,i.post(Svea.ajaxUrl,{action:"svea_get_address",pers_nr:s,country_code:m,payment_type:e,security:Svea.gaSecurity},function(e){t.removeClass("getting-address"),o=!1,void 0===e.resultcode||void 0===e.customerIdentity?(t.append('<div class="svea-message error">'+Phrases.could_not_get_address+"</div>"),t.addClass("getting-address-error"),setTimeout(function(){t.find(".svea-message.error").remove(),t.removeClass("getting-address-error")},5e3)):"Error"==e.resultcode||"NoSuchEntity"==e.resultcode?(t.append('<div class="svea-message error">'+e.errormessage+"</div>"),t.addClass("getting-address-error"),setTimeout(function(){t.find(".svea-message.error").remove(),t.removeClass("getting-address-error")},5e3)):(u(e.customerIdentity[0]),t.append('<div class="svea-message success">'+Phrases.your_address_was_found+"</div>"),t.addClass("getting-address-success"),setTimeout(function(){t.find(".svea-message.success").remove(),t.removeClass("getting-address-success")},5e3))})):"company"==_&&(s=i(a?"[name='svea_billing_org_number']":"[name='"+(e==d||e==l?"iv":"pp")+"_billing_org_number']").val(),t.addClass("getting-address"),o=!0,i.post(Svea.ajaxUrl,{action:"svea_get_address",org_nr:s,country_code:m,payment_type:e,security:Svea.gaSecurity},function(e){t.removeClass("getting-address"),o=!1,void 0===e.resultcode||void 0===e.customerIdentity?(t.append('<div class="svea-message error">'+Phrases.could_not_get_address+"</div>"),t.addClass("getting-address-error"),setTimeout(function(){t.find(".svea-message.error").remove(),t.removeClass("getting-address-error")},5e3)):"Error"==e.resultcode||"NoSuchEntity"==e.resultcode?(t.append('<div class="svea-message error">'+e.errormessage+"</div>"),t.addClass("getting-address-error"),setTimeout(function(){t.find(".svea-message.error").remove(),t.removeClass("getting-address-error")},5e3)):(e=e.customerIdentity,i(".org-address-selector").html(v(e)),n=e,i(".address-selector").val(e[0].addressSelector),u(e[0]),r=e[0],t.addClass("getting-address-success"),t.append('<div class="svea-message success">'+Phrases.your_address_was_found+"</div>"),setTimeout(function(){t.find(".svea-message.success").remove(),t.removeClass("getting-address-success")},5e3))})))}),Svea.isPayPage&&i('.payment_methods [name="payment_method"]').on("change",function(){var e=g||!1;g=i('[name="payment_method"]:checked').val(),_=i('[name="iv_billing_customer_type"]').val()||!1,i(".payment_methods, .svea-get-address-button-container").removeClass("payment-method-"+e).addClass("payment-method-"+g).removeClass("customer-type-"+_).addClass("customer-type-"+_),r=!1,n=[],i(".org-address-selector").html("")}),i(document).on("updated_checkout",function(){0<i(".svea-get-address-button-container.get-address-shortcode").length&&(i(".payment_method_"+d).is(":visible")?i(".svea-get-address-button-container.get-address-shortcode").removeClass("invoice-not-available"):i(".svea-get-address-button-container.get-address-shortcode").addClass("invoice-not-available")),i(".svea-get-address-button-container.get-address-shortcode").is(":visible")&&(i("[name='iv_billing_ssn'], [name='pp_billing_ssn']").val(i("[name='svea_billing_ssn']").val()),i("[name='iv_billing_org_number']").val(i("[name='svea_billing_org_number']").val()),i('[name="iv_billing_customer_type"]').val(i('[name="svea_get_address_customer_type"]:checked').val()));var e=m||!1,s=g||!1,t=_||!1;0==Svea.onlyOneAllowedCountry&&(m=i('[name="billing_country"]').val()),g=i('[name="payment_method"]:checked').val(),_=i('[name="iv_billing_customer_type"]').val()||"individual",i(".payment_methods, .svea-get-address-button-container").removeClass("country-"+(e?e.toLowerCase():"false")).addClass("country-"+(m?m.toLowerCase():"false")).removeClass("payment-method-"+s).addClass("payment-method-"+g),i(".svea-get-address-button-container.get-address-shortcode").is(":visible")&&(_=i('[name="iv_billing_customer_type"]').val()||"individual"),i(".payment_methods, .svea-get-address-button-container").removeClass("customer-type-"+t).addClass("customer-type-"+_),!1!==r&&0<n.length&&(i(".org-address-selector").html(v(n)),i(".org-address-selector").val(r.addressSelector),i(".address-selector").val(r.addressSelector)),void 0!==Svea.sameShippingAsBilling[g]&&Svea.sameShippingAsBilling[g]?i(".woocommerce .woocommerce-checkout").hasClass("hide-shipping-fields")||i(".woocommerce .woocommerce-checkout").addClass("hide-shipping-fields"):i(".woocommerce .woocommerce-checkout").hasClass("hide-shipping-fields")&&i(".woocommerce .woocommerce-checkout").removeClass("hide-shipping-fields"),e===m&&g===s||(r=!1,n=[],i(".org-address-selector").html(""),p(m,g,_)?p(m,g,_)&&b(!0):(b(!1),a||h()))}),i(document).on("change",'[name="payment_method"]',function(){i("body").trigger("update_checkout")}),i(document).on("change",'[name="billing_country"]',function(){var e=m||!1;m=i('[name="billing_country"]').val(),i(".payment_methods, .svea-get-address-button-container").removeClass("country-"+(e?e.toLowerCase():"false")).addClass("country-"+(m?m.toLowerCase():"false")),p(m,g,_)?p(m,g,_)&&b(!0):(b(!1),a||h())});var s=null;i(document).on("change",'.invoice-customer-type select, [name="svea_get_address_customer_type"]',function(){var e;o?null!=s&&i(this).val(s.val()):(e=_||!1,_=i(this).val()||!1,i(".payment_methods, .svea-get-address-button-container").removeClass("customer-type-"+e).addClass("customer-type-"+_),s=i(this),p(m,g,_)?p(m,g,_)&&b(!0):(b(!1),a||h()))}),i(document).on("change",'[name="svea_get_address_customer_type"]',function(){i("[name='iv_billing_customer_type']").val(i(this).val()),s=i(this),i("body").trigger("update_checkout")}),i(document).on("change",".org-address-selector",function(){for(var e=0;e<n.length;++e){var s=n[e];if(s.addressSelector==i(".org-address-selector").val())return i(".address-selector").val(i(".org-address-selector").val()),u(s),void(r=s)}}),i(document).on("change",".birth-date-month, .birth-date-day, .birth-date-year",function(){var e=i(this).parents(".svea-part-pay-fields, .svea-invoice-fields"),s=parseInt(e.find(".birth-date-year").val()),t=parseInt(e.find(".birth-date-month").val()),a=parseInt(e.find(".birth-date-day").val()),n=new Date(s,t,0).getDate();e.find(".birth-date-day option").each(function(){parseInt(i(this).val())>n?i(this).prop("disabled",!0):i(this).prop("disabled",!1)}),n<a&&e.find(".birth-date-day").val(n)})});
  • svea-webpay-for-woocommerce/tags/4.0.3/inc/Gateways/WC_Gateway_Svea_Invoice.php

    r3319942 r3328029  
    143143        add_action( 'woocommerce_api_wc_gateway_svea_invoice_strong_auth_rejected', [ $this, 'handle_callback_request_rejected' ] );
    144144
     145        self::$log_enabled = $this->get_option( 'debug' ) === 'yes';
     146
    145147        $this->same_shipping_as_billing = $this->get_option( 'same_shipping_as_billing' ) === 'yes';
    146148
     
    167169        $this->invoice_fee_taxable = $this->get_option( 'invoice_fee_taxable_' . $customer_country ) === 'yes';
    168170
    169         self::$log_enabled = $this->get_option( 'debug' ) === 'yes';
    170171        $this->description = __( $this->get_option( 'description' ), 'svea-webpay-for-woocommerce' ); // phpcs:ignore
    171172    }
     
    12011202        $strong_auth = $this->uses_strong_auth( $customer_country, $customer_type );
    12021203
     1204        $this->testmode = $this->get_option( 'testmode_' . strtolower( $customer_country ) ) === 'yes';
     1205
    12031206        $config = $this->get_config( $customer_country, $customer_type );
    12041207
     
    14991502
    15001503        $post_data = [
    1501             'iv_billing_customer_type' => $subscription->get_meta( '_svea_customer_type' ),
    1502             'iv_billing_org_number'    => $subscription->get_meta( '_svea_iv_billing_org_number' ),
    1503             'iv_billing_ssn'           => $subscription->get_meta( '_svea_iv_billing_ssn' ),
    1504             'iv_billing_vat_number'    => $subscription->get_meta( '_svea_iv_billing_vat_number' ),
    1505             'iv_birth_date_year'       => $subscription->get_meta( '_svea_iv_birth_date_year' ),
    1506             'iv_birth_date_month'      => $subscription->get_meta( '_svea_iv_birth_date_month' ),
    1507             'iv_birth_date_day'        => $subscription->get_meta( '_svea_iv_birth_date_day' ),
    1508             'iv_billing_initials'      => $subscription->get_meta( '_svea_iv_billing_initials' ),
     1504            'iv_billing_customer_type'    => $subscription->get_meta( '_svea_customer_type' ) ?: $subscription->get_meta( '_svea_iv_billing_customer_type' ),
     1505            'iv_billing_address_selector' => $subscription->get_meta( '_svea_address_selector' ),
     1506            'iv_billing_org_number'       => $subscription->get_meta( '_svea_iv_billing_org_number' ),
     1507            'iv_billing_ssn'              => $subscription->get_meta( '_svea_iv_billing_ssn' ),
     1508            'iv_billing_vat_number'       => $subscription->get_meta( '_svea_iv_billing_vat_number' ),
     1509            'iv_birth_date_year'          => $subscription->get_meta( '_svea_iv_birth_date_year' ),
     1510            'iv_birth_date_month'         => $subscription->get_meta( '_svea_iv_birth_date_month' ),
     1511            'iv_birth_date_day'           => $subscription->get_meta( '_svea_iv_birth_date_day' ),
     1512            'iv_billing_initials'         => $subscription->get_meta( '_svea_iv_billing_initials' ),
    15091513        ];
    15101514
     
    16771681        $customer_company = $wc_order->get_billing_company();
    16781682
    1679         $customer_type = $subscription->get_meta( '_svea_customer_type' );
     1683        $customer_type = $subscription->get_meta( '_svea_customer_type' ) ?: $subscription->get_meta( '_svea_iv_billing_customer_type' );
    16801684
    16811685        $invoice_fee_label = $this->get_option( 'invoice_fee_label_' . strtolower( $customer_country ) );
     
    17371741        }
    17381742
     1743        $this->testmode = $this->get_option( 'testmode_' . strtolower( $customer_country ) ) === 'yes';
     1744
    17391745        $config = $this->get_config( $customer_country, $customer_type );
    17401746
     
    17561762         */
    17571763        $svea_data = [
    1758             'customer_type'    => $subscription->get_meta( '_svea_customer_type' ),
     1764            'customer_type'    => $subscription->get_meta( '_svea_customer_type' ) ?: $subscription->get_meta( '_svea_iv_billing_customer_type' ),
    17591765            'address_selector' => $subscription->get_meta( '_svea_address_selector' ),
    17601766            'org_number'       => $subscription->get_meta( '_svea_iv_billing_org_number' ),
     
    18871893     */
    18881894    public function cancel_order( $order, $svea_order_id ) {
    1889         $customer_type = $order->get_meta( '_svea_customer_type' );
     1895        $customer_type = $order->get_meta( '_svea_customer_type' ) ?: $order->get_meta( '_svea_iv_billing_customer_type' );
    18901896        $config = $this->get_config( $order->get_billing_country(), $customer_type );
    18911897
     
    19261932     */
    19271933    public function credit_order( $order, $svea_order_id ) {
    1928         $customer_type = $order->get_meta( '_svea_customer_type' );
     1934        $customer_type = $order->get_meta( '_svea_customer_type' ) ?: $order->get_meta( '_svea_iv_billing_customer_type' );
    19291935        $config = $this->get_config( $order->get_billing_country(), $customer_type );
    19301936
     
    21402146     */
    21412147    public function deliver_order( $order, $svea_order_id ) {
    2142         $customer_type = $order->get_meta( '_svea_customer_type' );
     2148        $customer_type = $order->get_meta( '_svea_customer_type' ) ?: $order->get_meta( '_svea_iv_billing_customer_type' );
    21432149        $config = $this->get_config( $order->get_billing_country(), $customer_type );
    21442150        $is_b2b = $customer_type === 'company';
  • svea-webpay-for-woocommerce/tags/4.0.3/inc/Gateways/WC_Gateway_Svea_Part_Pay.php

    r3319942 r3328029  
    116116        add_action( 'woocommerce_api_wc_gateway_svea_part_pay_strong_auth_rejected', [ $this, 'handle_callback_request_rejected' ] );
    117117
     118        self::$log_enabled = $this->get_option( 'debug' ) === 'yes';
     119
    118120        if ( ! isset( WC()->customer ) ) {
    119121            return;
     
    141143        $this->display_product_widget = $this->get_option( 'display_product_widget' ) === 'yes';
    142144
    143         self::$log_enabled = $this->get_option( 'debug' ) === 'yes';
    144145        $this->description = __( $this->get_option( 'description' ), 'svea-webpay-for-woocommerce' ); // phpcs:ignore
    145146    }
  • svea-webpay-for-woocommerce/tags/4.0.3/inc/Order_Functions.php

    r3319942 r3328029  
    3232
    3333        add_action( 'woocommerce_after_checkout_validation', [ $this, 'checkout_validation_handler' ], 10, 2 );
     34
     35        if ( ! is_admin() ) {
     36            add_filter( 'pre_option_woocommerce_ship_to_destination', [ $this, 'maybe_force_ship_to_billing_address' ], 10, 2 );
     37        }
    3438
    3539        add_filter( 'woocommerce_get_order_item_totals', [ $this, 'receipt_display_svea_order_id' ], 10, 2 );
     
    9195
    9296    /**
     97     * Maybe force the ship to billing address
     98     *
     99     * @param mixed $value
     100     * @return mixed
     101     */
     102    public function maybe_force_ship_to_billing_address( $value ) {
     103        // Get current gateway
     104        $current_gateway = Helper::get_current_gateway();
     105
     106        if ( $current_gateway && method_exists( $current_gateway, 'can_ship_to_different_address' )
     107            && ! $current_gateway->can_ship_to_different_address() ) {
     108            // If the gateway does not allow shipping to a different address, force the value to 'billing_only'
     109            $value = 'billing_only';
     110        }
     111
     112        return $value;
     113    }
     114
     115    /**
    93116     * Display the svea order id whilst viewing the receipt
    94117     *
  • svea-webpay-for-woocommerce/tags/4.0.3/partials/invoice/admin-subscription.php

    r2365521 r3328029  
    5555            <select class="org-address-selector"></select>
    5656        </p>
    57         <input type="hidden" name="_address_selector" class="address-selector" />
     57        <input type="hidden" name="_address_selector"
     58            value="<?php echo isset( $post_data['iv_billing_address_selector'] ) ? esc_attr( $post_data['iv_billing_address_selector'] ) : ''; ?>" class="address-selector" />
    5859    </div>
    5960    <div class="vat-number-container">
  • svea-webpay-for-woocommerce/tags/4.0.3/readme.txt

    r3327589 r3328029  
    1010License: Apache 2.0
    1111License URI: https://www.apache.org/licenses/LICENSE-2.0
    12 Stable tag: 4.0.2
     12Stable tag: 4.0.3
    1313
    1414The Svea Stand Alone payment module is a complete solution for shops using WordPress / WooCommerce as an e-commerce platform.
     
    3939== Upgrade Notice ==
    4040
     41= 4.0.3 =
     424.0.3 is a patch release.
     43
    4144= 4.0.2 =
    42454.0.2 is a patch release.
     
    5760
    5861== Changelog ==
     62
     63= 4.0.3 2025-07-15 =
     64* Add backwards compatibility for subscription payments.
     65* Fix problems with organisational number not being fetched.
     66* Force billing address with new method.
    5967
    6068= 4.0.2 2025-07-09 =
  • svea-webpay-for-woocommerce/tags/4.0.3/svea-webpay-for-woocommerce.php

    r3327589 r3328029  
    44 * Plugin Name: Svea Stand Alone for WooCommerce
    55 * Description: Supercharge your WooCommerce Store with powerful features to pay via Svea Credit card, Invoice, Part Payment, Trustly, Swish, MobilePay and Vipps.
    6  * Version: 4.0.2
     6 * Version: 4.0.3
    77 * Author: The Generation
    88 * Author URI: https://thegeneration.se/
     
    3737         * @var     string
    3838         */
    39         const VERSION = '4.0.2';
     39        const VERSION = '4.0.3';
    4040
    4141        /**
  • svea-webpay-for-woocommerce/trunk/assets/js/frontend.min.js

    r3319942 r3328029  
    1 "use strict";jQuery(document).ready(function(i){var n=[],r=!1,a=!1,o=!1,d="sveawebpay_invoice",l="sveawebpay_invoice_b2b",c="sveawebpay_part_pay",g=i('[name="payment_method"]:checked').val()||!1,m=i('[name="billing_country"]').val()||!1,_=(void 0!==Svea.sameShippingAsBilling[g]&&Svea.sameShippingAsBilling[g]&&i(".woocommerce form.woocommerce-checkout").addClass("hide-shipping-fields"),0!=Svea.onlyOneAllowedCountry&&(m=Svea.onlyOneAllowedCountry),Svea.isPayPage&&(m=Svea.customerCountry,i(".payment_methods, .svea-get-address-button-container").addClass("is-pay-page")),i(".payment_methods, .svea-get-address-button-container").addClass("payment-method-"+g).addClass("country-"+(m?m.toLowerCase():"false")),!1);function v(e){if(e.length<=0)return"";for(var s="",t=0;t<e.length;++t){var a=e[t];s+='<option value="'+a.addressSelector+'">',"business"==a.customerType.toLowerCase()?s+=a.fullName+", ":"person"==a.customerType.toLowerCase()&&(s+=a.lastName+", "+a.firstName+" "),s+=a.street+" "+a.zipCode+" "+a.locality+"</option>"}return s}function u(e){0<String(e.firstName).length&&i("#billing_first_name").val(String(e.firstName)).change().trigger("keydown"),0<String(e.lastName).length&&i("#billing_last_name").val(String(e.lastName)).change().trigger("keydown"),"business"==String(e.customerType).toLowerCase()&&i("#billing_company").val(String(e.fullName)).change().trigger("keydown"),0<String(e.street).length&&i("#billing_address_1").val(String(e.street)).change().trigger("keydown"),0<String(e.coAddress).length&&i("#billing_address_2").val(String(e.coAddress)).change().trigger("keydown"),0<String(e.zipCode).length&&i("#billing_postcode").val(String(e.zipCode)).change().trigger("keydown"),0<String(e.locality).length&&i("#billing_city").val(String(e.locality)).change().trigger("keydown"),0<String(e.phoneNumber).length&&i("#billing_phone").val(String(e.phoneNumber)).change().trigger("keydown"),a=!0}function b(e){e?(i("#billing_address_1, #billing_address_2, #billing_postcode, \t\t\t\t#billing_city").prop("readonly",!1),i("#billing_address_1, #billing_address_2, #billing_postcode, \t\t\t\t#billing_city").removeClass("disabled-input")):(i("#billing_address_1, #billing_address_2, \t\t\t\t#billing_postcode, #billing_city").prop("readonly",!0),i("#billing_address_1, #billing_address_2, \t\t\t\t#billing_postcode, #billing_city").addClass("disabled-input"))}function p(e,s,t){switch(e){case"SE":case"DK":switch(s){case d:if("individual"===t)return;break;case c:return}}return 1}function b(e){e?(i("#billing_first_name, #billing_last_name, #billing_address_1, \t\t\t\t#billing_address_2, #billing_postcode, #billing_city").prop("readonly",!1),i("#billing_first_name, #billing_last_name, #billing_address_1, \t\t\t\t#billing_address_2, #billing_postcode, #billing_city").removeClass("disabled-input")):(i("#billing_first_name, #billing_last_name, #billing_address_1, \t\t\t\t#billing_address_2, #billing_postcode, #billing_city").prop("readonly",!0),i("#billing_first_name, #billing_last_name, #billing_address_1, \t\t\t\t#billing_address_2, #billing_postcode, #billing_city").addClass("disabled-input"))}function h(){i("#billing_first_name, #billing_last_name, #billing_address_1, \t\t\t\t#billing_address_2, #billing_postcode, #billing_city").val([])}0<i(".svea-get-address-button-container.get-address-shortcode").length&&(i(".payment_method_"+d).is(":visible")||i(".payment_method_"+l).is(":visible")?i(".svea-get-address-button-container.get-address-shortcode").removeClass("invoice-not-available"):i(".svea-get-address-button-container.get-address-shortcode").addClass("invoice-not-available")),i(".svea-get-address-button-container.get-address-shortcode").is(":visible")&&(_=i("[name='svea_get_address_customer_type']:checked").val(),i('[name="iv_billing_customer_type"]').val(_),i(".payment_methods, .svea-get-address-button-container").addClass("customer-type-"+_)),p(m,g,_)?p(m,g,_)&&b(!0):(b(!1),a||h()),i(document).on("change",".woocommerce form.woocommerce-checkout .woocommerce-billing-fields :input",function(e){a=!1}),i(document).on("keydown",'[name="svea_billing_ssn"], [name="svea_billing_org_number"], [name="iv_billing_org_number"], [name="iv_billing_ssn"], [name="pp_billing_ssn"]',function(e){var s=i(e.target);13==(e.which||e.keyCode||0)&&(e.preventDefault(),(e=($container=s.closest(".svea-fields, .svea-get-address-button-container")).find(".svea-get-address-button")).is(":visible"))&&e.click()}),i(document).on("change",'[name="svea_billing_ssn"]',function(e){i("[name='iv_billing_ssn'], [name='pp_billing_ssn']").val(i(this).val())}),i(document).on("change",'[name="svea_billing_org_number"]',function(e){i("[name='iv_billing_org_number'], [name='pp_billing_org_number']").val(i(this).val())}),i(document).on("click",".svea-get-address-button",function(e){e.preventDefault();var s,e=g,t=(i(this),i(this).closest(".svea-get-address-button-container")),a=i(".svea-get-address-button-container.get-address-shortcode").is(":visible");i(".svea-invoice-fields, .svea-part-pay-fields");o||(a&&(e=d),"individual"==_||e==c?(s=i(a?"[name='svea_billing_ssn']":"[name='"+(e==d?"iv":"pp")+"_billing_ssn']").val(),t.addClass("getting-address"),o=!0,i.post(Svea.ajaxUrl,{action:"svea_get_address",pers_nr:s,country_code:m,payment_type:e,security:Svea.gaSecurity},function(e){t.removeClass("getting-address"),o=!1,void 0===e.resultcode||void 0===e.customerIdentity?(t.append('<div class="svea-message error">'+Phrases.could_not_get_address+"</div>"),t.addClass("getting-address-error"),setTimeout(function(){t.find(".svea-message.error").remove(),t.removeClass("getting-address-error")},5e3)):"Error"==e.resultcode||"NoSuchEntity"==e.resultcode?(t.append('<div class="svea-message error">'+e.errormessage+"</div>"),t.addClass("getting-address-error"),setTimeout(function(){t.find(".svea-message.error").remove(),t.removeClass("getting-address-error")},5e3)):(u(e.customerIdentity[0]),t.append('<div class="svea-message success">'+Phrases.your_address_was_found+"</div>"),t.addClass("getting-address-success"),setTimeout(function(){t.find(".svea-message.success").remove(),t.removeClass("getting-address-success")},5e3))})):"company"==_&&(s=i(a?"[name='svea_billing_org_number']":"[name='"+(e==d||e==l?"iv":"pp")+"_billing_org_number_"+e+"']").val(),t.addClass("getting-address"),o=!0,i.post(Svea.ajaxUrl,{action:"svea_get_address",org_nr:s,country_code:m,payment_type:e,security:Svea.gaSecurity},function(e){t.removeClass("getting-address"),o=!1,void 0===e.resultcode||void 0===e.customerIdentity?(t.append('<div class="svea-message error">'+Phrases.could_not_get_address+"</div>"),t.addClass("getting-address-error"),setTimeout(function(){t.find(".svea-message.error").remove(),t.removeClass("getting-address-error")},5e3)):"Error"==e.resultcode||"NoSuchEntity"==e.resultcode?(t.append('<div class="svea-message error">'+e.errormessage+"</div>"),t.addClass("getting-address-error"),setTimeout(function(){t.find(".svea-message.error").remove(),t.removeClass("getting-address-error")},5e3)):(e=e.customerIdentity,i(".org-address-selector").html(v(e)),n=e,i(".address-selector").val(e[0].addressSelector),u(e[0]),r=e[0],t.addClass("getting-address-success"),t.append('<div class="svea-message success">'+Phrases.your_address_was_found+"</div>"),setTimeout(function(){t.find(".svea-message.success").remove(),t.removeClass("getting-address-success")},5e3))})))}),Svea.isPayPage&&i('.payment_methods [name="payment_method"]').on("change",function(){var e=g||!1;g=i('[name="payment_method"]:checked').val(),_=i('[name="iv_billing_customer_type"]').val()||!1,i(".payment_methods, .svea-get-address-button-container").removeClass("payment-method-"+e).addClass("payment-method-"+g).removeClass("customer-type-"+_).addClass("customer-type-"+_),r=!1,n=[],i(".org-address-selector").html("")}),i(document).on("updated_checkout",function(){0<i(".svea-get-address-button-container.get-address-shortcode").length&&(i(".payment_method_"+d).is(":visible")?i(".svea-get-address-button-container.get-address-shortcode").removeClass("invoice-not-available"):i(".svea-get-address-button-container.get-address-shortcode").addClass("invoice-not-available")),i(".svea-get-address-button-container.get-address-shortcode").is(":visible")&&(i("[name='iv_billing_ssn'], [name='pp_billing_ssn']").val(i("[name='svea_billing_ssn']").val()),i("[name='iv_billing_org_number']").val(i("[name='svea_billing_org_number']").val()),i('[name="iv_billing_customer_type"]').val(i('[name="svea_get_address_customer_type"]:checked').val()));var e=m||!1,s=g||!1,t=_||!1;0==Svea.onlyOneAllowedCountry&&(m=i('[name="billing_country"]').val()),g=i('[name="payment_method"]:checked').val(),_=i('[name="iv_billing_customer_type"]').val()||"individual",i(".payment_methods, .svea-get-address-button-container").removeClass("country-"+(e?e.toLowerCase():"false")).addClass("country-"+(m?m.toLowerCase():"false")).removeClass("payment-method-"+s).addClass("payment-method-"+g),i(".svea-get-address-button-container.get-address-shortcode").is(":visible")&&(_=i('[name="iv_billing_customer_type"]').val()||"individual"),i(".payment_methods, .svea-get-address-button-container").removeClass("customer-type-"+t).addClass("customer-type-"+_),!1!==r&&0<n.length&&(i(".org-address-selector").html(v(n)),i(".org-address-selector").val(r.addressSelector),i(".address-selector").val(r.addressSelector)),void 0!==Svea.sameShippingAsBilling[g]&&Svea.sameShippingAsBilling[g]?i(".woocommerce .woocommerce-checkout").hasClass("hide-shipping-fields")||i(".woocommerce .woocommerce-checkout").addClass("hide-shipping-fields"):i(".woocommerce .woocommerce-checkout").hasClass("hide-shipping-fields")&&i(".woocommerce .woocommerce-checkout").removeClass("hide-shipping-fields"),e===m&&g===s||(r=!1,n=[],i(".org-address-selector").html(""),p(m,g,_)?p(m,g,_)&&b(!0):(b(!1),a||h()))}),i(document).on("change",'[name="payment_method"]',function(){i("body").trigger("update_checkout")}),i(document).on("change",'[name="billing_country"]',function(){var e=m||!1;m=i('[name="billing_country"]').val(),i(".payment_methods, .svea-get-address-button-container").removeClass("country-"+(e?e.toLowerCase():"false")).addClass("country-"+(m?m.toLowerCase():"false")),p(m,g,_)?p(m,g,_)&&b(!0):(b(!1),a||h())});var s=null;i(document).on("change",'.invoice-customer-type select, [name="svea_get_address_customer_type"]',function(){var e;o?null!=s&&i(this).val(s.val()):(e=_||!1,_=i(this).val()||!1,i(".payment_methods, .svea-get-address-button-container").removeClass("customer-type-"+e).addClass("customer-type-"+_),s=i(this),p(m,g,_)?p(m,g,_)&&b(!0):(b(!1),a||h()))}),i(document).on("change",'[name="svea_get_address_customer_type"]',function(){i("[name='iv_billing_customer_type']").val(i(this).val()),s=i(this),i("body").trigger("update_checkout")}),i(document).on("change",".org-address-selector",function(){for(var e=0;e<n.length;++e){var s=n[e];if(s.addressSelector==i(".org-address-selector").val())return i(".address-selector").val(i(".org-address-selector").val()),u(s),void(r=s)}}),i(document).on("change",".birth-date-month, .birth-date-day, .birth-date-year",function(){var e=i(this).parents(".svea-part-pay-fields, .svea-invoice-fields"),s=parseInt(e.find(".birth-date-year").val()),t=parseInt(e.find(".birth-date-month").val()),a=parseInt(e.find(".birth-date-day").val()),n=new Date(s,t,0).getDate();e.find(".birth-date-day option").each(function(){parseInt(i(this).val())>n?i(this).prop("disabled",!0):i(this).prop("disabled",!1)}),n<a&&e.find(".birth-date-day").val(n)})});
     1"use strict";jQuery(document).ready(function(i){var n=[],r=!1,a=!1,o=!1,d="sveawebpay_invoice",l="sveawebpay_invoice_b2b",c="sveawebpay_part_pay",g=i('[name="payment_method"]:checked').val()||!1,m=i('[name="billing_country"]').val()||!1,_=(void 0!==Svea.sameShippingAsBilling[g]&&Svea.sameShippingAsBilling[g]&&i(".woocommerce form.woocommerce-checkout").addClass("hide-shipping-fields"),0!=Svea.onlyOneAllowedCountry&&(m=Svea.onlyOneAllowedCountry),Svea.isPayPage&&(m=Svea.customerCountry,i(".payment_methods, .svea-get-address-button-container").addClass("is-pay-page")),i(".payment_methods, .svea-get-address-button-container").addClass("payment-method-"+g).addClass("country-"+(m?m.toLowerCase():"false")),!1);function v(e){if(e.length<=0)return"";for(var s="",t=0;t<e.length;++t){var a=e[t];s+='<option value="'+a.addressSelector+'">',"business"==a.customerType.toLowerCase()?s+=a.fullName+", ":"person"==a.customerType.toLowerCase()&&(s+=a.lastName+", "+a.firstName+" "),s+=a.street+" "+a.zipCode+" "+a.locality+"</option>"}return s}function u(e){0<String(e.firstName).length&&i("#billing_first_name").val(String(e.firstName)).change().trigger("keydown"),0<String(e.lastName).length&&i("#billing_last_name").val(String(e.lastName)).change().trigger("keydown"),"business"==String(e.customerType).toLowerCase()&&i("#billing_company").val(String(e.fullName)).change().trigger("keydown"),0<String(e.street).length&&i("#billing_address_1").val(String(e.street)).change().trigger("keydown"),0<String(e.coAddress).length&&i("#billing_address_2").val(String(e.coAddress)).change().trigger("keydown"),0<String(e.zipCode).length&&i("#billing_postcode").val(String(e.zipCode)).change().trigger("keydown"),0<String(e.locality).length&&i("#billing_city").val(String(e.locality)).change().trigger("keydown"),0<String(e.phoneNumber).length&&i("#billing_phone").val(String(e.phoneNumber)).change().trigger("keydown"),a=!0}function b(e){e?(i("#billing_address_1, #billing_address_2, #billing_postcode, \t\t\t\t#billing_city").prop("readonly",!1),i("#billing_address_1, #billing_address_2, #billing_postcode, \t\t\t\t#billing_city").removeClass("disabled-input")):(i("#billing_address_1, #billing_address_2, \t\t\t\t#billing_postcode, #billing_city").prop("readonly",!0),i("#billing_address_1, #billing_address_2, \t\t\t\t#billing_postcode, #billing_city").addClass("disabled-input"))}function p(e,s,t){switch(e){case"SE":case"DK":switch(s){case d:if("individual"===t)return;break;case c:return}}return 1}function b(e){e?(i("#billing_first_name, #billing_last_name, #billing_address_1, \t\t\t\t#billing_address_2, #billing_postcode, #billing_city").prop("readonly",!1),i("#billing_first_name, #billing_last_name, #billing_address_1, \t\t\t\t#billing_address_2, #billing_postcode, #billing_city").removeClass("disabled-input")):(i("#billing_first_name, #billing_last_name, #billing_address_1, \t\t\t\t#billing_address_2, #billing_postcode, #billing_city").prop("readonly",!0),i("#billing_first_name, #billing_last_name, #billing_address_1, \t\t\t\t#billing_address_2, #billing_postcode, #billing_city").addClass("disabled-input"))}function h(){i("#billing_first_name, #billing_last_name, #billing_address_1, \t\t\t\t#billing_address_2, #billing_postcode, #billing_city").val([])}0<i(".svea-get-address-button-container.get-address-shortcode").length&&(i(".payment_method_"+d).is(":visible")||i(".payment_method_"+l).is(":visible")?i(".svea-get-address-button-container.get-address-shortcode").removeClass("invoice-not-available"):i(".svea-get-address-button-container.get-address-shortcode").addClass("invoice-not-available")),i(".svea-get-address-button-container.get-address-shortcode").is(":visible")&&(_=i("[name='svea_get_address_customer_type']:checked").val(),i('[name="iv_billing_customer_type"]').val(_),i(".payment_methods, .svea-get-address-button-container").addClass("customer-type-"+_)),p(m,g,_)?p(m,g,_)&&b(!0):(b(!1),a||h()),i(document).on("change",".woocommerce form.woocommerce-checkout .woocommerce-billing-fields :input",function(e){a=!1}),i(document).on("keydown",'[name="svea_billing_ssn"], [name="svea_billing_org_number"], [name="iv_billing_org_number"], [name="iv_billing_ssn"], [name="pp_billing_ssn"]',function(e){var s=i(e.target);13==(e.which||e.keyCode||0)&&(e.preventDefault(),(e=($container=s.closest(".svea-fields, .svea-get-address-button-container")).find(".svea-get-address-button")).is(":visible"))&&e.click()}),i(document).on("change",'[name="svea_billing_ssn"]',function(e){i("[name='iv_billing_ssn'], [name='pp_billing_ssn']").val(i(this).val())}),i(document).on("change",'[name="svea_billing_org_number"]',function(e){i("[name='iv_billing_org_number'], [name='pp_billing_org_number']").val(i(this).val())}),i(document).on("click",".svea-get-address-button",function(e){e.preventDefault();var s,e=g,t=(i(this),i(this).closest(".svea-get-address-button-container")),a=i(".svea-get-address-button-container.get-address-shortcode").is(":visible");i(".svea-invoice-fields, .svea-part-pay-fields");o||(a&&(e=d),"individual"==_||e==c?(s=i(a?"[name='svea_billing_ssn']":"[name='"+(e==d?"iv":"pp")+"_billing_ssn']").val(),t.addClass("getting-address"),o=!0,i.post(Svea.ajaxUrl,{action:"svea_get_address",pers_nr:s,country_code:m,payment_type:e,security:Svea.gaSecurity},function(e){t.removeClass("getting-address"),o=!1,void 0===e.resultcode||void 0===e.customerIdentity?(t.append('<div class="svea-message error">'+Phrases.could_not_get_address+"</div>"),t.addClass("getting-address-error"),setTimeout(function(){t.find(".svea-message.error").remove(),t.removeClass("getting-address-error")},5e3)):"Error"==e.resultcode||"NoSuchEntity"==e.resultcode?(t.append('<div class="svea-message error">'+e.errormessage+"</div>"),t.addClass("getting-address-error"),setTimeout(function(){t.find(".svea-message.error").remove(),t.removeClass("getting-address-error")},5e3)):(u(e.customerIdentity[0]),t.append('<div class="svea-message success">'+Phrases.your_address_was_found+"</div>"),t.addClass("getting-address-success"),setTimeout(function(){t.find(".svea-message.success").remove(),t.removeClass("getting-address-success")},5e3))})):"company"==_&&(s=i(a?"[name='svea_billing_org_number']":"[name='"+(e==d||e==l?"iv":"pp")+"_billing_org_number']").val(),t.addClass("getting-address"),o=!0,i.post(Svea.ajaxUrl,{action:"svea_get_address",org_nr:s,country_code:m,payment_type:e,security:Svea.gaSecurity},function(e){t.removeClass("getting-address"),o=!1,void 0===e.resultcode||void 0===e.customerIdentity?(t.append('<div class="svea-message error">'+Phrases.could_not_get_address+"</div>"),t.addClass("getting-address-error"),setTimeout(function(){t.find(".svea-message.error").remove(),t.removeClass("getting-address-error")},5e3)):"Error"==e.resultcode||"NoSuchEntity"==e.resultcode?(t.append('<div class="svea-message error">'+e.errormessage+"</div>"),t.addClass("getting-address-error"),setTimeout(function(){t.find(".svea-message.error").remove(),t.removeClass("getting-address-error")},5e3)):(e=e.customerIdentity,i(".org-address-selector").html(v(e)),n=e,i(".address-selector").val(e[0].addressSelector),u(e[0]),r=e[0],t.addClass("getting-address-success"),t.append('<div class="svea-message success">'+Phrases.your_address_was_found+"</div>"),setTimeout(function(){t.find(".svea-message.success").remove(),t.removeClass("getting-address-success")},5e3))})))}),Svea.isPayPage&&i('.payment_methods [name="payment_method"]').on("change",function(){var e=g||!1;g=i('[name="payment_method"]:checked').val(),_=i('[name="iv_billing_customer_type"]').val()||!1,i(".payment_methods, .svea-get-address-button-container").removeClass("payment-method-"+e).addClass("payment-method-"+g).removeClass("customer-type-"+_).addClass("customer-type-"+_),r=!1,n=[],i(".org-address-selector").html("")}),i(document).on("updated_checkout",function(){0<i(".svea-get-address-button-container.get-address-shortcode").length&&(i(".payment_method_"+d).is(":visible")?i(".svea-get-address-button-container.get-address-shortcode").removeClass("invoice-not-available"):i(".svea-get-address-button-container.get-address-shortcode").addClass("invoice-not-available")),i(".svea-get-address-button-container.get-address-shortcode").is(":visible")&&(i("[name='iv_billing_ssn'], [name='pp_billing_ssn']").val(i("[name='svea_billing_ssn']").val()),i("[name='iv_billing_org_number']").val(i("[name='svea_billing_org_number']").val()),i('[name="iv_billing_customer_type"]').val(i('[name="svea_get_address_customer_type"]:checked').val()));var e=m||!1,s=g||!1,t=_||!1;0==Svea.onlyOneAllowedCountry&&(m=i('[name="billing_country"]').val()),g=i('[name="payment_method"]:checked').val(),_=i('[name="iv_billing_customer_type"]').val()||"individual",i(".payment_methods, .svea-get-address-button-container").removeClass("country-"+(e?e.toLowerCase():"false")).addClass("country-"+(m?m.toLowerCase():"false")).removeClass("payment-method-"+s).addClass("payment-method-"+g),i(".svea-get-address-button-container.get-address-shortcode").is(":visible")&&(_=i('[name="iv_billing_customer_type"]').val()||"individual"),i(".payment_methods, .svea-get-address-button-container").removeClass("customer-type-"+t).addClass("customer-type-"+_),!1!==r&&0<n.length&&(i(".org-address-selector").html(v(n)),i(".org-address-selector").val(r.addressSelector),i(".address-selector").val(r.addressSelector)),void 0!==Svea.sameShippingAsBilling[g]&&Svea.sameShippingAsBilling[g]?i(".woocommerce .woocommerce-checkout").hasClass("hide-shipping-fields")||i(".woocommerce .woocommerce-checkout").addClass("hide-shipping-fields"):i(".woocommerce .woocommerce-checkout").hasClass("hide-shipping-fields")&&i(".woocommerce .woocommerce-checkout").removeClass("hide-shipping-fields"),e===m&&g===s||(r=!1,n=[],i(".org-address-selector").html(""),p(m,g,_)?p(m,g,_)&&b(!0):(b(!1),a||h()))}),i(document).on("change",'[name="payment_method"]',function(){i("body").trigger("update_checkout")}),i(document).on("change",'[name="billing_country"]',function(){var e=m||!1;m=i('[name="billing_country"]').val(),i(".payment_methods, .svea-get-address-button-container").removeClass("country-"+(e?e.toLowerCase():"false")).addClass("country-"+(m?m.toLowerCase():"false")),p(m,g,_)?p(m,g,_)&&b(!0):(b(!1),a||h())});var s=null;i(document).on("change",'.invoice-customer-type select, [name="svea_get_address_customer_type"]',function(){var e;o?null!=s&&i(this).val(s.val()):(e=_||!1,_=i(this).val()||!1,i(".payment_methods, .svea-get-address-button-container").removeClass("customer-type-"+e).addClass("customer-type-"+_),s=i(this),p(m,g,_)?p(m,g,_)&&b(!0):(b(!1),a||h()))}),i(document).on("change",'[name="svea_get_address_customer_type"]',function(){i("[name='iv_billing_customer_type']").val(i(this).val()),s=i(this),i("body").trigger("update_checkout")}),i(document).on("change",".org-address-selector",function(){for(var e=0;e<n.length;++e){var s=n[e];if(s.addressSelector==i(".org-address-selector").val())return i(".address-selector").val(i(".org-address-selector").val()),u(s),void(r=s)}}),i(document).on("change",".birth-date-month, .birth-date-day, .birth-date-year",function(){var e=i(this).parents(".svea-part-pay-fields, .svea-invoice-fields"),s=parseInt(e.find(".birth-date-year").val()),t=parseInt(e.find(".birth-date-month").val()),a=parseInt(e.find(".birth-date-day").val()),n=new Date(s,t,0).getDate();e.find(".birth-date-day option").each(function(){parseInt(i(this).val())>n?i(this).prop("disabled",!0):i(this).prop("disabled",!1)}),n<a&&e.find(".birth-date-day").val(n)})});
  • svea-webpay-for-woocommerce/trunk/inc/Gateways/WC_Gateway_Svea_Invoice.php

    r3319942 r3328029  
    143143        add_action( 'woocommerce_api_wc_gateway_svea_invoice_strong_auth_rejected', [ $this, 'handle_callback_request_rejected' ] );
    144144
     145        self::$log_enabled = $this->get_option( 'debug' ) === 'yes';
     146
    145147        $this->same_shipping_as_billing = $this->get_option( 'same_shipping_as_billing' ) === 'yes';
    146148
     
    167169        $this->invoice_fee_taxable = $this->get_option( 'invoice_fee_taxable_' . $customer_country ) === 'yes';
    168170
    169         self::$log_enabled = $this->get_option( 'debug' ) === 'yes';
    170171        $this->description = __( $this->get_option( 'description' ), 'svea-webpay-for-woocommerce' ); // phpcs:ignore
    171172    }
     
    12011202        $strong_auth = $this->uses_strong_auth( $customer_country, $customer_type );
    12021203
     1204        $this->testmode = $this->get_option( 'testmode_' . strtolower( $customer_country ) ) === 'yes';
     1205
    12031206        $config = $this->get_config( $customer_country, $customer_type );
    12041207
     
    14991502
    15001503        $post_data = [
    1501             'iv_billing_customer_type' => $subscription->get_meta( '_svea_customer_type' ),
    1502             'iv_billing_org_number'    => $subscription->get_meta( '_svea_iv_billing_org_number' ),
    1503             'iv_billing_ssn'           => $subscription->get_meta( '_svea_iv_billing_ssn' ),
    1504             'iv_billing_vat_number'    => $subscription->get_meta( '_svea_iv_billing_vat_number' ),
    1505             'iv_birth_date_year'       => $subscription->get_meta( '_svea_iv_birth_date_year' ),
    1506             'iv_birth_date_month'      => $subscription->get_meta( '_svea_iv_birth_date_month' ),
    1507             'iv_birth_date_day'        => $subscription->get_meta( '_svea_iv_birth_date_day' ),
    1508             'iv_billing_initials'      => $subscription->get_meta( '_svea_iv_billing_initials' ),
     1504            'iv_billing_customer_type'    => $subscription->get_meta( '_svea_customer_type' ) ?: $subscription->get_meta( '_svea_iv_billing_customer_type' ),
     1505            'iv_billing_address_selector' => $subscription->get_meta( '_svea_address_selector' ),
     1506            'iv_billing_org_number'       => $subscription->get_meta( '_svea_iv_billing_org_number' ),
     1507            'iv_billing_ssn'              => $subscription->get_meta( '_svea_iv_billing_ssn' ),
     1508            'iv_billing_vat_number'       => $subscription->get_meta( '_svea_iv_billing_vat_number' ),
     1509            'iv_birth_date_year'          => $subscription->get_meta( '_svea_iv_birth_date_year' ),
     1510            'iv_birth_date_month'         => $subscription->get_meta( '_svea_iv_birth_date_month' ),
     1511            'iv_birth_date_day'           => $subscription->get_meta( '_svea_iv_birth_date_day' ),
     1512            'iv_billing_initials'         => $subscription->get_meta( '_svea_iv_billing_initials' ),
    15091513        ];
    15101514
     
    16771681        $customer_company = $wc_order->get_billing_company();
    16781682
    1679         $customer_type = $subscription->get_meta( '_svea_customer_type' );
     1683        $customer_type = $subscription->get_meta( '_svea_customer_type' ) ?: $subscription->get_meta( '_svea_iv_billing_customer_type' );
    16801684
    16811685        $invoice_fee_label = $this->get_option( 'invoice_fee_label_' . strtolower( $customer_country ) );
     
    17371741        }
    17381742
     1743        $this->testmode = $this->get_option( 'testmode_' . strtolower( $customer_country ) ) === 'yes';
     1744
    17391745        $config = $this->get_config( $customer_country, $customer_type );
    17401746
     
    17561762         */
    17571763        $svea_data = [
    1758             'customer_type'    => $subscription->get_meta( '_svea_customer_type' ),
     1764            'customer_type'    => $subscription->get_meta( '_svea_customer_type' ) ?: $subscription->get_meta( '_svea_iv_billing_customer_type' ),
    17591765            'address_selector' => $subscription->get_meta( '_svea_address_selector' ),
    17601766            'org_number'       => $subscription->get_meta( '_svea_iv_billing_org_number' ),
     
    18871893     */
    18881894    public function cancel_order( $order, $svea_order_id ) {
    1889         $customer_type = $order->get_meta( '_svea_customer_type' );
     1895        $customer_type = $order->get_meta( '_svea_customer_type' ) ?: $order->get_meta( '_svea_iv_billing_customer_type' );
    18901896        $config = $this->get_config( $order->get_billing_country(), $customer_type );
    18911897
     
    19261932     */
    19271933    public function credit_order( $order, $svea_order_id ) {
    1928         $customer_type = $order->get_meta( '_svea_customer_type' );
     1934        $customer_type = $order->get_meta( '_svea_customer_type' ) ?: $order->get_meta( '_svea_iv_billing_customer_type' );
    19291935        $config = $this->get_config( $order->get_billing_country(), $customer_type );
    19301936
     
    21402146     */
    21412147    public function deliver_order( $order, $svea_order_id ) {
    2142         $customer_type = $order->get_meta( '_svea_customer_type' );
     2148        $customer_type = $order->get_meta( '_svea_customer_type' ) ?: $order->get_meta( '_svea_iv_billing_customer_type' );
    21432149        $config = $this->get_config( $order->get_billing_country(), $customer_type );
    21442150        $is_b2b = $customer_type === 'company';
  • svea-webpay-for-woocommerce/trunk/inc/Gateways/WC_Gateway_Svea_Part_Pay.php

    r3319942 r3328029  
    116116        add_action( 'woocommerce_api_wc_gateway_svea_part_pay_strong_auth_rejected', [ $this, 'handle_callback_request_rejected' ] );
    117117
     118        self::$log_enabled = $this->get_option( 'debug' ) === 'yes';
     119
    118120        if ( ! isset( WC()->customer ) ) {
    119121            return;
     
    141143        $this->display_product_widget = $this->get_option( 'display_product_widget' ) === 'yes';
    142144
    143         self::$log_enabled = $this->get_option( 'debug' ) === 'yes';
    144145        $this->description = __( $this->get_option( 'description' ), 'svea-webpay-for-woocommerce' ); // phpcs:ignore
    145146    }
  • svea-webpay-for-woocommerce/trunk/inc/Order_Functions.php

    r3319942 r3328029  
    3232
    3333        add_action( 'woocommerce_after_checkout_validation', [ $this, 'checkout_validation_handler' ], 10, 2 );
     34
     35        if ( ! is_admin() ) {
     36            add_filter( 'pre_option_woocommerce_ship_to_destination', [ $this, 'maybe_force_ship_to_billing_address' ], 10, 2 );
     37        }
    3438
    3539        add_filter( 'woocommerce_get_order_item_totals', [ $this, 'receipt_display_svea_order_id' ], 10, 2 );
     
    9195
    9296    /**
     97     * Maybe force the ship to billing address
     98     *
     99     * @param mixed $value
     100     * @return mixed
     101     */
     102    public function maybe_force_ship_to_billing_address( $value ) {
     103        // Get current gateway
     104        $current_gateway = Helper::get_current_gateway();
     105
     106        if ( $current_gateway && method_exists( $current_gateway, 'can_ship_to_different_address' )
     107            && ! $current_gateway->can_ship_to_different_address() ) {
     108            // If the gateway does not allow shipping to a different address, force the value to 'billing_only'
     109            $value = 'billing_only';
     110        }
     111
     112        return $value;
     113    }
     114
     115    /**
    93116     * Display the svea order id whilst viewing the receipt
    94117     *
  • svea-webpay-for-woocommerce/trunk/partials/invoice/admin-subscription.php

    r2365521 r3328029  
    5555            <select class="org-address-selector"></select>
    5656        </p>
    57         <input type="hidden" name="_address_selector" class="address-selector" />
     57        <input type="hidden" name="_address_selector"
     58            value="<?php echo isset( $post_data['iv_billing_address_selector'] ) ? esc_attr( $post_data['iv_billing_address_selector'] ) : ''; ?>" class="address-selector" />
    5859    </div>
    5960    <div class="vat-number-container">
  • svea-webpay-for-woocommerce/trunk/readme.txt

    r3327589 r3328029  
    1010License: Apache 2.0
    1111License URI: https://www.apache.org/licenses/LICENSE-2.0
    12 Stable tag: 4.0.2
     12Stable tag: 4.0.3
    1313
    1414The Svea Stand Alone payment module is a complete solution for shops using WordPress / WooCommerce as an e-commerce platform.
     
    3939== Upgrade Notice ==
    4040
     41= 4.0.3 =
     424.0.3 is a patch release.
     43
    4144= 4.0.2 =
    42454.0.2 is a patch release.
     
    5760
    5861== Changelog ==
     62
     63= 4.0.3 2025-07-15 =
     64* Add backwards compatibility for subscription payments.
     65* Fix problems with organisational number not being fetched.
     66* Force billing address with new method.
    5967
    6068= 4.0.2 2025-07-09 =
  • svea-webpay-for-woocommerce/trunk/svea-webpay-for-woocommerce.php

    r3327589 r3328029  
    44 * Plugin Name: Svea Stand Alone for WooCommerce
    55 * Description: Supercharge your WooCommerce Store with powerful features to pay via Svea Credit card, Invoice, Part Payment, Trustly, Swish, MobilePay and Vipps.
    6  * Version: 4.0.2
     6 * Version: 4.0.3
    77 * Author: The Generation
    88 * Author URI: https://thegeneration.se/
     
    3737         * @var     string
    3838         */
    39         const VERSION = '4.0.2';
     39        const VERSION = '4.0.3';
    4040
    4141        /**
Note: See TracChangeset for help on using the changeset viewer.