43 行
1.6 KiB
PHP
43 行
1.6 KiB
PHP
<?php
|
|
define('APP_PATH', __DIR__ . '/../application/');
|
|
define('ROOT_PATH', __DIR__ . '/../');
|
|
require_once ROOT_PATH . 'thinkphp/base.php';
|
|
require_once ROOT_PATH . 'thinkphp/helper.php';
|
|
\think\Config::set(\think\Config::load(APP_PATH . 'config.php'));
|
|
\think\Config::set(include APP_PATH . 'database.php', 'database');
|
|
\think\Loader::addNamespace('app', APP_PATH);
|
|
\think\Loader::addNamespace('addons\\shopro', ROOT_PATH . 'addons/shopro/');
|
|
require_once ROOT_PATH . 'addons/shopro/helper/helper.php';
|
|
|
|
// 强制设置 epay 为 v3
|
|
set_addon_config('epay', ['version' => 'v3'], false);
|
|
|
|
require_once ROOT_PATH . 'addons/epay/Epay.php';
|
|
$epay = new \addons\epay\Epay();
|
|
$epay->actionBegin();
|
|
|
|
echo "Yansongda Pay loaded: " . (class_exists('\\Yansongda\\Pay\\Pay') ? 'YES' : 'NO') . PHP_EOL;
|
|
|
|
$order_data = [
|
|
'order_sn' => 'P' . date('YmdHis') . '0001',
|
|
'total_amount' => 0.01,
|
|
'description' => '测试订单',
|
|
'openid' => 'oUmhc3dnq-Z-f7GrVth17frJovX8',
|
|
];
|
|
|
|
$payService = new \addons\shopro\library\pay\PayService('wechat', 'WechatMiniProgram');
|
|
|
|
try {
|
|
$result = $payService->pay($order_data);
|
|
echo "Result Type: " . (is_object($result) ? get_class($result) : gettype($result)) . PHP_EOL;
|
|
echo "Result Raw:\n";
|
|
print_r($result);
|
|
echo "\nResult json_encode:\n" . json_encode($result, JSON_UNESCAPED_UNICODE) . PHP_EOL;
|
|
} catch (\Exception $e) {
|
|
echo "Exception: " . $e->getMessage() . PHP_EOL;
|
|
echo "File: " . $e->getFile() . ":" . $e->getLine() . PHP_EOL;
|
|
if (method_exists($e, 'getResponse')) {
|
|
echo "Response: " . json_encode($e->getResponse(), JSON_UNESCAPED_UNICODE) . PHP_EOL;
|
|
}
|
|
}
|