Hooks for stripe

This commit is contained in:
Mike Jolley 2012-06-19 19:09:51 +01:00
parent 74fbd56d5b
commit c9ddba1e35
5 changed files with 58 additions and 43 deletions

View File

@ -708,50 +708,63 @@ jQuery(document).ready(function($) {
/* AJAX Form Submission */
$('form.checkout').submit( function() {
var $form = $(this);
if ($form.is('.processing')) return false;
$form.addClass('processing').block({message: null, overlayCSS: {background: '#fff url(' + woocommerce_params.plugin_url + '/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6}});
$.ajax({
type: 'POST',
url: woocommerce_params.checkout_url,
data: $form.serialize(),
success: function( code ) {
$('.woocommerce_error, .woocommerce_message').remove();
try {
result = $.parseJSON( code );
if (result.result=='success') {
if ( $form.is('.processing') )
return false;
// Trigger a handler to let gateways manipulate the checkout if needed
if ( $form.triggerHandler('checkout_place_order') !== false && $form.triggerHandler('checkout_place_order_' + $('#order_review input[name=payment_method]:checked').val() ) !== false ) {
$form.addClass('processing');
var form_data = $form.data();
if ( form_data["blockUI.isBlocked"] != 1 )
$form.block({message: null, overlayCSS: {background: '#fff url(' + woocommerce_params.plugin_url + '/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6}});
$.ajax({
type: 'POST',
url: woocommerce_params.checkout_url,
data: $form.serialize(),
success: function( code ) {
try {
result = $.parseJSON( code );
window.location = decodeURI(result.redirect);
if (result.result=='success') {
window.location = decodeURI(result.redirect);
} else if (result.result=='failure') {
$('.woocommerce_error, .woocommerce_message').remove();
$form.prepend( result.messages );
$form.removeClass('processing').unblock();
} else if (result.result=='failure') {
$form.prepend( result.messages );
if (result.refresh=='true') $('body').trigger('update_checkout');
$('html, body').animate({
scrollTop: ($('form.checkout').offset().top - 100)
}, 1000);
} else {
throw "Invalid response";
}
}
catch(err) {
$('.woocommerce_error, .woocommerce_message').remove();
$form.prepend( code );
$form.removeClass('processing').unblock();
if (result.refresh=='true') $('body').trigger('update_checkout');
$('html, body').animate({
scrollTop: ($('form.checkout').offset().top - 100)
}, 1000);
} else {
throw "Invalid response";
}
}
catch(err) {
$form.prepend( code );
$form.removeClass('processing').unblock();
$('html, body').animate({
scrollTop: ($('form.checkout').offset().top - 100)
}, 1000);
}
},
dataType: "html"
});
},
dataType: "html"
});
}
return false;
});

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@ Tags: ecommerce, e-commerce, commerce, woothemes, wordpress ecommerce, affiliate
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=paypal@woothemes.com&item_name=Donation+for+WooCommerce
Requires at least: 3.3
Tested up to: 3.4
Stable tag: 1.5.7.1
Stable tag: 1.5.8
License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html
@ -161,7 +161,9 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
== Changelog ==
= =
= 1.5.8 - 21/06/2012 =
* Tweak - Added checkout processing triggers for gateways (in particular stripe) to use
* Tweak - Pay page woocommerce_pay hidden input so we can use javascript to submit the form
* Tweak - Hooks for order statuses in reports
* Fix - Remove depreciated ereg_replace in validation class
* Fix - strpos warning in shipping class

View File

@ -76,8 +76,8 @@ global $woocommerce;
<div class="form-row">
<?php $woocommerce->nonce_field('pay')?>
<input type="submit" class="button alt" name="woocommerce_pay" id="place_order" value="<?php _e('Pay for order', 'woocommerce'); ?>" />
<input type="submit" class="button alt" id="place_order" value="<?php _e('Pay for order', 'woocommerce'); ?>" />
<input type="hidden" name="woocommerce_pay" value="1" />
</div>
</div>

View File

@ -3,7 +3,7 @@
* Plugin Name: WooCommerce
* Plugin URI: http://www.woothemes.com/woocommerce/
* Description: An e-commerce toolkit that helps you sell anything. Beautifully.
* Version: 1.5.7.1
* Version: 1.5.8
* Author: WooThemes
* Author URI: http://woothemes.com
* Requires at least: 3.3
@ -32,7 +32,7 @@ class Woocommerce {
/** Version ***************************************************************/
var $version = '1.5.7.1';
var $version = '1.5.8';
/** URLS ******************************************************************/