Forum

Thread tagged as: Problem, Shop

Testing shop+stripe: nothing happens after payment submit

I'm testing Shop with Stripe in test mode (on localhost) and when you submit the card details in the Stripe modal box the green tick appears then the page (confirm.php) reloads with just the header visible and rest of the page blank. The order is not registered and there is no redirect to either success or failure pages.

confirm.php (the cart):

<?php 
    include($_SERVER['DOCUMENT_ROOT'].'/admin/runtime.php');

    perch_layout('header', array(
        'title' => "Confirm your order",
    ));

    if (perch_member_logged_in() && perch_post('stripeToken')) {

      // 'success' and 'failure' URLs
      $return_url = '/pay/success';
      $cancel_url = '/pay/cancelled';

      perch_shop_checkout('stripe', [
        'return_url' => $return_url,
        'cancel_url' => $cancel_url,
        'token' => perch_post('stripeToken')
      ]);
    }

?>

<div class="clear">
    <div class="wrap wrap--large">
        <h1>Confirm and pay</h1>
    </div>
</div>

<div class="clear">
    <div class="wrap wrap--small">

        <?php perch_content('Intro text'); ?>

        <?php
            // Show the cart 
            perch_shop_cart([
                'template'=>'cart/cart.html'
            ]);

            // Show the order addresses
            perch_shop_order_addresses();

            // Show the payment form if logged in and something in cart
            if (perch_member_logged_in() && perch_shop_cart_item_count([], true) > 0) {
            perch_shop_payment_form('stripe');
            }
        ?>

    </div>
</div>

<div class="clear">
    <div class="wrap wrap--small">
        <?php perch_content('Shop footer'); ?>
    </div>
</div>

<?php perch_layout('footer');?>

config/shop.php:

<?php
    return [

        /*
        |--------------------------------------------------------------------------
        | Gateway settings
        |--------------------------------------------------------------------------
        */

        'gateways' => [

            'default' => [
                'enabled'   => false,
                'test_mode' => false,
                'live' => [
                    'api_key'      => 'abc123',
                ],
                'test' => [
                    'api_key'      => 'abc123',
                ],
            ],


            'stripe' => [
                'enabled'   => true,
                'test_mode' => true,
                'live' => [
                    'secret_key'      => 'mylivekeyishere',
                    'publishable_key' => 'mylivekeyishere',
                ],
                'test' => [
                    'secret_key'      => 'mytestkeyishere',
                    'publishable_key' => 'mytestkeyishere',
                ],
            ],

        ],

    ];

stripe_payment_form.html:

<a href="logout" style="float: right;">Cancel order</a>
<form action="" method="post">
    <script src="https://checkout.stripe.com/checkout.js" class="stripe-button" data-key="<perch:shop id="publishable_key" escape="true" />"
        data-amount="<perch:shop id="amount" escape="true" />"
        data-currency="<perch:shop id="currency" escape="true" />"
        data-name="My Shop"
        data-description="Items (<perch:shop id="amount_formatted" escape="true" />)"
        data-email="<perch:member id="email" escape="true" />">
    </script>
</form>
Stephen Turvey

Stephen Turvey 0 points

  • 4 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

If you are getting a blank or cut off page then you have a PHP error, what is the actual error?

Also, remember we need to see your Diagnostics Report in order to help.

No error appears, it just seems to reload the page with the header (which is a perch layout file) and nothing else. I've got debug on the page but lower down in the code so it doesn't get loaded.

