From 9d3962eee6dbef1442c4a24ca4570828fab7607f Mon Sep 17 00:00:00 2001 From: nloewen Date: Sat, 23 May 2015 15:37:59 -0500 Subject: [PATCH 1/2] Add custom button text via shortcode attributes --- includes/stripe-functions.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/includes/stripe-functions.php b/includes/stripe-functions.php index 8e48ea6..9fc9c3d 100644 --- a/includes/stripe-functions.php +++ b/includes/stripe-functions.php @@ -20,14 +20,15 @@ function wp_stripe_shortcode( $atts ) { } extract( shortcode_atts(array( - 'cards' => 'true' + 'cards' => 'true', + 'button_text' => $options['stripe_header'] ), $atts ) ); if ( $cards === 'true' ) { $payments = '
'; } - return '' . esc_html( $options['stripe_header'] ) . '' . $payments; + return '' . esc_html( $button_text ) . '' . $payments; } add_shortcode( 'wp-stripe', 'wp_stripe_shortcode' ); From 838271c12131dd6e9f11aec7ee60dc076092ce49 Mon Sep 17 00:00:00 2001 From: nloewen Date: Thu, 4 Jun 2015 23:08:07 -0500 Subject: [PATCH 2/2] Use metadata field for email and comment. Add a description setting and use that for the description. --- includes/stripe-functions.php | 14 ++++++++------ includes/stripe-options.php | 14 ++++++++++++-- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/includes/stripe-functions.php b/includes/stripe-functions.php index 9fc9c3d..6917da6 100644 --- a/includes/stripe-functions.php +++ b/includes/stripe-functions.php @@ -58,7 +58,7 @@ function wp_stripe_shortcode_legacy( $atts ){ * @since 1.0 * */ -function wp_stripe_charge($amount, $card, $name, $description) { +function wp_stripe_charge($amount, $card, $name, $email, $comment) { $options = get_option( 'wp_stripe_options' ); @@ -71,12 +71,14 @@ function wp_stripe_charge($amount, $card, $name, $description) { 'card' => $card, 'amount' => $amount, 'currency' => $currency, + 'description' => $options['stripe_description'], + 'receipt_email' => $email, + 'metadata' => array( + 'email' => $email, + 'comment' => $comment, + ), ); - if ( $description ) { - $charge['description'] = $description; - } - $response = Stripe_Charge::create( $charge ); return $response; @@ -125,7 +127,7 @@ function wp_stripe_charge_initiate() { // Create Charge try { - $response = wp_stripe_charge( $amount, $card, $name, $stripe_comment ); + $response = wp_stripe_charge( $amount, $card, $name, $email, sanitize_text_field( $_POST['wp_stripe_comment']) ); $id = $response->id; $amount = $response->amount / 100; diff --git a/includes/stripe-options.php b/includes/stripe-options.php index 136205a..4212c97 100644 --- a/includes/stripe-options.php +++ b/includes/stripe-options.php @@ -12,7 +12,8 @@ function wp_stripe_options_init() { add_settings_section( 'wp_stripe_section_main', '', 'wp_stripe_options_header', 'wp_stripe_section' ); - add_settings_field( 'stripe_header', 'Payment Form Header', 'wp_stripe_field_header', 'wp_stripe_section', 'wp_stripe_section_main' ); + add_settings_field( 'stipe_header', 'Payment Form Header', 'wp_stripe_field_header', 'wp_stripe_section', 'wp_stripe_section_main' ); + add_settings_field( 'stripe_description', 'Recipt description', 'wp_stripe_field_description', '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_css_switch', 'Enable Payment Form CSS?', 'wp_stripe_field_css', 'wp_stripe_section', 'wp_stripe_section_main' ); add_settings_field( 'stripe_labels_on', 'Enable Payment Form Labels?', 'wp_stripe_field_labels', 'wp_stripe_section', 'wp_stripe_section_main' ); @@ -68,6 +69,15 @@ function wp_stripe_field_header () { + + + +