<?php
namespace application\pay\model;
use ticky\traits\instance;
class payment {
use instance;
public function pay($paytype, $params) {
$data = db('pay_mode')->field('enabled,action')->where(array('id' => $paytype))->find();
if (!$data || $data['enabled'] == 1)
$action = $data['action'];
if (!$action || !method_exists($this, $action))
$this->$action($params);
}
public function alipay($params) {
load_extend('alipay/pagepay.php');
$params = array(
'subject' => $params['desc'],
'out_trade_no' => $params['order_sn'],
'total_amount' => $params['money'],
'body' => $params['desc']
);
\pagepay::pay($params);
}
public function alipay_notify($params, $order) {
if ($order['status'] != 0)
return false;
load_extend('alipay/notify.php');
return \notify::check($params, $order);
}
public function alipay_check_status($status) {
if ($status == 'TRADE_SUCCESS')
return true;
return false;
}
public static function alipay_config() {
if (!$alipay = cache('alipay')) {
$data = db('pay_mode')->where(array('action' => 'alipay'))->find();
$alipay = string2array($data['config']);
$alipay['notify_url'] = url('pay/index/pay_callback'); $alipay['return_url'] = url('pay/index/pay_return'); $alipay['charset'] = 'UTF-8'; $alipay['sign_type'] = 'RSA2'; $alipay['gatewayUrl'] = 'https://openapi.alipay.com/gateway.do'; cache('alipay', $alipay);
}
return $alipay;
}
public function update_order($order, $transaction) {
$result = db('order')->update(array('status' => 1, 'paytime' => SYS_TIME, 'transaction' => $transaction), array('id' => $order['id']));
if ($result) {
if ($order['quantity']) {
}
return true;
} else {
return false;
}
}
public function wechat($params) {
load_extend('wxpay/native.php'); $params = array(
'body' => $params['desc'],
'out_trade_no' => $params['order_sn'],
'total_fee' => $params['money'] * 100, 'product_id' => $params['order_id']
);
$img = \native::getPayImage($params);
include template('member', 'wxpay');
}
}