/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event. /// </summary> /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param> protected override void OnInit(EventArgs e) { // Script that lets us use the CollectJS API (see https://secure.tnbcigateway.com/merchants/resources/integration/integration_portal.php?#cjs_methodology) var additionalAttributes = new Dictionary <string, string>(); additionalAttributes.Add("data-tokenization-key", this.TokenizationKey); additionalAttributes.Add("data-variant", "inline"); RockPage.AddScriptSrcToHead(this.Page, "nmiCollectJS", $"https://secure.tnbcigateway.com/token/Collect.js", additionalAttributes); RockPage.AddStyleToHead(this.Page, "nmiCollectJSCSS", Css.gatewayCollect); // Script that contains the initializeTokenizer scripts for us to use on the client if (!Page.IsPostBack) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "nmiGatewayCollectJSBlock", Scripts.gatewayCollectJS, true); } ScriptManager.RegisterStartupScript(this, this.GetType(), "nmiGatewayCollectJSStartup", $"Rock.NMI.controls.gatewayCollectJS.initialize('{this.ClientID}');", true); base.OnInit(e); }