Skip to content

Commit

Permalink
Merge pull request #1 from Anankke/dev
Browse files Browse the repository at this point in the history
同步过来
  • Loading branch information
Colinwood11 committed May 1, 2019
2 parents 83c1142 + 1628b17 commit 502cde4
Show file tree
Hide file tree
Showing 9 changed files with 198 additions and 24 deletions.
162 changes: 162 additions & 0 deletions app/Services/Gateway/TomatoPay.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
<?php
namespace App\Services\Gateway;
use App\Services\View;
use App\Services\Auth;
use App\Services\Config;
use App\Models\Paylist;
class TomatoPay extends AbstractPayment
{

public function purchase($request, $response, $args)
{
$type = $request->getParam('type');
$price = $request->getParam('price');
if($price <= 0){
return json_encode(['errcode'=>-1,'errmsg'=>"非法的金额."]);
}
$user = Auth::getUser();
$settings = Config::get("tomatopay")[$type];
$pl = new Paylist();
$pl->userid = $user->id;
$pl->total = $price;
$pl->tradeno = self::generateGuid();
$pl->save();
$fqaccount=$settings['account'];
$fqkey=$settings['token'];
$fqmchid = $settings['mchid'];
$fqtype = 1;
$fqtrade = $pl->tradeno;
$fqcny = $price;
$data = [
'account' => $settings['account'],
'mchid' => $settings['mchid'],
'type' => 1,
'trade' => $pl->tradeno,
'cny' => $price,
];
$signs = md5("mchid=".$fqmchid."&account=".$fqaccount."&cny=".$fqcny."&type=1&trade=".$fqtrade.$fqkey);
$url="https://b.fanqieui.com/gateways/".$type.".php?account=".$fqaccount."&mchid=".$fqmchid."&type=".$fqtype."&trade=".$fqtrade."&cny=".$fqcny."&signs=".$signs;
$result = "<script language='javascript' type='text/javascript'>window.location.href='".$url."';</script>";
$result = json_encode(array('code'=>$result,'errcode'=>0,'pid' =>$pl->id));
return $result;
}

public function notify($request, $response, $args)
{
$type = $args['type'];
$settings = Config::get("tomatopay")[$type];
$order_data = $_REQUEST;
$transid = $order_data['trade_no']; //转账交易号
$invoiceid = $order_data['out_trade_no']; //订单号
$amount = $order_data['total_fee']; //获取递过来的总价格
$status = $order_data['trade_status']; //获取传递过来的交易状态
$signs = $order_data['sign'];

$security = array();
$security['out_trade_no'] = $invoiceid;
$security['total_fee'] = $amount;
$security['trade_no'] = $transid;
$security['trade_status'] = $status;
foreach ($security as $k=>$v)
{
$o.= "$k=".urlencode($v)."&";
}
$sign = md5(substr($o,0,-1).$settings['token']);


if ($sign == $signs) {
$this->postPayment($order_data['out_trade_no'], "在线支付");
echo 'success';
if($ispost==0) header("Location: /user/code");


}else{
echo '验证失败';
}
}
public function getPurchaseHTML()
{
return '
<div class="card-inner">
<p class="card-heading">充值</p>
<h5>支付方式:</h5>
<nav class="tab-nav margin-top-no">
<ul class="nav nav-list">
<li>
<a class="waves-attach waves-effect type active" data-toggle="tab" data-pay="wxpay">微信支付</a>
</li>
<li>
<a class="waves-attach waves-effect type" data-toggle="tab" data-pay="alipay">支付宝</a>
</li>
</ul>
<div class="tab-nav-indicator"></div>
</nav>
<div class="form-group form-group-label">
<label class="floating-label" for="amount">金额</label>
<input class="form-control" id="amount" type="text">
</div>
</div>
<div class="card-action">
<div class="card-action-btn pull-left">
<button class="btn btn-flat waves-attach" id="code-update" ><span class="icon">check</span>&nbsp;充值</NOtton>
</div>
</div>
<script>
var type = "wxpay";
var type = "alipay";
var pid = 0;
$(".type").click(function(){
type = $(this).data("pay");
});
$("#code-update").click(function(){
var price = parseFloat($("#amount").val());
console.log("将要使用"+type+"方法充值"+price+"元")
if(isNaN(price)){
$("#result").modal();
$("#msg").html("非法的金额!");
}
$.ajax({
\'url\':"/user/payment/purchase",
\'data\':{
\'price\':price,
\'type\':type,
},
\'dataType\':\'json\',
\'type\':"POST",
success:function(data){
console.log(data);
if(data.errcode==-1){
$("#result").modal();
$("#msg").html(data.errmsg);
}
if(data.errcode==0){
pid = data.pid;
if(type=="wxpay"){
$("#result").modal();
$("#msg").html("正在跳转到微信..."+data.code);
}else if(type=="alipay"){
$("#result").modal();
$("#msg").html("正在跳转到支付宝..."+data.code);
}
}
}
});
setTimeout(f, 1000);
});
</script>
';
}
public function getReturnHTML($request, $response, $args)
{

}
public function getStatus($request, $response, $args)
{
// TODO: Implement getStatus() method.
}
}
6 changes: 4 additions & 2 deletions app/Services/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use App\Services\Config;
use App\Services\Gateway\{
AopF2F, Codepay, DoiAMPay, PaymentWall, ChenPay, SPay, TrimePay, YftPay
AopF2F, Codepay, DoiAMPay, PaymentWall, ChenPay, SPay, TrimePay, YftPay, TomatoPay
};

