GithubHelp home page GithubHelp logo

xhat / payjs Goto Github PK

View Code? Open in Web Editor NEW
75.0 2.0 11.0 12 KB

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

Home Page: https://payjs.cn

PHP 100.00%
payjs wechat payment wechatpay wepay alipay jsapi payjs-package

payjs's Introduction

PAYJS Wechat Payment Composer Package

Latest Stable Version Total Downloads License

简介

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

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

其它版本: PAYJS Laravel 开发包

安装

通过 Composer 安装

$ composer require xhat/payjs

使用方法

首先在业务中引入

<?php
require_once __DIR__ . '/vendor/autoload.php';
use Xhat\Payjs\Payjs;

// 配置通信参数
$config = [
    'mchid' => '12323412323',   // 配置商户号
    'key'   => 'sadfsaddsaf',   // 配置通信密钥
];

// 初始化
$payjs = new Payjs($config);

其次开始使用

  • 扫码支付
// 构造订单基础信息
$data = [
    'body' => '订单测试',                        // 订单标题
    'total_fee' => 2,                           // 订单金额
    'out_trade_no' => time(),                   // 订单号
    'attach' => 'test_order_attach',            // 订单附加信息(可选参数)
    'notify_url' => 'https://www.baidu.com',    // 异步通知地址(可选参数)
];

$result = $payjs->native($data);
print_r($result);
  • 收银台模式支付(直接在微信浏览器打开)
// 构造订单基础信息
$data = [
    'body' => '订单测试',                         // 订单标题
    'total_fee' => 2,                            // 订单金额
    'out_trade_no' => time(),                    // 订单号
    'attach' => 'test_order_attach',             // 订单附加信息(可选参数)
    'notify_url' => 'https://www.baidu.com',     // 异步通知地址(可选参数)
    'callback_url' => 'https://www.baidu.com',   // 支付后前端跳转地址(可选参数)
];
$url = $payjs->cashier($data);
header('Location:'.$url);
exit;
  • JSAPI模式支付
// 构造订单基础信息
$data = [
    'body' => '订单测试',                         // 订单标题
    'total_fee' => 2,                            // 订单金额
    'out_trade_no' => time(),                    // 订单号
    'attach' => 'test_order_attach',             // 订单附加信息(可选参数)
    'notify_url' => 'https://www.baidu.com',     // 异步通知地址(可选参数)
    'openid' => 'xxxxxxxxxxxxx',                 // OPENID (必选参数)
];

$result = $payjs->jsapi($data);
print_r($result);
  • H5 模式支付
// 构造订单基础信息
$data = [
    'body'         => '订单测试',                 // 订单标题
    'total_fee'    => 2,                         // 订单金额
    'out_trade_no' => time(),                    // 订单号
    'attach'       => 'test_order_attach',       // 订单附加信息(可选参数)
    'notify_url'   => 'https://www.baidu.com',   // 异步通知地址(可选参数)
    'callback_url' => 'https://www.qq.com',      // 前端跳转url(可选参数)
];

$result = $payjs->mweb($data);
print_r($result);
  • 查询订单
// 根据订单号查询订单状态
$payjs_order_id = '********************';
$result = $payjs->check($payjs_order_id);
print_r($result);
  • 关闭订单
// 根据订单号关闭订单
$payjs_order_id = '********************';
$result = $payjs->close($payjs_order_id);
print_r($result);
  • 退款
// 根据订单号退款
$payjs_order_id = '*********************';
$result = $payjs->refund($payjs_order_id);
print_r($result);
  • 投诉订单获取
// 构造订单基础信息
$data = [
    'mchid'         => '123123',                 // 商户号
];

$result = $payjs->complaint($data);
print_r($result);
  • 获取商户资料
// 返回商户基础信息
$result = $payjs->info();
print_r($result);
  • 获取用户资料
// 根据订单信息中的 OPENID 查询用户资料
$openid = '*******************';
$result = $payjs->user($openid);
print_r($result);
  • 查询银行名称
// 根据订单信息中的银行编码查询银行中文名称
$bank = '*******************';
$result = $payjs->bank($bank);
print_r($result);
  • 接收异步通知
// 接收异步通知,无需关注验签动作,已自动处理
$notify_info = $payjs->notify();
// 接收信息后自行处理

更新日志

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

Version 1.4.3 主要去除了对 GuzzleHttp 包的依赖,同时去除了 Curl 60 的错误提示 修复jsapi的一处bug

安全相关

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

payjs's People

Contributors

xhat avatar xiangrui2019 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

payjs's Issues

异步回调问题

  • 问题: swoole_server 中对全局变量做了严格的处理, 可否把 $_POST 改为默认参数.
// 异步通知接收
public function notify($data = $_POST)
{
    // $data = $_POST; // 可否把 $_POST 改为默认参数
    if ($this->checkSign($data) === true) {
        return $data;
    } else {
        return '验签失败';
    }
}

文字描述错误

// 构造订单基础信息
$data = [
    'body' => '订单测试',                        // 订单标题
    'total_fee' => 2,                           // 订单标题  这里应该为 订单金额
    'out_trade_no' => time(),                   // 订单号
    'attach' => 'test_order_attach',            // 订单附加信息(可选参数)
    'notify_url' => 'https://www.baidu.com',    // 异步通知地址(可选参数)
];

$result = $payjs->native($data);
print_r($result);

这里少了一个post,可能

// JSAPI 模式
public function jsapi(array $data)
{
$this->url = $this->api_url_jsapi;
$data = $this->sign($data);
$url = $this->url . '?' . http_build_query($data);
return $url;
}

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.