dficoins
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

82 lines
3.3 KiB

<?php
namespace App\Http\Controllers\Api\V1;
use App\Events\UserLoginEvent;
use App\Events\UserRegisterEvent;
use App\Exceptions\ApiException;
use App\Models\User;
use App\Services\UserService;
use App\Services\UserWalletService;
use Carbon\Carbon;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Jenssegers\Agent\Agent;
class UserPayController extends ApiController
{
public function index(){
//用户地址
$user = array([
'address' => 'TWvGPFXNBn8Eo4TdDKJayW6Kh7F95EKUC5',
'trans_amt' => '10',
'pingtai' => strtolower('trx'),
]);
$data=[
'mch_no'=>'113', //商户编号
'out_trade_no'=>'123456', //商户订单编号
'notify_url'=>'http://'.$_SERVER['HTTP_HOST'] . '/index/pay2/pay_withdraw_usdt',
'timestamp'=>time(), //时间戳
'rpay_type'=>'1', //服务类型:1:立即一次性支付;2:指定时间一次性支付;3:定期多次支付
'rpay_type_p'=>'1', //服务类型:1:空;2:指定时间比如:2021-09-22 00:00:00;3:{‘num’:’1’,‘unit’:’1/2/3,‘start’:’2021-09-22 00:00:00’}创建任务命令,num的数值范围由unit决定,unit=1表示小时、unit=2表示天、unit=3表示月,{‘action’:’cancel’,‘trade_no’:’TR20210716011811882308‘,’cancelType’:3}取消任务命令,连续2天无法支付成功系统会自动取消任务;定时定期的开始时间至少超出当前时间30秒
'users' => $user, //对象数组,对象结构如下
];
$key = "aa5e08f54ffa7d17fb7e311c84c42d47";
//排序
$sign_type = "mch_no={$data['mch_no']}&
notify_url={$data['notify_url']}&
out_trade_no={$data['out_trade_no']}&
rpay_type={$data['rpay_type']}&
rpay_type_p={$data['rpay_type_p']}&
timestamp={$data['timestamp']}&
users=[address={$user[0]['address']}&
pingtai={$user[0]['pingtai']}&
trans_amt={$user[0]['trans_amt']}]&
key=". $key;
$data['sign'] = strtolower(md5($sign_type));
$url = "https://www.usdtpay.online/myip.php";
echo 1;
$ret = $this->send_post($url,$data);
print_r($ret);
echo 2;
// $ret = json_decode($ret, true);
// print_r($ret);
}
public function send_post($url, $post_data) {
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-type: application/json"));
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($post_data));
curl_setopt($curl, CURLOPT_TIMEOUT, 60);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 100);
$output = curl_exec($curl);
print_r($output);
echo '**';
curl_close($curl);
return $output;
}
}