impress-org / givewp

GiveWP - The #1 Donation Plugin for WordPress. Easily accept donations and fundraise using your WordPress website.
https://givewp.com/
GNU General Public License v3.0
345 stars 191 forks source link

fix: prevent payment failure when multi level donations are too long on recurring stripe #4596

Closed allienimmons closed 2 years ago

allienimmons commented 4 years ago

Bug Report

User Story

As an admin, I want to name my multi-level donation options anything I want, including long strings of text, without the plugin and form failing and preventing the donor from completing the donation.

Current Behavior

Currently, if the multi-level donation title is longer than 250 characters, the plugin will fail.

Expected Behavior

The length of the titles should not affect the ability of the form to take donations successfully.

Bug Type

Steps to Reproduce

  1. Install Givewp and Recurring Donations.
  2. Enable any Recurring Donations option on a form, as well as Multi-Level Donations.
  3. Create a multi-level donation option. Add a long string of text to the title that is longer than 250.
  4. Observe that when a donation is made with that form, it fails and shows the error message: "A critical error has occurred on your website."

Related

https://secure.helpscout.net/conversation/1118260148/60514?folderId=3046394 https://givewp.slack.com/archives/C0E290T6Z/p1585579611007800

Acceptance Criteria

Environment

Operating System
  • Platform: Mac OS X
  • Version: 10.15.3
Browser
  • Name: Chrome
  • Version: 80.0.3987.149
