Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

allow users to require donor address and phone number

  • Loading branch information...
commit 35dfd3cef8ef6e992401562f0c96b5d2b4a2026f 1 parent 8ad4f9c
@molawson authored
View
28 css/wp-stripe-display.css
@@ -10,6 +10,13 @@
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif !important;
}
+#wp-stripe-wrap.two-column { width: 800px; }
+
+.two-column .wp-stripe-details,
+.two-column .wp-stripe-card { float: left; }
+
+.two-column .wp-stripe-actions { text-align: right; }
+
/* Payment Form Link */
#wp-stripe-modal-button {
@@ -98,9 +105,9 @@ form#wp-stripe-payment-form .stripe-row-right {
form#wp-stripe-payment-form .stripe-submit-button {
position:relative;
- margin:10px;
+ margin:20px 10px;
padding: 8px 15px;
- display:block;
+ display:inline-block;
font-weight: bold;
font-size: 12px;
background: #1275FF;
@@ -148,7 +155,7 @@ form#wp-stripe-payment-form .stripe-submit-button {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif !important;
color:#777;
font-size:10px;
- padding:0 20px;
+ padding:0 10px;
}
.wp-stripe-poweredby a {
@@ -161,9 +168,8 @@ form#wp-stripe-payment-form .stripe-submit-button {
.wp-stripe-notification {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 12px;
- width:360px;
padding:10px;
- margin:10px 0 10px 10px;
+ margin:10px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
@@ -223,6 +229,11 @@ form#wp-stripe-payment-form input {
background-color:#fff;
}
+
+
+form#wp-stripe-payment-form .stripe-row-left span { padding-left:10px; }
+form#wp-stripe-payment-form .stripe-row-right input { width:148px; }
+
input.wp-stripe-name {background: url('../images/h-name.png') no-repeat 8px 8px;}
input.wp-stripe-email {background: url('../images/h-email.png') no-repeat 8px 10px;}
textarea.wp-stripe-comment {background: url('../images/h-comment.png') no-repeat 8px 10px;}
@@ -289,6 +300,13 @@ form#wp-stripe-payment-form .uneditable-input {
border-radius: 3px;
}
+form#wp-stripe-payment-form input.no-icon,
+form#wp-stripe-payment-form textarea.no-icon,
+form#wp-stripe-payment-form select.no-icon,
+form#wp-stripe-payment-form .uneditable-input.no-icon {
+ padding: 8px 30px 8px 8px;
+}
+
form#wp-stripe-payment-form input[type=checkbox], form#wp-stripe-payment-form input[type=radio] {
width: auto;
height: auto;
View
105 includes/stripe-display.php
@@ -13,42 +13,116 @@ function wp_stripe_form() {
ob_start();
+ $options = get_option('wp_stripe_options');
+
?>
<!-- Start WP-Stripe -->
- <div id="wp-stripe-wrap">
+ <div id="wp-stripe-wrap"<?php if ( $options['stripe_address_switch'] == 'Yes' ): echo 'class="two-column"'; endif; ?>>
<form id="wp-stripe-payment-form">
<input type="hidden" name="action" value="wp_stripe_charge_initiate" />
<input type="hidden" name="nonce" value="<?php echo wp_create_nonce( 'wp-stripe-nonce' ); ?>" />
- <div class="wp-stripe-details">
+ <div class="wp-stripe-notification wp-stripe-failure payment-errors" style="display:none"></div>
- <div class="wp-stripe-notification wp-stripe-failure payment-errors" style="display:none"></div>
+ <div class="wp-stripe-details">
<div class="stripe-row">
<input type="text" name="wp_stripe_name" class="wp-stripe-name" placeholder="<?php _e('Name', 'wp-stripe'); ?> *" autofocus required />
</div>
<div class="stripe-row">
- <input type="email" name="wp_stripe_email" class="wp-stripe-email" placeholder="<?php _e('E-mail', 'wp-stripe'); ?>" />
+ <input type="email" name="wp_stripe_email" class="wp-stripe-email" placeholder="<?php _e('E-mail', 'wp-stripe'); ?> *" required />
</div>
+ <?php if ( $options['stripe_address_switch'] == 'Yes' ): ?>
<div class="stripe-row">
- <textarea name="wp_stripe_comment" class="wp-stripe-comment" placeholder="<?php _e('Comment', 'wp-stripe'); ?>"></textarea>
+ <input type="text" name="wp_stripe_address" class="wp-stripe-address no-icon" placeholder="<?php _e('Address', 'wp-stripe'); ?> *" required />
</div>
- </div>
+ <div class="stripe-row">
+ <input type="text" name="wp_stripe_city" class="wp-stripe-city no-icon" placeholder="<?php _e('City', 'wp-stripe'); ?> *" required />
+ </div>
- <div class="wp-stripe-card">
+ <div class="stripe-row">
+ <div class="stripe-row-left">
+ <span class="stripe-expiry">STATE</span>
+ <select name="wp_stripe_state" class="wp-stripe-city">
+ <option value="" selected="selected">Please select</option>
+ <option value="AK">AK</option>
+ <option value="AL">AL</option>
+ <option value="AR">AR</option>
+ <option value="AZ">AZ</option>
+ <option value="CA">CA</option>
+ <option value="CO">CO</option>
+ <option value="CT">CT</option>
+ <option value="DC">DC</option>
+ <option value="DE">DE</option>
+ <option value="FL">FL</option>
+ <option value="GA">GA</option>
+ <option value="HI">HI</option>
+ <option value="IA">IA</option>
+ <option value="ID">ID</option>
+ <option value="IL">IL</option>
+ <option value="IN">IN</option>
+ <option value="KS">KS</option>
+ <option value="KY">KY</option>
+ <option value="LA">LA</option>
+ <option value="MA">MA</option>
+ <option value="MD">MD</option>
+ <option value="ME">ME</option>
+ <option value="MI">MI</option>
+ <option value="MN">MN</option>
+ <option value="MO">MO</option>
+ <option value="MS">MS</option>
+ <option value="MT">MT</option>
+ <option value="NC">NC</option>
+ <option value="ND">ND</option>
+ <option value="NE">NE</option>
+ <option value="NH">NH</option>
+ <option value="NJ">NJ</option>
+ <option value="NM">NM</option>
+ <option value="NV">NV</option>
+ <option value="NY">NY</option>
+ <option value="OH">OH</option>
+ <option value="OK">OK</option>
+ <option value="OR">OR</option>
+ <option value="PA">PA</option>
+ <option value="RI">RI</option>
+ <option value="SC">SC</option>
+ <option value="SD">SD</option>
+ <option value="TN">TN</option>
+ <option value="TX">TX</option>
+ <option value="UT">UT</option>
+ <option value="VA">VA</option>
+ <option value="VT">VT</option>
+ <option value="WA">WA</option>
+ <option value="WI">WI</option>
+ <option value="WV">WV</option>
+ <option value="WY">WY</option>
+ </select>
+ </div>
+ <div class="stripe-row-right">
+ <input type="text" name="wp_stripe_zip" class="wp-stripe-zip no-icon" placeholder="<?php _e('Zip', 'wp-stripe'); ?> *" required />
+ </div>
+ </div>
<div class="stripe-row">
+ <input type="text" name="wp_stripe_phone" class="wp-stripe-phone no-icon" placeholder="<?php _e('Phone Number', 'wp-stripe'); ?> *" required />
+ </div>
+ <?php endif; ?>
+
+ </div>
+
+ <div class="wp-stripe-card">
+ <div class="stripe-row">
<input type="text" name="wp_stripe_amount" autocomplete="off" class="wp-stripe-card-amount" id="wp-stripe-card-amount" placeholder="<?php _e('Amount (USD)', 'wp-stripe'); ?> *" required />
</div>
- <?php $options = get_option('wp_stripe_options'); if ( $options['stripe_recurring_switch'] == 'Yes' ): ?>
+ <?php if ( $options['stripe_recurring_switch'] == 'Yes' ): ?>
<div class="stripe-row">
<label><?php _e('Payment Type', 'wp-stripe'); ?></label>
<input type="radio" name="wp_stripe_type" class="wp-stripe-type" value="once" checked /> <span class="wp-stripe-radio-text">One-Time</span>
@@ -64,6 +138,10 @@ function wp_stripe_form() {
</div>
<?php endif; ?>
+ <div class="stripe-row">
+ <textarea name="wp_stripe_comment" class="wp-stripe-comment" placeholder="<?php _e('Comment', 'wp-stripe'); ?>"></textarea>
+ </div>
+
<div class="stripe-row">
<input type="text" autocomplete="off" class="card-number" placeholder="<?php _e('Card Number', 'wp-stripe'); ?> *" required />
</div>
@@ -121,17 +199,20 @@ function wp_stripe_form() {
<div style="clear:both"></div>
- <input type="hidden" name="wp_stripe_form" value="1"/>
+ <div class="wp-stripe-actions">
+ <input type="hidden" name="wp_stripe_form" value="1"/>
- <button type="submit" class="stripe-submit-button"><?php _e('Submit Payment', 'wp-stripe'); ?></button>
- <div class="stripe-spinner"></div>
+ <button type="submit" class="stripe-submit-button"><?php _e('Submit Payment', 'wp-stripe'); ?></button>
+ <div class="stripe-spinner"></div>
+
+ <div class="wp-stripe-poweredby">Payments powered by <a href="http://wordpress.org/extend/plugins/wp-stripe" target="_blank">WP-Stripe</a>. No card information is stored on this server.</div>
+ </div>
</form>
</div>
- <div class="wp-stripe-poweredby">Payments powered by <a href="http://wordpress.org/extend/plugins/wp-stripe" target="_blank">WP-Stripe</a>. No card information is stored on this server.</div>
<!-- End WP-Stripe -->
View
32 includes/stripe-functions.php
@@ -14,7 +14,11 @@ function wp_stripe_shortcode( $atts ){
$options = get_option('wp_stripe_options');
- $settings = '?keepThis=true&TB_iframe=true&height=580&width=400';
+ if ( $options['stripe_address_switch'] == 'Yes' ) {
+ $settings = '?keepThis=true&TB_iframe=true&height=460&width=800';
+ } else {
+ $settings = '?keepThis=true&TB_iframe=true&height=580&width=400';
+ }
$path = WP_STRIPE_PATH . '/includes/stripe-iframe.php'. $settings;
$count = 1;
@@ -144,13 +148,14 @@ function wp_stripe_find_or_create_plan($amount, $interval) {
* @param $email string
* @param $card string
* @param $plan_id int
+ * @param $description string
* @return array
*
* @since 1.4.5
*
*/
-function wp_stripe_subscribe_customer_to_plan($email, $card, $plan_id) {
+function wp_stripe_subscribe_customer_to_plan($email, $card, $plan_id, $description) {
$customer = array(
'email' => $email,
@@ -158,7 +163,9 @@ function wp_stripe_subscribe_customer_to_plan($email, $card, $plan_id) {
'plan' => $plan_id
);
- // TODO: build comment from extra form fields
+ if ( $description ) {
+ $customer['description'] = $description;
+ }
$response = Stripe_Customer::create($customer);
@@ -230,11 +237,16 @@ function wp_stripe_charge_initiate() {
$amount = str_replace('$', '', $_POST['wp_stripe_amount']) * 100;
$card = $_POST['stripeToken'];
$type = $_POST['wp_stripe_type'];
+ $details = 'Email: ' . $_POST['wp_stripe_email'];
+
+ if ( $_POST['wp_stripe_address'] ) {
+ $address = implode(', ', array($_POST['wp_stripe_address'], $_POST['wp_stripe_city'], $_POST['wp_stripe_state'], $_POST['wp_stripe_zip']));
+ $phone = $_POST['wp_stripe_phone'];
+ $details .= ' // Address: ' . $address . ' // Phone: ' . $phone;
+ }
- if ( !$_POST['wp_stripe_comment'] ) {
- $comment = __('E-mail: ', 'wp-stipe') . $_POST['wp_stripe_email'] . ' - ' . __('This transaction has no additional details', 'wp-stripe');
- } else {
- $comment = __('E-mail: ', 'wp-stipe') . $_POST['wp_stripe_email'] . ' - ' . $_POST['wp_stripe_comment'];
+ if ( $_POST['wp_stripe_comment'] ) {
+ $details .= ' // Comment: ' . $_POST['wp_stripe_comment'];
}
// Create Charge
@@ -250,7 +262,7 @@ function wp_stripe_charge_initiate() {
$plan = wp_stripe_find_or_create_plan($amount, $interval);
// Subscribe the customer to that plan
- $customer = wp_stripe_subscribe_customer_to_plan ($email, $card, $plan->id);
+ $customer = wp_stripe_subscribe_customer_to_plan ($email, $card, $plan->id, $details);
// Get the charge that we just created
$response = wp_stripe_find_customer_subscription_charge($customer->id, $plan->id);
@@ -258,7 +270,7 @@ function wp_stripe_charge_initiate() {
// One Time donation
} else {
- $response = wp_stripe_charge($amount, $card, $name, $comment);
+ $response = wp_stripe_charge($amount, $card, $name, $details);
}
@@ -281,7 +293,7 @@ function wp_stripe_charge_initiate() {
'ID' => '',
'post_type' => 'wp-stripe-trx',
'post_author' => 1,
- 'post_content' => $comment,
+ 'post_content' => $details,
'post_title' => $id,
'post_status' => 'publish',
);
View
15 includes/stripe-options.php
@@ -14,6 +14,7 @@ function wp_stripe_options_init() {
add_settings_field( 'stripe_header', 'Payment Form Header', 'wp_stripe_field_header', 'wp_stripe_section', 'wp_stripe_section_main' );
add_settings_field( 'stripe_recent_switch', 'Enable Recent Widget?', 'wp_stripe_field_recent', 'wp_stripe_section', 'wp_stripe_section_main' );
add_settings_field( 'stripe_recurring_switch', 'Enable Recurring Donations?', 'wp_stripe_field_recurring', 'wp_stripe_section', 'wp_stripe_section_main' );
+ add_settings_field( 'stripe_address_switch', 'Require Donor Address?', 'wp_stripe_field_address', 'wp_stripe_section', 'wp_stripe_section_main' );
add_settings_field( 'stripe_css_switch', 'Enable Payment Form CSS?', 'wp_stripe_field_css', 'wp_stripe_section', 'wp_stripe_section_main' );
add_settings_section( 'wp_stripe_section_api', '', 'wp_stripe_options_header_api', 'wp_stripe_section' );
add_settings_field( 'stripe_api_switch', 'Enable Test API Environment?', 'wp_stripe_field_switch', 'wp_stripe_section', 'wp_stripe_section_api' );
@@ -105,6 +106,20 @@ function wp_stripe_field_recurring () {
echo "</select>";
}
+function wp_stripe_field_address () {
+
+ $options = get_option( 'wp_stripe_options' );
+ $items = array( 'Yes', 'No' );
+ echo "<select id='stripe_api_switch' name='wp_stripe_options[stripe_address_switch]'>";
+
+ foreach( $items as $item ) {
+ $selected = ($options['stripe_address_switch']==$item) ? 'selected="selected"' : '';
+ echo "<option value='$item' $selected>$item</option>";
+ }
+
+ echo "</select>";
+}
+
function wp_stripe_field_css () {
$options = get_option( 'wp_stripe_options' );
View
2  js/wp-stripe.js
@@ -40,7 +40,7 @@ jQuery(document).ready(function($) {
data : newStripeForm,
success: function(response) {
- $('.wp-stripe-details').prepend(response);
+ $('.wp-stripe-details').before(response);
$('.stripe-submit-button').prop("disabled", false).css("opacity","1.0");
resetStripeForm();
View
2  wp-stripe.php
@@ -76,6 +76,8 @@ function wp_stripe_defaults() {
'stripe_css_switch' => 'Yes',
'stripe_api_switch'=>'Yes',
'stripe_recent_switch'=>'Yes',
+ 'stripe_recurring_switch'=>'No',
+ 'stripe_address_switch'=>'No',
'stripe_modal_ssl'=>'No'
);
Please sign in to comment.
Something went wrong with that request. Please try again.