Tree 1 mēnesi atpakaļ
vecāks
revīzija
0c4b559264

+ 101 - 0
app/Http/Controllers/Api/AiPayController.php

@@ -0,0 +1,101 @@
+<?php
+
+namespace App\Http\Controllers\Api;
+
+use App\Http\logic\api\AiPayCashierLogic;
+use App\Http\logic\api\AiPayLogic;
+use App\Inter\PayMentInterFace;
+use App\Notification\TelegramBot;
+use App\Services\AiPay;
+use App\Util;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Redis;
+
+class AiPayController implements PayMentInterFace
+{
+    private $retryTimes = 0;
+
+    public function pay_order($userId, $payAmt, $userName, $userEmail, $userPhone, $GiftsID, $buyIP, $AdId, $eventType, $pay_method = '')
+    {
+        $logic = new AiPayLogic();
+        try {
+            $res = $logic->pay_order($userId, $payAmt, $userPhone, $userEmail, $userName, $GiftsID, $buyIP, $AdId, $eventType, $pay_method);
+        } catch (\Throwable $exception) {
+            Redis::set('PayErro_AiPay', 1, 'EX', 600);
+            Util::WriteLog('AiPay_error', $exception->getMessage());
+            TelegramBot::getDefault()->sendProgramNotify('AiPay pay_order exception', $exception->getMessage(), $exception);
+            return apiReturnFail($logic->getError());
+        }
+
+        if (isset($res['code']) && (int)$res['code'] === 0) {
+            $data = [
+                'content' => $res['data']['payUrl'] ?? '',
+                'money' => $payAmt,
+                'prdOrdNo' => $res['data']['sysOrderNo'] ?? '',
+            ];
+            return apiReturnSuc($data);
+        }
+
+        if ($res === false) {
+            return apiReturnFail($logic->getError());
+        }
+
+        if ($this->retryTimes > 0) {
+            Redis::set('PayErro_AiPay', 1, 'EX', 600);
+            TelegramBot::getDefault()->sendProgramNotify('AiPay pay_order failed', json_encode($res));
+            return apiReturnFail($logic->getError());
+        }
+
+        $this->retryTimes++;
+        return $this->pay_order($userId, $payAmt, $userName, $userEmail, $userPhone, $GiftsID, $buyIP, $AdId, $eventType, $pay_method);
+    }
+
+    public function notify(Request $request)
+    {
+        $post = $request->all();
+        Util::WriteLog('AiPay', 'pay notify: ' . json_encode($post, JSON_UNESCAPED_UNICODE));
+
+        $service = new AiPay();
+        if (!$service->verify($post)) {
+            Util::WriteLog('AiPay', 'pay notify verify failed');
+            return 'fail';
+        }
+
+        $logic = new AiPayLogic();
+        try {
+            return $logic->notify($post);
+        } catch (\Throwable $exception) {
+            Redis::set('PayErro_AiPay', 1, 'EX', 600);
+            //TelegramBot::getDefault()->sendProgramNotify('AiPay notify exception', json_encode($post), $exception);
+            return '{"success":false,"message":"internal error"}';
+        }
+    }
+
+    public function sync_notify(Request $request)
+    {
+        Util::WriteLog('AiPay', 'sync callback: ' . json_encode($request->all(), JSON_UNESCAPED_UNICODE));
+        return 'success';
+    }
+
+    public function cash_notify(Request $request)
+    {
+        $post = $request->all();
+        Util::WriteLog('AiPay', 'cash notify: ' . json_encode($post, JSON_UNESCAPED_UNICODE));
+
+        $service = new AiPay('AiPayOut');
+
+        if (!$service->verify($post)) {
+            Util::WriteLog('AiPay', 'cash notify verify failed');
+            return 'fail';
+        }
+
+        $logic = new AiPayCashierLogic();
+        try {
+            return $logic->notify($post);
+        } catch (\Throwable $exception) {
+            TelegramBot::getDefault()->sendProgramNotify('AiPay cash notify exception', json_encode($post), $exception);
+            return '{"success":false,"message":"internal error"}';
+        }
+    }
+}
+

+ 256 - 0
app/Http/logic/api/AiPayCashierLogic.php

