Plugin Directory

Changeset 2903685


Ignore:
Timestamp:
04/25/2023 07:39:32 AM (3 years ago)
Author:
9pay
Message:

Update BNPL var

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

Legend:

Unmodified
Added
Removed
  • 9pay-gateway/trunk/includes/gateways/core/config.php

    r2903653 r2903685  
    2222    'min_amount_collection_vnd' => 10000,
    2323    'max_amount_collection_vnd' => 200000000,
     24    'min_amount_bnpl_vnd' => 10000,
     25    'max_amount_bnpl_vnd' => 25000000,
    2426    'max_amount' => 200000000,
    2527    'status' => [
  • 9pay-gateway/trunk/includes/gateways/ninepay-gateway.php

    r2724280 r2903685  
    241241                )
    242242            ),
     243
     244            /*Buy Now Pay Later*/
     245            'ninepay_payment_method_bnpl' => array(
     246                'desc_tip' => true,
     247                'class' => 'pb-0',
     248                'type' => 'checkbox',
     249                'label' => __( 'Mua trước trả sau', 'woocommerce' ),
     250                'default' => 'no'
     251            ),
     252            'ninepay_payment_method_bnpl_fee_percent' => array(
     253                'class' => 'ninepay-element-bnpl ninepay-percent pt-0',
     254                'text' => 'text',
     255                'description' => __( '%   +', 'woocommerce' ),
     256                'placeholder' => 'Phí % giá bán (Ví dụ: 1.8)',
     257                'default' => 0,
     258                'custom_attributes' => array(
     259                    'onkeypress' => 'return nineMethodPercent(event, this)',
     260                )
     261            ),
     262            'ninepay_payment_method_bnpl_fee_fixed' => array(
     263                'class' => 'ninepay-element-bnpl ninepay-fixed pt-0',
     264                'text' => 'text',
     265                'placeholder' => 'Phí cố định (Ví dụ: 2000)',
     266                'default' => 0,
     267                'custom_attributes' => array(
     268                    'onkeypress' => 'return nineMethodPercent(event, this)',
     269                )
     270            ),
     271
    243272        );
    244273    }
  • 9pay-gateway/trunk/mc-quetma.php

    r2902123 r2903685  
    1717 * Plugin URI:
    1818 * Description:       Tích hợp cổng thanh toán 9PAY vào phương thức thanh toán của woocomerce
    19  * Version:           1.9
     19 * Version:           2.0
    2020 * Author:            9Pay
    2121 * Author URI:
     
    3636 * Rename this for your plugin and update it as you release new versions.
    3737 */
    38 define( 'NINEPAY_MC_9PAY_VERSION', '1.0.0' );
     38define( 'NINEPAY_MC_9PAY_VERSION', '2.0' );
    3939define( 'NINEPAY_MC_9PAY_PLUGIN_URL', esc_url( plugins_url( '', __FILE__ ) ) );
    4040
     
    220220            $result[NinePayConstance::METHOD_COLLECTION] = __($configLang[$lang][NinePayConstance::METHOD_COLLECTION], "woocommerce");
    221221        }
     222
     223        /*Buy Now Pay Later*/
     224        if($settings['ninepay_payment_method_bnpl'] === 'yes') {
     225            $result[NinePayConstance::METHOD_BNPL] = __($configLang[$lang][NinePayConstance::METHOD_BNPL], "woocommerce");
     226        }
     227
    222228
    223229        return $result;
     
    291297        $minAmountCollectionVnd = $configFile['min_amount_collection_vnd'];
    292298        $maxAmountCollectionVnd = $configFile['max_amount_collection_vnd'];
     299
     300        $minAmountBnplVnd = $configFile['min_amount_bnpl_vnd'];
     301        $maxAmountBnplVnd = $configFile['max_amount_bnpl_vnd'];
    293302        ?>
    294303        <script type="text/javascript">
     
    310319            let maxAmountCollectionVnd = parseFloat("<?php echo esc_html($maxAmountCollectionVnd); ?>");
    311320
     321            let minAmountBnplVnd = parseFloat("<?php echo esc_html($minAmountBnplVnd); ?>");
     322            let maxAmountBnplVnd = parseFloat("<?php echo esc_html($maxAmountBnplVnd); ?>");
     323
     324
    312325            jQuery(document).on("updated_checkout", function(){
    313326                jQuery('#place_order').click(function (e) {
     
    447460                    }
    448461
     462                    if (paymentMethod === "BUY_NOW_PAY_LATER" && currency === "VND") {
     463                        if (totalCart < minAmountBnplVnd) {
     464                            let errorMessage = '';
     465                            if (language === 'vi') {
     466                                errorMessage = `Số tiền tối thiểu mua trước trả sau là ${minAmountBnplVnd.toLocaleString()} đ. Vui lòng chọn phương thức thanh toán khác.`;
     467                            } else {
     468                                errorMessage = `The minimum amount to buy now pay later is ${minAmountBnplVnd.toLocaleString()} VND. Please choose another payment method.`;
     469                            }
     470                            let error = `<div class="woocommerce-NoticeGroup woocommerce-NoticeGroup-checkout">
     471                                    <ul class="woocommerce-error" role="alert">
     472                                        <li>${errorMessage}</li>
     473                                    </ul>
     474                                </div>`;
     475                            ninePayShowError(error);
     476                            e.preventDefault();
     477                        }
     478                        if (totalCart > maxAmountBnplVnd) {
     479                            let errorMessage = '';
     480                            if (language === 'vi') {
     481                                errorMessage = `Số tiền tối thiểu mua trước trả sau là ${maxAmountBnplVnd.toLocaleString()} đ. Vui lòng chọn phương thức thanh toán khác.`;
     482                            } else {
     483                                errorMessage = `The maximum amount to buy now pay later is ${maxAmountBnplVnd.toLocaleString()} VND. Please choose another payment method.`;
     484                            }
     485                            let errorElement = `<div class="woocommerce-NoticeGroup woocommerce-NoticeGroup-checkout">
     486                                    <ul class="woocommerce-error" role="alert">
     487                                        <li>${errorMessage}</li>
     488                                    </ul>
     489                                </div>`;
     490                            ninePayShowError(errorElement);
     491                            e.preventDefault();
     492                        }
     493                    }
     494
    449495                    if (currency !== "VND") {
    450496                        let minAmountWalletForeign = Number((minAmountWalletVnd / excRate).toFixed(2));
     
    459505                        let minAmountCollectionForeign = Number((minAmountCollectionVnd / excRate).toFixed(2));
    460506
     507                        let minAmountBnplForeign = Number((minAmountBnplVnd / excRate).toFixed(2));
     508                        let maxAmountBnplForeign = Number((maxAmountBnplVnd / excRate).toFixed(2));
     509
    461510                        if (paymentMethod === "WALLET") {
    462511                            if (totalCart < minAmountWalletForeign) {
     
    575624                            }
    576625                        }
     626
     627                        if (paymentMethod === "BUY_NOW_PAY_LATER") {
     628                            if (totalCart < minAmountBnplForeign) {
     629                                let errorMessage = '';
     630                                if (language === 'vi') {
     631                                    errorMessage = `Số tiền tối thiểu chấp nhận thanh toán là ${minAmountBnplForeign.toLocaleString()} ${currency}. Vui lòng chọn phương thức thanh toán khác.`;
     632                                } else {
     633                                    errorMessage = `The minimum amount accepted for payment is ${minAmountBnplForeign.toLocaleString()} ${currency}. Please choose another payment method.`;
     634                                }
     635                                let error = `<div class="woocommerce-NoticeGroup woocommerce-NoticeGroup-checkout">
     636                                    <ul class="woocommerce-error" role="alert">
     637                                        <li>${errorMessage}</li>
     638                                    </ul>
     639                                </div>`;
     640                                ninePayShowError(error);
     641                                e.preventDefault();
     642                            }
     643                            if (totalCart > maxAmountBnplForeign) {
     644                                let errorMessage = '';
     645                                if (language === 'vi') {
     646                                    errorMessage = `Số tiền tối đa chấp nhận thanh toán là ${maxAmountBnplForeign.toLocaleString()} ${currency}. Vui lòng chọn phương thức thanh toán khác.`;
     647                                } else {
     648                                    errorMessage = `The maximum amount accepted for payment is ${maxAmountBnplForeign.toLocaleString()} ${currency}. Please choose another payment method.`;
     649                                }
     650                                let error = `<div class="woocommerce-NoticeGroup woocommerce-NoticeGroup-checkout">
     651                                    <ul class="woocommerce-error" role="alert">
     652                                        <li>${errorMessage}</li>
     653                                    </ul>
     654                                </div>`;
     655                                ninePayShowError(error);
     656                                e.preventDefault();
     657                            }
     658                        }
     659
    577660                    }
    578661                });
     
    652735            case NinePayConstance::METHOD_COLLECTION:
    653736                return ninepay_handle_charge($amount, $config['ninepay_payment_method_collection_fee_percent'], $config['ninepay_payment_method_collection_fee_fixed']);
     737                break;
     738
     739            case NinePayConstance::METHOD_BNPL:
     740                return ninepay_handle_charge($amount, $config['ninepay_payment_method_bnpl_fee_percent'], $config['ninepay_payment_method_bnpl_fee_fixed']);
    654741                break;
    655742
Note: See TracChangeset for help on using the changeset viewer.