znatali/yii2-braintree 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

znatali/yii2-braintree

最新稳定版本:1.0.1

Composer 安装命令:

composer require znatali/yii2-braintree

包简介

Braintree for Yii2

README 文档

README

Integrate a credit card payment form with Braintree's API into Yii2. Inspired by braintreeapi.

Latest Stable Version Scrutinizer Code Quality Code Coverage Build Status Total Downloads

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist tuyakhov/yii2-braintree "*"

or add

"tuyakhov/yii2-braintree": "*"

to the require section of your composer.json file.

Usage

You should add Braintree component to your Yii config first:

'components' => [
    'braintree' => [
        'class' => 'tuyakhov\braintree\Braintree',
        'merchantId' => 'YOUR_MERCHANT_ID',
        'publicKey' => 'YOUR_PUBLIC_KEY',
        'privateKey' => 'YOUR_PRIVATE_KEY',
    ],
]

Once the extension is installed, simply use it in your code by :

BraintreeForm provide all basic operations for sales and stores customer info. Operation name equals scenario name. Available scenarios:

creditCard - create a credit card doc
address - create an address doc
customer - create a customer doc
sale - create a transaction doc
saleFromVault - create a transaction from your Vault doc

Action example:

public function actionSale() {
    $model = new BraintreeForm();
    $model->setScenario('sale');
    if ($model->load(Yii::$app->request->post()) && $model->send()) {
        // do something
    }
    return $this->render('purchase', ['model' => $model]);
}

Form widget for your view:

<?php $form = \tuyakhov\braintree\ActiveForm::begin(); ?>
<?= $form->field($model, 'creditCard_number'); ?>
<?= $form->field($model, 'creditCard_cvv'); ?>
<?=
$form->field($model, 'creditCard_expirationDate')->widget(
    \yii\widgets\MaskedInput::className(),
    ['mask' => '99/9999']
);
?>
<?= $form->field($model, 'amount'); ?>
<?= \yii\helpers\Html::submitButton(); ?>
<?php \tuyakhov\braintree\ActiveForm::end(); ?>

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 2
  • Forks: 9
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-09-29