承接 cubicmushroom/stripe-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

cubicmushroom/stripe-bundle

最新稳定版本:v2.7.3

Composer 安装命令:

composer require cubicmushroom/stripe-bundle

包简介

Symfony bundle for handling Stripe payments

README 文档

README

Symfony bundle to add support for Stripe payments

Installation

Using composer...

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

Symfony Setup

Register bundle by adding the following line to your AppKernel file...

// 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...

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...

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...

{{ cm_stripe_api_script() }}

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

Bundle JS file

First ensure the bundle assets are installed using the app/console assets:install command.

Add the following script tag to your page's JavaScript files...

If using assetic...

{% 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...

<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.

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...

(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.

统计信息

  • 总下载量: 141
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-10-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固