Skip to content

MasPay是国广创享支付,集成了微信支付、支付宝支付、PayPal、Stripe 提供统一的调用接口,方便快速接入各种支付、查询、退款、转账能力。服务端接入支付功能,方便、快捷。企业,个人均可进行申请使用 JPay PHP SDK Library

Notifications You must be signed in to change notification settings

ruihan0618/jpay-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JPay PHP bindings

You can sign up for a MasJPay account at https://jpay.weidun.biz.

Requirements

PHP 5.6.0 and later.

Composer

You can install the bindings via Composer. Run the following command:

composer require jpaypp/jpay-php

To use the bindings, use Composer's autoload:

require_once('vendor/autoload.php');

Manual Installation

If you do not wish to use Composer, you can download the latest release. Then, to use the bindings, include the init.php file.

require_once('/path/to/jpay-php/init.php');

Dependencies

The bindings require the following extensions in order to work properly:

  • curl, although you can use your own non-cURL client if you prefer
  • json
  • mbstring (Multibyte String)

If you use Composer, these dependencies should be handled automatically. If you install manually, you'll want to make sure that these extensions are available.

Getting Started

Simple usage looks like:

\MasJPay\MasJPay::setDebug(true); //调试模式   true /false
\MasJPay\MasJPay::setApiMode('sandbox'); //环境  live 线上,sandbox 沙盒
\MasJPay\MasJPay::setClientId('10000000');   // 设置 CLIENT ID
\MasJPay\MasJPay::setApiKey('BQokikJOvBiI2HlWgH4olfQ2');    // 设置 API Key
try {
    $ch = \MasJPay\Charge::create([
        'channel'   => '901',                // 支付使用的第三方支付渠道取值
        'out_order_no' => time(),  //外部订单号 ,为空时由系统生成
        'product' =>[  //商品信息
            'subject'      => '测试商品',   //商品名称
            'body'      => '测试商品',   //商品描述
            'amount'    => '1',   // 订单总金额
            'quantity'  => '1'  //商品数量
        ],
        'extra'    =>[     //扩展信息
            'mode'      => 'mweb',  //微信渠道901 ,支付模式,jsapi 微信公众号、native 扫码支付、mweb H5 支付 ,link 返回支付链接跳转
            'format'    => 'json', //返回方式 from 表单直接提交/ json 返回
        ],
        'metadata'  => '自定义数据',
        'client_ip' => '1.1.1.1',   //客户端发起支付请求的IP
        'description' => '测试数据', //订单备注说明
        'notify'=> 'http://localhost/notify.html',   //异步通知地址
        'return'=>'http://localhost/callback.html',  //同步地址
     ]);
    echo $ch;                                       // 输出 返回的支付凭据 Charge
} catch (\MasJPay\Error\Base $e) {
    // 捕获报错信息
    if ($e->getHttpStatus() != null) {
        header('Status: ' . $e->getHttpStatus());
        echo $e->getHttpBody();
    } else {
        echo $e->getMessage();
    }
}

Documentation

Please see https://jpay.weidun.biz/api for up-to-date documentation.

Development

Get [Composer][composer]. For example, on Mac OS:

brew install composer

Install dependencies:

composer install

Install dependencies as mentioned above (which will resolve PHPUnit), then you can run the test suite:

./vendor/bin/phpunit

Or to run an individual test file:

./vendor/bin/phpunit tests/UtilTest.php

The method should be called once, before any request is sent to the API. The second and third parameters are optional.

About

MasPay是国广创享支付,集成了微信支付、支付宝支付、PayPal、Stripe 提供统一的调用接口,方便快速接入各种支付、查询、退款、转账能力。服务端接入支付功能,方便、快捷。企业,个人均可进行申请使用 JPay PHP SDK Library

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages