fk/pay 问题修复 & 功能扩展

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

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

fk/pay

Composer 安装命令:

composer require fk/pay

包简介

README 文档

README

Integration of all Third Part Payment(TPP)

Configuration

# main-local.php
<?php
return [
    // other config
    'components' => [
        'pay' => [
            'class' => 'fk\pay\Component',
            'channel' => 'WeChat', // Here is default channel
            // As for different platforms, the actual notify_url will need a prefix of platform name
            // end with .php
            // e.g.
            // For WeChat, it will be `https://api.alijian.net/notify/we-chat.php`
            // The `we-chat.php` come from `WeChat`.
            // You should rewrite the server route, to fit the filename rule.
            'notifyPath' => 'https://api-test.alijian.net/notify/',
            'platforms' => [
                'WeChat' => [
                    'web' => [ // Web, a.k.a JS, a.k.a H5 payment
                        'app_id' => 'wx71xxx',
                        'app_secret' => 'xxx',
                        'mch_id' => 1234567890,
                        'key' => 'QqDAWHMgDpskKmsdjYH', // to sign
                        'ssl_cert_path' => '@common/data/cache/apiclient_cert.pem', // to refund
                        'ssl_key_path' => '@common/data/cache/apiclient_key.pem',
                    ],
                    'app' => [ // App(iOS, Android) payment
                        'app_id' => 'wxxxxx',
                        'mch_id' => 1234567890,
                        'app_secret' => '6exxx',
                        'key' => 'QqDAWHMgDpskKmsdjYH', // to sign
                        'ssl_cert_path' => '@common/data/cache/apiclient_cert.pem', // to refund
                        'ssl_key_path' => '@common/data/cache/apiclient_key.pem',
                    ]
                ],
                'AliPay' => [ // under construction
                    'name' => 'haha',
                ],
            ]
        ]
    ]
];

Pay

Transfer money from user's TPP account to your platform

<?php
$orderSn = '2014124582620133'; // 20 bytes recommended
$amount = 1000; // Money with unit Fen(CNY), 10 Yuan
$name = 'Apple';
$description = 'Sweet Apple';
$extra = [
    'trade_type' => 'JSAPI',
    'openid' => 'o-28js7h4kd01kldfg7ag29zk3'
];
Yii::$app->pay
    ->with('WeChat') // Default defined in config file
    ->pay($orderSn, $amount, $name, $description, $extra);
Parameter Description
$orderSn Order Serial Number on your platform
$amount Money of the goods
$name Name of the goods
$description Description for the goods
$extra Extra information for the order, differs with TPP

$extra for Wechat

  • trade_type: required APP, JSAPI, NATIVE
  • openid: required when trade_type=JSAPI
  • ...: other optional params for WeChat API, see JSAPI Docs and APP Docs

$extra for AliPay

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2016-09-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固