cubicmushroom/stripe-bundle
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.
cubicmushroom/stripe-bundle 适用场景与选型建议
cubicmushroom/stripe-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 141 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 10 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 cubicmushroom/stripe-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cubicmushroom/stripe-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 141
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-10-08