Plugin Directory

Changeset 3187287


Ignore:
Timestamp:
11/13/2024 09:37:54 AM (16 months ago)
Author:
9pay
Message:

Update installment to plugin

Location:
9pay-gateway/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • 9pay-gateway/trunk/admin/js/mc-ninepay-admin.js

    r2919019 r3187287  
    1919
    2020        jQuery( '.ninepay-percent' ).parents( 'fieldset' ).find( 'legend' ).replaceWith( '<div><p style="margin-right: 30px;">Tính phí người mua</p></div>' );
     21        jQuery( '.ninepay-percent-installment' ).parents( 'fieldset' ).find( 'legend' ).replaceWith( '<div><p style="margin-right: 30px;">Số tiền thanh toán trả góp tối thiểu</p></div>' );
     22        jQuery( '.ninepay-percent-installment' ).attr( "min" , "3000000" )
     23        jQuery( '.ninepay-percent-installment' ).attr("required",true)
    2124    }
    2225);
  • 9pay-gateway/trunk/includes/gateways/class-ninepaygateway.php

    r2919019 r3187287  
    245245                'placeholder'       => 'Phí cố định (Ví dụ: 2000)',
    246246                'default'           => 0,
     247                'custom_attributes' => array(
     248                    'onkeypress' => 'return nineMethodPercent(event, this)',
     249                ),
     250            ),
     251
     252            'ninepay_payment_method_installment'               => array(
     253                'desc_tip' => true,
     254                'class'    => 'pb-0',
     255                'type'     => 'checkbox',
     256                'label'    => __( 'Trả góp với thẻ quốc tế', 'woocommerce' ),
     257                'default'  => 'no',
     258            ),
     259            'ninepay_payment_method_installment_fee_percent'   => array(
     260                'class'             => 'ninepay-element-collection ninepay-percent pt-0',
     261                'text'              => 'text',
     262                'description'       => __( '%   +', 'woocommerce' ),
     263                'placeholder'       => 'Phí % giá bán (Ví dụ: 1.8)',
     264                'default'           => 0,
     265                'custom_attributes' => array(
     266                    'onkeypress' => 'return nineMethodPercent(event, this)',
     267                ),
     268            ),
     269            'ninepay_payment_method_installment_fee_fixed'     => array(
     270                'class'             => 'ninepay-element-collection ninepay-fixed pt-0',
     271                'text'              => 'text',
     272                'placeholder'       => 'Phí cố định (Ví dụ: 2000)',
     273                'default'           => 0,
     274                'custom_attributes' => array(
     275                    'onkeypress' => 'return nineMethodPercent(event, this)',
     276                ),
     277            ),
     278            'ninepay_payment_method_installment_min_amount'     => array(
     279                'class'             => 'ninepay-percent-installment pb-0',
     280                'text'              => 'text',
     281                'placeholder'       => 'Số tiền thanh toán trả góp tối thiểu',
     282                'default'           => 3000000,
     283                'type'              => 'number',
    247284                'custom_attributes' => array(
    248285                    'onkeypress' => 'return nineMethodPercent(event, this)',
  • 9pay-gateway/trunk/includes/gateways/core/class-ninepaypayment.php

    r2919019 r3187287  
    5555
    5656        if ( ! empty( $payment_method ) ) {
    57             $data['method'] = $payment_method;
     57            if ($payment_method === NinePayConstance::METHOD_INSTALLMENT) {
     58                $data['method'] = NinePayConstance::METHOD_CREDIT;
     59                $data['transaction_type'] = "INSTALLMENT";
     60            } else {
     61                $data['method'] = $payment_method;
     62            }
    5863        }
    5964
  • 9pay-gateway/trunk/includes/gateways/core/lang.php

    r2919019 r3187287  
    1919        NinePayConstance::METHOD_COLLECTION => 'Chuyển khoản ngân hàng',
    2020        NinePayConstance::METHOD_BNPL       => 'Mua trước trả sau',
     21        NinePayConstance::METHOD_INSTALLMENT       => 'Trả góp với thẻ quốc tế',
    2122
    2223        'description_payment_method'        => 'Hãy chọn phương thức thanh toán',
     
    3132        NinePayConstance::METHOD_COLLECTION => 'Bank transfer',
    3233        NinePayConstance::METHOD_BNPL       => 'Buy now Pay later',
     34        NinePayConstance::METHOD_INSTALLMENT       => 'Installment payment via credit card',
    3335
    3436        'description_payment_method'        => 'Please choose payment method',
  • 9pay-gateway/trunk/includes/gateways/core/lib/class-ninepayconstance.php

    r2919019 r3187287  
    2828    const METHOD_COLLECTION = 'COLLECTION';
    2929    const METHOD_BNPL       = 'BUY_NOW_PAY_LATER';
     30    const METHOD_INSTALLMENT       = 'INSTALLMENT';
    3031}
  • 9pay-gateway/trunk/mc-ninepay.php

    r3160196 r3187287  
    277277        }
    278278
     279        /*collection*/
     280        if ( $settings['ninepay_payment_method_collection'] === 'yes' ) {
     281            $result[ NinePayConstance::METHOD_COLLECTION ] = $config_lang[ $lang ][ NinePayConstance::METHOD_COLLECTION ];
     282        }
     283
     284        /*collection*/
     285        if ( $settings['ninepay_payment_method_installment'] === 'yes' ) {
     286            $result[ NinePayConstance::METHOD_INSTALLMENT ] = $config_lang[ $lang ][ NinePayConstance::METHOD_INSTALLMENT ];
     287        }
     288
    279289        return $result;
    280290    }
     
    340350    function ninepay_add_checkout_script() {
    341351        global $woocommerce;
     352        $ninepay        = new NinePayGateway();
     353        $payment_config = $ninepay->settings;
    342354        $language              = get_locale();
    343355        $config_file           = include 'includes/gateways/core/config.php';
     
    359371        $min_amount_bnpl_vnd = $config_file['min_amount_bnpl_vnd'];
    360372        $max_amount_bnpl_vnd = $config_file['max_amount_bnpl_vnd'];
     373
     374        $min_amount_intallment_vnd = $payment_config['ninepay_payment_method_installment_min_amount'];
    361375        ?>
    362376        <script type="text/javascript">
     
    381395            let maxAmountBnplVnd = parseFloat("<?php echo esc_html( $max_amount_bnpl_vnd ); ?>");
    382396
     397            let minAmountIntallmentVnd = parseFloat("<?php echo esc_html( $min_amount_intallment_vnd ); ?>");
    383398
    384399            jQuery(document).on("updated_checkout", function(){
     
    552567                    }
    553568
     569                    if (paymentMethod === "INSTALLMENT" && currency === "VND") {
     570                        if (totalCart < minAmountIntallmentVnd) {
     571                            let errorMessage = '';
     572                            if (language === 'vi') {
     573                                errorMessage = `Số tiền tối thiểu thanh toán trả góp là ${minAmountIntallmentVnd.toLocaleString()} đ. Vui lòng chọn phương thức thanh toán khác.`;
     574                            } else {
     575                                errorMessage = `The minimum amount accepted for installment payment via credit card is ${minAmountIntallmentVnd.toLocaleString()} VND. Please choose another payment method.`;
     576                            }
     577                            let error = `<div class="woocommerce-NoticeGroup woocommerce-NoticeGroup-checkout">
     578                                    <ul class="woocommerce-error" role="alert">
     579                                        <li>${errorMessage}</li>
     580                                    </ul>
     581                                </div>`;
     582                            ninePayShowError(error);
     583                            e.preventDefault();
     584                        }
     585                    }
     586
    554587                    if (currency !== "VND") {
    555588                        let minAmountWalletForeign = Number((minAmountWalletVnd / excRate).toFixed(2));
     
    566599                        let minAmountBnplForeign = Number((minAmountBnplVnd / excRate).toFixed(2));
    567600                        let maxAmountBnplForeign = Number((maxAmountBnplVnd / excRate).toFixed(2));
     601
     602                        let minAmountIntallmentForeign = Number((minAmountIntallmentVnd / excRate).toFixed(2));
    568603
    569604                        if (paymentMethod === "WALLET") {
     
    712747                                    </ul>
    713748                                </div>`;
     749                                ninePayShowError(error);
     750                                e.preventDefault();
     751                            }
     752                        }
     753
     754                        if (paymentMethod === "INSTALLMENT") {
     755                            if (totalCart < minAmountIntallmentForeign) {
     756                                let errorMessage = '';
     757                                if (language === 'vi') {
     758                                    errorMessage = `Số tiền tối thiểu thanh toán trả góp là ${minAmountIntallmentForeign.toLocaleString()} ${currency}. Vui lòng chọn phương thức thanh toán khác.`;
     759                                } else {
     760                                    errorMessage = `The minimum amount accepted for installment payment via credit card is ${minAmountIntallmentForeign.toLocaleString()} ${currency}. Please choose another payment method.`;
     761                                }
     762                                let error = `<div class="woocommerce-NoticeGroup woocommerce-NoticeGroup-checkout">
     763                                        <ul class="woocommerce-error" role="alert">
     764                                            <li>${errorMessage}</li>
     765                                        </ul>
     766                                    </div>`;
    714767                                ninePayShowError(error);
    715768                                e.preventDefault();
     
    808861                return ninepay_handle_charge( $amount, $config['ninepay_payment_method_bnpl_fee_percent'], $config['ninepay_payment_method_bnpl_fee_fixed'] );
    809862
     863            case NinePayConstance::METHOD_INSTALLMENT:
     864                return ninepay_handle_charge( $amount, $config['ninepay_payment_method_installment_fee_percent'], $config['ninepay_payment_method_installment_fee_fixed'] );
     865
    810866            default:
    811867                return 0;
Note: See TracChangeset for help on using the changeset viewer.