Perch: 2.8.34
Production mode: Production (100)
Installed apps: content (2.8.34), assets (2.8.34), categories (2.8.34), perch_blog (5.0), perch_forms (1.8.3), perch_gallery (2.8.6), perch_shop_orders (1.0.9), perch_shop_products (1.0.9), perch_shop (1.0.9), perch_members (1.5), perch_backup (1.2)
DB driver: PDO
DB tables: perch2_blog_authors (1), perch2_blog_comments (0), perch2_blog_index (76), perch2_blog_posts (3), perch2_blog_posts_to_tags (0), perch2_blog_sections (1), perch2_blog_tags (0), perch2_blogs (1), perch2_categories (33), perch2_category_counts (4), perch2_category_sets (4), perch2_content_index (2648), perch2_content_items (651), perch2_content_regions (88), perch2_forms (1), perch2_forms_responses (2), perch2_gallery_albums (0), perch2_gallery_image_versions (0), perch2_gallery_images (0), perch2_members (8), perch2_members_forms (1), perch2_members_member_tags (0), perch2_members_sessions (2), perch2_members_tags (0), perch2_navigation (3), perch2_navigation_pages (11), perch2_page_templates (4), perch2_pages (45), perch2_resource_log (1494), perch2_resource_tags (0), perch2_resources (244), perch2_resources_to_tags (0), perch2_settings (40), perch2_shop_addresses (13), perch2_shop_admin_index (32), perch2_shop_brands (1), perch2_shop_cart (31), perch2_shop_cart_data (73), perch2_shop_cart_items (7), perch2_shop_countries (250), perch2_shop_currencies (152), perch2_shop_customers (8), perch2_shop_emails (1), perch2_shop_index (496), perch2_shop_option_values (2), perch2_shop_options (2), perch2_shop_order_items (4), perch2_shop_order_promotions (0), perch2_shop_order_statuses (9), perch2_shop_orders (4), perch2_shop_orders_meta (1), perch2_shop_product_files (0), perch2_shop_product_option_values (0), perch2_shop_product_options (0), perch2_shop_product_tags (0), perch2_shop_products (9), perch2_shop_promotions (1), perch2_shop_search (9), perch2_shop_shipping_zone_countries (0), perch2_shop_shipping_zones (1), perch2_shop_shippings (1), perch2_shop_tax_exhibits (4), perch2_shop_tax_group_rates (1), perch2_shop_tax_groups (1), perch2_shop_tax_locations (1), perch2_shop_tax_rates (0), perch2_shop_variants (3), perch2_user_passwords (0), perch2_user_privileges (81), perch2_user_role_privileges (16), perch2_user_roles (2), perch2_users (1)
Users: 1
PHPMailer: 5.2.21
App runtimes:
<?php
    $apps_list = array(
        'content', 
        'categories',
        'perch_blog',
        'perch_members',
        'perch_forms',
        'perch_shop',
    );
Scheduled tasks for perch_blog: delete_spam_comments (1440 mins)
Editor plug-ins: ckeditor, markitup
H1: 55451ac9f139b81c4f44a8a268afcc57
L1: 73252867ff1d2645a823d8df3812dd58
F1: 6a33f95eca3667f9e0c39bf5ca2980fe
headerColour: #ffffff
content_singlePageEdit: 1
helpURL:
siteURL: /
hideBranding: 1
content_collapseList: 0
lang: en-gb
update_2.8.32: done
latest_version: 2.8.15
on_sale_version: 2.8.34
headerScheme: light
dashboard: 0
hide_pwd_reset: 0
content_hideNonEditableRegions: 0
content_frontend_edit: 0
perch_backup_mysqldump_path: /Applications/MAMP/Library/bin/mysqldump
perch_blog_update: 5.0.1
perch_blog_post_url: /community/articles/{postSlug}
perch_gallery_update: 2.8.5
perch_members_update: 1.4
perch_shop_update: 1.0.9
perch_blog_site_name:
perch_blog_slug_format: %Y-%m-%d-{postTitle}
perch_blog_akismet_key:
perch_blog_max_spam_days: 0
perch_gallery_bucket_mode: single
perch_gallery_bucket: default
perch_members_login_page: /members/login.php?r={returnURL}
perch_shop_price_tax_mode: inc
perch_shop_site_url: esl/pay
perch_shop_product_url: /pay/products/{slug}
perch_shop_default_currency: 47
perch_shop_reporting_currency: 47
perch_shop_invoice_number_format: Invoice%d
perch_blog_comment_notify: 0
perch_gallery_basicUpload: 0
update_2.8.34: done
PERCH_DEVELOPMENT: 10
PERCH_STAGING: 50
PERCH_PRODUCTION: 100
PERCH_DB_USERNAME: root
PERCH_DB_SERVER: localhost
PERCH_DB_DATABASE: esl
PERCH_DB_PREFIX: perch2_
PERCH_TZ: Europe/London
PERCH_EMAIL_FROM: stephen@yepdesign.co.uk
PERCH_EMAIL_FROM_NAME: Stephen Turvey
PERCH_LOGINPATH: /admin
PERCH_PATH: /Users/turveyair/Google Drive/htdocs/esl/admin
PERCH_CORE: /Users/turveyair/Google Drive/htdocs/esl/admin/core
PERCH_RESFILEPATH: /Users/turveyair/Google Drive/htdocs/esl/admin/resources
PERCH_RESPATH: /admin/resources
PERCH_HTML5: 1
PERCH_DEBUG: 1
PERCH_RUNWAY:
PERCH_ERROR_MODE: DIE
PERCH_DATE_LONG: %d %B %Y
PERCH_DATE_SHORT: %d %b %Y
PERCH_TIME_SHORT: %H:%M
PERCH_TIME_LONG: %H:%M:%S
PERCH_RUNWAY_ROUTED:
PERCH_STRONG_PASSWORDS:
PERCH_PREVIEW_ARG: preview
PERCH_TEMPLATE_PATH: /Users/turveyair/Google Drive/htdocs/esl/admin/templates
PERCH_DEFAULT_DOC: index.php
PERCH_DEFAULT_EXT: .php
PERCH_PRODUCTION_MODE: 100
PERCH_RWD:
PERCH_HTML_ENTITIES:
PERCH_SSL:
PERCH_STRIPSLASHES:
PERCH_PROGRESSIVE_FLUSH: 1
PERCH_PARANOID:
PERCH_FORCE_SECURE_COOKIES:
PERCH_PASSWORD_MIN_LENGTH: 6
PERCH_MAX_FAILED_LOGINS: 10
PERCH_AUTH_LOCKOUT_DURATION: 1 HOUR
PERCH_VERIFY_UPLOADS:
PERCH_AUTH_PLUGIN:
PERCH_DB_CHARSET: utf8
PERCH_DB_PORT:
PERCH_DB_SOCKET:
PERCH_SESSION_TIMEOUT_MINS: 20
PERCH_SHOP_VERSION: 1.0.9
PERCH_APPS_EDITOR_PLUGIN: markitup
PERCH_APPS_EDITOR_MARKUP_LANGUAGE: textile
Rachel Andrew