### WordPress Environment ### Home URL: https://oxfamdev.wpengine.com Site URL: https://oxfamdev.wpengine.com WP Version: 5.3.2 WP Multisite: – WP Memory Limit: 512 MB WP Debug Mode: – WP Cron: ✔ Language: it_IT Permalink Structure: /%postname%/ Show on Front: page Page on Front: Home (#10) Page for Posts: Non impostato Table Prefix Length: wp_ Table Prefix Length: 3 Table Prefix Status: Acceptable Admin AJAX: Accessibile Registered Post Statuses: publish, future, draft, pending, private, trash, auto-draft, inherit, request-pending, request-confirmed, request-failed, request-completed, acf-disabled, wc-pending, wc-processing, wc-on-hold, wc-completed, wc-cancelled, wc-refunded, wc-failed, refunded, failed, revoked, cancelled, abandoned, processing, preapproval, orders, tribe-ea-success, tribe-ea-failed, tribe-ea-schedule, tribe-ea-pending, tribe-ea-draft, tribe-ignored, hidden, give_subscription ### Server Environment ### Hosting Provider: WP Engine TLS Connection: Connessione usata TLS 1.2 TLS Connection: Probably Okay Server Info: Apache PHP Version: 7.3.15-3+ubuntu18.04.1+deb.sury.org+1 PHP Post Max Size: 100 MB PHP Time Limit: 300 PHP Max Input Vars: 10000 PHP Max Upload Size: 50 MB cURL Version: 7.58.0, OpenSSL/1.1.1d SUHOSIN Installed: – MySQL Version: 5.7.28 Default Timezone is UTC: ✔ fsockopen/cURL: ✔ SoapClient: ✔ DOMDocument: ✔ gzip: ✔ GD Graphics Library: ✔ Multibyte String: ✔ Pubblicazione Remota: ✔ Get Remoto: ✔ ### GiveWP Configuration ### GiveWP Version: 2.6.0 GiveWP Cache: Abilitato Database Updates: Tutti gli aggiornamenti del database sono stati completati. Database Tables: ✔ wp_give_donors - 1.0✔ wp_give_donormeta - 1.0✔ wp_give_comments - 1.0✔ wp_give_commentmeta - 1.0✔ wp_give_sessions - 1.0✔ wp_give_logs - 1.0✔ wp_give_logmeta - 1.0✔ wp_give_formmeta - 1.0✔ wp_give_sequential_ordering - 1.0✔ wp_give_donationmeta - 1.0 GiveWP Cache: Abilitato GiveWP Cache: ✔Nuova Donazione✔Ricevuta Donazione❌Nuova donazione offline❌Istruzioni per la donazione offline✔Registrazione Nuovo Utente✔Informazioni dell'utente registrato✔Donation Note✔Accesso Email❌Renewal Receipt Email❌Renewal Receipt Email❌Subscription Cancelled Email❌Subscription Cancelled Email❌Subscription Completed Email❌Subscription Reminder Email✔Subscriptions Email Access✔Subscription Payment Failed Email Upgraded From: 2.5.13 Test Mode: Abilitato Currency Code: EUR Currency Position: Dopo Decimal Separator: , Thousands Separator: . Success Page: https://oxfamdev.wpengine.com/donation-confirmation/ Failure Page: https://oxfamdev.wpengine.com/transaction-failed/ Donation History Page: https://oxfamdev.wpengine.com/my-oxfam/donation-history/ GiveWP Forms Slug: /donazioni/ Enabled Payment Gateways: PayPal Standard, Stripe - Credit Card Default Payment Gateway: Stripe - Credit Card PayPal IPN Verification: Abilitato PayPal IPN Notifications: IPN received for #112645 ( 4VM26806TR956920S ) on 02/23/2020 at 11:58. Status VERIFIED Donor Email Access: Abilitato Stripe Webhook Notifications: 24 Marzo 2020 11:52 ### Active GiveWP Add-ons ### Give - Form Field Manager: ✔ Licenza Attiva – Da GiveWP – 1.4.4 Give - Manual Donations: ✔ Licenza Attiva – Da GiveWP – 1.4.6 Give - Per Form Gateways: ✔ Licenza Attiva – Da GiveWP – 1.0.2 Give - Recurring Donations: ✔ Licenza Attiva – Da GiveWP – 1.9.14 Give - Stripe Gateway: ✔ Licenza Attiva – Da GiveWP – 2.2.3 ### Other Active Plugins ### ACF-VC Integrator: Da Frederik Rosendahl-Kaa – 1.8.1 Admin Menu Editor: Da Janis Elsts – 1.9.4 Advanced Custom Fields: Repeater Field: Da Elliot Condon – 2.1.0 Advanced Custom Fields: Separator: Da Codelight – 1.0.0 Advanced Custom Fields PRO: Da Elliot Condon – 5.8.8 Advanced Order Export For WooCommerce: Da AlgolPlus – 3.1.3 Breadcrumb NavXT: Da John Havlik – 6.4.0 Classic Editor: Da WordPress Contributors – 1.5 Contact Form 7: Da Takayuki Miyoshi – 5.1.7 Contact Form 7 - Dynamic Text Extension: Da Chris Mavricos, SevenSpark – 2.0.3 Contact Form 7 Multi-step Pro: Da Rednumber – 5.8 Custom Post Type Widgets: Da thingsym – 1.2.1 Custom Sidebars: Da WPMU DEV – 3.2.3 Duplicate Post: Da Enrico Battocchi – 3.2.4 Error Log Monitor: Da Janis Elsts – 1.6.9 Filarete Widget Pack: Da Filarete – 0.1 Give - Custom Donate Widget: Da Shambix – 1.0 Glue for Yoast SEO & AMP: Da Joost de Valk – 0.6 Mapplic: Da sekler – 4.0 MonsterInsights - AMP Addon: Da MonsterInsights Team – 1.4.5 MonsterInsights - Performance Addon: Da MonsterInsights Team – 1.4.0 PayPal IPN for WordPress: Da Angell EYE – 1.1.6 Popup Maker: Da Popup Maker – 1.9.1 Post SMTP: Da Yehuda Hassine – 2.0.11 Product Customer List for WooCommerce: Da Kokomo – 9.9 Shortcodes Ultimate: Da Vladimir Anokhin – 5.8.0 SpeakOut: Da – 1.2 The Events Calendar: Da Modern Tribe, Inc. – 5.0.3.1 Theme Options Maker: Da tonjoo – 1.0.5 TinyMCE Advanced: Da Andrew Ozz – 5.3.0 Toolset Types: Da OnTheGoSystems – 3.3.5 User Role Editor: Da Vladimir Garagulya – 4.53.1 VC Simple Slider: Da Shambix – 6 Widget CSS Classes: Da C.M. Kendrick – 1.5.4 WooCommerce: Da Automattic – 4.0.1 WooCommerce Checkout Field Editor: Da WooCommerce – 1.5.30 WooCommerce Multiple Shipping Addresses: Da Shop Plugins – 1.0.7 WooCommerce Stripe Gateway: Da WooCommerce – 4.3.2 WooEvents: Da ExThemes – 3.6 WPBakery Page Builder: Da Michael M - WPBakery.com – 6.1 WP Social Sharing: Da Arjun Jain – 2.2 WP Timeline: Da ExThemes – 1.6 ### Inactive Plugins ### Advanced Cron Manager: Da BracketSpace – 2.3.10 AMP: Da AMP Project Contributors – 1.4.4 ARI Adminer: Da ARI Soft – 1.2.3 Breadcrumb: Da PickPlugins – 1.5.14 Contact Form 7 - Success Page Redirects: Da Ryan Nevius – 1.2.0 Contact Form DB: Da Michael Simpson – 2.10.26 Debug Bar: Da wordpressdotorg – 1.0 Debug Objects: Da Frank Bültge – 2.5.0 Debug This: Da MachoThemes – 0.6.3 Email Log: Da Sudar – 2.3.2 Give - Custom Donate Widget: Da Shambix – 1.0 Give - Google Analytics Donation Tracking: Da GiveWP – 1.2.4 Instant Articles for WP: Da Automattic, Dekode, Facebook – 4.2.0 Layered Popups: Da Halfdata, Inc. – 6.54 Media Cleaner Pro: Da Jordy Meow – 5.4.9 MonsterInsights - eCommerce Addon: Da MonsterInsights Team – 7.3.5 MonsterInsights - Facebook Instant Articles Addon: Da MonsterInsights Team – 1.1.1 MonsterInsights Pro: Da MonsterInsights – 7.10.4 Payment Gateways by User Roles for WooCommerce: Da Tyche Softwares – 1.2.2 Search & Replace: Da Inpsyde GmbH – 3.2.1 User Switching: Da John Blackbourn & contributors – 1.5.4 WooCommerce Multiple Shipping Addresses: Da Shop Plugins – 1.0.7 WooCommerce Satispay: Da Satispay – 1.4.3 WP-Sweep: Da Lester 'GaMerZ' Chan – 1.1.1 WPBakery Page Builder: Da Michael M - WPBakery.com – 6.0.5 WPBakery Page Builder - OXFAM: Da – 5.7 WP Cron Pixie: Da Ian M. Jones – 1.4.1 WP Term Colors: Da John James Jacoby – 0.1.4 Yoast SEO: Da Team Yoast – 13.3 ### Active MU Plugins ### Force Strong Passwords - WPE Edition: Da Jason Cosper – 1.6.4 WP Engine Seamless Login Plugin: Da WP Engine – 1.5.3 WP Engine Security Auditor: Da wpengine – 1.0.8 WP Engine System: Da WP Engine – 4.0.0 ### Theme ### Name: OXFAM Version: 2.0 Author URL: http://www.filarete.eu Child Theme: No – If you're modifying GiveWP on a parent theme you didn't build personally, then we recommend using a child theme. See: How to Create a Child Theme
Jany-M commented 4 years ago

