GithubHelp home page GithubHelp logo

xhat / payjs-laravel Goto Github PK

View Code? Open in Web Editor NEW
59.0 4.0 8.0 14 KB

基于 PAYJS 微信支付个人接口开发的 Laravel Package,可直接用于生产环境

Home Page: https://payjs.cn

PHP 100.00%
payjs payment wechat wechatpay wepay

payjs-laravel's Introduction

PAYJS Wechat Payment Laravel Package

Latest Stable Version Total Downloads License

简介

本项目是基于 PAYJS 的 API 开发的 Laravel Package,可直接用于生产环境

PAYJS 针对个人主体提供微信支付接入能力,是经过检验的正规、安全、可靠的微信支付个人开发接口

其它版本: PAYJS 通用开发包

支持Laravel 5.x、Laravel 6.x、Laravel 7.x、Laravel 8.x

安装

通过 Composer 安装

$ composer require xhat/payjs-laravel

使用方法

一、发布并修改配置文件

  • 发布配置文件
php artisan vendor:publish --provider="Xhat\Payjs\PayjsServiceProvider"
  • 编辑配置文件 config/payjs.php 配置商户号和通信密钥
return [
    'mchid' => '', // 填写商户号
    'key'   => '', // 填写通信KEY
];

二、在业务中使用

首先在业务模块中引入门面

use Xhat\Payjs\Facades\Payjs;
  • 扫码支付
// 构造订单基础信息
$data = [
    'body' => '订单测试',                                // 订单标题
    'total_fee' => 2,                                   // 订单标题
    'out_trade_no' => time(),                           // 订单号
    'attach' => 'test_order_attach',                    // 订单附加信息(可选参数)
    'notify_url' => 'https://www.baidu.com/notify',     // 异步通知地址(可选参数)
];
return Payjs::native($data);
  • 收银台模式支付(直接在微信浏览器打开)
// 构造订单基础信息
$data = [
    'body' => '订单测试',                                    // 订单标题
    'total_fee' => 2,                                       // 订单金额
    'out_trade_no' => time(),                               // 订单号
    'attach' => 'test_order_attach',                        // 订单附加信息(可选参数)
    'notify_url' => 'https://www.baidu.com/notify',         // 异步通知地址(可选参数)
    'callback_url' => 'https://www.baidu.com/callback',     // 支付后前端跳转地址(可选参数)
];
$url = Payjs::cashier($data);
return redirect($url);
  • JSAPI模式支付
// 构造订单基础信息
$data = [
    'body' => '订单测试',                                    // 订单标题
    'total_fee' => 2,                                       // 订单金额
    'out_trade_no' => time(),                               // 订单号
    'attach' => 'test_order_attach',                        // 订单附加信息(可选参数)
    'openid' => 'xxxxxxxxxxxxxxxxx',                        // 订单附加信息(可选参数)
    'notify_url' => 'https://www.baidu.com/notify',         // 异步通知地址(可选参数)
];
return Payjs::jsapi($data);
  • H5支付
// 构造订单基础信息
$data = [
    'body' => '订单测试',                                    // 订单标题
    'total_fee' => 2,                                       // 订单金额
    'out_trade_no' => time(),                               // 订单号
    'attach' => 'test_order_attach',                        // 订单附加信息(可选参数)
    'notify_url' => 'https://www.baidu.com/notify',         // 异步通知地址(可选参数)
    'callback_url' => 'https://www.baidu.com',              // 前端跳转地址(可选参数)
];
return Payjs::mweb($data);
  • 投诉查询
// 构造订单基础信息
$data = [
    'mchid' => '123123',                                    // 商户号
];
return Payjs::complaint($data);
  • 查询订单
// 根据订单号查询订单状态
$payjs_order_id = '****************';
return Payjs::check($payjs_order_id);
  • 关闭订单
// 根据订单号关闭订单
$payjs_order_id = '****************';
return Payjs::close($payjs_order_id);
  • 退款
// 根据订单号退款
$payjs_order_id = '****************';
return Payjs::refund($payjs_order_id);
  • 获取商户资料
// 返回商户基础信息
return Payjs::info();
  • 获取用户资料
// 根据订单信息中的 OPENID 查询用户资料
$openid = '***************';
return Payjs::user($openid);
  • 查询银行名称
// 根据订单信息中的银行编码查询银行中文名称
$bank = '***************';
return Payjs::bank($bank);
  • 接收异步通知
// 接收异步通知,无需关注验签动作,已自动处理
$notify_info = Payjs::notify();
Log::info($notify_info);

更新日志

Version 1.5.0 增加投诉API、H5支付API

Version 1.4 修正空值参数的过滤问题

安全相关

如果您在使用过程中发现各种 bug,请积极反馈,我会尽早修复

payjs-laravel's People

Contributors

xhat avatar xiaohuilam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

payjs-laravel's Issues

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.