rapidwebltd/simplestripe
Composer 安装命令:
composer require rapidwebltd/simplestripe
包简介
SimpleStripe makes it easier than ever to integrate basic Stripe-powered payments into a site. With only a small amount of code you can have a payment form ready to start charging customers.
关键字:
README 文档
README
This super simple Stripe integration package allow you to integrate a Stripe powered payment form and charge your customers with only a tiny amount of code.
Installation & Dependencies
This package and its dependencies can be installed using composer.
Just add the package to your composer.json file as follows and run
composer update.
{
"require": {
"rapidwebltd/simplestripe": "1.*"
}
}
If your framework does not do so for you, remember to include the autoload files generated by composer, as follows.
require_once 'vendor/autoload.php';
Setup
To use SimpleStripe, you must first instantiate the
SimpleStripe object. To do this, all you need is the Stripe API
keys and the currency you wish to take payments in.
// Setup SimpleStripe using Stripe API keys and currency $simpleStripe = \RapidWeb\SimpleStripe\Factories\SimpleStripeFactory::create('PUBLISHABLE_KEY', 'SECRET_KEY', 'GBP');
You can find your Stripe API keys within your https://dashboard.stripe.com/account/apikeys. You will need both the secret key and the publishable key.
The currency must be presented in ISO 4217 format, such as GBP, USD, EUR.
Displaying payment form
The following code will display a simple payment form, suitable for taking payment with all common debit and credit cards.
// Display a simple payment form echo $simpleStripe->paymentForm();
This code will also include all the necessary JavaScript code to handle client-side communication with Stripe and display of validation errors. The form will post back to the same URL it is displayed upon.
Charging the customer
Charging customers is simple. The following code is an example of how you can:
- Handle the payment form post back
- Attempt to charge the customer
- Handle success or failure
// If payment form has been submitted if (isset($_POST['stripeToken'])) { // Get the amount to charge (in the currency's lowest denomination) $amount = 500; // Five hundred pence = Five pounds (5 GBP) // Charge the customer $charge = $simpleStripe->charge($amount, $_POST['stripeToken']); if ($charge->succeeded) { // If charge succeeded, display success messsage, or perhaps redirect the user to a success page echo "Success!"; exit; } elseif ($charge->problemType=='Card') { // If there was a problem with the card, display details of the problem echo $charge->problem; } else { // Else, display a generic failure message echo "Sorry, there was a problem processing your payment."; } }
You should include code similar to this towards the top of the page containing your payment form.
Example
For a complete implementation of SimpleStripe, see src/Example.php.
License
This library is licensed under the Lesser General Public License version 3.
rapidwebltd/simplestripe 适用场景与选型建议
rapidwebltd/simplestripe 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 20 次下载、GitHub Stars 达 0, 最近一次更新时间为 2016 年 11 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「library」 「stripe」 「payment gateway」 「PHP Library」 「Stripe library」 「PHP Stripe library」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rapidwebltd/simplestripe 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rapidwebltd/simplestripe 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rapidwebltd/simplestripe 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Flexible payment integration for Laravel, lunarphp, supporting multiple payment providers.
Inbox pattern process implementation for your Laravel Applications
Rich payment solutions for Laravel framework. Paypal, payex, authorize.net, be2bill, omnipay, recurring paymens, instant notifications and many more
Core library that defines common interfaces used by the rest of the intahwebz..
Amqp classes
统计信息
- 总下载量: 20
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: LGPL-3.0-only
- 更新时间: 2016-11-09