PageSourceSearch

https://www.kpva.org/wp-content/plugins/give-paymill/assets/js/give-paymill.js?ver=1.1.1

js kpva.org collected 2026-10-04 11:13:03 UTC 2,198 bytes, 72 lines download raw bytes

1/**
2 * Give - Paymill Gateway Add-on JS
3 */
4var give_global_vars;
5jQuery( document ).ready( function ( $ ) {
6
7	var this_form;
8
9	// non AJAX
10	$( 'body' ).on( 'submit', '.give-form', function ( event ) {
11
12		this_form = $( this );
13
14		if ( this_form.find( 'input.give-gateway:checked' ).val() == 'paymill' ) {
15
16			event.preventDefault();
17
18			give_paymill_process_card( this_form );
19
20		}
21
22	} );
23
24	function give_paymill_response_handler( error, result ) {
25
26		if ( error ) {
27			// re-enable the submit button
28			jQuery( '#give_purchase_form_wrap #give-purchase-button' ).attr( "disabled", false );
29			jQuery( '.give-loading-animation' ).fadeOut();
30
31			if ( give_global_vars.complete_purchase ) {
32				jQuery( '#give-purchase-button' ).val( give_global_vars.complete_purchase );
33			} else {
34				jQuery( '#give-purchase-button' ).val( 'Purchase' );
35			}
36
37			// show the errors on the form
38			jQuery( this_form ).find( '.cc-address' ).after( '<div id="give-paymill-payment-errors" class="give_error">' + error.apierror + '</div>' );
39
40		} else {
41
42			// token contains id, last4, and card type
43			var token = result.token;
44			// insert the token into the form so it gets submitted to the server
45			this_form.append( "<input type='hidden' name='paymillToken' value='" + token + "' />" );
46			// and submit
47			this_form.get( 0 ).submit();
48
49		}
50	}
51
52	function give_paymill_process_card( this_form ) {
53
54		// disable the submit button to prevent repeated clicks
55		jQuery( this_form ).find( '#give-purchase-button' ).attr( 'disabled', 'disabled' );
56
57		// createToken returns immediately - the supplied callback submits the form if there are no errors
58		paymill.createToken( {
59			number    : jQuery( this_form ).find( '.card-number' ).val(),
60			cardholder: jQuery( this_form ).find( '.card-name' ).val(),
61			cvc       : jQuery( this_form ).find( '.card-cvc' ).val(),
62			exp_month : jQuery( this_form ).find( '.card-expiry-month' ).val(),
63			exp_year  : jQuery( this_form ).find( '.card-expiry-year' ).val(),
64			currency  : give_paymill_vars.currency,
65			amount_int: Number( jQuery( this_form ).find( '#give-amount' ).val() * 100 )
66		}, give_paymill_response_handler );
67
68		return false; // submit from callback
69	}
70
71} );
72

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.