2017 © Pedro Peláez
 

library stripe-bundle

Symfony bundle for handling Stripe payments

image

cubicmushroom/stripe-bundle

Symfony bundle for handling Stripe payments

  • Tuesday, November 28, 2017
  • by ToG
  • Repository
  • 1 Watchers
  • 0 Stars
  • 130 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

Stripe Payment Bundle

Symfony bundle to add support for Stripe payments, (*1)

Installation

Using composer..., (*2)

$ composer require "cubicmushroom/stripe-bundle" "dev-master"

Symfony Setup

Register bundle by adding the following line to your AppKernel file..., (*3)

// app/AppKernel.php
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            //...
            new CubicMushroom\Symfony\StripeBundle\CMStripeBundle(),
            //...
        );

        // ...
    }

    // ...
}

Add the following to your app/config.yml file..., (*4)

cm_stripe:
    api_publishable_key:  %cm_stripe.api_publishable_key%
    api_secret_key:       %cm_stripe.api_secret_key%

... and the following to your parameters.yml.dist/parameters.yml, replacing the '~'s with your API details in the parameters.yml file..., (*5)

parameters:
    ...

    # Stripe Bundle
    cm_stripe.api_publishable_key:  ~
    cm_stripe.api_secret_key:       ~

Load JavaScript library

Stripe JS file & API key

Add the following twig function call to your page templates for pages that contain Stripe payment forms..., (*6)

{{ cm_stripe_api_script() }}

This injects the Stripe API JavaScript file, along with your public key into the page., (*7)

Bundle JS file

First ensure the bundle assets are installed using the app/console assets:install command., (*8)

Add the following script tag to your page's JavaScript files..., (*9)

If using assetic..., (*10)

{% javascripts
{#...#}
'@CMStripeBundle/Resources/public/js/stripe-bundle.js'
{#...#}
output='compiled/js/app.js' %}
<script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}

... or if not using assetic..., (*11)

<script type="text/javascript" src="/bundles/cmstripe/js/stripe-bundle.js"></script>

Customising error messages

The error messages displayed by the plugin are attached to the .stripe-errors form element (must be within the related form), which is added to the top of the form if it doesn't already exist., (*12)

You can customise the format of these errors using the StripeBundle.EVENTS.FORMAT_ERROR_MSG event that's fired on the Stripe form's form tag by using something similar to the following..., (*13)

(function ($) {
    'use strict';

    //noinspection JSLint,JSUnusedLocalSymbols
    /**
     *
     * @param {Event} event
     * @param {{errorMessage: string}} errorDetails
     */
    function addStripeErrorFormatting(event, errorDetails) {
        errorDetails.errorMessage = '<div class="alert alert-danger fade in">' + errorDetails.errorMessage + '</div>';
    }

    $(function () {
        $('form.stripe-form').on(StripeBundle.EVENTS.FORMAT_ERROR_MSG, addStripeErrorFormatting);
    });
}(jQuery));

TakePaymentCommand form

The bundle provides a form type called cm_stripe_take_payment. This can be used to display a Stripe payment form, along with the other TakePaymentCommand fields., (*14)

The Versions

26/04 2016
26/04 2016
26/04 2016
24/04 2016

2.7.0

2.7.0.0

Symfony bundle for handling Stripe payments

  Sources   Download

MIT

The Requires

 

The Development Requires

by Toby Griffiths

23/04 2016

1.0.0

1.0.0.0

Symfony bundle for handling Stripe payments

  Sources   Download

MIT

The Requires

 

The Development Requires

by Toby Griffiths