Changeset 2266810
- Timestamp:
- 03/24/2020 07:57:29 PM (6 years ago)
- Location:
- workshop-butler
- Files:
-
- 4 added
- 48 edited
- 1 copied
-
tags/2.8.0 (copied) (copied from workshop-butler/trunk)
-
tags/2.8.0/languages/wsbintegration-de_DE.mo (modified) (previous)
-
tags/2.8.0/languages/wsbintegration-de_DE.po (modified) (2 diffs)
-
tags/2.8.0/languages/wsbintegration-en_US.mo (modified) (previous)
-
tags/2.8.0/languages/wsbintegration-en_US.po (modified) (2 diffs)
-
tags/2.8.0/languages/wsbintegration-es_ES.mo (modified) (previous)
-
tags/2.8.0/languages/wsbintegration-es_ES.po (modified) (2 diffs)
-
tags/2.8.0/languages/wsbintegration-fr_FR.mo (modified) (previous)
-
tags/2.8.0/languages/wsbintegration-fr_FR.po (modified) (2 diffs)
-
tags/2.8.0/languages/wsbintegration-nb_NO.mo (modified) (previous)
-
tags/2.8.0/languages/wsbintegration-nb_NO.po (modified) (1 diff)
-
tags/2.8.0/languages/wsbintegration-nl_NL.mo (modified) (previous)
-
tags/2.8.0/languages/wsbintegration-nl_NL.po (modified) (2 diffs)
-
tags/2.8.0/languages/wsbintegration-nn_NO.mo (modified) (previous)
-
tags/2.8.0/languages/wsbintegration-nn_NO.po (modified) (1 diff)
-
tags/2.8.0/languages/wsbintegration-pt_PT.mo (modified) (previous)
-
tags/2.8.0/languages/wsbintegration-pt_PT.po (modified) (2 diffs)
-
tags/2.8.0/public/class-wsb-integration-public.php (modified) (2 diffs)
-
tags/2.8.0/public/css/wsb.wordpress.css (modified) (1 diff)
-
tags/2.8.0/public/includes/class-wsb-ajax.php (modified) (2 diffs)
-
tags/2.8.0/public/includes/models/class-event.php (modified) (3 diffs)
-
tags/2.8.0/public/includes/models/class-payment.php (added)
-
tags/2.8.0/public/includes/shortcodes/class-wsb-registration-page.php (modified) (4 diffs)
-
tags/2.8.0/public/js/registration-page.js (modified) (11 diffs)
-
tags/2.8.0/views/registration/form.twig (modified) (2 diffs)
-
tags/2.8.0/views/registration/payment-section.twig (added)
-
tags/2.8.0/workshop-butler.php (modified) (2 diffs)
-
trunk/languages/wsbintegration-de_DE.mo (modified) (previous)
-
trunk/languages/wsbintegration-de_DE.po (modified) (2 diffs)
-
trunk/languages/wsbintegration-en_US.mo (modified) (previous)
-
trunk/languages/wsbintegration-en_US.po (modified) (2 diffs)
-
trunk/languages/wsbintegration-es_ES.mo (modified) (previous)
-
trunk/languages/wsbintegration-es_ES.po (modified) (2 diffs)
-
trunk/languages/wsbintegration-fr_FR.mo (modified) (previous)
-
trunk/languages/wsbintegration-fr_FR.po (modified) (2 diffs)
-
trunk/languages/wsbintegration-nb_NO.mo (modified) (previous)
-
trunk/languages/wsbintegration-nb_NO.po (modified) (1 diff)
-
trunk/languages/wsbintegration-nl_NL.mo (modified) (previous)
-
trunk/languages/wsbintegration-nl_NL.po (modified) (2 diffs)
-
trunk/languages/wsbintegration-nn_NO.mo (modified) (previous)
-
trunk/languages/wsbintegration-nn_NO.po (modified) (1 diff)
-
trunk/languages/wsbintegration-pt_PT.mo (modified) (previous)
-
trunk/languages/wsbintegration-pt_PT.po (modified) (2 diffs)
-
trunk/public/class-wsb-integration-public.php (modified) (2 diffs)
-
trunk/public/css/wsb.wordpress.css (modified) (1 diff)
-
trunk/public/includes/class-wsb-ajax.php (modified) (2 diffs)
-
trunk/public/includes/models/class-event.php (modified) (3 diffs)
-
trunk/public/includes/models/class-payment.php (added)
-
trunk/public/includes/shortcodes/class-wsb-registration-page.php (modified) (4 diffs)
-
trunk/public/js/registration-page.js (modified) (11 diffs)
-
trunk/views/registration/form.twig (modified) (2 diffs)
-
trunk/views/registration/payment-section.twig (added)
-
trunk/workshop-butler.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
workshop-butler/tags/2.8.0/languages/wsbintegration-de_DE.po
r2266411 r2266810 6 6 "Content-Transfer-Encoding: 8bit\n" 7 7 "Plural-Forms: nplurals=2; plural=(n != 1)\n" 8 "POT-Creation-Date: 2020-03-22T1 1:58:26.323Z\n"9 "PO-Revision-Date: 2020-03-22T1 1: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" 10 10 "Language: de\n" 11 11 … … 1180 1180 msgstr "Adresse (Zeile 2)" 1181 1181 1182 msgid "form.field.payment_type" 1183 msgstr "Bezahlverfahren" 1184 1182 1185 msgid "form.field.street_first" 1183 1186 msgstr "Adresse (Zeile 1)" -
workshop-butler/tags/2.8.0/languages/wsbintegration-en_US.po
r2266411 r2266810 6 6 "Content-Transfer-Encoding: 8bit\n" 7 7 "Plural-Forms: nplurals=2; plural=(n != 1)\n" 8 "POT-Creation-Date: 2020-03-22T1 1:58:26.012Z\n"9 "PO-Revision-Date: 2020-03-22T1 1: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" 10 10 "Language: en\n" 11 11 … … 1141 1141 msgstr "Street 2" 1142 1142 1143 msgid "form.field.payment_type" 1144 msgstr "Payment method" 1145 1143 1146 msgid "form.field.street_first" 1144 1147 msgstr "Street 1" -
workshop-butler/tags/2.8.0/languages/wsbintegration-es_ES.po
r2266411 r2266810 6 6 "Content-Transfer-Encoding: 8bit\n" 7 7 "Plural-Forms: nplurals=2; plural=(n != 1)\n" 8 "POT-Creation-Date: 2020-03-22T1 1:58:26.619Z\n"9 "PO-Revision-Date: 2020-03-22T1 1: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" 10 10 "Language: es\n" 11 11 … … 1180 1180 msgstr "Calle 2" 1181 1181 1182 msgid "form.field.payment_type" 1183 msgstr "Método de pago" 1184 1182 1185 msgid "form.field.street_first" 1183 1186 msgstr "Calle 1" -
workshop-butler/tags/2.8.0/languages/wsbintegration-fr_FR.po
r2266411 r2266810 6 6 "Content-Transfer-Encoding: 8bit\n" 7 7 "Plural-Forms: nplurals=2; plural=(n > 1)\n" 8 "POT-Creation-Date: 2020-03-22T1 1:58:26.922Z\n"9 "PO-Revision-Date: 2020-03-22T1 1: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" 10 10 "Language: fr\n" 11 11 … … 1180 1180 msgstr "Rue 2" 1181 1181 1182 msgid "form.field.payment_type" 1183 msgstr "Mode de paiement" 1184 1182 1185 msgid "form.field.street_first" 1183 1186 msgstr "Rue 1" -
workshop-butler/tags/2.8.0/languages/wsbintegration-nb_NO.po
r2266411 r2266810 6 6 "Content-Transfer-Encoding: 8bit\n" 7 7 "Plural-Forms: nplurals=2; plural=(n != 1)\n" 8 "POT-Creation-Date: 2020-03-22T1 1:58:27.823Z\n"9 "PO-Revision-Date: 2020-03-22T1 1: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" 10 10 "Language: nb\n" 11 11 -
workshop-butler/tags/2.8.0/languages/wsbintegration-nl_NL.po
r2266411 r2266810 6 6 "Content-Transfer-Encoding: 8bit\n" 7 7 "Plural-Forms: nplurals=2; plural=(n != 1)\n" 8 "POT-Creation-Date: 2020-03-22T1 1:58:27.231Z\n"9 "PO-Revision-Date: 2020-03-22T1 1: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" 10 10 "Language: nl\n" 11 11 … … 1180 1180 msgstr "Straat 2" 1181 1181 1182 msgid "form.field.payment_type" 1183 msgstr "Betalingswijze" 1184 1182 1185 msgid "form.field.street_first" 1183 1186 msgstr "Straat 1" -
workshop-butler/tags/2.8.0/languages/wsbintegration-nn_NO.po
r2266411 r2266810 6 6 "Content-Transfer-Encoding: 8bit\n" 7 7 "Plural-Forms: nplurals=2; plural=(n != 1)\n" 8 "POT-Creation-Date: 2020-03-22T1 1:58:27.527Z\n"9 "PO-Revision-Date: 2020-03-22T1 1: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" 10 10 "Language: nn\n" 11 11 -
workshop-butler/tags/2.8.0/languages/wsbintegration-pt_PT.po
r2266411 r2266810 6 6 "Content-Transfer-Encoding: 8bit\n" 7 7 "Plural-Forms: nplurals=2; plural=(n > 1)\n" 8 "POT-Creation-Date: 2020-03-22T1 1:58:28.132Z\n"9 "PO-Revision-Date: 2020-03-22T1 1: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" 10 10 "Language: pt\n" 11 11 … … 1180 1180 msgstr "Endereço 2" 1181 1181 1182 msgid "form.field.payment_type" 1183 msgstr "Forma de pagamento" 1184 1182 1185 msgid "form.field.street_first" 1183 1186 msgstr "Endereço 1" -
workshop-butler/tags/2.8.0/public/class-wsb-integration-public.php
r2258174 r2266810 116 116 wp_register_script( 'jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js', false, null ); 117 117 wp_enqueue_script( 'jquery' ); 118 119 wp_register_script( 'stripe', 'https://js.stripe.com/v3/' ); 118 120 119 121 $ga_key = WSB_Options::get_option( WSB_Options::GA_API_KEY ); … … 311 313 add_action( 'wp_ajax_wsb_get_values', array( 'WorkshopButler\WSB_Ajax', 'get_values' ) ); 312 314 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' ) ); 315 320 } 316 321 } -
workshop-butler/tags/2.8.0/public/css/wsb.wordpress.css
r2266411 r2266810 9 9 } 10 10 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 { 12 33 position: relative; 13 34 } 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; 16 62 } 17 63 -
workshop-butler/tags/2.8.0/public/includes/class-wsb-ajax.php
r2266411 r2266810 110 110 * Makes a POST Register request to Workshop Butler API 111 111 */ 112 public static function register _to_event() {112 public static function register() { 113 113 if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { 114 114 check_ajax_referer( 'wsb-nonce' ); … … 120 120 $requests = new WSB_Requests(); 121 121 $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 ); 122 141 wp_send_json( $response->body, $response->http_code ); 123 142 } else { -
workshop-butler/tags/2.8.0/public/includes/models/class-event.php
r2250704 r2266810 23 23 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'models/class-event-url.php'; 24 24 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'models/class-cover-image.php'; 25 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'models/class-payment.php'; 25 26 require_once plugin_dir_path( __FILE__ ) . 'form/class-form.php'; 26 27 … … 193 194 */ 194 195 private $url; 196 197 /** 198 * Payment configuration 199 * 200 * @since 2.8.0 201 * @var Payment|null $payment 202 */ 203 public $payment; 195 204 196 205 /** … … 237 246 $this->trainers = $this->get_trainers( $json_data, $trainer_page_url ); 238 247 $this->state = new Event_State( $this ); 248 $this->payment = Payment::from_json( $json_data->card_payment ); 239 249 } 240 250 -
workshop-butler/tags/2.8.0/public/includes/shortcodes/class-wsb-registration-page.php
r2266411 r2266810 41 41 } 42 42 43 /** 44 * Loads templates used later in the other templates 45 * 46 * @since 2.7.0 47 */ 43 48 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 ); 49 55 $this->twig->loader->setTemplate( 'field.twig', $field ); 50 56 $this->twig->loader->setTemplate( 'label.twig', $label ); … … 52 58 $this->twig->loader->setTemplate( 'ticket.twig', $ticket ); 53 59 $this->twig->loader->setTemplate( 'ticket-section.twig', $ticket_section ); 60 $this->twig->loader->setTemplate( 'payment-section.twig', $payment_section ); 54 61 } 55 62 … … 87 94 } 88 95 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 89 103 $this->add_theme_fonts(); 90 104 $this->add_localized_script( $may_be_event ); 91 105 92 106 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; 93 129 } 94 130 … … 120 156 ) 121 157 ); 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 } 122 181 } 123 182 -
workshop-butler/tags/2.8.0/public/js/registration-page.js
r2266411 r2266810 30 30 } 31 31 } 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 */ 38 function 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 32 131 33 132 /** … … 58 157 ); 59 158 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(); 70 161 71 162 this._assignEvents(); … … 81 172 return { 82 173 $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"]'), 85 175 $cardSection: $root.find('[data-card-section]'), 86 176 $success: jQuery('#wsb-success'), … … 92 182 this.initPromoActivation(); 93 183 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; 94 225 } 95 226 96 227 _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; 98 233 } 99 234 … … 114 249 if (!( 115 250 this._cardPaymentAllowed() 116 && CONFIG.payment 117 && CONFIG.payment.stripeClientId 118 && CONFIG.payment.stripeKey) 251 && this._isPaymentActive() 252 && this._isPageSecure()) 119 253 ) return false; 120 254 121 this.stripeCard = create StripeCard(255 this.stripeCard = create_stripe_card( 122 256 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); 125 259 126 260 this._displayCardSection(this._cardPaymentSelected()); … … 191 325 _onSubmitForm(e) { 192 326 e.preventDefault(); 327 console.log("SUBMIT"); 193 328 194 329 if (this.formIsLocked) return; … … 226 361 227 362 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; 231 364 232 365 self._lockFormSubmit(); 233 self._sendFormData( preparePaymentUrl, formData)366 self._sendFormData(url, this._prepareFormData(formData, true)) 234 367 .done((data) => { 235 self._processCardPayment( registrationUrl, formData, data.data.client_secret);368 self._processCardPayment(url, formData, data.data.stripe_client_secret); 236 369 }).fail(self._processFailResponse); 237 370 } … … 243 376 244 377 const formData = self.formHelper.getFormData(); 245 // const registrationUrl = self.$root.attr('action');246 378 const registrationUrl = wsb_event.ajax_url; 247 379 248 380 self._lockFormSubmit(); 249 self._sendFormData(registrationUrl, this._prepareFormData(formData ))381 self._sendFormData(registrationUrl, this._prepareFormData(formData, false)) 250 382 .done(() => { 251 383 self._submitSucceed(); … … 257 389 * 258 390 * @param data {object} Form data 391 * @param preRegister {boolean} True if the call is to pre-register 259 392 * @return {object} 260 393 */ 261 _prepareFormData(data ) {262 data.action = 'wsb_register_to_event';394 _prepareFormData(data, preRegister) { 395 data.action = preRegister ? 'wsb_pre_register' : 'wsb_register'; 263 396 data._ajax_nonce = wsb_event.nonce; 264 397 data.event_id = Number(wsb_event.id); … … 316 449 formData['intent_id'] = result.paymentIntent.id; 317 450 318 self._sendFormData(url, formData)451 self._sendFormData(url, this._prepareFormData(formData, false)) 319 452 .done(() => { 320 453 self._submitSucceed(); … … 367 500 // transport 368 501 _sendFormData(url, data) { 369 data.action = 'wsb_register_to_event';370 502 data._ajax_nonce = wsb_event.nonce; 371 503 return $.ajax({ -
workshop-butler/tags/2.8.0/views/registration/form.twig
r2258174 r2266810 16 16 {% if section.id == 'ticket' %} 17 17 {{ 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') }} 18 26 {% else %} 19 27 <section> … … 32 40 {% else %} 33 41 <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') }} 35 43 </button> 36 44 {% endif %} -
workshop-butler/tags/2.8.0/workshop-butler.php
r2266411 r2266810 12 12 * Description: This plugin integrates Workshop Butler Events, Trainers and Testimonials to your WordPress 13 13 * website. 14 * Version: 2. 7.614 * Version: 2.8.0 15 15 * Author: Workshop Butler 16 16 * Author URI: https://workshopbutler.com/ … … 29 29 * Currently plugin version. 30 30 */ 31 define( 'WSB_INTEGRATION_VERSION', '2. 7.6' );31 define( 'WSB_INTEGRATION_VERSION', '2.8.0' ); 32 32 33 33 /** 34 34 * Version of Workshop Butler API, used by this plugin 35 35 */ 36 define( 'WSB_API_VERSION', '2020-0 1-23' );36 define( 'WSB_API_VERSION', '2020-03-19' ); 37 37 38 38 /** -
workshop-butler/trunk/languages/wsbintegration-de_DE.po
r2266411 r2266810 6 6 "Content-Transfer-Encoding: 8bit\n" 7 7 "Plural-Forms: nplurals=2; plural=(n != 1)\n" 8 "POT-Creation-Date: 2020-03-22T1 1:58:26.323Z\n"9 "PO-Revision-Date: 2020-03-22T1 1: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" 10 10 "Language: de\n" 11 11 … … 1180 1180 msgstr "Adresse (Zeile 2)" 1181 1181 1182 msgid "form.field.payment_type" 1183 msgstr "Bezahlverfahren" 1184 1182 1185 msgid "form.field.street_first" 1183 1186 msgstr "Adresse (Zeile 1)" -
workshop-butler/trunk/languages/wsbintegration-en_US.po
r2266411 r2266810 6 6 "Content-Transfer-Encoding: 8bit\n" 7 7 "Plural-Forms: nplurals=2; plural=(n != 1)\n" 8 "POT-Creation-Date: 2020-03-22T1 1:58:26.012Z\n"9 "PO-Revision-Date: 2020-03-22T1 1: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" 10 10 "Language: en\n" 11 11 … … 1141 1141 msgstr "Street 2" 1142 1142 1143 msgid "form.field.payment_type" 1144 msgstr "Payment method" 1145 1143 1146 msgid "form.field.street_first" 1144 1147 msgstr "Street 1" -
workshop-butler/trunk/languages/wsbintegration-es_ES.po
r2266411 r2266810 6 6 "Content-Transfer-Encoding: 8bit\n" 7 7 "Plural-Forms: nplurals=2; plural=(n != 1)\n" 8 "POT-Creation-Date: 2020-03-22T1 1:58:26.619Z\n"9 "PO-Revision-Date: 2020-03-22T1 1: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" 10 10 "Language: es\n" 11 11 … … 1180 1180 msgstr "Calle 2" 1181 1181 1182 msgid "form.field.payment_type" 1183 msgstr "Método de pago" 1184 1182 1185 msgid "form.field.street_first" 1183 1186 msgstr "Calle 1" -
workshop-butler/trunk/languages/wsbintegration-fr_FR.po
r2266411 r2266810 6 6 "Content-Transfer-Encoding: 8bit\n" 7 7 "Plural-Forms: nplurals=2; plural=(n > 1)\n" 8 "POT-Creation-Date: 2020-03-22T1 1:58:26.922Z\n"9 "PO-Revision-Date: 2020-03-22T1 1: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" 10 10 "Language: fr\n" 11 11 … … 1180 1180 msgstr "Rue 2" 1181 1181 1182 msgid "form.field.payment_type" 1183 msgstr "Mode de paiement" 1184 1182 1185 msgid "form.field.street_first" 1183 1186 msgstr "Rue 1" -
workshop-butler/trunk/languages/wsbintegration-nb_NO.po
r2266411 r2266810 6 6 "Content-Transfer-Encoding: 8bit\n" 7 7 "Plural-Forms: nplurals=2; plural=(n != 1)\n" 8 "POT-Creation-Date: 2020-03-22T1 1:58:27.823Z\n"9 "PO-Revision-Date: 2020-03-22T1 1: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" 10 10 "Language: nb\n" 11 11 -
workshop-butler/trunk/languages/wsbintegration-nl_NL.po
r2266411 r2266810 6 6 "Content-Transfer-Encoding: 8bit\n" 7 7 "Plural-Forms: nplurals=2; plural=(n != 1)\n" 8 "POT-Creation-Date: 2020-03-22T1 1:58:27.231Z\n"9 "PO-Revision-Date: 2020-03-22T1 1: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" 10 10 "Language: nl\n" 11 11 … … 1180 1180 msgstr "Straat 2" 1181 1181 1182 msgid "form.field.payment_type" 1183 msgstr "Betalingswijze" 1184 1182 1185 msgid "form.field.street_first" 1183 1186 msgstr "Straat 1" -
workshop-butler/trunk/languages/wsbintegration-nn_NO.po
r2266411 r2266810 6 6 "Content-Transfer-Encoding: 8bit\n" 7 7 "Plural-Forms: nplurals=2; plural=(n != 1)\n" 8 "POT-Creation-Date: 2020-03-22T1 1:58:27.527Z\n"9 "PO-Revision-Date: 2020-03-22T1 1: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" 10 10 "Language: nn\n" 11 11 -
workshop-butler/trunk/languages/wsbintegration-pt_PT.po
r2266411 r2266810 6 6 "Content-Transfer-Encoding: 8bit\n" 7 7 "Plural-Forms: nplurals=2; plural=(n > 1)\n" 8 "POT-Creation-Date: 2020-03-22T1 1:58:28.132Z\n"9 "PO-Revision-Date: 2020-03-22T1 1: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" 10 10 "Language: pt\n" 11 11 … … 1180 1180 msgstr "Endereço 2" 1181 1181 1182 msgid "form.field.payment_type" 1183 msgstr "Forma de pagamento" 1184 1182 1185 msgid "form.field.street_first" 1183 1186 msgstr "Endereço 1" -
workshop-butler/trunk/public/class-wsb-integration-public.php
r2258174 r2266810 116 116 wp_register_script( 'jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js', false, null ); 117 117 wp_enqueue_script( 'jquery' ); 118 119 wp_register_script( 'stripe', 'https://js.stripe.com/v3/' ); 118 120 119 121 $ga_key = WSB_Options::get_option( WSB_Options::GA_API_KEY ); … … 311 313 add_action( 'wp_ajax_wsb_get_values', array( 'WorkshopButler\WSB_Ajax', 'get_values' ) ); 312 314 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' ) ); 315 320 } 316 321 } -
workshop-butler/trunk/public/css/wsb.wordpress.css
r2266411 r2266810 9 9 } 10 10 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 { 12 33 position: relative; 13 34 } 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; 16 62 } 17 63 -
workshop-butler/trunk/public/includes/class-wsb-ajax.php
r2266411 r2266810 110 110 * Makes a POST Register request to Workshop Butler API 111 111 */ 112 public static function register _to_event() {112 public static function register() { 113 113 if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { 114 114 check_ajax_referer( 'wsb-nonce' ); … … 120 120 $requests = new WSB_Requests(); 121 121 $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 ); 122 141 wp_send_json( $response->body, $response->http_code ); 123 142 } else { -
workshop-butler/trunk/public/includes/models/class-event.php
r2250704 r2266810 23 23 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'models/class-event-url.php'; 24 24 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'models/class-cover-image.php'; 25 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'models/class-payment.php'; 25 26 require_once plugin_dir_path( __FILE__ ) . 'form/class-form.php'; 26 27 … … 193 194 */ 194 195 private $url; 196 197 /** 198 * Payment configuration 199 * 200 * @since 2.8.0 201 * @var Payment|null $payment 202 */ 203 public $payment; 195 204 196 205 /** … … 237 246 $this->trainers = $this->get_trainers( $json_data, $trainer_page_url ); 238 247 $this->state = new Event_State( $this ); 248 $this->payment = Payment::from_json( $json_data->card_payment ); 239 249 } 240 250 -
workshop-butler/trunk/public/includes/shortcodes/class-wsb-registration-page.php
r2266411 r2266810 41 41 } 42 42 43 /** 44 * Loads templates used later in the other templates 45 * 46 * @since 2.7.0 47 */ 43 48 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 ); 49 55 $this->twig->loader->setTemplate( 'field.twig', $field ); 50 56 $this->twig->loader->setTemplate( 'label.twig', $label ); … … 52 58 $this->twig->loader->setTemplate( 'ticket.twig', $ticket ); 53 59 $this->twig->loader->setTemplate( 'ticket-section.twig', $ticket_section ); 60 $this->twig->loader->setTemplate( 'payment-section.twig', $payment_section ); 54 61 } 55 62 … … 87 94 } 88 95 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 89 103 $this->add_theme_fonts(); 90 104 $this->add_localized_script( $may_be_event ); 91 105 92 106 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; 93 129 } 94 130 … … 120 156 ) 121 157 ); 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 } 122 181 } 123 182 -
workshop-butler/trunk/public/js/registration-page.js
r2266411 r2266810 30 30 } 31 31 } 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 */ 38 function 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 32 131 33 132 /** … … 58 157 ); 59 158 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(); 70 161 71 162 this._assignEvents(); … … 81 172 return { 82 173 $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"]'), 85 175 $cardSection: $root.find('[data-card-section]'), 86 176 $success: jQuery('#wsb-success'), … … 92 182 this.initPromoActivation(); 93 183 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; 94 225 } 95 226 96 227 _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; 98 233 } 99 234 … … 114 249 if (!( 115 250 this._cardPaymentAllowed() 116 && CONFIG.payment 117 && CONFIG.payment.stripeClientId 118 && CONFIG.payment.stripeKey) 251 && this._isPaymentActive() 252 && this._isPageSecure()) 119 253 ) return false; 120 254 121 this.stripeCard = create StripeCard(255 this.stripeCard = create_stripe_card( 122 256 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); 125 259 126 260 this._displayCardSection(this._cardPaymentSelected()); … … 191 325 _onSubmitForm(e) { 192 326 e.preventDefault(); 327 console.log("SUBMIT"); 193 328 194 329 if (this.formIsLocked) return; … … 226 361 227 362 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; 231 364 232 365 self._lockFormSubmit(); 233 self._sendFormData( preparePaymentUrl, formData)366 self._sendFormData(url, this._prepareFormData(formData, true)) 234 367 .done((data) => { 235 self._processCardPayment( registrationUrl, formData, data.data.client_secret);368 self._processCardPayment(url, formData, data.data.stripe_client_secret); 236 369 }).fail(self._processFailResponse); 237 370 } … … 243 376 244 377 const formData = self.formHelper.getFormData(); 245 // const registrationUrl = self.$root.attr('action');246 378 const registrationUrl = wsb_event.ajax_url; 247 379 248 380 self._lockFormSubmit(); 249 self._sendFormData(registrationUrl, this._prepareFormData(formData ))381 self._sendFormData(registrationUrl, this._prepareFormData(formData, false)) 250 382 .done(() => { 251 383 self._submitSucceed(); … … 257 389 * 258 390 * @param data {object} Form data 391 * @param preRegister {boolean} True if the call is to pre-register 259 392 * @return {object} 260 393 */ 261 _prepareFormData(data ) {262 data.action = 'wsb_register_to_event';394 _prepareFormData(data, preRegister) { 395 data.action = preRegister ? 'wsb_pre_register' : 'wsb_register'; 263 396 data._ajax_nonce = wsb_event.nonce; 264 397 data.event_id = Number(wsb_event.id); … … 316 449 formData['intent_id'] = result.paymentIntent.id; 317 450 318 self._sendFormData(url, formData)451 self._sendFormData(url, this._prepareFormData(formData, false)) 319 452 .done(() => { 320 453 self._submitSucceed(); … … 367 500 // transport 368 501 _sendFormData(url, data) { 369 data.action = 'wsb_register_to_event';370 502 data._ajax_nonce = wsb_event.nonce; 371 503 return $.ajax({ -
workshop-butler/trunk/views/registration/form.twig
r2258174 r2266810 16 16 {% if section.id == 'ticket' %} 17 17 {{ 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') }} 18 26 {% else %} 19 27 <section> … … 32 40 {% else %} 33 41 <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') }} 35 43 </button> 36 44 {% endif %} -
workshop-butler/trunk/workshop-butler.php
r2266411 r2266810 12 12 * Description: This plugin integrates Workshop Butler Events, Trainers and Testimonials to your WordPress 13 13 * website. 14 * Version: 2. 7.614 * Version: 2.8.0 15 15 * Author: Workshop Butler 16 16 * Author URI: https://workshopbutler.com/ … … 29 29 * Currently plugin version. 30 30 */ 31 define( 'WSB_INTEGRATION_VERSION', '2. 7.6' );31 define( 'WSB_INTEGRATION_VERSION', '2.8.0' ); 32 32 33 33 /** 34 34 * Version of Workshop Butler API, used by this plugin 35 35 */ 36 define( 'WSB_API_VERSION', '2020-0 1-23' );36 define( 'WSB_API_VERSION', '2020-03-19' ); 37 37 38 38 /**
Note: See TracChangeset
for help on using the changeset viewer.