mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-10-26 09:02:53 -04:00 
			
		
		
		
	
		
			
				
	
	
		
			52 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
		
			Vendored
		
	
	
	
			
		
		
	
	
			52 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
		
			Vendored
		
	
	
	
| /**
 | |
|  * Invoice Ninja (https://invoiceninja.com).
 | |
|  *
 | |
|  * @link https://github.com/invoiceninja/invoiceninja source repository
 | |
|  *
 | |
|  * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
 | |
|  *
 | |
|  * @license https://www.elastic.co/licensing/elastic-license 
 | |
|  */
 | |
| 
 | |
| class CheckoutCreditCardAuthorization {
 | |
|     constructor() {
 | |
|         this.button = document.querySelector('#pay-button');
 | |
|     }
 | |
| 
 | |
|     init() {
 | |
|         this.frames = Frames.init(
 | |
|             document.querySelector('meta[name=public-key]').content
 | |
|         );
 | |
|     }
 | |
| 
 | |
|     handle() {
 | |
|         this.init();
 | |
| 
 | |
|         Frames.addEventHandler(
 | |
|             Frames.Events.CARD_VALIDATION_CHANGED,
 | |
|             (event) => {
 | |
|                 this.button.disabled = !Frames.isCardValid();
 | |
|             }
 | |
|         );
 | |
| 
 | |
|         Frames.addEventHandler(Frames.Events.CARD_TOKENIZED, (event) => {
 | |
|             document.querySelector(
 | |
|                 'input[name="gateway_response"]'
 | |
|             ).value = JSON.stringify(event);
 | |
| 
 | |
|             document.getElementById('server_response').submit();
 | |
|         });
 | |
| 
 | |
|         document
 | |
|             .querySelector('#authorization-form')
 | |
|             .addEventListener('submit', (event) => {
 | |
|                 this.button.disabled = true;
 | |
| 
 | |
|                 event.preventDefault();
 | |
|                 Frames.submitCard();
 | |
|             });
 | |
|     }
 | |
| }
 | |
| 
 | |
| new CheckoutCreditCardAuthorization().handle();
 |