Giter Site home page Giter Site logo

yii2-payment's Introduction

支付组件

YII2 支付组件(支付宝支付、微信支付)

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist ixiaomu/yii2-payment "*"

or add

"ixiaomu/yii2-payment": "*"

to the require section of your composer.json file.

Used || Example

//根据不同的支付方式及通道 传入不同的支付配置及支付数据

<?= 
    use ixiaomu\payment\Pay;

    $payConfig = [ //换成自己的
        'app_id'        => 'wx69f7d561891b969d',  // 公众账号ID
        'mch_id'        => '1597082962',// 商户id
        'mch_key'           => '1n156wnp3qtihtht93y2xte7bxeoz2ub',// 秘钥
        'app_secret'    => '9e261fd174495ef81989daebfdcd9c05',
        'fee_type'      => 'CNY',// 货币类型  当前仅支持该字段
        'sslcert_path'  => Yii::getAlias('@common').'/lib/payment/wechat/cert/apiclient_cert.pem',
        'sslkey_path'   => Yii::getAlias('@common').'/lib/payment/wechat/cert/apiclient_key.pem',
        'notify_url'    => Yii::getAlias('@apiUrl').'/RestApi/v1/wechat-callback/wx-notify',
    ];
    
    $payData = [
         'out_trade_no'     => '12345678901', // 订单号
         'total_fee'        => '520000', // 订单金额,**单位:分**
         'body'             => '订单描述', // 订单描述
         'openid'           => 'o89PEv2vT_niCY9n5nNAsQWK4D_Q', // 支付人的 openID
    ];
    $pay = new Pay($payConfig);
    try{
        $redult = $pay->driver('wechat')->gateway('mp')->apply($payData);
        var_dump($redult);die;
    }catch (Exception $e){
        throw new Exception('支付失败:'.$e->getMessage());
    }
    

yii2-payment's People

Contributors

ixiaomu avatar

Stargazers

 avatar liaolin avatar  avatar Tinymeng微梦 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.