Setup

Include triple.js script:   
<script src="https://www.tripleplaypay.com/static/js/triple.js"></script>

Initialize Triple

Create new instance of Triple class:
const triple = new Triple(your_api_key);
Use payment form in built-in iframe on your page or separate window:
triple.generatePaymentForm({
	// Div location for payment form
	containerSelector: '#example',
	amount: 10.00,
	//Handle error response
	onError: (errorData) => {
		console.log('Error');
		console.log(errorData);
	},
	// Handle success response
	onSuccess: (data) => {
		console.log('Success');
		console.log(data);
	},
});
Configure your payment options:  Any pay service (Google Pay™, Apple Pay™, etc...) will appear under the Credit Card section of the iframe when activated
triple.generatePaymentForm({
	amount: 10.00,
	paymentOptions: ['credit_card', 'bank', 'crypto']
	newWindow: true,
	// Handle error response here
	onError: (errorData) => {
		console.log('Payment was rejected');
		console.log(errorData);
	},
	// Handle success response here
	onSuccess: (data) => {
		console.log('Payment was successful');
		console.log(data);
	},
});
Button to trigger the payment process:
<button id="btn">Pay now</button>
const button = document.querySelector('#btn');

button.addEventListener('click', () => {
    // This will open payment form in a new window
	triple.processPayment();
});
Clear irrelevant data:
triple.clear();
Generate form again with new parameters:
triple.generatePaymentForm(...)

Creating Payment Tokens

Create a token during a charge event
triple.generatePaymentForm({
	// Container for our payment form
	containerSelector: '#example',
	// Amount
	amount: 100,

	// will process payment and save user token
	tokenMode: 'charge',
	//Handle error response
	onError: (errorData) => {
		console.log('This is error');
		console.log(errorData);
	},
	// Handle success response
	onSuccess: (data) => {
		console.log('This is success');
		console.log(data);
	},
});
	
Simply create a token
triple.generatePaymentForm({
	// Container for our payment form
	containerSelector: '#example',
	// will just save user token without payment
	// 'amount' is not required for this action
	tokenMode: 'save',
	//Handle error response
	onError: (errorData) => {
		console.log('This is error');
		console.log(errorData);
	},
	// Handle success response
	onSuccess: (data) => {
		console.log('This is success');
		console.log(data);
	},
});
Create a token but delay a charge, so you can send the token in later to finalize payment
triple.generatePaymentForm({
	// Container for our payment form
	containerSelector: '#example',
	amount: 1.00,
	//turn off email field requirement, or supply an email instead example: 'test@test.com'
	email: false,
	// will just save user token without payment
	// 'amount' is required for this action
	tokenMode: 'save',
	//Handle error response
	onError: (errorData) => {
		console.log('This is error');
		console.log(errorData);
	},
	// Handle success response
	onSuccess: (data) => {
		console.log('This is success');
		console.log(data);
	},
});
Disable Tokenization
triple.generatePaymentForm({
	// Container for our payment form
	containerSelector: '#example',
	amount: 1,
	// Disable token feature(no saving/no payments with token)
	tokenMode: false,
	//Handle error response
	onError: (errorData) => {
		console.log('This is error');
		console.log(errorData);
	},
	// Handle success response
	onSuccess: (data) => {
		console.log('This is success');
		console.log(data);
	},
});
	

Forms

Displaying a form from the api\form in the iframe
triple.form({
	containerSelector: '#example',
	// relative or absolute
	url: '/form/7ec17b5b-72c4-48b9-a0ab-cf7f222031e3/test/user@gmail.com',
	// custom height
	height: 450,
});
	

Styling

Specify CSS Properties
triple.generatePaymentForm({
	// ... Payment properties
	styles: {
		// styles the text input elements
		inputStyle: {
			mode: 'simple', // or 'boxed' for rounded inputs
			focusBorderColor: '#f6951e'
		},
		// styles the payment method selector
		paymentMethodStyle: {
			selectedBackgroundColor: '#fffbf5',
			selectedTextColor: '#f6951e',
			selectedBorderColor: '#f6951e',
			hoverBackgroundColor: '#f6951e',
			hoverTextColor: '#ffffff',
			hoverBorderColor: '#fffbf5',
			borderColor: '#f1f2f5',
			backgroundColor: '#f3f3f3',
			textColor: '#939393'
		},
		// styles the payment submission button
		submitButtonStyle: {
			backgroundColor: '#000000',
			textColor: '#ffffff',
			hoverBackgroundColor: '#30313d',
			hoverTextColor: '#ffffff'
		}
	},
});
	
triple.generatePaymentForm({
	// ... Payment properties
	styles: {
		// input styling
		input: {
			color: '#454545',
			background: '#f5faf2',
			borderRadius: '5px',
			borderColor: '#fff',
			borderWidth: '1px',
			height: '50px',
			fontSize: '14px',
			fontWeight: '500',
			// Handle focus pseudo class
			focus: {
				borderColor: '#c8e3b8',
				background: 'black',
				color: '#bfbfbf',
			},
			// Handle error state (when input contains incorrect data)
			error: {
				borderColor: '#cf6565',
				background: '#edcccc',
				color: '#bfbfbf',
			},
			// Placeholder style
			placeholder: {
				color: '#a3a3a3',
				fontSize: '14px',
				fontWeight: '500',
			},
			// Error text style (text below input in error state)
			errorText: {
				color: 'blue',
				fontSize: '14px',
				fontWeight: '500',
			},
		},
	},
});