Plugin Directory

Changeset 2266810


Ignore:
Timestamp:
03/24/2020 07:57:29 PM (6 years ago)
Author:
workshopbutlers
Message:

Update to version 2.8.0 from GitHub

Location:
workshop-butler
Files:
4 added
48 edited
1 copied

Legend:

Unmodified
Added
Removed
  • workshop-butler/tags/2.8.0/languages/wsbintegration-de_DE.po

    r2266411 r2266810  
    66"Content-Transfer-Encoding: 8bit\n"
    77"Plural-Forms: nplurals=2; plural=(n != 1)\n"
    8 "POT-Creation-Date: 2020-03-22T11:58:26.323Z\n"
    9 "PO-Revision-Date: 2020-03-22T11:58:26.323Z\n"
     8"POT-Creation-Date: 2020-03-22T16:45:13.681Z\n"
     9"PO-Revision-Date: 2020-03-22T16:45:13.681Z\n"
    1010"Language: de\n"
    1111
     
    11801180msgstr "Adresse (Zeile 2)"
    11811181
     1182msgid "form.field.payment_type"
     1183msgstr "Bezahlverfahren"
     1184
    11821185msgid "form.field.street_first"
    11831186msgstr "Adresse (Zeile 1)"
  • workshop-butler/tags/2.8.0/languages/wsbintegration-en_US.po

    r2266411 r2266810  
    66"Content-Transfer-Encoding: 8bit\n"
    77"Plural-Forms: nplurals=2; plural=(n != 1)\n"
    8 "POT-Creation-Date: 2020-03-22T11:58:26.012Z\n"
    9 "PO-Revision-Date: 2020-03-22T11:58:26.012Z\n"
     8"POT-Creation-Date: 2020-03-22T16:45:13.370Z\n"
     9"PO-Revision-Date: 2020-03-22T16:45:13.370Z\n"
    1010"Language: en\n"
    1111
     
    11411141msgstr "Street 2"
    11421142
     1143msgid "form.field.payment_type"
     1144msgstr "Payment method"
     1145
    11431146msgid "form.field.street_first"
    11441147msgstr "Street 1"
  • workshop-butler/tags/2.8.0/languages/wsbintegration-es_ES.po

    r2266411 r2266810  
    66"Content-Transfer-Encoding: 8bit\n"
    77"Plural-Forms: nplurals=2; plural=(n != 1)\n"
    8 "POT-Creation-Date: 2020-03-22T11:58:26.619Z\n"
    9 "PO-Revision-Date: 2020-03-22T11:58:26.619Z\n"
     8"POT-Creation-Date: 2020-03-22T16:45:13.989Z\n"
     9"PO-Revision-Date: 2020-03-22T16:45:13.989Z\n"
    1010"Language: es\n"
    1111
     
    11801180msgstr "Calle 2"
    11811181
     1182msgid "form.field.payment_type"
     1183msgstr "Método de pago"
     1184
    11821185msgid "form.field.street_first"
    11831186msgstr "Calle 1"
  • workshop-butler/tags/2.8.0/languages/wsbintegration-fr_FR.po

    r2266411 r2266810  
    66"Content-Transfer-Encoding: 8bit\n"
    77"Plural-Forms: nplurals=2; plural=(n > 1)\n"
    8 "POT-Creation-Date: 2020-03-22T11:58:26.922Z\n"
    9 "PO-Revision-Date: 2020-03-22T11:58:26.922Z\n"
     8"POT-Creation-Date: 2020-03-22T16:45:14.290Z\n"
     9"PO-Revision-Date: 2020-03-22T16:45:14.290Z\n"
    1010"Language: fr\n"
    1111
     
    11801180msgstr "Rue 2"
    11811181
     1182msgid "form.field.payment_type"
     1183msgstr "Mode de paiement"
     1184
    11821185msgid "form.field.street_first"
    11831186msgstr "Rue 1"
  • workshop-butler/tags/2.8.0/languages/wsbintegration-nb_NO.po

    r2266411 r2266810  
    66"Content-Transfer-Encoding: 8bit\n"
    77"Plural-Forms: nplurals=2; plural=(n != 1)\n"
    8 "POT-Creation-Date: 2020-03-22T11:58:27.823Z\n"
    9 "PO-Revision-Date: 2020-03-22T11:58:27.823Z\n"
     8"POT-Creation-Date: 2020-03-22T16:45:15.199Z\n"
     9"PO-Revision-Date: 2020-03-22T16:45:15.199Z\n"
    1010"Language: nb\n"
    1111
  • workshop-butler/tags/2.8.0/languages/wsbintegration-nl_NL.po

    r2266411 r2266810  
    66"Content-Transfer-Encoding: 8bit\n"
    77"Plural-Forms: nplurals=2; plural=(n != 1)\n"
    8 "POT-Creation-Date: 2020-03-22T11:58:27.231Z\n"
    9 "PO-Revision-Date: 2020-03-22T11:58:27.231Z\n"
     8"POT-Creation-Date: 2020-03-22T16:45:14.589Z\n"
     9"PO-Revision-Date: 2020-03-22T16:45:14.589Z\n"
    1010"Language: nl\n"
    1111
     
    11801180msgstr "Straat 2"
    11811181
     1182msgid "form.field.payment_type"
     1183msgstr "Betalingswijze"
     1184
    11821185msgid "form.field.street_first"
    11831186msgstr "Straat 1"
  • workshop-butler/tags/2.8.0/languages/wsbintegration-nn_NO.po

    r2266411 r2266810  
    66"Content-Transfer-Encoding: 8bit\n"
    77"Plural-Forms: nplurals=2; plural=(n != 1)\n"
    8 "POT-Creation-Date: 2020-03-22T11:58:27.527Z\n"
    9 "PO-Revision-Date: 2020-03-22T11:58:27.527Z\n"
     8"POT-Creation-Date: 2020-03-22T16:45:14.888Z\n"
     9"PO-Revision-Date: 2020-03-22T16:45:14.888Z\n"
    1010"Language: nn\n"
    1111
  • workshop-butler/tags/2.8.0/languages/wsbintegration-pt_PT.po

    r2266411 r2266810  
    66"Content-Transfer-Encoding: 8bit\n"
    77"Plural-Forms: nplurals=2; plural=(n > 1)\n"
    8 "POT-Creation-Date: 2020-03-22T11:58:28.132Z\n"
    9 "PO-Revision-Date: 2020-03-22T11:58:28.132Z\n"
     8"POT-Creation-Date: 2020-03-22T16:45:15.496Z\n"
     9"PO-Revision-Date: 2020-03-22T16:45:15.496Z\n"
    1010"Language: pt\n"
    1111
     
    11801180msgstr "Endereço 2"
    11811181
     1182msgid "form.field.payment_type"
     1183msgstr "Forma de pagamento"
     1184
    11821185msgid "form.field.street_first"
    11831186msgstr "Endereço 1"
  • workshop-butler/tags/2.8.0/public/class-wsb-integration-public.php

    r2258174 r2266810  
    116116        wp_register_script( 'jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js', false, null );
    117117        wp_enqueue_script( 'jquery' );
     118
     119        wp_register_script( 'stripe', 'https://js.stripe.com/v3/' );
    118120
    119121        $ga_key = WSB_Options::get_option( WSB_Options::GA_API_KEY );
     
    311313        add_action( 'wp_ajax_wsb_get_values', array( 'WorkshopButler\WSB_Ajax', 'get_values' ) );
    312314
    313         add_action( 'wp_ajax_nopriv_wsb_register_to_event', array( 'WorkshopButler\WSB_Ajax', 'register_to_event' ) );
    314         add_action( 'wp_ajax_wsb_register_to_event', array( 'WorkshopButler\WSB_Ajax', 'register_to_event' ) );
     315        add_action( 'wp_ajax_nopriv_wsb_register', array( 'WorkshopButler\WSB_Ajax', 'register' ) );
     316        add_action( 'wp_ajax_wsb_register', array( 'WorkshopButler\WSB_Ajax', 'register' ) );
     317
     318        add_action( 'wp_ajax_nopriv_wsb_pre_register', array( 'WorkshopButler\WSB_Ajax', 'pre_register' ) );
     319        add_action( 'wp_ajax_wsb_pre_register', array( 'WorkshopButler\WSB_Ajax', 'pre_register' ) );
    315320    }
    316321}
  • workshop-butler/tags/2.8.0/public/css/wsb.wordpress.css

    r2266411 r2266810  
    99}
    1010
    11 .wsb-form__field {
     11.wsb-content .wsb-form__payment-alert {
     12  background-color: #E73B2B;
     13  color: white;
     14  padding: 1em;
     15}
     16.wsb-content .wsb-not-secure-alert,
     17.wsb-content .wsb-no-payment-method {
     18  display: none;
     19}
     20
     21.wsb-content .wsb-form-not-secure .wsb-not-secure-alert {
     22  display: block;
     23}
     24.wsb-content .wsb-form-without-payment .wsb-no-payment-method {
     25  display: block;
     26}
     27
     28.wsb-form__error {
     29  margin-left: 10em;
     30}
     31
     32.wsb-content .wsb-form__field {
    1233  position: relative;
    1334}
    14 .wsb-form__error {
    15   margin-left: 10em;
     35.wsb-content .wsb-stripe-card-error {
     36  padding-top: 1em;
     37  color: #E73B2B;
     38}
     39
     40.wsb-content .wsb-form__payment {
     41  margin-bottom: 0;
     42}
     43
     44.wsb-content .wsb-form__card {
     45  border-color: #BBB;
     46  border-radius: 2px;
     47  height: 2em;
     48  margin-bottom: 1em;
     49}
     50.wsb-form__payment-holder {
     51  width: 100%;
     52  display: block;
     53}
     54
     55.wsb-form__payment-holder .wsb-form__error {
     56  padding-bottom: 0;
     57}
     58
     59.wsb-content .wsb-form__btn:disabled {
     60  opacity: 0.5;
     61  cursor: auto;
    1662}
    1763
  • workshop-butler/tags/2.8.0/public/includes/class-wsb-ajax.php

    r2266411 r2266810  
    110110     * Makes a POST Register request to Workshop Butler API
    111111     */
    112     public static function register_to_event() {
     112    public static function register() {
    113113        if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
    114114            check_ajax_referer( 'wsb-nonce' );
     
    120120            $requests = new WSB_Requests();
    121121            $response = $requests->post( 'attendees/register', $form_data );
     122            wp_send_json( $response->body, $response->http_code );
     123        } else {
     124            exit();
     125        }
     126    }
     127
     128    /**
     129     * Makes a POST Pre-Register request to Workshop Butler API
     130     */
     131    public static function pre_register() {
     132        if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
     133            check_ajax_referer( 'wsb-nonce' );
     134
     135            $form_data = self::replace_changed_keys( $_POST );
     136            unset( $form_data['action'] );
     137            unset( $form_data['_ajax_nonce'] );
     138
     139            $requests = new WSB_Requests();
     140            $response = $requests->post( 'attendees/pre-register', $form_data );
    122141            wp_send_json( $response->body, $response->http_code );
    123142        } else {
  • workshop-butler/tags/2.8.0/public/includes/models/class-event.php

    r2250704 r2266810  
    2323require_once plugin_dir_path( dirname( __FILE__ ) ) . 'models/class-event-url.php';
    2424require_once plugin_dir_path( dirname( __FILE__ ) ) . 'models/class-cover-image.php';
     25require_once plugin_dir_path( dirname( __FILE__ ) ) . 'models/class-payment.php';
    2526require_once plugin_dir_path( __FILE__ ) . 'form/class-form.php';
    2627
     
    193194     */
    194195    private $url;
     196
     197    /**
     198     * Payment configuration
     199     *
     200     * @since 2.8.0
     201     * @var Payment|null $payment
     202     */
     203    public $payment;
    195204
    196205    /**
     
    237246        $this->trainers = $this->get_trainers( $json_data, $trainer_page_url );
    238247        $this->state    = new Event_State( $this );
     248        $this->payment  = Payment::from_json( $json_data->card_payment );
    239249    }
    240250
  • workshop-butler/tags/2.8.0/public/includes/shortcodes/class-wsb-registration-page.php

    r2266411 r2266810  
    4141    }
    4242
     43    /**
     44     * Loads templates used later in the other templates
     45     *
     46     * @since 2.7.0
     47     */
    4348    private function load_templates() {
    44         $field          = $this->get_template( 'registration/field', null );
    45         $label          = $this->get_template( 'registration/label', null );
    46         $input          = $this->get_template( 'registration/input', null );
    47         $ticket         = $this->get_template( 'registration/ticket', null );
    48         $ticket_section = $this->get_template( 'registration/ticket-section', null );
     49        $field           = $this->get_template( 'registration/field', null );
     50        $label           = $this->get_template( 'registration/label', null );
     51        $input           = $this->get_template( 'registration/input', null );
     52        $ticket          = $this->get_template( 'registration/ticket', null );
     53        $ticket_section  = $this->get_template( 'registration/ticket-section', null );
     54        $payment_section = $this->get_template( 'registration/payment-section', null );
    4955        $this->twig->loader->setTemplate( 'field.twig', $field );
    5056        $this->twig->loader->setTemplate( 'label.twig', $label );
     
    5258        $this->twig->loader->setTemplate( 'ticket.twig', $ticket );
    5359        $this->twig->loader->setTemplate( 'ticket-section.twig', $ticket_section );
     60        $this->twig->loader->setTemplate( 'payment-section.twig', $payment_section );
    5461    }
    5562
     
    8794        }
    8895        wp_enqueue_script( 'wsb-registration-page' );
     96        if ( $may_be_event->payment ) {
     97            if ( $this->is_https() || $this->is_test( $may_be_event->payment ) ) {
     98                wp_enqueue_script( 'stripe' );
     99            }
     100            $this->add_payment_config( $may_be_event );
     101        }
     102
    89103        $this->add_theme_fonts();
    90104        $this->add_localized_script( $may_be_event );
    91105
    92106        return $this->render_page( $may_be_event );
     107    }
     108
     109    /**
     110     * Returns true if the request is secure
     111     *
     112     * @return bool
     113     */
     114    protected function is_https() {
     115        return
     116            ( ! empty( $_SERVER['HTTPS'] ) && 'off' !== $_SERVER['HTTPS'] )
     117            || 443 === $_SERVER['SERVER_PORT'];
     118    }
     119
     120    /**
     121     * Returns true if the payment is in test mode
     122     *
     123     * @param Payment $payment Payment configuration.
     124     *
     125     * @return bool
     126     */
     127    protected function is_test( $payment ) {
     128        return strpos( $payment->stripe_public_key, 'pk_test_' ) === 0;
    93129    }
    94130
     
    120156            )
    121157        );
     158    }
     159
     160    /**
     161     * Adds payment configuration to the registration page
     162     *
     163     * @param Event $event Event.
     164     *
     165     * @since 2.8.0
     166     */
     167    protected function add_payment_config( $event ) {
     168        if ( $event->payment ) {
     169            wp_localize_script(
     170                'wsb-registration-page',
     171                'wsb_payment',
     172                array(
     173                    'active'            => $event->payment->active,
     174                    'secure'            => $this->is_https(),
     175                    'test'              => $this->is_test( $event->payment ),
     176                    'stripe_public_key' => $event->payment->stripe_public_key,
     177                    'stripe_client_id'  => $event->payment->stripe_client_id,
     178                )
     179            );
     180        }
    122181    }
    123182
  • workshop-butler/tags/2.8.0/public/js/registration-page.js

    r2266411 r2266810  
    3030    }
    3131}
     32
     33/**
     34 * Creates a Stripe payment form
     35 *
     36 * @returns {{validateInputs: validateInputs, clearCardInput: clearCardInput, createPaymentMethod: createPaymentMethod, disableCardInput: (function(*=): card|void|undefined|Promise<void>|*|IDBRequest<IDBValidKey>), confirmCardPayment: confirmCardPayment, stripeClient: *}}
     37 */
     38function create_stripe_card(stripeHolderEl, publicKey, stripeAccount) {
     39    const x = function (tagName, attrs = null) {
     40        const el = document.createElement(tagName);
     41        if (attrs !== null) Object.entries(attrs).forEach((e) => el.setAttribute(e[0], e[1]));
     42        return el;
     43    };
     44
     45    const options = {};
     46    if (stripeAccount) {
     47        options.stripeAccount = stripeAccount;
     48    }
     49
     50    const cl = Stripe(publicKey, options);
     51
     52    const stripeCardHolderEl = x('div', {'class': 'wsb-stripe-card-element'});
     53    stripeHolderEl.appendChild(stripeCardHolderEl);
     54    const stripeCardErrorsHolderEl = x('div', {'class': 'wsb-stripe-card-error'});
     55    stripeHolderEl.appendChild(stripeCardErrorsHolderEl);
     56    const incompleteMessage = "Your card number is incomplete.";
     57
     58    const elements = cl.elements();
     59    const stripeCardEl = elements.create('card', {
     60        hidePostalCode: true,
     61        style: {
     62            base: {
     63                color: '#32325d',
     64                fontFamily: '"Helvetica Neue", Helvetica, sans-serif',
     65                fontSmoothing: 'antialiased',
     66                fontSize: '16px',
     67                '::placeholder': {
     68                    color: '#aab7c4'
     69                }
     70            },
     71            invalid: {
     72                color: '#fa755a',
     73                iconColor: '#fa755a'
     74            }
     75        }
     76    });
     77
     78    let inputComplete = false;
     79    stripeCardEl.on('change', (e) => {
     80        inputComplete = e.complete;
     81        if (e.error) {
     82            stripeCardErrorsHolderEl.innerHTML = e.error.message;
     83        } else {
     84            stripeCardErrorsHolderEl.innerHTML = "";
     85        }
     86    });
     87    stripeCardEl.mount(stripeCardHolderEl);
     88    return {
     89        stripeClient: cl,
     90        disableCardInput: (disable) => stripeCardEl.update({disabled:disable}),
     91        clearCardInput: () => {
     92            stripeCardEl.clear();
     93            stripeCardErrorsHolderEl.innerHTML = ""
     94        },
     95        validateInputs: () => {
     96            // It is also possible to use createToken method for card validation,
     97            // bit it's not a proper usage and we don't know about possible side effects of it
     98            // cl.createToken(stripeCardEl).then((token)=>console.log(token))
     99            //
     100            if(!inputComplete) {
     101                stripeCardErrorsHolderEl.innerHTML = incompleteMessage;
     102                stripeCardEl.focus(); // not work on iOS 13+
     103                return false;
     104            }
     105            return true;
     106        },
     107        confirmCardPayment: (clientSecret, {payment_method}) => {
     108            if (!inputComplete) {
     109                return Promise.reject(incompleteMessage);
     110            }
     111            return cl.confirmCardPayment(clientSecret, {
     112                payment_method: {
     113                    card: stripeCardEl,
     114                    billing_details: payment_method ? payment_method.billing_details : {},
     115                },
     116            })
     117        },
     118        createPaymentMethod: ({billing_details}) => {
     119            if (!inputComplete) {
     120                return Promise.reject(incompleteMessage);
     121            }
     122            return cl.createPaymentMethod({
     123                type: 'card',
     124                card: stripeCardEl,
     125                billing_details: billing_details || {}
     126            })
     127        }
     128    };
     129}
     130
    32131
    33132/**
     
    58157        );
    59158
    60         this.cardPaymentEnabled = false;
    61         //this._initStripeCard();
    62 
    63         // if (!this.cardPaymentEnabled) {
    64         //  console.log('Card payment allowed: ' + this._cardPaymentAllowed());
    65         //  // const conf = CONFIG.payment || {};
    66         //  const conf = {};
    67         //  console.log('Stripe client id: ' + conf.stripeClientId);
    68         //  console.log('Stripe key: ' + conf.stripeKey);
    69         // }
     159        this.cardPaymentEnabled = this._initStripeCard();
     160        this.invoicePaymentEnabled = !this._isPaymentActive() || this._invoicePaymentAllowed();
    70161
    71162        this._assignEvents();
     
    81172        return {
    82173            $formControls: $root.find('[data-control]'),
    83             $btnToggle: $root.find('[data-widget-register]'),
    84             $btnSubmit: $root.find('[data-widget-submit]'),
     174            $btnSubmit: $root.find('[type="submit"]'),
    85175            $cardSection: $root.find('[data-card-section]'),
    86176            $success: jQuery('#wsb-success'),
     
    92182        this.initPromoActivation();
    93183        this.initActiveTicketSelection();
     184        this._isNotSecure();
     185        this._checkPaymentMethods();
     186    }
     187
     188    _checkPaymentMethods() {
     189        if (this.cardPaymentEnabled || this.invoicePaymentEnabled) {
     190            return;
     191        }
     192        this.$root.addClass('wsb-form-without-payment');
     193        this.$root.find('[data-payment-section]').hide();
     194        this.formIsLocked = true;
     195        this.locals.$btnSubmit.prop('disabled', true);
     196    }
     197
     198    _isNotSecure() {
     199        if (this._isPaymentActive() && !this._isPageSecure()) {
     200            this.$root.addClass('wsb-form-not-secure');
     201            this._getCardPaymentOption().prop('disabled', 'disabled').removeProp('selected');
     202        }
     203    }
     204
     205    _getCardPaymentOption() {
     206        return this.$root.find('[data-control][name="payment_type"] option[value="Card"]');
     207    }
     208
     209    /**
     210     * Returns true if the payment configuration is available
     211     * @returns boolean
     212     * @private
     213     */
     214    _isPaymentActive() {
     215        return wsb_payment && wsb_payment.active && wsb_payment.stripe_client_id && wsb_payment.stripe_public_key;
     216    }
     217
     218    /**
     219     * Returns true if it's allowed to use card payments on this page
     220     * @returns boolean
     221     * @private
     222     */
     223    _isPageSecure() {
     224        return wsb_payment.secure || wsb_payment.test;
    94225    }
    95226
    96227    _cardPaymentAllowed() {
    97         return !!this.$root.find('[data-control][name="payment_type"] option[value="Card"]').length;
     228        return !!this._getCardPaymentOption().length;
     229    }
     230
     231    _invoicePaymentAllowed() {
     232        return !!this.$root.find('[data-control][name="payment_type"] option[value="Invoice"]').length;
    98233    }
    99234
     
    114249        if (!(
    115250            this._cardPaymentAllowed()
    116             && CONFIG.payment
    117             && CONFIG.payment.stripeClientId
    118             && CONFIG.payment.stripeKey)
     251            && this._isPaymentActive()
     252            && this._isPageSecure())
    119253        ) return false;
    120254
    121         this.stripeCard = createStripeCard(
     255        this.stripeCard = create_stripe_card(
    122256            this.$root.find("#stripe-placeholder")[0],
    123             CONFIG.payment.stripeKey,
    124             CONFIG.payment.stripeClientId);
     257            wsb_payment.stripe_public_key,
     258            wsb_payment.stripe_client_id);
    125259
    126260        this._displayCardSection(this._cardPaymentSelected());
     
    191325    _onSubmitForm(e) {
    192326        e.preventDefault();
     327        console.log("SUBMIT");
    193328
    194329        if (this.formIsLocked) return;
     
    226361
    227362        const formData = self.formHelper.getFormData();
    228         const registrationUrl = self.$root.attr('action');
    229         // const preparePaymentUrl = self.$root.data("preparePaymentUrl");
    230         const preparePaymentUrl = wsb_event.ajax_url;
     363        const url = wsb_event.ajax_url;
    231364
    232365        self._lockFormSubmit();
    233         self._sendFormData(preparePaymentUrl, formData)
     366        self._sendFormData(url, this._prepareFormData(formData, true))
    234367            .done((data) => {
    235                 self._processCardPayment(registrationUrl, formData, data.data.client_secret);
     368                self._processCardPayment(url, formData, data.data.stripe_client_secret);
    236369            }).fail(self._processFailResponse);
    237370    }
     
    243376
    244377        const formData = self.formHelper.getFormData();
    245         // const registrationUrl = self.$root.attr('action');
    246378        const registrationUrl = wsb_event.ajax_url;
    247379
    248380        self._lockFormSubmit();
    249         self._sendFormData(registrationUrl, this._prepareFormData(formData))
     381        self._sendFormData(registrationUrl, this._prepareFormData(formData, false))
    250382            .done(() => {
    251383                self._submitSucceed();
     
    257389     *
    258390     * @param data {object} Form data
     391     * @param preRegister {boolean} True if the call is to pre-register
    259392     * @return {object}
    260393     */
    261     _prepareFormData(data) {
    262         data.action = 'wsb_register_to_event';
     394    _prepareFormData(data, preRegister) {
     395        data.action = preRegister ? 'wsb_pre_register' : 'wsb_register';
    263396        data._ajax_nonce = wsb_event.nonce;
    264397        data.event_id = Number(wsb_event.id);
     
    316449            formData['intent_id'] = result.paymentIntent.id;
    317450
    318             self._sendFormData(url, formData)
     451            self._sendFormData(url, this._prepareFormData(formData, false))
    319452                .done(() => {
    320453                    self._submitSucceed();
     
    367500    // transport
    368501    _sendFormData(url, data) {
    369         data.action = 'wsb_register_to_event';
    370502        data._ajax_nonce = wsb_event.nonce;
    371503        return $.ajax({
  • workshop-butler/tags/2.8.0/views/registration/form.twig

    r2258174 r2266810  
    1616            {% if section.id == 'ticket' %}
    1717                {{ include('ticket-section.twig') }}
     18            {% elseif section.id == 'payment' %}
     19                <div class="wsb-form__payment-alert wsb-not-secure-alert">
     20                    This page is not secure. Card payments are turned off.
     21                </div>
     22                <div class="wsb-form__payment-alert wsb-no-payment-method">
     23                    No payment method is available. You cannot register to this event.
     24                </div>
     25                {{ include('payment-section.twig') }}
    1826            {% else %}
    1927                <section>
     
    3240        {% else %}
    3341            <button type="submit" class="wsb-form__btn">
    34                 {{ wsb_t('event.form.button') }}
     42                <i class="fa fa-spinner fa-spin" style="display: none;"></i> {{ wsb_t('event.form.button') }}
    3543            </button>
    3644        {% endif %}
  • workshop-butler/tags/2.8.0/workshop-butler.php

    r2266411 r2266810  
    1212 * Description:       This plugin integrates Workshop Butler Events, Trainers and Testimonials to your WordPress
    1313 *     website.
    14  * Version:           2.7.6
     14 * Version:           2.8.0
    1515 * Author:            Workshop Butler
    1616 * Author URI:        https://workshopbutler.com/
     
    2929 * Currently plugin version.
    3030 */
    31 define( 'WSB_INTEGRATION_VERSION', '2.7.6' );
     31define( 'WSB_INTEGRATION_VERSION', '2.8.0' );
    3232
    3333/**
    3434 * Version of Workshop Butler API, used by this plugin
    3535 */
    36 define( 'WSB_API_VERSION', '2020-01-23' );
     36define( 'WSB_API_VERSION', '2020-03-19' );
    3737
    3838/**
  • workshop-butler/trunk/languages/wsbintegration-de_DE.po

    r2266411 r2266810  
    66"Content-Transfer-Encoding: 8bit\n"
    77"Plural-Forms: nplurals=2; plural=(n != 1)\n"
    8 "POT-Creation-Date: 2020-03-22T11:58:26.323Z\n"
    9 "PO-Revision-Date: 2020-03-22T11:58:26.323Z\n"
     8"POT-Creation-Date: 2020-03-22T16:45:13.681Z\n"
     9"PO-Revision-Date: 2020-03-22T16:45:13.681Z\n"
    1010"Language: de\n"
    1111
     
    11801180msgstr "Adresse (Zeile 2)"
    11811181
     1182msgid "form.field.payment_type"
     1183msgstr "Bezahlverfahren"
     1184
    11821185msgid "form.field.street_first"
    11831186msgstr "Adresse (Zeile 1)"
  • workshop-butler/trunk/languages/wsbintegration-en_US.po

    r2266411 r2266810  
    66"Content-Transfer-Encoding: 8bit\n"
    77"Plural-Forms: nplurals=2; plural=(n != 1)\n"
    8 "POT-Creation-Date: 2020-03-22T11:58:26.012Z\n"
    9 "PO-Revision-Date: 2020-03-22T11:58:26.012Z\n"
     8"POT-Creation-Date: 2020-03-22T16:45:13.370Z\n"
     9"PO-Revision-Date: 2020-03-22T16:45:13.370Z\n"
    1010"Language: en\n"
    1111
     
    11411141msgstr "Street 2"
    11421142
     1143msgid "form.field.payment_type"
     1144msgstr "Payment method"
     1145
    11431146msgid "form.field.street_first"
    11441147msgstr "Street 1"
  • workshop-butler/trunk/languages/wsbintegration-es_ES.po

    r2266411 r2266810  
    66"Content-Transfer-Encoding: 8bit\n"
    77"Plural-Forms: nplurals=2; plural=(n != 1)\n"
    8 "POT-Creation-Date: 2020-03-22T11:58:26.619Z\n"
    9 "PO-Revision-Date: 2020-03-22T11:58:26.619Z\n"
     8"POT-Creation-Date: 2020-03-22T16:45:13.989Z\n"
     9"PO-Revision-Date: 2020-03-22T16:45:13.989Z\n"
    1010"Language: es\n"
    1111
     
    11801180msgstr "Calle 2"
    11811181
     1182msgid "form.field.payment_type"
     1183msgstr "Método de pago"
     1184
    11821185msgid "form.field.street_first"
    11831186msgstr "Calle 1"
  • workshop-butler/trunk/languages/wsbintegration-fr_FR.po

    r2266411 r2266810  
    66"Content-Transfer-Encoding: 8bit\n"
    77"Plural-Forms: nplurals=2; plural=(n > 1)\n"
    8 "POT-Creation-Date: 2020-03-22T11:58:26.922Z\n"
    9 "PO-Revision-Date: 2020-03-22T11:58:26.922Z\n"
     8"POT-Creation-Date: 2020-03-22T16:45:14.290Z\n"
     9"PO-Revision-Date: 2020-03-22T16:45:14.290Z\n"
    1010"Language: fr\n"
    1111
     
    11801180msgstr "Rue 2"
    11811181
     1182msgid "form.field.payment_type"
     1183msgstr "Mode de paiement"
     1184
    11821185msgid "form.field.street_first"
    11831186msgstr "Rue 1"
  • workshop-butler/trunk/languages/wsbintegration-nb_NO.po

    r2266411 r2266810  
    66"Content-Transfer-Encoding: 8bit\n"
    77"Plural-Forms: nplurals=2; plural=(n != 1)\n"
    8 "POT-Creation-Date: 2020-03-22T11:58:27.823Z\n"
    9 "PO-Revision-Date: 2020-03-22T11:58:27.823Z\n"
     8"POT-Creation-Date: 2020-03-22T16:45:15.199Z\n"
     9"PO-Revision-Date: 2020-03-22T16:45:15.199Z\n"
    1010"Language: nb\n"
    1111
  • workshop-butler/trunk/languages/wsbintegration-nl_NL.po

    r2266411 r2266810  
    66"Content-Transfer-Encoding: 8bit\n"
    77"Plural-Forms: nplurals=2; plural=(n != 1)\n"
    8 "POT-Creation-Date: 2020-03-22T11:58:27.231Z\n"
    9 "PO-Revision-Date: 2020-03-22T11:58:27.231Z\n"
     8"POT-Creation-Date: 2020-03-22T16:45:14.589Z\n"
     9"PO-Revision-Date: 2020-03-22T16:45:14.589Z\n"
    1010"Language: nl\n"
    1111
     
    11801180msgstr "Straat 2"
    11811181
     1182msgid "form.field.payment_type"
     1183msgstr "Betalingswijze"
     1184
    11821185msgid "form.field.street_first"
    11831186msgstr "Straat 1"
  • workshop-butler/trunk/languages/wsbintegration-nn_NO.po

    r2266411 r2266810  
    66"Content-Transfer-Encoding: 8bit\n"
    77"Plural-Forms: nplurals=2; plural=(n != 1)\n"
    8 "POT-Creation-Date: 2020-03-22T11:58:27.527Z\n"
    9 "PO-Revision-Date: 2020-03-22T11:58:27.527Z\n"
     8"POT-Creation-Date: 2020-03-22T16:45:14.888Z\n"
     9"PO-Revision-Date: 2020-03-22T16:45:14.888Z\n"
    1010"Language: nn\n"
    1111
  • workshop-butler/trunk/languages/wsbintegration-pt_PT.po

    r2266411 r2266810  
    66"Content-Transfer-Encoding: 8bit\n"
    77"Plural-Forms: nplurals=2; plural=(n > 1)\n"
    8 "POT-Creation-Date: 2020-03-22T11:58:28.132Z\n"
    9 "PO-Revision-Date: 2020-03-22T11:58:28.132Z\n"
     8"POT-Creation-Date: 2020-03-22T16:45:15.496Z\n"
     9"PO-Revision-Date: 2020-03-22T16:45:15.496Z\n"
    1010"Language: pt\n"
    1111
     
    11801180msgstr "Endereço 2"
    11811181
     1182msgid "form.field.payment_type"
     1183msgstr "Forma de pagamento"
     1184
    11821185msgid "form.field.street_first"
    11831186msgstr "Endereço 1"
  • workshop-butler/trunk/public/class-wsb-integration-public.php

    r2258174 r2266810  
    116116        wp_register_script( 'jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js', false, null );
    117117        wp_enqueue_script( 'jquery' );
     118
     119        wp_register_script( 'stripe', 'https://js.stripe.com/v3/' );
    118120
    119121        $ga_key = WSB_Options::get_option( WSB_Options::GA_API_KEY );
     
    311313        add_action( 'wp_ajax_wsb_get_values', array( 'WorkshopButler\WSB_Ajax', 'get_values' ) );
    312314
    313         add_action( 'wp_ajax_nopriv_wsb_register_to_event', array( 'WorkshopButler\WSB_Ajax', 'register_to_event' ) );
    314         add_action( 'wp_ajax_wsb_register_to_event', array( 'WorkshopButler\WSB_Ajax', 'register_to_event' ) );
     315        add_action( 'wp_ajax_nopriv_wsb_register', array( 'WorkshopButler\WSB_Ajax', 'register' ) );
     316        add_action( 'wp_ajax_wsb_register', array( 'WorkshopButler\WSB_Ajax', 'register' ) );
     317
     318        add_action( 'wp_ajax_nopriv_wsb_pre_register', array( 'WorkshopButler\WSB_Ajax', 'pre_register' ) );
     319        add_action( 'wp_ajax_wsb_pre_register', array( 'WorkshopButler\WSB_Ajax', 'pre_register' ) );
    315320    }
    316321}
  • workshop-butler/trunk/public/css/wsb.wordpress.css

    r2266411 r2266810  
    99}
    1010
    11 .wsb-form__field {
     11.wsb-content .wsb-form__payment-alert {
     12  background-color: #E73B2B;
     13  color: white;
     14  padding: 1em;
     15}
     16.wsb-content .wsb-not-secure-alert,
     17.wsb-content .wsb-no-payment-method {
     18  display: none;
     19}
     20
     21.wsb-content .wsb-form-not-secure .wsb-not-secure-alert {
     22  display: block;
     23}
     24.wsb-content .wsb-form-without-payment .wsb-no-payment-method {
     25  display: block;
     26}
     27
     28.wsb-form__error {
     29  margin-left: 10em;
     30}
     31
     32.wsb-content .wsb-form__field {
    1233  position: relative;
    1334}
    14 .wsb-form__error {
    15   margin-left: 10em;
     35.wsb-content .wsb-stripe-card-error {
     36  padding-top: 1em;
     37  color: #E73B2B;
     38}
     39
     40.wsb-content .wsb-form__payment {
     41  margin-bottom: 0;
     42}
     43
     44.wsb-content .wsb-form__card {
     45  border-color: #BBB;
     46  border-radius: 2px;
     47  height: 2em;
     48  margin-bottom: 1em;
     49}
     50.wsb-form__payment-holder {
     51  width: 100%;
     52  display: block;
     53}
     54
     55.wsb-form__payment-holder .wsb-form__error {
     56  padding-bottom: 0;
     57}
     58
     59.wsb-content .wsb-form__btn:disabled {
     60  opacity: 0.5;
     61  cursor: auto;
    1662}
    1763
  • workshop-butler/trunk/public/includes/class-wsb-ajax.php

    r2266411 r2266810  
    110110     * Makes a POST Register request to Workshop Butler API
    111111     */
    112     public static function register_to_event() {
     112    public static function register() {
    113113        if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
    114114            check_ajax_referer( 'wsb-nonce' );
     
    120120            $requests = new WSB_Requests();
    121121            $response = $requests->post( 'attendees/register', $form_data );
     122            wp_send_json( $response->body, $response->http_code );
     123        } else {
     124            exit();
     125        }
     126    }
     127
     128    /**
     129     * Makes a POST Pre-Register request to Workshop Butler API
     130     */
     131    public static function pre_register() {
     132        if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
     133            check_ajax_referer( 'wsb-nonce' );
     134
     135            $form_data = self::replace_changed_keys( $_POST );
     136            unset( $form_data['action'] );
     137            unset( $form_data['_ajax_nonce'] );
     138
     139            $requests = new WSB_Requests();
     140            $response = $requests->post( 'attendees/pre-register', $form_data );
    122141            wp_send_json( $response->body, $response->http_code );
    123142        } else {
  • workshop-butler/trunk/public/includes/models/class-event.php

    r2250704 r2266810  
    2323require_once plugin_dir_path( dirname( __FILE__ ) ) . 'models/class-event-url.php';
    2424require_once plugin_dir_path( dirname( __FILE__ ) ) . 'models/class-cover-image.php';
     25require_once plugin_dir_path( dirname( __FILE__ ) ) . 'models/class-payment.php';
    2526require_once plugin_dir_path( __FILE__ ) . 'form/class-form.php';
    2627
     
    193194     */
    194195    private $url;
     196
     197    /**
     198     * Payment configuration
     199     *
     200     * @since 2.8.0
     201     * @var Payment|null $payment
     202     */
     203    public $payment;
    195204
    196205    /**
     
    237246        $this->trainers = $this->get_trainers( $json_data, $trainer_page_url );
    238247        $this->state    = new Event_State( $this );
     248        $this->payment  = Payment::from_json( $json_data->card_payment );
    239249    }
    240250
  • workshop-butler/trunk/public/includes/shortcodes/class-wsb-registration-page.php

    r2266411 r2266810  
    4141    }
    4242
     43    /**
     44     * Loads templates used later in the other templates
     45     *
     46     * @since 2.7.0
     47     */
    4348    private function load_templates() {
    44         $field          = $this->get_template( 'registration/field', null );
    45         $label          = $this->get_template( 'registration/label', null );
    46         $input          = $this->get_template( 'registration/input', null );
    47         $ticket         = $this->get_template( 'registration/ticket', null );
    48         $ticket_section = $this->get_template( 'registration/ticket-section', null );
     49        $field           = $this->get_template( 'registration/field', null );
     50        $label           = $this->get_template( 'registration/label', null );
     51        $input           = $this->get_template( 'registration/input', null );
     52        $ticket          = $this->get_template( 'registration/ticket', null );
     53        $ticket_section  = $this->get_template( 'registration/ticket-section', null );
     54        $payment_section = $this->get_template( 'registration/payment-section', null );
    4955        $this->twig->loader->setTemplate( 'field.twig', $field );
    5056        $this->twig->loader->setTemplate( 'label.twig', $label );
     
    5258        $this->twig->loader->setTemplate( 'ticket.twig', $ticket );
    5359        $this->twig->loader->setTemplate( 'ticket-section.twig', $ticket_section );
     60        $this->twig->loader->setTemplate( 'payment-section.twig', $payment_section );
    5461    }
    5562
     
    8794        }
    8895        wp_enqueue_script( 'wsb-registration-page' );
     96        if ( $may_be_event->payment ) {
     97            if ( $this->is_https() || $this->is_test( $may_be_event->payment ) ) {
     98                wp_enqueue_script( 'stripe' );
     99            }
     100            $this->add_payment_config( $may_be_event );
     101        }
     102
    89103        $this->add_theme_fonts();
    90104        $this->add_localized_script( $may_be_event );
    91105
    92106        return $this->render_page( $may_be_event );
     107    }
     108
     109    /**
     110     * Returns true if the request is secure
     111     *
     112     * @return bool
     113     */
     114    protected function is_https() {
     115        return
     116            ( ! empty( $_SERVER['HTTPS'] ) && 'off' !== $_SERVER['HTTPS'] )
     117            || 443 === $_SERVER['SERVER_PORT'];
     118    }
     119
     120    /**
     121     * Returns true if the payment is in test mode
     122     *
     123     * @param Payment $payment Payment configuration.
     124     *
     125     * @return bool
     126     */
     127    protected function is_test( $payment ) {
     128        return strpos( $payment->stripe_public_key, 'pk_test_' ) === 0;
    93129    }
    94130
     
    120156            )
    121157        );
     158    }
     159
     160    /**
     161     * Adds payment configuration to the registration page
     162     *
     163     * @param Event $event Event.
     164     *
     165     * @since 2.8.0
     166     */
     167    protected function add_payment_config( $event ) {
     168        if ( $event->payment ) {
     169            wp_localize_script(
     170                'wsb-registration-page',
     171                'wsb_payment',
     172                array(
     173                    'active'            => $event->payment->active,
     174                    'secure'            => $this->is_https(),
     175                    'test'              => $this->is_test( $event->payment ),
     176                    'stripe_public_key' => $event->payment->stripe_public_key,
     177                    'stripe_client_id'  => $event->payment->stripe_client_id,
     178                )
     179            );
     180        }
    122181    }
    123182
  • workshop-butler/trunk/public/js/registration-page.js

    r2266411 r2266810  
    3030    }
    3131}
     32
     33/**
     34 * Creates a Stripe payment form
     35 *
     36 * @returns {{validateInputs: validateInputs, clearCardInput: clearCardInput, createPaymentMethod: createPaymentMethod, disableCardInput: (function(*=): card|void|undefined|Promise<void>|*|IDBRequest<IDBValidKey>), confirmCardPayment: confirmCardPayment, stripeClient: *}}
     37 */
     38function create_stripe_card(stripeHolderEl, publicKey, stripeAccount) {
     39    const x = function (tagName, attrs = null) {
     40        const el = document.createElement(tagName);
     41        if (attrs !== null) Object.entries(attrs).forEach((e) => el.setAttribute(e[0], e[1]));
     42        return el;
     43    };
     44
     45    const options = {};
     46    if (stripeAccount) {
     47        options.stripeAccount = stripeAccount;
     48    }
     49
     50    const cl = Stripe(publicKey, options);
     51
     52    const stripeCardHolderEl = x('div', {'class': 'wsb-stripe-card-element'});
     53    stripeHolderEl.appendChild(stripeCardHolderEl);
     54    const stripeCardErrorsHolderEl = x('div', {'class': 'wsb-stripe-card-error'});
     55    stripeHolderEl.appendChild(stripeCardErrorsHolderEl);
     56    const incompleteMessage = "Your card number is incomplete.";
     57
     58    const elements = cl.elements();
     59    const stripeCardEl = elements.create('card', {
     60        hidePostalCode: true,
     61        style: {
     62            base: {
     63                color: '#32325d',
     64                fontFamily: '"Helvetica Neue", Helvetica, sans-serif',
     65                fontSmoothing: 'antialiased',
     66                fontSize: '16px',
     67                '::placeholder': {
     68                    color: '#aab7c4'
     69                }
     70            },
     71            invalid: {
     72                color: '#fa755a',
     73                iconColor: '#fa755a'
     74            }
     75        }
     76    });
     77
     78    let inputComplete = false;
     79    stripeCardEl.on('change', (e) => {
     80        inputComplete = e.complete;
     81        if (e.error) {
     82            stripeCardErrorsHolderEl.innerHTML = e.error.message;
     83        } else {
     84            stripeCardErrorsHolderEl.innerHTML = "";
     85        }
     86    });
     87    stripeCardEl.mount(stripeCardHolderEl);
     88    return {
     89        stripeClient: cl,
     90        disableCardInput: (disable) => stripeCardEl.update({disabled:disable}),
     91        clearCardInput: () => {
     92            stripeCardEl.clear();
     93            stripeCardErrorsHolderEl.innerHTML = ""
     94        },
     95        validateInputs: () => {
     96            // It is also possible to use createToken method for card validation,
     97            // bit it's not a proper usage and we don't know about possible side effects of it
     98            // cl.createToken(stripeCardEl).then((token)=>console.log(token))
     99            //
     100            if(!inputComplete) {
     101                stripeCardErrorsHolderEl.innerHTML = incompleteMessage;
     102                stripeCardEl.focus(); // not work on iOS 13+
     103                return false;
     104            }
     105            return true;
     106        },
     107        confirmCardPayment: (clientSecret, {payment_method}) => {
     108            if (!inputComplete) {
     109                return Promise.reject(incompleteMessage);
     110            }
     111            return cl.confirmCardPayment(clientSecret, {
     112                payment_method: {
     113                    card: stripeCardEl,
     114                    billing_details: payment_method ? payment_method.billing_details : {},
     115                },
     116            })
     117        },
     118        createPaymentMethod: ({billing_details}) => {
     119            if (!inputComplete) {
     120                return Promise.reject(incompleteMessage);
     121            }
     122            return cl.createPaymentMethod({
     123                type: 'card',
     124                card: stripeCardEl,
     125                billing_details: billing_details || {}
     126            })
     127        }
     128    };
     129}
     130
    32131
    33132/**
     
    58157        );
    59158
    60         this.cardPaymentEnabled = false;
    61         //this._initStripeCard();
    62 
    63         // if (!this.cardPaymentEnabled) {
    64         //  console.log('Card payment allowed: ' + this._cardPaymentAllowed());
    65         //  // const conf = CONFIG.payment || {};
    66         //  const conf = {};
    67         //  console.log('Stripe client id: ' + conf.stripeClientId);
    68         //  console.log('Stripe key: ' + conf.stripeKey);
    69         // }
     159        this.cardPaymentEnabled = this._initStripeCard();
     160        this.invoicePaymentEnabled = !this._isPaymentActive() || this._invoicePaymentAllowed();
    70161
    71162        this._assignEvents();
     
    81172        return {
    82173            $formControls: $root.find('[data-control]'),
    83             $btnToggle: $root.find('[data-widget-register]'),
    84             $btnSubmit: $root.find('[data-widget-submit]'),
     174            $btnSubmit: $root.find('[type="submit"]'),
    85175            $cardSection: $root.find('[data-card-section]'),
    86176            $success: jQuery('#wsb-success'),
     
    92182        this.initPromoActivation();
    93183        this.initActiveTicketSelection();
     184        this._isNotSecure();
     185        this._checkPaymentMethods();
     186    }
     187
     188    _checkPaymentMethods() {
     189        if (this.cardPaymentEnabled || this.invoicePaymentEnabled) {
     190            return;
     191        }
     192        this.$root.addClass('wsb-form-without-payment');
     193        this.$root.find('[data-payment-section]').hide();
     194        this.formIsLocked = true;
     195        this.locals.$btnSubmit.prop('disabled', true);
     196    }
     197
     198    _isNotSecure() {
     199        if (this._isPaymentActive() && !this._isPageSecure()) {
     200            this.$root.addClass('wsb-form-not-secure');
     201            this._getCardPaymentOption().prop('disabled', 'disabled').removeProp('selected');
     202        }
     203    }
     204
     205    _getCardPaymentOption() {
     206        return this.$root.find('[data-control][name="payment_type"] option[value="Card"]');
     207    }
     208
     209    /**
     210     * Returns true if the payment configuration is available
     211     * @returns boolean
     212     * @private
     213     */
     214    _isPaymentActive() {
     215        return wsb_payment && wsb_payment.active && wsb_payment.stripe_client_id && wsb_payment.stripe_public_key;
     216    }
     217
     218    /**
     219     * Returns true if it's allowed to use card payments on this page
     220     * @returns boolean
     221     * @private
     222     */
     223    _isPageSecure() {
     224        return wsb_payment.secure || wsb_payment.test;
    94225    }
    95226
    96227    _cardPaymentAllowed() {
    97         return !!this.$root.find('[data-control][name="payment_type"] option[value="Card"]').length;
     228        return !!this._getCardPaymentOption().length;
     229    }
     230
     231    _invoicePaymentAllowed() {
     232        return !!this.$root.find('[data-control][name="payment_type"] option[value="Invoice"]').length;
    98233    }
    99234
     
    114249        if (!(
    115250            this._cardPaymentAllowed()
    116             && CONFIG.payment
    117             && CONFIG.payment.stripeClientId
    118             && CONFIG.payment.stripeKey)
     251            && this._isPaymentActive()
     252            && this._isPageSecure())
    119253        ) return false;
    120254
    121         this.stripeCard = createStripeCard(
     255        this.stripeCard = create_stripe_card(
    122256            this.$root.find("#stripe-placeholder")[0],
    123             CONFIG.payment.stripeKey,
    124             CONFIG.payment.stripeClientId);
     257            wsb_payment.stripe_public_key,
     258            wsb_payment.stripe_client_id);
    125259
    126260        this._displayCardSection(this._cardPaymentSelected());
     
    191325    _onSubmitForm(e) {
    192326        e.preventDefault();
     327        console.log("SUBMIT");
    193328
    194329        if (this.formIsLocked) return;
     
    226361
    227362        const formData = self.formHelper.getFormData();
    228         const registrationUrl = self.$root.attr('action');
    229         // const preparePaymentUrl = self.$root.data("preparePaymentUrl");
    230         const preparePaymentUrl = wsb_event.ajax_url;
     363        const url = wsb_event.ajax_url;
    231364
    232365        self._lockFormSubmit();
    233         self._sendFormData(preparePaymentUrl, formData)
     366        self._sendFormData(url, this._prepareFormData(formData, true))
    234367            .done((data) => {
    235                 self._processCardPayment(registrationUrl, formData, data.data.client_secret);
     368                self._processCardPayment(url, formData, data.data.stripe_client_secret);
    236369            }).fail(self._processFailResponse);
    237370    }
     
    243376
    244377        const formData = self.formHelper.getFormData();
    245         // const registrationUrl = self.$root.attr('action');
    246378        const registrationUrl = wsb_event.ajax_url;
    247379
    248380        self._lockFormSubmit();
    249         self._sendFormData(registrationUrl, this._prepareFormData(formData))
     381        self._sendFormData(registrationUrl, this._prepareFormData(formData, false))
    250382            .done(() => {
    251383                self._submitSucceed();
     
    257389     *
    258390     * @param data {object} Form data
     391     * @param preRegister {boolean} True if the call is to pre-register
    259392     * @return {object}
    260393     */
    261     _prepareFormData(data) {
    262         data.action = 'wsb_register_to_event';
     394    _prepareFormData(data, preRegister) {
     395        data.action = preRegister ? 'wsb_pre_register' : 'wsb_register';
    263396        data._ajax_nonce = wsb_event.nonce;
    264397        data.event_id = Number(wsb_event.id);
     
    316449            formData['intent_id'] = result.paymentIntent.id;
    317450
    318             self._sendFormData(url, formData)
     451            self._sendFormData(url, this._prepareFormData(formData, false))
    319452                .done(() => {
    320453                    self._submitSucceed();
     
    367500    // transport
    368501    _sendFormData(url, data) {
    369         data.action = 'wsb_register_to_event';
    370502        data._ajax_nonce = wsb_event.nonce;
    371503        return $.ajax({
  • workshop-butler/trunk/views/registration/form.twig

    r2258174 r2266810  
    1616            {% if section.id == 'ticket' %}
    1717                {{ include('ticket-section.twig') }}
     18            {% elseif section.id == 'payment' %}
     19                <div class="wsb-form__payment-alert wsb-not-secure-alert">
     20                    This page is not secure. Card payments are turned off.
     21                </div>
     22                <div class="wsb-form__payment-alert wsb-no-payment-method">
     23                    No payment method is available. You cannot register to this event.
     24                </div>
     25                {{ include('payment-section.twig') }}
    1826            {% else %}
    1927                <section>
     
    3240        {% else %}
    3341            <button type="submit" class="wsb-form__btn">
    34                 {{ wsb_t('event.form.button') }}
     42                <i class="fa fa-spinner fa-spin" style="display: none;"></i> {{ wsb_t('event.form.button') }}
    3543            </button>
    3644        {% endif %}
  • workshop-butler/trunk/workshop-butler.php

    r2266411 r2266810  
    1212 * Description:       This plugin integrates Workshop Butler Events, Trainers and Testimonials to your WordPress
    1313 *     website.
    14  * Version:           2.7.6
     14 * Version:           2.8.0
    1515 * Author:            Workshop Butler
    1616 * Author URI:        https://workshopbutler.com/
     
    2929 * Currently plugin version.
    3030 */
    31 define( 'WSB_INTEGRATION_VERSION', '2.7.6' );
     31define( 'WSB_INTEGRATION_VERSION', '2.8.0' );
    3232
    3333/**
    3434 * Version of Workshop Butler API, used by this plugin
    3535 */
    36 define( 'WSB_API_VERSION', '2020-01-23' );
     36define( 'WSB_API_VERSION', '2020-03-19' );
    3737
    3838/**
Note: See TracChangeset for help on using the changeset viewer.