Navigation Menu

Skip to content

Commit

Permalink
-Fix IE9 JS issue preventing card number submission
Browse files Browse the repository at this point in the history
-Prevent Stripe API key whitespace error by stripping whitespace from API keys
-Fix annoying PHP warnings
-Clean up duplicate and unneeded code
  • Loading branch information
naomicbush committed May 15, 2013
1 parent dda97e1 commit fd2f067
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions stripe.php
Expand Up @@ -3,13 +3,13 @@
Plugin Name: Gravity Forms + Stripe
Plugin URI: https://gravityplus.pro
Description: Use Stripe to process credit card payments on your site, easily and securely, with Gravity Forms
Version: 1.7.2.2
Version: 1.7.2.3
Author: gravity+
Author URI: https://gravityplus.pro
------------------------------------------------------------------------
Copyright 2012-2013 Naomi C. Bush
last updated: May 2, 2013
last updated: May 14, 2013
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -51,7 +51,7 @@ class GFPStripe {
private static $path = "gravityforms-stripe/stripe.php";
private static $url = "http://gravityplus.pro";
private static $slug = "gravityforms-stripe";
public static $version = '1.7.2.2';
public static $version = '1.7.2.3';
private static $min_gravityforms_version = '1.7.2';
private static $transaction_response = '';

Expand Down Expand Up @@ -389,9 +389,9 @@ private static function list_page () {
_e( 'Product and Services', 'gfp-stripe' );
break;

case 'subscription' :
/*case 'subscription' :
_e( 'Subscription', 'gfp-stripe' );
break;
break;*/
}
}
?>
Expand Down Expand Up @@ -470,10 +470,10 @@ public static function settings_page () {
else if ( isset( $_POST["gfp_stripe_submit"] ) ) {
check_admin_referer( 'update', 'gfp_stripe_update' );
$settings = array(
'test_secret_key' => rgpost( 'gfp_stripe_test_secret_key' ),
'test_publishable_key' => rgpost( 'gfp_stripe_test_publishable_key' ),
'live_secret_key' => rgpost( 'gfp_stripe_live_secret_key' ),
'live_publishable_key' => rgpost( 'gfp_stripe_live_publishable_key' ),
'test_secret_key' => trim( rgpost( 'gfp_stripe_test_secret_key' ) ),
'test_publishable_key' => trim( rgpost( 'gfp_stripe_test_publishable_key' ) ),
'live_secret_key' => trim( rgpost( 'gfp_stripe_live_secret_key' ) ),
'live_publishable_key' => trim( rgpost( 'gfp_stripe_live_publishable_key' ) ),
'mode' => rgpost( 'gfp_stripe_mode' )
);
$settings = apply_filters( 'gfp_stripe_save_settings', $settings );
Expand Down Expand Up @@ -560,7 +560,7 @@ public static function settings_page () {
</th>
<td width="88%">
<input class="size-1" id="gfp_stripe_test_secret_key" name="gfp_stripe_test_secret_key"
value="<?php echo esc_attr( rgar( $settings, 'test_secret_key' ) ) ?>"/>
value="<?php echo trim( esc_attr( rgar( $settings, 'test_secret_key' ) ) ) ?>"/>
<img
src="<?php echo self::get_base_url() ?>/images/<?php echo $is_valid[1]['test_secret_key'] ? 'tick.png' : 'stop.png' ?>"
border="0"
Expand All @@ -577,7 +577,7 @@ public static function settings_page () {
</th>
<td width="88%">
<input class="size-1" id="gfp_stripe_test_publishable_key" name="gfp_stripe_test_publishable_key"
value="<?php echo esc_attr( rgar( $settings, 'test_publishable_key' ) ) ?>"/>
value="<?php echo trim( esc_attr( rgar( $settings, 'test_publishable_key' ) ) ) ?>"/>
<img
src="<?php echo self::get_base_url() ?>/images/<?php echo $is_valid[1]['test_publishable_key'] ? 'tick.png' : 'stop.png' ?>"
border="0"
Expand All @@ -594,7 +594,7 @@ public static function settings_page () {
</th>
<td width="88%">
<input class="size-1" id="gfp_stripe_live_secret_key" name="gfp_stripe_live_secret_key"
value="<?php echo esc_attr( rgar( $settings, 'live_secret_key' ) ) ?>"/>
value="<?php echo trim( esc_attr( rgar( $settings, 'live_secret_key' ) ) ) ?>"/>
<img
src="<?php echo self::get_base_url() ?>/images/<?php echo $is_valid[1]['live_secret_key'] ? 'tick.png' : 'stop.png' ?>"
border="0"
Expand All @@ -618,7 +618,7 @@ public static function settings_page () {
</th>
<td width="88%">
<input class="size-1" id="gfp_stripe_live_publishable_key" name="gfp_stripe_live_publishable_key"
value="<?php echo esc_attr( rgar( $settings, 'live_publishable_key' ) ) ?>"/>
value="<?php echo trim( esc_attr( rgar( $settings, 'live_publishable_key' ) ) ) ?>"/>
<img
src="<?php echo self::get_base_url() ?>/images/<?php echo $is_valid[1]['live_publishable_key'] ? 'tick.png' : 'stop.png' ?>"
border="0"
Expand Down Expand Up @@ -732,7 +732,7 @@ public static function get_api_key ( $type ) {
$mode = rgar( $settings, 'mode' );
$key = $mode . '_' . $type . '_key';

return esc_attr( rgar( $settings, $key ) );
return trim( esc_attr( rgar( $settings, $key ) ) );

}

Expand Down Expand Up @@ -2022,13 +2022,12 @@ public static function gform_validation ( $validation_result ) {
//making one time payment
$validation_result = self::make_product_payment( $config, $validation_result );

return $validation_result;
}
else {
$validation_result = apply_filters( 'gfp_stripe_gform_validation', $validation_result, $config );

return $validation_result;
}

return $validation_result;
}

public static function gform_get_form_filter ( $form_string ) {
Expand Down Expand Up @@ -2072,18 +2071,18 @@ public static function gform_get_form_filter ( $form_string ) {
$mode = rgar( $settings, 'mode' );
switch ( $mode ) {
case 'test':
$publishable_key = esc_attr( rgar( $settings, 'test_publishable_key' ) );
$publishable_key = trim( esc_attr( rgar( $settings, 'test_publishable_key' ) ) );
break;
case 'live':
$publishable_key = esc_attr( rgar( $settings, 'live_publishable_key' ) );
$publishable_key = trim( esc_attr( rgar( $settings, 'live_publishable_key' ) ) );
break;
default:
//something is wrong TODO better error handling here
return $form_string;
}

//if more than one feed, find out if conditional logic affects Stripe token fields (address)
if ( 0 < $valid_feeds ) {
if ( isset( $valid_feeds ) && ( 0 < $valid_feeds ) ) {
$need_conditional_js = 0;
$field_info = array();
foreach ( $form_feeds as $feed ) {
Expand Down Expand Up @@ -2234,7 +2233,7 @@ public static function gform_get_form_filter ( $form_string ) {
"if ( last_page === '0' ){" .
"var form$ = jQuery('#gform_{$form_id}');" .
"Stripe.setPublishableKey('" . $publishable_key . "');" .
"var card_number = jQuery('#gform_{$form_id} span.ginput_cardextras').parent().children(':input').val();" .
"var card_number = jQuery('#gform_{$form_id} #input_{$form_id}_{$field_id}_1').val();" .
"var exp_month = jQuery('#gform_{$form_id} .ginput_card_expiration_month').val();" .
"var exp_year = jQuery('#gform_{$form_id} .ginput_card_expiration_year').val();" .
"var cvc = jQuery('#gform_{$form_id} .ginput_card_security_code').val();" .
Expand Down

0 comments on commit fd2f067

Please sign in to comment.