Rachel Andrew 394 points
Perch Support

You will need to look in your error log as usual for the error.

Hi Rachel. I got the following:

Warning: include(/Users/turveyair/Google Drive/htdocs/esl/admin/addons/apps/perch_shop/lib/vendor/guzzle/guzzle/src/Guzzle/Http/Message/EntityEnclosingRequest.php): failed to open stream: No such file or directory in /Users/turveyair/Google Drive/htdocs/esl/admin/addons/apps/perch_shop/lib/vendor/composer/ClassLoader.php on line 414

Warning: include(): Failed opening '/Users/turveyair/Google Drive/htdocs/esl/admin/addons/apps/perch_shop/lib/vendor/guzzle/guzzle/src/Guzzle/Http/Message/EntityEnclosingRequest.php' for inclusion (include_path='.:/Applications/MAMP/bin/php/php5.5.10/lib/php') in /Users/turveyair/Google Drive/htdocs/esl/admin/addons/apps/perch_shop/lib/vendor/composer/ClassLoader.php on line 414

Fatal error: Class 'Guzzle\Http\Message\EntityEnclosingRequest' not found in /Users/turveyair/Google Drive/htdocs/esl/admin/addons/apps/perch_shop/lib/vendor/guzzle/guzzle/src/Guzzle/Http/Message/RequestFactory.php on line 99
Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you try the current version of Shop?

I updated Shop and same issue but this time just get one warning:

Warning: Cannot modify header information - headers already sent by (output started at /Users/turveyair/Google Drive/htdocs/esl/admin/templates/layouts/header.php:5) in /Users/turveyair/Google Drive/htdocs/esl/admin/core/lib/PerchUtil.class.php on line 194
Drew McLellan

Drew McLellan 2638 points
Perch Support

Make sure you're not outputting anything to the page before you try to redirect to payment.

I don't know why but I can't access any of my site on localhost this morning due to this error:

Warning: require(/Users/turveyair/Google Drive/htdocs/esl/admin/addons/apps/perch_shop/lib/vendor/ircmaxell/password-compat/lib/password.php): failed to open stream: No such file or directory in /Users/turveyair/Google Drive/htdocs/esl/admin/addons/apps/perch_shop/lib/vendor/composer/autoload_real.php on line 66

Fatal error: require(): Failed opening required '/Users/turveyair/Google Drive/htdocs/esl/admin/addons/apps/perch_shop/lib/vendor/ircmaxell/password-compat/lib/password.php' (include_path='.:/Applications/MAMP/bin/php/php5.5.10/lib/php') in /Users/turveyair/Google Drive/htdocs/esl/admin/addons/apps/perch_shop/lib/vendor/composer/autoload_real.php on line 66
Duncan Revell

Duncan Revell 78 points
Registered Developer

Throwing this into the mix incase it somehow helps:

It looks like you're storing your website files in a Google Drive synced folder - it might be worth trying all this stuff in a folder that isn't being synced - it could be causing the issues you're seeing with files missing and what-not.

Not a guaranteed solution, but worth a go.

Thanks Duncan yes I had considered that.

I fixed the fatal error warning by reinstalling Shop anyway. I'm now going to try the checkout process again and report back.

Ok after entering the test card details this time and submitting I get a redirect to my failed URL. How can I get more information about why the transaction failed? The order did not appear in Perch admin or Stripe so I'm wondering how I can investigate?

Update: just found the Stripe Logs area which I hadn't seen before. I'm getting:

{
  "error": {
    "type": "invalid_request_error",
    "message": "Stripe no longer supports API requests made with TLS 1.0. Please initiate HTTPS connections with TLS 1.2 or later. You can learn more about this at https://stripe.com/blog/upgrading-tls."
  }
}

Does this mean I can't test on localhost?

Drew McLellan

Drew McLellan 2638 points
Perch Support

No, you'll just need to update your local server.