@@ -0,0 +1,256 @@
+<?php
+
+namespace App\Http\logic\api;
+
+use App\dao\Estatisticas\RechargeWithDraw;
+use App\Http\helper\NumConfig;
+use App\Inter\CashierInterFace;
+use App\Models\PrivateMail;
+use App\Models\RecordUserDataStatistics;
+use App\Services\AiPay;
+use App\Services\StoredProcedure;
+use App\Util;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Log;
+use Illuminate\Support\Facades\Redis;
+
+class AiPayCashierLogic implements CashierInterFace
+{
+    const AGENT = 101;
+    protected $agent = 101;
+
+    public function payment($RecordID, $amount, $accountName, $phone, $email, $OrderId, $PixNum, $PixType, $IFSCNumber, $BranchBank, $BankNO)
+    {
+        $query = DB::connection('write')->table('QPAccountsDB.dbo.OrderWithDraw')->where('RecordID', $RecordID)->first();
+        if (!$query) {
+            return 'fail';
+        }
+
+        $service = new AiPay('AiPayOut');
+        $config = $service->getConfig();
+
+        $paymentMethod = $this->resolvePaymentMethod($PixType);
+        $accountData = $this->buildAccountData($paymentMethod, $accountName, $PixNum, $email, $phone, $IFSCNumber, $BranchBank, $BankNO);
+
+        if ($paymentMethod === null || empty($accountData)) {
+            Util::WriteLog('AiPay', 'unsupported PixType for withdraw: ' . $PixType);
+            return 'fail';
+        }
+
+        $amountDecimal = number_format($amount / NumConfig::NUM_VALUE, 2, '.', '');
+
+        $params = [
+            'mchNo' => $config['mchNo'] ?? '',
+            'mchOrderNo' => $OrderId,
+            'paymentMethod' => $paymentMethod,
+            'amount' => $amountDecimal,
+            'notifyUrl' => $config['cashNotify'] ?? '',
+            'timestamp' => (string)round(microtime(true) * 1000),
+            'accountData' => $accountData,
+        ];
+
+        $signedParams = $service->sign($params);
+        $result = $service->post('/api/transfer', $signedParams);
+
+        Log::info('AiPay withdraw request', $signedParams);
+        Log::info('AiPay withdraw response', [$result]);
+
+        try {
+            $data = \GuzzleHttp\json_decode($result, true);
+        } catch (\Throwable $e) {
+            Util::WriteLog('AiPay_error', $e->getMessage());
+            return 'fail';
+        }
+
+        if (isset($data['code']) && (int)$data['code'] === 0) {
+            return $data;
+        }
+
+        return 'fail';
+    }
+
+    public function notify($post)
+    {
+        if (!is_array($post)) {
+            $post = \GuzzleHttp\json_decode($post, true);
+        }
+
+        Util::WriteLog('AiPay', 'cash callback: ' . json_encode($post, JSON_UNESCAPED_UNICODE));
+
+        $OrderId = $post['mchOrderNo'] ?? '';
+        $query = DB::connection('write')->table('QPAccountsDB.dbo.OrderWithDraw')->where('OrderId', $OrderId)->first();
+        if (!$query) {
+            Util::WriteLog('AiPay', 'withdraw order not found: ' . $OrderId);
+            return '{"success":true,"message":"order not found"}';
+        }
+
+        if (!in_array($query->State, [5, 7])) {
+            Util::WriteLog('AiPay', $OrderId . ' already handled');
+            return 'success';
+        }
+
+        $agentID = DB::connection('write')->table('agent.dbo.admin_configs')
+            ->where('config_value', self::AGENT)
+            ->where('type', 'cash')
+            ->value('id') ?? '';
+
+        $status = (int)($post['status'] ?? 0);
+        $now = now();
+        $withdraw_data = [];
+        $notifyState = 0;
+        $msg = $post['msg'] ?? '';
+
+        $TakeMoney = $query->WithDraw + $query->ServiceFee;
+        $UserID = $query->UserID;
+
+        switch ($status) {
+            case 3: // success
+                $withdraw_data = [
+                    'State' => 2,
+                    'agent' => $agentID,
+                    'finishDate' => $now,
+                ];
+                $this->handleSuccess($UserID, $TakeMoney, $OrderId, $query->ServiceFee);
+                $notifyState = 1;
+                break;
+
+            case 4: // fail
+            case 5: // reversal
+                $msg = $msg ?: 'Withdraw rejected';
+                $bonus = '30000,' . $TakeMoney;
+                PrivateMail::failMail($UserID, $OrderId, $TakeMoney, $msg, $bonus);
+                Util::WriteLog('AiPayEmail', [$UserID, $OrderId, $TakeMoney, $msg, $bonus]);
+                $withdraw_data = ['State' => 6, 'agent' => $agentID, 'remark' => $msg];
+                $notifyState = 2;
+                break;
+
+            default:
+                Util::WriteLog('AiPay', 'cash notify pending: ' . $OrderId);
+                return 'success';
+        }
+
+        $recordData = [
+            'before_state' => $query->State,
+            'after_state' => $withdraw_data['State'] ?? $query->State,
+            'RecordID' => $query->RecordID,
+            'update_at' => date('Y-m-d H:i:s'),
+        ];
+
+        DB::connection('write')->table('QPAccountsDB.dbo.AccountsRecord')
+            ->updateOrInsert(['RecordID' => $query->RecordID, 'type' => 1], $recordData);
+        DB::connection('write')->table('QPAccountsDB.dbo.OrderWithDraw')
+            ->where('OrderId', $OrderId)
+            ->update($withdraw_data);
+
+        return 'success';
+    }
+
+    protected function resolvePaymentMethod($PixType): ?string
+    {
+        $map = [
+            1 => '1201', // CashApp
+            2 => '1202', // PayPal
+            3 => '1203', // Venmo
+            4 => '1204', // CARD
+        ];
+
+        return $map[$PixType] ?? null;
+    }
+
+    protected function buildAccountData(?string $paymentMethod, $accountName, $PixNum, $email, $phone, $IFSCNumber, $BranchBank, $BankNO): array
+    {
+        $splitName = $this->splitName($accountName);
+
+        switch ($paymentMethod) {
+            case '1201':
+                $account = $PixNum ?: $phone;
+                if ($account && strpos($account, '$') !== 0) {
+                    $account = '$' . $account;
+                }
+                return ['account' => $account];
+
+            case '1202':
+            case '1203':
+                return [
+                    'account' => $email ?: $PixNum,
+                    'firstName' => $splitName['first'],
+                    'lastName' => $splitName['last'],
+                ];
+
+            case '1204':
+                return [
+                    'cardNo' => $PixNum ?: $BankNO,
+                    'cardExpireMonth' => $this->extractMonth($BranchBank),
+                    'cardExpireYear' => $this->extractYear($BranchBank),
+                    'cardSecurityCode' => substr($IFSCNumber ?? '', 0, 4),
+                    'cardBrand' => 'visa',
+                    'firstName' => $splitName['first'],
+                    'lastName' => $splitName['last'],
+                ];
+        }
+
+        return [];
+    }
+
+    protected function splitName($name): array
+    {
+        $name = trim($name ?: 'User');
+        $parts = preg_split('/\s+/', $name, 2);
+        return [
+            'first' => $parts[0] ?? 'User',
+            'last' => $parts[1] ?? ($parts[0] ?? 'User'),
+        ];
+    }
+
+    protected function extractMonth($value): string
+    {
+        if (preg_match('/(\d{2})/', (string)$value, $match)) {
+            return $match[1];
+        }
+        return '01';
+    }
+
+    protected function extractYear($value): string
+    {
+        if (preg_match('/(\d{2,4})/', (string)$value, $match)) {
+            return substr($match[1], -2);
+        }
+        return '25';
+    }
+
+    protected function handleSuccess($UserID, $TakeMoney, $OrderId, $serviceFee): void
+    {
+        $first = DB::connection('write')->table('QPAccountsDB.dbo.UserTabData')->where('UserID', $UserID)->first();
+        if ($first) {
+            DB::connection('write')->table('QPAccountsDB.dbo.UserTabData')->where('UserID', $UserID)->increment('TakeMoney', $TakeMoney);
+        } else {
+            DB::connection('write')->table('QPAccountsDB.dbo.UserTabData')->insert(['TakeMoney' => $TakeMoney, 'UserID' => $UserID]);
+            try {
+                PrivateMail::praiseSendMail($UserID);
+            } catch (\Throwable $e) {
+                // ignore mail failure
+            }
+        }
+
+        try {
+            StoredProcedure::addPlatformData($UserID, 4, $TakeMoney);
+        } catch (\Throwable $exception) {
+            Util::WriteLog('StoredProcedure', $exception->getMessage());
+        }
+
+        $withdrawal_position_log = DB::connection('write')->table('agent.dbo.withdrawal_position_log')->where('order_sn', $OrderId)->first();
+        if ($withdrawal_position_log) {
+            DB::connection('write')->table('agent.dbo.withdrawal_position_log')
+                ->where('order_sn', $OrderId)
+                ->update(['take_effect' => 2, 'update_at' => date('Y-m-d H:i:s')]);
+        }
+
+        RecordUserDataStatistics::updateOrAdd($UserID, $TakeMoney, 0, $serviceFee);
+        (new RechargeWithDraw())->withDraw($UserID, $TakeMoney);
+        $redis = Redis::connection();
+        $redis->incr('draw_' . date('Ymd') . $UserID);
+
+        StoredProcedure::user_label($UserID, 2, $TakeMoney);
+    }
+}
+

