cgm/zf2-tip-me

ZF2 module for accepting tips/donations with Stripe

dev-master 2016-01-17 16:19 UTC

This package is not auto-updated.

Last update: 2024-12-18 13:40:59 UTC


README

No Maintenance Intended

Version 1.0.0 / Created by Christopher Martin / BSD-3-Clause License

Introduction

Accept donations directly on your site with Zend Framework 2 and a free Stripe account.

ZF2TipMe example screenshot

Features

  • Notification emails can be sent after successful payments.
  • Test mode toggle, with a list of test credit cards for various testing scenarios.
  • Designed for easy customization. Donation items are configurable. Event hooks available.
  • Failed transactions are logged.
  • No PCI data is sent to or stored on your server, thanks to Stripe.

Stripe currently is only available in United States and Canada.

Get notified of when Stripe is available in your country.

Installation

Composer / Packagist Install

Add "minimum-stability": "dev" to your composer.json file, and run:

# From project's base directory...
% composer.phar require cgm/zf2-tip-me
Please provide a version constraint for the cgm/config-admin requirement: dev-master

Enable the ZF2TipMe Module

Edit your application.config.php and enable the ZfcBase and ZF2TipMe modules:

return array(
    'modules' => array(
        // ...
        'ZfcBase',
        'ZF2TipMe',
    ),
    // ...
);

Create Directories and Symbolic Links

Out of the box, this module is configured to write log files to ./data/log and ./data/mail. The mail logs are used when you have chosen not to use a mail server.

# From project's base directory...
% cd data
% mkdir log mail
% chmod 777 log mail
# Or set the appropriate group permissions to be writable by the webserver

There is an asset folder with CSS and JavaScript files. You can link them to ./public/tip-me-assets, or potentially use a asset management module:

# From the project's base dir...
% cd public
% ln -s ../vendor/cgm/zf2-tip-me/public tip-me-assets

Edit the Configuration

Copy the .global and .local dist files from the module config directory:

# From project's base directory...
% cd config/autoload
% cp ../../vendor/cgm/zf2-tip-me/config/zf2tipme.global.php.dist ./zf2tipme.global.php
% cp ../../vendor/cgm/zf2-tip-me/config/zf2tipme.local.php.dist ./zf2tipme.local.php

Edit the zf2tipme.global.php file to taste:

<?php
return array(
    'zf2tipme' => array(
        'error_log'            => './data/log/tipme.log',
        'recipient_name'       => '{{{RECIPIENT}}}',            // Your name
        'admin_email'          => '{{{admin@email.address}}}',  // Displayed for refunds, and used for mail notifications
        'statement_descriptor' => '{{{STATEMENT_DESCRIPTOR}}}', // Stripe account setting
        'tip_options' => array(                                 // Customize away...
            'coffee' => array(
                'title'   => 'Cup of Starbucks coffee (12 oz)',
                'amount'  => 2.50,
                'img_src' => 'http://placehold.it/200x150',
            ),
            'redbull' => array(
                'title'  => 'Red Bull (20 oz, sugar free)',
                'amount' => 4.48,
                'img_src' => 'http://placehold.it/200x150',
            ),
            'music' => array(
                'title'  => 'MP3 music (album)',
                'amount' => 9.99,
                'img_src' => 'http://placehold.it/200x150',
            ),
        ),
        'mail_transport_options' => array(                       // Used with default 'zf2tipme_mailtransport' factory in Module.php
            'path' => './data/mail/',
        ),
    ),
);

Edit the zf2tipme.local.php file with your Stripe API keys:

<?php
$testMode = true;
return array(
    'zf2tipme' => array(
        'test_mode'          => $testMode,
        'stripe_secret_key'  => ($testMode)
                              ? '{{{TEST_SECRET_KEY_HERE}}}'
                              : '{{{LIVE_SECRET_KEY_HERE}}}',
        'stripe_publish_key' => ($testMode)
                              ? '{{{TEST_PUBLISHABLE_KEY_HERE}}}'
                              : '{{{LIVE_PUBLISHABLE_KEY_HERE}}}',
    ),
);

Verify it works

Point your browser to /tip-me and use the "Fill Test Data" dropdown for testable credit cards.

Like this module?

Tip me a coffee ☕ ;)