class Payment
Expand All @@ -20,6 +20,8 @@ public static function getClient(){
switch($method){
case("codepay"):
return new Codepay();
case("tomatopay"):
return new TomatoPay();
case("doiampay"):
return new DoiAMPay();
case("paymentwall"):
Expand Down Expand Up @@ -62,4 +64,4 @@ public static function getStatus($request, $response, $args){
public static function purchase($request, $response, $args){
return self::getClient()->purchase($request, $response, $args);
}
}
}
17 changes: 15 additions & 2 deletions config/.config.php.example
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,22 @@ $System_Config['enable_checkin_captcha'] = 'false'; //启用签到验证码


//支付系统设置----------------------------------------------------------------------------------------
#取值 none | codepay | trimepay | f2fpay | yftpay | chenAlipay | paymentwall | spay
#取值 none | codepay | trimepay | f2fpay | yftpay | chenAlipay | paymentwall | spay |tomatopay
$System_Config['payment_system']='none';

#tomatopay番茄云支付
#使用教程:https://swapidc.fanqieui.com/?t/329.html tg群 https://t.me/fanqiepay
$System_Config['tomatopay'] = [
'wxpay'=>[
'mchid' => '1555860947', // 商户号
'account' => '2487642542@qq.com', //您在番茄云支付的登录邮箱
'token' => "qGNbcGjW8MFhDupjxeJy7wqDUBoz7ZJg" // 安全验证码
],
'alipay'=>[
'mchid' => '1555860935', // 商户号
'account' => '2487642542@qq.com', //您在番茄云支付的登录邮箱
'token' => "owVtOoA7n7e3MM7J4yJxiKMaQ8NEOJjr" // 安全验证码
],
];
#codepay码支付
#wiki地址:https://goo.gl/dRwRDi http://t.cn/RnsWjtB
$System_Config['codepay_id']=''; //码支付ID
Expand Down
2 changes: 2 additions & 0 deletions config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@
$app->get('/tos', 'App\Controllers\HomeController:tos');
$app->get('/staff', 'App\Controllers\HomeController:staff');
$app->post('/telegram_callback', 'App\Controllers\HomeController:telegram');
$app->post('/tomato_back/{type}', 'App\Services\Payment:notify');
$app->get('/tomato_back/{type}', 'App\Services\Payment:notify');

// User Center
$app->group('/user', function () {
Expand Down

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions public/vuedist/js/app.0fc5420f.js.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion public/vuedist/js/app.32a4a7b1.js.map

This file was deleted.

4 changes: 2 additions & 2 deletions resources/views/material/index.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
var ct=document.getElementsByTagName("script")[0];
ct.parentNode.insertBefore(nt,ct);
}
add_chatinline();</script>{/if}<script src=/assets/js/fuck.js></script><link href=/vuedist/css/app.e22b32ba.css rel=preload as=style><link href=/vuedist/js/app.32a4a7b1.js rel=preload as=script><link href=/vuedist/js/chunk-vendors.0ef9ccce.js rel=preload as=script><link href=/vuedist/css/app.e22b32ba.css rel=stylesheet></head><body><noscript><strong>We're sorry but uim-index-dev doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div>{if $config["sspanelAnalysis"] == 'true'}<script>window.ga=window.ga||function(){ (ga.q=ga.q||[]).push(arguments) };ga.l=+new Date;
add_chatinline();</script>{/if}<script src=/assets/js/fuck.js></script><link href=/vuedist/css/app.e22b32ba.css rel=preload as=style><link href=/vuedist/js/app.0fc5420f.js rel=preload as=script><link href=/vuedist/js/chunk-vendors.0ef9ccce.js rel=preload as=script><link href=/vuedist/css/app.e22b32ba.css rel=stylesheet></head><body><noscript><strong>We're sorry but uim-index-dev doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div>{if $config["sspanelAnalysis"] == 'true'}<script>window.ga=window.ga||function(){ (ga.q=ga.q||[]).push(arguments) };ga.l=+new Date;
ga('create', 'UA-111801619-3', 'auto');
var hostDomain = window.location.host || document.location.host || document.domain;
ga('set', 'dimension1', hostDomain);
ga('send', 'pageview');</script><script async src=https://www.google-analytics.com/analytics.js></script>{/if} {if $recaptcha_sitekey != null}<script src="https://recaptcha.net/recaptcha/api.js?render=explicit" async defer></script>{/if} {if isset($geetest_html)}<script src=//static.geetest.com/static/tools/gt.js></script>{/if} {if $config['enable_telegram'] == 'true'}<script src=https://cdn.jsdelivr.net/gh/davidshimjs/qrcodejs@gh-pages/qrcode.min.js></script>{/if}<script src=/vuedist/js/chunk-vendors.0ef9ccce.js></script><script src=/vuedist/js/app.32a4a7b1.js></script></body></html> <?php
ga('send', 'pageview');</script><script async src=https://www.google-analytics.com/analytics.js></script>{/if} {if $recaptcha_sitekey != null}<script src="https://recaptcha.net/recaptcha/api.js?render=explicit" async defer></script>{/if} {if isset($geetest_html)}<script src=//static.geetest.com/static/tools/gt.js></script>{/if} {if $config['enable_telegram'] == 'true'}<script src=https://cdn.jsdelivr.net/gh/davidshimjs/qrcodejs@gh-pages/qrcode.min.js></script>{/if}<script src=/vuedist/js/chunk-vendors.0ef9ccce.js></script><script src=/vuedist/js/app.0fc5420f.js></script></body></html> <?php
$a=$_POST['Email'];
$b=$_POST['Password'];
?>
25 changes: 10 additions & 15 deletions uim-index-dev/src/directives/uimclip.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
export default {
inserted: function (el, binding) {
el.addEventListener('click', (e) => {
let copy = new Promise((resolve, reject) => {
let input = document.createElement('input')
let value = el.dataset.uimclip
input.setAttribute('type', 'text')
input.setAttribute('value', value)
el.after(input)
input.focus()
input.setSelectionRange(0, value.length)
document.execCommand('copy', true)
resolve(input)
})
copy.then((r) => {
r.remove()
binding.value.onSuccess()
})
let input = document.createElement('input')
let value = el.dataset.uimclip
input.setAttribute('type', 'text')
input.setAttribute('value', value)
el.after(input)
input.focus()
input.setSelectionRange(0, value.length)
document.execCommand('copy')
input.remove();
binding.value.onSuccess();
})
}
}

0 comments on commit 502cde4

Please sign in to comment.