+ 167 - 0
app/Http/logic/api/AiPayLogic.php

@@ -0,0 +1,167 @@
+<?php
+
+namespace App\Http\logic\api;
+
+use App\dao\Pay\AccountPayInfo;
+use App\dao\Pay\PayController;
+use App\Facade\TableName;
+use App\Http\helper\CreateOrder;
+use App\Http\helper\NumConfig;
+use App\Jobs\Order as OrderJob;
+use App\Notification\TelegramBot;
+use App\Services\AiPay;
+use App\Services\OrderServices;
+use App\Services\PayConfig;
+use App\Services\CreateLog;
+use App\Util;
+use Illuminate\Support\Facades\DB;
+
+class AiPayLogic extends BaseApiLogic
+{
+    public $result;
+
+    public function pay_order($userId, $pay_amount, $userPhone, $userEmail, $userName, $GiftsID, $buyIP, $AdId, $eventType, $pay_method = '')
+    {
+        $dao = new AccountPayInfo();
+        [$userPhone, $userName, $userEmail] = $dao->payInfo($userId);
+
+        $PayVerify = new PayController();
+        if ($PayVerify->verify($userId, $GiftsID, $pay_amount) === false) {
+            $this->error = $PayVerify->getError();
+            return false;
+        }
+        if ($pay_amount < 0) {
+            $this->error = 'Payment error_4';
+            return false;
+        }
+
+        $service = new AiPay();
+        $config = $service->getConfig();
+
+        $order_sn = CreateOrder::order_sn($userId);
+        $orderLogic = new OrderLogic();
+        $amountInt = (int) round($pay_amount * NumConfig::NUM_VALUE);
+        $orderLogic->orderCreate($order_sn, $amountInt, 'AiPay', $userId, '', $GiftsID, $AdId, $eventType);
+
+        $methodMap = [
+            1 => '1101',
+            2 => '1102',
+            4 => '1103',
+            8 => '1104',
+        ];
+        $paymentMethod = $methodMap[$pay_method] ?? ($config['paymentMethod'] ?? '1101');
+
+        $params = [
+            'mchNo' => $config['mchNo'] ?? '',
+            'mchOrderNo' => $order_sn,
+            'paymentMethod' => (string)$paymentMethod,
+            'amount' => number_format($pay_amount, 2, '.', ''),
+            'notifyUrl' => $config['notify'] ?? '',
+            'returnUrl' => $config['return'] ?? '',
+            'clientId' => (string)$userId,
+            'clientIp' => $buyIP,
+            'timestamp' => (string)round(microtime(true) * 1000),
+        ];
+
+//        if (!empty($config['accountData']) && is_array($config['accountData'])) {
+//            $params['accountData'] = $config['accountData'];
+//        }
+
+        $signedParams = $service->sign($params);
+        CreateLog::pay_request($userPhone, json_encode($signedParams), $order_sn, $userEmail, $userId, $userName);
+
+        $response = $service->post('/api/payment', $signedParams);
+        Util::WriteLog('AiPay', 'pay request => ' . json_encode($signedParams, JSON_UNESCAPED_UNICODE));
+        Util::WriteLog('AiPay', 'pay response => ' . $response);
+
+        try {
+            $data = \GuzzleHttp\json_decode($response, true);
+        } catch (\Throwable $e) {
+            Util::WriteLog('AiPay_error', $e->getMessage());
+            $this->error = 'Payment processing error';
+            return false;
+        }
+
+        if (!isset($data['code']) || (int)$data['code'] !== 0) {
+            $this->error = $data['msg'] ?? 'Payment request failed';
+        }
+
+        return $data;
+    }
+
+    public function notify(array $post)
+    {
+        $order_sn = $post['mchOrderNo'] ?? '';
+        if (!$order_sn) {
+            return '{"success":false,"message":"missing order"}';
+        }
+
+        $order = DB::connection('write')->table('agent.dbo.order')->where('order_sn', $order_sn)->first();
+        if (!$order) {
+            Util::WriteLog('AiPay', 'order not found: ' . $order_sn);
+            return '{"success":false,"message":"order not found"}';
+        }
+
+        if (!empty($order->pay_at) && !empty($order->finished_at)) {
+            return 'success';
+        }
+
+        $status = (int)($post['status'] ?? 0);
+        $payAmt = (float)($post['actualAmount'] ?? $post['amount'] ?? 0);
+
+        $body = [
+            'payment_sn' => $post['sysOrderNo'] ?? '',
+            'updated_at' => date('Y-m-d H:i:s'),
+        ];
+
+        $GiftsID = $order->GiftsID ?: '';
+        $userID = $order->user_id ?: '';
+        $AdId = $order->AdId ?: '';
+        $eventType = $order->eventType ?: '';
+
+        switch ($status) {
+            case 3:
+                $body['pay_status'] = 1;
+                $body['pay_at'] = date('Y-m-d H:i:s');
+                $body['finished_at'] = date('Y-m-d H:i:s');
+                $body['amount'] = (int) round($payAmt * NumConfig::NUM_VALUE);
+
+                $config = (new PayConfig())->getConfig('AiPay');
+                if (!empty($config['payin_fee'])) {
+                    $body['payment_fee'] = $body['amount'] * (float)$config['payin_fee'];
+                }
+
+                try {
+                    $service = new OrderServices();
+                    if ((int)$order->amount !== $body['amount']) {
+                        $body['GiftsID'] = 0;
+                        $Recharge = $payAmt;
+                        $give = 0;
+                        $favorable_price = $Recharge;
+                        $czReason = 1;
+                        $cjReason = 45;
+                    } else {
+                        [$give, $favorable_price, $Recharge, $czReason, $cjReason] = $service->getPayInfo($GiftsID, $userID, $payAmt);
+                    }
+                    [$Score] = $service->addRecord($userID, $payAmt, $favorable_price, $order_sn, $GiftsID, $Recharge, $czReason, $give, $cjReason, $AdId, $eventType);
+                    OrderJob::dispatch([$userID, $payAmt, $Score, $favorable_price, $GiftsID, $order_sn]);
+                } catch (\Throwable $exception) {
+                    Util::WriteLog('AiPay_error', $exception->getMessage());
+                    TelegramBot::getDefault()->sendProgramNotify('AiPay notify error', $exception->getMessage(), $exception);
+                }
+                break;
+
+            case 4:
+                $body['pay_status'] = 2;
+                break;
+
+            default:
+                return 'fail';
+        }
+
+        DB::connection('write')->table('agent.dbo.order')->where('order_sn', $order_sn)->update($body);
+
+        return 'success';
+    }
+}
+

