3 Star 0 Fork 0

旮旯村の小志 / payment

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

payPackage

the weixinPay and alipay package

for install

composer require first236108/payment

support payment type

class PayType
{

    const ALI_APP = AliApp::class;   //支付宝APP支付
    const ALI_H5 = AliH5::class; //支付宝H5支付
    const ALI_QRPAY = AliQrpay::class; //支付宝二维码支付
    const ALI_QUERY = AliQuery::class; //支付宝支付查询
    const ALI_REFUND = AliRefund::class; //支付宝退款
    const ALI_REFUNDQUERY = AliRefundQuery::class;   //支付宝退款查询
    const ALI_TRANS = AliTrans::class;   //支付宝转账
    const ALI_WEB = AliWeb::class;  //支付宝网页调起支付


    const WX_APP = WxApp::class; //微信APP支付
    const WX_Minipro = WxMinipro::class; //微信小程序支付
    const WX_H5 = WxH5::class; //微信H5支付
    const WX_JSPAY = WxJspay::class; //微信公众号支付
    const WX_QRPAY = WxQrpay::class; //微信二维码支付
    const WX_QUERY = WxQuery::class; //微信支付查询
    const WX_REFUND = WxRefund::class; //微信退款
    const WX_REFUNDQUERY = WxRefundQuery::class;  //微信退款查询

}

#pay example

	use Payment\Pay;
	use Payment\PayType;
	
	$payConf	= array(
		'ali'=>[
				'app_id'				=>	'2017103109632000',
				'charset'				=>	'UTF-8',
				'sign_type'				=>	'RSA2',
				'gatewayUrl'			=>	'https://openapi.alipay.com/gateway.do',
				'merchant_private_key'	=>	'MIIEogIBAAKCAQEAsrq1a7XLpsqmkm5lA6whw0gCG...',
				'alipay_public_key'		=>	'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgAQE...',
				'return_url'			=>	'https://pay.web.cn/notify/',
				'notify_url'			=>	'https://pay.web.cn/return/',
		],
		'wx'=>[
				'appid'					=>	'wxd61e5ed1a5c7b8b5',
				'mchid'					=>	'1488194000',
				'key'					=>	'0598e9a56c45cd5243d27394cb21be3b',
				'sign_type'				=>	'MD5',
				'secret'				=>	'cdcb1b56897754fb0459ba962bd01bba',
				'notify_url'			=>	'https://pay.web.cn/notify/',
		],
	);
			
	$payData	=	array(
		'subject'		=>	"支付测试",
		'out_trade_no'	=>	"202182347283741234",		
		'amount'		=>	0.01,
		'param'			=>	"{'goods_id':1001}",
	);

	try {			
		Pay::run(PayType::ALI_H5, strtoupper(substr(PayType::ALI_H5, 0, 2))=='WX'?$payConf['wx']:$payConf['ali'], $payData);
	} catch (Exception $e) {				
		$result = array(
			'ret' => 9,
			'msg' => $e->getMessage(),
		);
	}

#notify example

use Payment\Notify;

//微信支付回调
public function wxNotifyAction()
    {
        #Log::out(file_get_contents('php://input'), 'wxnotify');
        $payConf    = [
				'appid'					=>	'wxd61e5ed1a5c7b8b5',
				'mchid'					=>	'1488194000',
				'key'					=>	'0598e9a56c45cd5243d27394cb21be3b',
				'sign_type'				=>	'MD5',
				'secret'				=>	'cdcb1b56897754fb0459ba962bd01bba',
				'notify_url'			=>	'https://pay.web.cn/notify/',
		];
        Notify::run('NotifyWx', $payConf, ['ordersModel', 'notifyProcess']);
    }

#refund exapmle

use Payment\Pay;
use Payment\PayType;

try {
    $payConf    = [
				'appid'					=>	'wxd61e5ed1a5c7b8b5',
				'mchid'					=>	'1488194000',
				'key'					=>	'0598e9a56c45cd5243d27394cb21be3b',
				'sign_type'				=>	'MD5',
				'secret'				=>	'cdcb1b56897754fb0459ba962bd01bba',
				'notify_url'			=>	'https://pay.web.cn/notify/',
	];
    $refundData = [
        'refund_no' => uniqid('ref'),
        'trade_no' => 'transaction_id',
        'total_fee' => 0.01,
        'refund_fee' => 0.01,
    ];
    $paidType = 'wxpay';
    $refund = '';
    if ($paidType == 'wxpay') {
        $config['sslcert_path'] = __DIR__ . '../cert/apiclient_cert.pem';
        $config['sslkey_path'] = __DIR__ . '../cert/apiclient_key.pem';
        $refund = PayType::WX_REFUND;
    } elseif ($paidType == 'alipay') {
        $refund = PayType::ALI_REFUND;
    }
    $result = Pay::run($refund, $payConf, $refundData);
} catch (\Throwable $t) {
    echo $t->getMessage();
}

空文件

简介

暂无描述 展开 收起
PHP
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
PHP
1
https://gitee.com/alexpan/payment.git
git@gitee.com:alexpan/payment.git
alexpan
payment
payment
factory

搜索帮助