PHP各大付出平台在线付出集成源码

演示检察:http://www.erdangjiade.com/ph…
php给客户开辟网站的时刻须要用到各大平台付款功用,下面就免费分享给人人,此类是个成熟类,网上down下来的,经由修正测试了(能够直接拿来运用,附带运用方法,有须要的朋侪请拿走。),如果有须要装置的演示请上岸“二当家的”检察:http://www.erdangjiade.com/ph…

““门生”或“还没有事情的童鞋”能够无条件享用本站一切素材资本
现在包括了付出宝pc版、付出宝wap版、palpay、yeepay、unionpay、kuaiqian、财付通tenpay等,这几个经常使用的付出平台,付出体式格局均为立即到账,不包括包管付出。
付出设置ThinkPayApplicationCommonConfconfig.php

array(
/ 付出设置 /
‘payment’ => array(
‘tenpay’ => array(
// 加密key,开通财付通账户后赋予
‘key’ => ‘e82573dc7e6136ba414f2e2affbe39fa’,
// 合作者ID,财付通有该设置,开通财付通账户后赋予
‘partner’ => ‘1900000113’
),
‘alipay’ => array(
// 收款账号邮箱
’email’ => ‘chenf003@yahoo .cn’,
// 加密key,开通付出宝账户后赋予
‘key’ => ‘aaa’,
// 合作者ID,付出宝有该设置,开通易宝账户后赋予
‘partner’ => ‘2088101000137799’
),
‘aliwappay’ => array(
// 收款账号邮箱
’email’ => ‘chenf003@yahoo .cn’,
// 加密key,开通付出宝账户后赋予
‘key’ => ‘aaa’,
// 合作者ID,付出宝有该设置,开通易宝账户后赋予
‘partner’ => ‘2088101000137799’
),
‘palpay’ => array(
‘business’ => ‘zyj@qq .com’
),
‘yeepay’ => array(
‘key’ => ’69cl522AV6q613Ii4W6u8K6XuW8vM1N6bFgyv769220IuYe9u37N4y7rI4Pl’,
‘partner’ => ‘10001126856’
),
‘kuaiqian’ => array(
‘key’ => ‘1234567897654321’,
‘partner’ => ‘1000300079901’
),
‘unionpay’ => array(
‘key’ => ‘88888888’,
‘partner’ => ‘105550149170027’
)
)
);

付出天生定单 ThinkPayThinkPHPLibraryThinkPay.class.php

function buildRequestForm(PayPayVo $vo) {
$this->payer->check();
//天生当地纪录数据
$check = M(“Pay”)->add(array(
‘out_trade_no’ => $vo->getOrderNo(),
‘money’ => $vo->getFee(),
‘status’ => 0,
‘callback’ => $vo->getCallback(),
‘url’ => $vo->getUrl(),
‘param’ => serialize($vo->getParam()),
‘create_time’ => time(),
‘update_time’ => time()
));

if ($check !== false) {
return $this->payer->buildRequestForm($vo);
} else {
E(M(“Pay”)->getDbError());
}
}

付出定单表

/**
数据库
CREATE TABLE think_pay (
out_trade_no varchar(100) NOT NULL,
money decimal(10,2) NOT NULL,
status tinyint(1) NOT NULL DEFAULT ‘0’,
callback varchar(255) NOT NULL,
url varchar(255) NOT NULL,
param text NOT NULL,
create_time int(11) NOT NULL,
update_time int(11) NOT NULL,
PRIMARY KEY (out_trade_no)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
*/

alipay设置ThinkPayThinkPHPLibraryThinkPayDriverAlipay.class.php

protected $gateway = ‘https://mapi.alipay.com/gatew…‘;
protected $verify_url = ‘http://notify.alipay.com/trad…‘;
protected $config = array(
’email’ => ”,
‘key’ => ”,
‘partner’ => ”
);

md5加密

public function buildRequestForm(ThinkPayPayVo $vo) {
$param = array(
‘service’ => ‘create_direct_pay_by_user’,
‘payment_type’ => ‘1’,
‘_input_charset’ => ‘utf-8’,
‘seller_email’ => $this->config[’email’],
‘partner’ => $this->config[‘partner’],
‘notify_url’ => $this->config[‘notify_url’],
‘return_url’ => $this->config[‘return_url’],
‘out_trade_no’ => $vo->getOrderNo(),
‘subject’ => $vo->gettitle(),
‘body’ => $vo->getBody(),
‘total_fee’ => $vo->getFee()
);

ksort($param);
reset($param);

$arg = ”;
foreach ($param as $key => $value) {
if ($value) {
$arg .= “$key=$value&”;
}
}

$param[‘sign’] = md5(substr($arg, 0, -1) . $this->config[‘key’]);
$param[‘sign_type’] = ‘MD5’;

$sHtml = $this->_buildForm($param, $this->gateway, ‘get’);

return $sHtml;
}

付出胜利后回调地点ThinkPayApplicationHomeControllerPublicController.class.php

public function notify() {
$apitype = I(‘get.apitype’);

$pay = new ThinkPay($apitype, C(‘payment.’ . $apitype));
if (IS_POST && !empty($_POST)) {
$notify = $_POST;
} elseif (IS_GET && !empty($_GET)) {
$notify = $_GET;
unset($notify[‘method’]);
unset($notify[‘apitype’]);
} else {
exit(‘Access Denied’);
}
//考证
if ($pay->verifyNotify($notify)) {
//猎取定单信息
$info = $pay->getInfo();

if ($info[‘status’]) {
$payinfo = M(“Pay”)->field(true)->where(array(‘out_trade_no’ => $info[‘out_trade_no’]))->find();
if ($payinfo[‘status’] == 0 && $payinfo[‘callback’]) {
session(“pay_verify”, true);
$check = R($payinfo[‘callback’], array(‘money’ => $payinfo[‘money’], ‘param’ => unserialize($payinfo[‘param’])));
if ($check !== false) {
M(“Pay”)->where(array(‘out_trade_no’ => $info[‘out_trade_no’]))->setField(array(‘update_time’ => time(), ‘status’ => 1));
}
}
if (I(‘get.method’) == “return”) {
redirect($payinfo[‘url’]);
} else {
$pay->notifySuccess();
}
} else {
$this->error(“付出失利!”);
}
} else {
E(“Access Denied”);
}
}

    原文作者:二当家的
    原文地址: https://segmentfault.com/a/1190000008302112
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