+ 118 - 0
app/Services/AiPay.php

@@ -0,0 +1,118 @@
+<?php
+
+namespace App\Services;
+
+use App\Util;
+use Exception;
+
+class AiPay
+{
+    protected $config;
+    protected $key;
+    protected $baseUrl;
+
+    public function __construct(string $configKey = 'AiPay')
+    {
+        $payConfigService = new PayConfig();
+        $this->config = $payConfigService->getConfig($configKey);
+        $this->key = $this->config['key'] ?? '';
+        $this->baseUrl = rtrim($this->config['apiUrl'] ?? 'https://api.7aipay.com', '/');
+    }
+
+    public function getConfig(): array
+    {
+        return $this->config;
+    }
+
+    public function sign(array $params): array
+    {
+        $params['sign'] = $this->generateSign($params);
+        return $params;
+    }
+
+    public function verify(array $params): bool
+    {
+        if (!isset($params['sign'])) {
+            return false;
+        }
+        $sign = strtoupper($params['sign']);
+        unset($params['sign']);
+
+        return $sign === $this->generateSign($params);
+    }
+
+    public function post(string $path, array $payload)
+    {
+        $url = $this->baseUrl . $path;
+        $body = json_encode($payload, JSON_UNESCAPED_UNICODE);
+        $headers = [
+            'Content-Type: application/json;charset=UTF-8',
+            'version: 2',
+        ];
+
+        $ch = curl_init();
+        curl_setopt($ch, CURLOPT_URL, $url);
+        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
+        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+        curl_setopt($ch, CURLOPT_POST, 1);
+        curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
+        curl_setopt($ch, CURLOPT_TIMEOUT, 30);
+        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+
+        $result = curl_exec($ch);
+        if (curl_errno($ch)) {
+            Util::WriteLog('AiPay_error', 'CURL Error: ' . curl_error($ch));
+        }
+        curl_close($ch);
+        return $result;
+    }
+
+    protected function generateSign(array $params): string
+    {
+        $signParams = [];
+        foreach ($params as $key => $value) {
+            if ($key === 'sign' || $value === null || $value === '' || (is_array($value) && empty($value))) {
+                continue;
+            }
+            if (is_array($value)) {
+                $signParams[$key] = $this->buildObjectString($value);
+            } else {
+                $signParams[$key] = $value;
+            }
+        }
+
+        ksort($signParams);
+        $pairs = [];
+        foreach ($signParams as $key => $value) {
+            $pairs[] = $key . '=' . $value;
+        }
+        $stringA = implode('&', $pairs);
+        $stringSign = $stringA . '&key=' . $this->key;
+
+        return strtoupper(md5($stringSign));
+    }
+
+    protected function buildObjectString($data): string
+    {
+        if (is_array($data)) {
+            ksort($data);
+            $parts = [];
+            foreach ($data as $k => $v) {
+                if ($v === null || $v === '') {
+                    continue;
+                }
+                if (is_array($v)) {
+                    $parts[] = $k . '=' . $this->buildObjectString($v);
+                } else {
+                    $parts[] = $k . '=' . $v;
+                }
+            }
+            return implode('&', $parts);
+        }
+
+        return (string)$data;
+    }
+}
+

