Instalar selo EBIT e Confi (antigo Movimento Compre e Confie)

Nova configuração para o programa confi.
Validada pelo suporte da Confi.

<script>
var DiasEntrega = '0';
var CEPEntrega = '';
var ebitCEPEntrega = '';
var DL_Email = '';
var DL_TransactionId = '0';

var DL_TransactionTotal = '0.00';
var DL_EC_PU_AF_Shipping = '';
var DL_EC_PU_PR_Id = '';
var DL_EC_PU_PR_Name = '';
var DL_EC_PU_PR_Price = '';
var DL_EC_PU_PR_Quantity = '';
var JS_Platform = '0';
var JS_BirthDay = '23-12-1980';
var JS_Gender = 'F';
var JS_CPF = '00000000000';
var JS_Host = window.location.origin;
var datetime = new Date();
var dateString = new Date(datetime.getTime() - datetime.getTimezoneOffset() * 60000);
var orderDate = dateString.toISOString().replace("T", " ").substr(0, 19);

var JS_UA = navigator.userAgent || navigator.vendor || window.opera;
if (/windows phone/i.test(JS_UA)) {
    JS_Platform = "WP";
}
else if (/android/i.test(JS_UA)) {
    JS_Platform = "ANDROID";
}
else if (/iPad|iPhone|iPod/.test(JS_UA) && !window.MSStream) {
    JS_Platform = "IOS";
}
else if (JS_Platform == '0') {
    var pf = ["Android", "iOS"];
    for (var i = 0; i < pf.length; i++) {
        if (navigator.platform.indexOf(pf[i]) > -1) {
            if (pf[i] == "iOS") {JS_Platform = "IOS";}
            else if (pf[i] == "Android") {JS_Platform = "ANDROID";}
        }
    }
}

if (JS_Host == null || JS_Host == undefined || JS_Host == ''){
	JS_Host = window.location.protocol.concat("//").concat(window.location.hostname);
}

