diff --git a/packages/globalpayments-js/examples/heartland.html b/packages/globalpayments-js/examples/heartland.html index 7e21f24..ddc823b 100644 --- a/packages/globalpayments-js/examples/heartland.html +++ b/packages/globalpayments-js/examples/heartland.html @@ -138,28 +138,35 @@

Drop-in Track reader

cardExternalTrigger.addEventListener('click', function (e) { e.preventDefault(); - for (var type in cardForm.fields) { - if (type === "submit") { + // manually include submit button + const fields = ['submit']; + const target = cardForm.frames['card-number']; + + for (const type in cardForm.frames) { + if (cardForm.frames.hasOwnProperty(type)) { + fields.push(type); + } + } + + for (const type in cardForm.frames) { + if (!cardForm.frames.hasOwnProperty(type)) { continue; } - var field = cardForm.frames[type]; + const frame = cardForm.frames[type]; - if (!field) { + if (!frame) { continue; } - GlobalPayments.internal.postMessage.post( - { - data: { - fields: cardForm.fields, - target: cardForm.frames["card-number"].id - }, - id: field.id, - type: "ui:iframe-field:request-data", + GlobalPayments.internal.postMessage.post({ + data: { + fields: fields, + target: target.id }, - field.id - ); + id: frame.id, + type: 'ui:iframe-field:request-data' + }, frame.id); } }); } diff --git a/packages/globalpayments-js/src/ui/iframe-field/index.ts b/packages/globalpayments-js/src/ui/iframe-field/index.ts index e6fab4b..97816b2 100644 --- a/packages/globalpayments-js/src/ui/iframe-field/index.ts +++ b/packages/globalpayments-js/src/ui/iframe-field/index.ts @@ -416,7 +416,7 @@ export class IframeField extends EventEmitter { } if (this.container.hasChildNodes()) { - this.container.insertBefore(this.frame, this.container); + this.container.insertBefore(this.frame, this.container.firstChild); } else { this.container.appendChild(this.frame); }