+ 4 - 0
app/Services/CashService.php

@@ -5,6 +5,7 @@ namespace App\Services;
 
 use App\Http\logic\api\WiwiPayCashierLogic;
 use App\Http\logic\api\WDPayCashierLogic;
+use App\Http\logic\api\AiPayCashierLogic;
 
 
 class CashService
@@ -20,6 +21,9 @@ class CashService
             case WDPayCashierLogic::AGENT:
                 return new WDPayCashierLogic();
 
+            case AiPayCashierLogic::AGENT:
+                return new AiPayCashierLogic();
+
         }
     }
 }

+ 4 - 0
app/Services/PayMentService.php

@@ -11,6 +11,7 @@ use App\Http\Controllers\Api\GoopagoController;
 use App\Http\Controllers\Api\SitoBankController;
 use App\Http\Controllers\Api\WiwiPayController;
 use App\Http\Controllers\Api\WDPayController;
+use App\Http\Controllers\Api\AiPayController;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Log;
 use Illuminate\Support\Facades\Redis;
@@ -28,6 +29,9 @@ class PayMentService
             case 'WDPay':
                 return new WDPayController();
 
+            case 'AiPay':
+                return new AiPayController();
+
 
             case 'apple':
                 return new AppleStorePayController();

+ 19 - 0
config/pay.php