(function(document) {
    $(document).ready(function() {
		$.get(JS_Host + "/conta/editar", function( data ) {
			JS_BirthDay = $(data).find('#id_data_nascimento')[0].value.toString().replace(/\//g, '-');
			JS_Gender = $(data).find('#id_sexo')[0].value.toString().toUpperCase();
			JS_CPF = $(data).find('#id_cpf')[0].value.toString().toUpperCase();
		})
	    .always(function() {
			setTimeout(function() {
				DiasEntrega = $("b:contains('dia')")[0].innerText.split(" ")[0];
				CEPEntrega = $($("b:contains('CEP')")[0].parentNode).find("span")[0].innerText;
				ebitCEPEntrega = CEPEntrega.substring(0, CEPEntrega.length-3) + '-' + CEPEntrega.substring(CEPEntrega.length-3, CEPEntrega.length)
				$.each(dataLayer, function(i, val) {
					if (val != null && val != undefined) {
						if (val.PageType === 'TransactionPage') {
							DL_Email = encodeURI(val.email.toString());
							DL_TransactionId = encodeURI(val.transactionId.toString());
							DL_TransactionTotal = encodeURI(parseFloat(val.transactionTotal).toFixed(2).toString());
						} 
						else if (val.ecommerce != null && val.ecommerce != undefined) {
							if (val.ecommerce.purchase != null && val.ecommerce.purchase != undefined) {
								if (val.ecommerce.purchase.actionField != null && val.ecommerce.purchase.actionField != undefined) {
									DL_EC_PU_AF_Shipping = encodeURI(parseFloat(val.ecommerce.purchase.actionField.shipping).toFixed(2).toString());
								}
								if (val.ecommerce.purchase.products != null && val.ecommerce.purchase.products != undefined) {
									var pros = val.ecommerce.purchase.products;
									$.each(pros, function(j, pro) {
										if (DL_EC_PU_PR_Id == '') {
											DL_EC_PU_PR_Id = encodeURI(pro.id.toString());
											DL_EC_PU_PR_Name = encodeURI(pro.name.toString());
											DL_EC_PU_PR_Price = encodeURI(parseFloat(pro.price).toFixed(2).toString());
											DL_EC_PU_PR_Quantity = encodeURI(parseFloat(pro.quantity).toFixed(0).toString());
										} else {
											DL_EC_PU_PR_Id = DL_EC_PU_PR_Id + "|" + encodeURI(pro.id.toString());
											DL_EC_PU_PR_Name = DL_EC_PU_PR_Name + "|" + encodeURI(pro.name.toString());
											DL_EC_PU_PR_Price = DL_EC_PU_PR_Price + "|" + encodeURI(parseFloat(pro.price).toFixed(2).toString());
											DL_EC_PU_PR_Quantity = DL_EC_PU_PR_Quantity + "|" + encodeURI(parseFloat(pro.quantity).toFixed(0).toString());
										}
									});
								}
							}
						}
					}
				});
				
				var ebitParam = 'storeId={{storeId}}' + '&plataform=' + JS_Platform + '&platform=' + JS_Platform +'&gender=' + JS_Gender + '&birthDay=' + JS_BirthDay + '&zipcode=' + ebitCEPEntrega + '&parcels=1' 
				+ '&transactionId=' + DL_TransactionId + '&deliveryTax=' + DL_EC_PU_AF_Shipping + '&deliveryTime=' + DiasEntrega + '&mktSaleID=0' + '&mktSaleId=0' + '&totalSpent=' + DL_TransactionTotal + '&invoiceEmissor=19' 
				+ '&paymentType=14' + '&cardFlag=7' + '&sku=' + DL_EC_PU_PR_Id + '&productname=' + DL_EC_PU_PR_Name + '&value=' + DL_EC_PU_PR_Price + '&quantity=' + DL_EC_PU_PR_Quantity + '&ean=' + DL_EC_PU_PR_Id 
				+ '&productcondition=1' + '&deliveryType=1' + '&email=' + DL_Email;
				
				//console.log(ebitParam);
				
				$("#ebitParam").attr('value', ebitParam).attr('data', ebitParam);

				var orderDeliveryTime = new Date(new Date().getTime() + (DiasEntrega * 24 * 60 * 60 * 1000)).toJSON();
				orderDeliveryTime = orderDeliveryTime.substring(8,10) + '-' + orderDeliveryTime.substring(5,8) + orderDeliveryTime.substring(0,4)
				
				var mccParam = 'orderSellerID={{orderSellerID}}' + '&orderID=' + DL_TransactionId + '&orderDate=' + orderDate + '&orderPlatform=0'+'&orderPartnerPayment=17' + '&orderBankEmissor=16' + '&orderCardFlag=7' 
				+ '&orderDeliveryTax=' + DL_EC_PU_AF_Shipping + '&orderDeliveryType=0' + '&orderDeliveryTime=' + orderDeliveryTime + '&orderPaymentType=3' + '&orderParcels=1' + '&orderTotalSpent=' + DL_TransactionTotal 
				+ '&consumerBirthDate=' + JS_BirthDay + '&consumerCPF='+ JS_CPF + '&consumerEmail=' + DL_Email + '&consumerGender=' + JS_Gender + '&consumerName=' + DL_EC_PU_PR_Name + '&consumerPhone=5511922222222' 
				+ '&consumerZipcode=' + CEPEntrega + '&billingCPF=' + JS_CPF + '&billingEmail=' + DL_Email + '&billingGender=' + JS_Gender + '&billingName=' + DL_EC_PU_PR_Name + '&billingPhone=5511922222222' 
				+ '&billingZipcode=' + CEPEntrega + '&productName=' + DL_EC_PU_PR_Name + '&productQuantity=' + DL_EC_PU_PR_Quantity + '&productValue=' + DL_EC_PU_PR_Price + '&productDiscount=0' + '&productDeliveryTax=' 
				+ DL_EC_PU_AF_Shipping + '&productDeliveryType=0' + '&productDeliveryTime=' + DiasEntrega + '&productMktSaleID=0' + '&productSKU=' + DL_EC_PU_PR_Id + '&productEAN=' + DL_EC_PU_PR_Id; 

				//console.log(mccParam);
				
				$("#TagEConfy").attr('value', mccParam).attr('data', mccParam);

				var scriptEBIT = document.createElement('script');
				scriptEBIT.src = 'https://imgs.ebit.com.br/ebitBR/selo-ebit/js/getSelo.js?{{storeId}}&lightbox=false';
				scriptEBIT.id = 'getSelo';
				scriptEBIT.type = 'text/javascript';
				document.body.appendChild(scriptEBIT);

				var scriptMMC = document.createElement('script');
				scriptMMC.src = 'https://cdn.confi.com.vc/scripts/tagBanner.min.js?sellerId={{orderSellerID}}&lightbox=false';
				scriptMMC.id = 'getData';
				scriptMMC.type = 'text/javascript';
				document.body.appendChild(scriptMMC);
				
				setTimeout(function() {
					$("#bannerEbit").attr('href',  $("#bannerEbit").attr('href') + '&email=' + DL_Email);
				}, 500);
				
			}, 1000);
		});
    });
	
})(document);
</script>

<param id="ebitParam" value=""/>

<a id="bannerEbit"></a>

<param id="TagEConfy" value=""/>

<a id="bannerEconfy"></a>

Boa noite! Tudo certo? Teria como você mandar só o do Confi sem o Ebit? É porque eu não tenho o Ebit, eu tava procurando por isso faz uns dias já… muito obrigado!

segue link do documento enviado pela confi, mas tive que fazer uma correção no script para a data prevista de entrega.

link: Integração Banner Confi Loja Integrada (5) (1).pdf - Google Drive

Código Acertado, seguir o resto do manual com as modificações do id da loja.

<script type="text/javascript">
var DiasEntrega = '0';
var CEPEntrega = '';
var ebitCEPEntrega = '';
var DL_Email = '';
var DL_TransactionId = '0';

var DL_TransactionTotal = '0.00';
var DL_EC_PU_AF_Shipping = '';
var DL_EC_PU_PR_Id = '';
var DL_EC_PU_PR_Name = '';
var DL_EC_PU_PR_Price = '';
var DL_EC_PU_PR_Quantity = '';
var JS_Platform = '0';
var JS_BirthDay = 'dd/MM/yyyy';
var JS_Gender = '';
var JS_CPF = '00000000000';
var JS_Host = window.location.origin;
var datetime = new Date();
var dateString = new Date(datetime.getTime() - datetime.getTimezoneOffset() * 60000);
var orderDate = dateString.toISOString().replace("T", " ").substr(0, 19);

var JS_UA = navigator.userAgent || navigator.vendor || window.opera;
if (/windows phone/i.test(JS_UA)) {
    JS_Platform = "WP";
}
else if (/android/i.test(JS_UA)) {
    JS_Platform = "ANDROID";
}
else if (/iPad|iPhone|iPod/.test(JS_UA) && !window.MSStream) {
    JS_Platform = "IOS";
}
else if (JS_Platform == '0') {
    var pf = ["Android", "iOS"];
    for (var i = 0; i < pf.length; i++) {
        if (navigator.platform.indexOf(pf[i]) > -1) {
            if (pf[i] == "iOS") {
                JS_Platform = "IOS";
            }
            else if (pf[i] == "Android") {
                JS_Platform = "ANDROID";
            }
        }
    }
}

if (JS_Host == null || JS_Host == undefined || JS_Host == '') {
    JS_Host = window.location.protocol.concat("//").concat(window.location.hostname);
}
(function(document) {
    $(document).ready(function() {
        $.get(JS_Host + "/conta/editar", function(data) {
                JS_BirthDay = $(data).find('#id_data_nascimento')[0].value.toString().replace(/\//g, '-');
                JS_Gender = $(data).find('#id_sexo')[0].value.toString().toUpperCase();
                JS_CPF = $(data).find('#id_cpf')[0].value.toString().toUpperCase();
            })
            .always(function() {
                setTimeout(function() {
                    DiasEntrega = $("b:contains('dia')")[0].innerText.split(" ")[0];
                    CEPEntrega = $($("b:contains('CEP')")[0].parentNode).find("span")[0].innerText;
                    ebitCEPEntrega = CEPEntrega.substring(0, CEPEntrega.length - 3) + '-' + CEPEntrega.substring(CEPEntrega.length - 3, CEPEntrega.length)

                    /* Estrutura */

                    $.each(dataLayer, function(i, val) {
                        if (val != null && val != undefined) {
                            if (val.PageType === 'TransactionPage') {
                                DL_Email = encodeURI(val.email.toString());
                                DL_TransactionId = encodeURI(val.transactionId.toString());
                                DL_TransactionTotal = encodeURI(parseFloat(val.transactionTotal).toFixed(2).toString());
                            }
                            else if (val.ecommerce != null && val.ecommerce != undefined) {
                                if (val.ecommerce.purchase != null && val.ecommerce.purchase != undefined) {
                                    if (val.ecommerce.purchase.actionField != null &&
                                        val.ecommerce.purchase.actionField != undefined) {
                                        DL_EC_PU_AF_Shipping = encodeURI(parseFloat(val.ecommerce.purchase.actionField.shipping).toFixed(2).toString());
                                    }
                                    if (val.ecommerce.purchase.products != null && val.ecommerce.purchase.products !=
                                        undefined) {
                                        var pros = val.ecommerce.purchase.products;
                                        $.each(pros, function(j, pro) {
                                            if (DL_EC_PU_PR_Id == '') {

                                                DL_EC_PU_PR_Id = encodeURI(pro.id.toString());
                                                DL_EC_PU_PR_Name = encodeURI(pro.name.toString());
                                                DL_EC_PU_PR_Price = encodeURI(parseFloat(pro.price).toFixed(2).toString());
                                                DL_EC_PU_PR_Quantity =

                                                    encodeURI(parseFloat(pro.quantity).toFixed(0).toString());
                                            }
                                            else {
                                                DL_EC_PU_PR_Id = DL_EC_PU_PR_Id + "|" + encodeURI(pro.id.toString());
                                                DL_EC_PU_PR_Name = DL_EC_PU_PR_Name + "|" + encodeURI(pro.name.toString());
                                                DL_EC_PU_PR_Price = DL_EC_PU_PR_Price + "|" + encodeURI(parseFloat(pro.price).toFixed(2).toString());
                                                DL_EC_PU_PR_Quantity = DL_EC_PU_PR_Quantity + "|" + encodeURI(parseFloat(pro.quantity).toFixed(0).toString());
                                            }
                                        });
                                    }
                                }
                            }
                        }
                    });

                    var orderDeliveryTime = new Date(new Date().getTime() + (DiasEntrega * 24 * 60 * 60 * 1000)).toJSON();
                    orderDeliveryTime = orderDeliveryTime.substring(0, 4) + '-' + orderDeliveryTime.substring(5, 8) + orderDeliveryTime.substring(8, 10);

                    var mccParam = 'orderSellerID={sellerId}' + '&orderID=' + DL_TransactionId + '&orderDate=' + orderDate + '&orderPlatform=0' + '&orderPartnerPayment=17' + '&orderBankEmissor=16' + '&orderCardFlag=7' + '&orderDeliveryTax=' + DL_EC_PU_AF_Shipping + '&orderDeliveryType=0' + '&orderDeliveryTime=' + orderDeliveryTime + '&orderPaymentType=3' + '&orderParcels=1' + '&orderTotalSpent=' + DL_TransactionTotal + '&consumerBirthDate=' + JS_BirthDay + '&consumerCPF=' + JS_CPF + '&consumerEmail=' + DL_Email + '&consumerGender=' + JS_Gender + '&consumerName=' + DL_EC_PU_PR_Name + '&consumerPhone=5511922222222' + '&consumerZipcode=' + CEPEntrega + '&billingCPF=' + JS_CPF + '&billingEmail=' + DL_Email + '&billingGender=' + JS_Gender + '&billingName=' + DL_EC_PU_PR_Name + '&billingPhone=5511922222222' + '&billingZipcode=' + CEPEntrega + '&productName=' + DL_EC_PU_PR_Name + '&productQuantity=' + DL_EC_PU_PR_Quantity + '&productValue=' + DL_EC_PU_PR_Price + '&productDiscount=0' + '&productDeliveryTax=' + DL_EC_PU_AF_Shipping + '&productDeliveryType=0' + '&productDeliveryTime=' + DiasEntrega + '&productMktSaleID=0' + '&productSKU=' + DL_EC_PU_PR_Id + '&productEAN=' + DL_EC_PU_PR_Id;

                    $("#TagEConfy").attr('value', mccParam);
                    var scriptMMC = document.createElement('script');
                    scriptMMC.src = 'https://cdn.confi.com.vc/scripts/tagBanner.min.js?sellerId={sellerId}&lightbox=true';
                    scriptMMC.id = 'getData';
                    scriptMMC.type = 'text/javascript';
                    document.body.appendChild(scriptMMC);
                }, 1000);
            });

    });
})(document);
</script>
<param id="TagEConfy" value=""/>
<a id="bannerEconfy"></a>

2 curtidas

Muito obrigado! Era exatamente o que eu precisava! Que Deus te abençoe!