Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to tokenize CC without submit iFrame #37

Open
alecsfp opened this issue Dec 1, 2020 · 0 comments
Open

How to tokenize CC without submit iFrame #37

alecsfp opened this issue Dec 1, 2020 · 0 comments

Comments

@alecsfp
Copy link

alecsfp commented Dec 1, 2020

I am trying to tokenize credit card data without using an iframe submit button. In the Heartland example I see cardExternalTrigger as the solution to this; however no requests are made and the token-success event does not fire.

document.getElementById('place-order-btn').addEventListener('click', function(event) {
	event.preventDefault();

	for (var type in cardForm.fields) {
		if (type === "submit") {
			continue;
		}

		var field = cardForm.frames[type];
		
		if (!field) {
			continue;
		}

		GlobalPayments.internal.postMessage.post(
			{
				data: {
					fields: cardForm.fields,
					target: field.id
				},
				id: field.id,
				type: "ui:iframe-field:request-data",
			},
			field.id
		);
	}

	cardForm.on("token-success", (resp) => {
		// Save payment token
		this.paymentToken = resp.paymentReference;
		console.log('token recieved')

		// Submit data to the integration's backend for processing
		// that.submitForm();
	});

	cardForm.on("token-error", (resp) => {

	});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant