Giter VIP home page Giter VIP logo

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;
  • 查询订单
// 根据订单号查询订单状态
$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);
  • 获取商户资料
// 返回商户基础信息
$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.0

安全相关

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

payjs's People

Contributors

xhat avatar

Watchers

Sky Walker 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.