Loading js/stripe.js +3 −0 Original line number Diff line number Diff line Loading @@ -59,6 +59,9 @@ // Create an instance of the card Element var card = elements.create('card', options); // Allow other modules to act on the created card element $(element).trigger('drupalStripe.elementCreated', ['card', card, elements]); // Add an instance of the card Element into the `card-element` <div> card.mount('#' + element.id + '-card-element'); Loading modules/stripe_examples/js/stripe_examples.js 0 → 100644 +35 −0 Original line number Diff line number Diff line /** * @file * Provides stripe attachment logic. */ (function ($, window, Drupal, drupalSettings, Stripe) { 'use strict'; /** * Attaches the stripe behavior * * @type {Drupal~behavior} * * @prop {Drupal~behaviorAttach} attach */ Drupal.behaviors.stripeExamples = { attach: function (context, settings) { $('.form-item-stripe').on('drupalStripe.elementCreate', function(event, type, options) { console.log('Stripe ' + type + ' create options:', options); }); $('.form-item-stripe').on('drupalStripe.elementCreated', function(event, type, element, elements) { // Do something on card. console.log('Stripe elements instance: ', elements); console.log('Stripe ' + type + ' element intance:', element); element.on('ready', function(e) { // Add an event handler }); }); } }; })(jQuery, window, Drupal, drupalSettings, Stripe); modules/stripe_examples/stripe_examples.libraries.yml +3 −0 Original line number Diff line number Diff line stripe_examples: js: js/stripe_examples.js: {} css: theme: css/stripe_examples.css: {} Loading
js/stripe.js +3 −0 Original line number Diff line number Diff line Loading @@ -59,6 +59,9 @@ // Create an instance of the card Element var card = elements.create('card', options); // Allow other modules to act on the created card element $(element).trigger('drupalStripe.elementCreated', ['card', card, elements]); // Add an instance of the card Element into the `card-element` <div> card.mount('#' + element.id + '-card-element'); Loading
modules/stripe_examples/js/stripe_examples.js 0 → 100644 +35 −0 Original line number Diff line number Diff line /** * @file * Provides stripe attachment logic. */ (function ($, window, Drupal, drupalSettings, Stripe) { 'use strict'; /** * Attaches the stripe behavior * * @type {Drupal~behavior} * * @prop {Drupal~behaviorAttach} attach */ Drupal.behaviors.stripeExamples = { attach: function (context, settings) { $('.form-item-stripe').on('drupalStripe.elementCreate', function(event, type, options) { console.log('Stripe ' + type + ' create options:', options); }); $('.form-item-stripe').on('drupalStripe.elementCreated', function(event, type, element, elements) { // Do something on card. console.log('Stripe elements instance: ', elements); console.log('Stripe ' + type + ' element intance:', element); element.on('ready', function(e) { // Add an event handler }); }); } }; })(jQuery, window, Drupal, drupalSettings, Stripe);
modules/stripe_examples/stripe_examples.libraries.yml +3 −0 Original line number Diff line number Diff line stripe_examples: js: js/stripe_examples.js: {} css: theme: css/stripe_examples.css: {}