Watching this, as we can't update the plugin until fixed.

ravinderk commented 4 years ago

@Benunc You can use this snippet to shorten the subscription plan name for stripe gateways.

/**
 * Filter subscription plan name.
 *
 * @param string $subscription_name
 *
 * @return string
 */
function givewp_60514_filtered_recurring_subscription_name( $subscription_name ){
    $whiteListGateways = [
        'stripe',
        'stripe_ach',
        'stripe_apple_pay',
        'stripe_becs',
        'stripe_checkout',
        'stripe_google_pay',
        'stripe_ideal',
        'stripe_sepa'
    ];
    $donorPaymentGateway = give_clean( $_POST['give-gateway'] );
    $charLength = 140; // Do not remove it be.

    // Shorten subscription plan only for allowed payment gateways.
    if(
        $charLength > strlen( $subscription_name ) ||
        ! in_array( $donorPaymentGateway, $whiteListGateways, true )
    ) {
        return $subscription_name;
    }

    $subscription_name = sprintf(
        '%1$s...',
        substr( $subscription_name, 0, $charLength - 4 ) // 3 char less to add ' ...'.
    );

    return $subscription_name;
}
add_filter( 'give_recurring_subscription_name', 'givewp_60514_filtered_recurring_subscription_name' );
Jany-M commented 4 years ago

Thanks for snippet. So will this not be fixed at an add-on level?

Benunc commented 4 years ago

@Jany-M we do plan to incorporate something into either the add-on or GiveWP itself, but as we were evaluating this we determined that you are the only customer currently reporting issues, and a fix within our product will require extensive testing. So I asked Ravinder to make a custom snippet that you can use in the meantime to solve the problem.

If you need assistance implementing custom PHP code on your website we have this guide:

https://givewp.com/documentation/resources/adding-custom-functions-to-your-wordpress-website/

Please note that this code snippet is provided as an example of how you can extend GiveWP with code. It’s up to you to implement and customize to your liking.

Jany-M commented 4 years ago

Snippet does work, fatal error is gone. Thank you! This only happened with a recurring donation, not with a single one btw.

jonwaldstein commented 2 years ago

@Benunc was this issue ever reported again? it seems like a fairly simple fix for us to include in core to limit the characters of the subscription name.

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 14 additional days.

kjohnson commented 2 years ago

Closing in favor of feedback, see https://feedback.givewp.com/bug-reports/p/subscription-payments-fail-when-multi-level-donation-titles-are-longer-than-250.