Plugin Directory

Changeset 2903962


Ignore:
Timestamp:
04/25/2023 02:07:27 PM (3 years ago)
Author:
sprinque
Message:

v.1.3.0

Location:
sprinque
Files:
58 added
34 edited
1 copied

Legend:

Unmodified
Added
Removed
  • sprinque/tags/1.3.0/assets/css/frontend.css

    r2863342 r2903962  
    88  }
    99}
    10 #register-company-tab, #register-company-tab-2 {
     10#register-company-tab {
    1111  cursor: pointer;
    12   color: rgb(52, 58, 235);
     12  color: #000339;
    1313  text-decoration: none;
    1414}
     
    2929  cursor: default !important;
    3030  background: rgb(255, 255, 255);
    31   border: 1px solid rgb(52, 58, 235);
     31  border: 1px solid #000339;
    3232  box-shadow: rgba(217, 219, 242, 0.5) 0px 4px 8px;
    3333  border-radius: 8px;
     
    100100    padding-right: 10px;
    101101  }
     102}
     103
     104.wpm-modal-form-tab__terms .wpm-terms-row {
     105  display: flex;
     106  align-items: center;
     107  box-sizing: border-box;
     108  border: 1px solid #e2e4f9;
     109  border-radius: 3px;
     110  padding: 17px 7px;
     111  color: #1f2355;
     112  margin-top: 16px;
     113}
     114.wpm-modal-form-tab__terms .wpm-terms-row.total {
     115  font-weight: bold;
     116  border: none;
     117  padding-bottom: 0;
     118}
     119.wpm-modal-form-tab__terms .wpm-terms-row.active {
     120  border-color: #00023c;
     121}
     122.wpm-modal-form-tab__terms .wpm-terms-row .value {
     123  margin-left: auto;
     124}
     125.wpm-modal-form-tab__terms .wpm-terms-row input[type=radio] {
     126  display: none;
     127}
     128.wpm-modal-form-tab__terms .wpm-terms-row input[type=radio]:checked + .input-placeholder {
     129  background-color: #00023c;
     130  border-color: #00023c;
     131  background-image: url("../img/checkmark.png");
     132  background-position: center center;
     133  background-repeat: no-repeat;
     134}
     135.wpm-modal-form-tab__terms .wpm-terms-row .input-placeholder {
     136  width: 20px;
     137  height: 20px;
     138  border-radius: 20px;
     139  border: 2px solid #D9DBF2;
     140  margin-right: 9px;
    102141}
    103142
     
    424463.wpm-modal-form-tab__dsc a {
    425464  text-decoration: none !important;
    426   color: rgb(52, 58, 235);
     465  color: #000339;
    427466}
    428467.wpm-modal-form-tab__note {
     
    488527.field-group input:not([type=submit]):focus {
    489528  outline: none !important;
     529}
     530.field-group .field-warning {
     531  margin-top: 8px;
     532  box-sizing: border-box;
     533  color: rgb(40, 43, 93);
     534  border-radius: 8px;
     535  display: none;
     536  font-size: 14px;
    490537}
    491538
     
    504551  appearance: none;
    505552  text-decoration: none;
    506   font-weight: 500 !important;
    507   font-size: 14px;
     553  font-weight: 600 !important;
     554  font-size: 16px;
    508555  letter-spacing: 0.02857em;
    509556  min-width: 64px;
    510557  transition: background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, border-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
    511   padding: 3px 16px;
     558  padding: 12px 16px;
    512559  width: auto;
    513   height: 40px;
     560  height: 48px;
    514561  border: 2px solid transparent !important;
    515562  box-shadow: none;
    516   color: rgb(52, 58, 235);
    517   border-radius: 8px;
     563  color: #000339;
     564  border-radius: 4px;
    518565  text-transform: none;
    519566}
     
    526573}
    527574#wpm-modal-form .wpm-btn_primary {
    528   background: rgb(52, 58, 235) !important;
     575  background: #000339 !important;
    529576  color: rgb(255, 255, 255) !important;
    530577}
    531578#wpm-modal-form .wpm-btn_primary:hover {
    532   background: rgb(52, 58, 235) !important;
     579  background: #000339 !important;
    533580  box-shadow: rgba(0, 0, 0, 0.2) 0px 2px 4px -1px, rgba(0, 0, 0, 0.14) 0px 4px 5px 0px, rgba(0, 0, 0, 0.12) 0px 1px 10px 0px !important;
    534581  border-color: transparent !important;
     
    537584  font-weight: 600 !important;
    538585  background: transparent !important;
    539   color: rgb(52, 58, 235) !important;
    540   border-color: rgb(52, 58, 235) !important;
     586  color: #000339 !important;
     587  border-color: #000339 !important;
    541588}
    542589#wpm-modal-form .wpm-btn_outline-primary:hover {
    543   background: rgb(52, 58, 235) !important;
     590  background: #000339 !important;
    544591  color: #fff !important;
    545592}
    546593#wpm-modal-form .wpm-btn:disabled {
    547   color: rgba(0, 0, 0, 0.26) !important;
     594  color: #ffffff !important;
    548595  box-shadow: none !important;
    549   background-color: rgba(0, 0, 0, 0.12) !important;
     596  background-color: #D9DBF2 !important;
    550597  pointer-events: none !important;
    551598  cursor: default !important;
     
    687734  vertical-align: middle;
    688735  animation: spinAround 0.5s infinite linear;
    689   border: 3px solid rgb(52, 58, 235);
     736  border: 3px solid #000339;
    690737  margin-right: 8px;
    691738  border-radius: 290486px;
     
    723770  width: calc(20% - 10px) !important;
    724771  font-size: 38px !important;
    725   color: rgb(52, 58, 235);
     772  color: #000339;
    726773  font-weight: 500 !important;
    727774  text-align: center !important;
     
    735782  border-radius: 50%;
    736783  animation: spinAround 0.5s infinite linear;
    737   border: 4px solid rgb(52, 58, 235);
     784  border: 4px solid #000339;
    738785  border-right-color: transparent;
    739786  border-top-color: transparent;
     
    756803}
    757804
    758 .register-company-tab, .error-confirm-order a, #register-company-tab-2 {
     805.register-company-tab, .error-confirm-order a {
    759806  color: blue;
    760807  cursor: pointer;
     
    762809}
    763810
    764 .register-company-tab:hover, #register-company-tab-2:hover {
     811.register-company-tab:hover {
    765812  text-decoration: none;
    766813}
     
    790837  padding: 0 5px;
    791838}
     839
     840.purchase_approved .wpm-modal-form-tab__dsc {
     841  text-align: center;
     842}
     843.purchase_approved .approved-days {
     844  font-size: 20px;
     845  font-weight: 600;
     846  margin-top: 10px;
     847}
     848
     849/*# sourceMappingURL=frontend.css.map */
  • sprinque/tags/1.3.0/assets/css/frontend.scss

    r2863342 r2903962  
    11@keyframes spinAround{from{transform:rotate(0)}to{transform:rotate(359deg)}}
    2 $primary_color: rgb(52, 58, 235);
    3 
    4 #register-company-tab, #register-company-tab-2 {
     2//$primary_color: rgb(52, 58, 235);
     3$primary_color: #000339;
     4
     5#register-company-tab {
    56  cursor: pointer;
    67  color: $primary_color;
     
    115116  &::-moz-placeholder          { @content; }
    116117  &:-ms-input-placeholder      { @content; }
     118}
     119
     120.wpm-modal-form-tab__terms {
     121  .wpm-terms-row {
     122    display: flex;
     123    align-items: center;
     124    box-sizing: border-box;
     125    border: 1px solid #e2e4f9;
     126    border-radius: 3px;
     127    padding: 17px 7px;
     128    color: #1f2355;
     129    margin-top: 16px;
     130
     131    &.total {
     132      font-weight: bold;
     133      border: none;
     134      padding-bottom: 0;
     135    }
     136
     137    &.active {
     138      border-color: #00023c;
     139    }
     140
     141    .value {
     142      margin-left: auto;
     143    }
     144
     145    input[type="radio"] {
     146      display: none;
     147
     148      &:checked + .input-placeholder {
     149        background-color: #00023c;
     150        border-color: #00023c;
     151        background-image: url('../img/checkmark.png');
     152        background-position: center center;
     153        background-repeat: no-repeat;
     154      }
     155    }
     156
     157    .input-placeholder {
     158      width:  20px;
     159      height: 20px;
     160      border-radius: 20px;
     161      border: 2px solid #D9DBF2;
     162      margin-right: 9px;
     163    }
     164  }
    117165}
    118166
     
    534582      outline: none !important;
    535583    }
     584  }
     585
     586  .field-warning {
     587    margin-top: 8px;
     588    box-sizing: border-box;
     589    color: rgb(40, 43, 93);
     590    border-radius: 8px;
     591    display: none;
     592    font-size: 14px;
    536593  }
    537594}
     
    673730    appearance: none;
    674731    text-decoration: none;
    675     font-weight: 500 !important;
    676     font-size: 14px;
     732    font-weight: 600 !important;
     733    font-size: 16px;
    677734    letter-spacing: 0.02857em;
    678735    min-width: 64px;
    679736    transition: background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, border-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
    680     padding: 3px 16px;
     737    padding: 12px 16px;
    681738    width: auto;
    682     height: 40px;
     739    height: 48px;
    683740    border: 2px solid transparent !important;
    684741    box-shadow: none;
    685742    color: $primary_color;
    686743
    687     border-radius: 8px;
     744    border-radius: 4px;
    688745    text-transform: none;
    689746    @media screen and (max-width: 575.98px) {
     
    712769    }
    713770    &:disabled {
    714       color: rgba(0, 0, 0, 0.26) !important;
     771      color: #ffffff !important;
    715772      box-shadow: none !important;
    716       background-color: rgba(0, 0, 0, 0.12) !important;
     773      background-color: #D9DBF2 !important;
    717774      pointer-events: none !important;
    718775      cursor: default !important;
     
    9671024}
    9681025
    969 .register-company-tab, .error-confirm-order a, #register-company-tab-2 {
     1026.register-company-tab, .error-confirm-order a {
    9701027  color: blue;
    9711028  cursor: pointer;
     
    9731030}
    9741031
    975 .register-company-tab:hover, #register-company-tab-2:hover {
     1032.register-company-tab:hover {
    9761033  text-decoration: none;
    9771034}
     
    10011058  padding: 0 5px;
    10021059}
     1060
     1061.purchase_approved {
     1062  .wpm-modal-form-tab__dsc {
     1063    text-align: center;
     1064  }
     1065
     1066  .approved-days {
     1067    font-size: 20px;
     1068    font-weight: 600;
     1069    margin-top: 10px;
     1070  }
     1071}
  • sprinque/tags/1.3.0/assets/js/frontend.js

    r2873134 r2903962  
    55
    66    var countries = [];
     7
     8    function PaymentTermSelect() {
     9        this.payment_terms = window.admin.payment_terms;
     10        this.amount = 0;
     11        this.selected_fee = 0;
     12        this.selected_term = null;
     13        this.eligible_payment_terms = [];
     14
     15        if (typeof this.payment_terms === "undefined") {
     16            this.payment_terms = {};
     17        }
     18    }
     19
     20    PaymentTermSelect.prototype = {
     21        setEligiblePaymentTerms(paymentTerms) {
     22            this.eligible_payment_terms = paymentTerms;
     23        },
     24        setAmount(amount) {
     25            this.amount = amount;
     26            this.recalculateTotal();
     27        },
     28        setSelected(term) {
     29            if (typeof this.payment_terms[term] === "undefined") {
     30                return ;
     31            }
     32
     33            this.selected_fee = this.payment_terms[term];
     34            this.selected_term = term.toUpperCase();
     35
     36            this.recalculateTotal();
     37        },
     38        getPaymentTerm() {
     39            return this.selected_term;
     40        },
     41
     42        update() {
     43            for (let key in this.payment_terms) {
     44                const keyUpper = key.toUpperCase();
     45                if (this.eligible_payment_terms.indexOf(keyUpper) > -1) {
     46                    const availableTermUpperCase = this.eligible_payment_terms[keyUpper];
     47                    const fee = this.payment_terms[key];
     48                    const days = key.replace('net', '');
     49
     50                    if (typeof fee === "undefined") {
     51                        continue;
     52                    }
     53
     54                    $('.wpm-modal-form-tab__terms').append(`
     55                    <label class="wpm-terms-row">
     56                        <input type="radio" name="wpm_net_term" value="${availableTermUpperCase}" data-fee="${fee}" data-term="${key}" />
     57                        <div class="input-placeholder"></div>
     58                        <div class="label">Net ${days} ${window.admin.days}</div>
     59                        <div class="value">${this.calculateWithFee(fee)}</div>
     60                    </label>
     61                `);
     62                }
     63            }
     64        },
     65
     66        calculateWithFee(fee) {
     67            const calculatedFee = ( this.amount * (Number(fee) / 100.0) );
     68
     69            if (calculatedFee === 0.0) {
     70                return 'Free';
     71            }
     72
     73            return '€' + calculatedFee.toFixed(2);
     74        },
     75        recalculateTotal() {
     76            const fee = 1.0 + (Number(this.selected_fee) / 100.0);
     77            const totalWithFee = this.amount * fee;
     78
     79            jQuery('.wpm-terms-row.total .value').text('€' + totalWithFee.toFixed(2));
     80        }
     81    };
     82
     83    const selectPaymentTerm = new PaymentTermSelect();
    784
    885    if ($('#wpm-modal-form').length) {
     
    1289            var modal = $(this).attr('data-wpm-close');
    1390            hidePopup(modal);
     91        });
     92
     93        $('body').on('change', '.wpm-terms-row input[type="radio"]', function () {
     94            const terms = jQuery(this).closest('.wpm-modal-form-tab__terms');
     95            jQuery('.active', terms).removeClass('active');
     96            jQuery(this).closest('.wpm-terms-row').addClass('active');
     97            jQuery('.confirm-order-term').removeAttr('disabled');
     98
     99            recalculateTotal();
     100        });
     101
     102        $('body').on('click', '.confirm-order-term', function () {
     103            $(this).attr('disabled', 'disabled');
     104
     105            authorize_company_payment(function () {
     106                $('.choose_another_payment_method').trigger( "click" );
     107                orderPayed = true;
     108                $('#place_order').trigger( "click" );
     109            }, {
     110                payment_terms: selectPaymentTerm.getPaymentTerm()
     111            });
    14112        });
    15113
     
    53151    }
    54152
     153    function recalculateTotal() {
     154        if (jQuery('.wpm-terms-row.active').length < 1) {
     155            return ;
     156        }
     157
     158        selectPaymentTerm.setSelected(jQuery('.wpm-terms-row.active input:checked').attr('data-term'));
     159    }
     160
    55161    function checkRegisterFields()
    56162    {
     
    74180      $(elem).removeClass('modal-middle');
    75181      $('.error-confirm-order').hide();
     182      // showTab('.select_payment_term');
    76183    }
    77184
     
    143250
    144251    function showTab(el) {
    145         $(el).show(0).siblings().hide(0);
     252        $(el).siblings().hide();
     253        $(el).show();
    146254    }
    147255
     
    289397
    290398    $("body").on("input", "#reg_number_pay", function(event) {
     399        const country_code = $('#select_country_pay').val().toLowerCase();
     400        const reg_number = $(this).val();
     401        let language = document.documentElement.lang;
     402        language = language.replace('_', '-');
     403        language = language.split('-');
     404        language = language.shift();
     405        const validation = Sprinque.checkRegNumber(reg_number, country_code, language);
     406
     407        if (!validation.isValid) {
     408            $('#reg_number_warning')
     409                .show()
     410                .text(validation.message);
     411        } else {
     412            $('#reg_number_warning').hide();
     413        }
     414
    291415        $('.error-confirm-order').hide();
    292416    });
     
    305429        $('#reg_number_pay').val(company_reg_code);
    306430        $('#confirm-company-order').prop('disabled', false);
     431
     432        $('#reg_number_pay').trigger('input');
    307433    });
    308434
     
    345471    });
    346472
    347     $("body").on("click", "#register-company-tab, #register-company-tab-2, .register-company-tab, .js-register-company-tab", function(event) {
     473    $("body").on("click", "#register-company-tab, .company-item-404, .register-company-tab, .js-register-company-tab", function(event) {
    348474        event.preventDefault();
    349475        var reg_number = $('#reg_number_pay').val();
     
    736862            success: function (response) {
    737863                if(response.status === true) {
    738                     showTab('.placing_your_order');
    739                     setTimeout(function() {
    740                         $('#days-review').html(response.days);
    741                         showTab('.purchase_approved');
    742                     }, 1000);
     864                    if (response.eligible_payment_terms.length > 1) {
     865                        selectPaymentTerm.setEligiblePaymentTerms(response.eligible_payment_terms);
     866                        selectPaymentTerm.setAmount(Number(response.total));
     867                        selectPaymentTerm.update();
     868
     869                        showTab('.select_payment_term');
     870                    } else {
     871
     872                        showTab('.placing_your_order');
     873                        setTimeout(function() {
     874                            $('#days-review').html(response.days);
     875                            const paymentTerm = response.eligible_payment_terms[0];
     876                            $('.approve-place-order').attr('data-term', paymentTerm);
     877                            showTab('.purchase_approved');
     878                        }, 1000);
     879                    }
    743880                } else if(response.status === false) {
    744881                    if(response.credit_decision === 'MANUAL_REVIEW' || response.credit_decision === 'PENDING') {
     
    773910    }
    774911
    775     function authorize_company_payment(callback)
     912    function authorize_company_payment(callback, params = {})
    776913    {
    777914        var address_line1 = $('#billing_address_1').val();
     
    795932                    'country_code': country_code,
    796933                    'email': email,
    797                     'nonce': admin.nonce
     934                    'nonce': admin.nonce,
     935                    'payment_terms': typeof params.payment_terms !== "undefined" ? params.payment_terms : null
    798936                },
    799937                type: 'POST',
     
    811949                            var modal_class = 'modal-middle';
    812950
     951                            showTab('.verifying_your_account');
    813952                            $('.cant-complete-autorization').show();
    814953                            $('.placing_your_order').hide();
    815                             $('.verifying_your_account').show();
    816954                            $('.verifying_your_account .wpm-loader_my1').hide();
    817955                            $('.verify-error-explanation, .verify-error').hide();
     
    8661004    $("body").on("click", ".approve-place-order", function(event) {
    8671005        showTab('.placing_your_order');
    868         setTimeout(function() {
     1006        const paymentTerm = $(this).attr('data-term');
     1007            setTimeout(function() {
    8691008            authorize_company_payment(function () {
    8701009                $('.choose_another_payment_method').trigger( "click" );
    8711010                orderPayed = true;
    8721011                $('#place_order').trigger( "click" );
    873             });
     1012            }, { payment_terms: paymentTerm });
    8741013        }, 1000);
    8751014    });
  • sprinque/tags/1.3.0/include/payment_method.php

    r2877020 r2903962  
    246246            $merchant_buyer_id = time();
    247247            $email = sanitize_text_field( $_POST['email'] );
    248             $phone = sanitize_text_field( $_POST['phone'] );
     248            $phone_number = sanitize_text_field($_POST['phone']);
     249            $phone_number = str_replace(' ', '', $phone_number);
     250            $phone = $phone_number;
    249251            $country = sanitize_text_field( $_POST['country_code'] );
    250252            $business_name = sanitize_text_field( $_POST['business_name'] );
     
    258260                'business_name'       => stripslashes($business_name),
    259261                'registration_number' => sanitize_text_field( $_POST['registration_number'] ),
    260                 'phone' => sanitize_text_field( $_POST['phone'] ),
     262                'phone' => $phone_number,
    261263                'address'             => [
    262264                    'address_line1' => sanitize_text_field( $_POST['address_line1'] ),
     
    278280                        'last_name'  => sanitize_text_field( $_POST['last_name'] ),
    279281                        'email'      => $email,
    280                         'phone' => sanitize_text_field( $_POST['phone'] ),
     282                        'phone' => $phone_number,
    281283                        'role'       => 'MEMBER'
    282284                    ]
     
    394396            $ip = $this->get_ip_address();
    395397
    396             // Prepare Data to Send
    397             $data = [
     398            // Prepare Data to Send
     399            $data = [
    398400                'merchant_order_id' => sanitize_text_field($_SESSION['order_id']),
    399401                'order_amount'      => WC()->cart->total,
     
    411413            ];
    412414
     415            if (isset($_POST['payment_terms']) && $_POST['payment_terms'] !== null) {
     416                $payment_term = sanitize_text_field($_POST['payment_terms']);
     417                $data['payment_terms'] = $payment_term;
     418                $payment_term_lower = strtolower($payment_term);
     419
     420                $payment_terms = wp_cache_get('sprinque_available_payment_terms');
     421                if ( !$payment_terms ) {
     422                    $payment_terms = [];
     423                }
     424                $fee = $payment_terms[$payment_term_lower] ?? 0.0;
     425
     426                if ($fee > 0.0) {
     427                    $fee /= 100.0;
     428                    $data['order_amount'] *= 1.0 + $fee;
     429                }
     430            }
     431
    413432            // Get Data from API
    414433            $result = $this->srinque_api( $data, 'POST', "/transactions/authorize/{$buyer_id}" );
     
    431450                $_SESSION['review_order'] = sanitize_text_field($buyer_id);
    432451                unset( $_SESSION['transaction_id'] );
     452                unset( $_SESSION['net_term'] );
    433453
    434454                wp_send_json( [
     
    440460                // Prepare Data to Create Order
    441461                $_SESSION['transaction_id'] = sanitize_text_field($result['transaction_id']);
     462                $_SESSION['net_term'] = sanitize_text_field($result['payment_terms']);
    442463                unset( $_SESSION['review_order'] );
    443464
     
    471492            $buyer = $this->srinque_api( [], 'GET', "/buyers/{$buyer_id}" );
    472493            $days = isset($buyer['credit_qualification']['payment_terms']) ? str_replace('NET', '', $buyer['credit_qualification']['payment_terms']) : 30;
     494            $eligible_payment_terms = $buyer['credit_qualification']['eligible_payment_terms'];
    473495
    474496            $credit_decision = $buyer['credit_qualification']['credit_decision'];
     
    479501                'days'    => $days,
    480502                'credit_decision' => $credit_decision ?? 'MANUAL_REVIEW',
     503                'eligible_payment_terms' => $eligible_payment_terms,
     504                'total'   => WC()->cart->get_total('float'),
    481505                'message' => sprintf(__("You have been approved for a payment term of %s days by Sprinque!", "sprinque"), $days)
    482506            ] );
     
    503527            $_SESSION['review_order'] = sanitize_text_field($buyer_id);
    504528            unset( $_SESSION['transaction_id'] );
     529            unset( $_SESSION['net_term'] );
    505530
    506531            wp_send_json([
     
    732757                update_post_meta( $order_id, 'transaction_id', sanitize_text_field($_SESSION['transaction_id']) );
    733758                update_post_meta( $order_id, 'merchant_order_id', sanitize_text_field($_SESSION['order_id']) );
     759
    734760                $order->update_status( 'processing', __( 'Pay by Invoice - Business only', 'sprinque' ) );
    735761            }
     762
     763            if ( isset( $_SESSION['net_term'] ) ) {
     764                update_post_meta( $order_id, 'net_term', sanitize_text_field($_SESSION['net_term']) );
     765            }
     766
     767            if ( isset( $_SESSION['surcharge_fee'] ) ) {
     768                update_post_meta( $order_id, 'buyer_fee_percentage', sanitize_text_field($_SESSION['surcharge_fee']) );
     769            }
     770
     771            unset($_SESSION['net_term']);
     772            unset($_SESSION['surcharge_fee']);
    736773
    737774            // Reduce stock levels
  • sprinque/tags/1.3.0/languages/sprinque-de_DE.po

    r2877020 r2903962  
    99
    1010#: templates/frontend/srinque_pay_modal_form.php:102
    11 #, fuzzy
    1211msgid "(in :sec seconds)"
    13 msgstr "(in :sec sekunden)"
     12msgstr "(in :sec Sekunden)"
    1413
    1514#: sprinque.php:442 templates/ajax/founded_companies.php:22
     
    9190#: sprinque.php:440 templates/ajax/founded_companies.php:3
    9291msgid "Company not found"
    93 msgstr "Firma nicht gefunden"
     92msgstr "Firma nicht gefunden?"
    9493
    9594#: templates/frontend/srinque_pay_modal_form.php:29
     
    108107msgstr "Stornierung bestätigen"
    109108
     109#: templates/frontend/srinque_pay_modal_form.php:137
     110msgid "Confirm order"
     111msgstr "Bestellung bestätigen"
     112
     113#: templates/frontend/srinque_pay_modal_form.php:129
     114msgid "Congratulations!"
     115msgstr "Herzlichen Glückwunsch!"
     116
    110117#: templates/frontend/srinque_pay_modal_form.php:107
    111118#: templates/frontend/srinque_pay_modal_form.php:114
     
    116123msgid "Country"
    117124msgstr "Land"
     125
     126#: sprinque.php:546
     127msgid "days"
     128msgstr "Tage"
    118129
    119130#: templates/frontend/srinque_pay_modal_form.php:100
     
    255266msgstr "um es trotzdem zu benutzen"
    256267
     268#: templates/frontend/srinque_pay_modal_form.php:133
     269msgid "Total amount"
     270msgstr "Gesamtbetrag"
     271
    257272msgid "VAT ID"
    258273msgstr "USt-IdNr."
     
    282297msgid "You have been approved for a payment term of %s days by Sprinque!"
    283298msgstr "Du wurdest von Sprinque für ein Zahlungsziel von %s Tagen zugelassen!"
     299
     300#: templates/frontend/srinque_pay_modal_form.php:130
     301msgid "You've been approved to pay with net terms. Select the payment term that best suits your company"
     302msgstr "Sie wurden für die Zahlung auf Rechnung zugelassen. Wählen Sie das Zahlungsziel, das am besten zu Ihrem Unternehmen passt"
  • sprinque/tags/1.3.0/languages/sprinque-en_US.po

    r2873134 r2903962  
    105105#: sprinque.php:440 templates/ajax/founded_companies.php:3
    106106msgid "Company not found"
    107 msgstr "Company not found"
     107msgstr "Company not found?"
    108108
    109109#: templates/frontend/srinque_pay_modal_form.php:31
     
    304304msgstr "Title"
    305305
     306#: templates/frontend/srinque_pay_modal_form.php:129
     307msgid "Congratulations!"
     308msgstr "Congratulations!"
     309
     310#: templates/frontend/srinque_pay_modal_form.php:130
     311msgid "You've been approved to pay with net terms. Select the payment term that best suits your company"
     312msgstr "You've been approved to pay with net terms. Select the payment term that best suits your company"
     313
     314#: templates/frontend/srinque_pay_modal_form.php:133
     315msgid "Total amount"
     316msgstr "Total amount"
     317
     318#: templates/frontend/srinque_pay_modal_form.php:137
     319msgid "Confirm order"
     320msgstr "Confirm order"
     321
     322#: sprinque.php:546
     323msgid "days"
     324msgstr "days"
     325
     326#: sprinque.php:259
     327#: sprinque.php:451
     328msgid "Net terms fee"
     329msgstr "Net terms fee"
  • sprinque/tags/1.3.0/languages/sprinque-es_ES.po

    r2877020 r2903962  
    99
    1010#: templates/frontend/srinque_pay_modal_form.php:102
    11 #, fuzzy
    1211msgid "(in :sec seconds)"
    1312msgstr "(en :sec segundos)"
     
    9190#: sprinque.php:440 templates/ajax/founded_companies.php:3
    9291msgid "Company not found"
    93 msgstr "Empresa no encontrada"
     92msgstr "Empresa no encontrada?"
    9493
    9594#: templates/frontend/srinque_pay_modal_form.php:29
     
    108107msgstr "Confirmar anulación"
    109108
     109#: templates/frontend/srinque_pay_modal_form.php:137
     110msgid "Confirm order"
     111msgstr "Confirmar pedido"
     112
     113#: templates/frontend/srinque_pay_modal_form.php:129
     114msgid "Congratulations!"
     115msgstr "¡Felicidades!"
     116
    110117#: templates/frontend/srinque_pay_modal_form.php:107
    111118#: templates/frontend/srinque_pay_modal_form.php:114
     
    117124msgstr "País"
    118125
     126#: sprinque.php:546
     127msgid "days"
     128msgstr "días"
     129
    119130#: templates/frontend/srinque_pay_modal_form.php:100
    120131msgid "days by Sprinque!"
     
    253264msgstr "usarlo de todos modos"
    254265
     266#: templates/frontend/srinque_pay_modal_form.php:133
     267msgid "Total amount"
     268msgstr "La cantidad total"
     269
    255270msgid "VAT ID"
    256271msgstr "VAT ID"
     
    280295msgid "You have been approved for a payment term of %s days by Sprinque!"
    281296msgstr "Sprinque le ha aprobado un plazo de pago de %s días."
     297
     298#: templates/frontend/srinque_pay_modal_form.php:130
     299msgid "You've been approved to pay with net terms. Select the payment term that best suits your company"
     300msgstr "Has sido aprobado para pagar con factura. Selecciona el plazo de pago que mejor se adapte a su empresa"
  • sprinque/tags/1.3.0/languages/sprinque-fr_FR.po

    r2877020 r2903962  
    99
    1010#: templates/frontend/srinque_pay_modal_form.php:102
    11 #, fuzzy
     11
     12
    1213msgid "(in :sec seconds)"
    1314msgstr "(en :sec secondes)"
     
    9192#: sprinque.php:440 templates/ajax/founded_companies.php:3
    9293msgid "Company not found"
    93 msgstr "Société introuvable"
     94msgstr "Société introuvable?"
    9495
    9596#: templates/frontend/srinque_pay_modal_form.php:29
     
    108109msgstr "Confirmer l'annulation"
    109110
     111#: templates/frontend/srinque_pay_modal_form.php:137
     112
     113
     114msgid "Confirm order"
     115msgstr "Confirmer la commande"
     116
     117#: templates/frontend/srinque_pay_modal_form.php:129
     118
     119
     120msgid "Congratulations!"
     121msgstr "Félicitations !"
     122
    110123#: templates/frontend/srinque_pay_modal_form.php:107
    111124#: templates/frontend/srinque_pay_modal_form.php:114
     
    117130msgstr "Pays"
    118131
     132#: sprinque.php:546
     133
     134
     135msgid "days"
     136msgstr "jours"
     137
    119138#: templates/frontend/srinque_pay_modal_form.php:100
    120139msgid "days by Sprinque!"
     
    253272msgstr "de l'utiliser quand même"
    254273
     274#: templates/frontend/srinque_pay_modal_form.php:133
     275
     276
     277msgid "Total amount"
     278msgstr "Montant total"
     279
    255280msgid "VAT ID"
    256281msgstr "NUMÉRO DE TVA"
     
    280305msgid "You have been approved for a payment term of %s days by Sprinque!"
    281306msgstr "Vous avez été approuvé pour un délai de paiement de %s jours par Sprinque !"
     307
     308#: templates/frontend/srinque_pay_modal_form.php:130
     309
     310
     311msgid "You've been approved to pay with net terms. Select the payment term that best suits your company"
     312msgstr "Vous avez été autorisé à payer avec des conditions nettes. Sélectionnez le délai de paiement qui convient le mieux à votre entreprise"
  • sprinque/tags/1.3.0/languages/sprinque-nl_NL.po

    r2877020 r2903962  
    99
    1010#: templates/frontend/srinque_pay_modal_form.php:102
    11 #, fuzzy
    1211msgid "(in :sec seconds)"
    1312msgstr "(in :sec seconden)"
     
    9190#: sprinque.php:440 templates/ajax/founded_companies.php:3
    9291msgid "Company not found"
    93 msgstr "Bedrijf niet gevonden"
     92msgstr "Bedrijf niet gevonden?"
    9493
    9594#: templates/frontend/srinque_pay_modal_form.php:29
     
    108107msgstr "Annuleren bevestigen"
    109108
     109#: templates/frontend/srinque_pay_modal_form.php:137
     110msgid "Confirm order"
     111msgstr "Bevestig bestelling"
     112
     113#: templates/frontend/srinque_pay_modal_form.php:129
     114msgid "Congratulations!"
     115msgstr "Gefeliciteerd!"
     116
    110117#: templates/frontend/srinque_pay_modal_form.php:107
    111118#: templates/frontend/srinque_pay_modal_form.php:114
     
    117124msgstr "Land"
    118125
     126#: sprinque.php:546
     127#, fuzzy
     128msgid "days"
     129msgstr "dagen"
     130
    119131#: templates/frontend/srinque_pay_modal_form.php:100
    120132msgid "days by Sprinque!"
     
    253265msgstr "om alsnog te gebruiken"
    254266
     267#: templates/frontend/srinque_pay_modal_form.php:133
     268msgid "Total amount"
     269msgstr "Totaal bedrag"
     270
    255271msgid "VAT ID"
    256272msgstr "BTW-NUMMER"
     
    280296msgid "You have been approved for a payment term of %s days by Sprinque!"
    281297msgstr "Je bent goedgekeurd voor een betalingstermijn van %s dagen door Sprinque!"
     298
     299#: templates/frontend/srinque_pay_modal_form.php:130
     300msgid "You've been approved to pay with net terms. Select the payment term that best suits your company"
     301msgstr "Je bent goedgekeurd om met netto termijnen te betalen. Selecteer de betalingstermijn die het beste bij jouw bedrijf past"
  • sprinque/tags/1.3.0/readme.txt

    r2877020 r2903962  
    66Tested up to: 6.0
    77Requires PHP: 5.3
    8 Stable tag: 1.2.7
     8Stable tag: 1.3.0
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    5050
    5151== Changelog ==
     52
     53= 1.3.0 - April 25, 2023 =
     54* Passing Sprinque fee to buyers;
     55* Registration number warnings;
     56* Remove spaces in buyer phone;
     57* Updated "Company not found" styles and made it clickable;
    5258
    5359= 1.2.7 - March 8, 2023 =
  • sprinque/tags/1.3.0/sprinque.php

    r2877020 r2903962  
    55Description: Sprinque for WordPress is a plugin that allows you to offer your business buyers net payment terms (15, 30, 60, 90 days) and thereby grow conversion and retention.
    66Author: Sprinque
    7 Version: 1.2.7
     7Version: 1.3.0
    88Text Domain: sprinque
    99Domain Path: /languages
    1010*/
    1111
    12 define( 'PLUGIN_SRINQUE_VERSION', '1.2.7' );
     12define( 'PLUGIN_SRINQUE_VERSION', '1.3.0' );
    1313define( 'PLUGIN_SRINQUE_DIR', __DIR__ );
    1414define( 'PLUGIN_SRINQUE_PATH', plugins_url( '', __FILE__ ) );
     
    6969
    7070    public function __construct() {
     71        $this->get_payment_terms();
     72
    7173        // Include Styles and Scripts
    7274        add_action( 'wp_enqueue_scripts', [ $this, 'include_scripts_and_styles' ], 99 );
     
    8688        add_action( 'woocommerce_order_refunded', [ $this, 'send_refund_captured_order' ], 10, 1 );
    8789        add_action( 'woocommerce_update_order', [ $this, 'send_refund_voided_order' ], 10, 1 );
     90        add_action( 'woocommerce_cart_calculate_fees', [ $this, 'calculate_fees' ] );
    8891
    8992        // Initialize RestAPI
     
    227230            $response = $this->srinque_api( $data, 'POST', "/transactions/void/{$transaction_id}" );
    228231        }
     232    }
     233
     234    public function calculate_fees()
     235    {
     236        global $woocommerce;
     237
     238        if ( is_admin() && ! defined( 'DOING_AJAX' ) )
     239            return;
     240
     241        if ( ! session_id() ) {
     242            session_cache_limiter('public');
     243            session_start();
     244        }
     245
     246        if ( !isset( $_SESSION['net_term'] ) ) {
     247            return;
     248        }
     249
     250        $net_term = $_SESSION['net_term'];
     251        $net_term = strtolower($net_term);
     252        $payment_terms = $this->get_payment_terms();
     253        $percentage = $payment_terms[$net_term] ?? 0.0;
     254        $_SESSION['surcharge_fee'] = $percentage;
     255        $percentage /= 100;
     256
     257        if ($percentage > 0) {
     258            $surcharge = ( $woocommerce->cart->cart_contents_total + $woocommerce->cart->shipping_total ) * $percentage;
     259            $woocommerce->cart->add_fee( __('Net terms fee', 'sprinque'), $surcharge, true, '' );
     260        }
    229261    }
    230262
     
    362394                    $ip_address = get_post_meta( $order->get_id(), 'ip_address', true );
    363395
     396                    // Calculate order total
     397                    $payment_term = sanitize_text_field( $webhook['credit_qualification']['payment_terms'] );
     398                    $payment_terms = $this->get_payment_terms();
     399                    $total = $order->get_total();
     400                    $fee = $payment_terms[ strtolower($payment_term) ];
     401                    $fee_percents = floatval($fee) / 100;
     402                    $calculated_fee = $total * $fee_percents;
     403                    $total += $calculated_fee;
     404
    364405                    // Prepare Data to Send
    365406                    $data = [
    366407                        'merchant_order_id' =>  ( $order_id_from_sequential_plugin ?: $order->get_id() ) . '_wh',
    367                         'order_amount'      => $order->get_total(),
     408                        'order_amount'      => $total,
     409                        'payment_terms'     => $payment_term,
    368410                        'shipping_address'  => [
    369411                            'address_line1' => $order->get_billing_address_1(),
     
    394436
    395437                    if (isset($result['transaction_id'])) {
     438
    396439                        update_post_meta( $order->ID, 'transaction_id', $result['transaction_id'] );
    397440                        update_post_meta( $order->ID, 'merchant_order_id', $order->ID );
     441
     442                        update_post_meta( $order->ID,  'net_term', $payment_term );
     443                        update_post_meta( $order->ID,  'buyer_fee_percentage', $fee );
     444
    398445                        $order = new WC_Order( $order->ID );
    399446                        $order->update_status($status);
     447
     448                        // Add fee if needed
     449                        if ($fee_percents > 0.0) {
     450                            $fee = new stdClass();
     451                            $fee->name = __('Net terms fee', 'sprinque');
     452                            $fee->amount = $calculated_fee;
     453                            $fee->tax_status = 'taxable';
     454                            $fee->total = $calculated_fee;
     455
     456                            $order->add_fee($fee);
     457                            $order->calculate_totals();
     458                        }
     459
     460                        // Save the order
    400461                        $order->save();
    401462                    }
     
    500561            // Register scripts
    501562            $settings = get_option( 'woocommerce_wpm_srinque_pay_settings', true );
    502             wp_enqueue_script( 'wpm_srinque_pay', PLUGIN_SRINQUE_PATH . '/assets/js/frontend.js', array( 'jquery' ), PLUGIN_SRINQUE_VERSION, 'all' );
     563            wp_enqueue_script( 'wpm_srinque_tools', 'https://unpkg.com/b2b-sprinque-tools@1.0.0/dist/index.umd.min.js', array( ), PLUGIN_SRINQUE_VERSION, 'all' );
     564            wp_enqueue_script( 'wpm_srinque_pay', PLUGIN_SRINQUE_PATH . '/assets/js/frontend.js', array( 'jquery', 'wpm_srinque_tools' ), PLUGIN_SRINQUE_VERSION, 'all' );
    503565
    504566            wp_localize_script( 'wpm_srinque_pay', 'admin', array(
     
    515577                'loading' => __( "Loading...", 'sprinque' ),
    516578                'place_order' => __( "Place order", 'sprinque' ),
     579                'days' => __('days', 'sprinque'),
     580                'payment_terms' => $this->get_payment_terms()
    517581            ) );
    518582        }
     583    }
     584
     585    public function get_payment_terms()
     586    {
     587        $payment_terms = wp_cache_get('sprinque_available_payment_terms');
     588        if ( !$payment_terms ) {
     589            $payment_terms = $this->srinque_api([], 'GET', "/seller/pricing");
     590            $payment_terms = $payment_terms['buyer_pricing_fee_percent'];
     591            if (!is_array($payment_terms)) {
     592                return [];
     593            }
     594
     595            wp_cache_add('sprinque_available_payment_terms', $payment_terms, '', 300);
     596        }
     597
     598        return $payment_terms;
    519599    }
    520600
  • sprinque/tags/1.3.0/templates/frontend/srinque_pay_modal_form.php

    r2863342 r2903962  
    4444                        <label><?php _e( "Registration number", 'sprinque' ); ?>*</label>
    4545                        <input type="text" id="reg_number_pay" placeholder="<?php _e( "Registration number", 'sprinque' ); ?>">
     46                        <div class="field-warning" id="reg_number_warning">
     47                            Some text here
     48                        </div>
    4649                    </div>
    4750
     
    126129                </div>
    127130
     131                <div class="select_payment_term" style="display: none;">
     132                    <div class="wpm-modal-form-tab__title"><?php _e( "Congratulations!", 'sprinque' ); ?></div>
     133                    <div class="wpm-modal-form-tab__dsc"><?php _e( "You've been approved to pay with net terms. Select the payment term that best suits your company", 'sprinque' ); ?></div>
     134                    <div class="wpm-modal-form-tab__terms">
     135                        <div class="wpm-terms-row total">
     136                            <div class="label"><?php _e("Total amount", 'sprinque'); ?></div>
     137                            <div class="value">€00.00</div>
     138                        </div>
     139                    </div>
     140                    <button class="wpm-btn wpm-btn_primary wpm-btn_mt wpm-btn_block confirm-order-term" disabled><?php _e( "Confirm order", 'sprinque' ); ?></button>
     141                </div>
     142
    128143                <div class="purchase_approved" style="display: none;">
    129144                    <div class="wpm-modal-form-tab__title"><?php _e( "Purchase approved", 'sprinque' ); ?></div>
    130                     <div class="wpm-modal-form-tab__dsc"><?php _e( "You have been approved for a payment term of", 'sprinque' ); ?> <span id="days-review"></span> <?php _e( "days by Sprinque!", 'sprinque' ); ?></div>
    131                     <a class="wpm-btn wpm-btn_primary wpm-btn_mt-2 wpm-btn_block approve-place-order"><?php _e( "Place order", 'sprinque' ); ?></a>
     145                    <div class="wpm-modal-form-tab__dsc">
     146                        <div>
     147                            <?php _e( "Your account has been created and you’ve been approved for a payment term of:", 'sprinque' ); ?>
     148                        </div>
     149                        <div class="approved-days">
     150                            <span id="days-review"></span> <?php _e( "days", 'sprinque' ); ?>
     151                        </div>
     152                    </div>
     153                    <a class="wpm-btn wpm-btn_primary wpm-btn_mt-2 wpm-btn_block approve-place-order"><?php _e( "Confirm order", 'sprinque' ); ?></a>
    132154                </div>
    133155
  • sprinque/trunk/assets/css/frontend.css

    r2863342 r2903962  
    88  }
    99}
    10 #register-company-tab, #register-company-tab-2 {
     10#register-company-tab {
    1111  cursor: pointer;
    12   color: rgb(52, 58, 235);
     12  color: #000339;
    1313  text-decoration: none;
    1414}
     
    2929  cursor: default !important;
    3030  background: rgb(255, 255, 255);
    31   border: 1px solid rgb(52, 58, 235);
     31  border: 1px solid #000339;
    3232  box-shadow: rgba(217, 219, 242, 0.5) 0px 4px 8px;
    3333  border-radius: 8px;
     
    100100    padding-right: 10px;
    101101  }
     102}
     103
     104.wpm-modal-form-tab__terms .wpm-terms-row {
     105  display: flex;
     106  align-items: center;
     107  box-sizing: border-box;
     108  border: 1px solid #e2e4f9;
     109  border-radius: 3px;
     110  padding: 17px 7px;
     111  color: #1f2355;
     112  margin-top: 16px;
     113}
     114.wpm-modal-form-tab__terms .wpm-terms-row.total {
     115  font-weight: bold;
     116  border: none;
     117  padding-bottom: 0;
     118}
     119.wpm-modal-form-tab__terms .wpm-terms-row.active {
     120  border-color: #00023c;
     121}
     122.wpm-modal-form-tab__terms .wpm-terms-row .value {
     123  margin-left: auto;
     124}
     125.wpm-modal-form-tab__terms .wpm-terms-row input[type=radio] {
     126  display: none;
     127}
     128.wpm-modal-form-tab__terms .wpm-terms-row input[type=radio]:checked + .input-placeholder {
     129  background-color: #00023c;
     130  border-color: #00023c;
     131  background-image: url("../img/checkmark.png");
     132  background-position: center center;
     133  background-repeat: no-repeat;
     134}
     135.wpm-modal-form-tab__terms .wpm-terms-row .input-placeholder {
     136  width: 20px;
     137  height: 20px;
     138  border-radius: 20px;
     139  border: 2px solid #D9DBF2;
     140  margin-right: 9px;
    102141}
    103142
     
    424463.wpm-modal-form-tab__dsc a {
    425464  text-decoration: none !important;
    426   color: rgb(52, 58, 235);
     465  color: #000339;
    427466}
    428467.wpm-modal-form-tab__note {
     
    488527.field-group input:not([type=submit]):focus {
    489528  outline: none !important;
     529}
     530.field-group .field-warning {
     531  margin-top: 8px;
     532  box-sizing: border-box;
     533  color: rgb(40, 43, 93);
     534  border-radius: 8px;
     535  display: none;
     536  font-size: 14px;
    490537}
    491538
     
    504551  appearance: none;
    505552  text-decoration: none;
    506   font-weight: 500 !important;
    507   font-size: 14px;
     553  font-weight: 600 !important;
     554  font-size: 16px;
    508555  letter-spacing: 0.02857em;
    509556  min-width: 64px;
    510557  transition: background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, border-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
    511   padding: 3px 16px;
     558  padding: 12px 16px;
    512559  width: auto;
    513   height: 40px;
     560  height: 48px;
    514561  border: 2px solid transparent !important;
    515562  box-shadow: none;
    516   color: rgb(52, 58, 235);
    517   border-radius: 8px;
     563  color: #000339;
     564  border-radius: 4px;
    518565  text-transform: none;
    519566}
     
    526573}
    527574#wpm-modal-form .wpm-btn_primary {
    528   background: rgb(52, 58, 235) !important;
     575  background: #000339 !important;
    529576  color: rgb(255, 255, 255) !important;
    530577}
    531578#wpm-modal-form .wpm-btn_primary:hover {
    532   background: rgb(52, 58, 235) !important;
     579  background: #000339 !important;
    533580  box-shadow: rgba(0, 0, 0, 0.2) 0px 2px 4px -1px, rgba(0, 0, 0, 0.14) 0px 4px 5px 0px, rgba(0, 0, 0, 0.12) 0px 1px 10px 0px !important;
    534581  border-color: transparent !important;
     
    537584  font-weight: 600 !important;
    538585  background: transparent !important;
    539   color: rgb(52, 58, 235) !important;
    540   border-color: rgb(52, 58, 235) !important;
     586  color: #000339 !important;
     587  border-color: #000339 !important;
    541588}
    542589#wpm-modal-form .wpm-btn_outline-primary:hover {
    543   background: rgb(52, 58, 235) !important;
     590  background: #000339 !important;
    544591  color: #fff !important;
    545592}
    546593#wpm-modal-form .wpm-btn:disabled {
    547   color: rgba(0, 0, 0, 0.26) !important;
     594  color: #ffffff !important;
    548595  box-shadow: none !important;
    549   background-color: rgba(0, 0, 0, 0.12) !important;
     596  background-color: #D9DBF2 !important;
    550597  pointer-events: none !important;
    551598  cursor: default !important;
     
    687734  vertical-align: middle;
    688735  animation: spinAround 0.5s infinite linear;
    689   border: 3px solid rgb(52, 58, 235);
     736  border: 3px solid #000339;
    690737  margin-right: 8px;
    691738  border-radius: 290486px;
     
    723770  width: calc(20% - 10px) !important;
    724771  font-size: 38px !important;
    725   color: rgb(52, 58, 235);
     772  color: #000339;
    726773  font-weight: 500 !important;
    727774  text-align: center !important;
     
    735782  border-radius: 50%;
    736783  animation: spinAround 0.5s infinite linear;
    737   border: 4px solid rgb(52, 58, 235);
     784  border: 4px solid #000339;
    738785  border-right-color: transparent;
    739786  border-top-color: transparent;
     
    756803}
    757804
    758 .register-company-tab, .error-confirm-order a, #register-company-tab-2 {
     805.register-company-tab, .error-confirm-order a {
    759806  color: blue;
    760807  cursor: pointer;
     
    762809}
    763810
    764 .register-company-tab:hover, #register-company-tab-2:hover {
     811.register-company-tab:hover {
    765812  text-decoration: none;
    766813}
     
    790837  padding: 0 5px;
    791838}
     839
     840.purchase_approved .wpm-modal-form-tab__dsc {
     841  text-align: center;
     842}
     843.purchase_approved .approved-days {
     844  font-size: 20px;
     845  font-weight: 600;
     846  margin-top: 10px;
     847}
     848
     849/*# sourceMappingURL=frontend.css.map */
  • sprinque/trunk/assets/css/frontend.scss

    r2863342 r2903962  
    11@keyframes spinAround{from{transform:rotate(0)}to{transform:rotate(359deg)}}
    2 $primary_color: rgb(52, 58, 235);
    3 
    4 #register-company-tab, #register-company-tab-2 {
     2//$primary_color: rgb(52, 58, 235);
     3$primary_color: #000339;
     4
     5#register-company-tab {
    56  cursor: pointer;
    67  color: $primary_color;
     
    115116  &::-moz-placeholder          { @content; }
    116117  &:-ms-input-placeholder      { @content; }
     118}
     119
     120.wpm-modal-form-tab__terms {
     121  .wpm-terms-row {
     122    display: flex;
     123    align-items: center;
     124    box-sizing: border-box;
     125    border: 1px solid #e2e4f9;
     126    border-radius: 3px;
     127    padding: 17px 7px;
     128    color: #1f2355;
     129    margin-top: 16px;
     130
     131    &.total {
     132      font-weight: bold;
     133      border: none;
     134      padding-bottom: 0;
     135    }
     136
     137    &.active {
     138      border-color: #00023c;
     139    }
     140
     141    .value {
     142      margin-left: auto;
     143    }
     144
     145    input[type="radio"] {
     146      display: none;
     147
     148      &:checked + .input-placeholder {
     149        background-color: #00023c;
     150        border-color: #00023c;
     151        background-image: url('../img/checkmark.png');
     152        background-position: center center;
     153        background-repeat: no-repeat;
     154      }
     155    }
     156
     157    .input-placeholder {
     158      width:  20px;
     159      height: 20px;
     160      border-radius: 20px;
     161      border: 2px solid #D9DBF2;
     162      margin-right: 9px;
     163    }
     164  }
    117165}
    118166
     
    534582      outline: none !important;
    535583    }
     584  }
     585
     586  .field-warning {
     587    margin-top: 8px;
     588    box-sizing: border-box;
     589    color: rgb(40, 43, 93);
     590    border-radius: 8px;
     591    display: none;
     592    font-size: 14px;
    536593  }
    537594}
     
    673730    appearance: none;
    674731    text-decoration: none;
    675     font-weight: 500 !important;
    676     font-size: 14px;
     732    font-weight: 600 !important;
     733    font-size: 16px;
    677734    letter-spacing: 0.02857em;
    678735    min-width: 64px;
    679736    transition: background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, border-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
    680     padding: 3px 16px;
     737    padding: 12px 16px;
    681738    width: auto;
    682     height: 40px;
     739    height: 48px;
    683740    border: 2px solid transparent !important;
    684741    box-shadow: none;
    685742    color: $primary_color;
    686743
    687     border-radius: 8px;
     744    border-radius: 4px;
    688745    text-transform: none;
    689746    @media screen and (max-width: 575.98px) {
     
    712769    }
    713770    &:disabled {
    714       color: rgba(0, 0, 0, 0.26) !important;
     771      color: #ffffff !important;
    715772      box-shadow: none !important;
    716       background-color: rgba(0, 0, 0, 0.12) !important;
     773      background-color: #D9DBF2 !important;
    717774      pointer-events: none !important;
    718775      cursor: default !important;
     
    9671024}
    9681025
    969 .register-company-tab, .error-confirm-order a, #register-company-tab-2 {
     1026.register-company-tab, .error-confirm-order a {
    9701027  color: blue;
    9711028  cursor: pointer;
     
    9731030}
    9741031
    975 .register-company-tab:hover, #register-company-tab-2:hover {
     1032.register-company-tab:hover {
    9761033  text-decoration: none;
    9771034}
     
    10011058  padding: 0 5px;
    10021059}
     1060
     1061.purchase_approved {
     1062  .wpm-modal-form-tab__dsc {
     1063    text-align: center;
     1064  }
     1065
     1066  .approved-days {
     1067    font-size: 20px;
     1068    font-weight: 600;
     1069    margin-top: 10px;
     1070  }
     1071}
  • sprinque/trunk/assets/js/frontend.js

    r2873134 r2903962  
    55
    66    var countries = [];
     7
     8    function PaymentTermSelect() {
     9        this.payment_terms = window.admin.payment_terms;
     10        this.amount = 0;
     11        this.selected_fee = 0;
     12        this.selected_term = null;
     13        this.eligible_payment_terms = [];
     14
     15        if (typeof this.payment_terms === "undefined") {
     16            this.payment_terms = {};
     17        }
     18    }
     19
     20    PaymentTermSelect.prototype = {
     21        setEligiblePaymentTerms(paymentTerms) {
     22            this.eligible_payment_terms = paymentTerms;
     23        },
     24        setAmount(amount) {
     25            this.amount = amount;
     26            this.recalculateTotal();
     27        },
     28        setSelected(term) {
     29            if (typeof this.payment_terms[term] === "undefined") {
     30                return ;
     31            }
     32
     33            this.selected_fee = this.payment_terms[term];
     34            this.selected_term = term.toUpperCase();
     35
     36            this.recalculateTotal();
     37        },
     38        getPaymentTerm() {
     39            return this.selected_term;
     40        },
     41
     42        update() {
     43            for (let key in this.payment_terms) {
     44                const keyUpper = key.toUpperCase();
     45                if (this.eligible_payment_terms.indexOf(keyUpper) > -1) {
     46                    const availableTermUpperCase = this.eligible_payment_terms[keyUpper];
     47                    const fee = this.payment_terms[key];
     48                    const days = key.replace('net', '');
     49
     50                    if (typeof fee === "undefined") {
     51                        continue;
     52                    }
     53
     54                    $('.wpm-modal-form-tab__terms').append(`
     55                    <label class="wpm-terms-row">
     56                        <input type="radio" name="wpm_net_term" value="${availableTermUpperCase}" data-fee="${fee}" data-term="${key}" />
     57                        <div class="input-placeholder"></div>
     58                        <div class="label">Net ${days} ${window.admin.days}</div>
     59                        <div class="value">${this.calculateWithFee(fee)}</div>
     60                    </label>
     61                `);
     62                }
     63            }
     64        },
     65
     66        calculateWithFee(fee) {
     67            const calculatedFee = ( this.amount * (Number(fee) / 100.0) );
     68
     69            if (calculatedFee === 0.0) {
     70                return 'Free';
     71            }
     72
     73            return '€' + calculatedFee.toFixed(2);
     74        },
     75        recalculateTotal() {
     76            const fee = 1.0 + (Number(this.selected_fee) / 100.0);
     77            const totalWithFee = this.amount * fee;
     78
     79            jQuery('.wpm-terms-row.total .value').text('€' + totalWithFee.toFixed(2));
     80        }
     81    };
     82
     83    const selectPaymentTerm = new PaymentTermSelect();
    784
    885    if ($('#wpm-modal-form').length) {
     
    1289            var modal = $(this).attr('data-wpm-close');
    1390            hidePopup(modal);
     91        });
     92
     93        $('body').on('change', '.wpm-terms-row input[type="radio"]', function () {
     94            const terms = jQuery(this).closest('.wpm-modal-form-tab__terms');
     95            jQuery('.active', terms).removeClass('active');
     96            jQuery(this).closest('.wpm-terms-row').addClass('active');
     97            jQuery('.confirm-order-term').removeAttr('disabled');
     98
     99            recalculateTotal();
     100        });
     101
     102        $('body').on('click', '.confirm-order-term', function () {
     103            $(this).attr('disabled', 'disabled');
     104
     105            authorize_company_payment(function () {
     106                $('.choose_another_payment_method').trigger( "click" );
     107                orderPayed = true;
     108                $('#place_order').trigger( "click" );
     109            }, {
     110                payment_terms: selectPaymentTerm.getPaymentTerm()
     111            });
    14112        });
    15113
     
    53151    }
    54152
     153    function recalculateTotal() {
     154        if (jQuery('.wpm-terms-row.active').length < 1) {
     155            return ;
     156        }
     157
     158        selectPaymentTerm.setSelected(jQuery('.wpm-terms-row.active input:checked').attr('data-term'));
     159    }
     160
    55161    function checkRegisterFields()
    56162    {
     
    74180      $(elem).removeClass('modal-middle');
    75181      $('.error-confirm-order').hide();
     182      // showTab('.select_payment_term');
    76183    }
    77184
     
    143250
    144251    function showTab(el) {
    145         $(el).show(0).siblings().hide(0);
     252        $(el).siblings().hide();
     253        $(el).show();
    146254    }
    147255
     
    289397
    290398    $("body").on("input", "#reg_number_pay", function(event) {
     399        const country_code = $('#select_country_pay').val().toLowerCase();
     400        const reg_number = $(this).val();
     401        let language = document.documentElement.lang;
     402        language = language.replace('_', '-');
     403        language = language.split('-');
     404        language = language.shift();
     405        const validation = Sprinque.checkRegNumber(reg_number, country_code, language);
     406
     407        if (!validation.isValid) {
     408            $('#reg_number_warning')
     409                .show()
     410                .text(validation.message);
     411        } else {
     412            $('#reg_number_warning').hide();
     413        }
     414
    291415        $('.error-confirm-order').hide();
    292416    });
     
    305429        $('#reg_number_pay').val(company_reg_code);
    306430        $('#confirm-company-order').prop('disabled', false);
     431
     432        $('#reg_number_pay').trigger('input');
    307433    });
    308434
     
    345471    });
    346472
    347     $("body").on("click", "#register-company-tab, #register-company-tab-2, .register-company-tab, .js-register-company-tab", function(event) {
     473    $("body").on("click", "#register-company-tab, .company-item-404, .register-company-tab, .js-register-company-tab", function(event) {
    348474        event.preventDefault();
    349475        var reg_number = $('#reg_number_pay').val();
     
    736862            success: function (response) {
    737863                if(response.status === true) {
    738                     showTab('.placing_your_order');
    739                     setTimeout(function() {
    740                         $('#days-review').html(response.days);
    741                         showTab('.purchase_approved');
    742                     }, 1000);
     864                    if (response.eligible_payment_terms.length > 1) {
     865                        selectPaymentTerm.setEligiblePaymentTerms(response.eligible_payment_terms);
     866                        selectPaymentTerm.setAmount(Number(response.total));
     867                        selectPaymentTerm.update();
     868
     869                        showTab('.select_payment_term');
     870                    } else {
     871
     872                        showTab('.placing_your_order');
     873                        setTimeout(function() {
     874                            $('#days-review').html(response.days);
     875                            const paymentTerm = response.eligible_payment_terms[0];
     876                            $('.approve-place-order').attr('data-term', paymentTerm);
     877                            showTab('.purchase_approved');
     878                        }, 1000);
     879                    }
    743880                } else if(response.status === false) {
    744881                    if(response.credit_decision === 'MANUAL_REVIEW' || response.credit_decision === 'PENDING') {
     
    773910    }
    774911
    775     function authorize_company_payment(callback)
     912    function authorize_company_payment(callback, params = {})
    776913    {
    777914        var address_line1 = $('#billing_address_1').val();
     
    795932                    'country_code': country_code,
    796933                    'email': email,
    797                     'nonce': admin.nonce
     934                    'nonce': admin.nonce,
     935                    'payment_terms': typeof params.payment_terms !== "undefined" ? params.payment_terms : null
    798936                },
    799937                type: 'POST',
     
    811949                            var modal_class = 'modal-middle';
    812950
     951                            showTab('.verifying_your_account');
    813952                            $('.cant-complete-autorization').show();
    814953                            $('.placing_your_order').hide();
    815                             $('.verifying_your_account').show();
    816954                            $('.verifying_your_account .wpm-loader_my1').hide();
    817955                            $('.verify-error-explanation, .verify-error').hide();
     
    8661004    $("body").on("click", ".approve-place-order", function(event) {
    8671005        showTab('.placing_your_order');
    868         setTimeout(function() {
     1006        const paymentTerm = $(this).attr('data-term');
     1007            setTimeout(function() {
    8691008            authorize_company_payment(function () {
    8701009                $('.choose_another_payment_method').trigger( "click" );
    8711010                orderPayed = true;
    8721011                $('#place_order').trigger( "click" );
    873             });
     1012            }, { payment_terms: paymentTerm });
    8741013        }, 1000);
    8751014    });
  • sprinque/trunk/include/payment_method.php

    r2877020 r2903962  
    246246            $merchant_buyer_id = time();
    247247            $email = sanitize_text_field( $_POST['email'] );
    248             $phone = sanitize_text_field( $_POST['phone'] );
     248            $phone_number = sanitize_text_field($_POST['phone']);
     249            $phone_number = str_replace(' ', '', $phone_number);
     250            $phone = $phone_number;
    249251            $country = sanitize_text_field( $_POST['country_code'] );
    250252            $business_name = sanitize_text_field( $_POST['business_name'] );
     
    258260                'business_name'       => stripslashes($business_name),
    259261                'registration_number' => sanitize_text_field( $_POST['registration_number'] ),
    260                 'phone' => sanitize_text_field( $_POST['phone'] ),
     262                'phone' => $phone_number,
    261263                'address'             => [
    262264                    'address_line1' => sanitize_text_field( $_POST['address_line1'] ),
     
    278280                        'last_name'  => sanitize_text_field( $_POST['last_name'] ),
    279281                        'email'      => $email,
    280                         'phone' => sanitize_text_field( $_POST['phone'] ),
     282                        'phone' => $phone_number,
    281283                        'role'       => 'MEMBER'
    282284                    ]
     
    394396            $ip = $this->get_ip_address();
    395397
    396             // Prepare Data to Send
    397             $data = [
     398            // Prepare Data to Send
     399            $data = [
    398400                'merchant_order_id' => sanitize_text_field($_SESSION['order_id']),
    399401                'order_amount'      => WC()->cart->total,
     
    411413            ];
    412414
     415            if (isset($_POST['payment_terms']) && $_POST['payment_terms'] !== null) {
     416                $payment_term = sanitize_text_field($_POST['payment_terms']);
     417                $data['payment_terms'] = $payment_term;
     418                $payment_term_lower = strtolower($payment_term);
     419
     420                $payment_terms = wp_cache_get('sprinque_available_payment_terms');
     421                if ( !$payment_terms ) {
     422                    $payment_terms = [];
     423                }
     424                $fee = $payment_terms[$payment_term_lower] ?? 0.0;
     425
     426                if ($fee > 0.0) {
     427                    $fee /= 100.0;
     428                    $data['order_amount'] *= 1.0 + $fee;
     429                }
     430            }
     431
    413432            // Get Data from API
    414433            $result = $this->srinque_api( $data, 'POST', "/transactions/authorize/{$buyer_id}" );
     
    431450                $_SESSION['review_order'] = sanitize_text_field($buyer_id);
    432451                unset( $_SESSION['transaction_id'] );
     452                unset( $_SESSION['net_term'] );
    433453
    434454                wp_send_json( [
     
    440460                // Prepare Data to Create Order
    441461                $_SESSION['transaction_id'] = sanitize_text_field($result['transaction_id']);
     462                $_SESSION['net_term'] = sanitize_text_field($result['payment_terms']);
    442463                unset( $_SESSION['review_order'] );
    443464
     
    471492            $buyer = $this->srinque_api( [], 'GET', "/buyers/{$buyer_id}" );
    472493            $days = isset($buyer['credit_qualification']['payment_terms']) ? str_replace('NET', '', $buyer['credit_qualification']['payment_terms']) : 30;
     494            $eligible_payment_terms = $buyer['credit_qualification']['eligible_payment_terms'];
    473495
    474496            $credit_decision = $buyer['credit_qualification']['credit_decision'];
     
    479501                'days'    => $days,
    480502                'credit_decision' => $credit_decision ?? 'MANUAL_REVIEW',
     503                'eligible_payment_terms' => $eligible_payment_terms,
     504                'total'   => WC()->cart->get_total('float'),
    481505                'message' => sprintf(__("You have been approved for a payment term of %s days by Sprinque!", "sprinque"), $days)
    482506            ] );
     
    503527            $_SESSION['review_order'] = sanitize_text_field($buyer_id);
    504528            unset( $_SESSION['transaction_id'] );
     529            unset( $_SESSION['net_term'] );
    505530
    506531            wp_send_json([
     
    732757                update_post_meta( $order_id, 'transaction_id', sanitize_text_field($_SESSION['transaction_id']) );
    733758                update_post_meta( $order_id, 'merchant_order_id', sanitize_text_field($_SESSION['order_id']) );
     759
    734760                $order->update_status( 'processing', __( 'Pay by Invoice - Business only', 'sprinque' ) );
    735761            }
     762
     763            if ( isset( $_SESSION['net_term'] ) ) {
     764                update_post_meta( $order_id, 'net_term', sanitize_text_field($_SESSION['net_term']) );
     765            }
     766
     767            if ( isset( $_SESSION['surcharge_fee'] ) ) {
     768                update_post_meta( $order_id, 'buyer_fee_percentage', sanitize_text_field($_SESSION['surcharge_fee']) );
     769            }
     770
     771            unset($_SESSION['net_term']);
     772            unset($_SESSION['surcharge_fee']);
    736773
    737774            // Reduce stock levels
  • sprinque/trunk/languages/sprinque-de_DE.po

    r2877020 r2903962  
    99
    1010#: templates/frontend/srinque_pay_modal_form.php:102
    11 #, fuzzy
    1211msgid "(in :sec seconds)"
    13 msgstr "(in :sec sekunden)"
     12msgstr "(in :sec Sekunden)"
    1413
    1514#: sprinque.php:442 templates/ajax/founded_companies.php:22
     
    9190#: sprinque.php:440 templates/ajax/founded_companies.php:3
    9291msgid "Company not found"
    93 msgstr "Firma nicht gefunden"
     92msgstr "Firma nicht gefunden?"
    9493
    9594#: templates/frontend/srinque_pay_modal_form.php:29
     
    108107msgstr "Stornierung bestätigen"
    109108
     109#: templates/frontend/srinque_pay_modal_form.php:137
     110msgid "Confirm order"
     111msgstr "Bestellung bestätigen"
     112
     113#: templates/frontend/srinque_pay_modal_form.php:129
     114msgid "Congratulations!"
     115msgstr "Herzlichen Glückwunsch!"
     116
    110117#: templates/frontend/srinque_pay_modal_form.php:107
    111118#: templates/frontend/srinque_pay_modal_form.php:114
     
    116123msgid "Country"
    117124msgstr "Land"
     125
     126#: sprinque.php:546
     127msgid "days"
     128msgstr "Tage"
    118129
    119130#: templates/frontend/srinque_pay_modal_form.php:100
     
    255266msgstr "um es trotzdem zu benutzen"
    256267
     268#: templates/frontend/srinque_pay_modal_form.php:133
     269msgid "Total amount"
     270msgstr "Gesamtbetrag"
     271
    257272msgid "VAT ID"
    258273msgstr "USt-IdNr."
     
    282297msgid "You have been approved for a payment term of %s days by Sprinque!"
    283298msgstr "Du wurdest von Sprinque für ein Zahlungsziel von %s Tagen zugelassen!"
     299
     300#: templates/frontend/srinque_pay_modal_form.php:130
     301msgid "You've been approved to pay with net terms. Select the payment term that best suits your company"
     302msgstr "Sie wurden für die Zahlung auf Rechnung zugelassen. Wählen Sie das Zahlungsziel, das am besten zu Ihrem Unternehmen passt"
  • sprinque/trunk/languages/sprinque-en_US.po

    r2873134 r2903962  
    105105#: sprinque.php:440 templates/ajax/founded_companies.php:3
    106106msgid "Company not found"
    107 msgstr "Company not found"
     107msgstr "Company not found?"
    108108
    109109#: templates/frontend/srinque_pay_modal_form.php:31
     
    304304msgstr "Title"
    305305
     306#: templates/frontend/srinque_pay_modal_form.php:129
     307msgid "Congratulations!"
     308msgstr "Congratulations!"
     309
     310#: templates/frontend/srinque_pay_modal_form.php:130
     311msgid "You've been approved to pay with net terms. Select the payment term that best suits your company"
     312msgstr "You've been approved to pay with net terms. Select the payment term that best suits your company"
     313
     314#: templates/frontend/srinque_pay_modal_form.php:133
     315msgid "Total amount"
     316msgstr "Total amount"
     317
     318#: templates/frontend/srinque_pay_modal_form.php:137
     319msgid "Confirm order"
     320msgstr "Confirm order"
     321
     322#: sprinque.php:546
     323msgid "days"
     324msgstr "days"
     325
     326#: sprinque.php:259
     327#: sprinque.php:451
     328msgid "Net terms fee"
     329msgstr "Net terms fee"
  • sprinque/trunk/languages/sprinque-es_ES.po

    r2877020 r2903962  
    99
    1010#: templates/frontend/srinque_pay_modal_form.php:102
    11 #, fuzzy
    1211msgid "(in :sec seconds)"
    1312msgstr "(en :sec segundos)"
     
    9190#: sprinque.php:440 templates/ajax/founded_companies.php:3
    9291msgid "Company not found"
    93 msgstr "Empresa no encontrada"
     92msgstr "Empresa no encontrada?"
    9493
    9594#: templates/frontend/srinque_pay_modal_form.php:29
     
    108107msgstr "Confirmar anulación"
    109108
     109#: templates/frontend/srinque_pay_modal_form.php:137
     110msgid "Confirm order"
     111msgstr "Confirmar pedido"
     112
     113#: templates/frontend/srinque_pay_modal_form.php:129
     114msgid "Congratulations!"
     115msgstr "¡Felicidades!"
     116
    110117#: templates/frontend/srinque_pay_modal_form.php:107
    111118#: templates/frontend/srinque_pay_modal_form.php:114
     
    117124msgstr "País"
    118125
     126#: sprinque.php:546
     127msgid "days"
     128msgstr "días"
     129
    119130#: templates/frontend/srinque_pay_modal_form.php:100
    120131msgid "days by Sprinque!"
     
    253264msgstr "usarlo de todos modos"
    254265
     266#: templates/frontend/srinque_pay_modal_form.php:133
     267msgid "Total amount"
     268msgstr "La cantidad total"
     269
    255270msgid "VAT ID"
    256271msgstr "VAT ID"
     
    280295msgid "You have been approved for a payment term of %s days by Sprinque!"
    281296msgstr "Sprinque le ha aprobado un plazo de pago de %s días."
     297
     298#: templates/frontend/srinque_pay_modal_form.php:130
     299msgid "You've been approved to pay with net terms. Select the payment term that best suits your company"
     300msgstr "Has sido aprobado para pagar con factura. Selecciona el plazo de pago que mejor se adapte a su empresa"
  • sprinque/trunk/languages/sprinque-fr_FR.po

    r2877020 r2903962  
    99
    1010#: templates/frontend/srinque_pay_modal_form.php:102
    11 #, fuzzy
     11
     12
    1213msgid "(in :sec seconds)"
    1314msgstr "(en :sec secondes)"
     
    9192#: sprinque.php:440 templates/ajax/founded_companies.php:3
    9293msgid "Company not found"
    93 msgstr "Société introuvable"
     94msgstr "Société introuvable?"
    9495
    9596#: templates/frontend/srinque_pay_modal_form.php:29
     
    108109msgstr "Confirmer l'annulation"
    109110
     111#: templates/frontend/srinque_pay_modal_form.php:137
     112
     113
     114msgid "Confirm order"
     115msgstr "Confirmer la commande"
     116
     117#: templates/frontend/srinque_pay_modal_form.php:129
     118
     119
     120msgid "Congratulations!"
     121msgstr "Félicitations !"
     122
    110123#: templates/frontend/srinque_pay_modal_form.php:107
    111124#: templates/frontend/srinque_pay_modal_form.php:114
     
    117130msgstr "Pays"
    118131
     132#: sprinque.php:546
     133
     134
     135msgid "days"
     136msgstr "jours"
     137
    119138#: templates/frontend/srinque_pay_modal_form.php:100
    120139msgid "days by Sprinque!"
     
    253272msgstr "de l'utiliser quand même"
    254273
     274#: templates/frontend/srinque_pay_modal_form.php:133
     275
     276
     277msgid "Total amount"
     278msgstr "Montant total"
     279
    255280msgid "VAT ID"
    256281msgstr "NUMÉRO DE TVA"
     
    280305msgid "You have been approved for a payment term of %s days by Sprinque!"
    281306msgstr "Vous avez été approuvé pour un délai de paiement de %s jours par Sprinque !"
     307
     308#: templates/frontend/srinque_pay_modal_form.php:130
     309
     310
     311msgid "You've been approved to pay with net terms. Select the payment term that best suits your company"
     312msgstr "Vous avez été autorisé à payer avec des conditions nettes. Sélectionnez le délai de paiement qui convient le mieux à votre entreprise"
  • sprinque/trunk/languages/sprinque-nl_NL.po

    r2877020 r2903962  
    99
    1010#: templates/frontend/srinque_pay_modal_form.php:102
    11 #, fuzzy
    1211msgid "(in :sec seconds)"
    1312msgstr "(in :sec seconden)"
     
    9190#: sprinque.php:440 templates/ajax/founded_companies.php:3
    9291msgid "Company not found"
    93 msgstr "Bedrijf niet gevonden"
     92msgstr "Bedrijf niet gevonden?"
    9493
    9594#: templates/frontend/srinque_pay_modal_form.php:29
     
    108107msgstr "Annuleren bevestigen"
    109108
     109#: templates/frontend/srinque_pay_modal_form.php:137
     110msgid "Confirm order"
     111msgstr "Bevestig bestelling"
     112
     113#: templates/frontend/srinque_pay_modal_form.php:129
     114msgid "Congratulations!"
     115msgstr "Gefeliciteerd!"
     116
    110117#: templates/frontend/srinque_pay_modal_form.php:107
    111118#: templates/frontend/srinque_pay_modal_form.php:114
     
    117124msgstr "Land"
    118125
     126#: sprinque.php:546
     127#, fuzzy
     128msgid "days"
     129msgstr "dagen"
     130
    119131#: templates/frontend/srinque_pay_modal_form.php:100
    120132msgid "days by Sprinque!"
     
    253265msgstr "om alsnog te gebruiken"
    254266
     267#: templates/frontend/srinque_pay_modal_form.php:133
     268msgid "Total amount"
     269msgstr "Totaal bedrag"
     270
    255271msgid "VAT ID"
    256272msgstr "BTW-NUMMER"
     
    280296msgid "You have been approved for a payment term of %s days by Sprinque!"
    281297msgstr "Je bent goedgekeurd voor een betalingstermijn van %s dagen door Sprinque!"
     298
     299#: templates/frontend/srinque_pay_modal_form.php:130
     300msgid "You've been approved to pay with net terms. Select the payment term that best suits your company"
     301msgstr "Je bent goedgekeurd om met netto termijnen te betalen. Selecteer de betalingstermijn die het beste bij jouw bedrijf past"
  • sprinque/trunk/readme.txt

    r2877020 r2903962  
    66Tested up to: 6.0
    77Requires PHP: 5.3
    8 Stable tag: 1.2.7
     8Stable tag: 1.3.0
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    5050
    5151== Changelog ==
     52
     53= 1.3.0 - April 25, 2023 =
     54* Passing Sprinque fee to buyers;
     55* Registration number warnings;
     56* Remove spaces in buyer phone;
     57* Updated "Company not found" styles and made it clickable;
    5258
    5359= 1.2.7 - March 8, 2023 =
  • sprinque/trunk/sprinque.php

    r2877020 r2903962  
    55Description: Sprinque for WordPress is a plugin that allows you to offer your business buyers net payment terms (15, 30, 60, 90 days) and thereby grow conversion and retention.
    66Author: Sprinque
    7 Version: 1.2.7
     7Version: 1.3.0
    88Text Domain: sprinque
    99Domain Path: /languages
    1010*/
    1111
    12 define( 'PLUGIN_SRINQUE_VERSION', '1.2.7' );
     12define( 'PLUGIN_SRINQUE_VERSION', '1.3.0' );
    1313define( 'PLUGIN_SRINQUE_DIR', __DIR__ );
    1414define( 'PLUGIN_SRINQUE_PATH', plugins_url( '', __FILE__ ) );
     
    6969
    7070    public function __construct() {
     71        $this->get_payment_terms();
     72
    7173        // Include Styles and Scripts
    7274        add_action( 'wp_enqueue_scripts', [ $this, 'include_scripts_and_styles' ], 99 );
     
    8688        add_action( 'woocommerce_order_refunded', [ $this, 'send_refund_captured_order' ], 10, 1 );
    8789        add_action( 'woocommerce_update_order', [ $this, 'send_refund_voided_order' ], 10, 1 );
     90        add_action( 'woocommerce_cart_calculate_fees', [ $this, 'calculate_fees' ] );
    8891
    8992        // Initialize RestAPI
     
    227230            $response = $this->srinque_api( $data, 'POST', "/transactions/void/{$transaction_id}" );
    228231        }
     232    }
     233
     234    public function calculate_fees()
     235    {
     236        global $woocommerce;
     237
     238        if ( is_admin() && ! defined( 'DOING_AJAX' ) )
     239            return;
     240
     241        if ( ! session_id() ) {
     242            session_cache_limiter('public');
     243            session_start();
     244        }
     245
     246        if ( !isset( $_SESSION['net_term'] ) ) {
     247            return;
     248        }
     249
     250        $net_term = $_SESSION['net_term'];
     251        $net_term = strtolower($net_term);
     252        $payment_terms = $this->get_payment_terms();
     253        $percentage = $payment_terms[$net_term] ?? 0.0;
     254        $_SESSION['surcharge_fee'] = $percentage;
     255        $percentage /= 100;
     256
     257        if ($percentage > 0) {
     258            $surcharge = ( $woocommerce->cart->cart_contents_total + $woocommerce->cart->shipping_total ) * $percentage;
     259            $woocommerce->cart->add_fee( __('Net terms fee', 'sprinque'), $surcharge, true, '' );
     260        }
    229261    }
    230262
     
    362394                    $ip_address = get_post_meta( $order->get_id(), 'ip_address', true );
    363395
     396                    // Calculate order total
     397                    $payment_term = sanitize_text_field( $webhook['credit_qualification']['payment_terms'] );
     398                    $payment_terms = $this->get_payment_terms();
     399                    $total = $order->get_total();
     400                    $fee = $payment_terms[ strtolower($payment_term) ];
     401                    $fee_percents = floatval($fee) / 100;
     402                    $calculated_fee = $total * $fee_percents;
     403                    $total += $calculated_fee;
     404
    364405                    // Prepare Data to Send
    365406                    $data = [
    366407                        'merchant_order_id' =>  ( $order_id_from_sequential_plugin ?: $order->get_id() ) . '_wh',
    367                         'order_amount'      => $order->get_total(),
     408                        'order_amount'      => $total,
     409                        'payment_terms'     => $payment_term,
    368410                        'shipping_address'  => [
    369411                            'address_line1' => $order->get_billing_address_1(),
     
    394436
    395437                    if (isset($result['transaction_id'])) {
     438
    396439                        update_post_meta( $order->ID, 'transaction_id', $result['transaction_id'] );
    397440                        update_post_meta( $order->ID, 'merchant_order_id', $order->ID );
     441
     442                        update_post_meta( $order->ID,  'net_term', $payment_term );
     443                        update_post_meta( $order->ID,  'buyer_fee_percentage', $fee );
     444
    398445                        $order = new WC_Order( $order->ID );
    399446                        $order->update_status($status);
     447
     448                        // Add fee if needed
     449                        if ($fee_percents > 0.0) {
     450                            $fee = new stdClass();
     451                            $fee->name = __('Net terms fee', 'sprinque');
     452                            $fee->amount = $calculated_fee;
     453                            $fee->tax_status = 'taxable';
     454                            $fee->total = $calculated_fee;
     455
     456                            $order->add_fee($fee);
     457                            $order->calculate_totals();
     458                        }
     459
     460                        // Save the order
    400461                        $order->save();
    401462                    }
     
    500561            // Register scripts
    501562            $settings = get_option( 'woocommerce_wpm_srinque_pay_settings', true );
    502             wp_enqueue_script( 'wpm_srinque_pay', PLUGIN_SRINQUE_PATH . '/assets/js/frontend.js', array( 'jquery' ), PLUGIN_SRINQUE_VERSION, 'all' );
     563            wp_enqueue_script( 'wpm_srinque_tools', 'https://unpkg.com/b2b-sprinque-tools@1.0.0/dist/index.umd.min.js', array( ), PLUGIN_SRINQUE_VERSION, 'all' );
     564            wp_enqueue_script( 'wpm_srinque_pay', PLUGIN_SRINQUE_PATH . '/assets/js/frontend.js', array( 'jquery', 'wpm_srinque_tools' ), PLUGIN_SRINQUE_VERSION, 'all' );
    503565
    504566            wp_localize_script( 'wpm_srinque_pay', 'admin', array(
     
    515577                'loading' => __( "Loading...", 'sprinque' ),
    516578                'place_order' => __( "Place order", 'sprinque' ),
     579                'days' => __('days', 'sprinque'),
     580                'payment_terms' => $this->get_payment_terms()
    517581            ) );
    518582        }
     583    }
     584
     585    public function get_payment_terms()
     586    {
     587        $payment_terms = wp_cache_get('sprinque_available_payment_terms');
     588        if ( !$payment_terms ) {
     589            $payment_terms = $this->srinque_api([], 'GET', "/seller/pricing");
     590            $payment_terms = $payment_terms['buyer_pricing_fee_percent'];
     591            if (!is_array($payment_terms)) {
     592                return [];
     593            }
     594
     595            wp_cache_add('sprinque_available_payment_terms', $payment_terms, '', 300);
     596        }
     597
     598        return $payment_terms;
    519599    }
    520600
  • sprinque/trunk/templates/frontend/srinque_pay_modal_form.php

    r2863342 r2903962  
    4444                        <label><?php _e( "Registration number", 'sprinque' ); ?>*</label>
    4545                        <input type="text" id="reg_number_pay" placeholder="<?php _e( "Registration number", 'sprinque' ); ?>">
     46                        <div class="field-warning" id="reg_number_warning">
     47                            Some text here
     48                        </div>
    4649                    </div>
    4750
     
    126129                </div>
    127130
     131                <div class="select_payment_term" style="display: none;">
     132                    <div class="wpm-modal-form-tab__title"><?php _e( "Congratulations!", 'sprinque' ); ?></div>
     133                    <div class="wpm-modal-form-tab__dsc"><?php _e( "You've been approved to pay with net terms. Select the payment term that best suits your company", 'sprinque' ); ?></div>
     134                    <div class="wpm-modal-form-tab__terms">
     135                        <div class="wpm-terms-row total">
     136                            <div class="label"><?php _e("Total amount", 'sprinque'); ?></div>
     137                            <div class="value">€00.00</div>
     138                        </div>
     139                    </div>
     140                    <button class="wpm-btn wpm-btn_primary wpm-btn_mt wpm-btn_block confirm-order-term" disabled><?php _e( "Confirm order", 'sprinque' ); ?></button>
     141                </div>
     142
    128143                <div class="purchase_approved" style="display: none;">
    129144                    <div class="wpm-modal-form-tab__title"><?php _e( "Purchase approved", 'sprinque' ); ?></div>
    130                     <div class="wpm-modal-form-tab__dsc"><?php _e( "You have been approved for a payment term of", 'sprinque' ); ?> <span id="days-review"></span> <?php _e( "days by Sprinque!", 'sprinque' ); ?></div>
    131                     <a class="wpm-btn wpm-btn_primary wpm-btn_mt-2 wpm-btn_block approve-place-order"><?php _e( "Place order", 'sprinque' ); ?></a>
     145                    <div class="wpm-modal-form-tab__dsc">
     146                        <div>
     147                            <?php _e( "Your account has been created and you’ve been approved for a payment term of:", 'sprinque' ); ?>
     148                        </div>
     149                        <div class="approved-days">
     150                            <span id="days-review"></span> <?php _e( "days", 'sprinque' ); ?>
     151                        </div>
     152                    </div>
     153                    <a class="wpm-btn wpm-btn_primary wpm-btn_mt-2 wpm-btn_block approve-place-order"><?php _e( "Confirm order", 'sprinque' ); ?></a>
    132154                </div>
    133155
Note: See TracChangeset for help on using the changeset viewer.