How to Get custom fields on the confirmation page in the Elbrus version

We can extend the confirmation in submit function of LiveOrder.Model. So we need to override the module of LiveOrder.Model.

We are adding the example of the override of the module

ns.package.json

{
    "gulp": {
        "javascript": [
            "JavaScript/*.js"
        ],
        "ssp-libraries": [
            "SuiteScript/*.js"
        ]
    },
    "overrides": {
        "suitecommerce/LiveOrder@4.0.0/JavaScript/LiveOrder.Line.Model.js" : "JavaScript/LiveOrder.Line.Model.js",
        "suitecommerce/LiveOrder@4.0.0/SuiteScript/LiveOrder.Model.js" : "SuiteScript/LiveOrder.Model.js"
    }
}

So with the help of the extension, we can extend the LiveOrder.Model and we can submit the customize the customize function.

  , submit: function submit() {

                var confirmation
                    , payment = ModelsInit.order.getPayment();

                var customFields = JSON.stringify(this.getTransactionBodyField())
                var customFields1 = JSON.stringify(ModelsInit.order.getCustomFieldValues())
                var tempcard_stripe = _.findWhere(JSON.parse(customFields1), { name: 'custbody_jj_tempcard_stripe' });

                if (!threedsecure && payment && payment.paymentterms === 'CreditCard' && SC.Configuration.isThreeDSecureEnabled) {
                    return this.process3DSecure();
                }
                else {
                    var paypal_address = _.find(ModelsInit.customer.getAddressBook(), function (address) {
                        return !address.phone && address.isvalid === 'T';
                    })
                        , confirmation = ModelsInit.order.submit();
                    // We need remove the paypal's address because after order submit the address is invalid for the next time.
                    this.removePaypalAddress(paypal_address);

                    ModelsInit.context.setSessionObject('paypal_complete', 'F');

                    if (this.isMultiShippingEnabled) {
                        ModelsInit.order.setEnableItemLineShipping(false); // By default non order should be MST
                    }

                    //As the commerce API does not remove the purchase number after submitting the order we manually remove it
                    this.setPurchaseNumber();

                    if (confirmation.statuscode !== 'redirect') {

                        var self = this;
                        if (payment && payment.creditcard && payment.creditcard.paymentmethod.name === 'Stripe') {
                            confirmation = _.extend(this.getConfirmation(confirmation.internalid), confirmation);
                            var tempcard = tempcard_stripe && tempcard_stripe.value ? tempcard_stripe.value : (confirmation.custbody_jj_tempcard_stripe || '');
                            if (tempcard) {
                                var Result = JJStripeLibrary.StripePaymentIntent(tempcard, confirmation);
                                nlapiLogExecution("ERROR", "confirmation", JSON.stringify(confirmation));
                                Result = JSON.parse(Result)
                                var resultintent = Result && Result.confirm ? Result.confirm : {};
                                var IntentID = Result.intent.success ? Result.intent.message : '';
                                var resultconfirm = Result && Result.confirm ? Result.confirm : {};
                                var StripeConfirm = resultconfirm.success ? resultconfirm.message : ''
                                var successConfirm = resultconfirm.success && resultconfirm.message === 'succeeded' ? 'T' : 'F';
                                nlapiLogExecution("ERROR", "confirmation", JSON.stringify(resultconfirm));
                                var custom = {
                                    'custbody_stripe_intent': IntentID,
                                    'custbody_payment_confirmed_checkbox': successConfirm,
                                    'custbody_stripe_confirmation': StripeConfirm
                                };

                                var custom1 = {
                                    'custbody_stripe_intent': IntentID,
                                };
                                var custom2 = {
                                    'custbody_payment_confirmed_checkbox': successConfirm,
                                };
                                var custom3 = {
                                    'custbody_stripe_confirmation': StripeConfirm
                                };
                                var exturl = ''
                                try {
                                    ModelsInit.order.setCustomFieldValues(custom2);
                                    var customfeildlist = ModelsInit.order.getCustomFieldValues();
                                    var salesOrderId = confirmation.internalid
                                    var entity = confirmation.entity
                                    var currencyCode = confirmation.currency;
                                    var stripeIntegrationRecordId = this.stripeIntegrationInstance();
                                    exturl = nlapiResolveURL('SUITELET', 'customscript_jj_sl_add_paymen', 'customdeploy_jj_sl_add_paymen', true)
                                    exturl += '&amounttoPay=' + (confirmation.summary.total) * 100;
                                    exturl += '&amountCurrency=' + currencyCode;
                                    exturl += '&customerId=' + entity;
                                    exturl += '&salesOrderIneternalID=' + salesOrderId;
                                    exturl += '&stripeIntegrationId=' + stripeIntegrationRecordId;
                                    nlapiLogExecution("ERROR", "url", JSON.stringify(exturl));


                                    var custom6 = {
                                        'custbody_stripe_external_link': exturl,


                                    };
                                    var custom4 = {
                                        // 'custbody_stripe_external_link': exturl,
                                        'internalid': salesOrderId,
                                        'amounttoPay': confirmation.summary.total,
                                        'customerId': entity,
                                        'salesOrderIneternalID': salesOrderId,
                                        'stripeIntegrationId': stripeIntegrationRecordId,
                                        'amountCurrency': currencyCode,

                                    };
                                    var list = _.extend(custom, custom4);
                                    confirmation.customlist = _.extend(custom, custom6);
                                    JJStripeLibrary.StripeSalesorderUpdate(list);
                                    nlapiLogExecution("ERROR", "confirmation.customlist", JSON.stringify(custom));
                                    // ModelsInit.order.setCustomFieldValues(custom4);

                                }
                                catch (e) {
                                    nlapiLogExecution("ERROR", "ecustom41", JSON.stringify(e));
                                  
                                }

                                nlapiLogExecution("ERROR", "custom", JSON.stringify(custom1));
                            }
                        }
                        else {
                            confirmation = _.extend(this.getConfirmation(confirmation.internalid), confirmation);
                        }
                    }
                    else {
                        confirmation.redirecturl = ExternalPayment.generateUrl(confirmation.internalid, 'salesorder');
                    }
                }


                return confirmation;
            }

The screenshot is added below

Leave a comment

Your email address will not be published. Required fields are marked *