@@ -63,4 +63,23 @@ return [
         'cashNotify' => env('APP_URL', '').'/api/wdpay/payout_notify',
         'return' => env('APP_URL', '').'/api/wdpay/return',
     ],
+
+    'AiPay' => [
+        'mchNo' => 'TEST2311609409',
+        'key' => 'v6jtjhsrPOBFh2YRAN89TnaTRJXJ7LC9nfcHuZQneyI=',
+        'apiUrl' => 'https://api.7aipay.com',
+        'currency' => 'USD',
+        'paymentMethod' => '1101',
+        'payin_fee' => 0.15,
+        'notify' => env('APP_URL', '').'/api/aipay/notify',
+        'return' => env('APP_URL', '').'/api/aipay/return',
+    ],
+
+    'AiPayOut' => [
+        'mchNo' => 'TEST2311609409',
+        'key' => 'v6jtjhsrPOBFh2YRAN89TnaTRJXJ7LC9nfcHuZQneyI=',
+        'apiUrl' => 'https://api.7aipay.com',
+        'currency' => 'USD',
+        'cashNotify' => env('APP_URL', '').'/api/aipay/payout_notify',
+    ],
 ];

+ 5 - 0
routes/api.php

@@ -306,6 +306,11 @@ Route::any('/wdpay/notify', 'Api\WDPayController@notify');
 Route::any('/wdpay/payout_notify', 'Api\WDPayController@cash_notify');
 Route::any('/wdpay/return', 'Api\WDPayController@sync_notify');
 
+// AiPay支付渠道
+Route::any('/aipay/notify', 'Api\AiPayController@notify');
+Route::any('/aipay/payout_notify', 'Api\AiPayController@cash_notify');
+Route::any('/aipay/return', 'Api\AiPayController@sync_notify');
+
 
 Route::any('/russia/notify', 'Api\RussiaPayController@notify');
 Route::any('/russia/cash_notify', 'Api\RussiaPayController@cash_notify');